Table of Contents

Class WebGPURenderTarget

Namespace
SixLabors.ImageSharp.Drawing.Processing.Backends
Assembly
SixLabors.ImageSharp.Drawing.WebGPU.dll

An offscreen WebGPU render target.

public sealed class WebGPURenderTarget : IDisposable
Inheritance
WebGPURenderTarget
Implements
Inherited Members

Remarks

The constructors on this type allocate a target on the shared process WebGPU device.

Constructors

WebGPURenderTarget(Configuration, WebGPUTextureFormat, PixelAlphaRepresentation, int, int)

Initializes a new instance of the WebGPURenderTarget class using the shared process-level device.

public WebGPURenderTarget(Configuration configuration, WebGPUTextureFormat format, PixelAlphaRepresentation alphaRepresentation, int width, int height)

Parameters

configuration Configuration

The configuration instance to bind to the created backend.

format WebGPUTextureFormat

The target texture format.

alphaRepresentation PixelAlphaRepresentation

The alpha representation stored by the target.

width int

The target width in pixels.

height int

The target height in pixels.

WebGPURenderTarget(Configuration, WebGPUTextureFormat, int, int)

Initializes a new instance of the WebGPURenderTarget class using the shared process-level device.

public WebGPURenderTarget(Configuration configuration, WebGPUTextureFormat format, int width, int height)

Parameters

configuration Configuration

The configuration instance to bind to the created backend.

format WebGPUTextureFormat

The target texture format.

width int

The target width in pixels.

height int

The target height in pixels.

WebGPURenderTarget(Configuration, int, int)

Initializes a new instance of the WebGPURenderTarget class using the shared process-level device and default RGBA8 format.

public WebGPURenderTarget(Configuration configuration, int width, int height)

Parameters

configuration Configuration

The configuration instance to bind to the created backend.

width int

The target width in pixels.

height int

The target height in pixels.

WebGPURenderTarget(WebGPUTextureFormat, PixelAlphaRepresentation, int, int)

Initializes a new instance of the WebGPURenderTarget class using the shared process-level device.

public WebGPURenderTarget(WebGPUTextureFormat format, PixelAlphaRepresentation alphaRepresentation, int width, int height)

Parameters

format WebGPUTextureFormat

The target texture format.

alphaRepresentation PixelAlphaRepresentation

The alpha representation stored by the target.

width int

The target width in pixels.

height int

The target height in pixels.

WebGPURenderTarget(WebGPUTextureFormat, int, int)

Initializes a new instance of the WebGPURenderTarget class using the shared process-level device.

public WebGPURenderTarget(WebGPUTextureFormat format, int width, int height)

Parameters

format WebGPUTextureFormat

The target texture format.

width int

The target width in pixels.

height int

The target height in pixels.

WebGPURenderTarget(int, int)

Initializes a new instance of the WebGPURenderTarget class using the shared process-level device and default RGBA8 format.

public WebGPURenderTarget(int width, int height)

Parameters

width int

The target width in pixels.

height int

The target height in pixels.

Properties

AlphaRepresentation

Gets the alpha representation stored by the target.

public PixelAlphaRepresentation AlphaRepresentation { get; }

Property Value

PixelAlphaRepresentation

Bounds

Gets the target bounds in pixels.

public Rectangle Bounds { get; }

Property Value

Rectangle

DeviceContext

Gets the device context used by this render target.

public WebGPUDeviceContext DeviceContext { get; }

Property Value

WebGPUDeviceContext

Format

Gets the allocated texture format.

public WebGPUTextureFormat Format { get; }

Property Value

WebGPUTextureFormat

Height

Gets the target height in pixels.

public int Height { get; }

Property Value

int

Width

Gets the target width in pixels.

public int Width { get; }

Property Value

int

Methods

CreateCanvas()

Creates a drawing canvas over this render target.

public DrawingCanvas CreateCanvas()

Returns

DrawingCanvas

A drawing canvas targeting this render target.

CreateCanvas(DrawingOptions)

Creates a drawing canvas over this render target.

public DrawingCanvas CreateCanvas(DrawingOptions options)

Parameters

options DrawingOptions

The initial drawing options.

Returns

DrawingCanvas

A drawing canvas targeting this render target.

CreateCanvas(DrawingOptions, DrawingTextCache)

Creates a drawing canvas over this render target.

public DrawingCanvas CreateCanvas(DrawingOptions options, DrawingTextCache textCache)

Parameters

options DrawingOptions

The initial drawing options.

textCache DrawingTextCache

The text drawing cache used by this canvas instance.

Returns

DrawingCanvas

A drawing canvas targeting this render target.

CreateRenderTarget(int, int)

Creates an empty render target with the same texture format as this target.

public WebGPURenderTarget CreateRenderTarget(int width, int height)

Parameters

width int

The target width in pixels.

height int

The target height in pixels.

Returns

WebGPURenderTarget

The created render target.

Remarks

The created target does not contain a copy of this target's pixels. This target must remain undisposed while the created target is in use.

Dispose()

Releases the owned texture view and texture, and the device context when this target created it. Targets created from a shared context leave that context untouched.

public void Dispose()

ReadbackImage()

Reads the current GPU texture contents back into a new CPU image whose pixel type matches Format and AlphaRepresentation.

public Image ReadbackImage()

Returns

Image

The readback image whose pixel type has the target's channel layout, numeric encoding, and alpha representation.

ReadbackImage<TPixel>()

Reads the current GPU texture contents back into a new CPU image.

public Image<TPixel> ReadbackImage<TPixel>() where TPixel : unmanaged, IPixel<TPixel>

Returns

Image<TPixel>

The readback image.

Type Parameters

TPixel

The destination image pixel format. Must match Format and AlphaRepresentation; the backend read throws NotSupportedException on a mismatch. Use ReadbackImage() to dispatch by format.

ReadbackInto<TPixel>(Buffer2DRegion<TPixel>)

Reads the current GPU texture contents back into an existing CPU buffer region.

public void ReadbackInto<TPixel>(Buffer2DRegion<TPixel> destination) where TPixel : unmanaged, IPixel<TPixel>

Parameters

destination Buffer2DRegion<TPixel>

The destination buffer region that receives the readback pixels.

Type Parameters

TPixel

The destination image pixel format. Must match Format and AlphaRepresentation; the backend read throws NotSupportedException on a mismatch.