struct CCL::IGraphicsLayer
Overview
Graphics layers are surfaces which allow content to be rendered, transformed, and animated efficiently by the system compositor with hardware-accelleration if supported by the underlying platform. More…
#include <igraphicslayer.h> struct IGraphicsLayer: public CCL::IUnknown { // enums enum Modes; // methods virtual tresult CCL_API construct ( IUnknown* content, RectRef bounds = Rect (), int mode = 0, float contentScaleFactor = 1.f ) = 0; virtual tresult CCL_API setContent (IUnknown* content) = 0; virtual void CCL_API setOffset (PointRef offset) = 0; virtual void CCL_API setOffsetX (float offsetX) = 0; virtual void CCL_API setOffsetY (float offsetY) = 0; virtual void CCL_API setSize (Coord width, Coord height) = 0; virtual void CCL_API setMode (int mode) = 0; virtual void CCL_API setOpacity (float opacity) = 0; virtual void CCL_API setTransform (TransformRef transform) = 0; virtual void CCL_API setContentScaleFactor (float factor) = 0; virtual void CCL_API setUpdateNeeded () = 0; virtual void CCL_API setUpdateNeeded (RectRef rect) = 0; virtual IGraphicsLayer*CCL_API getParentLayer () = 0; virtual tresult CCL_API addSublayer (IGraphicsLayer* layer) = 0; virtual tresult CCL_API removeSublayer (IGraphicsLayer* layer) = 0; virtual tresult CCL_API placeAbove ( IGraphicsLayer* layer, IGraphicsLayer* sibling ) = 0; virtual tresult CCL_API placeBelow ( IGraphicsLayer* layer, IGraphicsLayer* sibling ) = 0; virtual IGraphicsLayer*CCL_API getNextSibling (IGraphicsLayer* layer) const = 0; virtual IGraphicsLayer*CCL_API getPreviousSibling (IGraphicsLayer* layer) const = 0; virtual tresult CCL_API addAnimation ( StringID propertyId, const IAnimation* animation ) = 0; virtual tresult CCL_API removeAnimation (StringID propertyId) = 0; virtual tbool CCL_API getPresentationProperty ( Variant& value, StringID propertyId ) const = 0; virtual tresult CCL_API flush () = 0; virtual void CCL_API suspendTiling (tbool suspend, const Rect* visibleRect) = 0; virtual void CCL_API setTileSize (int size) = 0; virtual void CCL_API setBackColor (const Color& color) = 0; DECLARE_STRINGID_MEMBER (kOpacity); };
Inherited Members
public: // methods virtual tresult CCL_API queryInterface (UIDRef iid, void** ptr) = 0; virtual unsigned int CCL_API retain () = 0; virtual unsigned int CCL_API release () = 0;
Detailed Documentation
Graphics layers are surfaces which allow content to be rendered, transformed, and animated efficiently by the system compositor with hardware-accelleration if supported by the underlying platform.
On Windows, layers are implemented via DirectComposition, and with Core Animation on macOS/iOS. On Linux, layers are implemented using wl_subsurface.
Graphics layers are rendered above any view elements that are not rendered as layer content. Layers can be nested. Sublayers are rendered above parent layers and previous siblings.
The position of a layer, relative to its parent, is determined by its offset.
Layers are always clipped at the window boundaries. Additional clipping behavior depends on Modes flags. When kClipToBounds is set, contents of the layer and all sublayers are clipped at the layer boundaries, determined by its size and offset.
While the layer’s offset affects the position of the layer itself, an additional transform can be used to rotate, translate, or scale the layer content. This transform does not affect the offset, size, or clipping rectangle of the layer.
Methods
virtual tresult CCL_API construct ( IUnknown* content, RectRef bounds = Rect (), int mode = 0, float contentScaleFactor = 1.f ) = 0
Construct a graphics layer.
The layer will become visible on screen in the next update cycle of the compositor or when flush is called.
Parameters:
content |
The initial layer content, either an IBitmap or an IGraphicsLayerContent implementation. |
bounds |
The boundaries of the layer. The top-left corner of this rect is used as the initial offset. Width and height of this rect determine the intial size. |
mode |
A combination of Modes flags. |
contentScaleFactor |
The initial content scale factor of the layer. |
virtual tresult CCL_API setContent (IUnknown* content) = 0
Set the layer content, either an IBitmap or an IGraphicsLayerContent implementation.
virtual void CCL_API setOffset (PointRef offset) = 0
Set the position of the layer, relative to its parent.
virtual void CCL_API setOffsetX (float offsetX) = 0
Set the horizontal position of the layer, relative to its parent.
virtual void CCL_API setOffsetY (float offsetY) = 0
Set the vertical position of the layer, relative to its parent.
virtual void CCL_API setSize (Coord width, Coord height) = 0
Set the size of the layer.
virtual void CCL_API setMode (int mode) = 0
Set mode flags, see Modes.
virtual void CCL_API setOpacity (float opacity) = 0
Set the opacity of the layer content.
virtual void CCL_API setTransform (TransformRef transform) = 0
Set a transform that is applied to the layer content.
virtual void CCL_API setContentScaleFactor (float factor) = 0
Set the points to pixels scaling factor.
virtual void CCL_API setUpdateNeeded () = 0
Invalidate the layer.
Multiple changes are collected and will become visible on screen in the next update cycle of the compositor or when flush is called.
virtual void CCL_API setUpdateNeeded (RectRef rect) = 0
Invalidate part of the layer.
Multiple changes are collected and will become visible on screen in the next update cycle of the compositor or when flush is called.
virtual IGraphicsLayer*CCL_API getParentLayer () = 0
Get the parent layer.
virtual tresult CCL_API addSublayer (IGraphicsLayer* layer) = 0
Add a sublayer.
New layers are always drawn on top of previous sublayers.
virtual tresult CCL_API removeSublayer (IGraphicsLayer* layer) = 0
Remove a sublayer.
If currently visible, the layer will become invisible in the next update cycle of the compositor or when flush is called.
virtual tresult CCL_API placeAbove ( IGraphicsLayer* layer, IGraphicsLayer* sibling ) = 0
Change layer order, so that the given child layer is drawn right after the given sibling.
virtual tresult CCL_API placeBelow ( IGraphicsLayer* layer, IGraphicsLayer* sibling ) = 0
Change layer order, so that the given child layer is drawn right before the given sibling.
virtual IGraphicsLayer*CCL_API getNextSibling (IGraphicsLayer* layer) const = 0
Get the sibling after the given child layer.
virtual IGraphicsLayer*CCL_API getPreviousSibling (IGraphicsLayer* layer) const = 0
Get the sibling before the given child layer.
virtual tresult CCL_API addAnimation ( StringID propertyId, const IAnimation* animation ) = 0
Add an animation.
virtual tresult CCL_API removeAnimation (StringID propertyId) = 0
Remove an animation.
virtual tbool CCL_API getPresentationProperty ( Variant& value, StringID propertyId ) const = 0
While an animation is running, get a property of the currently displayed state.
virtual tresult CCL_API flush () = 0
Commit pending changes to graphics hardware.
virtual void CCL_API suspendTiling (tbool suspend, const Rect* visibleRect) = 0
Stop using tiles for drawing, only paint into visibleRect instead.
virtual void CCL_API setTileSize (int size) = 0
Set tile size in points.
virtual void CCL_API setBackColor (const Color& color) = 0
Set background color.
DECLARE_STRINGID_MEMBER (kOpacity)
< float