Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <title>Ensure correct behavior of drawImage video elements.</title> | 3 <title>Ensure correct behavior of drawImage video elements on both software ca nvas and accelerated canvas. crbug.com/424591</title> |
| 4 <style trpe="text/css"> | 4 <style trpe="text/css"> |
| 5 video { | 5 video { |
| 6 display: none; | 6 display: none; |
| 7 } | 7 } |
| 8 </style> | 8 </style> |
| 9 </head> | 9 </head> |
| 10 <body> | 10 <body> |
| 11 <canvas id="canvas"></canvas> | 11 <canvas id="hw-canvas" width=300 height=300></canvas> |
|
Justin Novosad
2014/10/17 16:23:46
For layouts test it does not work like this for co
| |
| 12 <canvas id="sw-canvas" width=150 height=150></canvas> | |
| 12 <video id="video" loop> | 13 <video id="video" loop> |
| 13 <source src="resources/canvas_video.mp4" type='video/mp4' /> | 14 <source src="resources/canvas_video.mp4" type='video/mp4' /> |
| 14 <source src="resources/canvas_video.webm" type='video/webm' /> | 15 <source src="resources/canvas_video.webm" type='video/webm' /> |
| 15 <source src="resources/canvas_video.ogv" type='video/ogg' /> | 16 <source src="resources/canvas_video.ogv" type='video/ogg' /> |
| 16 </video> | 17 </video> |
| 17 <script> | 18 <script> |
| 18 if (window.testRunner) { | 19 if (window.testRunner) { |
| 19 testRunner.dumpAsTextWithPixelResults(); | 20 testRunner.dumpAsTextWithPixelResults(); |
| 20 testRunner.waitUntilDone(); | 21 testRunner.waitUntilDone(); |
| 21 } | 22 } |
| 22 | 23 |
| 23 var length = 150; | 24 var hw_canvas = document.getElementById("hw-canvas"); |
| 24 var canvas = document.getElementById("canvas"); | 25 var hw_ctx = hw_canvas.getContext("2d"); |
| 25 canvas.setAttribute("width", length); | 26 // Although enabling accelerated-2d-canvas, canvas with the dimension |
| 26 canvas.setAttribute("height", length); | 27 // less than 257*256 is not accelerated. |
|
Justin Novosad
2014/10/17 16:23:46
Not true in layout tests
| |
| 27 var ctx = canvas.getContext("2d"); | 28 var sw_canvas = document.getElementById("sw-canvas"); |
| 29 var sw_ctx = sw_canvas.getContext("2d"); | |
| 28 | 30 |
| 29 var video = document.getElementById("video"); | 31 var video = document.getElementById("video"); |
| 30 video.addEventListener("playing", drawImageToCanvas, true); | 32 video.addEventListener("playing", drawImageToCanvas, true); |
| 31 video.play(); | 33 video.play(); |
| 32 | 34 |
| 33 function drawImageToCanvas() { | 35 function drawVideo(ctx, canvas) { |
| 34 video.removeEventListener("playing", drawImageToCanvas, true); | 36 ctx.globalAlpha = 1; |
| 35 ctx.fillStyle = "blue"; | 37 ctx.fillStyle = "blue"; |
| 36 ctx.fillRect(0, 0, length, length); | 38 ctx.fillRect(0, 0, canvas.width, canvas.width); |
| 37 ctx.drawImage(video, 0, 0); | 39 ctx.drawImage(video, 0, 0); |
| 38 ctx.globalAlpha = 0.5; | 40 ctx.globalAlpha = 0.5; |
| 39 ctx.drawImage(video, 0, 60); | 41 ctx.drawImage(video, 0, 60); |
| 42 } | |
| 43 | |
| 44 function drawImageToCanvas() { | |
| 45 video.removeEventListener("playing", drawImageToCanvas, true); | |
| 46 for (i = 0; i < 10; i++) { | |
| 47 drawVideo(sw_ctx, sw_canvas); | |
| 48 drawVideo(hw_ctx, hw_canvas); | |
| 49 } | |
| 40 if (window.testRunner) | 50 if (window.testRunner) |
| 41 testRunner.notifyDone(); | 51 testRunner.notifyDone(); |
| 42 } | 52 } |
| 43 </script> | 53 </script> |
| 44 </body> | 54 </body> |
| 45 </html> | 55 </html> |
| OLD | NEW |