<!DOCTYPE html>
<html>
<head>
<script src="./resources/webgl-test-utils-full.js"></script>
<script src="./resources/tex-image-and-sub-image-utils.js"></script>
<script src="./resources/tex-image-and-sub-image-image-bitmap-utils.js"></script>
<script src="../../resources/js-test.js"></script>
<script>
window.jsTestIsAsync = true;
var wtu = WebGLTestUtils;
var tiu = TexImageUtils;
var gl = null;
var internalFormat = "RGBA";
var pixelFormat = "RGBA";
var pixelType = "UNSIGNED_BYTE";
var redColor = [255, 0, 0];
var greenColor = [0, 255, 0];
var blackColor = [0, 0, 0];
var darkRed = [26, 0, 0];
var darkGreen = [0, 26, 0];
var blob1 = null;
var blob2 = null;
function promiseRejected()
{
document.getElementById("results").innerHTML = "Promise <span style='color:red'>REJECTED</span>";
}
function pass()
{
document.getElementById("results").innerHTML = "Test <span style='color:green'>PASSED</span>";
}
function generateTest()
{
var bitmaps = [];
var canvas = document.getElementById("example");
gl = canvas.getContext("webgl");
gl.clearColor(0,0,0,1);
gl.clearDepth(1);
var p1 = createImageBitmap(blob1).then(function(imageBitmap) { bitmaps.defaultOption = imageBitmap });
var p2 = createImageBitmap(blob1, {imageOrientation: "from-image", premultiplyAlpha: "premultiply"}).then(function(imageBitmap) { bitmaps.noFlipYPremul = imageBitmap });
var p3 = createImageBitmap(blob1, {imageOrientation: "from-image", premultiplyAlpha: "default"}).then(function(imageBitmap) { bitmaps.noFlipYDefault = imageBitmap });
var p4 = createImageBitmap(blob1, {imageOrientation: "from-image", premultiplyAlpha: "none"}).then(function(imageBitmap) { bitmaps.noFlipYUnpremul = imageBitmap });
var p5 = createImageBitmap(blob1, {imageOrientation: "flipY", premultiplyAlpha: "premultiply"}).then(function(imageBitmap) { bitmaps.flipYPremul = imageBitmap });
var p6 = createImageBitmap(blob1, {imageOrientation: "flipY", premultiplyAlpha: "default"}).then(function(imageBitmap) { bitmaps.flipYDefault = imageBitmap });
var p7 = createImageBitmap(blob1, {imageOrientation: "flipY", premultiplyAlpha: "none"}).then(function(imageBitmap) { bitmaps.flipYUnpremul = imageBitmap });
var p8 = createImageBitmap(blob2).then(function(imageBitmap) { bitmaps.colorSpaceDef = imageBitmap });
var p9 = createImageBitmap(blob2, {colorSpaceConversion: "none"}).then(function(imageBitmap) { bitmaps.colorSpaceNone = imageBitmap });
var p10 = createImageBitmap(blob2, {colorSpaceConversion: "default"}).then(function(imageBitmap) { bitmaps.colorSpaceDefault = imageBitmap });
Promise.all([p1, p2, p3, p4, p5, p6, p7, p8, p9, p10]).then(function() {
var alphaVal = 0.5;
var testPassed = runTest(bitmaps, alphaVal, true);
if (testPassed)
pass();
finishJSTest();
}, function() {
promiseRejected();
finishJSTest();
});
}
function init()
{
if (window.testRunner) {
testRunner.dumpAsText();
}
var xhr1 = new XMLHttpRequest();
xhr1.open("GET", 'resources/red-green-semi-transparent.png');
xhr1.responseType = 'blob';
xhr1.send();
xhr1.onload = function() {
blob1 = xhr1.response;
var xhr2 = new XMLHttpRequest();
xhr2.open("GET", 'resources/square-with-colorspin-profile.png');
xhr2.responseType = 'blob';
xhr2.send();
xhr2.onload = function() {
blob2 = xhr2.response;
generateTest();
}
}
}
</script>
</head>
<body onload="init()">
<canvas id="texcanvas" width="2" height="2"></canvas>
<canvas id="example" width="32" height="32"></canvas>
<div id="results">Test <span style="color:red">FAILED</span></div>
</body>
</html>