drawImage from different sources (v7)

Revision 7 of this benchmark created on


Preparation HTML

<canvas id="cnv1" width="320" height="240">
<canvas id="cnv2" width="320" height="240">
</canvas>
<img id="img" src="http://mozilla.org/media/img/firefox/template/header-logo-inverse.png" style="display: none" />

Setup

function createCanvas(w, h) {
    var canvas = document.createElement('canvas');
    canvas.setAttribute('width', w);
    canvas.setAttribute('height', h);
    return canvas;
  }
  
  // globals
  var g_ctx1 = document.getElementById('cnv1').getContext('2d');
  var g_ctx2 = document.getElementById('cnv1').getContext('2d');
  g_ctx2.globalCompositeOperation = "copy";
  g_ctx2.scale(1.001,1.001);
  var g_img = document.getElementById('img');
  var g_offscreenCanvas = createCanvas(320, 240);
  
  g_offscreenCanvas.getContext('2d').drawImage(g_img, 0, 0);

Test runner

Ready to run.

Testing in
TestOps/sec
img normal
g_ctx1.drawImage(g_img, 0, 0, 180, 70, 0, 0, 180, 70);
ready
not-in-dom canvas normal
g_ctx1.drawImage(g_offscreenCanvas, 0, 0, 180, 70, 0, 0, 180, 70);
ready
img copy
g_ctx2.drawImage(g_img, 0, 0, 180, 70, 0, 0, 180, 70);
ready
offsceen copy
g_ctx2.drawImage(g_offscreenCanvas, 0, 0, 180, 70, 0, 0, 180, 70);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.