Changeset 114961 in webkit


Ignore:
Timestamp:
Apr 23, 2012, 4:22:03 PM (13 years ago)
Author:
zmo@google.com
Message:

framebuffer binding should not be changed after canvas resize or compositing
https://bugs.webkit.org/show_bug.cgi?id=84609

Reviewed by Kenneth Russell.

Source/WebCore:

Test: fast/canvas/webgl/framebuffer-bindings-unaffected-on-resize.html

  • html/canvas/WebGLRenderingContext.cpp: set framebuffer binding to DrawingBuffer.

(WebCore):
(WebCore::WebGLRenderingContext::bindFramebuffer):
(WebCore::WebGLRenderingContext::deleteFramebuffer):
(WebCore::WebGLRenderingContext::loseContextImpl):

  • platform/graphics/cairo/DrawingBufferCairo.cpp: initialize m_framebufferBinding.

(WebCore::DrawingBuffer::DrawingBuffer):

  • platform/graphics/chromium/DrawingBufferChromium.cpp: Ditto.

(WebCore::DrawingBuffer::DrawingBuffer):

  • platform/graphics/chromium/WebGLLayerChromium.cpp: Recover framebuffer binding after update().

(WebCore::WebGLLayerChromium::update):

  • platform/graphics/gpu/DrawingBuffer.cpp: Add a function to restore framebuffer binding.

(WebCore::DrawingBuffer::restoreFramebufferBinding):
(WebCore):

  • platform/graphics/gpu/DrawingBuffer.h: Ditto.

(WebCore::DrawingBuffer::setTexture2DBinding):
(DrawingBuffer):
(WebCore::DrawingBuffer::setFramebufferBinding):

  • platform/graphics/gpu/mac/DrawingBufferMac.mm: initialize m_framebufferBinding.

(WebCore::DrawingBuffer::DrawingBuffer):

  • platform/graphics/gpu/qt/DrawingBufferQt.cpp: initialize m_framebufferBinding.

(WebCore::DrawingBuffer::DrawingBuffer):

LayoutTests:

  • fast/canvas/webgl/framebuffer-bindings-unaffected-on-resize-expected.txt: Added.
  • fast/canvas/webgl/framebuffer-bindings-unaffected-on-resize.html: Added.
  • fast/canvas/webgl/resources/webgl-test-utils.js: Sync with khronos side (partial)

(WebGLTestUtils.):
(WebGLTestUtils):

Location:
trunk
Files:
2 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r114959 r114961  
     12012-04-23  Zhenyao Mo  <zmo@google.com>
     2
     3        framebuffer binding should not be changed after canvas resize or compositing
     4        https://bugs.webkit.org/show_bug.cgi?id=84609
     5
     6        Reviewed by Kenneth Russell.
     7
     8        * fast/canvas/webgl/framebuffer-bindings-unaffected-on-resize-expected.txt: Added.
     9        * fast/canvas/webgl/framebuffer-bindings-unaffected-on-resize.html: Added.
     10        * fast/canvas/webgl/resources/webgl-test-utils.js: Sync with khronos side (partial)
     11        (WebGLTestUtils.):
     12        (WebGLTestUtils):
     13
    1142012-04-23  Oliver Hunt  <oliver@apple.com>
    215
  • trunk/LayoutTests/fast/canvas/webgl/resources/webgl-test-utils.js

    r114935 r114961  
    11051105};
    11061106
     1107/**
     1108 * Provides requestAnimationFrame in a cross browser way.
     1109 */
     1110var requestAnimFrameImpl_;
     1111
     1112var requestAnimFrame = function(callback, element) {
     1113  if (!requestAnimFrameImpl_) {
     1114    requestAnimFrameImpl_ = function() {
     1115      var functionNames = [
     1116        "requestAnimationFrame",
     1117        "webkitRequestAnimationFrame",
     1118        "mozRequestAnimationFrame",
     1119        "oRequestAnimationFrame",
     1120        "msRequestAnimationFrame"
     1121      ];
     1122      for (var jj = 0; jj < functionNames.length; ++jj) {
     1123        var functionName = functionNames[jj];
     1124        if (window[functionName]) {
     1125          return function(name) {
     1126            return function(callback, element) {
     1127              return window[name].call(window, callback, element);
     1128            };
     1129          }(functionName);
     1130        }
     1131      }
     1132      return function(callback, element) {
     1133           return window.setTimeout(callback, 1000 / 70);
     1134        };
     1135    }();
     1136  }
     1137
     1138  return requestAnimFrameImpl_(callback, element);
     1139};
     1140
     1141/**
     1142 * Provides cancelAnimationFrame in a cross browser way.
     1143 */
     1144var cancelAnimFrame = (function() {
     1145  return window.cancelAnimationFrame ||
     1146         window.webkitCancelAnimationFrame ||
     1147         window.mozCancelAnimationFrame ||
     1148         window.oCancelAnimationFrame ||
     1149         window.msCancelAnimationFrame ||
     1150         window.clearTimeout;
     1151})();
     1152
     1153var waitFrames = function(frames, callback) {
     1154  var countDown = function() {
     1155    if (frames == 0) {
     1156      callback();
     1157    } else {
     1158      --frames;
     1159      requestAnimFrame(countDown);
     1160    }
     1161  };
     1162  countDown();
     1163};
     1164
    11071165return {
     1166  cancelAnimFrame: cancelAnimFrame,
    11081167  create3DContext: create3DContext,
    11091168  create3DContextWithWrapperThatThrowsOnGLError:
     
    11481207  readFile: readFile,
    11491208  readFileList: readFileList,
     1209  requestAnimFrame: requestAnimFrame,
     1210  waitFrames: waitFrames,
    11501211
    11511212  none: false
  • trunk/Source/WebCore/ChangeLog

    r114957 r114961  
     12012-04-23  Zhenyao Mo  <zmo@google.com>
     2
     3        framebuffer binding should not be changed after canvas resize or compositing
     4        https://bugs.webkit.org/show_bug.cgi?id=84609
     5
     6        Reviewed by Kenneth Russell.
     7
     8        Test: fast/canvas/webgl/framebuffer-bindings-unaffected-on-resize.html
     9
     10        * html/canvas/WebGLRenderingContext.cpp: set framebuffer binding to DrawingBuffer.
     11        (WebCore):
     12        (WebCore::WebGLRenderingContext::bindFramebuffer):
     13        (WebCore::WebGLRenderingContext::deleteFramebuffer):
     14        (WebCore::WebGLRenderingContext::loseContextImpl):
     15        * platform/graphics/cairo/DrawingBufferCairo.cpp: initialize m_framebufferBinding.
     16        (WebCore::DrawingBuffer::DrawingBuffer):
     17        * platform/graphics/chromium/DrawingBufferChromium.cpp: Ditto.
     18        (WebCore::DrawingBuffer::DrawingBuffer):
     19        * platform/graphics/chromium/WebGLLayerChromium.cpp: Recover framebuffer binding after update().
     20        (WebCore::WebGLLayerChromium::update):
     21        * platform/graphics/gpu/DrawingBuffer.cpp: Add a function to restore framebuffer binding.
     22        (WebCore::DrawingBuffer::restoreFramebufferBinding):
     23        (WebCore):
     24        * platform/graphics/gpu/DrawingBuffer.h: Ditto.
     25        (WebCore::DrawingBuffer::setTexture2DBinding):
     26        (DrawingBuffer):
     27        (WebCore::DrawingBuffer::setFramebufferBinding):
     28        * platform/graphics/gpu/mac/DrawingBufferMac.mm: initialize m_framebufferBinding.
     29        (WebCore::DrawingBuffer::DrawingBuffer):
     30        * platform/graphics/gpu/qt/DrawingBufferQt.cpp: initialize m_framebufferBinding.
     31        (WebCore::DrawingBuffer::DrawingBuffer):
     32
    1332012-04-23  Victor Carbune  <vcarbune@adobe.com>
    234
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp

    r114935 r114961  
    921921    }
    922922    m_framebufferBinding = buffer;
     923    if (m_drawingBuffer)
     924        m_drawingBuffer->setFramebufferBinding(objectOrZero(m_framebufferBinding.get()));
    923925    if (!m_framebufferBinding && m_drawingBuffer) {
    924926        // Instead of binding fb 0, bind the drawing buffer.
     
    15341536    if (framebuffer == m_framebufferBinding) {
    15351537        m_framebufferBinding = 0;
    1536         // Have to call bindFramebuffer here to bind back to internal fbo.
    1537         if (m_drawingBuffer)
     1538        if (m_drawingBuffer) {
     1539            m_drawingBuffer->setFramebufferBinding(0);
     1540            // Have to call bindFramebuffer here to bind back to internal fbo.
    15381541            m_drawingBuffer->bind();
    1539         else
     1542        } else
    15401543            m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, 0);
    15411544    }
     
    43084311
    43094312    if (m_drawingBuffer) {
    4310         // Make absolutely sure we do not refer to an already-deleted texture.
     4313        // Make absolutely sure we do not refer to an already-deleted texture or framebuffer.
    43114314        m_drawingBuffer->setTexture2DBinding(0);
     4315        m_drawingBuffer->setFramebufferBinding(0);
    43124316    }
    43134317
  • trunk/Source/WebCore/platform/graphics/cairo/DrawingBufferCairo.cpp

    r114935 r114961  
    4444    , m_scissorEnabled(false)
    4545    , m_texture2DBinding(0)
     46    , m_framebufferBinding(0)
    4647    , m_activeTextureUnit(GraphicsContext3D::TEXTURE0)
    4748    , m_context(context)
  • trunk/Source/WebCore/platform/graphics/chromium/DrawingBufferChromium.cpp

    r114935 r114961  
    7070    , m_scissorEnabled(false)
    7171    , m_texture2DBinding(0)
     72    , m_framebufferBinding(0)
    7273    , m_activeTextureUnit(GraphicsContext3D::TEXTURE0)
    7374    , m_context(context)
  • trunk/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.cpp

    r114935 r114961  
    8787    if (m_drawingBuffer->requiresCopyFromBackToFrontBuffer())
    8888        updater.appendCopy(m_drawingBuffer->colorBuffer(), m_textureId, bounds());
     89
     90    m_drawingBuffer->restoreFramebufferBinding();
    8991}
    9092
  • trunk/Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp

    r114935 r114961  
    337337}
    338338
     339void DrawingBuffer::restoreFramebufferBinding()
     340{
     341    if (!m_context || !m_framebufferBinding)
     342        return;
     343
     344    m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_framebufferBinding);
     345}
     346
    339347bool DrawingBuffer::multisample() const
    340348{
  • trunk/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h

    r114935 r114961  
    100100    // The DrawingBuffer needs to track the texture bound to texture unit 0.
    101101    // The bound texture is tracked to avoid costly queries during rendering.
    102     void setTexture2DBinding(GC3Dint texture) { m_texture2DBinding = texture; }
     102    void setTexture2DBinding(Platform3DObject texture) { m_texture2DBinding = texture; }
     103
     104    // The DrawingBuffer needs to track the currently bound framebuffer so it
     105    // restore the binding when needed.
     106    void setFramebufferBinding(Platform3DObject fbo) { m_framebufferBinding = fbo; }
     107
     108    // Bind to the m_framebufferBinding if it's not 0.
     109    void restoreFramebufferBinding();
    103110
    104111    // Track the currently active texture unit. Texture unit 0 is used as host for a scratch
     
    136143    bool m_scissorEnabled;
    137144    Platform3DObject m_texture2DBinding;
     145    Platform3DObject m_framebufferBinding;
    138146    GC3Denum m_activeTextureUnit;
    139147
  • trunk/Source/WebCore/platform/graphics/gpu/mac/DrawingBufferMac.mm

    r114935 r114961  
    4747    , m_scissorEnabled(false)
    4848    , m_texture2DBinding(0)
     49    , m_framebufferBinding(0)
    4950    , m_activeTextureUnit(GraphicsContext3D::TEXTURE0)
    5051    , m_context(context)
  • trunk/Source/WebCore/platform/graphics/gpu/qt/DrawingBufferQt.cpp

    r114935 r114961  
    4242    , m_scissorEnabled(false)
    4343    , m_texture2DBinding(0)
     44    , m_framebufferBinding(0)
    4445    , m_activeTextureUnit(GraphicsContext3D::TEXTURE0)
    4546    , m_context(context)
Note: See TracChangeset for help on using the changeset viewer.