Test name | Executions per second |
---|---|
DrawImage whole master into di canvas | 271356.2 Ops/sec |
PutImageData whole master into pid canvas | 24757.6 Ops/sec |
DrawImage half master into di2 canvas | 293920.6 Ops/sec |
PutImageData half master into pid2 canvas | 24470.7 Ops/sec |
<canvas id='master' width='100' height='100'></canvas>master<br><br>
<canvas id='pid' width='100' height='100'></canvas>pid1<br><br>
<canvas id='di' width='100' height='100'></canvas>di1<br><br>
<canvas id='pid2' width='100' height='100'></canvas>pid2<br><br>
<canvas id='di2' width='100' height='100'></canvas>di2
var master = document.getElementById('master');
var masterctx = master.getContext('2d');
var pid = document.getElementById('pid').getContext('2d');
var di = document.getElementById('di').getContext('2d');
var pid2 = document.getElementById('pid2').getContext('2d');
var di2 = document.getElementById('di2').getContext('2d');
masterctx.fillRect(0,0,50,50);
masterctx.fillStyle = "red";
masterctx.fillRect(50,50,100,100);
var imgData = masterctx.getImageData(0,0,100,100);
var imgDatas = masterctx.getImageData(25,0,50,100);
di.drawImage(master,0,0);
pid.putImageData(imgData,0,0);
di2.drawImage(master,25,0,50,100,25,0,50,100);
pid2.putImageData(imgDatas,25,0);