{{APIRef("Canvas API")}} {{SeeCompatTable}}
The OffscreenCanvas
interface provides a canvas that can be rendered off screen. It is available in both, the window and in a worker context.
Note: This API is currently implemented for WebGL1 and WebGL2 contexts only. See {{bug(801176)}} for Canvas 2D API support from workers.
Constructors
- {{domxref("OffscreenCanvas.OffscreenCanvas", "OffscreenCanvas()")}}
OffscreenCanvas
constructor. Creates a newOffscreenCanvas
object.
Properties
- {{domxref("OffscreenCanvas.height")}}
- The height of the offscreen canvas.
- {{domxref("OffscreenCanvas.width")}}
- The width of the offscreen canvas.
Methods
- {{domxref("OffscreenCanvas.getContext()")}}
- Returns a rendering context for the offscreen canvas.
- {{domxref("OffscreenCanvas.toBlob()")}}
- Creates a {{domxref("Blob")}} object representing the image contained in the canvas.
- {{domxref("OffscreenCanvas.transferToImageBitmap()")}}
- Creates an {{domxref("ImageBitmap")}} object from the most recently rendered image of the
OffscreenCanvas
.
Specifications
{{WhyNoSpecStart}} Currently drafted as a proposal: OffscreenCanvas.{{WhyNoSpecEnd}}
Browser compatibility
{{CompatibilityTable}}
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | {{CompatNo}} | {{CompatGeckoDesktop(44)}} [1] | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
Feature | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | {{CompatNo}} | {{CompatGeckoMobile(44)}} [1] | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
[1] This feature is behind a feature preference setting. In about:config, set gfx.offscreencanvas.enabled
to true
.
See also
- {{domxref("CanvasRenderingContext2D")}}
- {{domxref("ImageBitmap")}}
- {{domxref("ImageBitmapRenderingContext")}}
- {{domxref("HTMLCanvasElement.transferControlToOffscreen")}}
- {{domxref("WebGLRenderingContext.commit()")}}