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(GLenum target, GLbitfield clearMask) |
Zhenyao Mo
2015/06/04 22:08:17
No need for the target, the original code is corre
yunchao
2015/06/09 10:37:55
Acknowledged.
| |
709 { | 710 { |
711 ASSERT(target == GL_FRAMEBUFFER || target == GL_DRAW_FRAMEBUFFER); | |
710 // We will clear the multisample FBO, but we also need to clear the non-mult isampled buffer. | 712 // We will clear the multisample FBO, but we also need to clear the non-mult isampled buffer. |
711 if (m_multisampleFBO) { | 713 if (m_multisampleFBO) { |
712 m_context->bindFramebuffer(GL_FRAMEBUFFER, m_fbo); | 714 m_context->bindFramebuffer(target, m_fbo); |
713 m_context->clear(GL_COLOR_BUFFER_BIT); | 715 m_context->clear(GL_COLOR_BUFFER_BIT); |
714 } | 716 } |
715 | 717 |
716 m_context->bindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO ? m_multisampleF BO : m_fbo); | 718 m_context->bindFramebuffer(target, m_multisampleFBO ? m_multisampleFBO : m_f bo); |
717 m_context->clear(clearMask); | 719 m_context->clear(clearMask); |
718 } | 720 } |
719 | 721 |
720 void DrawingBuffer::setSize(const IntSize& size) | 722 void DrawingBuffer::setSize(const IntSize& size) |
721 { | 723 { |
722 if (m_size == size) | 724 if (m_size == size) |
723 return; | 725 return; |
724 | 726 |
725 m_size = size; | 727 m_size = size; |
726 } | 728 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
771 m_context->clearDepth(1.0f); | 773 m_context->clearDepth(1.0f); |
772 clearMask |= GL_DEPTH_BUFFER_BIT; | 774 clearMask |= GL_DEPTH_BUFFER_BIT; |
773 m_context->depthMask(true); | 775 m_context->depthMask(true); |
774 } | 776 } |
775 if (m_actualAttributes.stencil) { | 777 if (m_actualAttributes.stencil) { |
776 m_context->clearStencil(0); | 778 m_context->clearStencil(0); |
777 clearMask |= GL_STENCIL_BUFFER_BIT; | 779 clearMask |= GL_STENCIL_BUFFER_BIT; |
778 m_context->stencilMaskSeparate(GL_FRONT, 0xFFFFFFFF); | 780 m_context->stencilMaskSeparate(GL_FRONT, 0xFFFFFFFF); |
779 } | 781 } |
780 | 782 |
781 clearFramebuffers(clearMask); | 783 clearFramebuffers(GL_FRAMEBUFFER, clearMask); |
782 return true; | 784 return true; |
783 } | 785 } |
784 | 786 |
785 void DrawingBuffer::commit() | 787 void DrawingBuffer::commit(GLenum target) |
Zhenyao Mo
2015/06/04 22:08:17
|target| is not needed.
yunchao
2015/06/09 10:37:55
Acknowledged.
| |
786 { | 788 { |
787 if (m_multisampleFBO && !m_contentsChangeCommitted) { | 789 if (m_multisampleFBO && !m_contentsChangeCommitted) { |
788 m_context->bindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, m_multisampleFBO); | 790 m_context->bindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, m_multisampleFBO); |
789 m_context->bindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, m_fbo); | 791 m_context->bindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, m_fbo); |
790 | 792 |
791 if (m_scissorEnabled) | 793 if (m_scissorEnabled) |
792 m_context->disable(GL_SCISSOR_TEST); | 794 m_context->disable(GL_SCISSOR_TEST); |
793 | 795 |
794 int width = m_size.width(); | 796 int width = m_size.width(); |
795 int height = m_size.height(); | 797 int height = m_size.height(); |
796 // Use NEAREST, because there is no scale performed during the blit. | 798 // 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); | 799 m_context->blitFramebufferCHROMIUM(0, 0, width, height, 0, 0, width, hei ght, GL_COLOR_BUFFER_BIT, GL_NEAREST); |
798 | 800 |
799 if (m_scissorEnabled) | 801 if (m_scissorEnabled) |
800 m_context->enable(GL_SCISSOR_TEST); | 802 m_context->enable(GL_SCISSOR_TEST); |
801 } | 803 } |
802 | 804 |
803 m_context->bindFramebuffer(GL_FRAMEBUFFER, m_fbo); | 805 m_context->bindFramebuffer(target, m_fbo); |
Zhenyao Mo
2015/06/04 22:08:17
Instead of calling this directly, you should call
yunchao
2015/06/09 10:37:55
Acknowledged.
| |
804 m_contentsChangeCommitted = true; | 806 m_contentsChangeCommitted = true; |
805 } | 807 } |
806 | 808 |
807 void DrawingBuffer::restoreFramebufferBinding() | 809 void DrawingBuffer::restoreFramebufferBinding(GLenum target) |
Zhenyao Mo
2015/06/04 22:08:17
It should not have a target, but restore both READ
yunchao
2015/06/09 10:37:55
Acknowledged.
| |
808 { | 810 { |
809 if (!m_framebufferBinding) { | 811 if (((target == GL_FRAMEBUFFER || target == GL_DRAW_FRAMEBUFFER) && !m_frame bufferBinding) |
810 bind(); | 812 || (target == GL_READ_FRAMEBUFFER && !m_readFramebufferBinding)) { |
813 bind(target); | |
811 return; | 814 return; |
812 } | 815 } |
813 m_context->bindFramebuffer(GL_FRAMEBUFFER, m_framebufferBinding); | 816 m_context->bindFramebuffer(target, target == GL_READ_FRAMEBUFFER ? m_readFra mebufferBinding : m_framebufferBinding); |
814 } | 817 } |
815 | 818 |
816 bool DrawingBuffer::multisample() const | 819 bool DrawingBuffer::multisample() const |
817 { | 820 { |
818 return m_multisampleMode != None; | 821 return m_multisampleMode != None; |
819 } | 822 } |
820 | 823 |
821 void DrawingBuffer::bind(GLenum target) | 824 void DrawingBuffer::bind(GLenum target) |
822 { | 825 { |
823 m_context->bindFramebuffer(target, m_multisampleFBO ? m_multisampleFBO : m_f bo); | 826 m_context->bindFramebuffer(target, m_multisampleFBO ? m_multisampleFBO : m_f bo); |
Zhenyao Mo
2015/06/04 22:08:17
I think we should get rid of the target in this fu
yunchao
2015/06/09 10:37:54
In WebGL 1.0, there may have both m_multisampleFBO
| |
824 } | 827 } |
825 | 828 |
826 void DrawingBuffer::setPackAlignment(GLint param) | 829 void DrawingBuffer::setPackAlignment(GLint param) |
827 { | 830 { |
828 m_packAlignment = param; | 831 m_packAlignment = param; |
829 } | 832 } |
830 | 833 |
831 void DrawingBuffer::paintRenderingResultsToCanvas(ImageBuffer* imageBuffer) | 834 void DrawingBuffer::paintRenderingResultsToCanvas(ImageBuffer* imageBuffer) |
832 { | 835 { |
833 paintFramebufferToCanvas(framebuffer(), size().width(), size().height(), !m_ actualAttributes.premultipliedAlpha, imageBuffer); | 836 paintFramebufferToCanvas(framebuffer(), size().width(), size().height(), !m_ actualAttributes.premultipliedAlpha, imageBuffer); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
981 void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info) | 984 void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info) |
982 { | 985 { |
983 if (info->imageId) { | 986 if (info->imageId) { |
984 m_context->releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, info->imageId); | 987 m_context->releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, info->imageId); |
985 m_context->destroyImageCHROMIUM(info->imageId); | 988 m_context->destroyImageCHROMIUM(info->imageId); |
986 info->imageId = 0; | 989 info->imageId = 0; |
987 } | 990 } |
988 } | 991 } |
989 | 992 |
990 } // namespace blink | 993 } // namespace blink |
OLD | NEW |