• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<!DOCTYPE html>
2<html>
3<body>
4<script src="../resources/runner.js"></script>
5<script>
6
7var canvas2D = document.createElement("canvas");
8var ctx2D = canvas2D.getContext("2d");
9var imageData = null;
10
11function setSize(width, height) {
12    canvas2D.width = width;
13    canvas2D.height = height;
14}
15
16function rand(range) {
17    return Math.floor(Math.random() * range);
18}
19
20function 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
25function putImageDataToCanvas2D() {
26    ctx2D.putImageData(imageData, 0, 0);
27}
28
29setSize(1024, 1024);
30fillCanvas(ctx2D, canvas2D);
31imageData = ctx2D.getImageData(0, 0, canvas2D.width, canvas2D.height);
32
33PerfTestRunner.measureRunsPerSecond({run: putImageDataToCanvas2D, description: "This bench test checks the speed on putting ImageData to Canvas2D(1024x1024)."});
34
35</script>
36</body>
37</html>
38