mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2024-12-22 12:50:36 +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;
|
||||
return function getImageData(sx, sy, sw, sh){
|
||||
var window = getWindow(this.canvas);
|
||||
var context;
|
||||
if (sw * sh > maxSize){
|
||||
return original.call(this, sx, sy, sw, sh);
|
||||
return original.apply(this, window.Array.from(arguments));
|
||||
}
|
||||
else {
|
||||
notify("fakedReadout");
|
||||
context = window.HTMLCanvasElement.prototype.getContext.call(
|
||||
var context = window.HTMLCanvasElement.prototype.getContext.call(
|
||||
getFakeCanvas(window, this.canvas),
|
||||
"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