Enable Accelerated Compositing on the WebKit Android NDK port && Texture Mapper

http://www.dorothybrowser.com/enable-accelerated-compositing-on-the-webkit-android-ndk-port/


Enable Accelerated Compositing on the WebKit Android NDK port

As the previous articles said, our team ported the latest WebKit engine to the Android platform from scratch, and we named it WebKit Android NDK port. The project was to develop a web engine that conforms with WAC 2.0 based on the latest WebKit code, supports JS remote debugging and SVG, and enables various GPU accelerations on the Android platform. In this article I will tell you how we enabled the Accelerated Compositing on the port. I will also compare its rendering performance with the original Android port’s.

What is the Accelerated Compositing?

Web pages are composed of many layers to represent their contents, and browsers render each and every layer to the window on every repaint, iteratively. This means that the browser has to render all the layers of a page even if only a single layer has been changed.

We wanted to reduce unnecessary work with the Accelerated Compositing. The main idea was not to repaint the unchanged layer, but to render each layer to a prepared canvas, so that if a layer is changed, the browser repaints only the changed layer and composes it with the other pre-rendered layers. I recommend you read the Chromium blog article[1] for the more details.

What is the Texture Mapper?

As of porting it, there were several ports which implemented the Accelerated Compositing including Chromium, Mac and Qt. Our choice was the Texture Mapper, which was originally written by Qt. We chose it because first, it had the most simple structure and a clearly separated porting layer, so it was relatively easy to port it without structural changes. Second, Texture Mapper implementation was the only that directly uses OpenGL APIs, and does not depend on other graphics backend such as CoreGraphics. This was important for us because we didn’t want port huge graphics backend for this relatively tiny work. For the details of the Texture Mapper, read this Qt blog[2].

So what did we do?

We had to do three simple things to enable Texture Mapper-based Accelerated Compositing.

  1. we replaced the imagebuffer backend of the BitmapTexture with our own backend. BitmapTexture is an abstraction layer of OpenGL texture which is implemented using QImage and QPainter. We replaced it with SkBitmap and SkCanvas, because Android NDK port already uses Skia as its graphics backend.
  2. we ported the OpenGL based code to OpenGL-ES based one because the Android platform only provided OpenGL-ES.
  3. we implemented the TextureMapperLayerClient on the API layer. We had to implement few callback functions exposed to the API layer of Texture Mapper. These are mostly for synchronizing and drawing the composited layers which are the output of the Accelerated Compositing.

That’s all. Although we had to patch some bugs while we ported the Texture Mapper, it works perfectly with minimum effort. I believe the Texture Mapper is the easiest way to enable Accelerated Compositing on any port. Thanks to Qt guys!

How much does the Accelerated Compositing boost up?

You can see how the Accelerated Compositing boosts up the speed of HTML5 animations and transitions on the next video. This video compares the repainting speed of the default Android browser and the Android NDK port. The left side browser of the video is an Android default browser slightly modified to show its FPS for the comparison. Look at the FPSs on the top of both browsers!

 

As you can see, the Android NDK port shows up to 3 times higher FPS than the default browser in the test pages with heavy html5 animations. It is even up to 10 times faster in the last test.

References


1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。、资源 5来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。、资 5源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。
1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看REaDME.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值