Changeset 71282 in webkit


Ignore:
Timestamp:
Nov 3, 2010 4:53:19 PM (13 years ago)
Author:
zmo@google.com
Message:

2010-11-02 Zhenyao Mo <zmo@google.com>

Reviewed by Kenneth Russell.

A different mask or reference value in stencil operations should generate INVALID_OPERATION
https://bugs.webkit.org/show_bug.cgi?id=48669

  • html/canvas/WebGLRenderingContext.cpp: (WebCore::WebGLRenderingContext::WebGLRenderingContext): Init stencil func ref/mask and stencil mask to default. (WebCore::WebGLRenderingContext::stencilFunc): Cache ref/mask value. (WebCore::WebGLRenderingContext::stencilFuncSeparate): Generate error if front/back values differ. (WebCore::WebGLRenderingContext::stencilMask): Cache mask value. (WebCore::WebGLRenderingContext::stencilMaskSeparate): Generate error if front/back values differ. (WebCore::WebGLRenderingContext::validateFace): Validate face parameter. (WebCore::WebGLRenderingContext::validateStencilFunc): Validate stencil func parameter.
  • html/canvas/WebGLRenderingContext.h: Add members to track stencil func ref/mask and stencil mask.

2010-11-02 Zhenyao Mo <zmo@google.com>

Reviewed by Kenneth Russell.

A different mask or reference value in stencil operations should generate INVALID_OPERATION
https://bugs.webkit.org/show_bug.cgi?id=48669

  • fast/canvas/webgl/webgl-specific-expected.txt:
  • fast/canvas/webgl/webgl-specific.html: Uncomment the test cases for the bug.
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r71280 r71282  
     12010-11-02  Zhenyao Mo  <zmo@google.com>
     2
     3        Reviewed by Kenneth Russell.
     4
     5        A different mask or reference value in stencil operations should generate INVALID_OPERATION
     6        https://bugs.webkit.org/show_bug.cgi?id=48669
     7
     8        * fast/canvas/webgl/webgl-specific-expected.txt:
     9        * fast/canvas/webgl/webgl-specific.html: Uncomment the test cases for the bug.
     10
    1112010-11-03  Oliver Hunt  <oliver@apple.com>
    212
  • trunk/LayoutTests/fast/canvas/webgl/webgl-specific-expected.txt

    r71185 r71282  
    1919PASS getError was expected value: INVALID_OPERATION : constant color and constant alpha cannot be used together as source and destination factors in the blend function
    2020PASS getError was expected value: INVALID_OPERATION : constant color and constant alpha cannot be used together as source and destination factors in the blend function
     21PASS getError was expected value: NO_ERROR : stencilMask should generate no error
     22PASS getError was expected value: INVALID_OPERATION : a different mask value for front and back facing is illegal
     23PASS getError was expected value: INVALID_OPERATION : a different mask value for front and back facing is illegal
     24PASS getError was expected value: NO_ERROR : stencilFunc should generate no error
     25PASS getError was expected value: INVALID_OPERATION : a different reference value for front and back facing is illegal
     26PASS getError was expected value: INVALID_OPERATION : a different reference value for front and back facing is illegal
     27PASS getError was expected value: INVALID_OPERATION : a different mask value for front and back facing is illegal
     28PASS getError was expected value: INVALID_OPERATION : a different mask value for front and back facing is illegal
    2129PASS successfullyParsed is true
    2230
  • trunk/LayoutTests/fast/canvas/webgl/webgl-specific.html

    r71185 r71282  
    7373glErrorShouldBe(gl, gl.INVALID_OPERATION,
    7474    "depthRange should generate INVALID_OPERATION if zNear is greater than zFar");
     75*/
    7576
    7677gl.stencilMask(255);
     
    99100glErrorShouldBe(gl, gl.INVALID_OPERATION,
    100101    "a different mask value for front and back facing is illegal");
    101 */
    102102
    103103successfullyParsed = true;
  • trunk/WebCore/ChangeLog

    r71278 r71282  
     12010-11-02  Zhenyao Mo  <zmo@google.com>
     2
     3        Reviewed by Kenneth Russell.
     4
     5        A different mask or reference value in stencil operations should generate INVALID_OPERATION
     6        https://bugs.webkit.org/show_bug.cgi?id=48669
     7
     8        * html/canvas/WebGLRenderingContext.cpp:
     9        (WebCore::WebGLRenderingContext::WebGLRenderingContext): Init stencil func ref/mask and stencil mask to default.
     10        (WebCore::WebGLRenderingContext::stencilFunc): Cache ref/mask value.
     11        (WebCore::WebGLRenderingContext::stencilFuncSeparate): Generate error if front/back values differ.
     12        (WebCore::WebGLRenderingContext::stencilMask): Cache mask value.
     13        (WebCore::WebGLRenderingContext::stencilMaskSeparate): Generate error if front/back values differ.
     14        (WebCore::WebGLRenderingContext::validateFace): Validate face parameter.
     15        (WebCore::WebGLRenderingContext::validateStencilFunc): Validate stencil func parameter.
     16        * html/canvas/WebGLRenderingContext.h: Add members to track stencil func ref/mask and stencil mask.
     17
    1182010-11-03  Dimitri Glazkov  <dglazkov@chromium.org>
    219
  • trunk/WebCore/html/canvas/WebGLRenderingContext.cpp

    r71274 r71282  
    105105    , m_videoCache(4)
    106106    , m_contextLost(false)
     107    , m_stencilMask(0xFFFFFFFF)
     108    , m_stencilFuncRef(0)
     109    , m_stencilFuncMask(0xFFFFFFFF)
    107110{
    108111    ASSERT(m_context);
     
    22182221    if (isContextLost())
    22192222        return;
     2223    if (!validateStencilFunc(func))
     2224        return;
     2225    m_stencilFuncRef = ref;
     2226    m_stencilFuncMask = mask;
    22202227    m_context->stencilFunc(func, ref, mask);
    22212228    cleanupAfterGraphicsCall(false);
     
    22262233    if (isContextLost())
    22272234        return;
     2235    if (!validateFace(face) || !validateStencilFunc(func))
     2236        return;
     2237    if (face == GraphicsContext3D::FRONT_AND_BACK) {
     2238        m_stencilFuncRef = ref;
     2239        m_stencilFuncMask = mask;
     2240    } else if (m_stencilFuncRef != ref || m_stencilFuncMask != mask) {
     2241        // for ref value, we generate an error if user specify a different value
     2242        // for front/back faces even if they clamp to the same value internally.
     2243        m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     2244        return;
     2245    }
    22282246    m_context->stencilFuncSeparate(face, func, ref, mask);
    22292247    cleanupAfterGraphicsCall(false);
     
    22342252    if (isContextLost())
    22352253        return;
     2254    m_stencilMask = mask;
    22362255    m_context->stencilMask(mask);
    22372256    cleanupAfterGraphicsCall(false);
     
    22422261    if (isContextLost())
    22432262        return;
     2263    if (!validateFace(face))
     2264        return;
     2265    if (face == GraphicsContext3D::FRONT_AND_BACK)
     2266        m_stencilMask = mask;
     2267    else if (m_stencilMask != mask) {
     2268        m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     2269        return;
     2270    }
    22442271    m_context->stencilMaskSeparate(face, mask);
    22452272    cleanupAfterGraphicsCall(false);
     
    35563583}
    35573584
     3585bool WebGLRenderingContext::validateFace(unsigned long face)
     3586{
     3587    switch (face) {
     3588    case GraphicsContext3D::FRONT:
     3589    case GraphicsContext3D::BACK:
     3590    case GraphicsContext3D::FRONT_AND_BACK:
     3591        return true;
     3592    default:
     3593        m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     3594        return false;
     3595    }
     3596}
     3597
     3598bool WebGLRenderingContext::validateStencilFunc(unsigned long func)
     3599{
     3600    switch (func) {
     3601    case GraphicsContext3D::NEVER:
     3602    case GraphicsContext3D::LESS:
     3603    case GraphicsContext3D::LEQUAL:
     3604    case GraphicsContext3D::GREATER:
     3605    case GraphicsContext3D::GEQUAL:
     3606    case GraphicsContext3D::EQUAL:
     3607    case GraphicsContext3D::NOTEQUAL:
     3608    case GraphicsContext3D::ALWAYS:
     3609        return true;
     3610    default:
     3611        m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     3612        return false;
     3613    }
     3614}
     3615
    35583616void WebGLRenderingContext::printWarningToConsole(const String& message)
    35593617{
  • trunk/WebCore/html/canvas/WebGLRenderingContext.h

    r71274 r71282  
    427427    bool m_contextLost;
    428428
     429    long m_stencilBits;
     430    unsigned long m_stencilMask;
     431    long m_stencilFuncRef; // Note that this is the user specified value, not the internal clamped value.
     432    unsigned long m_stencilFuncMask;
     433
    429434    // Helpers for getParameter and others
    430435    WebGLGetInfo getBooleanParameter(unsigned long pname);
     
    486491    bool validateDrawMode(unsigned long);
    487492
     493    // Helper function to validate face.
     494    bool validateFace(unsigned long);
     495
     496    // Helper function to validate stencil func.
     497    bool validateStencilFunc(unsigned long);
     498
    488499    // Helper function for texParameterf and texParameteri.
    489500    void texParameter(unsigned long target, unsigned long pname, float parami, int paramf, bool isFloat);
Note: See TracChangeset for help on using the changeset viewer.