ISurfaceImageSourceNativeWithD2D interface (windows.ui.xaml.media.dxinterop.h)

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

Inheritance

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

Methods

The ISurfaceImageSourceNativeWithD2D interface has these methods.

 
ISurfaceImageSourceNativeWithD2D::BeginDraw

Initiates an update to the associated SurfaceImageSource or VirtualSurfaceImageSource.
ISurfaceImageSourceNativeWithD2D::EndDraw

The ISurfaceImageSourceNativeWithD2D::EndDraw method (windows.ui.xaml.media.dxinterop.h) closes the surface draw operation.
ISurfaceImageSourceNativeWithD2D::ResumeDraw

Resume the drawing operation.
ISurfaceImageSourceNativeWithD2D::SetDevice

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

Suspends the drawing operation.

Remarks

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.

Requirements

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
Header windows.ui.xaml.media.dxinterop.h

See also

DirectX and XAML interop

IUnknown

SurfaceContentsLost

SurfaceImageSource

VirtualSurfaceImageSource