Respect RFP in offscreenToBlobCallback

Fixes #644
This commit is contained in:
kkapsner 2023-04-07 17:35:57 +02:00
parent 3b08fdaf9b
commit 269574ae17
1 changed files with 7 additions and 4 deletions

View File

@ -258,7 +258,6 @@
const {prefs, notify, window, original} = check;
if (canvasSizeShouldBeFaked(this, prefs)){
try {
const options = args[0];
const canvas = window.document.createElement("canvas");
canvas.width = this.width;
canvas.height = this.height;
@ -268,9 +267,13 @@
if (fakeCanvas !== canvas){
notify("fakedReadout");
}
return new window.Promise(function(resolve){
fakeCanvas.toBlob(resolve, options && options.type, options && options.quality);
});
const fakeContext = getContext(window, fakeCanvas);
const {imageData} = getImageData(window, fakeContext);
const fakeOffscreenCanvas = new window.OffscreenCanvas(this.width, this.height);
const offscreenContext = fakeOffscreenCanvas.getContext("2d");
offscreenContext.putImageData(imageData, 0, 0);
return original.call(fakeOffscreenCanvas, ...args);
}
catch (error){
logging.warning("Error while faking:", error);