Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

ID2D1RenderTarget::PushLayer method

Adds the specified layer to the render target so that it receives all subsequent drawing operations until PopLayer is called.


virtual void PushLayer(
  [inconst D2D1_LAYER_PARAMETERS *layerParameters,
  [in]       ID2D1Layer            *layer
) = 0;


layerParameters [in]


The content bounds, geometric mask, opacity, opacity mask, and antialiasing options for the layer.

layer [in]

Type: ID2D1Layer*

The layer that receives subsequent drawing operations.

Note  Starting with Windows 8, this parameter is optional. If a layer is not specified, Direct2D manages the layer resource automatically.

Return value

This method does not return a value.


The PushLayer method allows a caller to begin redirecting rendering to a layer. All rendering operations are valid in a layer. The location of the layer is affected by the world transform set on the render target.

Each PushLayer must have a matching PopLayer call. If there are more PopLayer calls than PushLayer calls, the render target is placed into an error state. If Flush is called before all outstanding layers are popped, the render target is placed into an error state, and an error is returned. The error state can be cleared by a call to EndDraw.

A particular ID2D1Layer resource can be active only at one time. In other words, you cannot call a PushLayer method, and then immediately follow with another PushLayer method with the same layer resource. Instead, you must call the second PushLayer method with different layer resources.

This method doesn't return an error code if it fails. To determine whether a drawing operation (such as PushLayer) failed, check the result returned by the ID2D1RenderTarget::EndDraw or ID2D1RenderTarget::Flush methods.


Minimum supported client

Windows 7, Windows Vista with SP2 and Platform Update for Windows Vista [desktop apps | UWP apps]

Minimum supported server

Windows Server 2008 R2, Windows Server 2008 with SP2 and Platform Update for Windows Server 2008 [desktop apps | UWP apps]

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]







See also

Layers Overview



© 2018 Microsoft