Find file
Fetching contributors…
Cannot retrieve contributors at this time
14 lines (12 sloc) 7.16 KB
layout: post
title: "WebKitGTK+ hackfest wrapup: accelerated compositing"
date: 2011-12-08
comments: false
- Gnome
- Igalia
- WebKit
<div class='post'>
I just returned from this year's&nbsp;<a href="">WebKitGTK+ hackfest</a>. Not only was it the most productive hackfest to date, the diversity of the people involved was incredible. Attendees included hackers from Igalia, Collabora, RedHat and Motorola. It's great to be part of a company which can pull this kind of event together.<br /><br /><table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: left; margin-right: 1em; position: static; text-align: left; z-index: auto;"><tbody><tr><td style="text-align: center;"><span style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><a href=""><img alt="WebKitGTK+ 2011 Hackfest" height="160" src="" width="240" /></a></span></td></tr><tr><td class="tr-caption" style="text-align: center;"><a href="">Planning</a></td></tr></tbody></table>&nbsp;One of the things different about this hackfest were the <a href="">BoFs</a>, which were mainly planning sessions. The WebKitGTK+ community has shifted from a ragtag group of developers unafraid of <tt>g_object_ref</tt> and <tt>g_object_unref</tt> furiously hacking on a tiny WebKit port to an integral piece of the Gnome renaissance moving steadily toward ambitious goals. I'm obviously biased, but I believe the investment of small companies with strong ideals like <a href="">Igalia</a> and <a href="">Collabora</a> is directly responsible.&nbsp; <br /><br />Others have already reported on <a href="">some of the incredible work</a> at the hackfest including the <a href="">bold new Epiphany redesign</a>, <a href="">accessibility support for WebKit2</a>, and <a href="">JHBuild-ification</a>. I'd like to talk a bit about something in which I'm personally involved: <a href="">accelerated compositing</a>.<br /><br /><table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: right; margin-left: 1em; position: relative; text-align: right; z-index: 0;"><tbody><tr><td style="text-align: center;"><span style="clear: right; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><a href=""><img border="0" height="240" src="" width="320" /></a></span></td></tr><tr><td class="tr-caption" style="text-align: center;"><a href="">Epiphany's new look</a></td></tr></tbody></table>Accelerated compositing was introduced in 2009 with the bulk of the work provided by Apple and Google. GPUs are quite fast, but because of the overhead of moving bits from main main memory to GPU memory, <a href="">you need to use them intelligently to see any speedup</a>. Accelerated compositing is the smarts needed to use the GPU intelligently in WebKit. We're also trying to push these smarts down into painting libraries such as <a href="">Cairo</a> and <a href="">Skia</a>, but that's a more difficult task, with less immediate benefit. The best performance improvements come from using the GPU at the place that maintains the drawing state.<br /><br />In the context of WebKit, drawing state is the rendered page itself, with all its layered divs, canvas elements, video tags and WebGL contexts. WebKit stores elements to render in a data structure called the "<a href="">render tree</a>." Members of the the render tree which are drawn in main memory must be sent to the GPU to be displayed on the screen. Furthermore, some of these elements may be rendered on the GPU itself, so ideally we want to avoid copying them to main memory only to copy them back to the GPU at a later stage.<br /><br />CPUs are very fast, so it's often sufficient to rasterize things into main memory. On the other hand, when the entire page is rendered by the CPU, it spends a lot of time doing "boring" tasks that the GPU loves doing, such as compositing (blending images into each other). Accelerated compositing attacks this by slicing the page into layers of related content. The way this slicing works is a heuristic, but generally speaking divs at the same z-index, with the same CSS transform, WebGL contexts and hardware accelerated video are their own layer. It renders each of the non-GPU layers into an image and then uploads all the images to be composited by the GPU along with layers that are already there.<br /><br />Collabora, which created the Clutter port of WebKit has an implementation of accelerated compositing using Clutter. At the hackfest, Joone Hurr and Gustavo Noronha Silva started integrating this version into WebKitGTK+. The nice thing about the Clutter implementation is that it's almost complete. The unfortunate thing is that Clutter uses COGL which has very poor support for using raw OpenGL in the application. Obviously this means that the WebKitGTK+ port would need to rewrite it's WebGL backend. Igalia is also working on two implementations (OpenGL and the Cairo fallback) using No'am Rosenthal's very nice TextureMapper abstraction.<br /><br />During the hackfest, we decided to attempt to integrate all three approaches into the tree. The Clutter version is a nice stopgap for people who want to play with accelerated compositing or are using Clutter already. The intial parts of this implementation should be landing soon. Over the next few months we'll also be submitting OpenGL and Cairo versions of accelerated compositing. We already made great progress at the hackfest. If you're interested in following the work, you can follow the <a href="">accelerated compositing metabug</a>.<br /><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href=""><img border="0" src="" /></a></div><div class="separator" style="clear: both; text-align: center;"><a href=""><img border="0" src="" /></a></div><div class="separator" style="clear: both; text-align: center;"><a href=""><img border="0" height="104" src="" width="320" /></a></div></div>