| OLD | NEW |
| (Empty) | |
| 1 <html> |
| 2 <head> |
| 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"> |
| 5 video { |
| 6 display: none; |
| 7 } |
| 8 </style> |
| 9 </head> |
| 10 <body> |
| 11 <canvas id="hw-canvas" width=300 height=300></canvas> |
| 12 <canvas id="sw-canvas" width=150 height=150></canvas> |
| 13 <video id="hw-video" loop> |
| 14 <source src="resources/canvas_video.mp4" type='video/mp4' /> |
| 15 <source src="resources/canvas_video.webm" type='video/webm' /> |
| 16 <source src="resources/canvas_video.ogv" type='video/ogg' /> |
| 17 </video> |
| 18 <video id="sw-video" loop> |
| 19 <source src="resources/canvas_video.mp4" type='video/mp4' /> |
| 20 <source src="resources/canvas_video.webm" type='video/webm' /> |
| 21 <source src="resources/canvas_video.ogv" type='video/ogg' /> |
| 22 </video> |
| 23 <script> |
| 24 if (window.testRunner) { |
| 25 testRunner.waitUntilDone(); |
| 26 } |
| 27 |
| 28 var hw_canvas = document.getElementById("hw-canvas"); |
| 29 var hw_ctx = hw_canvas.getContext("2d"); |
| 30 // Although enabling accelerated-2d-canvas, canvas with the dimension |
| 31 // less than 257*256 is not accelerated. |
| 32 var sw_canvas = document.getElementById("sw-canvas"); |
| 33 var sw_ctx = sw_canvas.getContext("2d"); |
| 34 |
| 35 var blockUntilPlayingBothVideo = true; |
| 36 var hw_video = document.getElementById("hw-video"); |
| 37 hw_video.addEventListener("playing", onHwVideoPlaying, true); |
| 38 hw_video.play(); |
| 39 function onHwVideoPlaying() { |
| 40 hw_video.removeEventListener("playing", onHwVideoPlaying, true); |
| 41 if (blockUntilPlayingBothVideo) { |
| 42 blockUntilPlayingBothVideo = false; |
| 43 } else { |
| 44 drawImageToCanvas(); |
| 45 } |
| 46 } |
| 47 var sw_video = document.getElementById("sw-video"); |
| 48 sw_video.addEventListener("playing", onSwVideoPlaying, true); |
| 49 sw_video.play(); |
| 50 function onSwVideoPlaying() { |
| 51 sw_video.removeEventListener("playing", onSwVideoPlaying, true); |
| 52 if (blockUntilPlayingBothVideo) { |
| 53 blockUntilPlayingBothVideo = false; |
| 54 } else { |
| 55 drawImageToCanvas(); |
| 56 } |
| 57 } |
| 58 |
| 59 function drawVideo(video, ctx, canvas) { |
| 60 ctx.globalAlpha = 1; |
| 61 ctx.fillStyle = "blue"; |
| 62 ctx.fillRect(0, 0, canvas.width, canvas.width); |
| 63 ctx.drawImage(video, 0, 0); |
| 64 ctx.globalAlpha = 0.5; |
| 65 ctx.drawImage(video, 0, 60); |
| 66 } |
| 67 |
| 68 function drawImageToCanvas() { |
| 69 // draw a different video on a different canvas. |
| 70 drawVideo(sw_video, sw_ctx, sw_canvas); |
| 71 drawVideo(hw_video, hw_ctx, hw_canvas); |
| 72 if (window.testRunner) |
| 73 testRunner.notifyDone(); |
| 74 } |
| 75 </script> |
| 76 </body> |
| 77 </html> |
| OLD | NEW |