1,295
edits
| Line 201: | Line 201: | ||
# The layer parameter to RenderedLayer::copyFrom must not be before this layer in a pre-order traversal of the layer tree. | # The layer parameter to RenderedLayer::copyFrom must not be before this layer in a pre-order traversal of the layer tree. | ||
Then we can have an immediate-mode layer implementation which works just like our current code. Rule 1 means that when we call beginDraw, everything before the RenderedLayer has already been drawn, and we know the final values of the properties controlling rendering of this layer and its ancestors. If conditions are right, i.e. the opacity of this layer is 1.0, transform is affine, etc, we can avoid creating a buffer for this layer, and just return a gfxContext that renders directly into some ancestor buffer. The fact that we don't have this layer's contents stored anywhere is reflected by setting the layer's valid region to empty at the end of the transaction. Rule 2 ensures that no other layer can try to use an already-drawn RenderedLayer as the source of a copy. | Then we can have an immediate-mode layer implementation which works just like our current code. Rule 1 means that when we call beginDraw, everything before the RenderedLayer has already been drawn, and we know the final values of the properties controlling rendering of this layer and its ancestors. If conditions are right, i.e. the opacity of this layer is 1.0, transform is affine, etc, we can avoid creating a buffer for this layer, and just return a gfxContext that renders directly into some ancestor buffer. The fact that we don't have this layer's contents stored anywhere is reflected by setting the layer's valid region to empty at the end of the transaction. Rule 2 ensures that no other layer can try to use an already-drawn RenderedLayer as the source of a copy. Using a layer later in the tree as a source is fine, it has no valid region so we just remove the copied from the destination's valid region. | ||
Note that rule 1 means you must add all children to a ContainerLayer before rendering into any of them, and in particular you must add a RenderedLayer to its parent before rendering into it. These constraints are easy enough for the display list subsystem to satisfy. | Note that rule 1 means you must add all children to a ContainerLayer before rendering into any of them, and in particular you must add a RenderedLayer to its parent before rendering into it. These constraints are easy enough for the display list subsystem to satisfy. | ||
edits