1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 * For more information on this interface, please see
7 * https://html.spec.whatwg.org/#the-offscreencanvas-interface
10 typedef (OffscreenCanvasRenderingContext2D or ImageBitmapRenderingContext or WebGLRenderingContext or WebGL2RenderingContext or GPUCanvasContext) OffscreenRenderingContext;
12 dictionary ImageEncodeOptions {
13 DOMString type = "image/png";
14 unrestricted double quality;
17 enum OffscreenRenderingContextId { "2d", "bitmaprenderer", "webgl", "webgl2", "webgpu" };
19 [Exposed=(Window,Worker)]
20 interface OffscreenCanvas : EventTarget {
22 constructor([EnforceRange] unsigned long width, [EnforceRange] unsigned long height);
25 attribute [EnforceRange] unsigned long width;
27 attribute [EnforceRange] unsigned long height;
30 OffscreenRenderingContext? getContext(OffscreenRenderingContextId contextId,
31 optional any contextOptions = null);
34 ImageBitmap transferToImageBitmap();
36 Promise<Blob> convertToBlob(optional ImageEncodeOptions options = {});
38 attribute EventHandler oncontextlost;
39 attribute EventHandler oncontextrestored;
41 // Deprecated by convertToBlob
42 [Deprecated="OffscreenCanvasToBlob", NewObject]
43 Promise<Blob> toBlob(optional DOMString type = "",
44 optional any encoderOptions);