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
configurationConfigurationThe configuration instance to bind to the created backend.
optionsWebGPUWindowOptionsThe window creation options.
WebGPUWindow(WebGPUWindowOptions)
Initializes a new instance of the WebGPUWindow class.
public WebGPUWindow(WebGPUWindowOptions options)
Parameters
optionsWebGPUWindowOptionsThe window creation options.
Properties
ClientSize
Gets or sets the client-area size in window coordinates.
public Size ClientSize { get; set; }
Property Value
Configuration
Gets the configuration provided when the window was created.
public Configuration Configuration { get; }
Property Value
Format
Gets the swapchain texture format.
public WebGPUTextureFormat Format { get; }
Property Value
FramebufferSize
Gets the framebuffer size in pixels.
public Size FramebufferSize { get; }
Property Value
FramesPerSecond
Gets or sets the maximum number of render callbacks per second.
public double FramesPerSecond { get; set; }
Property Value
IsClosing
Gets or sets a value indicating whether the window has been requested to close.
public bool IsClosing { get; set; }
Property Value
IsEventDriven
Gets or sets a value indicating whether the window is event-driven.
public bool IsEventDriven { get; set; }
Property Value
IsTopMost
Gets or sets a value indicating whether the window stays above normal windows.
public bool IsTopMost { get; set; }
Property Value
IsVisible
Gets or sets a value indicating whether the window is visible.
public bool IsVisible { get; set; }
Property Value
Position
Gets or sets the window position in screen coordinates.
public Point Position { get; set; }
Property Value
PresentMode
Gets or sets the swapchain present mode.
public WebGPUPresentMode PresentMode { get; set; }
Property Value
RenderScale
Gets the ratio between framebuffer pixels and client coordinate units.
public float RenderScale { get; }
Property Value
Title
Gets or sets the window title.
public string Title { get; set; }
Property Value
UpdatesPerSecond
Gets or sets the maximum number of update callbacks per second.
public double UpdatesPerSecond { get; set; }
Property Value
WindowBorder
Gets or sets the window border mode.
public WebGPUWindowBorder WindowBorder { get; set; }
Property Value
WindowState
Gets or sets the window state.
public WebGPUWindowState WindowState { get; set; }
Property Value
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
pointPointThe point to convert.
Returns
- Point
The converted point.
PointToFramebuffer(Point)
Converts a client-space point to framebuffer coordinates.
public Point PointToFramebuffer(Point point)
Parameters
pointPointThe point to convert.
Returns
- Point
The converted point.
PointToScreen(Point)
Converts a client-space point to screen coordinates.
public Point PointToScreen(Point point)
Parameters
pointPointThe 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
optionsDrawingOptionsThe drawing options applied to each acquired frame.
renderAction<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
optionsDrawingOptionsThe drawing options applied to each acquired frame.
renderAction<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
optionsDrawingOptionsThe drawing options applied to each acquired frame.
renderAction<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
renderAction<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
renderAction<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
renderAction<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
frameWebGPUSurfaceFrameReceives the acquired frame on success.
Returns
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
optionsDrawingOptionsThe drawing options for the acquired frame.
frameWebGPUSurfaceFrameReceives the acquired frame on success.
Returns
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
FilesDropped
Raised when files are dropped onto the window.
public event Action<string[]>? FilesDropped
Event Type
FocusChanged
Raised when the window focus changes.
public event Action<bool>? FocusChanged
Event Type
FramebufferResized
Raised when the framebuffer size changes.
public event Action<Size>? FramebufferResized
Event Type
Moved
Raised when the window moves.
public event Action<Point>? Moved
Event Type
Resized
Raised when the client-area size in window coordinates changes.
public event Action<Size>? Resized
Event Type
StateChanged
Raised when the window state changes.
public event Action<WebGPUWindowState>? StateChanged
Event Type
Update
Raised when the window update loop runs.
public event Action<TimeSpan>? Update