Chromium Code Reviews| Index: Source/platform/graphics/gpu/DrawingBuffer.cpp |
| diff --git a/Source/platform/graphics/gpu/DrawingBuffer.cpp b/Source/platform/graphics/gpu/DrawingBuffer.cpp |
| index 1bbb20f2f48e21180c2a388fe0454f698b65b334..3ae504c078b8d030eb210f5a6ec5a51e602b6db6 100644 |
| --- a/Source/platform/graphics/gpu/DrawingBuffer.cpp |
| +++ b/Source/platform/graphics/gpu/DrawingBuffer.cpp |
| @@ -135,7 +135,8 @@ DrawingBuffer::DrawingBuffer(PassOwnPtr<WebGraphicsContext3D> context, |
| : m_preserveDrawingBuffer(preserve) |
| , m_scissorEnabled(false) |
| , m_texture2DBinding(0) |
| - , m_framebufferBinding(0) |
| + , m_drawFramebufferBinding(0) |
| + , m_readFramebufferBinding(0) |
| , m_activeTextureUnit(GL_TEXTURE0) |
| , m_context(context) |
| , m_extensionsUtil(extensionsUtil) |
| @@ -249,7 +250,7 @@ bool DrawingBuffer::prepareMailbox(WebExternalTextureMailbox* outMailbox, WebExt |
| // Resolve the multisampled buffer into m_colorBuffer texture. |
| if (m_multisampleMode != None) |
| - commit(); |
| + commit(GL_FRAMEBUFFER); |
| if (bitmap) { |
| bitmap->setSize(size()); |
| @@ -301,7 +302,7 @@ bool DrawingBuffer::prepareMailbox(WebExternalTextureMailbox* outMailbox, WebExt |
| m_context->copyTextureCHROMIUM(GL_TEXTURE_2D, m_colorBuffer.textureId, frontColorBufferMailbox->textureInfo.textureId, GL_RGBA, GL_UNSIGNED_BYTE); |
| } |
| - restoreFramebufferBinding(); |
| + restoreFramebufferBindings(); |
| m_contentsChanged = false; |
| m_context->produceTextureDirectCHROMIUM(frontColorBufferMailbox->textureInfo.textureId, GL_TEXTURE_2D, frontColorBufferMailbox->mailbox.name); |
| @@ -476,8 +477,8 @@ bool DrawingBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, Platfor |
| { |
| if (m_contentsChanged) { |
| if (m_multisampleMode != None) { |
| - commit(); |
| - restoreFramebufferBinding(); |
| + commit(GL_FRAMEBUFFER); |
| + restoreFramebufferBindings(); |
| } |
| m_context->flush(); |
| } |
| @@ -795,7 +796,7 @@ bool DrawingBuffer::reset(const IntSize& newSize) |
| return true; |
| } |
| -void DrawingBuffer::commit() |
| +void DrawingBuffer::commit(GLenum target) |
| { |
| if (m_multisampleFBO && !m_contentsChangeCommitted) { |
| m_context->bindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, m_multisampleFBO); |
| @@ -813,17 +814,32 @@ void DrawingBuffer::commit() |
| m_context->enable(GL_SCISSOR_TEST); |
| } |
| - m_context->bindFramebuffer(GL_FRAMEBUFFER, m_fbo); |
| + m_context->bindFramebuffer(target, m_fbo); |
|
yunchao
2015/06/10 09:42:30
WebGL conformance tests show that this code snippe
|
| m_contentsChangeCommitted = true; |
| } |
| -void DrawingBuffer::restoreFramebufferBinding() |
| +void DrawingBuffer::restoreFramebufferBindings() |
| { |
| - if (!m_framebufferBinding) { |
| - bind(); |
| + if (m_drawFramebufferBinding && m_readFramebufferBinding) { |
| + if (m_drawFramebufferBinding == m_readFramebufferBinding) { |
| + m_context->bindFramebuffer(GL_FRAMEBUFFER, m_readFramebufferBinding); |
| + } else { |
| + m_context->bindFramebuffer(GL_READ_FRAMEBUFFER, m_readFramebufferBinding); |
| + m_context->bindFramebuffer(GL_DRAW_FRAMEBUFFER, m_drawFramebufferBinding); |
| + } |
| + return; |
| + } |
| + if (!m_drawFramebufferBinding && !m_readFramebufferBinding) { |
| + bind(GL_FRAMEBUFFER); |
| return; |
| } |
| - m_context->bindFramebuffer(GL_FRAMEBUFFER, m_framebufferBinding); |
| + if (!m_drawFramebufferBinding) { |
| + bind(GL_DRAW_FRAMEBUFFER); |
| + m_context->bindFramebuffer(GL_READ_FRAMEBUFFER, m_readFramebufferBinding); |
| + } else { |
| + bind(GL_READ_FRAMEBUFFER); |
| + m_context->bindFramebuffer(GL_DRAW_FRAMEBUFFER, m_drawFramebufferBinding); |
| + } |
| } |
| bool DrawingBuffer::multisample() const |
| @@ -833,7 +849,10 @@ bool DrawingBuffer::multisample() const |
| void DrawingBuffer::bind(GLenum target) |
| { |
| - m_context->bindFramebuffer(target, m_multisampleFBO ? m_multisampleFBO : m_fbo); |
| + if (target != GL_READ_FRAMEBUFFER) |
| + m_context->bindFramebuffer(target, m_multisampleFBO ? m_multisampleFBO : m_fbo); |
| + else |
| + m_context->bindFramebuffer(target, m_fbo); |
| } |
| void DrawingBuffer::setPackAlignment(GLint param) |
| @@ -877,7 +896,7 @@ bool DrawingBuffer::paintRenderingResultsToImageData(int& width, int& height, So |
| m_context->deleteFramebuffer(fbo); |
| } |
| - restoreFramebufferBinding(); |
| + restoreFramebufferBindings(); |
| pixels.transfer(contents); |
| return true; |