[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
zmo at google.com
zmo at google.com
Wed Dec 22 16:25:50 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 873331e7a17411ef45b6424ae019fd1fe6771d91
Author: zmo at google.com <zmo at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Nov 23 16:51:12 2010 +0000
2010-11-17 Zhenyao Mo <zmo at google.com>
Reviewed by Kenneth Russell.
readPixels should generate INVALID_ENUM if only one of type/format mismatch UNSIGNED_BYTE/RGBA
https://bugs.webkit.org/show_bug.cgi?id=49673
Test: fast/canvas/webgl/read-pixels-test.html
* html/canvas/WebGLRenderingContext.cpp:
(WebCore::WebGLRenderingContext::readPixels):
2010-11-17 Zhenyao Mo <zmo at google.com>
Reviewed by Kenneth Russell.
readPixels should generate INVALID_ENUM if only one of type/format mismatch UNSIGNED_BYTE/RGBA
https://bugs.webkit.org/show_bug.cgi?id=49673
* fast/canvas/webgl/read-pixels-test-expected.txt: Added.
* fast/canvas/webgl/read-pixels-test.html: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@72610 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index daf6d85..b3c7ed0 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,13 @@
+2010-11-17 Zhenyao Mo <zmo at google.com>
+
+ Reviewed by Kenneth Russell.
+
+ readPixels should generate INVALID_ENUM if only one of type/format mismatch UNSIGNED_BYTE/RGBA
+ https://bugs.webkit.org/show_bug.cgi?id=49673
+
+ * fast/canvas/webgl/read-pixels-test-expected.txt: Added.
+ * fast/canvas/webgl/read-pixels-test.html: Added.
+
2010-11-23 Ilya Tikhonovsky <loislo at chromium.org>
Unreviewed. Expectations for chromium were fixed.
diff --git a/LayoutTests/fast/canvas/webgl/read-pixels-test-expected.txt b/LayoutTests/fast/canvas/webgl/read-pixels-test-expected.txt
new file mode 100644
index 0000000..959818e
--- /dev/null
+++ b/LayoutTests/fast/canvas/webgl/read-pixels-test-expected.txt
@@ -0,0 +1,145 @@
+Checks that ReadPixels works as expected.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+checking: in range
+PASS color pixel at 0, 0 should be about 127.5
+PASS color pixel at 0, 0 should be about 178.5
+PASS color pixel at 0, 0 should be about 255
+PASS color pixel at 0, 0 should be about 255
+PASS color pixel at 1, 0 should be about 127.5
+PASS color pixel at 1, 0 should be about 178.5
+PASS color pixel at 1, 0 should be about 255
+PASS color pixel at 1, 0 should be about 255
+PASS color pixel at 0, 1 should be about 127.5
+PASS color pixel at 0, 1 should be about 178.5
+PASS color pixel at 0, 1 should be about 255
+PASS color pixel at 0, 1 should be about 255
+PASS color pixel at 1, 1 should be about 127.5
+PASS color pixel at 1, 1 should be about 178.5
+PASS color pixel at 1, 1 should be about 255
+PASS color pixel at 1, 1 should be about 255
+
+checking: off top left
+PASS color pixel at 0, 0 should be about 0
+PASS color pixel at 0, 0 should be about 0
+PASS color pixel at 0, 0 should be about 0
+PASS color pixel at 0, 0 should be about 0
+PASS color pixel at 1, 0 should be about 0
+PASS color pixel at 1, 0 should be about 0
+PASS color pixel at 1, 0 should be about 0
+PASS color pixel at 1, 0 should be about 0
+PASS color pixel at 0, 1 should be about 0
+PASS color pixel at 0, 1 should be about 0
+PASS color pixel at 0, 1 should be about 0
+PASS color pixel at 0, 1 should be about 0
+PASS color pixel at 1, 1 should be about 127.5
+PASS color pixel at 1, 1 should be about 178.5
+PASS color pixel at 1, 1 should be about 255
+PASS color pixel at 1, 1 should be about 255
+
+checking: off bottom right
+PASS color pixel at 0, 0 should be about 127.5
+PASS color pixel at 0, 0 should be about 178.5
+PASS color pixel at 0, 0 should be about 255
+PASS color pixel at 0, 0 should be about 255
+PASS color pixel at 1, 0 should be about 0
+PASS color pixel at 1, 0 should be about 0
+PASS color pixel at 1, 0 should be about 0
+PASS color pixel at 1, 0 should be about 0
+PASS color pixel at 0, 1 should be about 0
+PASS color pixel at 0, 1 should be about 0
+PASS color pixel at 0, 1 should be about 0
+PASS color pixel at 0, 1 should be about 0
+PASS color pixel at 1, 1 should be about 0
+PASS color pixel at 1, 1 should be about 0
+PASS color pixel at 1, 1 should be about 0
+PASS color pixel at 1, 1 should be about 0
+
+checking: completely off top
+PASS color pixel at 0, 0 should be about 0
+PASS color pixel at 0, 0 should be about 0
+PASS color pixel at 0, 0 should be about 0
+PASS color pixel at 0, 0 should be about 0
+PASS color pixel at 1, 0 should be about 0
+PASS color pixel at 1, 0 should be about 0
+PASS color pixel at 1, 0 should be about 0
+PASS color pixel at 1, 0 should be about 0
+PASS color pixel at 0, 1 should be about 0
+PASS color pixel at 0, 1 should be about 0
+PASS color pixel at 0, 1 should be about 0
+PASS color pixel at 0, 1 should be about 0
+PASS color pixel at 1, 1 should be about 0
+PASS color pixel at 1, 1 should be about 0
+PASS color pixel at 1, 1 should be about 0
+PASS color pixel at 1, 1 should be about 0
+
+checking: completely off bottom
+PASS color pixel at 0, 0 should be about 0
+PASS color pixel at 0, 0 should be about 0
+PASS color pixel at 0, 0 should be about 0
+PASS color pixel at 0, 0 should be about 0
+PASS color pixel at 1, 0 should be about 0
+PASS color pixel at 1, 0 should be about 0
+PASS color pixel at 1, 0 should be about 0
+PASS color pixel at 1, 0 should be about 0
+PASS color pixel at 0, 1 should be about 0
+PASS color pixel at 0, 1 should be about 0
+PASS color pixel at 0, 1 should be about 0
+PASS color pixel at 0, 1 should be about 0
+PASS color pixel at 1, 1 should be about 0
+PASS color pixel at 1, 1 should be about 0
+PASS color pixel at 1, 1 should be about 0
+PASS color pixel at 1, 1 should be about 0
+
+checking: completely off left
+PASS color pixel at 0, 0 should be about 0
+PASS color pixel at 0, 0 should be about 0
+PASS color pixel at 0, 0 should be about 0
+PASS color pixel at 0, 0 should be about 0
+PASS color pixel at 1, 0 should be about 0
+PASS color pixel at 1, 0 should be about 0
+PASS color pixel at 1, 0 should be about 0
+PASS color pixel at 1, 0 should be about 0
+PASS color pixel at 0, 1 should be about 0
+PASS color pixel at 0, 1 should be about 0
+PASS color pixel at 0, 1 should be about 0
+PASS color pixel at 0, 1 should be about 0
+PASS color pixel at 1, 1 should be about 0
+PASS color pixel at 1, 1 should be about 0
+PASS color pixel at 1, 1 should be about 0
+PASS color pixel at 1, 1 should be about 0
+
+checking: completeley off right
+PASS color pixel at 0, 0 should be about 0
+PASS color pixel at 0, 0 should be about 0
+PASS color pixel at 0, 0 should be about 0
+PASS color pixel at 0, 0 should be about 0
+PASS color pixel at 1, 0 should be about 0
+PASS color pixel at 1, 0 should be about 0
+PASS color pixel at 1, 0 should be about 0
+PASS color pixel at 1, 0 should be about 0
+PASS color pixel at 0, 1 should be about 0
+PASS color pixel at 0, 1 should be about 0
+PASS color pixel at 0, 1 should be about 0
+PASS color pixel at 0, 1 should be about 0
+PASS color pixel at 1, 1 should be about 0
+PASS color pixel at 1, 1 should be about 0
+PASS color pixel at 1, 1 should be about 0
+PASS color pixel at 1, 1 should be about 0
+PASS getError was expected value: NO_ERROR : there should be no GL errors
+
+check disallowed formats
+PASS getError was expected value: INVALID_ENUM : Should not be able to read as RGB / UNSIGNED_BYTE
+PASS getError was expected value: INVALID_OPERATION : Should not be able to read as RGB / UNSIGNED_SHORT_5_6_5
+PASS getError was expected value: INVALID_ENUM : Should not be able to read as RGBA / UNSIGNED_SHORT_5_5_5_1
+PASS getError was expected value: INVALID_ENUM : Should not be able to read as RGBA / UNSIGNED_SHORT_4_4_4_4
+PASS getError was expected value: INVALID_ENUM : Should not be able to read as ALPHA / UNSIGNED_BYTE
+PASS getError was expected value: INVALID_ENUM : Should not be able to read as LUMINANCE / UNSIGNED_BYTE
+PASS getError was expected value: INVALID_ENUM : Should not be able to read as LUMINANCE_ALPHA / UNSIGNED_BYTE
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/canvas/webgl/read-pixels-test.html b/LayoutTests/fast/canvas/webgl/read-pixels-test.html
new file mode 100644
index 0000000..5ae0e5e
--- /dev/null
+++ b/LayoutTests/fast/canvas/webgl/read-pixels-test.html
@@ -0,0 +1,192 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<title>WebGL ReadPixels conformance test.</title>
+<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>
+</head>
+<body>
+<canvas id="example" width="200" height="200" style="width: 20px; height: 20px"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+<script>
+description("Checks that ReadPixels works as expected.");
+
+var wtu = WebGLTestUtils;
+var canvas = document.getElementById("example");
+var gl = create3DContext(canvas);
+
+if (window.initNonKhronosFramework) {
+ window.initNonKhronosFramework(false);
+}
+
+var width = 2;
+var height = 2;
+
+gl.clearColor(1, 1, 1, 1);
+gl.clear(gl.COLOR_BUFFER_BIT);
+
+// Resize the canvas to 2x2. This is an attempt to get stuff in the backbuffer.
+// that shouldn't be there.
+canvas.width = width;
+canvas.height = height;
+
+gl.clearColor(0.5, 0.7, 1.0, 1);
+gl.clear(gl.COLOR_BUFFER_BIT);
+
+var innerColor = [0.5, 0.7, 1.0, 1];
+var outerColor = [0, 0, 0, 0];
+
+var tests = [
+ { msg: 'in range', checkColor: innerColor, x: 0, y: 0,
+ oneColor: innerColor, oneX: 0, oneY: 0},
+ { msg: 'off top left', checkColor: outerColor, x: -1, y: -1,
+ oneColor: innerColor, oneX: 1, oneY: 1},
+ { msg: 'off bottom right', checkColor: outerColor, x: 1, y: 1,
+ oneColor: innerColor, oneX: 0, oneY: 0},
+ { msg: 'completely off top ', checkColor: outerColor, x: 0, y: -2,
+ oneColor: outerColor, oneX: 0, oneY: 0},
+ { msg: 'completely off bottom', checkColor: outerColor, x: 0, y: 2,
+ oneColor: outerColor, oneX: 0, oneY: 0},
+ { msg: 'completely off left', checkColor: outerColor, x: -2, y: 0,
+ oneColor: outerColor, oneX: 0, oneY: 0},
+ { msg: 'completeley off right', checkColor: outerColor, x: 2, y: 0,
+ oneColor: outerColor, oneX: 0, oneY: 0}
+];
+
+for (var tt = 0; tt < tests.length; ++tt) {
+ var test = tests[tt];
+ debug("");
+ debug("checking: " + test.msg);
+ checkBuffer(test.checkColor, test.x, test.y,
+ test.oneColor, test.oneX, test.oneY);
+}
+
+glErrorShouldBe(gl, gl.NO_ERROR, "there should be no GL errors");
+
+function checkBuffer(checkColor, x, y, oneColor, oneX, oneY) {
+ var buf = new Uint8Array(width * height * 4);
+ gl.readPixels(x, y, width, height, gl.RGBA, gl.UNSIGNED_BYTE, buf);
+ for (var yy = 0; yy < height; ++yy) {
+ for (var xx = 0; xx < width; ++xx) {
+ var offset = (yy * width + xx) * 4;
+ var expectedColors = (oneX == xx && oneY == yy) ? oneColor : checkColor;
+ for (var cc = 0; cc < 4; ++cc) {
+ var expectedColor = expectedColors[cc] * 255;
+ var color = buf[offset + cc];
+ var diff = Math.abs(expectedColor - color);
+ assertMsg(diff < 3,
+ "color pixel at " + xx + ", " + yy + " should be about " + expectedColor);
+ }
+ }
+ }
+}
+
+var badFormats = [
+ {
+ format: gl.RGB,
+ type: gl.UNSIGNED_BYTE,
+ dest: new Uint8Array(3)
+ },
+ {
+ format: gl.RGB,
+ type: gl.UNSIGNED_SHORT_5_6_5,
+ dest: new Uint8Array(3)
+ },
+ {
+ format: gl.RGBA,
+ type: gl.UNSIGNED_SHORT_5_5_5_1,
+ dest: new Uint16Array(1)
+ },
+ {
+ format: gl.RGBA,
+ type: gl.UNSIGNED_SHORT_4_4_4_4,
+ dest: new Uint16Array(1)
+ },
+ {
+ format: gl.ALPHA,
+ type: gl.UNSIGNED_BYTE,
+ dest: new Uint8Array(1)
+ },
+ {
+ format: gl.LUMINANCE,
+ type: gl.UNSIGNED_BYTE,
+ dest: new Uint8Array(1) },
+ {
+ format: gl.LUMINANCE_ALPHA,
+ type: gl.UNSIGNED_BYTE,
+ dest: new Uint8Array(2)
+ }
+];
+debug("");
+debug("check disallowed formats");
+for (var tt = 0; tt < badFormats.length; ++ tt) {
+ var info = badFormats[tt]
+ var format = info.format;
+ var type = info.type;
+ var dest = info.dest;
+ gl.readPixels(0, 0, 1, 1, format, type, dest);
+ // note that the GL error is INVALID_OPERATION if both format and type are invalid, but
+ // INVALID_ENUM if only one is.
+ glErrorShouldBe(
+ gl, (format == gl.RGBA || type == gl.UNSIGNED_BYTE) ? gl.INVALID_ENUM : gl.INVALID_OPERATION,
+ "Should not be able to read as " + wtu.glEnumToString(gl, format) +
+ " / " + wtu.glEnumToString(gl, type));
+}
+
+/*
+debug("");
+debug("check reading with lots of drawing");
+width = 1024;
+height = 1024;
+canvas.width = width;
+canvas.height = height;
+gl.viewport(0, 0, 1024, 1024);
+var program = wtu.setupTexturedQuad(gl);
+var loc = gl.getUniformLocation(program, "tex");
+gl.disable(gl.BLEND);
+gl.disable(gl.DEPTH_TEST);
+var colors = [[255, 0, 0, 1], [0, 255, 0, 1], [0, 0, 255, 1]];
+var textures = [];
+var results = [];
+for (var ii = 0; ii < colors.length; ++ii) {
+ gl.activeTexture(gl.TEXTURE0 + ii);
+ var tex = gl.createTexture();
+ wtu.fillTexture(gl, tex, 1, 1, colors[ii]);
+ textures.push(tex);
+}
+for (var ii = 0; ii < colors.length; ++ii) {
+ for (var jj = 0; jj < 300 + ii + 1; ++jj) {
+ gl.uniform1i(loc, jj % 3);
+ gl.drawArrays(gl.TRIANGLES, 0, 6);
+ }
+ var buf = new Uint8Array(4);
+ gl.readPixels(512, 512, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, buf);
+ results.push(buf);
+ for (var kk = 0; kk < 99; ++kk) {
+ gl.uniform1i(loc, (jj + kk) % 3);
+ gl.drawArrays(gl.TRIANGLES, 0, 6);
+ }
+}
+var actual;
+var expected;
+for (var ii = 0; ii < colors.length; ++ii) {
+ var buf = results[ii];
+ var color = colors[ii];
+ actual = [buf[0], buf[1], buf[2], buf[3]];
+ expected = [color[0], color[1], color[2], color[3] * 255];
+ shouldBe("actual", "expected");
+}
+glErrorShouldBe(gl, gl.NO_ERROR, "there should be no GL errors");
+*/
+
+debug("");
+successfullyParsed = true;
+</script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
+
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 35a1c31..85e406c 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,15 @@
+2010-11-17 Zhenyao Mo <zmo at google.com>
+
+ Reviewed by Kenneth Russell.
+
+ readPixels should generate INVALID_ENUM if only one of type/format mismatch UNSIGNED_BYTE/RGBA
+ https://bugs.webkit.org/show_bug.cgi?id=49673
+
+ Test: fast/canvas/webgl/read-pixels-test.html
+
+ * html/canvas/WebGLRenderingContext.cpp:
+ (WebCore::WebGLRenderingContext::readPixels):
+
2010-11-23 Alexander Pavlov <apavlov at chromium.org>
Reviewed by Pavel Feldman.
diff --git a/WebCore/html/canvas/WebGLRenderingContext.cpp b/WebCore/html/canvas/WebGLRenderingContext.cpp
index 0f4e65a..b201692 100644
--- a/WebCore/html/canvas/WebGLRenderingContext.cpp
+++ b/WebCore/html/canvas/WebGLRenderingContext.cpp
@@ -2249,10 +2249,14 @@ void WebGLRenderingContext::readPixels(long x, long y, long width, long height,
m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
return;
}
- if (format != GraphicsContext3D::RGBA || type != GraphicsContext3D::UNSIGNED_BYTE) {
+ if (format != GraphicsContext3D::RGBA && type != GraphicsContext3D::UNSIGNED_BYTE) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
return;
}
+ if (format != GraphicsContext3D::RGBA || type != GraphicsContext3D::UNSIGNED_BYTE) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
+ return;
+ }
// Validate array type against pixel type.
if ((type == GraphicsContext3D::UNSIGNED_BYTE && !pixels->isUnsignedByteArray())
|| (type != GraphicsContext3D::UNSIGNED_BYTE && !pixels->isUnsignedShortArray())) {
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list