Loading libraries/scrcpy-decoder-webcodecs/src/index.ts +12 −2 Original line number Diff line number Diff line Loading @@ -81,13 +81,23 @@ export class WebCodecsVideoDecoder implements ScrcpyVideoDecoder { #currentFrameRendered = false; #animationFrameId = 0; constructor(codec: ScrcpyVideoCodecId) { /** * Create a new WebCodecs video decoder. * @param codec The video codec to decode * @param enableCapture * Whether to allow capturing the canvas content using APIs like `readPixels` and `toDataURL`. * Enable this option may reduce performance. */ constructor(codec: ScrcpyVideoCodecId, enableCapture: boolean) { this.#codec = codec; this.#canvas = document.createElement("canvas"); try { this.#renderer = new WebGLFrameRenderer(this.#canvas); this.#renderer = new WebGLFrameRenderer( this.#canvas, enableCapture, ); } catch { this.#renderer = new BitmapFrameRenderer(this.#canvas); } Loading libraries/scrcpy-decoder-webcodecs/src/webgl.ts +10 −1 Original line number Diff line number Diff line Loading @@ -26,15 +26,24 @@ void main(void) { #context: WebGLRenderingContext; constructor(canvas: HTMLCanvasElement) { /** * Create a new WebGL frame renderer. * @param canvas The canvas to render frames to. * @param enableCapture * Whether to allow capturing the canvas content using APIs like `readPixels` and `toDataURL`. * Enable this option may reduce performance. */ constructor(canvas: HTMLCanvasElement, enableCapture: boolean) { const gl = canvas.getContext("webgl2", { alpha: false, failIfMajorPerformanceCaveat: true, preserveDrawingBuffer: enableCapture, }) || canvas.getContext("webgl", { alpha: false, failIfMajorPerformanceCaveat: true, preserveDrawingBuffer: enableCapture, }); if (!gl) { throw new Error("WebGL not supported"); Loading Loading
libraries/scrcpy-decoder-webcodecs/src/index.ts +12 −2 Original line number Diff line number Diff line Loading @@ -81,13 +81,23 @@ export class WebCodecsVideoDecoder implements ScrcpyVideoDecoder { #currentFrameRendered = false; #animationFrameId = 0; constructor(codec: ScrcpyVideoCodecId) { /** * Create a new WebCodecs video decoder. * @param codec The video codec to decode * @param enableCapture * Whether to allow capturing the canvas content using APIs like `readPixels` and `toDataURL`. * Enable this option may reduce performance. */ constructor(codec: ScrcpyVideoCodecId, enableCapture: boolean) { this.#codec = codec; this.#canvas = document.createElement("canvas"); try { this.#renderer = new WebGLFrameRenderer(this.#canvas); this.#renderer = new WebGLFrameRenderer( this.#canvas, enableCapture, ); } catch { this.#renderer = new BitmapFrameRenderer(this.#canvas); } Loading
libraries/scrcpy-decoder-webcodecs/src/webgl.ts +10 −1 Original line number Diff line number Diff line Loading @@ -26,15 +26,24 @@ void main(void) { #context: WebGLRenderingContext; constructor(canvas: HTMLCanvasElement) { /** * Create a new WebGL frame renderer. * @param canvas The canvas to render frames to. * @param enableCapture * Whether to allow capturing the canvas content using APIs like `readPixels` and `toDataURL`. * Enable this option may reduce performance. */ constructor(canvas: HTMLCanvasElement, enableCapture: boolean) { const gl = canvas.getContext("webgl2", { alpha: false, failIfMajorPerformanceCaveat: true, preserveDrawingBuffer: enableCapture, }) || canvas.getContext("webgl", { alpha: false, failIfMajorPerformanceCaveat: true, preserveDrawingBuffer: enableCapture, }); if (!gl) { throw new Error("WebGL not supported"); Loading