Skip to content

Commit 4159995

Browse files
committed
Revert back to first commit
1 parent 7240ce6 commit 4159995

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/image/filters.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,19 @@ Filters._toPixels = function(canvas) {
4040
.getContext('2d')
4141
.getImageData(0, 0, canvas.width, canvas.height).data;
4242
} else if (canvas.getContext('webgl')) {
43-
const offCanvas = document.createElement('canvas');
44-
offCanvas.width = canvas.width;
45-
offCanvas.height = canvas.height;
46-
const gl = offCanvas.getContext('2d');
47-
gl.drawImage(canvas, 0, 0);
48-
return gl.getImageData(0, 0, offCanvas.width, offCanvas.height).data;
43+
const gl = canvas.getContext('webgl');
44+
const len = gl.drawingBufferWidth * gl.drawingBufferHeight * 4;
45+
const data = new Uint8Array(len);
46+
gl.readPixels(
47+
0,
48+
0,
49+
canvas.width,
50+
canvas.height,
51+
gl.RGBA,
52+
gl.UNSIGNED_BYTE,
53+
data
54+
);
55+
return data;
4956
}
5057
}
5158
};

0 commit comments

Comments
 (0)