Skip to content

Commit

Permalink
chore: optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
guoxianzhe committed May 14, 2024
1 parent 0e0d394 commit 5c5b50f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ts/Renderer/IRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export abstract class IRenderer {
});
this.parentElement.appendChild(this.container);
this.canvas = document.createElement('canvas');
this.canvas.style.display = 'none';
this.container.appendChild(this.canvas);
}

Expand All @@ -45,7 +46,12 @@ export abstract class IRenderer {
this.parentElement = undefined;
}

public abstract drawFrame(videoFrame: VideoFrame): void;
public drawFrame(_videoFrame?: VideoFrame): void {
if (!this.canvas) return;
if (this.canvas.style.display !== '') {
this.canvas.style.display = '';
}
}

public setContext(context: RendererContext) {
if (this.context.renderMode !== context.renderMode) {
Expand Down
1 change: 1 addition & 0 deletions ts/Renderer/WebCodecsRenderer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export class WebCodecsRenderer extends IRenderer {
// Draw the frame.
this.gl.drawArrays(this.gl.TRIANGLE_FAN, 0, 4);
}
super.drawFrame();
this.getFps();
}
}
1 change: 1 addition & 0 deletions ts/Renderer/WebGLRenderer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ export class WebGLRenderer extends IRenderer {
);

this.gl.drawArrays(this.gl.TRIANGLES, 0, 6);
super.drawFrame();
this.getFps();
}

Expand Down
1 change: 1 addition & 0 deletions ts/Renderer/YUVCanvasRenderer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export class YUVCanvasRenderer extends IRenderer {
}
)
);
super.drawFrame();
}

protected override rotateCanvas({ width, height, rotation }: VideoFrame) {
Expand Down

0 comments on commit 5c5b50f

Please sign in to comment.