Changeset 52164 in webkit


Ignore:
Timestamp:
Dec 15, 2009 11:08:14 AM (14 years ago)
Author:
eric@webkit.org
Message:

2009-12-15 Kenneth Russell <kbr@google.com>

Reviewed by Darin Fisher.

Don't allow default framebuffer to be mutated
https://bugs.webkit.org/show_bug.cgi?id=32391

  • fast/canvas/webgl/error-reporting-expected.txt:
  • fast/canvas/webgl/null-object-behaviour-expected.txt:
  • fast/canvas/webgl/script-tests/error-reporting.js:
  • fast/canvas/webgl/script-tests/null-object-behaviour.js:

2009-12-15 Kenneth Russell <kbr@google.com>

Reviewed by Darin Fisher.

Don't allow default framebuffer to be mutated
https://bugs.webkit.org/show_bug.cgi?id=32391

  • html/canvas/WebGLRenderingContext.cpp: (WebCore::WebGLRenderingContext::framebufferRenderbuffer): (WebCore::WebGLRenderingContext::framebufferTexture2D):
  • platform/graphics/mac/GraphicsContext3DMac.cpp: (WebCore::GraphicsContext3D::bindFramebuffer):

2009-12-15 Kenneth Russell <kbr@google.com>

Reviewed by Darin Fisher.

Don't allow default framebuffer to be mutated
https://bugs.webkit.org/show_bug.cgi?id=32391

  • src/GraphicsContext3D.cpp: (WebCore::GraphicsContext3DInternal::GraphicsContext3DInternal): (WebCore::GraphicsContext3DInternal::reshape): (WebCore::GraphicsContext3DInternal::beginPaint): (WebCore::GraphicsContext3DInternal::bindFramebuffer): (WebCore::GraphicsContext3D::bindFramebuffer):
Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r52159 r52164  
     12009-12-15  Kenneth Russell  <kbr@google.com>
     2
     3        Reviewed by Darin Fisher.
     4
     5        Don't allow default framebuffer to be mutated
     6        https://bugs.webkit.org/show_bug.cgi?id=32391
     7
     8        * fast/canvas/webgl/error-reporting-expected.txt:
     9        * fast/canvas/webgl/null-object-behaviour-expected.txt:
     10        * fast/canvas/webgl/script-tests/error-reporting.js:
     11        * fast/canvas/webgl/script-tests/null-object-behaviour.js:
     12
    1132009-12-15  Chris Fleizach  <cfleizach@apple.com>
    214
  • trunk/LayoutTests/fast/canvas/webgl/error-reporting-expected.txt

    r51970 r52164  
    1818PASS context.getError() is context.INVALID_VALUE
    1919PASS context.getError() is context.NO_ERROR
     20Testing attempts to manipulate the default framebuffer
     21PASS context.bindFramebuffer(context.FRAMEBUFFER, 0) is undefined.
     22PASS context.getError() is context.NO_ERROR
     23PASS context.framebufferRenderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.RENDERBUFFER, 0) is undefined.
     24PASS context.getError() is context.INVALID_OPERATION
     25PASS context.getError() is context.NO_ERROR
     26PASS context.framebufferTexture2D(context.FRAMEBUFFER, context.COLOR_ATTACHMENT0, context.TEXTURE_2D, 0, 0) is undefined.
     27PASS context.getError() is context.INVALID_OPERATION
     28PASS context.getError() is context.NO_ERROR
    2029PASS successfullyParsed is true
    2130
  • trunk/LayoutTests/fast/canvas/webgl/null-object-behaviour-expected.txt

    r51970 r52164  
    1717PASS context.bindRenderbuffer(context.RENDERBUFFER, 0) is undefined.
    1818PASS context.bindTexture(context.TEXTURE_2D, 0) is undefined.
     19PASS context.framebufferRenderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.RENDERBUFFER, 0) threw exception GL error 1282 in framebufferRenderbuffer.
     20PASS context.framebufferTexture2D(context.FRAMEBUFFER, context.COLOR_ATTACHMENT0, context.TEXTURE_2D, 0, 0) threw exception GL error 1282 in framebufferTexture2D.
    1921PASS context.getProgramParameter(undefined, 0) threw exception GL error 1282 in getProgramParameter.
    2022PASS context.getProgramInfoLog(undefined, 0) threw exception GL error 1282 in getProgramInfoLog.
  • trunk/LayoutTests/fast/canvas/webgl/script-tests/error-reporting.js

    r51970 r52164  
    3737shouldBe("context.getError()", "context.NO_ERROR");
    3838
    39 // FIXME: the following tests don't work properly yet
    40 // https://bugs.webkit.org/show_bug.cgi?id=32391
    41 // debug("Testing attempts to manipulate the default framebuffer");
    42 // shouldBeUndefined("context.bindFramebuffer(context.FRAMEBUFFER, 0)");
    43 // shouldBe("context.getError()", "context.NO_ERROR");
    44 // shouldBeUndefined("context.framebufferRenderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.RENDERBUFFER, 0)");
    45 // // Synthetic OpenGL error
    46 // shouldBe("context.getError()", "context.INVALID_OPERATION");
    47 // // Error state should be clear by this point
    48 // shouldBe("context.getError()", "context.NO_ERROR");
    49 // shouldBeUndefined("context.framebufferTexture2D(context.FRAMEBUFFER, context.COLOR_ATTACHMENT0, context.TEXTURE_2D, 0, 0)");
    50 // // Synthetic OpenGL error
    51 // shouldBe("context.getError()", "context.INVALID_OPERATION");
    52 // // Error state should be clear by this point
    53 // shouldBe("context.getError()", "context.NO_ERROR");
     39debug("Testing attempts to manipulate the default framebuffer");
     40shouldBeUndefined("context.bindFramebuffer(context.FRAMEBUFFER, 0)");
     41shouldBe("context.getError()", "context.NO_ERROR");
     42shouldBeUndefined("context.framebufferRenderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.RENDERBUFFER, 0)");
     43// Synthetic OpenGL error
     44shouldBe("context.getError()", "context.INVALID_OPERATION");
     45// Error state should be clear by this point
     46shouldBe("context.getError()", "context.NO_ERROR");
     47shouldBeUndefined("context.framebufferTexture2D(context.FRAMEBUFFER, context.COLOR_ATTACHMENT0, context.TEXTURE_2D, 0, 0)");
     48// Synthetic OpenGL error
     49shouldBe("context.getError()", "context.INVALID_OPERATION");
     50// Error state should be clear by this point
     51shouldBe("context.getError()", "context.NO_ERROR");
    5452
    5553successfullyParsed = true;
  • trunk/LayoutTests/fast/canvas/webgl/script-tests/null-object-behaviour.js

    r51970 r52164  
    1919shouldBeUndefined("context.bindRenderbuffer(context.RENDERBUFFER, 0)");
    2020shouldBeUndefined("context.bindTexture(context.TEXTURE_2D, 0)");
    21 // FIXME: the following two tests should state shouldThrow, not shouldBeUndefined
    22 // https://bugs.webkit.org/show_bug.cgi?id=32391
    23 // shouldBeUndefined("context.framebufferRenderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.RENDERBUFFER, 0)");
    24 // shouldBeUndefined("context.framebufferTexture2D(context.FRAMEBUFFER, context.COLOR_ATTACHMENT0, context.TEXTURE_2D, 0, 0)");
     21// The following two throw exceptions because conceptually no
     22// framebuffer is bound at this point. In reality the WebGL
     23// implementation's internal framebuffer is bound, but we can't allow
     24// user code to manipulate it.
     25shouldThrow("context.framebufferRenderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.RENDERBUFFER, 0)");
     26shouldThrow("context.framebufferTexture2D(context.FRAMEBUFFER, context.COLOR_ATTACHMENT0, context.TEXTURE_2D, 0, 0)");
    2527shouldThrow("context.getProgramParameter(undefined, 0)");
    2628shouldThrow("context.getProgramInfoLog(undefined, 0)");
  • trunk/WebCore/ChangeLog

    r52163 r52164  
     12009-12-15  Kenneth Russell  <kbr@google.com>
     2
     3        Reviewed by Darin Fisher.
     4
     5        Don't allow default framebuffer to be mutated
     6        https://bugs.webkit.org/show_bug.cgi?id=32391
     7
     8        * html/canvas/WebGLRenderingContext.cpp:
     9        (WebCore::WebGLRenderingContext::framebufferRenderbuffer):
     10        (WebCore::WebGLRenderingContext::framebufferTexture2D):
     11        * platform/graphics/mac/GraphicsContext3DMac.cpp:
     12        (WebCore::GraphicsContext3D::bindFramebuffer):
     13
    1142009-12-15  Zoltan Horvath  <zoltan@webkit.org>
    215
  • trunk/WebCore/html/canvas/WebGLRenderingContext.cpp

    r51970 r52164  
    711711        return;
    712712    }       
     713    // Don't allow the default framebuffer to be mutated; all current
     714    // implementations use an FBO internally in place of the default
     715    // FBO.
     716    if (!m_framebufferBinding || !m_framebufferBinding->object()) {
     717        m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     718        return;
     719    }
    713720    m_context->framebufferRenderbuffer(target, attachment, renderbuffertarget, buffer);
    714721    cleanupAfterGraphicsCall(false);
     
    719726    UNUSED_PARAM(ec);
    720727    if (texture && texture->context() != this) {
     728        m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     729        return;
     730    }
     731    // Don't allow the default framebuffer to be mutated; all current
     732    // implementations use an FBO internally in place of the default
     733    // FBO.
     734    if (!m_framebufferBinding || !m_framebufferBinding->object()) {
    721735        m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
    722736        return;
  • trunk/WebCore/platform/graphics/mac/GraphicsContext3DMac.cpp

    r51970 r52164  
    263263{
    264264    ensureContext(m_contextObj);
    265     ::glBindFramebufferEXT(target, buffer ? (GLuint) buffer->object() : m_fbo);
     265    ::glBindFramebufferEXT(target, (buffer && buffer->object()) ? (GLuint) buffer->object() : m_fbo);
    266266}
    267267
  • trunk/WebKit/chromium/ChangeLog

    r52161 r52164  
     12009-12-15  Kenneth Russell  <kbr@google.com>
     2
     3        Reviewed by Darin Fisher.
     4
     5        Don't allow default framebuffer to be mutated
     6        https://bugs.webkit.org/show_bug.cgi?id=32391
     7
     8        * src/GraphicsContext3D.cpp:
     9        (WebCore::GraphicsContext3DInternal::GraphicsContext3DInternal):
     10        (WebCore::GraphicsContext3DInternal::reshape):
     11        (WebCore::GraphicsContext3DInternal::beginPaint):
     12        (WebCore::GraphicsContext3DInternal::bindFramebuffer):
     13        (WebCore::GraphicsContext3D::bindFramebuffer):
     14
    1152009-12-15  Dimitri Glazkov  <dglazkov@chromium.org>
    216
  • trunk/WebKit/chromium/src/GraphicsContext3D.cpp

    r51970 r52164  
    117117    void bindBuffer(unsigned long target,
    118118                    WebGLBuffer* buffer);
     119    void bindFramebuffer(unsigned long target,
     120                         WebGLFramebuffer* framebuffer);
    119121    void bindTexture(unsigned long target,
    120122                     WebGLTexture* texture);
     
    134136    unsigned int m_depthBuffer;
    135137    unsigned int m_cachedWidth, m_cachedHeight;
     138
     139    // For tracking which FBO is bound
     140    unsigned int m_boundFBO;
    136141
    137142#ifdef FLIP_FRAMEBUFFER_VERTICALLY
     
    235240    , m_fbo(0)
    236241    , m_depthBuffer(0)
     242    , m_boundFBO(0)
    237243#ifdef FLIP_FRAMEBUFFER_VERTICALLY
    238244    , m_scanline(0)
     
    595601
    596602    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
     603    m_boundFBO = m_fbo;
    597604    glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_depthBuffer);
    598605    glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, width, height);
     
    682689    ImageBuffer* imageBuffer = canvas->buffer();
    683690    unsigned char* pixels = 0;
     691    bool mustRestoreFBO = (m_boundFBO != m_fbo);
     692    if (mustRestoreFBO)
     693        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
    684694#if PLATFORM(SKIA)
    685695    const SkBitmap* canvasBitmap = imageBuffer->context()->platformContext()->bitmap();
     
    731741#endif
    732742
     743    if (mustRestoreFBO)
     744        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_boundFBO);
     745
    733746#ifdef FLIP_FRAMEBUFFER_VERTICALLY
    734747    if (pixels)
     
    787800        m_boundArrayBuffer = bufID;
    788801    glBindBuffer(target, bufID);
     802}
     803
     804void GraphicsContext3DInternal::bindFramebuffer(unsigned long target,
     805                                                WebGLFramebuffer* framebuffer)
     806{
     807    makeContextCurrent();
     808    GLuint id = EXTRACT(framebuffer);
     809    if (!id)
     810        id = m_fbo;
     811    glBindFramebufferEXT(target, id);
     812    m_boundFBO = id;
    789813}
    790814
     
    11911215}
    11921216
    1193 GL_SAME_METHOD_2_X2(BindFramebufferEXT, bindFramebuffer, unsigned long, WebGLFramebuffer*)
     1217void GraphicsContext3D::bindFramebuffer(unsigned long target, WebGLFramebuffer* framebuffer)
     1218{
     1219    m_internal->bindFramebuffer(target, framebuffer);
     1220}
    11941221
    11951222GL_SAME_METHOD_2_X2(BindRenderbufferEXT, bindRenderbuffer, unsigned long, WebGLRenderbuffer*)
Note: See TracChangeset for help on using the changeset viewer.