wiki:Accelerated rendering and compositing

Version 1 (modified by, 12 years ago) (diff)

Initial draft


  • Tree mania:

RenderObject RenderLayer z-order tree Graphicslayer tree PlatformLayer tree

  • Special considerations:

overlap clipping reflections video/webgl/plugins/etc. intersection

  • Accelerated drawing and compositing


Notion that identify elements in the web page that benefit from rendering to bitmap and using gpu to composite it with other elements in the page.

This is done through RenderLayer tree.

RenderLayer started as convenience for rendering certain objects. RenderLayer per element with its own coordinate system: overflow, scroll. transforms, and now video.

RenderTree with heirarchy of objs. And certain objs have renderlayer off of them. There is a renderlayer tree that mirrors render object tree.

paint root rl, then go through child rls, use rl for clipping and overflow. hit test through rls. reverse walk through child rls for hit testing.

another hierarchy of rls which is important, z-order tree. css props z-index, to move front-to-back ordering of pages. to support, z-order tree. before paint, compute z-order tree by going through rl tree, find stacking contexts. painting and hit-test use this z-order tree, not the rl tree.

compositing: z-order tree gives back-to-front ordering. use it to generate info about which was in front of what. in compositing, we can id rls that want to be composited, and create a backing store for.

if we make something composited, we render to backing store, then give it to teh gpu. rendered through opengl, probably. on top of regular content on page.

ensure that any elements in front of composited layers, are also composited. RenderLyaerCompositor, per renderview. manages hierarchy of layers and decides what needs to be a layer.

rl backing for each composited layer. rl backing creates 1+ gfx layers, glue between rendering and platform-compositing code.

each rl backing can create another gfx layer. clipping/masks/-z indexes. slice into multiple planes and create layers for clipping.

gfx layers are in their own tree. used by platform code to create platform layers (like corenimation).

gfx layers can have more than one platform layer: masks and reflections.

gfx layers have a way of dumping its tree, can get it from gdb.

test for overlap. RLCompositor list of rects of things that have been composited. Makes other layers composited if they intersect that list of rects.

clipping: div with overflow:hidden, child with transform or video. impl clipping via platform layer. on mac: calayer add masks to apply. if a layer is composited through clipping, it doesn't have its own backing store, paints into something behind it.

reflections: cloning layers, tracking clones. tricky.

special layers, because of content that benefits from composites. video, rendervideo gets renderlayer, becomes composited. communication between mac media player and comp code so that media player hand pl to comp code, and pl into compositing layer tree.

layer intersections: allows 3d transforms, to paint into a gl texture. If layers intersect (child through parent), break into subtextures along intersections.

hit test is done in software in RL code. hit testing should be same for all paltforms.

overlap map is updated when there is a layotu or style change that changes compositing layer tree.

special casing css animations. which transform animation is running, we don't updating clipping during animations. update at start and end, not during. don't change layout during. don't update scrollbars, for example. it's a cheat, but gives performance. opacity animation also.

overlap test is used if real 3d xforms are not present in page.

platforms have their own accel drawing impls. on mac, but compositing still has value when there is accel drawing, but depends on content. feedback from paltform code to tell RLCompositor when its valuable to do compositing or not.

  • plugins like flash force compositing.

how to debug

  • in safari, "show compositing borders"

every composited layer gets a border. the # represents # of times the layer has been repainted yellow, not green boxes have no css properties, so use just for geometry, and doesn't need a backing store. red needs a backing store.

do you see popping? something popping in front is probably composited.

blue outline: composited because it has overflow:hidden/scroll on it.

  • in gdb, debug only "call showLayerTree" any renderlayer tree. shows it as a z-order tree. prints whether rl is composited. says why something is a renderlayer. which GLs are associated with which RLs.
  • in inspector, turn on/off css properties. overflow, z-order, transforms. gmail bug case: command-c the dom into a fresh document, to give you a snapshot. although there was no css, the bug still repro'd.
  • in inspector, start deleting nodes.

text: on mac there is a limitation on gfx sys where rendering text on transparent background, can't do subpixel antialiasing. no good soln to this problem right now. if something is composited, but with opaque bg-color, then it's fine.

limitations on compositing: not smart when applying scale trasnforms. on mac, (scale:2) just blow up bitmap, looks fuzzy.

ms support: ie10 has transforms and animations. doing stuff with direct2d when dealing with scaling.

if we redid wk, would it based on compositing primitives instead of bitmap primitives? this lives under the platform layer. only ms has done this by throwing everything out and rebuilding with direct2d.

webcore lacks logic where knowing if elements up front obscure stuff behind it. right now it just repaints everything behind it from back-to-front.

svg compositing? doesn't use rl at all. split up rl, piece related to compositing needs to be something svg could use.