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

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

Issue 2182583002: Change implementation of resize ImageBitmap to meet specs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/frame/ImageBitmap.cpp » ('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> 1 <!DOCTYPE HTML>
2 <script src="../../resources/testharness.js"></script> 2 <script src="../../resources/testharness.js"></script>
3 <script src="../../resources/testharnessreport.js"></script> 3 <script src="../../resources/testharnessreport.js"></script>
4 <script> 4 <script>
5 function checkNoCrop(imageBitmap) 5 function checkNoCrop(imageBitmap)
6 { 6 {
7 var canvas = document.createElement("canvas"); 7 var canvas = document.createElement("canvas");
8 canvas.width = 50; 8 canvas.width = 50;
9 canvas.height = 50; 9 canvas.height = 50;
10 var ctx = canvas.getContext("2d"); 10 var ctx = canvas.getContext("2d");
11 ctx.clearRect(0, 0, canvas.width, canvas.height); 11 ctx.clearRect(0, 0, canvas.width, canvas.height);
12 ctx.drawImage(imageBitmap, 0, 0); 12 ctx.drawImage(imageBitmap, 0, 0);
13 var d = ctx.getImageData(0, 0, 1, 1).data; 13 var d = ctx.getImageData(0, 0, 1, 1).data;
14 assert_array_equals(d, [255, 0, 0, 255], "This pixel should be red."); 14 assert_array_equals(d, [255, 0, 0, 255], "This pixel should be red.");
15 console.log(d[0] + " " + d[1] + " " + d[2] + " " + d[3]);
16 d = ctx.getImageData(39, 0, 1, 1).data; 15 d = ctx.getImageData(39, 0, 1, 1).data;
17 assert_array_equals(d, [0, 255, 0, 255], "This pixel should be green."); 16 assert_array_equals(d, [0, 255, 0, 255], "This pixel should be green.");
18 console.log(d[0] + " " + d[1] + " " + d[2] + " " + d[3]);
19 d = ctx.getImageData(0, 39, 1, 1).data; 17 d = ctx.getImageData(0, 39, 1, 1).data;
20 assert_array_equals(d, [0, 0, 255, 255], "This pixel should be blue."); 18 assert_array_equals(d, [0, 0, 255, 255], "This pixel should be blue.");
21 console.log(d[0] + " " + d[1] + " " + d[2] + " " + d[3]);
22 d = ctx.getImageData(39, 39, 1, 1).data; 19 d = ctx.getImageData(39, 39, 1, 1).data;
23 assert_array_equals(d, [0, 0, 0, 255], "This pixel should be black."); 20 assert_array_equals(d, [0, 0, 0, 255], "This pixel should be black.");
24 console.log(d[0] + " " + d[1] + " " + d[2] + " " + d[3]);
25 d = ctx.getImageData(41, 41, 1, 1).data; 21 d = ctx.getImageData(41, 41, 1, 1).data;
26 assert_array_equals(d, [0, 0, 0, 0], "This pixel should be transparent black ."); 22 assert_array_equals(d, [0, 0, 0, 0], "This pixel should be transparent black .");
27 console.log(d[0] + " " + d[1] + " " + d[2] + " " + d[3]);
28 } 23 }
29 24
30 function checkCrop(imageBitmap) 25 function checkCrop(imageBitmap)
31 { 26 {
32 var canvas = document.createElement("canvas"); 27 var canvas = document.createElement("canvas");
33 canvas.width = 50; 28 canvas.width = 50;
34 canvas.height = 50; 29 canvas.height = 50;
35 var ctx = canvas.getContext("2d"); 30 var ctx = canvas.getContext("2d");
36 ctx.clearRect(0, 0, canvas.width, canvas.height); 31 ctx.clearRect(0, 0, canvas.width, canvas.height);
37 ctx.drawImage(imageBitmap, 0, 0); 32 ctx.drawImage(imageBitmap, 0, 0);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 assert_false(dataMatched); 68 assert_false(dataMatched);
74 } 69 }
75 70
76 function testImageBitmap(source) 71 function testImageBitmap(source)
77 { 72 {
78 return Promise.all([ 73 return Promise.all([
79 createImageBitmap(source, {resizeWidth: 40, resizeHeight: 40, resizeQual ity: "high"}), 74 createImageBitmap(source, {resizeWidth: 40, resizeHeight: 40, resizeQual ity: "high"}),
80 createImageBitmap(source, {resizeWidth: 40, resizeHeight: 40, resizeQual ity: "medium"}), 75 createImageBitmap(source, {resizeWidth: 40, resizeHeight: 40, resizeQual ity: "medium"}),
81 createImageBitmap(source, {resizeWidth: 40, resizeHeight: 40, resizeQual ity: "low"}), 76 createImageBitmap(source, {resizeWidth: 40, resizeHeight: 40, resizeQual ity: "low"}),
82 createImageBitmap(source, {resizeWidth: 40, resizeHeight: 40, resizeQual ity: "pixelated"}), 77 createImageBitmap(source, {resizeWidth: 40, resizeHeight: 40, resizeQual ity: "pixelated"}),
83 createImageBitmap(source, 10, 10, 20, 20, {resizeWidth: 40, resizeHeight : 40, resizeQuality: "high"}), 78 createImageBitmap(source, 5, 5, 10, 10, {resizeWidth: 20, resizeHeight: 20, resizeQuality: "high"}),
84 createImageBitmap(source, 10, 10, 20, 20, {resizeWidth: 40, resizeHeight : 40, resizeQuality: "medium"}), 79 createImageBitmap(source, 5, 5, 10, 10, {resizeWidth: 20, resizeHeight: 20, resizeQuality: "medium"}),
85 createImageBitmap(source, 10, 10, 20, 20, {resizeWidth: 40, resizeHeight : 40, resizeQuality: "low"}), 80 createImageBitmap(source, 5, 5, 10, 10, {resizeWidth: 20, resizeHeight: 20, resizeQuality: "low"}),
86 createImageBitmap(source, 10, 10, 20, 20, {resizeWidth: 40, resizeHeight : 40, resizeQuality: "pixelated"}), 81 createImageBitmap(source, 5, 5, 10, 10, {resizeWidth: 20, resizeHeight: 20, resizeQuality: "pixelated"}),
87 ]).then(([noCropHigh, noCropMedium, noCropLow, noCropPixelated, cropHigh, cr opMedium, cropLow, cropPixelated]) => { 82 ]).then(([noCropHigh, noCropMedium, noCropLow, noCropPixelated, cropHigh, cr opMedium, cropLow, cropPixelated]) => {
88 checkNoCrop(noCropHigh); 83 checkNoCrop(noCropHigh);
89 checkNoCrop(noCropMedium); 84 checkNoCrop(noCropMedium);
90 checkNoCrop(noCropLow); 85 checkNoCrop(noCropLow);
91 checkNoCrop(noCropPixelated); 86 checkNoCrop(noCropPixelated);
92 checkCrop(cropHigh); 87 checkCrop(cropHigh);
93 checkCrop(cropMedium); 88 checkCrop(cropMedium);
94 checkCrop(cropLow); 89 checkCrop(cropLow);
95 checkCrop(cropPixelated); 90 checkCrop(cropPixelated);
96 // Brute-force comparison among all bitmaps is too expensive 91 // Brute-force comparison among all bitmaps is too expensive
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 image.src = 'resources/pattern.png' 142 image.src = 'resources/pattern.png'
148 }).then(testImageBitmap); 143 }).then(testImageBitmap);
149 }, 'createImageBitmap from a HTMLImageElement with resize option.'); 144 }, 'createImageBitmap from a HTMLImageElement with resize option.');
150 145
151 // ImageBitmap 146 // ImageBitmap
152 promise_test(function() { 147 promise_test(function() {
153 var testCanvas = initializeTestCanvas(); 148 var testCanvas = initializeTestCanvas();
154 return createImageBitmap(testCanvas).then(testImageBitmap); 149 return createImageBitmap(testCanvas).then(testImageBitmap);
155 }, 'createImageBitmap from an ImageBitmap with resize option.'); 150 }, 'createImageBitmap from an ImageBitmap with resize option.');
156 </script> 151 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/frame/ImageBitmap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698