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.

IDCompositionDevice2::CreateSurfaceFactory method

Creates a Microsoft DirectComposition surface factory object, which can be used to create other DirectComposition surface or virtual surface objects


HRESULT CreateSurfaceFactory(
  [in]   IUnknown *renderingDevice,
  [out]  IDCompositionSurfaceFactory **surfaceFactory


renderingDevice [in]

A pointer to a DirectX device to be used to create DirectComposition surface objects. Must be a pointer to an object implementing the IDXGIDevice or ID2D1Device interfaces. This parameter must not be NULL.

surfaceFactory [out]

The newly created surface factory object. This parameter must not be NULL.

Return value

If the function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. See DirectComposition Error Codes for a list of error codes.


A surface factory allows an application to simultaneously use more than one single DXGI or Direct2D device with DirectComposition. Each surface factory has a permanent association with one DXGI or Direct2D device, but a DirectComposition device may have any number of surface factories.

Each surface factory manages resources independently from the others. In particular, DirectComposition pools surface allocations to mitigate surface allocation and deallocation costs. This pool is done on a per-surface factory basis.

If the DCompositionCreateDevice2 function is called with a non-NULL renderingDevice parameter, the returned DirectComposition device object has an implicit surface factory under the covers associated with the given rendering device. This implicit surface factory is used to service the IDCompositionDevice::CreateSurface, IDCompositionDevice::CreateVirtualSurface, IDCompositionDevice2::CreateSurface and IDCompositionDevice2::CreateVirtualSurface methods.

A surface object remains alive as long as any of the surfaces or virtual surfaces that it created remain alive, either directly because the application holds a direct reference, or indirectly because one or more such surfaces are associated with one or more visual objects.


Minimum supported client

Windows 8.1 [desktop apps only]

Minimum supported server

Windows Server 2012 R2 [desktop apps only]







See also




Community Additions

© 2014 Microsoft