D2D1_LAYER_OPTIONS enumeration (d2d1.h)

Specifies options that can be applied when a layer resource is applied to create a layer.

Note  Starting in Windows 8, the D2D1_LAYER_OPTIONS_INITIALIZE_FOR_CLEARTYPE option is no longer supported. See D2D1_LAYER_OPTIONS1 for Windows 8 layer options.
 

Syntax

typedef enum D2D1_LAYER_OPTIONS {
  D2D1_LAYER_OPTIONS_NONE = 0x00000000,
  D2D1_LAYER_OPTIONS_INITIALIZE_FOR_CLEARTYPE = 0x00000001,
  D2D1_LAYER_OPTIONS_FORCE_DWORD = 0xffffffff
} ;

Constants

 
D2D1_LAYER_OPTIONS_NONE
Value: 0x00000000
The text in this layer does not use ClearType antialiasing.
D2D1_LAYER_OPTIONS_INITIALIZE_FOR_CLEARTYPE
Value: 0x00000001
The layer renders correctly for ClearType text. If the render target is set to ClearType, the layer continues to render ClearType. If the render target is set to ClearType and this option is not specified, the render target will be set to render gray-scale until the layer is popped. The caller can override this default by calling SetTextAntialiasMode while within the layer. This flag is slightly slower than the default.
D2D1_LAYER_OPTIONS_FORCE_DWORD
Value: 0xffffffff

Remarks

ClearType antialiasing must use the current contents of the render target to blend properly. When a pushed layer requests initializing for ClearType, Direct2D copies the current contents of the render target into the layer so that ClearType antialiasing can be performed. Rendering ClearType text into a transparent layer does not produce the desired results.

A small performance hit from re-copying content occurs when ID2D1RenderTarget::Clear is called.

Examples

The following example shows how to use CreateLayer, PushLayer, and PopLayer. All fields in the D2D1_LAYER_PARAMETERS structure set to defaults, except opacityBrush, which is set to an ID2D1RadialGradientBrush.

// Create a layer.
ID2D1Layer *pLayer = NULL;
hr = pRT->CreateLayer(NULL, &pLayer);

if (SUCCEEDED(hr))
{
    pRT->SetTransform(D2D1::Matrix3x2F::Translation(300, 250));

    // Push the layer with the content bounds.
    pRT->PushLayer(
        D2D1::LayerParameters(
            D2D1::InfiniteRect(),
            NULL,
            D2D1_ANTIALIAS_MODE_PER_PRIMITIVE,
            D2D1::IdentityMatrix(),
            1.0,
            m_pRadialGradientBrush,
            D2D1_LAYER_OPTIONS_NONE),
        pLayer
        );

    pRT->DrawBitmap(m_pBambooBitmap, D2D1::RectF(0, 0, 190, 127));

    pRT->FillRectangle(
        D2D1::RectF(25.f, 25.f, 50.f, 50.f), 
        m_pSolidColorBrush
        );
    pRT->FillRectangle(
        D2D1::RectF(50.f, 50.f, 75.f, 75.f),
        m_pSolidColorBrush
        ); 
    pRT->FillRectangle(
        D2D1::RectF(75.f, 75.f, 100.f, 100.f),
        m_pSolidColorBrush
        );    
 
    pRT->PopLayer();
}
SafeRelease(&pLayer);

For additional examples, see the Layers Overview.

Requirements

Requirement Value
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]
Header d2d1.h

See also

Layers Overview