I have an asmjs module, which works on an ArrayBuffer
called 'MEM'. The repaint function is called in every loop. In the first 'siz' bytes are the pixel colors stored. My code works, but it runs slow. Is it possible to make it faster somehow? The arraybuffer can't be 'siz' length, because the module works on the whole ArrayBuffer.
var MEM = new ArrayBuffer(2*1024*1024);
var MEMU8 = new Uint8Array(MEM);
var imgData=ctx.createImageData(canvas.width,canvas.height);
var siz = (canvas.width*canvas.height*4)|0;
var rePaint = function() {
var i=0;
module.repaint();
i=siz;
while(i--) {
imgData.data[i] = MEMU8[i];
}
ctx.putImageData(imgData, 0, 0);
requestAnimationFrame(rePaint);
};