Table of Contents

Class WebGPUWindow

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

A self-contained WebGPU-backed window that owns the platform window, the WebGPU device and queue, the surface and swap chain, and the per-frame texture acquire/present cycle, exposing a DrawingCanvas for each frame. Use Run(Action<DrawingCanvas>) to let the window drive rendering, or TryAcquireFrame(out WebGPUSurfaceFrame?) to drive the frame loop yourself.

public sealed class WebGPUWindow : IDisposable
Inheritance
WebGPUWindow
Implements
Inherited Members

Remarks

Use this type when ImageSharp.Drawing owns the application's window. To render into a window owned by a host application or UI framework, use WebGPUExternalSurface.

Constructors

WebGPUWindow()

Initializes a new instance of the WebGPUWindow class.

public WebGPUWindow()

WebGPUWindow(Configuration, WebGPUWindowOptions)

Initializes a new instance of the WebGPUWindow class.

public WebGPUWindow(Configuration configuration, WebGPUWindowOptions options)

Parameters

configuration Configuration

The configuration instance to bind to the created backend.

options WebGPUWindowOptions

The window creation options.

WebGPUWindow(WebGPUWindowOptions)

Initializes a new instance of the WebGPUWindow class.

public WebGPUWindow(WebGPUWindowOptions options)

Parameters

options WebGPUWindowOptions

The window creation options.

Properties

ClientSize

Gets or sets the client-area size in window coordinates.

public Size ClientSize { get; set; }

Property Value

Size

Configuration

Gets the configuration provided when the window was created.

public Configuration Configuration { get; }

Property Value

Configuration

Format

Gets the swapchain texture format.

public WebGPUTextureFormat Format { get; }

Property Value

WebGPUTextureFormat

FramebufferSize

Gets the framebuffer size in pixels.

public Size FramebufferSize { get; }

Property Value

Size

FramesPerSecond

Gets or sets the maximum number of render callbacks per second.

public double FramesPerSecond { get; set; }

Property Value

double

IsClosing

Gets or sets a value indicating whether the window has been requested to close.

public bool IsClosing { get; set; }

Property Value

bool

IsEventDriven

Gets or sets a value indicating whether the window is event-driven.

public bool IsEventDriven { get; set; }

Property Value

bool

IsTopMost

Gets or sets a value indicating whether the window stays above normal windows.

public bool IsTopMost { get; set; }

Property Value

bool

IsVisible

Gets or sets a value indicating whether the window is visible.

public bool IsVisible { get; set; }

Property Value

bool

Position

Gets or sets the window position in screen coordinates.

public Point Position { get; set; }

Property Value

Point

PresentMode

Gets or sets the swapchain present mode.

public WebGPUPresentMode PresentMode { get; set; }

Property Value

WebGPUPresentMode

RenderScale

Gets the ratio between framebuffer pixels and client coordinate units.

public float RenderScale { get; }

Property Value

float

Title

Gets or sets the window title.

public string Title { get; set; }

Property Value

string

UpdatesPerSecond

Gets or sets the maximum number of update callbacks per second.

public double UpdatesPerSecond { get; set; }

Property Value

double

WindowBorder

Gets or sets the window border mode.

public WebGPUWindowBorder WindowBorder { get; set; }

Property Value

WebGPUWindowBorder

WindowState

Gets or sets the window state.

public WebGPUWindowState WindowState { get; set; }

Property Value

WebGPUWindowState

Methods

Close()

Closes the window immediately.

public void Close()

ContinueEvents()

Continues the event loop when running in event-driven mode.

public void ContinueEvents()

Dispose()

Disposes the window and its WebGPU resources.

public void Dispose()

DoEvents()

Polls the underlying window for events.

public void DoEvents()

Focus()

Sets keyboard focus to the window.

public void Focus()

Hide()

Hides the window.

public void Hide()

PointToClient(Point)

Converts a screen-space point to client coordinates.

public Point PointToClient(Point point)

Parameters

point Point

The point to convert.

Returns

Point

The converted point.

PointToFramebuffer(Point)

Converts a client-space point to framebuffer coordinates.

public Point PointToFramebuffer(Point point)

Parameters

point Point

The point to convert.

Returns

Point

The converted point.

PointToScreen(Point)

Converts a client-space point to screen coordinates.

public Point PointToScreen(Point point)

Parameters

point Point

The point to convert.

Returns

Point

The converted point.

RequestClose()

Requests that the window close.

public void RequestClose()

Run(DrawingOptions, Action<WebGPUSurfaceFrame, TimeSpan>)

Runs the window's event loop and renders one WebGPU frame per render callback.

public void Run(DrawingOptions options, Action<WebGPUSurfaceFrame, TimeSpan> render)

Parameters

options DrawingOptions

The drawing options applied to each acquired frame.

render Action<WebGPUSurfaceFrame, TimeSpan>

The per-frame render callback. The second argument is elapsed time since the previous render callback.

Run(DrawingOptions, Action<WebGPUSurfaceFrame>)

Runs the window's event loop and renders one WebGPU frame per render callback.

public void Run(DrawingOptions options, Action<WebGPUSurfaceFrame> render)

Parameters

options DrawingOptions

The drawing options applied to each acquired frame.

render Action<WebGPUSurfaceFrame>

The per-frame render callback.

Run(DrawingOptions, Action<DrawingCanvas>)

Runs the window's event loop and renders one WebGPU canvas per render callback.

public void Run(DrawingOptions options, Action<DrawingCanvas> render)

Parameters

options DrawingOptions

The drawing options applied to each acquired frame.

render Action<DrawingCanvas>

The per-frame render callback.

Run(Action<WebGPUSurfaceFrame, TimeSpan>)

Runs the window's event loop and renders one WebGPU frame per render callback.

public void Run(Action<WebGPUSurfaceFrame, TimeSpan> render)

Parameters

render Action<WebGPUSurfaceFrame, TimeSpan>

The per-frame render callback. The second argument is elapsed time since the previous render callback.

Run(Action<WebGPUSurfaceFrame>)

Runs the window's event loop and renders one WebGPU frame per render callback.

public void Run(Action<WebGPUSurfaceFrame> render)

Parameters

render Action<WebGPUSurfaceFrame>

The per-frame render callback.

Run(Action<DrawingCanvas>)

Runs the window's event loop and renders one WebGPU canvas per render callback.

public void Run(Action<DrawingCanvas> render)

Parameters

render Action<DrawingCanvas>

The per-frame render callback.

Show()

Shows the window.

public void Show()

TryAcquireFrame(out WebGPUSurfaceFrame?)

Tries to acquire the next drawable frame using default drawing options.

public bool TryAcquireFrame(out WebGPUSurfaceFrame? frame)

Parameters

frame WebGPUSurfaceFrame

Receives the acquired frame on success.

Returns

bool

true when a frame is available; otherwise false when the frame should be retried later.

Remarks

Use this overload when the default drawing options are sufficient.

TryAcquireFrame(DrawingOptions, out WebGPUSurfaceFrame?)

Tries to acquire the next drawable frame.

public bool TryAcquireFrame(DrawingOptions options, out WebGPUSurfaceFrame? frame)

Parameters

options DrawingOptions

The drawing options for the acquired frame.

frame WebGPUSurfaceFrame

Receives the acquired frame on success.

Returns

bool

true when a frame is available; otherwise false when the frame should be retried later.

Remarks

Use this overload when you are driving the render loop yourself and need explicit drawing options. A false result means no drawable frame is available right now, for example because the surface was lost, outdated, timed out, has a zero-sized framebuffer, or the window recovered from device loss. Dispose the returned frame when you are done with it to present it and release its per-frame resources.

Events

Closing

Raised when the window is closing.

public event Action? Closing

Event Type

Action

FilesDropped

Raised when files are dropped onto the window.

public event Action<string[]>? FilesDropped

Event Type

Action<string[]>

FocusChanged

Raised when the window focus changes.

public event Action<bool>? FocusChanged

Event Type

Action<bool>

FramebufferResized

Raised when the framebuffer size changes.

public event Action<Size>? FramebufferResized

Event Type

Action<Size>

Moved

Raised when the window moves.

public event Action<Point>? Moved

Event Type

Action<Point>

Resized

Raised when the client-area size in window coordinates changes.

public event Action<Size>? Resized

Event Type

Action<Size>

StateChanged

Raised when the window state changes.

public event Action<WebGPUWindowState>? StateChanged

Event Type

Action<WebGPUWindowState>

Update

Raised when the window update loop runs.

public event Action<TimeSpan>? Update

Event Type

Action<TimeSpan>