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

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

Issue 19393004: Allow eviction of ImageBitmaps that are created from ImageElements. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix drawImage out of bounds src rect. Created 7 years, 4 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 | Annotate | Revision Log
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="../js/resources/js-test-pre.js"></script> 4 <script src="../js/resources/js-test-pre.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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 imageBitmapLoaded = true; 134 imageBitmapLoaded = true;
135 loaded(); 135 loaded();
136 } 136 }
137 137
138 function loaded() { 138 function loaded() {
139 if (imageLoaded && imageBitmapLoaded) { 139 if (imageLoaded && imageBitmapLoaded) {
140 // check all of these elements 140 // check all of these elements
141 elements = [image, aCanvas, d, aCtx, testBitmap]; 141 elements = [image, aCanvas, d, aCtx, testBitmap];
142 142
143 // with all of these checks 143 // with all of these checks
144 checks = [checkNoCrop, checkCrop, checkCropRight, checkOverCrop, checkOv erCropRight, checkNegativeCrop, checkEmpty, checkEmpty2, checkImmutable]; 144 checks = [checkNoCrop, checkCrop, checkCropRight, checkOverCrop, checkOv erCropRight, checkNegativeCrop, checkEmpty, checkEmpty2];
145 145
146 // wait for callback to finish before each check to ensure synchronous b ehavior 146 // wait for callback to finish before each check to ensure synchronous b ehavior
147 nextCheck(); 147 nextCheck();
148 } 148 }
149 } 149 }
150 150
151 // these counters are incremented after every check 151 // these counters are incremented after every check
152 var i = 0; 152 var i = 0;
153 var j = 0; 153 var j = 0;
154 var callbackCount = 0; 154 var callbackCount = 0;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 function checkEmpty(element) { 195 function checkEmpty(element) {
196 debug("checkEmpty with ".concat(jsWrapperClass(element))); 196 debug("checkEmpty with ".concat(jsWrapperClass(element)));
197 createImageBitmap(element, callbackEmpty, -30, -30, 30, 30); 197 createImageBitmap(element, callbackEmpty, -30, -30, 30, 30);
198 } 198 }
199 199
200 function checkEmpty2(element) { 200 function checkEmpty2(element) {
201 debug("checkEmpty2 with ".concat(jsWrapperClass(element))); 201 debug("checkEmpty2 with ".concat(jsWrapperClass(element)));
202 createImageBitmap(element, callbackEmpty, 40, 30, 30, 30); 202 createImageBitmap(element, callbackEmpty, 40, 30, 30, 30);
203 } 203 }
204 204
205 function checkImmutable(element) { 205 function checkImmutable(element) {
Stephen White 2013/07/25 18:01:07 This function now seems to be unused; please remov
206 debug("checkImmutable with ".concat(jsWrapperClass(element))); 206 debug("checkImmutable with ".concat(jsWrapperClass(element)));
207 createImageBitmap(element, callbackImmutable); 207 createImageBitmap(element, callbackImmutable);
208 } 208 }
209 209
210 function callbackNoCrop(imageBitmap) { 210 function callbackNoCrop(imageBitmap) {
211 bitmap = imageBitmap; 211 bitmap = imageBitmap;
212 shouldBe("bitmap.width", "imageWidth"); 212 shouldBe("bitmap.width", "imageWidth");
213 shouldBe("bitmap.height", "imageHeight"); 213 shouldBe("bitmap.height", "imageHeight");
214 214
215 // should be drawn to (0, 0), (20, 20) 215 // should be drawn to (0, 0), (20, 20)
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 clearContext(ctx); 418 clearContext(ctx);
419 ctx.drawImage(imageBitmap, 0, 0); 419 ctx.drawImage(imageBitmap, 0, 0);
420 shouldBeClear(1, 1); 420 shouldBeClear(1, 1);
421 shouldBeClear(9, 9); 421 shouldBeClear(9, 9);
422 shouldBeClear(11, 11); 422 shouldBeClear(11, 11);
423 shouldBeClear(22, 22); 423 shouldBeClear(22, 22);
424 424
425 commonCallback(imageBitmap); 425 commonCallback(imageBitmap);
426 } 426 }
427 427
428 function callbackImmutable(imageBitmap) {
429 // change the underlying element to ensure that it does not change the image Bitmap
430 switch(i) {
431 case 0: // image
432 image = new Image();
433 break;
434 case 1: // canvas
435 clearContext(aCtx);
436 break;
437 case 2: // data
438 d = 0;
439 break;
440 case 3: // context
441 clearContext(aCtx);
442 break;
443 case 4: // bitmap
444 testBitmap = 0;
445 break;
446 default:
447 testFailed("Default should not be called.");
448 }
449 // should be drawn to (0, 0), (20, 20)
450 callbackNoCrop(imageBitmap);
451
452 // we potentially cleared our auxillary context, so redraw the image
453 drawPattern(aCtx);
454 }
455
456 function commonCallback(imageBitmap) { 428 function commonCallback(imageBitmap) {
457 bitmap = imageBitmap; 429 bitmap = imageBitmap;
458 shouldBeType("bitmap", "ImageBitmap"); 430 shouldBeType("bitmap", "ImageBitmap");
459 431
460 callbackCount += 1; 432 callbackCount += 1;
461 433
462 if (callbackCount < elements.length * checks.length) { 434 if (callbackCount < elements.length * checks.length) {
463 ++j; 435 ++j;
464 if(j == checks.length) { 436 if(j == checks.length) {
465 // completed all the checks for the ith element 437 // completed all the checks for the ith element
466 j = 0; 438 j = 0;
467 ++i; 439 ++i;
468 } 440 }
469 nextCheck(); 441 nextCheck();
470 } else { 442 } else {
471 finishJSTest(); 443 finishJSTest();
472 } 444 }
473 } 445 }
474 446
475 </script> 447 </script>
476 <script src="../js/resources/js-test-post.js"></script> 448 <script src="../js/resources/js-test-post.js"></script>
477 </body> 449 </body>
478 </html> 450 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698