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
configurationConfigurationThe configuration instance to bind to the created backend.
formatWebGPUTextureFormatThe target texture format.
alphaRepresentationPixelAlphaRepresentationThe alpha representation stored by the target.
widthintThe target width in pixels.
heightintThe 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
configurationConfigurationThe configuration instance to bind to the created backend.
formatWebGPUTextureFormatThe target texture format.
widthintThe target width in pixels.
heightintThe 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
configurationConfigurationThe configuration instance to bind to the created backend.
widthintThe target width in pixels.
heightintThe 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
formatWebGPUTextureFormatThe target texture format.
alphaRepresentationPixelAlphaRepresentationThe alpha representation stored by the target.
widthintThe target width in pixels.
heightintThe 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
formatWebGPUTextureFormatThe target texture format.
widthintThe target width in pixels.
heightintThe 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
Properties
AlphaRepresentation
Gets the alpha representation stored by the target.
public PixelAlphaRepresentation AlphaRepresentation { get; }
Property Value
Bounds
Gets the target bounds in pixels.
public Rectangle Bounds { get; }
Property Value
DeviceContext
Gets the device context used by this render target.
public WebGPUDeviceContext DeviceContext { get; }
Property Value
Format
Gets the allocated texture format.
public WebGPUTextureFormat Format { get; }
Property Value
Height
Gets the target height in pixels.
public int Height { get; }
Property Value
Width
Gets the target width in pixels.
public int Width { get; }
Property Value
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
optionsDrawingOptionsThe 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
optionsDrawingOptionsThe initial drawing options.
textCacheDrawingTextCacheThe 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
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
TPixelThe 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
destinationBuffer2DRegion<TPixel>The destination buffer region that receives the readback pixels.
Type Parameters
TPixelThe destination image pixel format. Must match Format and AlphaRepresentation; the backend read throws NotSupportedException on a mismatch.