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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/webgl/texImage-imageBitmap-from-canvas-resize.html

Issue 2218963002: Add more layout tests for createImageBitmap with resize options (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="./resources/webgl-test-utils-full.js"></script> 4 <script src="./resources/webgl-test-utils-full.js"></script>
5 <script src="./resources/tex-image-and-sub-image-utils.js"></script> 5 <script src="./resources/tex-image-and-sub-image-utils.js"></script>
6 <script src="./resources/tex-image-and-sub-image-image-bitmap-utils.js"></script > 6 <script src="./resources/tex-image-and-sub-image-image-bitmap-utils.js"></script >
7 <script src="../../../resources/js-test.js"></script> 7 <script src="../../../resources/testharness.js"></script>
8 <script src="../../../resources/testharnessreport.js"></script>
9 <body>
8 <script> 10 <script>
9
10 window.jsTestIsAsync = true;
11
12 var wtu = WebGLTestUtils; 11 var wtu = WebGLTestUtils;
13 var tiu = TexImageUtils; 12 var tiu = TexImageUtils;
14 var gl = null; 13 var gl = null;
15 var internalFormat = "RGBA"; 14 var internalFormat = "RGBA";
16 var pixelFormat = "RGBA"; 15 var pixelFormat = "RGBA";
17 var pixelType = "UNSIGNED_BYTE"; 16 var pixelType = "UNSIGNED_BYTE";
18 var redColor = [255, 0, 0]; 17 var redColor = [255, 0, 0];
19 var greenColor = [0, 255, 0]; 18 var greenColor = [0, 255, 0];
20 var blackColor = [0, 0, 0]; 19 var blackColor = [0, 0, 0];
21 var darkRed = [26, 0, 0]; 20 var darkRed = [26, 0, 0];
22 var darkGreen = [0, 26, 0]; 21 var darkGreen = [0, 26, 0];
23 22
24 function promiseRejected()
25 {
26 document.getElementById("results").innerHTML = "Promise <span style='color:r ed'>REJECTED</span>";
27 }
28
29 function pass()
30 {
31 document.getElementById("results").innerHTML = "Test <span style='color:gree n'>PASSED</span>";
32 }
33
34 function setCanvasToRedGreen(ctx) { 23 function setCanvasToRedGreen(ctx) {
35 ctx.canvas.width = 2; 24 ctx.canvas.width = 2;
36 ctx.canvas.height = 2; 25 ctx.canvas.height = 2;
37 var width = ctx.canvas.width; 26 var width = ctx.canvas.width;
38 var halfWidth = Math.floor(width / 2); 27 var halfWidth = Math.floor(width / 2);
39 var height = ctx.canvas.height; 28 var height = ctx.canvas.height;
40 var halfHeight = Math.floor(height / 2); 29 var halfHeight = Math.floor(height / 2);
41 ctx.fillStyle = "rgba(255, 0, 0, 1)"; 30 ctx.fillStyle = "rgba(255, 0, 0, 1)";
42 ctx.fillRect(0, 0, halfWidth, halfHeight); 31 ctx.fillRect(0, 0, halfWidth, halfHeight);
43 ctx.fillStyle = "rgba(255, 0, 0, 0.1)"; 32 ctx.fillStyle = "rgba(255, 0, 0, 0.1)";
44 ctx.fillRect(halfWidth, 0, halfWidth, halfHeight); 33 ctx.fillRect(halfWidth, 0, halfWidth, halfHeight);
45 ctx.fillStyle = "rgba(0, 255, 0, 1)"; 34 ctx.fillStyle = "rgba(0, 255, 0, 1)";
46 ctx.fillRect(0, halfHeight, halfWidth, halfHeight); 35 ctx.fillRect(0, halfHeight, halfWidth, halfHeight);
47 ctx.fillStyle = "rgba(0, 255, 0, 0.1)"; 36 ctx.fillStyle = "rgba(0, 255, 0, 0.1)";
48 ctx.fillRect(halfWidth, halfHeight, halfWidth, halfHeight); 37 ctx.fillRect(halfWidth, halfHeight, halfWidth, halfHeight);
49 } 38 }
50 39
51 function generateTest() 40 promise_test(function() {
52 {
53 var bitmaps = []; 41 var bitmaps = [];
54 42
55 var canvas = document.getElementById("example"); 43 var canvas = document.createElement('canvas');
44 canvas.width = 32;
45 canvas.height = 32;
46 document.body.appendChild(canvas);
56 gl = canvas.getContext("webgl"); 47 gl = canvas.getContext("webgl");
57 48
58 gl.clearColor(0,0,0,1); 49 gl.clearColor(0,0,0,1);
59 gl.clearDepth(1); 50 gl.clearDepth(1);
60 51
61 var testCanvas = document.createElement('canvas'); 52 var testCanvas = document.createElement('canvas');
62 var ctx = testCanvas.getContext("2d"); 53 var ctx = testCanvas.getContext("2d");
63 setCanvasToRedGreen(ctx); 54 setCanvasToRedGreen(ctx);
64 55
65 var p1 = createImageBitmap(testCanvas).then(function(imageBitmap) { bitmaps. defaultOption = imageBitmap }); 56 var p1 = createImageBitmap(testCanvas, {resizeWidth: 4, resizeHeight: 4, res izeQuality: "high"}).then(function(imageBitmap) { bitmaps.defaultOption = imageB itmap });
66 var p2 = createImageBitmap(testCanvas, {imageOrientation: "none", premultipl yAlpha: "premultiply"}).then(function(imageBitmap) { bitmaps.noFlipYPremul = ima geBitmap }); 57 var p2 = createImageBitmap(testCanvas, {imageOrientation: "none", premultipl yAlpha: "premultiply", resizeWidth: 4, resizeHeight: 4, resizeQuality: "high"}). then(function(imageBitmap) { bitmaps.noFlipYPremul = imageBitmap });
67 var p3 = createImageBitmap(testCanvas, {imageOrientation: "none", premultipl yAlpha: "default"}).then(function(imageBitmap) { bitmaps.noFlipYDefault = imageB itmap }); 58 var p3 = createImageBitmap(testCanvas, {imageOrientation: "none", premultipl yAlpha: "default", resizeWidth: 4, resizeHeight: 4, resizeQuality: "high"}).then (function(imageBitmap) { bitmaps.noFlipYDefault = imageBitmap });
68 var p4 = createImageBitmap(testCanvas, {imageOrientation: "none", premultipl yAlpha: "none"}).then(function(imageBitmap) { bitmaps.noFlipYUnpremul = imageBit map }); 59 var p4 = createImageBitmap(testCanvas, {imageOrientation: "none", premultipl yAlpha: "none", resizeWidth: 4, resizeHeight: 4, resizeQuality: "high"}).then(fu nction(imageBitmap) { bitmaps.noFlipYUnpremul = imageBitmap });
69 var p5 = createImageBitmap(testCanvas, {imageOrientation: "flipY", premultip lyAlpha: "premultiply"}).then(function(imageBitmap) { bitmaps.flipYPremul = imag eBitmap }); 60 var p5 = createImageBitmap(testCanvas, {imageOrientation: "flipY", premultip lyAlpha: "premultiply", resizeWidth: 4, resizeHeight: 4, resizeQuality: "high"}) .then(function(imageBitmap) { bitmaps.flipYPremul = imageBitmap });
70 var p6 = createImageBitmap(testCanvas, {imageOrientation: "flipY", premultip lyAlpha: "default"}).then(function(imageBitmap) { bitmaps.flipYDefault = imageBi tmap }); 61 var p6 = createImageBitmap(testCanvas, {imageOrientation: "flipY", premultip lyAlpha: "default", resizeWidth: 4, resizeHeight: 4, resizeQuality: "high"}).the n(function(imageBitmap) { bitmaps.flipYDefault = imageBitmap });
71 var p7 = createImageBitmap(testCanvas, {imageOrientation: "flipY", premultip lyAlpha: "none"}).then(function(imageBitmap) { bitmaps.flipYUnpremul = imageBitm ap }); 62 var p7 = createImageBitmap(testCanvas, {imageOrientation: "flipY", premultip lyAlpha: "none", resizeWidth: 4, resizeHeight: 4, resizeQuality: "high"}).then(f unction(imageBitmap) { bitmaps.flipYUnpremul = imageBitmap });
72 var p8 = createImageBitmap(testCanvas).then(function(imageBitmap) { bitmaps. colorSpaceDef = imageBitmap }); 63 var p8 = createImageBitmap(testCanvas, {resizeWidth: 4, resizeHeight: 4, res izeQuality: "high"}).then(function(imageBitmap) { bitmaps.colorSpaceDef = imageB itmap });
73 var p9 = createImageBitmap(testCanvas, {colorSpaceConversion: "none"}).then( function(imageBitmap) { bitmaps.colorSpaceNone = imageBitmap }); 64 var p9 = createImageBitmap(testCanvas, {colorSpaceConversion: "none", resize Width: 4, resizeHeight: 4, resizeQuality: "high"}).then(function(imageBitmap) { bitmaps.colorSpaceNone = imageBitmap });
74 var p10 = createImageBitmap(testCanvas, {colorSpaceConversion: "default"}).t hen(function(imageBitmap) { bitmaps.colorSpaceDefault = imageBitmap }); 65 var p10 = createImageBitmap(testCanvas, {colorSpaceConversion: "default", re sizeWidth: 4, resizeHeight: 4, resizeQuality: "high"}).then(function(imageBitmap ) { bitmaps.colorSpaceDefault = imageBitmap });
75 Promise.all([p1, p2, p3, p4, p5, p6, p7, p8, p9, p10]).then(function() { 66 Promise.all([p1, p2, p3, p4, p5, p6, p7, p8, p9, p10]).then(function() {
76 var alphaVal = 0.5; 67 var alphaVal = 0.5;
77 var testPassed = runTest(bitmaps, alphaVal, false); 68 var testPassed = runTest(bitmaps, alphaVal, false);
78 if (testPassed) 69 if (!testPassed)
79 pass(); 70 assert_true(false, 'Test failed');
80 finishJSTest();
81 }, function() { 71 }, function() {
82 promiseRejected(); 72 assert_true(false, 'Promise rejected');
83 finishJSTest();
84 }); 73 });
85 } 74 }, 'createImageBitmap(HTMLCanvasElement) with resize and other options');
86
87 function init()
88 {
89 if (window.testRunner) {
90 testRunner.overridePreference("WebKitWebGLEnabled", "1");
91 testRunner.dumpAsText();
92 }
93 generateTest();
94 }
95 </script> 75 </script>
96 </head>
97 <body onload="init()">
98 <canvas id="texcanvas" width="2" height="2"></canvas>
99 <canvas id="example" width="32" height="32"></canvas>
100 <div id="results">Test <span style="color:red">FAILED</span></div>
101 </body> 76 </body>
102 </html> 77 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698