Test name | Executions per second |
---|---|
DrawImage whole master into di canvas | 527600.0 Ops/sec |
PutImageData whole master into pid canvas | 18132.3 Ops/sec |
DrawImage half master into di canvas | 495002.5 Ops/sec |
PutImageData half master into pid canvas | 16859.6 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);
var imgDataFull = masterctx.getImageData(0,0,100,100);
var imgDataHalf = masterctx.getImageData(25,0,75,100);
di.drawImage(master,0,0);
pid.putImageData(imgDataFull,0,0);
di.drawImage(master,25,0,50,100,25,0,50,100);
pid.putImageData(imgDataHalf,25,0);