1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-11-11 07:38:58 +01:00

Fixed broken webGl faking.

Fixes #136
This commit is contained in:
kkapsner 2017-10-10 21:09:26 +02:00
parent db3b8fdd69
commit c5872ef5a1

View File

@ -31,8 +31,8 @@
var imageData;
var source;
if ((context.canvas.width || 0) * (context.canvas.height || 0) === 0){
imageData = new getWrapped(window).ImageData(0, 0);
source = new getWrapped(window).ImageData(0, 0);
imageData = new (getWrapped(window).ImageData)(0, 0);
source = new (getWrapped(window).ImageData)(0, 0);
}
else if (context instanceof window.CanvasRenderingContext2D){
imageData = window.CanvasRenderingContext2D.prototype.getImageData.call(
@ -43,9 +43,13 @@
source = imageData.data;
}
else {
imageData = new getWrapped(window).ImageData(context.canvas.width, context.canvas.height);
imageData = new (getWrapped(window).ImageData)(context.canvas.width, context.canvas.height);
source = new Uint8Array(imageData.data.length);
window.WebGLRenderingContext.prototype.readPixels.call(
(
context instanceof window.WebGLRenderingContext?
window.WebGLRenderingContext:
window.WebGL2RenderingContext
).prototype.readPixels.call(
context,
0, 0, context.canvas.width, context.canvas.height,
context.RGBA, context.UNSIGNED_BYTE,