| OLD | NEW |
| 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/js-test.js"></script> |
| 8 <script> | 8 <script> |
| 9 | 9 |
| 10 window.jsTestIsAsync = true; | 10 window.jsTestIsAsync = true; |
| 11 | 11 |
| 12 var wtu = WebGLTestUtils; | 12 var wtu = WebGLTestUtils; |
| 13 var tiu = TexImageUtils; | 13 var tiu = TexImageUtils; |
| 14 var gl = null; | 14 var gl = null; |
| 15 var internalFormat = "RGBA"; | 15 var internalFormat = "RGBA"; |
| 16 var pixelFormat = "RGBA"; | 16 var pixelFormat = "RGBA"; |
| 17 var pixelType = "UNSIGNED_BYTE"; | 17 var pixelType = "UNSIGNED_BYTE"; |
| 18 var redColor = [255, 0, 0]; | 18 var redColor = [255, 0, 0]; |
| 19 var greenColor = [0, 255, 0]; | 19 var greenColor = [0, 255, 0]; |
| 20 var blackColor = [0, 0, 0]; | 20 var blackColor = [0, 0, 0]; |
| 21 var halfRed = [128, 0, 0]; | 21 var halfRed = [128, 0, 0]; |
| 22 var halfGreen = [0, 128, 0]; | 22 var halfGreen = [0, 128, 0]; |
| 23 | 23 |
| 24 var blob = null; | 24 var blob1 = null; |
| 25 var blob2 = null; |
| 25 | 26 |
| 26 function promiseRejected() | 27 function promiseRejected() |
| 27 { | 28 { |
| 28 document.getElementById("results").innerHTML = "Promise <span style='color:r
ed'>REJECTED</span>"; | 29 document.getElementById("results").innerHTML = "Promise <span style='color:r
ed'>REJECTED</span>"; |
| 29 } | 30 } |
| 30 | 31 |
| 31 function pass() | 32 function pass() |
| 32 { | 33 { |
| 33 document.getElementById("results").innerHTML = "Test <span style='color:gree
n'>PASSED</span>"; | 34 document.getElementById("results").innerHTML = "Test <span style='color:gree
n'>PASSED</span>"; |
| 34 } | 35 } |
| 35 | 36 |
| 36 function generateTest() | 37 function generateTest() |
| 37 { | 38 { |
| 38 var bitmaps = []; | 39 var bitmaps = []; |
| 39 | 40 |
| 40 var canvas = document.getElementById("example"); | 41 var canvas = document.getElementById("example"); |
| 41 gl = canvas.getContext("webgl"); | 42 gl = canvas.getContext("webgl"); |
| 42 | 43 |
| 43 gl.clearColor(0,0,0,1); | 44 gl.clearColor(0,0,0,1); |
| 44 gl.clearDepth(1); | 45 gl.clearDepth(1); |
| 45 | 46 |
| 46 var p1 = createImageBitmap(blob).then(function(imageBitmap) { bitmaps.defaul
tOption = imageBitmap }); | 47 var p1 = createImageBitmap(blob1).then(function(imageBitmap) { bitmaps.defau
ltOption = imageBitmap }); |
| 47 var p2 = createImageBitmap(blob, {imageOrientation: "none", premultiplyAlpha
: "premultiply"}).then(function(imageBitmap) { bitmaps.noFlipYPremul = imageBitm
ap }); | 48 var p2 = createImageBitmap(blob1, {imageOrientation: "none", premultiplyAlph
a: "premultiply"}).then(function(imageBitmap) { bitmaps.noFlipYPremul = imageBit
map }); |
| 48 var p3 = createImageBitmap(blob, {imageOrientation: "none", premultiplyAlpha
: "default"}).then(function(imageBitmap) { bitmaps.noFlipYDefault = imageBitmap
}); | 49 var p3 = createImageBitmap(blob1, {imageOrientation: "none", premultiplyAlph
a: "default"}).then(function(imageBitmap) { bitmaps.noFlipYDefault = imageBitmap
}); |
| 49 var p4 = createImageBitmap(blob, {imageOrientation: "none", premultiplyAlpha
: "none"}).then(function(imageBitmap) { bitmaps.noFlipYUnpremul = imageBitmap })
; | 50 var p4 = createImageBitmap(blob1, {imageOrientation: "none", premultiplyAlph
a: "none"}).then(function(imageBitmap) { bitmaps.noFlipYUnpremul = imageBitmap }
); |
| 50 var p5 = createImageBitmap(blob, {imageOrientation: "flipY", premultiplyAlph
a: "premultiply"}).then(function(imageBitmap) { bitmaps.flipYPremul = imageBitma
p }); | 51 var p5 = createImageBitmap(blob1, {imageOrientation: "flipY", premultiplyAlp
ha: "premultiply"}).then(function(imageBitmap) { bitmaps.flipYPremul = imageBitm
ap }); |
| 51 var p6 = createImageBitmap(blob, {imageOrientation: "flipY", premultiplyAlph
a: "default"}).then(function(imageBitmap) { bitmaps.flipYDefault = imageBitmap }
); | 52 var p6 = createImageBitmap(blob1, {imageOrientation: "flipY", premultiplyAlp
ha: "default"}).then(function(imageBitmap) { bitmaps.flipYDefault = imageBitmap
}); |
| 52 var p7 = createImageBitmap(blob, {imageOrientation: "flipY", premultiplyAlph
a: "none"}).then(function(imageBitmap) { bitmaps.flipYUnpremul = imageBitmap }); | 53 var p7 = createImageBitmap(blob1, {imageOrientation: "flipY", premultiplyAlp
ha: "none"}).then(function(imageBitmap) { bitmaps.flipYUnpremul = imageBitmap })
; |
| 53 Promise.all([p1, p2, p3, p4, p5, p6, p7]).then(function() { | 54 var p8 = createImageBitmap(blob2).then(function(imageBitmap) { bitmaps.color
spaceDef = imageBitmap }); |
| 55 var p9 = createImageBitmap(blob2, {colorspaceConversion: "none"}).then(funct
ion(imageBitmap) { bitmaps.colorspaceNone = imageBitmap }); |
| 56 var p10 = createImageBitmap(blob2, {colorspaceConversion: "default"}).then(f
unction(imageBitmap) { bitmaps.colorspaceDefault = imageBitmap }); |
| 57 Promise.all([p1, p2, p3, p4, p5, p6, p7, p8, p9, p10]).then(function() { |
| 54 var alphaVal = 0.5; | 58 var alphaVal = 0.5; |
| 55 var testPassed = runTest(bitmaps, alphaVal); | 59 var testPassed = runTest(bitmaps, alphaVal, true); |
| 56 if (testPassed) | 60 if (testPassed) |
| 57 pass(); | 61 pass(); |
| 58 finishJSTest(); | 62 finishJSTest(); |
| 59 }, function() { | 63 }, function() { |
| 60 promiseRejected(); | 64 promiseRejected(); |
| 61 finishJSTest(); | 65 finishJSTest(); |
| 62 }); | 66 }); |
| 63 } | 67 } |
| 64 | 68 |
| 65 function init() | 69 function init() |
| 66 { | 70 { |
| 67 if (window.testRunner) { | 71 if (window.testRunner) { |
| 68 testRunner.overridePreference("WebKitWebGLEnabled", "1"); | 72 testRunner.overridePreference("WebKitWebGLEnabled", "1"); |
| 69 testRunner.dumpAsText(); | 73 testRunner.dumpAsText(); |
| 70 } | 74 } |
| 71 var xhr = new XMLHttpRequest(); | 75 var xhr1 = new XMLHttpRequest(); |
| 72 xhr.open("GET", 'resources/red-green-semi-transparent.png'); | 76 xhr1.open("GET", 'resources/red-green-semi-transparent.png'); |
| 73 xhr.responseType = 'blob'; | 77 xhr1.responseType = 'blob'; |
| 74 xhr.send(); | 78 xhr1.send(); |
| 75 xhr.onload = function() { | 79 xhr1.onload = function() { |
| 76 blob = xhr.response; | 80 blob1 = xhr1.response; |
| 77 generateTest(); | 81 var xhr2 = new XMLHttpRequest(); |
| 82 xhr2.open("GET", 'resources/square-with-colorspin-profile.png'); |
| 83 xhr2.responseType = 'blob'; |
| 84 xhr2.send(); |
| 85 xhr2.onload = function() { |
| 86 blob2 = xhr2.response; |
| 87 generateTest(); |
| 88 } |
| 78 } | 89 } |
| 79 } | 90 } |
| 80 | 91 |
| 81 </script> | 92 </script> |
| 82 </head> | 93 </head> |
| 83 <body onload="init()"> | 94 <body onload="init()"> |
| 84 <canvas id="texcanvas" width="2" height="2"></canvas> | 95 <canvas id="texcanvas" width="2" height="2"></canvas> |
| 85 <canvas id="example" width="32" height="32"></canvas> | 96 <canvas id="example" width="32" height="32"></canvas> |
| 86 <div id="results">Test <span style="color:red">FAILED</span></div> | 97 <div id="results">Test <span style="color:red">FAILED</span></div> |
| 87 </body> | 98 </body> |
| 88 </html> | 99 </html> |
| OLD | NEW |