Chromium Code Reviews| 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> | |
|
Justin Novosad
2014/10/20 20:39:02
What exactly makes this video sw and the other one
dshwang
2014/10/20 20:46:47
sw-canvas uses sw-video while hw-canvas uses hw-vi
Justin Novosad
2014/10/20 20:51:42
I don't understand what is the difference between
| |
| 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> | |
|
Justin Novosad
2014/10/20 20:39:02
Inconsistent indentation
dshwang
2014/10/20 20:46:47
do you mean 4-space indentation?
Justin Novosad
2014/10/20 20:51:42
No. I mean <video> and the matching </video> are n
| |
| 23 <script> | |
| 24 if (window.testRunner) { | |
| 25 testRunner.waitUntilDone(); | |
| 26 } | |
| 27 if (window.internals) | |
| 28 window.internals.settings.setMinimumAccelerated2dCanvasSize(257*256); | |
| 29 | |
| 30 var hw_canvas = document.getElementById("hw-canvas"); | |
| 31 var hw_ctx = hw_canvas.getContext("2d"); | |
| 32 // Although enabling accelerated-2d-canvas, canvas with the dimension | |
| 33 // less than 257*256 is not accelerated. | |
| 34 var sw_canvas = document.getElementById("sw-canvas"); | |
| 35 var sw_ctx = sw_canvas.getContext("2d"); | |
| 36 | |
| 37 var blockUntilPlayingBothVideo = true; | |
| 38 var hw_video = document.getElementById("hw-video"); | |
| 39 hw_video.addEventListener("playing", onHwVideoPlaying, true); | |
| 40 hw_video.play(); | |
| 41 function onHwVideoPlaying() { | |
| 42 hw_video.removeEventListener("playing", onHwVideoPlaying, true); | |
| 43 if (blockUntilPlayingBothVideo) { | |
| 44 blockUntilPlayingBothVideo = false; | |
| 45 } else { | |
| 46 drawImageToCanvas(); | |
| 47 } | |
| 48 } | |
| 49 var sw_video = document.getElementById("sw-video"); | |
| 50 sw_video.addEventListener("playing", onSwVideoPlaying, true); | |
| 51 sw_video.play(); | |
| 52 function onSwVideoPlaying() { | |
| 53 sw_video.removeEventListener("playing", onSwVideoPlaying, true); | |
| 54 if (blockUntilPlayingBothVideo) { | |
| 55 blockUntilPlayingBothVideo = false; | |
| 56 } else { | |
| 57 drawImageToCanvas(); | |
| 58 } | |
| 59 } | |
| 60 | |
| 61 function drawVideo(video, ctx, canvas) { | |
| 62 ctx.globalAlpha = 1; | |
| 63 ctx.fillStyle = "blue"; | |
| 64 ctx.fillRect(0, 0, canvas.width, canvas.width); | |
| 65 ctx.drawImage(video, 0, 0); | |
| 66 ctx.globalAlpha = 0.5; | |
| 67 ctx.drawImage(video, 0, 60); | |
| 68 } | |
| 69 | |
| 70 function drawImageToCanvas() { | |
| 71 // draw a different video on a different canvas. | |
| 72 drawVideo(sw_video, sw_ctx, sw_canvas); | |
| 73 drawVideo(hw_video, hw_ctx, hw_canvas); | |
| 74 if (window.testRunner) | |
| 75 testRunner.notifyDone(); | |
| 76 } | |
| 77 </script> | |
| 78 </body> | |
| 79 </html> | |
| OLD | NEW |