Commit 13daadda authored by zmo@google.com's avatar zmo@google.com

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

        Reviewed by Kenneth Russell.

        Update validation of stencil mask and ref values
        https://bugs.webkit.org/show_bug.cgi?id=50716

        * html/canvas/WebGLRenderingContext.cpp:
        (WebCore::WebGLRenderingContext::initializeNewContext): Initialize cached stencil settings.
        (WebCore::WebGLRenderingContext::drawArrays): Validate stencil settings.
        (WebCore::WebGLRenderingContext::drawElements): Ditto.
        (WebCore::WebGLRenderingContext::stencilFunc): Cache stencil settings, but generate no error.
        (WebCore::WebGLRenderingContext::stencilFuncSeparate): Ditto.
        (WebCore::WebGLRenderingContext::stencilMask): Ditto.
        (WebCore::WebGLRenderingContext::stencilMaskSeparate): Ditto.
        (WebCore::WebGLRenderingContext::validateStencilSettings): Helper function to validate stencil settings.
        * html/canvas/WebGLRenderingContext.h: Declare stencil setting members.
2010-12-29  Zhenyao Mo  <zmo@google.com>

        Reviewed by Kenneth Russell.

        Update validation of stencil mask and ref values
        https://bugs.webkit.org/show_bug.cgi?id=50716

        * fast/canvas/webgl/webgl-specific-expected.txt: Sync with khronos: refactor the test, also update the stencil setting test due to spec change.
        * fast/canvas/webgl/webgl-specific.html: Ditto.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@74818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent c54e30e5
2010-12-29 Zhenyao Mo <zmo@google.com>
Reviewed by Kenneth Russell.
Update validation of stencil mask and ref values
https://bugs.webkit.org/show_bug.cgi?id=50716
* html/canvas/WebGLRenderingContext.cpp:
(WebCore::WebGLRenderingContext::initializeNewContext): Initialize cached stencil settings.
(WebCore::WebGLRenderingContext::drawArrays): Validate stencil settings.
(WebCore::WebGLRenderingContext::drawElements): Ditto.
(WebCore::WebGLRenderingContext::stencilFunc): Cache stencil settings, but generate no error.
(WebCore::WebGLRenderingContext::stencilFuncSeparate): Ditto.
(WebCore::WebGLRenderingContext::stencilMask): Ditto.
(WebCore::WebGLRenderingContext::stencilMaskSeparate): Ditto.
(WebCore::WebGLRenderingContext::validateStencilSettings): Helper function to validate stencil settings.
* html/canvas/WebGLRenderingContext.h: Declare stencil setting members.
2010-12-30 Martin Robinson <mrobinson@igalia.com>
Reviewed by Xan Lopez.
......
......@@ -173,8 +173,11 @@ void WebGLRenderingContext::initializeNewContext()
m_framebufferBinding = 0;
m_renderbufferBinding = 0;
m_stencilMask = 0xFFFFFFFF;
m_stencilMaskBack = 0xFFFFFFFF;
m_stencilFuncRef = 0;
m_stencilFuncRefBack = 0;
m_stencilFuncMask = 0xFFFFFFFF;
m_stencilFuncMaskBack = 0xFFFFFFFF;
m_vertexAttribState.clear();
int numCombinedTextureImageUnits = 0;
......@@ -1109,6 +1112,9 @@ void WebGLRenderingContext::drawArrays(unsigned long mode, long first, long coun
if (isContextLost() || !validateDrawMode(mode))
return;
if (!validateStencilSettings())
return;
if (first < 0 || count < 0) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
return;
......@@ -1158,6 +1164,9 @@ void WebGLRenderingContext::drawElements(unsigned long mode, long count, unsigne
if (isContextLost() || !validateDrawMode(mode))
return;
if (!validateStencilSettings())
return;
switch (type) {
case GraphicsContext3D::UNSIGNED_BYTE:
case GraphicsContext3D::UNSIGNED_SHORT:
......@@ -2471,7 +2480,9 @@ void WebGLRenderingContext::stencilFunc(unsigned long func, long ref, unsigned l
if (!validateStencilFunc(func))
return;
m_stencilFuncRef = ref;
m_stencilFuncRefBack = ref;
m_stencilFuncMask = mask;
m_stencilFuncMaskBack = mask;
m_context->stencilFunc(func, ref, mask);
cleanupAfterGraphicsCall(false);
}
......@@ -2480,15 +2491,25 @@ void WebGLRenderingContext::stencilFuncSeparate(unsigned long face, unsigned lon
{
if (isContextLost())
return;
if (!validateFace(face) || !validateStencilFunc(func))
if (!validateStencilFunc(func))
return;
if (face == GraphicsContext3D::FRONT_AND_BACK) {
switch (face) {
case GraphicsContext3D::FRONT_AND_BACK:
m_stencilFuncRef = ref;
m_stencilFuncRefBack = ref;
m_stencilFuncMask = mask;
} else if (m_stencilFuncRef != ref || m_stencilFuncMask != mask) {
// for ref value, we generate an error if user specify a different value
// for front/back faces even if they clamp to the same value internally.
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
m_stencilFuncMaskBack = mask;
break;
case GraphicsContext3D::FRONT:
m_stencilFuncRef = ref;
m_stencilFuncMask = mask;
break;
case GraphicsContext3D::BACK:
m_stencilFuncRefBack = ref;
m_stencilFuncMaskBack = mask;
break;
default:
m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
return;
}
m_context->stencilFuncSeparate(face, func, ref, mask);
......@@ -2500,6 +2521,7 @@ void WebGLRenderingContext::stencilMask(unsigned long mask)
if (isContextLost())
return;
m_stencilMask = mask;
m_stencilMaskBack = mask;
m_context->stencilMask(mask);
cleanupAfterGraphicsCall(false);
}
......@@ -2508,12 +2530,19 @@ void WebGLRenderingContext::stencilMaskSeparate(unsigned long face, unsigned lon
{
if (isContextLost())
return;
if (!validateFace(face))
return;
if (face == GraphicsContext3D::FRONT_AND_BACK)
switch (face) {
case GraphicsContext3D::FRONT_AND_BACK:
m_stencilMask = mask;
else if (m_stencilMask != mask) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
m_stencilMaskBack = mask;
break;
case GraphicsContext3D::FRONT:
m_stencilMask = mask;
break;
case GraphicsContext3D::BACK:
m_stencilMaskBack = mask;
break;
default:
m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
return;
}
m_context->stencilMaskSeparate(face, mask);
......@@ -3865,17 +3894,13 @@ bool WebGLRenderingContext::validateDrawMode(unsigned long mode)
}
}
bool WebGLRenderingContext::validateFace(unsigned long face)
bool WebGLRenderingContext::validateStencilSettings()
{
switch (face) {
case GraphicsContext3D::FRONT:
case GraphicsContext3D::BACK:
case GraphicsContext3D::FRONT_AND_BACK:
return true;
default:
m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
if (m_stencilMask != m_stencilMaskBack || m_stencilFuncRef != m_stencilFuncRefBack || m_stencilFuncMask != m_stencilFuncMaskBack) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
return false;
}
return true;
}
bool WebGLRenderingContext::validateStencilFunc(unsigned long func)
......
......@@ -456,9 +456,9 @@ public:
GraphicsContext3D::Attributes m_attributes;
long m_stencilBits;
unsigned long m_stencilMask;
long m_stencilFuncRef; // Note that this is the user specified value, not the internal clamped value.
unsigned long m_stencilFuncMask;
unsigned long m_stencilMask, m_stencilMaskBack;
long m_stencilFuncRef, m_stencilFuncRefBack; // Note that these are the user specified values, not the internal clamped value.
unsigned long m_stencilFuncMask, m_stencilFuncMaskBack;
bool m_isGLES2Compliant;
bool m_isGLES2NPOTStrict;
......@@ -541,8 +541,8 @@ public:
// Helper function to validate mode for draw{Arrays/Elements}.
bool validateDrawMode(unsigned long);
// Helper function to validate face.
bool validateFace(unsigned long);
// Helper function to validate if front/back stencilMask and stencilFunc settings are the same.
bool validateStencilSettings();
// Helper function to validate stencil func.
bool validateStencilFunc(unsigned long);
......
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