| 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 <!-- | |
| 14 If we creates two video elements for each canvas, each video caches sw bitma
p or | |
| 15 hw bitmap respectively. So the -expected.html creates two videos. | |
| 16 --> | |
| 17 <video id="video-for-hw-canvas" loop> | |
| 18 <source src="resources/canvas_video.mp4" type='video/mp4' /> | |
| 19 <source src="resources/canvas_video.webm" type='video/webm' /> | |
| 20 <source src="resources/canvas_video.ogv" type='video/ogg' /> | |
| 21 </video> | |
| 22 <video id="video-for-sw-canvas" loop> | |
| 23 <source src="resources/canvas_video.mp4" type='video/mp4' /> | |
| 24 <source src="resources/canvas_video.webm" type='video/webm' /> | |
| 25 <source src="resources/canvas_video.ogv" type='video/ogg' /> | |
| 26 </video> | |
| 27 <script> | |
| 28 if (window.testRunner) { | |
| 29 testRunner.waitUntilDone(); | |
| 30 } | |
| 31 if (window.internals) | |
| 32 window.internals.settings.setMinimumAccelerated2dCanvasSize(257*256); | |
| 33 | |
| 34 var hw_canvas = document.getElementById("hw-canvas"); | |
| 35 var hw_ctx = hw_canvas.getContext("2d"); | |
| 36 // Although enabling accelerated-2d-canvas, canvas with the dimension | |
| 37 // less than 257*256 is not accelerated. | |
| 38 var sw_canvas = document.getElementById("sw-canvas"); | |
| 39 var sw_ctx = sw_canvas.getContext("2d"); | |
| 40 | |
| 41 var blockUntilPlayingBothVideo = true; | |
| 42 var video_for_hw_canvas = document.getElementById("video-for-hw-canvas"); | |
| 43 video_for_hw_canvas.addEventListener("playing", onHwVideoPlaying, true); | |
| 44 video_for_hw_canvas.play(); | |
| 45 function onHwVideoPlaying() { | |
| 46 video_for_hw_canvas.removeEventListener("playing", onHwVideoPlaying, true); | |
| 47 if (blockUntilPlayingBothVideo) { | |
| 48 blockUntilPlayingBothVideo = false; | |
| 49 } else { | |
| 50 drawImageToCanvas(); | |
| 51 } | |
| 52 } | |
| 53 var video_for_sw_canvas = document.getElementById("video-for-sw-canvas"); | |
| 54 video_for_sw_canvas.addEventListener("playing", onSwVideoPlaying, true); | |
| 55 video_for_sw_canvas.play(); | |
| 56 function onSwVideoPlaying() { | |
| 57 video_for_sw_canvas.removeEventListener("playing", onSwVideoPlaying, true); | |
| 58 if (blockUntilPlayingBothVideo) { | |
| 59 blockUntilPlayingBothVideo = false; | |
| 60 } else { | |
| 61 drawImageToCanvas(); | |
| 62 } | |
| 63 } | |
| 64 | |
| 65 function drawVideo(video, ctx, canvas) { | |
| 66 ctx.globalAlpha = 1; | |
| 67 ctx.fillStyle = "blue"; | |
| 68 ctx.fillRect(0, 0, canvas.width, canvas.width); | |
| 69 ctx.drawImage(video, 0, 0); | |
| 70 ctx.globalAlpha = 0.5; | |
| 71 ctx.drawImage(video, 0, 60); | |
| 72 } | |
| 73 | |
| 74 function drawImageToCanvas() { | |
| 75 // draw a different video on a different canvas. | |
| 76 drawVideo(video_for_sw_canvas, sw_ctx, sw_canvas); | |
| 77 drawVideo(video_for_hw_canvas, hw_ctx, hw_canvas); | |
| 78 if (window.testRunner) | |
| 79 testRunner.notifyDone(); | |
| 80 } | |
| 81 </script> | |
| 82 </body> | |
| 83 </html> | |
| OLD | NEW |