mirror of
https://github.com/yume-chan/ya-webadb.git
synced 2025-10-04 18:29:23 +02:00
feat(decoder): add an option to enable capture WebGL canvas
This commit is contained in:
parent
1eed9aaf8b
commit
b75669fb67
2 changed files with 22 additions and 3 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue