Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010, Google Inc. All rights reserved. | 2 * Copyright (c) 2010, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 PassOwnPtr<Extensions3DUtil> extensionsUtil, | 116 PassOwnPtr<Extensions3DUtil> extensionsUtil, |
| 117 bool multisampleExtensionSupported, | 117 bool multisampleExtensionSupported, |
| 118 bool packedDepthStencilExtensionSupported, | 118 bool packedDepthStencilExtensionSupported, |
| 119 bool discardFramebufferSupported, | 119 bool discardFramebufferSupported, |
| 120 PreserveDrawingBuffer preserve, | 120 PreserveDrawingBuffer preserve, |
| 121 WebGraphicsContext3D::Attributes requestedAttributes) | 121 WebGraphicsContext3D::Attributes requestedAttributes) |
| 122 : m_preserveDrawingBuffer(preserve) | 122 : m_preserveDrawingBuffer(preserve) |
| 123 , m_scissorEnabled(false) | 123 , m_scissorEnabled(false) |
| 124 , m_texture2DBinding(0) | 124 , m_texture2DBinding(0) |
| 125 , m_framebufferBinding(0) | 125 , m_framebufferBinding(0) |
| 126 , m_readFramebufferBinding(0) | |
| 126 , m_activeTextureUnit(GL_TEXTURE0) | 127 , m_activeTextureUnit(GL_TEXTURE0) |
| 127 , m_context(context) | 128 , m_context(context) |
| 128 , m_extensionsUtil(extensionsUtil) | 129 , m_extensionsUtil(extensionsUtil) |
| 129 , m_size(-1, -1) | 130 , m_size(-1, -1) |
| 130 , m_requestedAttributes(requestedAttributes) | 131 , m_requestedAttributes(requestedAttributes) |
| 131 , m_multisampleExtensionSupported(multisampleExtensionSupported) | 132 , m_multisampleExtensionSupported(multisampleExtensionSupported) |
| 132 , m_packedDepthStencilExtensionSupported(packedDepthStencilExtensionSupporte d) | 133 , m_packedDepthStencilExtensionSupported(packedDepthStencilExtensionSupporte d) |
| 133 , m_discardFramebufferSupported(discardFramebufferSupported) | 134 , m_discardFramebufferSupported(discardFramebufferSupported) |
| 134 , m_fbo(0) | 135 , m_fbo(0) |
| 135 , m_depthStencilBuffer(0) | 136 , m_depthStencilBuffer(0) |
| (...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 698 else | 699 else |
| 699 m_context->renderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX 8, size.width(), size.height()); | 700 m_context->renderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX 8, size.width(), size.height()); |
| 700 m_context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACH MENT, GL_RENDERBUFFER, m_stencilBuffer); | 701 m_context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACH MENT, GL_RENDERBUFFER, m_stencilBuffer); |
| 701 } | 702 } |
| 702 } | 703 } |
| 703 m_context->bindRenderbuffer(GL_RENDERBUFFER, 0); | 704 m_context->bindRenderbuffer(GL_RENDERBUFFER, 0); |
| 704 } | 705 } |
| 705 | 706 |
| 706 | 707 |
| 707 | 708 |
| 708 void DrawingBuffer::clearFramebuffers(GLbitfield clearMask) | 709 void DrawingBuffer::clearFramebuffers(GLbitfield clearMask, GLenum target) |
| 709 { | 710 { |
| 710 // We will clear the multisample FBO, but we also need to clear the non-mult isampled buffer. | 711 // We will clear the multisample FBO, but we also need to clear the non-mult isampled buffer. |
| 711 if (m_multisampleFBO) { | 712 if (m_multisampleFBO) { |
| 712 m_context->bindFramebuffer(GL_FRAMEBUFFER, m_fbo); | 713 m_context->bindFramebuffer(target, m_fbo); |
|
Ken Russell (switch to Gerrit)
2015/05/06 21:17:33
Let's add an ASSERT that target == GL_FRAMEBUFFER
yunchao
2015/05/22 09:54:35
Done.
| |
| 713 m_context->clear(GL_COLOR_BUFFER_BIT); | 714 m_context->clear(GL_COLOR_BUFFER_BIT); |
| 714 } | 715 } |
| 715 | 716 |
| 716 m_context->bindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO ? m_multisampleF BO : m_fbo); | 717 m_context->bindFramebuffer(target, m_multisampleFBO ? m_multisampleFBO : m_f bo); |
| 717 m_context->clear(clearMask); | 718 m_context->clear(clearMask); |
| 718 } | 719 } |
| 719 | 720 |
| 720 void DrawingBuffer::setSize(const IntSize& size) | 721 void DrawingBuffer::setSize(const IntSize& size) |
| 721 { | 722 { |
| 722 if (m_size == size) | 723 if (m_size == size) |
| 723 return; | 724 return; |
| 724 | 725 |
| 725 m_size = size; | 726 m_size = size; |
| 726 } | 727 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 775 if (m_actualAttributes.stencil) { | 776 if (m_actualAttributes.stencil) { |
| 776 m_context->clearStencil(0); | 777 m_context->clearStencil(0); |
| 777 clearMask |= GL_STENCIL_BUFFER_BIT; | 778 clearMask |= GL_STENCIL_BUFFER_BIT; |
| 778 m_context->stencilMaskSeparate(GL_FRONT, 0xFFFFFFFF); | 779 m_context->stencilMaskSeparate(GL_FRONT, 0xFFFFFFFF); |
| 779 } | 780 } |
| 780 | 781 |
| 781 clearFramebuffers(clearMask); | 782 clearFramebuffers(clearMask); |
| 782 return true; | 783 return true; |
| 783 } | 784 } |
| 784 | 785 |
| 785 void DrawingBuffer::commit() | 786 void DrawingBuffer::commit(GLenum target) |
| 786 { | 787 { |
| 787 if (m_multisampleFBO && !m_contentsChangeCommitted) { | 788 if (m_multisampleFBO && !m_contentsChangeCommitted) { |
| 788 m_context->bindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, m_multisampleFBO); | 789 m_context->bindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, m_multisampleFBO); |
| 789 m_context->bindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, m_fbo); | 790 m_context->bindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, m_fbo); |
| 790 | 791 |
| 791 if (m_scissorEnabled) | 792 if (m_scissorEnabled) |
| 792 m_context->disable(GL_SCISSOR_TEST); | 793 m_context->disable(GL_SCISSOR_TEST); |
| 793 | 794 |
| 794 int width = m_size.width(); | 795 int width = m_size.width(); |
| 795 int height = m_size.height(); | 796 int height = m_size.height(); |
| 796 // Use NEAREST, because there is no scale performed during the blit. | 797 // Use NEAREST, because there is no scale performed during the blit. |
| 797 m_context->blitFramebufferCHROMIUM(0, 0, width, height, 0, 0, width, hei ght, GL_COLOR_BUFFER_BIT, GL_NEAREST); | 798 m_context->blitFramebufferCHROMIUM(0, 0, width, height, 0, 0, width, hei ght, GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 798 | 799 |
| 799 if (m_scissorEnabled) | 800 if (m_scissorEnabled) |
| 800 m_context->enable(GL_SCISSOR_TEST); | 801 m_context->enable(GL_SCISSOR_TEST); |
| 801 } | 802 } |
| 802 | 803 |
| 803 m_context->bindFramebuffer(GL_FRAMEBUFFER, m_fbo); | 804 m_context->bindFramebuffer(target, m_fbo); |
| 804 m_contentsChangeCommitted = true; | 805 m_contentsChangeCommitted = true; |
| 805 } | 806 } |
| 806 | 807 |
| 807 void DrawingBuffer::restoreFramebufferBinding() | 808 void DrawingBuffer::restoreFramebufferBinding(GLenum target) |
| 808 { | 809 { |
| 809 if (!m_framebufferBinding) { | 810 if (((target == GL_FRAMEBUFFER || target == GL_DRAW_FRAMEBUFFER) && !m_frame bufferBinding) |
| 810 bind(); | 811 || (target == GL_READ_FRAMEBUFFER && !m_readFramebufferBinding)) { |
| 812 bind(target); | |
| 811 return; | 813 return; |
| 812 } | 814 } |
| 813 m_context->bindFramebuffer(GL_FRAMEBUFFER, m_framebufferBinding); | 815 m_context->bindFramebuffer(target, target == GL_READ_FRAMEBUFFER ? m_readFra mebufferBinding : m_framebufferBinding); |
| 814 } | 816 } |
| 815 | 817 |
| 816 bool DrawingBuffer::multisample() const | 818 bool DrawingBuffer::multisample() const |
| 817 { | 819 { |
| 818 return m_multisampleMode != None; | 820 return m_multisampleMode != None; |
| 819 } | 821 } |
| 820 | 822 |
| 821 void DrawingBuffer::bind(GLenum target) | 823 void DrawingBuffer::bind(GLenum target) |
| 822 { | 824 { |
| 823 m_context->bindFramebuffer(target, m_multisampleFBO ? m_multisampleFBO : m_f bo); | 825 m_context->bindFramebuffer(target, m_multisampleFBO ? m_multisampleFBO : m_f bo); |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 981 void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info) | 983 void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info) |
| 982 { | 984 { |
| 983 if (info->imageId) { | 985 if (info->imageId) { |
| 984 m_context->releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, info->imageId); | 986 m_context->releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, info->imageId); |
| 985 m_context->destroyImageCHROMIUM(info->imageId); | 987 m_context->destroyImageCHROMIUM(info->imageId); |
| 986 info->imageId = 0; | 988 info->imageId = 0; |
| 987 } | 989 } |
| 988 } | 990 } |
| 989 | 991 |
| 990 } // namespace blink | 992 } // namespace blink |
| OLD | NEW |