Test name | Executions per second |
---|---|
DrawImage whole master into di canvas | 71621.4 Ops/sec |
PutImageData whole master into pid canvas | 9928.4 Ops/sec |
DrawImage half master into di canvas | 65644.7 Ops/sec |
PutImageData half master into pid canvas | 8833.1 Ops/sec |
<canvas id='master' width='100' height='100'></canvas>
<canvas id='pid' width='100' height='100'></canvas>
<canvas id='di' width='100' height='100'></canvas>
var master = document.getElementById('master');
var masterctx = master.getContext('2d');
var pid = document.getElementById('pid').getContext('2d');
var di = document.getElementById('di').getContext('2d');
masterctx.fillRect(0,0,50,50);
masterctx.fillStyle = "red";
masterctx.fillRect(50,50,100,100);
let imgData1 = masterctx.getImageData(0,0,100,100);
let imgData2 = masterctx.getImageData(25,0,75,100);
di.drawImage(master,0,0);
pid.putImageData(imgData1,0,0);
di.drawImage(master,25,0,50,100,25,0,50,100);
pid.putImageData(imgData2,25,0);