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

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: Use CachedImage as the backing store for ImageBitmap. Implement O(1) decode cache. Created 7 years, 5 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 var checks; 90 var checks;
91 var elements; 91 var elements;
92 92
93 // Create auxiliary canvas to draw to and create an image from. 93 // Create auxiliary canvas to draw to and create an image from.
94 var aCanvas = document.createElement("canvas"); 94 var aCanvas = document.createElement("canvas");
95 aCanvas.setAttribute("width", "200"); 95 aCanvas.setAttribute("width", "200");
96 aCanvas.setAttribute("height", "200"); 96 aCanvas.setAttribute("height", "200");
97 var aCtx = aCanvas.getContext("2d"); 97 var aCtx = aCanvas.getContext("2d");
98 drawPattern(aCtx); 98 drawPattern(aCtx);
99 99
100 var bCanvas = document.createElement("canvas");
101 bCanvas.setAttribute("width", "200");
102 bCanvas.setAttribute("height", "200");
103 var bCtx = bCanvas.getContext("2d");
104 bCtx.fillStyle = 'red';
105 bCtx.fillRect(0, 0, 200, 200);
106
100 var canvas = document.createElement("canvas"); 107 var canvas = document.createElement("canvas");
101 canvas.setAttribute("width", "500"); 108 canvas.setAttribute("width", "500");
102 canvas.setAttribute("height", "500"); 109 canvas.setAttribute("height", "500");
103 var ctx = canvas.getContext("2d"); 110 var ctx = canvas.getContext("2d");
104 111
105 image = new Image(); 112 image = new Image();
106 image.onload = imageLoaded; 113 image.onload = imageLoaded;
107 image.src = aCanvas.toDataURL(); // set a data URI of the base64 enconded image as the source 114 image.src = aCanvas.toDataURL(); // set a data URI of the base64 enconded image as the source
108 115
109 var imageLoaded = false; 116 var imageLoaded = false;
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 shouldBeClear(110, 110); 388 shouldBeClear(110, 110);
382 shouldBeClear(210, 210); 389 shouldBeClear(210, 210);
383 390
384 commonCallback(imageBitmap); 391 commonCallback(imageBitmap);
385 } 392 }
386 393
387 function callbackImmutable(imageBitmap) { 394 function callbackImmutable(imageBitmap) {
388 // change the underlying element to ensure that it does not change the image Bitmap 395 // change the underlying element to ensure that it does not change the image Bitmap
389 switch(i) { 396 switch(i) {
390 case 0: // image 397 case 0: // image
391 image = new Image(); 398 image.onload = function() { callbackNoCrop(imageBitmap); }
399 image.src = bCanvas.toDataURL();
392 break; 400 break;
393 case 1: // canvas 401 case 1: // canvas
394 clearContext(aCtx); 402 clearContext(aCtx);
403 callbackNoCrop(imageBitmap);
395 break; 404 break;
396 case 2: // data 405 case 2: // data
397 d = 0; 406 d = 0;
407 callbackNoCrop(imageBitmap);
398 break; 408 break;
399 case 3: // context 409 case 3: // context
400 clearContext(aCtx); 410 clearContext(aCtx);
411 callbackNoCrop(imageBitmap);
401 break; 412 break;
402 case 4: // bitmap 413 case 4: // bitmap
403 testBitmap = 0; 414 testBitmap = 0;
415 callbackNoCrop(imageBitmap);
404 break; 416 break;
405 default: 417 default:
406 testFailed("Default should not be called."); 418 testFailed("Default should not be called.");
407 } 419 }
408 // should be drawn to (0, 0), (200, 200)
409 callbackNoCrop(imageBitmap);
410 420
411 // we potentially cleared our auxillary context, so redraw the image 421 // we potentially cleared our auxillary context, so redraw the image
412 drawPattern(aCtx); 422 drawPattern(aCtx);
413 } 423 }
414 424
415 function commonCallback(imageBitmap) { 425 function commonCallback(imageBitmap) {
416 bitmap = imageBitmap; 426 bitmap = imageBitmap;
417 shouldBeType("bitmap", "ImageBitmap"); 427 shouldBeType("bitmap", "ImageBitmap");
418 428
419 callbackCount += 1; 429 callbackCount += 1;
420 430
421 if (callbackCount < elements.length * checks.length) { 431 if (callbackCount < elements.length * checks.length) {
422 ++j; 432 ++j;
423 if(j == checks.length) { 433 if(j == checks.length) {
424 // completed all the checks for the ith element 434 // completed all the checks for the ith element
425 j = 0; 435 j = 0;
426 ++i; 436 ++i;
427 } 437 }
428 nextCheck(); 438 nextCheck();
429 } else { 439 } else {
430 finishJSTest(); 440 finishJSTest();
431 } 441 }
432 } 442 }
433 443
434 </script> 444 </script>
435 <script src="../js/resources/js-test-post.js"></script> 445 <script src="../js/resources/js-test-post.js"></script>
436 </body> 446 </body>
437 </html> 447 </html>
OLDNEW
« no previous file with comments | « no previous file | Source/core/html/canvas/CanvasRenderingContext2D.cpp » ('j') | Source/core/loader/cache/CachedResource.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698