1,295
edits
No edit summary |
|||
| Line 1: | Line 1: | ||
Layer API Proposals | Layer API Proposals | ||
= Things we'd like to be able to do = | |||
* Accelerated compositing and scaling | * Accelerated compositing and scaling | ||
| Line 15: | Line 15: | ||
* Accelerated composition of content from multiple processes, including untrusted processes that may lack access to native accelerated graphics APIs | * Accelerated composition of content from multiple processes, including untrusted processes that may lack access to native accelerated graphics APIs | ||
= Requirements = | |||
* Should have an efficient software fallback | * Should have an efficient software fallback | ||
| Line 24: | Line 24: | ||
* Support VRAM management; we'd like to be able to discard buffers and re-render them when VRAM is full, including with fine granularity via a tile cache | * Support VRAM management; we'd like to be able to discard buffers and re-render them when VRAM is full, including with fine granularity via a tile cache | ||
= Open questions = | |||
* Should we build the layer tree if we are not hardware accelerated? | * Should we build the layer tree if we are not hardware accelerated? | ||
| Line 39: | Line 39: | ||
** Roc: child order. i.e. the nth child is beneath n+1th child | ** Roc: child order. i.e. the nth child is beneath n+1th child | ||
= Use case = | |||
Assume we have a webpage with a container containing some web content and a video. This container has a 3d-transform applied to it. What should the layer hierarchy look like? | Assume we have a webpage with a container containing some web content and a video. This container has a 3d-transform applied to it. What should the layer hierarchy look like? | ||
| Line 52: | Line 52: | ||
*** Retained content that's in front of the transformed container (not needed if there is no such content) | *** Retained content that's in front of the transformed container (not needed if there is no such content) | ||
= Roc = | |||
== Display list processing == | |||
Taking a step back, let me write down how I think layout and display lists could/should build and maintain a layer tree. | Taking a step back, let me write down how I think layout and display lists could/should build and maintain a layer tree. | ||
| Line 91: | Line 91: | ||
Implicit layers can also change size, need to be scrolled, etc. | Implicit layers can also change size, need to be scrolled, etc. | ||
== Proposal == | |||
=== LayerManager === | |||
Every layer belongs to a LayerManager. The idea is that a window will provide an associated LayerManager. (Documents being rendered by their own process will probably have their own LayerManagers.) Every layer in a layer tree must have the same LayerManager. | Every layer belongs to a LayerManager. The idea is that a window will provide an associated LayerManager. (Documents being rendered by their own process will probably have their own LayerManagers.) Every layer in a layer tree must have the same LayerManager. | ||
| Line 108: | Line 108: | ||
LayerManager::SetRoot sets a layer to be the root layer. This is how you get a layer to be displayed. | LayerManager::SetRoot sets a layer to be the root layer. This is how you get a layer to be displayed. | ||
=== Layer === | |||
Layer is the superclass of all layers. A Layer could be anything that can be rendered into a destination surface. It has methods to set various properties that affect the rendering of a layer into its parent: opacity, transform, filter, etc... (For simplicity I'm only showing 'opacity' here.) | Layer is the superclass of all layers. A Layer could be anything that can be rendered into a destination surface. It has methods to set various properties that affect the rendering of a layer into its parent: opacity, transform, filter, etc... (For simplicity I'm only showing 'opacity' here.) | ||
| Line 121: | Line 121: | ||
Layers should be referenced counted. The LayerManager holds a reference to its root layer and parent layers hold references to their children. | Layers should be referenced counted. The LayerManager holds a reference to its root layer and parent layers hold references to their children. | ||
=== RenderedLayer === | |||
A RenderedLayer is the basic leaf layer that you can render into using cairo/Thebes. | A RenderedLayer is the basic leaf layer that you can render into using cairo/Thebes. | ||
| Line 147: | Line 147: | ||
For scrolling and to enable intelligent reuse of parts of RenderedLayers by other layers... | For scrolling and to enable intelligent reuse of parts of RenderedLayers by other layers... | ||
=== ContainerLayer === | |||
class ContainerLayer { | class ContainerLayer { | ||
| Line 200: | Line 200: | ||
When we go to off-main-thread compositing we'll want to add support for animation and other stuff. For example we might want a YUVSeriesLayerBuilder that can select from a queue of timestamped frames based on the current time. The rendering property setters on LayerBuilder would be extended with animating setters that take a list of timestamped values, or perhaps the parameters of actual transition functions. | When we go to off-main-thread compositing we'll want to add support for animation and other stuff. For example we might want a YUVSeriesLayerBuilder that can select from a queue of timestamped frames based on the current time. The rendering property setters on LayerBuilder would be extended with animating setters that take a list of timestamped values, or perhaps the parameters of actual transition functions. | ||
= Jeff = | |||
Layers have two basic operations: | Layers have two basic operations: | ||
| Line 227: | Line 227: | ||
CoreAnimation will ask a layer to redraw it's contents at particular timestamp. The layer can choose to do so, or ignore the request. | CoreAnimation will ask a layer to redraw it's contents at particular timestamp. The layer can choose to do so, or ignore the request. | ||
== WebKit == | |||
Here are some observations on WebKit's implementation: | Here are some observations on WebKit's implementation: | ||
| Line 241: | Line 241: | ||
# One for the div - 100x100 | # One for the div - 100x100 | ||
= Bas = | |||
// Interface implemented by 'renderers'. This interface can for example | // Interface implemented by 'renderers'. This interface can for example | ||
// be implemented by Cairo(possibly with cairo-gl), OpenGL, Direct3D or | // be implemented by Cairo(possibly with cairo-gl), OpenGL, Direct3D or | ||
| Line 347: | Line 348: | ||
} | } | ||
= Integration with windowing systems = | |||
== Webkit/Coreanimmation == | |||
AppKit supports hosting a layer tree in a NSView using the following technique: | AppKit supports hosting a layer tree in a NSView using the following technique: | ||
| Line 360: | Line 361: | ||
If we set an animating div to have a z-index of -1, we seem to get a large texture and a bunch of tiles? | If we set an animating div to have a z-index of -1, we seem to get a large texture and a bunch of tiles? | ||
== Scrolling == | |||
What should we do to scroll? | What should we do to scroll? | ||
| Line 368: | Line 369: | ||
Anholt: destination tile cache sounds pretty nice to me, and with APPLE_object_purgeable use the GPU could throw things out of the cache when appropriate (rather than you having to guess). | Anholt: destination tile cache sounds pretty nice to me, and with APPLE_object_purgeable use the GPU could throw things out of the cache when appropriate (rather than you having to guess). | ||
= Comparison with other APIs = | |||
== CoreAnimation == | |||
=== Rendering Model === | |||
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CoreAnimation_guide/Articles/CoreAnimationArchitecture.html#//apple_ref/doc/uid/TP40006655 | http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CoreAnimation_guide/Articles/CoreAnimationArchitecture.html#//apple_ref/doc/uid/TP40006655 | ||
| Line 382: | Line 383: | ||
Having separate trees sort of corresponds to Roc's LayerBuilder infrastructure described above. | Having separate trees sort of corresponds to Roc's LayerBuilder infrastructure described above. | ||
=== Classes === | |||
CALayer - CALayer is the model class for layer-tree objects. It encapsulates the position, size, and transform of a layer, which defines its coordinate system. It also encapsulates the duration and pacing of a layer and its animations by adopting the CAMediaTiming protocol, which defines a layer’s time space. | CALayer - CALayer is the model class for layer-tree objects. It encapsulates the position, size, and transform of a layer, which defines its coordinate system. It also encapsulates the duration and pacing of a layer and its animations by adopting the CAMediaTiming protocol, which defines a layer’s time space. | ||
| Line 389: | Line 390: | ||
[http://developer.apple.com/mac/library/documentation/GraphicsImaging/Reference/CAShapeLayer_class/Reference/Reference.html#//apple_ref/occ/cl/CAShapeLayer CAShapeLayer] - Added in 10.6 presumably provides hardware accelerated rendering of paths | [http://developer.apple.com/mac/library/documentation/GraphicsImaging/Reference/CAShapeLayer_class/Reference/Reference.html#//apple_ref/occ/cl/CAShapeLayer CAShapeLayer] - Added in 10.6 presumably provides hardware accelerated rendering of paths | ||
== Clutter == | |||
ClutterActor - Every actor is a 2D surface positioned and optionally | ClutterActor - Every actor is a 2D surface positioned and optionally | ||
edits