canvaskit-wasm 0.39
build 2026-04-29
WebGPUCanvasOptions
Plain JS object for CK.MakeGPUCanvasContext — picks the swapchain texture format and how the canvas's alpha is interpreted on composite. Both fields are optional; sensible defaults from the WebGPU spec are used when omitted.
const ctx = CK.MakeGPUCanvasContext(deviceCtx, canvasEl, {
format: 'bgra8unorm', // matches navigator.gpu.getPreferredCanvasFormat() on most hardware
alphaMode: 'premultiplied'
});
Fields
| Field | Type | Notes |
|---|---|---|
format | GPUTextureFormat | Swapchain texture format. Match navigator.gpu.getPreferredCanvasFormat() for best perf. |
alphaMode | GPUCanvasAlphaMode | 'opaque' | 'premultiplied'. Controls how the canvas alpha composites with the page. |
See also
WebGPUCanvasContext— whatMakeGPUCanvasContextreturns.CanvasKit.MakeGPUCanvasContext,MakeGPUCanvasSurface.WebGLOptions— equivalent for the WebGL path.