The ISurfaceImageSourceNativeWithD2D interface has these methods.
|ISurfaceImageSourceNativeWithD2D::BeginDraw||Initiates an update to the associated SurfaceImageSource or VirtualSurfaceImageSource.|
|ISurfaceImageSourceNativeWithD2D::EndDraw||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.|
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.
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.
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.
Handle the SurfaceContentsLost event to determine when you need to recreate content which may be lost if the system resets the GPU.
|Minimum supported client||Windows 8.1 [desktop apps | UWP apps]|
|Minimum supported server||Windows Server 2012 R2 [desktop apps | UWP apps]|