Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <body> | |
| 4 <script src="../resources/runner.js"></script> | |
| 5 <script> | |
| 6 var imgHeight = 1024; | |
| 7 var imgWidth = 1024; | |
| 8 var canvas = document.createElement("canvas"); | |
| 9 canvas.width = imgWidth; | |
| 10 canvas.height = imgHeight; | |
| 11 var context = canvas.getContext('2d'); | |
| 12 var image = context.createImageData(imgWidth, imgHeight); | |
| 13 | |
| 14 function rand(range) { | |
| 15 return Math.floor(Math.random() * range); | |
| 16 } | |
| 17 | |
| 18 function setImageData() { | |
|
Justin Novosad
2015/10/06 02:17:53
I would call this initializeImageData.
| |
| 19 for(var i = 0; i < image.data.length; i+= 4) | |
|
Justin Novosad
2015/10/06 02:17:53
if you just incremented i by 1, you would not need
| |
| 20 for(var j = 0; j < 4; j++) | |
| 21 image.data[i+j] = rand(255); | |
|
Justin Novosad
2015/10/06 02:17:52
Not that it matters much, but to produce values be
| |
| 22 } | |
| 23 | |
| 24 function imageBitmapFromImageData() { | |
| 25 createImageBitmap(image, 0, 0, imgWidth, imgHeight); | |
|
Justin Novosad
2015/10/06 02:17:53
Add a comment to explain that the return Promise i
| |
| 26 } | |
| 27 | |
| 28 setImageData(); | |
| 29 PerfTestRunner.measureRunsPerSecond({run: imageBitmapFromImageData, description: "This bench test checks the speed on creating ImageBitmap from ImageData(1024x1 024)."}); | |
| 30 </script> | |
| 31 </body> | |
| 32 </html> | |
| OLD | NEW |