Home | History | Annotate | Download | only in Canvas
      1 <!DOCTYPE html>
      2 <html>
      3 <body>
      4 <script src="../resources/runner.js"></script>
      5 <script>
      6 
      7 var canvas2D = document.createElement("canvas");
      8 var ctx2D = canvas2D.getContext("2d");
      9 var imageData = null;
     10 
     11 function setSize(width, height) {
     12     canvas2D.width = width;
     13     canvas2D.height = height;
     14 }
     15 
     16 function rand(range) {
     17     return Math.floor(Math.random() * range);
     18 }
     19 
     20 function fillCanvas(ctx2d, canvas2d) {
     21     ctx2d.fillStyle = "rgba(" + rand(255) + "," + rand(255) + "," + rand(255)  + "," + rand(255) + ")";
     22     ctx2d.fillRect(0, 0, canvas2d.width, canvas2d.height);
     23 }
     24 
     25 function putImageDataToCanvas2D() {
     26     ctx2D.putImageData(imageData, 0, 0);
     27 }
     28 
     29 setSize(1024, 1024);
     30 fillCanvas(ctx2D, canvas2D);
     31 imageData = ctx2D.getImageData(0, 0, canvas2D.width, canvas2D.height);
     32 
     33 PerfTestRunner.measureRunsPerSecond({run: putImageDataToCanvas2D, description: "This bench test checks the speed on putting ImageData to Canvas2D(1024x1024)."});
     34 
     35 </script>
     36 </body>
     37 </html>
     38