Commit 28cf3305 authored by zmo@google.com's avatar zmo@google.com

2010-07-12 Zhenyao Mo <zmo@google.com>

        Reviewed by Darin Fisher.

        Bring bufferData and clear to GLES2 compliant
        https://bugs.webkit.org/show_bug.cgi?id=41574

        * fast/canvas/webgl/invalidPassedParams-expected.txt: Add wrong param test cases for bufferData and clear.
        * fast/canvas/webgl/invalidPassedParams.html: Ditto.
        * fast/canvas/webgl/resources/desktop-gl-constants.js: Add ACCUM_BUFFER_BIT enum.
2010-07-12  Zhenyao Mo  <zmo@google.com>

        Reviewed by Darin Fisher.

        Bring bufferData and clear to GLES2 compliant
        https://bugs.webkit.org/show_bug.cgi?id=41574

        * html/canvas/WebGLRenderingContext.cpp:
        (WebCore::WebGLRenderingContext::bufferData): Call validateBufferDataUsage().
        (WebCore::WebGLRenderingContext::clear): Check mask.
        (WebCore::WebGLRenderingContext::validateBufferDataUsage): Check usage.
        * html/canvas/WebGLRenderingContext.h: Declare validateBufferDataUsage.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@63134 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 9fcd248d
2010-07-12 Zhenyao Mo <zmo@google.com>
Reviewed by Darin Fisher.
Bring bufferData and clear to GLES2 compliant
https://bugs.webkit.org/show_bug.cgi?id=41574
* fast/canvas/webgl/invalidPassedParams-expected.txt: Add wrong param test cases for bufferData and clear.
* fast/canvas/webgl/invalidPassedParams.html: Ditto.
* fast/canvas/webgl/resources/desktop-gl-constants.js: Add ACCUM_BUFFER_BIT enum.
2010-07-12 Alexey Proskuryakov <ap@apple.com>
https://bugs.webkit.org/show_bug.cgi?id=13075
......@@ -2,11 +2,27 @@ Test for invalid passed parameters
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Test shaders
PASS shader = context.createShader(context.FRAGMENT_SHADER) is shader
PASS shader = context.createShader(context.VERTEX_SHADER) is shader
PASS context.createShader(0) threw exception GL error 1280 in createShader.
PASS context.createShader(context.TRIANGLES) threw exception GL error 1280 in createShader.
Test createShader()
PASS context.createShader(context.FRAGMENT_SHADER) generated expected GL error: NO_ERROR.
PASS context.createShader(context.VERTEX_SHADER) generated expected GL error: NO_ERROR.
PASS context.createShader(0) generated expected GL error: INVALID_ENUM.
PASS context.createShader(context.TRIANGLES) generated expected GL error: INVALID_ENUM.
Test clear()
PASS context.clear(desktopGL['ACCUM_BUFFER_BIT']) generated expected GL error: INVALID_VALUE.
PASS context.clear(desktopGL['ACCUM_BUFFER_BIT'] | context.COLOR_BUFFER_BIT) generated expected GL error: INVALID_VALUE.
PASS context.clear(desktopGL['ACCUM_BUFFER_BIT'] | context.COLOR_BUFFER_BIT | context.DEPTH_BUFFER_BIT | context.STENCIL_BUFFER_BIT) generated expected GL error: INVALID_VALUE.
PASS context.clear(context.COLOR_BUFFER_BIT | context.DEPTH_BUFFER_BIT | context.STENCIL_BUFFER_BIT) generated expected GL error: NO_ERROR.
Test bufferData()
PASS context.bindBuffer(context.ARRAY_BUFFER, buffer) generated expected GL error: NO_ERROR.
PASS context.bufferData(context.ARRAY_BUFFER, 16, context.STREAM_DRAW) generated expected GL error: NO_ERROR.
PASS context.bufferData(context.ARRAY_BUFFER, 16, context.STATIC_DRAW) generated expected GL error: NO_ERROR.
PASS context.bufferData(context.ARRAY_BUFFER, 16, context.DYNAMIC_DRAW) generated expected GL error: NO_ERROR.
PASS context.bufferData(context.ARRAY_BUFFER, 16, desktopGL['STREAM_READ']) generated expected GL error: INVALID_ENUM.
PASS context.bufferData(context.ARRAY_BUFFER, 16, desktopGL['STREAM_COPY']) generated expected GL error: INVALID_ENUM.
PASS context.bufferData(context.ARRAY_BUFFER, 16, desktopGL['STATIC_READ']) generated expected GL error: INVALID_ENUM.
PASS context.bufferData(context.ARRAY_BUFFER, 16, desktopGL['STATIC_COPY']) generated expected GL error: INVALID_ENUM.
PASS context.bufferData(context.ARRAY_BUFFER, 16, desktopGL['DYNAMIC_READ']) generated expected GL error: INVALID_ENUM.
PASS context.bufferData(context.ARRAY_BUFFER, 16, desktopGL['DYNAMIC_COPY']) generated expected GL error: INVALID_ENUM.
PASS successfullyParsed is true
......
......@@ -3,6 +3,7 @@
<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/desktop-gl-constants.js"></script>
</head>
<body>
<div id="description"></div>
......@@ -11,14 +12,32 @@
<script>
description("Test for invalid passed parameters");
var context = create3DDebugContext();
var context = create3DContext();
debug("Test shaders");
var shader;
shouldBe("shader = context.createShader(context.FRAGMENT_SHADER)", "shader");
shouldBe("shader = context.createShader(context.VERTEX_SHADER)", "shader");
shouldThrow("context.createShader(0)");
shouldThrow("context.createShader(context.TRIANGLES)");
debug("Test createShader()");
shouldGenerateGLError(context, context.NO_ERROR, "context.createShader(context.FRAGMENT_SHADER)");
shouldGenerateGLError(context, context.NO_ERROR, "context.createShader(context.VERTEX_SHADER)");
shouldGenerateGLError(context, context.INVALID_ENUM, "context.createShader(0)");
shouldGenerateGLError(context, context.INVALID_ENUM, "context.createShader(context.TRIANGLES)");
debug("Test clear()");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.clear(desktopGL['ACCUM_BUFFER_BIT'])");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.clear(desktopGL['ACCUM_BUFFER_BIT'] | context.COLOR_BUFFER_BIT)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.clear(desktopGL['ACCUM_BUFFER_BIT'] | context.COLOR_BUFFER_BIT | context.DEPTH_BUFFER_BIT | context.STENCIL_BUFFER_BIT)");
shouldGenerateGLError(context, context.NO_ERROR, "context.clear(context.COLOR_BUFFER_BIT | context.DEPTH_BUFFER_BIT | context.STENCIL_BUFFER_BIT)");
debug("Test bufferData()");
var buffer = context.createBuffer();
shouldGenerateGLError(context, context.NO_ERROR, "context.bindBuffer(context.ARRAY_BUFFER, buffer)");
shouldGenerateGLError(context, context.NO_ERROR, "context.bufferData(context.ARRAY_BUFFER, 16, context.STREAM_DRAW)");
shouldGenerateGLError(context, context.NO_ERROR, "context.bufferData(context.ARRAY_BUFFER, 16, context.STATIC_DRAW)");
shouldGenerateGLError(context, context.NO_ERROR, "context.bufferData(context.ARRAY_BUFFER, 16, context.DYNAMIC_DRAW)");
shouldGenerateGLError(context, context.INVALID_ENUM, "context.bufferData(context.ARRAY_BUFFER, 16, desktopGL['STREAM_READ'])");
shouldGenerateGLError(context, context.INVALID_ENUM, "context.bufferData(context.ARRAY_BUFFER, 16, desktopGL['STREAM_COPY'])");
shouldGenerateGLError(context, context.INVALID_ENUM, "context.bufferData(context.ARRAY_BUFFER, 16, desktopGL['STATIC_READ'])");
shouldGenerateGLError(context, context.INVALID_ENUM, "context.bufferData(context.ARRAY_BUFFER, 16, desktopGL['STATIC_COPY'])");
shouldGenerateGLError(context, context.INVALID_ENUM, "context.bufferData(context.ARRAY_BUFFER, 16, desktopGL['DYNAMIC_READ'])");
shouldGenerateGLError(context, context.INVALID_ENUM, "context.bufferData(context.ARRAY_BUFFER, 16, desktopGL['DYNAMIC_COPY'])");
debug("")
successfullyParsed = true;
......
......@@ -18,6 +18,7 @@ var desktopGL = {
'STATIC_READ': '0x88E5',
'CLIP_PLANE0': '0x3000',
'PERSPECTIVE_CORRECTION_HINT': '0x0C50',
'ACCUM_BUFFER_BIT': '0x0200',
'RGB4': '0x804F',
'RGB5': '0x8050',
'RGB8': '0x8051',
......
2010-07-12 Zhenyao Mo <zmo@google.com>
Reviewed by Darin Fisher.
Bring bufferData and clear to GLES2 compliant
https://bugs.webkit.org/show_bug.cgi?id=41574
* html/canvas/WebGLRenderingContext.cpp:
(WebCore::WebGLRenderingContext::bufferData): Call validateBufferDataUsage().
(WebCore::WebGLRenderingContext::clear): Check mask.
(WebCore::WebGLRenderingContext::validateBufferDataUsage): Check usage.
* html/canvas/WebGLRenderingContext.h: Declare validateBufferDataUsage.
2010-07-12 Eric Seidel <eric@webkit.org>
Unreviewed. Attempt to fix Chromium Windows build.
......@@ -349,6 +349,10 @@ void WebGLRenderingContext::blendFuncSeparate(unsigned long srcRGB, unsigned lon
void WebGLRenderingContext::bufferData(unsigned long target, int size, unsigned long usage, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
if (!isGLES2Compliant()) {
if (!validateBufferDataUsage(usage))
return;
}
if (target == GraphicsContext3D::ELEMENT_ARRAY_BUFFER && m_boundElementArrayBuffer) {
if (!m_boundElementArrayBuffer->associateBufferData(size)) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
......@@ -371,6 +375,10 @@ void WebGLRenderingContext::bufferData(unsigned long target, int size, unsigned
void WebGLRenderingContext::bufferData(unsigned long target, ArrayBufferView* data, unsigned long usage, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
if (!isGLES2Compliant()) {
if (!validateBufferDataUsage(usage))
return;
}
if (target == GraphicsContext3D::ELEMENT_ARRAY_BUFFER && m_boundElementArrayBuffer) {
if (!m_boundElementArrayBuffer->associateBufferData(data)) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
......@@ -428,6 +436,12 @@ unsigned long WebGLRenderingContext::checkFramebufferStatus(unsigned long target
void WebGLRenderingContext::clear(unsigned long mask)
{
if (!isGLES2Compliant()) {
if (mask & ~(GraphicsContext3D::COLOR_BUFFER_BIT | GraphicsContext3D::DEPTH_BUFFER_BIT | GraphicsContext3D::STENCIL_BUFFER_BIT)) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
return;
}
}
m_context->clear(mask);
cleanupAfterGraphicsCall(true);
}
......@@ -3578,6 +3592,18 @@ bool WebGLRenderingContext::validateUniformMatrixParameters(const WebGLUniformLo
return true;
}
bool WebGLRenderingContext::validateBufferDataUsage(unsigned long usage)
{
switch (usage) {
case GraphicsContext3D::STREAM_DRAW:
case GraphicsContext3D::STATIC_DRAW:
case GraphicsContext3D::DYNAMIC_DRAW:
return true;
}
m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
return false;
}
void WebGLRenderingContext::vertexAttribfImpl(unsigned long index, int expectedSize, float v0, float v1, float v2, float v3)
{
if (index >= m_maxVertexAttribs) {
......
......@@ -501,6 +501,9 @@ class WebKitCSSMatrix;
bool validateUniformMatrixParameters(const WebGLUniformLocation* location, bool transpose, Float32Array* v, int mod);
bool validateUniformMatrixParameters(const WebGLUniformLocation* location, bool transpose, void* v, int size, int mod);
// Helper function to validate usage for bufferData.
bool validateBufferDataUsage(unsigned long);
// Helper functions for vertexAttribNf{v}.
void vertexAttribfImpl(unsigned long index, int expectedSize, float v0, float v1, float v2, float v3);
void vertexAttribfvImpl(unsigned long index, Float32Array* v, int expectedSize);
......
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