OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE HTML> |
| 2 <script src="../../resources/testharness.js"></script> |
| 3 <script src="../../resources/testharnessreport.js"></script> |
| 4 <script> |
| 5 function createNewCanvas(width, height) |
| 6 { |
| 7 var canvas = document.createElement("canvas"); |
| 8 canvas.width = width; |
| 9 canvas.height = height; |
| 10 var ctx = canvas.getContext("2d"); |
| 11 ctx.clearRect(0, 0, width, height); |
| 12 return ctx; |
| 13 } |
| 14 |
| 15 function compareTwoCanvases(ctx1, ctx2, width, height) |
| 16 { |
| 17 var data1 = ctx1.getImageData(0, 0, width, height).data; |
| 18 var data2 = ctx2.getImageData(0, 0, width, height).data; |
| 19 var dataMatched = true; |
| 20 for (var i = 0; i < data1.length; i++) { |
| 21 if (data1[i] != data2[i]) { |
| 22 dataMatched = false; |
| 23 break; |
| 24 } |
| 25 } |
| 26 assert_false(dataMatched); |
| 27 } |
| 28 |
| 29 async_test(function(t) { |
| 30 var video = document.createElement("video"); |
| 31 video.oncanplaythrough = t.step_func_done(function() { |
| 32 video.pause(); |
| 33 var width = 100; |
| 34 var height = 100; |
| 35 var ctx1 = createNewCanvas(width, height); |
| 36 var ctx2 = createNewCanvas(width, height); |
| 37 ctx1.imageSmoothingEnabled = true; |
| 38 ctx1.imageSmoothingQuality = 'low'; |
| 39 ctx2.imageSmoothingEnabled = true; |
| 40 ctx2.imageSmoothingQuality = 'high'; |
| 41 ctx1.drawImage(video, 0, 0, video.videoWidth, video.videoHeight, 0, 0, w
idth, height); |
| 42 ctx2.drawImage(video, 0, 0, video.videoWidth, video.videoHeight, 0, 0, w
idth, height); |
| 43 compareTwoCanvases(ctx1, ctx2, width, height); |
| 44 }); |
| 45 video.src = "../../compositing/resources/video.ogv"; |
| 46 }, 'drawImage from a video should look differently with different imageSmoothing
Quality'); |
| 47 </script> |
OLD | NEW |