Commit abdd5a29 authored by zmo@google.com's avatar zmo@google.com

2011-01-27 Zhenyao Mo <zmo@google.com>

        Reviewed by Kenneth Russell.

        texSubImage2D's format/type needs to match the internalformat/type from the previous texImage2D call
        https://bugs.webkit.org/show_bug.cgi?id=53054

        * fast/canvas/webgl/tex-sub-image-2d-bad-args-expected.txt: Added.
        * fast/canvas/webgl/tex-sub-image-2d-bad-args.html: Added.
2011-01-27  Zhenyao Mo  <zmo@google.com>

        Reviewed by Kenneth Russell.

        texSubImage2D's format/type needs to match the internalformat/type from the previous texImage2D call
        https://bugs.webkit.org/show_bug.cgi?id=53054

        Test: fast/canvas/webgl/tex-sub-image-2d-bad-args.html

        * html/canvas/WebGLRenderingContext.cpp:
        (WebCore::WebGLRenderingContext::texSubImage2DBase): Check format/type match.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76874 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 69ac5151
2011-01-27 Zhenyao Mo <zmo@google.com>
Reviewed by Kenneth Russell.
texSubImage2D's format/type needs to match the internalformat/type from the previous texImage2D call
https://bugs.webkit.org/show_bug.cgi?id=53054
* fast/canvas/webgl/tex-sub-image-2d-bad-args-expected.txt: Added.
* fast/canvas/webgl/tex-sub-image-2d-bad-args.html: Added.
2011-01-27 Ryosuke Niwa <rniwa@webkit.org>
Unreviewed rebaselines for Chromium Mac and Windows.
Tests texSubImage2D with bad arguments
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS getError was expected value: NO_ERROR : Setup should succeed
PASS getError was expected value: INVALID_VALUE : y + height > texture height
PASS getError was expected value: INVALID_VALUE : x + width > texture width
PASS getError was expected value: INVALID_VALUE : negative x
PASS getError was expected value: INVALID_VALUE : negative y
PASS getError was expected value: INVALID_VALUE : negative level
PASS getError was expected value: INVALID_ENUM : bad target
PASS getError was expected value: NO_ERROR : good args
PASS getError was expected value: INVALID_OPERATION : format not same as original
PASS getError was expected value: INVALID_OPERATION : type not same as original
PASS getError was expected value: NO_ERROR : make texture RGB
PASS getError was expected value: NO_ERROR : format same as original RGB
PASS getError was expected value: INVALID_OPERATION : format not same as original RGB
PASS getError was expected value: INVALID_OPERATION : type not same as original RGB
PASS getError was expected value: NO_ERROR : make texture RGBA 4_4_4_4
PASS getError was expected value: NO_ERROR : format same as original RGBA 4_4_4_4
PASS getError was expected value: INVALID_OPERATION : format not same as original RGBA 4_4_4_4
PASS getError was expected value: INVALID_OPERATION : type not same as original RGBA 4_4_4_4
PASS successfullyParsed is true
TEST COMPLETE
<html>
<head>
<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="testbed" width="16" height="16"></canvas>
<canvas id="c" width="16" height="16"></canvas>
<div id="description"></div>
<div id="console"></div>
<script>
description('Tests texSubImage2D with bad arguments');
var wtu = WebGLTestUtils;
var canvas = document.getElementById("testbed");
var c = document.getElementById("c");
var gl = wtu.create3DContext(canvas);
var tex = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, tex);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, c);
glErrorShouldBe(gl, gl.NO_ERROR, "Setup should succeed");
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 1, gl.RGBA, gl.UNSIGNED_BYTE, c);
glErrorShouldBe(gl, gl.INVALID_VALUE, "y + height > texture height");
gl.texSubImage2D(gl.TEXTURE_2D, 0, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, c);
glErrorShouldBe(gl, gl.INVALID_VALUE, "x + width > texture width");
gl.texSubImage2D(gl.TEXTURE_2D, 0, -1, 0, gl.RGBA, gl.UNSIGNED_BYTE, c);
glErrorShouldBe(gl, gl.INVALID_VALUE, "negative x");
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, -1, gl.RGBA, gl.UNSIGNED_BYTE, c);
glErrorShouldBe(gl, gl.INVALID_VALUE, "negative y");
gl.texSubImage2D(gl.TEXTURE_2D, -1, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, c);
glErrorShouldBe(gl, gl.INVALID_VALUE, "negative level");
gl.texSubImage2D(gl.FLOAT, 0, 0,0, gl.RGBA, gl.UNSIGNED_BYTE, c);
glErrorShouldBe(gl, gl.INVALID_ENUM, "bad target");
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, c);
glErrorShouldBe(gl, gl.NO_ERROR, "good args");
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGB, gl.UNSIGNED_BYTE, c);
glErrorShouldBe(gl, gl.INVALID_OPERATION, "format not same as original");
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGBA, gl.UNSIGNED_SHORT_4_4_4_4, c);
glErrorShouldBe(gl, gl.INVALID_OPERATION, "type not same as original");
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE, c);
glErrorShouldBe(gl, gl.NO_ERROR, "make texture RGB");
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGB, gl.UNSIGNED_BYTE, c);
glErrorShouldBe(gl, gl.NO_ERROR, "format same as original RGB");
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGBA, gl.UNSIGNED_BYTE, c);
glErrorShouldBe(gl, gl.INVALID_OPERATION, "format not same as original RGB");
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGB, gl.UNSIGNED_SHORT_5_6_5, c);
glErrorShouldBe(gl, gl.INVALID_OPERATION, "type not same as original RGB");
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_SHORT_4_4_4_4, c);
glErrorShouldBe(gl, gl.NO_ERROR, "make texture RGBA 4_4_4_4");
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGBA, gl.UNSIGNED_SHORT_4_4_4_4, c);
glErrorShouldBe(gl, gl.NO_ERROR, "format same as original RGBA 4_4_4_4");
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGB, gl.UNSIGNED_BYTE, c);
glErrorShouldBe(gl, gl.INVALID_OPERATION, "format not same as original RGBA 4_4_4_4");
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGBA, gl.UNSIGNED_BYTE, c);
glErrorShouldBe(gl, gl.INVALID_OPERATION, "type not same as original RGBA 4_4_4_4");
successfullyParsed = true;
</script>
<script src="../../js/resources/js-test-post.js"></script>
</body>
</html>
2011-01-27 Zhenyao Mo <zmo@google.com>
Reviewed by Kenneth Russell.
texSubImage2D's format/type needs to match the internalformat/type from the previous texImage2D call
https://bugs.webkit.org/show_bug.cgi?id=53054
Test: fast/canvas/webgl/tex-sub-image-2d-bad-args.html
* html/canvas/WebGLRenderingContext.cpp:
(WebCore::WebGLRenderingContext::texSubImage2DBase): Check format/type match.
2011-01-27 Yi Shen <yi.4.shen@nokia.com>, Tor Arne Vestbø <tor.arne.vestbo@nokia.com>
Reviewed by Andreas Kling.
......@@ -3078,12 +3078,21 @@ void WebGLRenderingContext::texSubImage2DBase(GC3Denum target, GC3Dint level, GC
ec = 0;
if (isContextLost())
return;
if (!validateTexFuncFormatAndType(format, type))
if (!validateTexFuncParameters(target, level, format, width, height, 0, format, type))
return;
if (!validateTextureBinding(target, true))
if (!validateSize(xoffset, yoffset))
return;
if (!validateSize(xoffset, yoffset) || !validateSize(width, height))
WebGLTexture* tex = validateTextureBinding(target, true);
if (!tex)
return;
if (xoffset + width > tex->getWidth(target, level) || yoffset + height > tex->getHeight(target, level)) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
return;
}
if (tex->getInternalFormat(target, level) != format || tex->getType(target, level) != type) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
return;
}
m_context->texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
cleanupAfterGraphicsCall(false);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment