mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-01-18 17:38:46 +01:00
Improved performance for getImageData.
This commit is contained in:
parent
7b7583afe0
commit
0eeaf84826
@ -191,24 +191,17 @@
|
|||||||
var maxSize = prefs("maxFakeSize") || Number.POSITIVE_INFINITY;
|
var maxSize = prefs("maxFakeSize") || Number.POSITIVE_INFINITY;
|
||||||
return function getImageData(sx, sy, sw, sh){
|
return function getImageData(sx, sy, sw, sh){
|
||||||
var window = getWindow(this.canvas);
|
var window = getWindow(this.canvas);
|
||||||
var context;
|
|
||||||
if (sw * sh > maxSize){
|
if (sw * sh > maxSize){
|
||||||
return original.call(this, sx, sy, sw, sh);
|
return original.apply(this, window.Array.from(arguments));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
notify("fakedReadout");
|
notify("fakedReadout");
|
||||||
context = window.HTMLCanvasElement.prototype.getContext.call(
|
var context = window.HTMLCanvasElement.prototype.getContext.call(
|
||||||
getFakeCanvas(window, this.canvas),
|
getFakeCanvas(window, this.canvas),
|
||||||
"2d"
|
"2d"
|
||||||
);
|
);
|
||||||
|
return original.apply(context, window.Array.from(arguments));
|
||||||
}
|
}
|
||||||
var data = window.CanvasRenderingContext2D.prototype.getImageData.apply(context, arguments).data;
|
|
||||||
|
|
||||||
var imageData = new window.wrappedJSObject.ImageData(sw, sh);
|
|
||||||
for (var i = 0, l = data.length; i < l; i += 1){
|
|
||||||
imageData.data[i] = data[i];
|
|
||||||
}
|
|
||||||
return imageData;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user