mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-06 15:47:18 +02:00
Fix taking screenshot not working when limiting FPS
This commit is contained in:
parent
602c31dc7f
commit
8664c1a60f
4
dist/better-xcloud.lite.user.js
vendored
4
dist/better-xcloud.lite.user.js
vendored
@ -5036,13 +5036,15 @@ class WebGL2Player {
|
||||
let gl = this.gl, program = this.program;
|
||||
gl.uniform2f(gl.getUniformLocation(program, "iResolution"), this.$canvas.width, this.$canvas.height), gl.uniform1i(gl.getUniformLocation(program, "filterId"), this.options.filterId), gl.uniform1f(gl.getUniformLocation(program, "sharpenFactor"), this.options.sharpenFactor), gl.uniform1f(gl.getUniformLocation(program, "brightness"), this.options.brightness), gl.uniform1f(gl.getUniformLocation(program, "contrast"), this.options.contrast), gl.uniform1f(gl.getUniformLocation(program, "saturation"), this.options.saturation);
|
||||
}
|
||||
drawFrame() {
|
||||
drawFrame(force = !1) {
|
||||
if (!force) {
|
||||
if (this.targetFps === 0) return;
|
||||
if (this.targetFps < 60) {
|
||||
let currentTime = performance.now();
|
||||
if (currentTime - this.lastFrameTime < this.frameInterval) return;
|
||||
this.lastFrameTime = currentTime;
|
||||
}
|
||||
}
|
||||
let gl = this.gl;
|
||||
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE, this.$video), gl.drawArrays(gl.TRIANGLES, 0, 6);
|
||||
}
|
||||
|
6
dist/better-xcloud.user.js
vendored
6
dist/better-xcloud.user.js
vendored
@ -1814,7 +1814,7 @@ class Screenshot {
|
||||
if (!$player || !$player.isConnected) return;
|
||||
$player.parentElement.addEventListener("animationend", this.#onAnimationEnd, { once: !0 }), $player.parentElement.classList.add("bx-taking-screenshot");
|
||||
let canvasContext = Screenshot.#canvasContext;
|
||||
if ($player instanceof HTMLCanvasElement) streamPlayer.getWebGL2Player().drawFrame();
|
||||
if ($player instanceof HTMLCanvasElement) streamPlayer.getWebGL2Player().drawFrame(!0);
|
||||
if (canvasContext.drawImage($player, 0, 0, $canvas.width, $canvas.height), AppInterface) {
|
||||
let data = $canvas.toDataURL("image/png").split(";base64,")[1];
|
||||
AppInterface.saveScreenshot(currentStream.titleSlug, data), canvasContext.clearRect(0, 0, $canvas.width, $canvas.height), callback && callback();
|
||||
@ -6915,13 +6915,15 @@ class WebGL2Player {
|
||||
let gl = this.gl, program = this.program;
|
||||
gl.uniform2f(gl.getUniformLocation(program, "iResolution"), this.$canvas.width, this.$canvas.height), gl.uniform1i(gl.getUniformLocation(program, "filterId"), this.options.filterId), gl.uniform1f(gl.getUniformLocation(program, "sharpenFactor"), this.options.sharpenFactor), gl.uniform1f(gl.getUniformLocation(program, "brightness"), this.options.brightness), gl.uniform1f(gl.getUniformLocation(program, "contrast"), this.options.contrast), gl.uniform1f(gl.getUniformLocation(program, "saturation"), this.options.saturation);
|
||||
}
|
||||
drawFrame() {
|
||||
drawFrame(force = !1) {
|
||||
if (!force) {
|
||||
if (this.targetFps === 0) return;
|
||||
if (this.targetFps < 60) {
|
||||
let currentTime = performance.now();
|
||||
if (currentTime - this.lastFrameTime < this.frameInterval) return;
|
||||
this.lastFrameTime = currentTime;
|
||||
}
|
||||
}
|
||||
let gl = this.gl;
|
||||
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE, this.$video), gl.drawArrays(gl.TRIANGLES, 0, 6);
|
||||
}
|
||||
|
@ -94,7 +94,8 @@ export class WebGL2Player {
|
||||
gl.uniform1f(gl.getUniformLocation(program, 'saturation'), this.options.saturation);
|
||||
}
|
||||
|
||||
drawFrame() {
|
||||
drawFrame(force=false) {
|
||||
if (!force) {
|
||||
// Don't draw when FPS is 0
|
||||
if (this.targetFps === 0) {
|
||||
return;
|
||||
@ -109,6 +110,7 @@ export class WebGL2Player {
|
||||
}
|
||||
this.lastFrameTime = currentTime;
|
||||
}
|
||||
}
|
||||
|
||||
const gl = this.gl!;
|
||||
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE, this.$video);
|
||||
|
@ -64,7 +64,7 @@ export class Screenshot {
|
||||
const canvasContext = Screenshot.#canvasContext;
|
||||
|
||||
if ($player instanceof HTMLCanvasElement) {
|
||||
streamPlayer.getWebGL2Player().drawFrame();
|
||||
streamPlayer.getWebGL2Player().drawFrame(true);
|
||||
}
|
||||
canvasContext.drawImage($player, 0, 0, $canvas.width, $canvas.height);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user