mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-06-06 00:03:22 +00:00
[js/web] add OffscreenCanvas support to WebGL backend (#12159)
* Add OffscreenCanvas support to WebGL backend * fix format * fix lint
This commit is contained in:
parent
471dbfc250
commit
c72bb8aaa9
1 changed files with 9 additions and 0 deletions
|
|
@ -83,7 +83,16 @@ export function createNewWebGLContext(contextId?: 'webgl'|'webgl2'): WebGLContex
|
|||
throw new Error('WebGL is not supported');
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
declare let OffscreenCanvas: {new (width: number, height: number): HTMLCanvasElement};
|
||||
|
||||
function createCanvas(): HTMLCanvasElement {
|
||||
if (typeof document === 'undefined') {
|
||||
if (typeof OffscreenCanvas === 'undefined') {
|
||||
throw new TypeError('failed to create canvas: OffscreenCanvas is not supported');
|
||||
}
|
||||
return new OffscreenCanvas(1, 1);
|
||||
}
|
||||
const canvas: HTMLCanvasElement = document.createElement('canvas');
|
||||
canvas.width = 1;
|
||||
canvas.height = 1;
|
||||
|
|
|
|||
Loading…
Reference in a new issue