ISurfaceImageSourceNativeWithD2D interface (

Provides the implementation of a shared Microsoft DirectX surface which is displayed in a SurfaceImageSource or VirtualSurfaceImageSource.


The ISurfaceImageSourceNativeWithD2D interface inherits from the IUnknown interface. ISurfaceImageSourceNativeWithD2D also has these types of members:


The ISurfaceImageSourceNativeWithD2D interface has these methods.


Initiates an update to the associated SurfaceImageSource or VirtualSurfaceImageSource.

The ISurfaceImageSourceNativeWithD2D::EndDraw method ( closes the surface draw operation.

Resume the drawing operation.

Sets the Microsoft DirectX Graphics Infrastructure (DXGI) or Direct2D device, created with D3D11_CREATE_DEVICE_BGRA_SUPPORT, that will draw the surface.

Suspends the drawing operation.


The ISurfaceImageSourceNativeWithD2D interface provides the native implementation of the SurfaceImageSource class. To get a pointer to the ISurfaceImageSourceNativeWithD2D interface, you must cast a SurfaceImageSource instance to IInspectable or IUnknown, and call the QueryInterface method.

Microsoft::WRL::ComPtr<ISurfaceImageSourceNativeWithD2D>	m_sisD2DNative;
// ...
IInspectable* sisInspectable = (IInspectable*) reinterpret_cast<IInspectable*>(surfaceImageSource);
sisInspectable->QueryInterface(__uuidof(ISurfaceImageSourceNative), (void **)&m_sisD2DNative)

The ISurfaceImageSourceNativeWithD2D interface provides high-performance batched Direct2D drawing, which enables drawing to multiple different SurfaceImageSource or VirtualSurfaceImageSource objects in the same batch, as long as they share the same Direct2D device. Batching can improve performance when updating multiple surfaces at the same time.

The ISurfaceImageSourceNativeWithD2D interface enables drawing to a SurfaceImageSource or VirtualSurfaceImageSource from one or more background threads, which allows high-performance DirectX rendering off the UI thread.

Only call the SetDevice, BeginDraw, and EndDraw methods on ISurfaceImageSourceNativeWithD2D interface, not on the ISurfaceImageSourceNative or IVirtualSurfaceImageSourceNative interfaces.

In order to support batching updates to multiple surfaces to improve performance, you can pass an ID2D1Device to the SetDevice method, instead of an ID3D11Device. The BeginDraw method can then optionally return a shared ID2D1DeviceContext, which the app uses to draw all content for that update.

To draw to the surface from a background thread, you must set any DirectX resources, including the Microsoft Direct3D device, Direct3D device context, Direct2D device, and Direct2D device context, to enable multithreading support.

You can call the BeginDraw, SuspendDraw, and ResumeDraw methods from any background thread to enable high-performance multithreaded drawing.

Always call the EndDraw method on the UI thread in order to synchronize updating the DirectX content with the current XAML UI thread frame. You can call BeginDraw on a background thread, call SuspendDraw when you're done drawing on the background thread, and call EndDraw on the UI thread.

Use SuspendDraw and ResumeDraw to suspend and resume drawing on any background or UI thread.

Handle the SurfaceContentsLost event to determine when you need to recreate content which may be lost if the system resets the GPU.


Requirement Value
Minimum supported client Windows 8.1 [desktop apps | UWP apps]
Minimum supported server Windows Server 2012 R2 [desktop apps | UWP apps]
Target Platform Windows

See also

DirectX and XAML interop