+2012-05-22 Kenneth Russell <kbr@google.com>
+
+ Must set/reset pixel unpack alignment to 1 during texSubImage2D
+ https://bugs.webkit.org/show_bug.cgi?id=86877
+
+ Reviewed by James Robinson.
+
+ Incorporated several tests from WebGL conformance suite at Khronos
+ as layout tests, verifying upload to all packed pixel formats.
+
+ There were difficulties incorporating the video-related variants
+ of these tests; Bug 87042 has been filed to track their addition.
+
+ * fast/canvas/webgl/resources/tex-image-and-sub-image-2d-with-canvas.js: Added.
+ (generateTest.init):
+ (generateTest.runOneIteration):
+ (generateTest.runTest):
+ (generateTest):
+ * fast/canvas/webgl/resources/tex-image-and-sub-image-2d-with-image-data.js: Added.
+ (generateTest.init):
+ (generateTest.runOneIteration):
+ (generateTest.runTest):
+ (generateTest):
+ * fast/canvas/webgl/resources/tex-image-and-sub-image-2d-with-image.js: Added.
+ (generateTest.init):
+ (generateTest.runOneIteration):
+ (generateTest.runTestOnImage):
+ (generateTest.runTest.newImage.onload):
+ (generateTest.runTest):
+ (generateTest.runTest2.newImage.onload):
+ (generateTest.runTest2):
+ (generateTest.runTest3):
+ (generateTest):
+ * fast/canvas/webgl/resources/webgl-test-utils.js:
+ (WebGLTestUtils):
+ * fast/canvas/webgl/tex-image-and-sub-image-2d-with-canvas-expected.txt: Copied from LayoutTests/fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-expected.txt.
+ * fast/canvas/webgl/tex-image-and-sub-image-2d-with-canvas-rgb565-expected.txt: Copied from LayoutTests/fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-expected.txt.
+ * fast/canvas/webgl/tex-image-and-sub-image-2d-with-canvas-rgb565.html: Added.
+ * fast/canvas/webgl/tex-image-and-sub-image-2d-with-canvas-rgba4444-expected.txt: Copied from LayoutTests/fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-expected.txt.
+ * fast/canvas/webgl/tex-image-and-sub-image-2d-with-canvas-rgba4444.html: Added.
+ * fast/canvas/webgl/tex-image-and-sub-image-2d-with-canvas-rgba5551-expected.txt: Copied from LayoutTests/fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-expected.txt.
+ * fast/canvas/webgl/tex-image-and-sub-image-2d-with-canvas-rgba5551.html: Added.
+ * fast/canvas/webgl/tex-image-and-sub-image-2d-with-canvas.html: Added.
+ * fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-data-expected.txt:
+ * fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-data-rgb565-expected.txt: Copied from LayoutTests/fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-data-expected.txt.
+ * fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-data-rgb565.html: Added.
+ * fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-data-rgba4444-expected.txt: Copied from LayoutTests/fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-data-expected.txt.
+ * fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-data-rgba4444.html: Added.
+ * fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-data-rgba5551-expected.txt: Copied from LayoutTests/fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-data-expected.txt.
+ * fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-data-rgba5551.html: Added.
+ * fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-data.html:
+ * fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-expected.txt:
+ * fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-rgb565-expected.txt: Added.
+ * fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-rgb565.html: Added.
+ * fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-rgba4444-expected.txt: Added.
+ * fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-rgba4444.html: Added.
+ * fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-rgba5551-expected.txt: Added.
+ * fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-rgba5551.html: Added.
+ * fast/canvas/webgl/tex-image-and-sub-image-2d-with-image.html:
+
2012-05-21 Emil A Eklund <eae@chromium.org>
Unreviewed table rebaselines for chromium.
--- /dev/null
+function generateTest(pixelFormat, pixelType, prologue) {
+ var wtu = WebGLTestUtils;
+ var gl = null;
+ var textureLoc = null;
+ var successfullyParsed = false;
+
+ var init = function()
+ {
+ if (window.initNonKhronosFramework) {
+ window.initNonKhronosFramework(true);
+ }
+
+ description('Verify texImage2D and texSubImage2D code paths taking canvas elements (' + pixelFormat + '/' + pixelType + ')');
+
+ gl = wtu.create3DContext("example");
+
+ if (!prologue(gl)) {
+ finishTest();
+ return;
+ }
+
+ var program = wtu.setupTexturedQuad(gl);
+
+ gl.clearColor(0,0,0,1);
+ gl.clearDepth(1);
+
+ var testCanvas = document.createElement('canvas');
+ testCanvas.width = 1;
+ testCanvas.height = 2;
+ var ctx = testCanvas.getContext("2d");
+ ctx.fillStyle = "#ff0000";
+ ctx.fillRect(0,0,1,1);
+ ctx.fillStyle = "#00ff00";
+ ctx.fillRect(0,1,1,1);
+ runTest(testCanvas);
+ }
+
+ function runOneIteration(image, useTexSubImage2D, flipY, topColor, bottomColor)
+ {
+ debug('Testing ' + (useTexSubImage2D ? 'texSubImage2D' : 'texImage2D') +
+ ' with flipY=' + flipY);
+ gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
+ // Disable any writes to the alpha channel
+ gl.colorMask(1, 1, 1, 0);
+ var texture = gl.createTexture();
+ // Bind the texture to texture unit 0
+ gl.bindTexture(gl.TEXTURE_2D, texture);
+ // Set up texture parameters
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
+ // Set up pixel store parameters
+ gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipY);
+ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
+ gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, gl.NONE);
+ // Upload the image into the texture
+ if (useTexSubImage2D) {
+ // Initialize the texture to black first
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl[pixelFormat], image.width, image.height, 0,
+ gl[pixelFormat], gl[pixelType], null);
+ gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl[pixelFormat], gl[pixelType], image);
+ } else {
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl[pixelFormat], gl[pixelFormat], gl[pixelType], image);
+ }
+
+ // Point the uniform sampler to texture unit 0
+ gl.uniform1i(textureLoc, 0);
+ // Draw the triangles
+ wtu.drawQuad(gl, [0, 0, 0, 255]);
+ // Check a few pixels near the top and bottom and make sure they have
+ // the right color.
+ debug("Checking lower left corner");
+ wtu.checkCanvasRect(gl, 4, 4, 2, 2, bottomColor,
+ "shouldBe " + bottomColor);
+ debug("Checking upper left corner");
+ wtu.checkCanvasRect(gl, 4, gl.canvas.height - 8, 2, 2, topColor,
+ "shouldBe " + topColor);
+ }
+
+ function runTest(image)
+ {
+ var red = [255, 0, 0];
+ var green = [0, 255, 0];
+ runOneIteration(image, false, true, red, green);
+ runOneIteration(image, false, false, green, red);
+ runOneIteration(image, true, true, red, green);
+ runOneIteration(image, true, false, green, red);
+
+ glErrorShouldBe(gl, gl.NO_ERROR, "should be no errors");
+ finishTest();
+ }
+
+ return init;
+}
--- /dev/null
+function generateTest(pixelFormat, pixelType, prologue) {
+ var wtu = WebGLTestUtils;
+ var gl = null;
+ var textureLoc = null;
+ var successfullyParsed = false;
+ var imageData = null;
+
+ var init = function()
+ {
+ if (window.initNonKhronosFramework) {
+ window.initNonKhronosFramework(true);
+ }
+
+ description('Verify texImage2D and texSubImage2D code paths taking ImageData (' + pixelFormat + '/' + pixelType + ')');
+
+ gl = wtu.create3DContext("example");
+
+ if (!prologue(gl)) {
+ finishTest();
+ return;
+ }
+
+ var program = wtu.setupTexturedQuad(gl);
+ gl.clearColor(0,0,0,1);
+ gl.clearDepth(1);
+ gl.disable(gl.BLEND);
+
+ textureLoc = gl.getUniformLocation(program, "tex");
+
+ var canvas2d = document.getElementById("texcanvas");
+ var context2d = canvas2d.getContext("2d");
+ imageData = context2d.createImageData(1, 2);
+ var data = imageData.data;
+ data[0] = 255;
+ data[1] = 0;
+ data[2] = 0;
+ data[3] = 255;
+ data[4] = 0;
+ data[5] = 255;
+ data[6] = 0;
+ data[7] = 0;
+
+ runTest();
+ }
+
+ function runOneIteration(useTexSubImage2D, flipY, premultiplyAlpha, topColor, bottomColor)
+ {
+ debug('Testing ' + (useTexSubImage2D ? 'texSubImage2D' : 'texImage2D') +
+ ' with flipY=' + flipY + ' and premultiplyAlpha=' + premultiplyAlpha);
+ gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
+ // Enable writes to the RGBA channels
+ gl.colorMask(1, 1, 1, 0);
+ var texture = gl.createTexture();
+ // Bind the texture to texture unit 0
+ gl.bindTexture(gl.TEXTURE_2D, texture);
+ // Set up texture parameters
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
+ // Set up pixel store parameters
+ gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipY);
+ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, premultiplyAlpha);
+ // Upload the image into the texture
+ if (useTexSubImage2D) {
+ // Initialize the texture to black first
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl[pixelFormat], 1, 2, 0,
+ gl[pixelFormat], gl[pixelType], null);
+ gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl[pixelFormat], gl[pixelType], imageData);
+ } else {
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl[pixelFormat], gl[pixelFormat], gl[pixelType], imageData);
+ }
+
+ // Point the uniform sampler to texture unit 0
+ gl.uniform1i(textureLoc, 0);
+ // Draw the triangles
+ wtu.drawQuad(gl, [0, 0, 0, 255]);
+
+ // Check the top pixel and bottom pixel and make sure they have
+ // the right color.
+ debug("Checking bottom pixel");
+ wtu.checkCanvasRect(gl, 0, 0, 1, 1, bottomColor, "shouldBe " + bottomColor);
+ debug("Checking top pixel");
+ wtu.checkCanvasRect(gl, 0, 1, 1, 1, topColor, "shouldBe " + topColor);
+ }
+
+ function runTest()
+ {
+ var red = [255, 0, 0, 255];
+ var green = [0, 255, 0, 255];
+ var redPremultiplyAlpha = [255, 0, 0, 255];
+ var greenPremultiplyAlpha = [0, 0, 0, 255];
+
+ runOneIteration(false, true, false,
+ red, green);
+ runOneIteration(false, false, false,
+ green, red);
+ runOneIteration(false, true, true,
+ redPremultiplyAlpha, greenPremultiplyAlpha);
+ runOneIteration(false, false, true,
+ greenPremultiplyAlpha, redPremultiplyAlpha);
+ runOneIteration(true, true, false,
+ red, green);
+ runOneIteration(true, false, false,
+ green, red);
+ runOneIteration(true, true, true,
+ redPremultiplyAlpha, greenPremultiplyAlpha);
+ runOneIteration(true, false, true,
+ greenPremultiplyAlpha, redPremultiplyAlpha);
+
+ glErrorShouldBe(gl, gl.NO_ERROR, "should be no errors");
+ finishTest();
+ }
+
+ return init;
+}
--- /dev/null
+function generateTest(pixelFormat, pixelType, pathToTestRoot, prologue) {
+ var wtu = WebGLTestUtils;
+ var gl = null;
+ var textureLoc = null;
+ var successfullyParsed = false;
+ var imgCanvas;
+ var red = [255, 0, 0];
+ var green = [0, 255, 0];
+
+ var init = function()
+ {
+ if (window.initNonKhronosFramework) {
+ window.initNonKhronosFramework(true);
+ }
+
+ description('Verify texImage2D and texSubImage2D code paths taking image elements (' + pixelFormat + '/' + pixelType + ')');
+
+ gl = wtu.create3DContext("example");
+
+ if (!prologue(gl)) {
+ finishTest();
+ return;
+ }
+
+ var program = wtu.setupTexturedQuad(gl);
+
+ gl.clearColor(0,0,0,1);
+ gl.clearDepth(1);
+
+ textureLoc = gl.getUniformLocation(program, "tex");
+
+ wtu.loadTexture(gl, pathToTestRoot + "/resources/red-green.png", runTest);
+ }
+
+ function runOneIteration(image, useTexSubImage2D, flipY, topColor, bottomColor)
+ {
+ debug('Testing ' + (useTexSubImage2D ? 'texSubImage2D' : 'texImage2D') +
+ ' with flipY=' + flipY);
+ gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
+ // Disable any writes to the alpha channel
+ gl.colorMask(1, 1, 1, 0);
+ var texture = gl.createTexture();
+ // Bind the texture to texture unit 0
+ gl.bindTexture(gl.TEXTURE_2D, texture);
+ // Set up texture parameters
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
+ // Set up pixel store parameters
+ gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipY);
+ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
+ gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, gl.NONE);
+ // Upload the image into the texture
+ if (useTexSubImage2D) {
+ // Initialize the texture to black first
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl[pixelFormat], image.width, image.height, 0,
+ gl[pixelFormat], gl[pixelType], null);
+ gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl[pixelFormat], gl[pixelType], image);
+ } else {
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl[pixelFormat], gl[pixelFormat], gl[pixelType], image);
+ }
+
+ // Point the uniform sampler to texture unit 0
+ gl.uniform1i(textureLoc, 0);
+ // Draw the triangles
+ wtu.drawQuad(gl, [0, 0, 0, 255]);
+ // Check a few pixels near the top and bottom and make sure they have
+ // the right color.
+ debug("Checking lower left corner");
+ wtu.checkCanvasRect(gl, 4, 4, 2, 2, bottomColor,
+ "shouldBe " + bottomColor);
+ debug("Checking upper left corner");
+ wtu.checkCanvasRect(gl, 4, gl.canvas.height - 8, 2, 2, topColor,
+ "shouldBe " + topColor);
+ }
+
+ function runTestOnImage(image) {
+ runOneIteration(image, false, true, red, green);
+ runOneIteration(image, false, false, green, red);
+ runOneIteration(image, true, true, red, green);
+ runOneIteration(image, true, false, green, red);
+ }
+
+ function runTest(image)
+ {
+ runTestOnImage(image);
+
+ imgCanvas = document.createElement("canvas");
+ imgCanvas.width = 1;
+ imgCanvas.height = 2;
+ var imgCtx = imgCanvas.getContext("2d");
+ var imgData = imgCtx.createImageData(1, 2);
+ imgData.data[0] = red[0];
+ imgData.data[1] = red[1];
+ imgData.data[2] = red[2];
+ imgData.data[3] = 255;
+ imgData.data[4] = green[0];
+ imgData.data[5] = green[1];
+ imgData.data[6] = green[2];
+ imgData.data[7] = 255;
+ imgCtx.putImageData(imgData, 0, 0);
+
+ // apparently Image is different than <img>.
+ var newImage = new Image();
+ newImage.onload = function() {
+ runTest2(newImage);
+ };
+ newImage.src = imgCanvas.toDataURL();
+ }
+
+ function runTest2(image) {
+ runTestOnImage(image);
+
+ var newImage = document.createElement("img");
+ newImage.onload = function() {
+ runTest3(newImage);
+ };
+ newImage.src = imgCanvas.toDataURL();
+ }
+
+ function runTest3(image) {
+ runTestOnImage(image);
+
+ glErrorShouldBe(gl, gl.NO_ERROR, "should be no errors");
+ finishTest();
+ }
+
+ return init;
+}
*/
var create3DContext = function(opt_canvas, opt_attributes) {
opt_canvas = opt_canvas || document.createElement("canvas");
+ if (typeof opt_canvas == 'string') {
+ opt_canvas = document.getElementById(opt_canvas);
+ }
var context = null;
- try {
- context = opt_canvas.getContext("webgl", opt_attributes);
- } catch(e) {}
- if (!context) {
+ var names = ["webgl", "experimental-webgl"];
+ for (var i = 0; i < names.length; ++i) {
try {
- context = opt_canvas.getContext("experimental-webgl", opt_attributes);
- } catch(e) {}
+ context = opt_canvas.getContext(names[i], opt_attributes);
+ } catch (e) {
+ }
+ if (context) {
+ break;
+ }
}
if (!context) {
testFailed("Unable to fetch WebGL rendering context for Canvas");
--- /dev/null
+Verify texImage2D and texSubImage2D code paths taking canvas elements (RGBA/UNSIGNED_BYTE)
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+Testing texImage2D with flipY=true
+Checking lower left corner
+PASS shouldBe 0,255,0
+Checking upper left corner
+PASS shouldBe 255,0,0
+Testing texImage2D with flipY=false
+Checking lower left corner
+PASS shouldBe 255,0,0
+Checking upper left corner
+PASS shouldBe 0,255,0
+Testing texSubImage2D with flipY=true
+Checking lower left corner
+PASS shouldBe 0,255,0
+Checking upper left corner
+PASS shouldBe 255,0,0
+Testing texSubImage2D with flipY=false
+Checking lower left corner
+PASS shouldBe 255,0,0
+Checking upper left corner
+PASS shouldBe 0,255,0
+PASS getError was expected value: NO_ERROR : should be no errors
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
--- /dev/null
+Verify texImage2D and texSubImage2D code paths taking canvas elements (RGB/UNSIGNED_SHORT_5_6_5)
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+Testing texImage2D with flipY=true
+Checking lower left corner
+PASS shouldBe 0,255,0
+Checking upper left corner
+PASS shouldBe 255,0,0
+Testing texImage2D with flipY=false
+Checking lower left corner
+PASS shouldBe 255,0,0
+Checking upper left corner
+PASS shouldBe 0,255,0
+Testing texSubImage2D with flipY=true
+Checking lower left corner
+PASS shouldBe 0,255,0
+Checking upper left corner
+PASS shouldBe 255,0,0
+Testing texSubImage2D with flipY=false
+Checking lower left corner
+PASS shouldBe 255,0,0
+Checking upper left corner
+PASS shouldBe 0,255,0
+PASS getError was expected value: NO_ERROR : should be no errors
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../js/resources/js-test-style.css"/>
+<script src="../../js/resources/js-test-pre.js"></script>
+<script src="resources/webgl-test.js"></script>
+<script src="resources/webgl-test-utils.js"></script>
+<script src="resources/tex-image-and-sub-image-2d-with-canvas.js"></script>
+<script>
+function testPrologue(gl) {
+ return true;
+}
+</script>
+</head>
+<body onload='generateTest("RGB", "UNSIGNED_SHORT_5_6_5", testPrologue)()'>
+<canvas id="example" width="32px" height="32px"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+</body>
+</html>
--- /dev/null
+Verify texImage2D and texSubImage2D code paths taking canvas elements (RGBA/UNSIGNED_SHORT_4_4_4_4)
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+Testing texImage2D with flipY=true
+Checking lower left corner
+PASS shouldBe 0,255,0
+Checking upper left corner
+PASS shouldBe 255,0,0
+Testing texImage2D with flipY=false
+Checking lower left corner
+PASS shouldBe 255,0,0
+Checking upper left corner
+PASS shouldBe 0,255,0
+Testing texSubImage2D with flipY=true
+Checking lower left corner
+PASS shouldBe 0,255,0
+Checking upper left corner
+PASS shouldBe 255,0,0
+Testing texSubImage2D with flipY=false
+Checking lower left corner
+PASS shouldBe 255,0,0
+Checking upper left corner
+PASS shouldBe 0,255,0
+PASS getError was expected value: NO_ERROR : should be no errors
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../js/resources/js-test-style.css"/>
+<script src="../../js/resources/js-test-pre.js"></script>
+<script src="resources/webgl-test.js"></script>
+<script src="resources/webgl-test-utils.js"></script>
+<script src="resources/tex-image-and-sub-image-2d-with-canvas.js"></script>
+<script>
+function testPrologue(gl) {
+ return true;
+}
+</script>
+</head>
+<body onload='generateTest("RGBA", "UNSIGNED_SHORT_4_4_4_4", testPrologue)()'>
+<canvas id="example" width="32px" height="32px"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+</body>
+</html>
--- /dev/null
+Verify texImage2D and texSubImage2D code paths taking canvas elements (RGBA/UNSIGNED_SHORT_5_5_5_1)
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+Testing texImage2D with flipY=true
+Checking lower left corner
+PASS shouldBe 0,255,0
+Checking upper left corner
+PASS shouldBe 255,0,0
+Testing texImage2D with flipY=false
+Checking lower left corner
+PASS shouldBe 255,0,0
+Checking upper left corner
+PASS shouldBe 0,255,0
+Testing texSubImage2D with flipY=true
+Checking lower left corner
+PASS shouldBe 0,255,0
+Checking upper left corner
+PASS shouldBe 255,0,0
+Testing texSubImage2D with flipY=false
+Checking lower left corner
+PASS shouldBe 255,0,0
+Checking upper left corner
+PASS shouldBe 0,255,0
+PASS getError was expected value: NO_ERROR : should be no errors
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../js/resources/js-test-style.css"/>
+<script src="../../js/resources/js-test-pre.js"></script>
+<script src="resources/webgl-test.js"></script>
+<script src="resources/webgl-test-utils.js"></script>
+<script src="resources/tex-image-and-sub-image-2d-with-canvas.js"></script>
+<script>
+function testPrologue(gl) {
+ return true;
+}
+</script>
+</head>
+<body onload='generateTest("RGBA", "UNSIGNED_SHORT_5_5_5_1", testPrologue)()'>
+<canvas id="example" width="32px" height="32px"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+</body>
+</html>
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../js/resources/js-test-style.css"/>
+<script src="../../js/resources/js-test-pre.js"></script>
+<script src="resources/webgl-test.js"></script>
+<script src="resources/webgl-test-utils.js"></script>
+<script src="resources/tex-image-and-sub-image-2d-with-canvas.js"></script>
+<script>
+function testPrologue(gl) {
+ return true;
+}
+</script>
+</head>
+<body onload='generateTest("RGBA", "UNSIGNED_BYTE", testPrologue)()'>
+<canvas id="example" width="32px" height="32px"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+</body>
+</html>
-Verify texImage2D and texSubImage2D code paths taking ImageData
+Verify texImage2D and texSubImage2D code paths taking ImageData (RGBA/UNSIGNED_BYTE)
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS shouldBe 255,0,0,255
Checking top pixel
PASS shouldBe 0,0,0,255
+PASS getError was expected value: NO_ERROR : should be no errors
PASS successfullyParsed is true
TEST COMPLETE
--- /dev/null
+
+Verify texImage2D and texSubImage2D code paths taking ImageData (RGB/UNSIGNED_SHORT_5_6_5)
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+Testing texImage2D with flipY=true and premultiplyAlpha=false
+Checking bottom pixel
+PASS shouldBe 0,255,0,255
+Checking top pixel
+PASS shouldBe 255,0,0,255
+Testing texImage2D with flipY=false and premultiplyAlpha=false
+Checking bottom pixel
+PASS shouldBe 255,0,0,255
+Checking top pixel
+PASS shouldBe 0,255,0,255
+Testing texImage2D with flipY=true and premultiplyAlpha=true
+Checking bottom pixel
+PASS shouldBe 0,0,0,255
+Checking top pixel
+PASS shouldBe 255,0,0,255
+Testing texImage2D with flipY=false and premultiplyAlpha=true
+Checking bottom pixel
+PASS shouldBe 255,0,0,255
+Checking top pixel
+PASS shouldBe 0,0,0,255
+Testing texSubImage2D with flipY=true and premultiplyAlpha=false
+Checking bottom pixel
+PASS shouldBe 0,255,0,255
+Checking top pixel
+PASS shouldBe 255,0,0,255
+Testing texSubImage2D with flipY=false and premultiplyAlpha=false
+Checking bottom pixel
+PASS shouldBe 255,0,0,255
+Checking top pixel
+PASS shouldBe 0,255,0,255
+Testing texSubImage2D with flipY=true and premultiplyAlpha=true
+Checking bottom pixel
+PASS shouldBe 0,0,0,255
+Checking top pixel
+PASS shouldBe 255,0,0,255
+Testing texSubImage2D with flipY=false and premultiplyAlpha=true
+Checking bottom pixel
+PASS shouldBe 255,0,0,255
+Checking top pixel
+PASS shouldBe 0,0,0,255
+PASS getError was expected value: NO_ERROR : should be no errors
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../js/resources/js-test-style.css"/>
+<script src="../../js/resources/js-test-pre.js"></script>
+<script src="resources/webgl-test.js"></script>
+<script src="resources/webgl-test-utils.js"></script>
+<script src="resources/tex-image-and-sub-image-2d-with-image-data.js"></script>
+<script>
+function testPrologue(gl) {
+ return true;
+}
+</script>
+</head>
+<body onload='generateTest("RGB", "UNSIGNED_SHORT_5_6_5", testPrologue)()'>
+<canvas id="texcanvas" width="1px" height="2px"></canvas>
+<canvas id="example" width="1px" height="2px"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+</body>
+</html>
--- /dev/null
+
+Verify texImage2D and texSubImage2D code paths taking ImageData (RGBA/UNSIGNED_SHORT_4_4_4_4)
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+Testing texImage2D with flipY=true and premultiplyAlpha=false
+Checking bottom pixel
+PASS shouldBe 0,255,0,255
+Checking top pixel
+PASS shouldBe 255,0,0,255
+Testing texImage2D with flipY=false and premultiplyAlpha=false
+Checking bottom pixel
+PASS shouldBe 255,0,0,255
+Checking top pixel
+PASS shouldBe 0,255,0,255
+Testing texImage2D with flipY=true and premultiplyAlpha=true
+Checking bottom pixel
+PASS shouldBe 0,0,0,255
+Checking top pixel
+PASS shouldBe 255,0,0,255
+Testing texImage2D with flipY=false and premultiplyAlpha=true
+Checking bottom pixel
+PASS shouldBe 255,0,0,255
+Checking top pixel
+PASS shouldBe 0,0,0,255
+Testing texSubImage2D with flipY=true and premultiplyAlpha=false
+Checking bottom pixel
+PASS shouldBe 0,255,0,255
+Checking top pixel
+PASS shouldBe 255,0,0,255
+Testing texSubImage2D with flipY=false and premultiplyAlpha=false
+Checking bottom pixel
+PASS shouldBe 255,0,0,255
+Checking top pixel
+PASS shouldBe 0,255,0,255
+Testing texSubImage2D with flipY=true and premultiplyAlpha=true
+Checking bottom pixel
+PASS shouldBe 0,0,0,255
+Checking top pixel
+PASS shouldBe 255,0,0,255
+Testing texSubImage2D with flipY=false and premultiplyAlpha=true
+Checking bottom pixel
+PASS shouldBe 255,0,0,255
+Checking top pixel
+PASS shouldBe 0,0,0,255
+PASS getError was expected value: NO_ERROR : should be no errors
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../js/resources/js-test-style.css"/>
+<script src="../../js/resources/js-test-pre.js"></script>
+<script src="resources/webgl-test.js"></script>
+<script src="resources/webgl-test-utils.js"></script>
+<script src="resources/tex-image-and-sub-image-2d-with-image-data.js"></script>
+<script>
+function testPrologue(gl) {
+ return true;
+}
+</script>
+</head>
+<body onload='generateTest("RGBA", "UNSIGNED_SHORT_4_4_4_4", testPrologue)()'>
+<canvas id="texcanvas" width="1px" height="2px"></canvas>
+<canvas id="example" width="1px" height="2px"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+</body>
+</html>
--- /dev/null
+
+Verify texImage2D and texSubImage2D code paths taking ImageData (RGBA/UNSIGNED_SHORT_5_5_5_1)
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+Testing texImage2D with flipY=true and premultiplyAlpha=false
+Checking bottom pixel
+PASS shouldBe 0,255,0,255
+Checking top pixel
+PASS shouldBe 255,0,0,255
+Testing texImage2D with flipY=false and premultiplyAlpha=false
+Checking bottom pixel
+PASS shouldBe 255,0,0,255
+Checking top pixel
+PASS shouldBe 0,255,0,255
+Testing texImage2D with flipY=true and premultiplyAlpha=true
+Checking bottom pixel
+PASS shouldBe 0,0,0,255
+Checking top pixel
+PASS shouldBe 255,0,0,255
+Testing texImage2D with flipY=false and premultiplyAlpha=true
+Checking bottom pixel
+PASS shouldBe 255,0,0,255
+Checking top pixel
+PASS shouldBe 0,0,0,255
+Testing texSubImage2D with flipY=true and premultiplyAlpha=false
+Checking bottom pixel
+PASS shouldBe 0,255,0,255
+Checking top pixel
+PASS shouldBe 255,0,0,255
+Testing texSubImage2D with flipY=false and premultiplyAlpha=false
+Checking bottom pixel
+PASS shouldBe 255,0,0,255
+Checking top pixel
+PASS shouldBe 0,255,0,255
+Testing texSubImage2D with flipY=true and premultiplyAlpha=true
+Checking bottom pixel
+PASS shouldBe 0,0,0,255
+Checking top pixel
+PASS shouldBe 255,0,0,255
+Testing texSubImage2D with flipY=false and premultiplyAlpha=true
+Checking bottom pixel
+PASS shouldBe 255,0,0,255
+Checking top pixel
+PASS shouldBe 0,0,0,255
+PASS getError was expected value: NO_ERROR : should be no errors
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../js/resources/js-test-style.css"/>
+<script src="../../js/resources/js-test-pre.js"></script>
+<script src="resources/webgl-test.js"></script>
+<script src="resources/webgl-test-utils.js"></script>
+<script src="resources/tex-image-and-sub-image-2d-with-image-data.js"></script>
+<script>
+function testPrologue(gl) {
+ return true;
+}
+</script>
+</head>
+<body onload='generateTest("RGBA", "UNSIGNED_SHORT_5_5_5_1", testPrologue)()'>
+<canvas id="texcanvas" width="1px" height="2px"></canvas>
+<canvas id="example" width="1px" height="2px"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+</body>
+</html>
+<!DOCTYPE html>
<html>
<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../js/resources/js-test-style.css"/>
<script src="../../js/resources/js-test-pre.js"></script>
<script src="resources/webgl-test.js"></script>
<script src="resources/webgl-test-utils.js"></script>
+<script src="resources/tex-image-and-sub-image-2d-with-image-data.js"></script>
<script>
-var wtu = WebGLTestUtils;
-var gl = null;
-var textureLoc = null;
-var imageData = null;
-
-function init()
-{
- if (window.initNonKhronosFramework) {
- window.initNonKhronosFramework(true);
- }
-
- description('Verify texImage2D and texSubImage2D code paths taking ImageData');
-
- var canvas2d = document.getElementById("texcanvas");
- var context2d = canvas2d.getContext("2d");
- imageData = context2d.createImageData(1, 2);
- var data = imageData.data;
- data[0] = 255;
- data[1] = 0;
- data[2] = 0;
- data[3] = 255;
- data[4] = 0;
- data[5] = 255;
- data[6] = 0;
- data[7] = 0;
-
- wtu = WebGLTestUtils;
- var canvas = document.getElementById("example");
- gl = wtu.create3DContext(canvas);
- var program = wtu.setupTexturedQuad(gl);
- gl.clearColor(0,0,0,1);
- gl.clearDepth(1);
- gl.disable(gl.BLEND);
-
- textureLoc = gl.getUniformLocation(program, "tex");
-
- runTest();
-}
-
-// These two declarations need to be global for "shouldBe" to see them
-var buf = null;
-var idx = 0;
-var pixel = [0, 0, 0, 1];
-var correctColor = null;
-
-function runOneIteration(useTexSubImage2D, flipY, premultiplyAlpha, topColor, bottomColor)
-{
- debug('Testing ' + (useTexSubImage2D ? 'texSubImage2D' : 'texImage2D') +
- ' with flipY=' + flipY + ' and premultiplyAlpha=' + premultiplyAlpha);
- gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
- // Enable writes to the RGBA channels
- gl.colorMask(1, 1, 1, 0);
- var texture = gl.createTexture();
- // Bind the texture to texture unit 0
- gl.bindTexture(gl.TEXTURE_2D, texture);
- // Set up texture parameters
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
- // Set up pixel store parameters
- gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipY);
- gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, premultiplyAlpha);
- // Upload the image into the texture
- if (useTexSubImage2D) {
- // Initialize the texture to black first
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 2, 0,
- gl.RGBA, gl.UNSIGNED_BYTE, null);
- gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, imageData);
- } else {
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, imageData);
- }
-
- // Point the uniform sampler to texture unit 0
- gl.uniform1i(textureLoc, 0);
- // Draw the triangles
- wtu.drawQuad(gl, [0, 0, 0, 255]);
-
- // Read back the rendering results
- buf = new Uint8Array(1 * 2 * 4);
- gl.readPixels(0, 0, 1, 2, gl.RGBA, gl.UNSIGNED_BYTE, buf);
- // Check the top pixel and bottom pixel and make sure they have
- // the right color.
- debug("Checking bottom pixel");
- wtu.checkCanvasRect(gl, 0, 0, 1, 1, bottomColor, "shouldBe " + bottomColor);
- debug("Checking top pixel");
- wtu.checkCanvasRect(gl, 0, 1, 1, 1, topColor, "shouldBe " + topColor);
-}
-
-function runTest()
-{
- var red = [255, 0, 0, 255];
- var green = [0, 255, 0, 255];
- var redPremultiplyAlpha = [255, 0, 0, 255];
- var greenPremultiplyAlpha = [0, 0, 0, 255];
-
- runOneIteration(false, true, false,
- red, green);
- runOneIteration(false, false, false,
- green, red);
- runOneIteration(false, true, true,
- redPremultiplyAlpha, greenPremultiplyAlpha);
- runOneIteration(false, false, true,
- greenPremultiplyAlpha, redPremultiplyAlpha);
- runOneIteration(true, true, false,
- red, green);
- runOneIteration(true, false, false,
- green, red);
- runOneIteration(true, true, true,
- redPremultiplyAlpha, greenPremultiplyAlpha);
- runOneIteration(true, false, true,
- greenPremultiplyAlpha, redPremultiplyAlpha);
- var epilogue = document.createElement("script");
- epilogue.onload = finish;
- epilogue.src = "../../js/resources/js-test-post.js";
- document.body.appendChild(epilogue);
-}
-
-function finish() {
- if (window.nonKhronosFrameworkNotifyDone) {
- window.nonKhronosFrameworkNotifyDone();
- }
+function testPrologue(gl) {
+ return true;
}
</script>
</head>
-<body onload="init()">
+<body onload='generateTest("RGBA", "UNSIGNED_BYTE", testPrologue)()'>
<canvas id="texcanvas" width="1px" height="2px"></canvas>
<canvas id="example" width="1px" height="2px"></canvas>
<div id="description"></div>
-Verify texImage2D and texSubImage2D code paths taking Images
+Verify texImage2D and texSubImage2D code paths taking image elements (RGBA/UNSIGNED_BYTE)
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS shouldBe 255,0,0
Checking upper left corner
PASS shouldBe 0,255,0
+Testing texImage2D with flipY=true
+Checking lower left corner
+PASS shouldBe 0,255,0
+Checking upper left corner
+PASS shouldBe 255,0,0
+Testing texImage2D with flipY=false
+Checking lower left corner
+PASS shouldBe 255,0,0
+Checking upper left corner
+PASS shouldBe 0,255,0
+Testing texSubImage2D with flipY=true
+Checking lower left corner
+PASS shouldBe 0,255,0
+Checking upper left corner
+PASS shouldBe 255,0,0
+Testing texSubImage2D with flipY=false
+Checking lower left corner
+PASS shouldBe 255,0,0
+Checking upper left corner
+PASS shouldBe 0,255,0
+Testing texImage2D with flipY=true
+Checking lower left corner
+PASS shouldBe 0,255,0
+Checking upper left corner
+PASS shouldBe 255,0,0
+Testing texImage2D with flipY=false
+Checking lower left corner
+PASS shouldBe 255,0,0
+Checking upper left corner
+PASS shouldBe 0,255,0
+Testing texSubImage2D with flipY=true
+Checking lower left corner
+PASS shouldBe 0,255,0
+Checking upper left corner
+PASS shouldBe 255,0,0
+Testing texSubImage2D with flipY=false
+Checking lower left corner
+PASS shouldBe 255,0,0
+Checking upper left corner
+PASS shouldBe 0,255,0
+PASS getError was expected value: NO_ERROR : should be no errors
PASS successfullyParsed is true
TEST COMPLETE
--- /dev/null
+Verify texImage2D and texSubImage2D code paths taking image elements (RGB/UNSIGNED_SHORT_5_6_5)
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+Testing texImage2D with flipY=true
+Checking lower left corner
+PASS shouldBe 0,255,0
+Checking upper left corner
+PASS shouldBe 255,0,0
+Testing texImage2D with flipY=false
+Checking lower left corner
+PASS shouldBe 255,0,0
+Checking upper left corner
+PASS shouldBe 0,255,0
+Testing texSubImage2D with flipY=true
+Checking lower left corner
+PASS shouldBe 0,255,0
+Checking upper left corner
+PASS shouldBe 255,0,0
+Testing texSubImage2D with flipY=false
+Checking lower left corner
+PASS shouldBe 255,0,0
+Checking upper left corner
+PASS shouldBe 0,255,0
+Testing texImage2D with flipY=true
+Checking lower left corner
+PASS shouldBe 0,255,0
+Checking upper left corner
+PASS shouldBe 255,0,0
+Testing texImage2D with flipY=false
+Checking lower left corner
+PASS shouldBe 255,0,0
+Checking upper left corner
+PASS shouldBe 0,255,0
+Testing texSubImage2D with flipY=true
+Checking lower left corner
+PASS shouldBe 0,255,0
+Checking upper left corner
+PASS shouldBe 255,0,0
+Testing texSubImage2D with flipY=false
+Checking lower left corner
+PASS shouldBe 255,0,0
+Checking upper left corner
+PASS shouldBe 0,255,0
+Testing texImage2D with flipY=true
+Checking lower left corner
+PASS shouldBe 0,255,0
+Checking upper left corner
+PASS shouldBe 255,0,0
+Testing texImage2D with flipY=false
+Checking lower left corner
+PASS shouldBe 255,0,0
+Checking upper left corner
+PASS shouldBe 0,255,0
+Testing texSubImage2D with flipY=true
+Checking lower left corner
+PASS shouldBe 0,255,0
+Checking upper left corner
+PASS shouldBe 255,0,0
+Testing texSubImage2D with flipY=false
+Checking lower left corner
+PASS shouldBe 255,0,0
+Checking upper left corner
+PASS shouldBe 0,255,0
+PASS getError was expected value: NO_ERROR : should be no errors
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../js/resources/js-test-style.css"/>
+<script src="../../js/resources/js-test-pre.js"></script>
+<script src="resources/webgl-test.js"></script>
+<script src="resources/webgl-test-utils.js"></script>
+<script src="resources/tex-image-and-sub-image-2d-with-image.js"></script>
+<script>
+function testPrologue(gl) {
+ return true;
+}
+</script>
+</head>
+<body onload='generateTest("RGB", "UNSIGNED_SHORT_5_6_5", ".", testPrologue)()'>
+<canvas id="example" width="32px" height="32px"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+</body>
+</html>
--- /dev/null
+Verify texImage2D and texSubImage2D code paths taking image elements (RGBA/UNSIGNED_SHORT_4_4_4_4)
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+Testing texImage2D with flipY=true
+Checking lower left corner
+PASS shouldBe 0,255,0
+Checking upper left corner
+PASS shouldBe 255,0,0
+Testing texImage2D with flipY=false
+Checking lower left corner
+PASS shouldBe 255,0,0
+Checking upper left corner
+PASS shouldBe 0,255,0
+Testing texSubImage2D with flipY=true
+Checking lower left corner
+PASS shouldBe 0,255,0
+Checking upper left corner
+PASS shouldBe 255,0,0
+Testing texSubImage2D with flipY=false
+Checking lower left corner
+PASS shouldBe 255,0,0
+Checking upper left corner
+PASS shouldBe 0,255,0
+Testing texImage2D with flipY=true
+Checking lower left corner
+PASS shouldBe 0,255,0
+Checking upper left corner
+PASS shouldBe 255,0,0
+Testing texImage2D with flipY=false
+Checking lower left corner
+PASS shouldBe 255,0,0
+Checking upper left corner
+PASS shouldBe 0,255,0
+Testing texSubImage2D with flipY=true
+Checking lower left corner
+PASS shouldBe 0,255,0
+Checking upper left corner
+PASS shouldBe 255,0,0
+Testing texSubImage2D with flipY=false
+Checking lower left corner
+PASS shouldBe 255,0,0
+Checking upper left corner
+PASS shouldBe 0,255,0
+Testing texImage2D with flipY=true
+Checking lower left corner
+PASS shouldBe 0,255,0
+Checking upper left corner
+PASS shouldBe 255,0,0
+Testing texImage2D with flipY=false
+Checking lower left corner
+PASS shouldBe 255,0,0
+Checking upper left corner
+PASS shouldBe 0,255,0
+Testing texSubImage2D with flipY=true
+Checking lower left corner
+PASS shouldBe 0,255,0
+Checking upper left corner
+PASS shouldBe 255,0,0
+Testing texSubImage2D with flipY=false
+Checking lower left corner
+PASS shouldBe 255,0,0
+Checking upper left corner
+PASS shouldBe 0,255,0
+PASS getError was expected value: NO_ERROR : should be no errors
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../js/resources/js-test-style.css"/>
+<script src="../../js/resources/js-test-pre.js"></script>
+<script src="resources/webgl-test.js"></script>
+<script src="resources/webgl-test-utils.js"></script>
+<script src="resources/tex-image-and-sub-image-2d-with-image.js"></script>
+<script>
+function testPrologue(gl) {
+ return true;
+}
+</script>
+</head>
+<body onload='generateTest("RGBA", "UNSIGNED_SHORT_4_4_4_4", ".", testPrologue)()'>
+<canvas id="example" width="32px" height="32px"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+</body>
+</html>
--- /dev/null
+Verify texImage2D and texSubImage2D code paths taking image elements (RGBA/UNSIGNED_SHORT_5_5_5_1)
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+Testing texImage2D with flipY=true
+Checking lower left corner
+PASS shouldBe 0,255,0
+Checking upper left corner
+PASS shouldBe 255,0,0
+Testing texImage2D with flipY=false
+Checking lower left corner
+PASS shouldBe 255,0,0
+Checking upper left corner
+PASS shouldBe 0,255,0
+Testing texSubImage2D with flipY=true
+Checking lower left corner
+PASS shouldBe 0,255,0
+Checking upper left corner
+PASS shouldBe 255,0,0
+Testing texSubImage2D with flipY=false
+Checking lower left corner
+PASS shouldBe 255,0,0
+Checking upper left corner
+PASS shouldBe 0,255,0
+Testing texImage2D with flipY=true
+Checking lower left corner
+PASS shouldBe 0,255,0
+Checking upper left corner
+PASS shouldBe 255,0,0
+Testing texImage2D with flipY=false
+Checking lower left corner
+PASS shouldBe 255,0,0
+Checking upper left corner
+PASS shouldBe 0,255,0
+Testing texSubImage2D with flipY=true
+Checking lower left corner
+PASS shouldBe 0,255,0
+Checking upper left corner
+PASS shouldBe 255,0,0
+Testing texSubImage2D with flipY=false
+Checking lower left corner
+PASS shouldBe 255,0,0
+Checking upper left corner
+PASS shouldBe 0,255,0
+Testing texImage2D with flipY=true
+Checking lower left corner
+PASS shouldBe 0,255,0
+Checking upper left corner
+PASS shouldBe 255,0,0
+Testing texImage2D with flipY=false
+Checking lower left corner
+PASS shouldBe 255,0,0
+Checking upper left corner
+PASS shouldBe 0,255,0
+Testing texSubImage2D with flipY=true
+Checking lower left corner
+PASS shouldBe 0,255,0
+Checking upper left corner
+PASS shouldBe 255,0,0
+Testing texSubImage2D with flipY=false
+Checking lower left corner
+PASS shouldBe 255,0,0
+Checking upper left corner
+PASS shouldBe 0,255,0
+PASS getError was expected value: NO_ERROR : should be no errors
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../js/resources/js-test-style.css"/>
+<script src="../../js/resources/js-test-pre.js"></script>
+<script src="resources/webgl-test.js"></script>
+<script src="resources/webgl-test-utils.js"></script>
+<script src="resources/tex-image-and-sub-image-2d-with-image.js"></script>
+<script>
+function testPrologue(gl) {
+ return true;
+}
+</script>
+</head>
+<body onload='generateTest("RGBA", "UNSIGNED_SHORT_5_5_5_1", ".", testPrologue)()'>
+<canvas id="example" width="32px" height="32px"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+</body>
+</html>
+<!DOCTYPE html>
<html>
<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../js/resources/js-test-style.css"/>
<script src="../../js/resources/js-test-pre.js"></script>
<script src="resources/webgl-test.js"></script>
<script src="resources/webgl-test-utils.js"></script>
+<script src="resources/tex-image-and-sub-image-2d-with-image.js"></script>
<script>
-var wtu = WebGLTestUtils;
-var gl = null;
-var textureLoc = null;
-
-function init()
-{
- if (window.initNonKhronosFramework) {
- window.initNonKhronosFramework(true);
- }
-
- description('Verify texImage2D and texSubImage2D code paths taking Images');
-
- var canvas = document.getElementById("example");
- gl = wtu.create3DContext(canvas);
- var program = wtu.setupTexturedQuad(gl);
-
- gl.clearColor(0,0,0,1);
- gl.clearDepth(1);
-
- textureLoc = gl.getUniformLocation(gl.program, "tex");
-
- wtu.loadTexture(gl, "resources/red-green.png", runTest);
-}
-
-// These two declarations need to be global for "shouldBe" to see them
-var buf = null;
-var idx = 0;
-var pixel = [0, 0, 0];
-var correctColor = null;
-
-function runOneIteration(image, useTexSubImage2D, flipY, topColor, bottomColor)
-{
- debug('Testing ' + (useTexSubImage2D ? 'texSubImage2D' : 'texImage2D') +
- ' with flipY=' + flipY);
- gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
- // Disable any writes to the alpha channel
- gl.colorMask(1, 1, 1, 0);
- var texture = gl.createTexture();
- // Bind the texture to texture unit 0
- gl.bindTexture(gl.TEXTURE_2D, texture);
- // Set up texture parameters
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
- // Set up pixel store parameters
- gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipY);
- gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
- // Upload the image into the texture
- if (useTexSubImage2D) {
- // Initialize the texture to black first
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, image.width, image.height, 0,
- gl.RGBA, gl.UNSIGNED_BYTE, null);
- gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, image);
- } else {
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
- }
-
- // Point the uniform sampler to texture unit 0
- gl.uniform1i(textureLoc, 0);
- // Draw the triangles
- wtu.drawQuad(gl, [0, 0, 0, 255]);
- // Check a few pixels near the top and bottom and make sure they have
- // the right color.
- debug("Checking lower left corner");
- wtu.checkCanvasRect(gl, 4, 4, 2, 2, bottomColor,
- "shouldBe " + bottomColor);
- debug("Checking upper left corner");
- wtu.checkCanvasRect(gl, 4, gl.canvas.height - 8, 2, 2, topColor,
- "shouldBe " + topColor);
-}
-
-function runTest(image)
-{
- var red = [255, 0, 0];
- var green = [0, 255, 0];
- runOneIteration(image, false, true, red, green);
- runOneIteration(image, false, false, green, red);
- runOneIteration(image, true, true, red, green);
- runOneIteration(image, true, false, green, red);
- var epilogue = document.createElement("script");
- epilogue.onload = finish;
- epilogue.src = "../../js/resources/js-test-post.js";
- document.body.appendChild(epilogue);
-}
-
-function finish() {
- if (window.nonKhronosFrameworkNotifyDone) {
- window.nonKhronosFrameworkNotifyDone();
- }
+function testPrologue(gl) {
+ return true;
}
</script>
</head>
-<body onload="init()">
+<body onload='generateTest("RGBA", "UNSIGNED_BYTE", ".", testPrologue)()'>
<canvas id="example" width="32px" height="32px"></canvas>
<div id="description"></div>
<div id="console"></div>
</body>
</html>
-
-
+2012-05-22 Kenneth Russell <kbr@google.com>
+
+ Must set/reset pixel unpack alignment to 1 during texSubImage2D
+ https://bugs.webkit.org/show_bug.cgi?id=86877
+
+ Reviewed by James Robinson.
+
+ Set pixel unpack alignment to 1 during upload, resetting afterward.
+
+ Tests: fast/canvas/webgl/tex-image-and-sub-image-2d-with-canvas-rgb565.html
+ fast/canvas/webgl/tex-image-and-sub-image-2d-with-canvas-rgba4444.html
+ fast/canvas/webgl/tex-image-and-sub-image-2d-with-canvas-rgba5551.html
+ fast/canvas/webgl/tex-image-and-sub-image-2d-with-canvas.html
+ fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-data-rgb565.html
+ fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-data-rgba4444.html
+ fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-data-rgba5551.html
+ fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-rgb565.html
+ fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-rgba4444.html
+ fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-rgba5551.html
+
+ * html/canvas/WebGLRenderingContext.cpp:
+ (WebCore::WebGLRenderingContext::texSubImage2DImpl):
+ (WebCore::WebGLRenderingContext::texSubImage2D):
+ Set pixel unpack alignment to 1 during upload; reset afterward.
+
2012-05-21 Sam D <dsam2912@gmail.com>
Web Inspector: "Deactivate All Breakpoints" should visually get reflected in Breakpoints pane.
synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texSubImage2D", "bad image");
return;
}
+ if (m_unpackAlignment != 1)
+ m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, 1);
texSubImage2DBase(target, level, xoffset, yoffset, image->width(), image->height(),
format, type, data.data(), ec);
+ if (m_unpackAlignment != 1)
+ m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlignment);
}
void WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset,
synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texSubImage2D", "bad image data");
return;
}
+ if (m_unpackAlignment != 1)
+ m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, 1);
texSubImage2DBase(target, level, xoffset, yoffset, pixels->width(), pixels->height(),
format, type, data.data(), ec);
+ if (m_unpackAlignment != 1)
+ m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlignment);
}
void WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset,