GPUCanvasContext
The GPUCanvasContext interface of the WebGPU API represents the WebGPU rendering context of a <canvas> element, returned via an HTMLCanvasElement.getContext() call with a contextType of "webgpu".
Available only in secure contexts.
Methods
configure()
configure(configuration): void;
The configure() method of the GPUCanvasContext interface configures the context to use for rendering with a given GPUDevice. When called the canvas will initially be cleared to transparent black.
Parameters
| Parameter | Type |
|---|---|
configuration | GPUCanvasConfiguration |
Returns
void
getConfiguration()
getConfiguration(): GPUCanvasConfiguration | null;
The getConfiguration() method of the GPUCanvasContext interface returns the current configuration set for the context.
Returns
GPUCanvasConfiguration | null
getCurrentTexture()
getCurrentTexture(): GPUTexture;
The getCurrentTexture() method of the GPUCanvasContext interface returns the next GPUTexture to be composited to the document by the canvas context.
Returns
unconfigure()
unconfigure(): void;
The unconfigure() method of the GPUCanvasContext interface removes any previously-set context configuration, and destroys any textures returned via getCurrentTexture() while the canvas context was configured.
Returns
void
Properties
canvas
readonly canvas:
| HTMLCanvasElement
| OffscreenCanvas;
The canvas read-only property of the GPUCanvasContext interface returns a reference to the canvas that the context was created from.