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

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

Issue 2845193002: Refactor ImageBitmap constructor from ImageData to be color managed
Patch Set: local commit - all working except unpremultiply Created 3 years, 6 months 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-drawImage-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../../resources/js-test.js"></script> 4 <script src="../../resources/js-test.js"></script>
5 </head> 5 </head>
6 <body> 6 <body>
7 <script> 7 <script>
8 8
9 description("Ensure correct behavior of drawImage with ImageBitmaps."); 9 description("Ensure correct behavior of drawImage with ImageBitmaps.");
10 window.jsTestIsAsync = true; 10 window.jsTestIsAsync = true;
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 xhr.onload = function() { 147 xhr.onload = function() {
148 blob = xhr.response; 148 blob = xhr.response;
149 blobLoaded = true; 149 blobLoaded = true;
150 loaded(); 150 loaded();
151 } 151 }
152 152
153 function loaded() { 153 function loaded() {
154 if (imageLoaded && imageBitmapLoaded && blobLoaded) { 154 if (imageLoaded && imageBitmapLoaded && blobLoaded) {
155 // check all of these elements 155 // check all of these elements
156 elements = [image, aCanvas, d, testBitmap, blob]; 156 elements = [image, aCanvas, d, testBitmap, blob];
157 //elements = [image];//, aCanvas, d, testBitmap, blob];
157 // wait for callback to finish before each check to ensure synchronous b ehavior 158 // wait for callback to finish before each check to ensure synchronous b ehavior
158 nextCheck(0); 159 nextCheck(0);
159 } 160 }
160 } 161 }
161 162
162 function nextCheck(elementIndex) { 163 function nextCheck(elementIndex) {
163 if (elementIndex == elements.length) { 164 if (elementIndex == elements.length) {
164 finishJSTest(); 165 finishJSTest();
165 return; 166 return;
166 } 167 }
167 var element = elements[elementIndex]; 168 var element = elements[elementIndex];
168 imageBitmaps = {}; 169 imageBitmaps = {};
169 debug("Checking " + jsWrapperClass(element) + "."); 170 debug("Checking " + jsWrapperClass(element) + ".");
170 var p1 = createImageBitmap(element).then(function (image) { imageBitmaps.noC rop = image }); 171 var p1 = createImageBitmap(element).then(function (image) { imageBitmaps.noC rop = image });
171 var p2 = createImageBitmap(element, 0, 0, 10, 10).then(function (image) { im ageBitmaps.crop = image }); 172 var p2 = createImageBitmap(element, 0, 0, 10, 10).then(function (image) { im ageBitmaps.crop = image });
172 var p3 = createImageBitmap(element, 5, 5, 10, 10).then(function (image) { im ageBitmaps.cropCenter = image }); 173 var p3 = createImageBitmap(element, 5, 5, 10, 10).then(function (image) { im ageBitmaps.cropCenter = image });
173 var p4 = createImageBitmap(element, 10, 10, 10, 10).then(function (image) { imageBitmaps.cropRight = image }); 174 var p4 = createImageBitmap(element, 10, 10, 10, 10).then(function (image) { imageBitmaps.cropRight = image });
174 var p5 = createImageBitmap(element, -10, -10, 60, 60).then(function (image) { imageBitmaps.overCrop = image }); 175 var p5 = createImageBitmap(element, -10, -10, 60, 60).then(function (image) { imageBitmaps.overCrop = image });
175 var p6 = createImageBitmap(element, 10, 10, 50, 50).then(function (image) { imageBitmaps.overCropRight = image }); 176 var p6 = createImageBitmap(element, 10, 10, 50, 50).then(function (image) { imageBitmaps.overCropRight = image });
176 var p7 = createImageBitmap(element, 10, 10, -10, -10).then(function (image) { imageBitmaps.negativeCrop = image }); 177 var p7 = createImageBitmap(element, 10, 10, -10, -10).then(function (image) { imageBitmaps.negativeCrop = image });
177 var p8 = createImageBitmap(element, -30, -30, 30, 30).then(function (image) { imageBitmaps.empty = image }); 178 var p8 = createImageBitmap(element, -30, -30, 30, 30).then(function (image) { imageBitmaps.empty = image });
178 var p9 = createImageBitmap(element, 40, 30, 30, 30).then(function (image) { imageBitmaps.emptyTwo = image }); 179 var p9 = createImageBitmap(element, 40, 30, 30, 30).then(function (image) { imageBitmaps.emptyTwo = image });
179 Promise.all([p1, p2, p3, p4, p5, p6, p7, p8, p9]).then(function() { 180 Promise.all([p1, p2, p3, p4, p5, p6, p7, p8, p9]).then(function() {
181 // Promise.all([p5]).then(function() {
180 checkNoCrop(imageBitmaps.noCrop); 182 checkNoCrop(imageBitmaps.noCrop);
181 checkCrop(imageBitmaps.crop); 183 checkCrop(imageBitmaps.crop);
182 checkCropCenter(imageBitmaps.cropCenter); 184 checkCropCenter(imageBitmaps.cropCenter);
183 checkCropRight(imageBitmaps.cropRight); 185 checkCropRight(imageBitmaps.cropRight);
184 checkOverCrop(imageBitmaps.overCrop); 186 checkOverCrop(imageBitmaps.overCrop);
185 checkOverCropRight(imageBitmaps.overCropRight); 187 checkOverCropRight(imageBitmaps.overCropRight);
186 checkCrop(imageBitmaps.negativeCrop); 188 checkCrop(imageBitmaps.negativeCrop);
187 checkEmpty(imageBitmaps.empty); 189 checkEmpty(imageBitmaps.empty);
188 checkEmpty(imageBitmaps.emptyTwo); 190 checkEmpty(imageBitmaps.emptyTwo);
189 createImageBitmap(element, 0, 0, 0x8000, 0x8000).then(function() { 191 createImageBitmap(element, 0, 0, 0x8000, 0x8000).then(function() {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 function checkCrop(imageBitmap) { 255 function checkCrop(imageBitmap) {
254 debug("Check crop."); 256 debug("Check crop.");
255 bitmap = imageBitmap; 257 bitmap = imageBitmap;
256 shouldBeType("bitmap", "ImageBitmap"); 258 shouldBeType("bitmap", "ImageBitmap");
257 shouldBe("bitmap.width", "10"); 259 shouldBe("bitmap.width", "10");
258 shouldBe("bitmap.height", "10"); 260 shouldBe("bitmap.height", "10");
259 261
260 // red should be drawn to (0, 0), (10, 10) 262 // red should be drawn to (0, 0), (10, 10)
261 clearContext(ctx); 263 clearContext(ctx);
262 ctx.drawImage(imageBitmap, 0, 0); 264 ctx.drawImage(imageBitmap, 0, 0);
265 shouldBeRed(0, 1);
266 shouldBeRed(1, 0);
263 shouldBeRed(1, 1); 267 shouldBeRed(1, 1);
264 shouldBeRed(9, 9); 268 shouldBeRed(9, 9);
265 shouldBeClear(12, 12); 269 shouldBeClear(12, 12);
266 shouldBeClear(1, 12); 270 shouldBeClear(1, 12);
267 shouldBeClear(12, 1); 271 shouldBeClear(12, 1);
268 272
269 // red should be drawn to (0, 0), (20, 20) 273 // red should be drawn to (0, 0), (20, 20)
270 clearContext(ctx); 274 clearContext(ctx);
271 ctx.drawImage(imageBitmap, 0, 0, 20, 20); 275 ctx.drawImage(imageBitmap, 0, 0, 20, 20);
272 shouldBeRed(1, 1); 276 shouldBeRed(1, 1);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 shouldBeBlack(9, 9); 326 shouldBeBlack(9, 9);
323 shouldBeClear(11, 11); 327 shouldBeClear(11, 11);
324 shouldBeClear(1, 11); 328 shouldBeClear(1, 11);
325 shouldBeClear(11, 1); 329 shouldBeClear(11, 1);
326 } 330 }
327 331
328 function checkOverCrop(imageBitmap) { 332 function checkOverCrop(imageBitmap) {
329 debug("Check over crop."); 333 debug("Check over crop.");
330 bitmap = imageBitmap; 334 bitmap = imageBitmap;
331 shouldBeType("bitmap", "ImageBitmap"); 335 shouldBeType("bitmap", "ImageBitmap");
332 shouldBe("bitmap.width", "60"); 336 shouldBe("bitmap.width", "20");
333 shouldBe("bitmap.height", "60"); 337 shouldBe("bitmap.height", "20");
334 338
335 // should be drawn to (10, 10), (30, 30) 339 // should be drawn to (0, 0), (20, 20)
336 clearContext(ctx); 340 clearContext(ctx);
337 ctx.drawImage(imageBitmap, 0, 0); 341 ctx.drawImage(imageBitmap, 0, 0);
338 shouldBeClear(1, 1);
339 shouldBeClear(9, 9);
340 shouldBeRed(11, 11);
341 shouldBeRed(19, 19);
342 shouldBeGreen(21, 19);
343 shouldBeBlue(19, 21);
344 shouldBeBlack(21, 21);
345 shouldBeBlack(29, 29);
346 shouldBeClear(32, 1);
347 shouldBeClear(1, 32);
348 shouldBeClear(32, 32);
349
350 // should be drawn to (5, 5), (15, 15)
351 clearContext(ctx);
352 ctx.drawImage(imageBitmap, 0, 0, 30, 30);
353 shouldBeClear(1, 1);
354 shouldBeClear(4, 4);
355 shouldBeRed(6, 6);
356 shouldBeRed(9, 9); 342 shouldBeRed(9, 9);
357 shouldBeGreen(11, 9); 343 shouldBeGreen(11, 9);
358 shouldBeBlue(9, 11); 344 shouldBeBlue(9, 11);
359 shouldBeBlack(11, 11); 345 shouldBeBlack(11, 11);
360 shouldBeBlack(14, 14); 346 shouldBeBlack(19, 19);
361 shouldBeClear(16, 1); 347 shouldBeClear(1, 21);
362 shouldBeClear(1, 16); 348 shouldBeClear(21, 1);
363 shouldBeClear(16, 16); 349 shouldBeClear(21, 21);
350
351 // shrunk to (0, 0), (10, 10)
352 clearContext(ctx);
353 ctx.drawImage(imageBitmap, 0, 0, 10, 10);
354 shouldBeRed(4, 4);
355 shouldBeGreen(6, 4);
356 shouldBeBlue(4, 6);
357 shouldBeBlack(6, 6);
358 shouldBeBlack(9, 9);
359 shouldBeClear(1, 11);
360 shouldBeClear(11, 1);
361 shouldBeClear(11, 11);
364 } 362 }
365 363
366 function checkOverCropRight(imageBitmap) { 364 function checkOverCropRight(imageBitmap) {
367 debug("Check over crop right."); 365 debug("Check over crop right.");
368 bitmap = imageBitmap; 366 bitmap = imageBitmap;
369 shouldBe("bitmap.width", "50"); 367 shouldBe("bitmap.width", "10");
370 shouldBe("bitmap.height", "50"); 368 shouldBe("bitmap.height", "10");
371 369
372 // black should be drawn to (0, 0), (10, 10) 370 // black should be drawn to (0, 0), (10, 10)
373 clearContext(ctx); 371 clearContext(ctx);
374 ctx.drawImage(imageBitmap, 0, 0); 372 ctx.drawImage(imageBitmap, 0, 0);
375 shouldBeBlack(1, 1); 373 shouldBeBlack(1, 1);
376 shouldBeBlack(9, 9); 374 shouldBeBlack(9, 9);
377 shouldBeClear(11, 11); 375 shouldBeClear(11, 11);
378 shouldBeClear(1, 11); 376 shouldBeClear(1, 11);
379 shouldBeClear(11, 1); 377 shouldBeClear(11, 1);
380 378
381 // black should be drawn to (0, 0), (4, 4) 379 // black should be drawn to (0, 0), (4, 4)
382 clearContext(ctx); 380 clearContext(ctx);
383 ctx.drawImage(imageBitmap, 0, 0, 20, 20); 381 ctx.drawImage(imageBitmap, 0, 0, 4, 4);
384 shouldBeBlack(1, 1); 382 shouldBeBlack(1, 1);
385 shouldBeBlack(3, 3); 383 shouldBeBlack(3, 3);
386 shouldBeClear(5, 5); 384 shouldBeClear(5, 5);
387 shouldBeClear(1, 5); 385 shouldBeClear(1, 5);
388 shouldBeClear(5, 1); 386 shouldBeClear(5, 1);
389 387
390 // nothing should be drawn 388 // nothing should be drawn
391 clearContext(ctx); 389 clearContext(ctx);
392 ctx.drawImage(imageBitmap, 10, 10, 20, 20, 0, 0, 20, 20); 390 ctx.drawImage(imageBitmap, 10, 10, 20, 20, 0, 0, 20, 20);
393 shouldBeClear(1, 1); 391 shouldBeClear(1, 1);
(...skipping 15 matching lines...) Expand all
409 ctx.drawImage(imageBitmap, 0, 0); 407 ctx.drawImage(imageBitmap, 0, 0);
410 shouldBeClear(1, 1); 408 shouldBeClear(1, 1);
411 shouldBeClear(9, 9); 409 shouldBeClear(9, 9);
412 shouldBeClear(11, 11); 410 shouldBeClear(11, 11);
413 shouldBeClear(22, 22); 411 shouldBeClear(22, 22);
414 } 412 }
415 413
416 </script> 414 </script>
417 </body> 415 </body>
418 </html> 416 </html>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-drawImage-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698