diff options
author | xidachen <xidachen@chromium.org> | 2016-03-08 11:12:51 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-08 19:13:57 +0000 |
commit | 7be4202c98d629b7eab64c251eb3ae3914e584e7 (patch) | |
tree | 3da4d6a94e55cec375cd7add0c9b29f510d634e3 /third_party/WebKit/LayoutTests/fast/canvas/webgl/tex-image-and-sub-image-2d-image-bitmap-from-blob.html | |
parent | 0dea451e0070bf8d989760e7a45d56370eea4329 (diff) | |
download | chromium_src-7be4202c98d629b7eab64c251eb3ae3914e584e7.zip chromium_src-7be4202c98d629b7eab64c251eb3ae3914e584e7.tar.gz chromium_src-7be4202c98d629b7eab64c251eb3ae3914e584e7.tar.bz2 |
Add layout tests for tex(Sub)Image2D for ImageBitmap
At this moment, there is an extensive coverage of this testing hosted on
KhronosGroup/WebGL. However, the problem is that we cannot have coverage
of the case for ImageBitmap constructor to take a "default" value for
some of the constructor options such as premultiplyAlpha. The reason is
that the option "default" is implementation-specific, and the results
could vary for different browsers.
In here, we add layout tests in chromium code base to have more test
cases than the ones hosted on KhronosGroup/WebGL.
Also, the KhronosGroup/WebGL testing suite tests tex(Sub)Image2D for 38
different kinds of pixel formats such as RGBA + UNSIGNED_SHORT_4444.
Here we test the basic one which is RGBA + UNSIGNED_BYTE, we can always
extend that in the future.
Review URL: https://codereview.chromium.org/1767113003
Cr-Commit-Position: refs/heads/master@{#379879}
Diffstat (limited to 'third_party/WebKit/LayoutTests/fast/canvas/webgl/tex-image-and-sub-image-2d-image-bitmap-from-blob.html')
-rw-r--r-- | third_party/WebKit/LayoutTests/fast/canvas/webgl/tex-image-and-sub-image-2d-image-bitmap-from-blob.html | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/webgl/tex-image-and-sub-image-2d-image-bitmap-from-blob.html b/third_party/WebKit/LayoutTests/fast/canvas/webgl/tex-image-and-sub-image-2d-image-bitmap-from-blob.html new file mode 100644 index 0000000..a3b109c --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/canvas/webgl/tex-image-and-sub-image-2d-image-bitmap-from-blob.html @@ -0,0 +1,88 @@ +<!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 halfRed = [128, 0, 0]; +var halfGreen = [0, 128, 0]; + +var blob = 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(blob).then(function(imageBitmap) { bitmaps.defaultOption = imageBitmap }); + var p2 = createImageBitmap(blob, {imageOrientation: "none", premultiplyAlpha: "premultiply"}).then(function(imageBitmap) { bitmaps.noFlipYPremul = imageBitmap }); + var p3 = createImageBitmap(blob, {imageOrientation: "none", premultiplyAlpha: "default"}).then(function(imageBitmap) { bitmaps.noFlipYDefault = imageBitmap }); + var p4 = createImageBitmap(blob, {imageOrientation: "none", premultiplyAlpha: "none"}).then(function(imageBitmap) { bitmaps.noFlipYUnpremul = imageBitmap }); + var p5 = createImageBitmap(blob, {imageOrientation: "flipY", premultiplyAlpha: "premultiply"}).then(function(imageBitmap) { bitmaps.flipYPremul = imageBitmap }); + var p6 = createImageBitmap(blob, {imageOrientation: "flipY", premultiplyAlpha: "default"}).then(function(imageBitmap) { bitmaps.flipYDefault = imageBitmap }); + var p7 = createImageBitmap(blob, {imageOrientation: "flipY", premultiplyAlpha: "none"}).then(function(imageBitmap) { bitmaps.flipYUnpremul = imageBitmap }); + Promise.all([p1, p2, p3, p4, p5, p6, p7]).then(function() { + var alphaVal = 0.5; + var testPassed = runTest(bitmaps, alphaVal); + if (testPassed) + pass(); + finishJSTest(); + }, function() { + promiseRejected(); + finishJSTest(); + }); +} + +function init() +{ + if (window.testRunner) { + testRunner.overridePreference("WebKitWebGLEnabled", "1"); + testRunner.dumpAsText(); + } + var xhr = new XMLHttpRequest(); + xhr.open("GET", 'resources/red-green-semi-transparent.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + blob = xhr.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> |