Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-recursive.html

Issue 1413583004: refractoring ImageBitmap class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clean up code Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <html> 1 <html>
2 <head> 2 <head>
3 <script src="../../resources/js-test.js"></script> 3 <script src="../../resources/js-test.js"></script>
4 </head> 4 </head>
5 <body> 5 <body>
6 <script> 6 <script>
7 description("Ensure correct behavior of drawImage with ImageBitmaps constructed from ImageBitmaps that are constructed from images (not pinned to memory) and ca nvases (pinned to memory)."); 7 description("Ensure correct behavior of drawImage with ImageBitmaps constructed from ImageBitmaps that are constructed from images (not pinned to memory) and ca nvases (pinned to memory).");
8 8
9 window.jsTestIsAsync = true; 9 window.jsTestIsAsync = true;
10 10
11 function shouldBeFilled(x, y, w, h) { 11 function shouldBeFilled(x, y, w, h) {
12 shouldBeGreen(x+2, y+2); 12 shouldBeGreen(x+2, y+2);
13 shouldBeGreen(x+w-2, y+h-2); 13 shouldBeGreen(x+w-3, y+h-3);
14 shouldBeGreen(x+w/2, y+h/2); 14 shouldBeGreen(x+w/2, y+h/2);
15 shouldBeClear(x-2, y-2); 15 shouldBeClear(x-2, y-2);
16 shouldBeClear(x+w+2, y+h+2); 16 shouldBeClear(x+w+2, y+h+2);
17 } 17 }
18 function shouldBeGreen(x, y) { 18 function shouldBeGreen(x, y) {
19 d = ctx.getImageData(x, y, 1, 1).data; 19 d = ctx.getImageData(x, y, 1, 1).data;
20 shouldBeTrue("d[0] == 0"); 20 shouldBe("d[0]", "0");
21 shouldBeTrue("d[1] == 255"); 21 shouldBe("d[1]", "255");
22 shouldBeTrue("d[2] == 0"); 22 shouldBe("d[2]", "0");
23 shouldBeTrue("d[3] == 255"); 23 shouldBe("d[3]", "255");
24 } 24 }
25 function shouldBeClear(x, y) { 25 function shouldBeClear(x, y) {
26 // should be transparent black pixels 26 // should be transparent black pixels
27 d = ctx.getImageData(x, y, 1, 1).data; 27 d = ctx.getImageData(x, y, 1, 1).data;
28 shouldBeTrue("d[0] == 0"); 28 shouldBe("d[0]", "0");
29 shouldBeTrue("d[1] == 0"); 29 shouldBe("d[1]", "0");
30 shouldBeTrue("d[2] == 0"); 30 shouldBe("d[2]", "0");
31 shouldBeTrue("d[3] == 0"); 31 shouldBe("d[3]", "0");
32 } 32 }
33 function shouldNotBeCalled() { 33 function shouldNotBeCalled() {
34 testFailed("Promise was rejected."); 34 testFailed("Promise was rejected.");
35 finishJSTest(); 35 finishJSTest();
36 } 36 }
37 function clearContext(context) { 37 function clearContext(context) {
38 context.clearRect(0, 0, 50, 50); 38 context.clearRect(0, 0, 50, 50);
39 } 39 }
40 40
41 var image; 41 var image;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 ctx.drawImage(imageBitmap, 0, 0, 50, 50); 120 ctx.drawImage(imageBitmap, 0, 0, 50, 50);
121 // scale up w and h as necessary 121 // scale up w and h as necessary
122 var w3 = w1 * 50.0 / imageBitmap.width; 122 var w3 = w1 * 50.0 / imageBitmap.width;
123 var h3 = h1 * 50.0 / imageBitmap.height; 123 var h3 = h1 * 50.0 / imageBitmap.height;
124 // x and y are transformed 124 // x and y are transformed
125 var x3 = x1 * w3 / w1; 125 var x3 = x1 * w3 / w1;
126 var y3 = y1 * h3 / h1; 126 var y3 = y1 * h3 / h1;
127 shouldBeFilled(x3, y3, w3, h3); 127 shouldBeFilled(x3, y3, w3, h3);
128 128
129 clearContext(ctx); 129 clearContext(ctx);
130 ctx.imageSmoothingEnabled=false;
130 ctx.drawImage(imageBitmap, x1, y1, w1, h1, 0, 0, 50, 50); 131 ctx.drawImage(imageBitmap, x1, y1, w1, h1, 0, 0, 50, 50);
131 shouldBeFilled(0, 0, 50, 50); 132 shouldBeFilled(0, 0, 50, 50);
132 } 133 }
133 } 134 }
134 135
135 </script> 136 </script>
136 </body> 137 </body>
137 </html> 138 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698