Click or drag to resize
CanvasSwapChain Class
A swap chain is a series of buffers that can be drawn to and presented to the screen.
Inheritance Hierarchy
SystemObject
  Microsoft.Graphics.CanvasCanvasSwapChain

Namespace:  Microsoft.Graphics.Canvas
Assembly:  Microsoft.Graphics.Canvas (in Microsoft.Graphics.Canvas.dll) Version: 0.0.0.0
Syntax
C#
public sealed class CanvasSwapChain : IDisposable, 
	ICanvasResourceCreatorWithDpi, ICanvasResourceCreator

The CanvasSwapChain type exposes the following members.

Constructors
  NameDescription
Public methodCanvasSwapChain(ICanvasResourceCreatorWithDpi, Size)
Initializes a new instance of the CanvasSwapChain class, with the specified size.
Public methodCanvasSwapChain(ICanvasResourceCreatorWithDpi, Single, Single)
Initializes a new instance of the CanvasSwapChain class, with the specified width and height.
Public methodCanvasSwapChain(ICanvasResourceCreator, Single, Single, Single)
Initializes a new instance of the CanvasSwapChain class with the specified width, height, and dpi.
Public methodCanvasSwapChain(ICanvasResourceCreator, Single, Single, Single, DirectXPixelFormat, Int32, CanvasAlphaMode)
Initializes a new instance of the CanvasSwapChain class with the options specified.
Top
Properties
  NameDescription
Public propertyAlphaMode
Gets the alpha mode associated with this CanvasSwapChain.
Public propertyBufferCount
Gets the number of buffers that comprise this CanvasSwapChain.
Public propertyDevice
Gets the device associated with this CanvasSwapChain.
Public propertyDpi
Gets the dots-per-inch (DPI) of this swap chain.
Public propertyFormat
Gets the pixel format associated with this CanvasSwapChain.
Public propertyRotation
Rotates the swap chain.
Public propertySize
Gets the size of the swap chain, in device independent pixels (DIPs).
Public propertySizeInPixels
Gets the size of the swap chain, in pixels.
Public propertySourceSize
Specifies that only a subregion of the swap chain should be displayed.
Public propertyTransformMatrix
Specifies a transform matrix that will be applied to the swap chain upon the next present.
Top
Methods
  NameDescription
Public methodConvertDipsToPixels
Converts units from device independent pixels (DIPs) to physical pixels based on the DPI of this swap chain.
Public methodConvertPixelsToDips
Converts units from physical pixels to device independent pixels (DIPs) based on the DPI of this swap chain.
Public methodCreateDrawingSession
Creates a drawing session that will draw onto this CanvasSwapChain.
Public methodStatic memberCreateForCoreWindow(ICanvasResourceCreator, CoreWindow, Single)
Initializes a new instance of a CanvasSwapChain, suitable for use with CoreWindow.
Public methodStatic memberCreateForCoreWindow(ICanvasResourceCreator, CoreWindow, Single, Single, Single, DirectXPixelFormat, Int32)
Initializes a new instance of a CanvasSwapChain, suitable for use with CoreWindow.
Public methodDispose
Releases all resources used by the CanvasSwapChain.
Public methodPresent
Presents a rendered image.
Public methodPresent(Int32)
Presents a rendered image, using the specified sync interval.
Public methodResizeBuffers(Size)
Changes the CanvasSwapChain's back buffer size.
Public methodResizeBuffers(Single, Single)
Changes the CanvasSwapChain's back buffer size.
Public methodResizeBuffers(Single, Single, Single)
Changes the CanvasSwapChain's back buffer size, and DPI.
Public methodResizeBuffers(Single, Single, Single, DirectXPixelFormat, Int32)
Changes the CanvasSwapChain's back buffer size, DPI, pixel format, and number of buffers.
Public methodWaitForVerticalBlank
Waits until the next vertical blank occurs on the display.
Top
Remarks

Like a bitmap, a swap chain has a fixed with and height, and stores 2D information. Underlying this, however, it may consist of multiple buffers. For more information about native swap chains, see the documentation on IDXGISwapChain.

Two types of CanvasSwapChain are supported: composition and CoreWindow.

Composition (XAML) Swap Chains

Composition swap chains are constructed via CanvasSwapChain Overload and are suitable for use in XAML apps. These swap chains can be displayed using CanvasSwapChainPanel. CanvasAnimatedControl uses a composition swap chain internally.

var swapChain = new CanvasSwapChain(device, width, height, dpi);
swapChainPanel.SwapChain = swapChain;
// ... later ...
swapChain.Present();

CoreWindow Swap Chains

CoreWindow swap chains are constructed via CreateForCoreWindow Overload and can only be used in non-XAML apps (also known as "DirectX apps".)

var swapChain = CanvasSwapChain.CreateForCoreWindow(device, coreWindow, dpi);
// ... later ...
swapChain.Present();

When using Direct2D interop, this Win2D class corresponds to the DXGI interface IDXGISwapChain1.

See Also