| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 exts.multisample = (extensionsUtil->supportsExtension("GL_CHROMIUM_framebuff
er_multisample") | 109 exts.multisample = (extensionsUtil->supportsExtension("GL_CHROMIUM_framebuff
er_multisample") |
| 110 || extensionsUtil->supportsExtension("GL_EXT_multisampled_render_to_text
ure")) | 110 || extensionsUtil->supportsExtension("GL_EXT_multisampled_render_to_text
ure")) |
| 111 && extensionsUtil->supportsExtension("GL_OES_rgb8_rgba8"); | 111 && extensionsUtil->supportsExtension("GL_OES_rgb8_rgba8"); |
| 112 if (exts.multisample) { | 112 if (exts.multisample) { |
| 113 extensionsUtil->ensureExtensionEnabled("GL_OES_rgb8_rgba8"); | 113 extensionsUtil->ensureExtensionEnabled("GL_OES_rgb8_rgba8"); |
| 114 if (extensionsUtil->supportsExtension("GL_CHROMIUM_framebuffer_multisamp
le")) | 114 if (extensionsUtil->supportsExtension("GL_CHROMIUM_framebuffer_multisamp
le")) |
| 115 extensionsUtil->ensureExtensionEnabled("GL_CHROMIUM_framebuffer_mult
isample"); | 115 extensionsUtil->ensureExtensionEnabled("GL_CHROMIUM_framebuffer_mult
isample"); |
| 116 else | 116 else |
| 117 extensionsUtil->ensureExtensionEnabled("GL_EXT_multisampled_render_t
o_texture"); | 117 extensionsUtil->ensureExtensionEnabled("GL_EXT_multisampled_render_t
o_texture"); |
| 118 } | 118 } |
| 119 exts.packedDepthStencil = true; | |
| 120 exts.depth24 = extensionsUtil->supportsExtension("GL_OES_depth24"); | 119 exts.depth24 = extensionsUtil->supportsExtension("GL_OES_depth24"); |
| 121 if (exts.depth24) | 120 if (exts.depth24) |
| 122 extensionsUtil->ensureExtensionEnabled("GL_OES_depth24"); | 121 extensionsUtil->ensureExtensionEnabled("GL_OES_depth24"); |
| 123 exts.discardFramebuffer = extensionsUtil->supportsExtension("GL_EXT_discard_
framebuffer"); | 122 exts.discardFramebuffer = extensionsUtil->supportsExtension("GL_EXT_discard_
framebuffer"); |
| 124 if (exts.discardFramebuffer) | 123 if (exts.discardFramebuffer) |
| 125 extensionsUtil->ensureExtensionEnabled("GL_EXT_discard_framebuffer"); | 124 extensionsUtil->ensureExtensionEnabled("GL_EXT_discard_framebuffer"); |
| 126 | 125 |
| 127 RefPtr<DrawingBuffer> drawingBuffer = adoptRef(new DrawingBuffer(std::move(c
ontext), extensionsUtil.release(), exts, preserve, requestedAttributes)); | 126 RefPtr<DrawingBuffer> drawingBuffer = adoptRef(new DrawingBuffer(std::move(c
ontext), extensionsUtil.release(), exts, preserve, requestedAttributes)); |
| 128 if (!drawingBuffer->initialize(size)) { | 127 if (!drawingBuffer->initialize(size)) { |
| 129 drawingBuffer->beginDestruction(); | 128 drawingBuffer->beginDestruction(); |
| 130 return PassRefPtr<DrawingBuffer>(); | 129 return PassRefPtr<DrawingBuffer>(); |
| 131 } | 130 } |
| 132 return drawingBuffer.release(); | 131 return drawingBuffer.release(); |
| 133 } | 132 } |
| 134 | 133 |
| 135 void DrawingBuffer::forceNextDrawingBufferCreationToFail() | 134 void DrawingBuffer::forceNextDrawingBufferCreationToFail() |
| 136 { | 135 { |
| 137 shouldFailDrawingBufferCreationForTesting = true; | 136 shouldFailDrawingBufferCreationForTesting = true; |
| 138 } | 137 } |
| 139 | 138 |
| 140 DrawingBuffer::SupportedExtensions::SupportedExtensions() : | 139 DrawingBuffer::SupportedExtensions::SupportedExtensions() : |
| 141 multisample(false), packedDepthStencil(false), depth24(false), discardFrameb
uffer(false) {} | 140 multisample(false), depth24(false), discardFramebuffer(false) {} |
| 142 | 141 |
| 143 DrawingBuffer::DrawingBuffer(PassOwnPtr<WebGraphicsContext3D> context, | 142 DrawingBuffer::DrawingBuffer(PassOwnPtr<WebGraphicsContext3D> context, |
| 144 PassOwnPtr<Extensions3DUtil> extensionsUtil, | 143 PassOwnPtr<Extensions3DUtil> extensionsUtil, |
| 145 const SupportedExtensions& supportedExtensions, | 144 const SupportedExtensions& supportedExtensions, |
| 146 PreserveDrawingBuffer preserve, | 145 PreserveDrawingBuffer preserve, |
| 147 WebGraphicsContext3D::Attributes requestedAttributes) | 146 WebGraphicsContext3D::Attributes requestedAttributes) |
| 148 : m_preserveDrawingBuffer(preserve) | 147 : m_preserveDrawingBuffer(preserve) |
| 149 , m_scissorEnabled(false) | 148 , m_scissorEnabled(false) |
| 150 , m_texture2DBinding(0) | 149 , m_texture2DBinding(0) |
| 151 , m_drawFramebufferBinding(0) | 150 , m_drawFramebufferBinding(0) |
| 152 , m_readFramebufferBinding(0) | 151 , m_readFramebufferBinding(0) |
| 153 , m_activeTextureUnit(GL_TEXTURE0) | 152 , m_activeTextureUnit(GL_TEXTURE0) |
| 154 , m_context(std::move(context)) | 153 , m_context(std::move(context)) |
| 155 , m_extensionsUtil(std::move(extensionsUtil)) | 154 , m_extensionsUtil(std::move(extensionsUtil)) |
| 156 , m_size(-1, -1) | 155 , m_size(-1, -1) |
| 157 , m_requestedAttributes(requestedAttributes) | 156 , m_requestedAttributes(requestedAttributes) |
| 158 , m_multisampleExtensionSupported(supportedExtensions.multisample) | 157 , m_multisampleExtensionSupported(supportedExtensions.multisample) |
| 159 , m_packedDepthStencilExtensionSupported(supportedExtensions.packedDepthSten
cil) | |
| 160 , m_depth24ExtensionSupported(supportedExtensions.depth24) | 158 , m_depth24ExtensionSupported(supportedExtensions.depth24) |
| 161 , m_discardFramebufferSupported(supportedExtensions.discardFramebuffer) | 159 , m_discardFramebufferSupported(supportedExtensions.discardFramebuffer) |
| 162 , m_fbo(0) | 160 , m_fbo(0) |
| 163 , m_depthStencilBuffer(0) | 161 , m_depthStencilBuffer(0) |
| 164 , m_depthBuffer(0) | 162 , m_depthBuffer(0) |
| 165 , m_stencilBuffer(0) | |
| 166 , m_multisampleFBO(0) | 163 , m_multisampleFBO(0) |
| 167 , m_multisampleColorBuffer(0) | 164 , m_multisampleColorBuffer(0) |
| 168 , m_contentsChanged(true) | 165 , m_contentsChanged(true) |
| 169 , m_contentsChangeCommitted(false) | 166 , m_contentsChangeCommitted(false) |
| 170 , m_bufferClearNeeded(false) | 167 , m_bufferClearNeeded(false) |
| 171 , m_antiAliasingMode(None) | 168 , m_antiAliasingMode(None) |
| 172 , m_maxTextureSize(0) | 169 , m_maxTextureSize(0) |
| 173 , m_sampleCount(0) | 170 , m_sampleCount(0) |
| 174 , m_packAlignment(4) | 171 , m_packAlignment(4) |
| 175 , m_destructionInProgress(false) | 172 , m_destructionInProgress(false) |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 | 611 |
| 615 if (m_multisampleColorBuffer) | 612 if (m_multisampleColorBuffer) |
| 616 m_context->deleteRenderbuffer(m_multisampleColorBuffer); | 613 m_context->deleteRenderbuffer(m_multisampleColorBuffer); |
| 617 | 614 |
| 618 if (m_depthStencilBuffer) | 615 if (m_depthStencilBuffer) |
| 619 m_context->deleteRenderbuffer(m_depthStencilBuffer); | 616 m_context->deleteRenderbuffer(m_depthStencilBuffer); |
| 620 | 617 |
| 621 if (m_depthBuffer) | 618 if (m_depthBuffer) |
| 622 m_context->deleteRenderbuffer(m_depthBuffer); | 619 m_context->deleteRenderbuffer(m_depthBuffer); |
| 623 | 620 |
| 624 if (m_stencilBuffer) | |
| 625 m_context->deleteRenderbuffer(m_stencilBuffer); | |
| 626 | |
| 627 if (m_colorBuffer.textureId) { | 621 if (m_colorBuffer.textureId) { |
| 628 deleteChromiumImageForTexture(&m_colorBuffer); | 622 deleteChromiumImageForTexture(&m_colorBuffer); |
| 629 m_context->deleteTexture(m_colorBuffer.textureId); | 623 m_context->deleteTexture(m_colorBuffer.textureId); |
| 630 } | 624 } |
| 631 | 625 |
| 632 setSize(IntSize()); | 626 setSize(IntSize()); |
| 633 | 627 |
| 634 m_colorBuffer = TextureInfo(); | 628 m_colorBuffer = TextureInfo(); |
| 635 m_frontColorBuffer = FrontBufferInfo(); | 629 m_frontColorBuffer = FrontBufferInfo(); |
| 636 m_multisampleColorBuffer = 0; | 630 m_multisampleColorBuffer = 0; |
| 637 m_depthStencilBuffer = 0; | 631 m_depthStencilBuffer = 0; |
| 638 m_depthBuffer = 0; | 632 m_depthBuffer = 0; |
| 639 m_stencilBuffer = 0; | |
| 640 m_multisampleFBO = 0; | 633 m_multisampleFBO = 0; |
| 641 m_fbo = 0; | 634 m_fbo = 0; |
| 642 | 635 |
| 643 if (m_layer) | 636 if (m_layer) |
| 644 GraphicsLayer::unregisterContentsLayer(m_layer->layer()); | 637 GraphicsLayer::unregisterContentsLayer(m_layer->layer()); |
| 645 } | 638 } |
| 646 | 639 |
| 647 WebGLId DrawingBuffer::createColorTexture(const TextureParameters& parameters) | 640 WebGLId DrawingBuffer::createColorTexture(const TextureParameters& parameters) |
| 648 { | 641 { |
| 649 WebGLId offscreenColorTexture = m_context->createTexture(); | 642 WebGLId offscreenColorTexture = m_context->createTexture(); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 if (!m_depthBuffer) | 702 if (!m_depthBuffer) |
| 710 m_depthBuffer = m_context->createRenderbuffer(); | 703 m_depthBuffer = m_context->createRenderbuffer(); |
| 711 m_context->bindRenderbuffer(GL_RENDERBUFFER, m_depthBuffer); | 704 m_context->bindRenderbuffer(GL_RENDERBUFFER, m_depthBuffer); |
| 712 if (m_antiAliasingMode == MSAAImplicitResolve) | 705 if (m_antiAliasingMode == MSAAImplicitResolve) |
| 713 m_context->renderbufferStorageMultisampleEXT(GL_RENDERBUFFER, m_samp
leCount, GL_DEPTH_COMPONENT24, size.width(), size.height()); | 706 m_context->renderbufferStorageMultisampleEXT(GL_RENDERBUFFER, m_samp
leCount, GL_DEPTH_COMPONENT24, size.width(), size.height()); |
| 714 else if (m_antiAliasingMode == MSAAExplicitResolve) | 707 else if (m_antiAliasingMode == MSAAExplicitResolve) |
| 715 m_context->renderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, m
_sampleCount, GL_DEPTH_COMPONENT24, size.width(), size.height()); | 708 m_context->renderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, m
_sampleCount, GL_DEPTH_COMPONENT24, size.width(), size.height()); |
| 716 else | 709 else |
| 717 m_context->renderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24
, size.width(), size.height()); | 710 m_context->renderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24
, size.width(), size.height()); |
| 718 m_context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
GL_RENDERBUFFER, m_depthBuffer); | 711 m_context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
GL_RENDERBUFFER, m_depthBuffer); |
| 719 } else if (m_packedDepthStencilExtensionSupported) { | 712 } else { |
| 720 if (!m_depthStencilBuffer) | 713 if (!m_depthStencilBuffer) |
| 721 m_depthStencilBuffer = m_context->createRenderbuffer(); | 714 m_depthStencilBuffer = m_context->createRenderbuffer(); |
| 722 m_context->bindRenderbuffer(GL_RENDERBUFFER, m_depthStencilBuffer); | 715 m_context->bindRenderbuffer(GL_RENDERBUFFER, m_depthStencilBuffer); |
| 723 if (m_antiAliasingMode == MSAAImplicitResolve) | 716 if (m_antiAliasingMode == MSAAImplicitResolve) |
| 724 m_context->renderbufferStorageMultisampleEXT(GL_RENDERBUFFER, m_samp
leCount, GL_DEPTH24_STENCIL8_OES, size.width(), size.height()); | 717 m_context->renderbufferStorageMultisampleEXT(GL_RENDERBUFFER, m_samp
leCount, GL_DEPTH24_STENCIL8_OES, size.width(), size.height()); |
| 725 else if (m_antiAliasingMode == MSAAExplicitResolve) | 718 else if (m_antiAliasingMode == MSAAExplicitResolve) |
| 726 m_context->renderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, m
_sampleCount, GL_DEPTH24_STENCIL8_OES, size.width(), size.height()); | 719 m_context->renderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, m
_sampleCount, GL_DEPTH24_STENCIL8_OES, size.width(), size.height()); |
| 727 else | 720 else |
| 728 m_context->renderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_
OES, size.width(), size.height()); | 721 m_context->renderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_
OES, size.width(), size.height()); |
| 729 m_context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTA
CHMENT, GL_RENDERBUFFER, m_depthStencilBuffer); | 722 m_context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTA
CHMENT, GL_RENDERBUFFER, m_depthStencilBuffer); |
| 730 } else { | |
| 731 if (m_requestedAttributes.depth) { | |
| 732 if (!m_depthBuffer) | |
| 733 m_depthBuffer = m_context->createRenderbuffer(); | |
| 734 m_context->bindRenderbuffer(GL_RENDERBUFFER, m_depthBuffer); | |
| 735 if (m_antiAliasingMode == MSAAImplicitResolve) | |
| 736 m_context->renderbufferStorageMultisampleEXT(GL_RENDERBUFFER, m_
sampleCount, GL_DEPTH_COMPONENT16, size.width(), size.height()); | |
| 737 else if (m_antiAliasingMode == MSAAExplicitResolve) | |
| 738 m_context->renderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFE
R, m_sampleCount, GL_DEPTH_COMPONENT16, size.width(), size.height()); | |
| 739 else | |
| 740 m_context->renderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONE
NT16, size.width(), size.height()); | |
| 741 m_context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHME
NT, GL_RENDERBUFFER, m_depthBuffer); | |
| 742 } | |
| 743 if (m_requestedAttributes.stencil) { | |
| 744 if (!m_stencilBuffer) | |
| 745 m_stencilBuffer = m_context->createRenderbuffer(); | |
| 746 m_context->bindRenderbuffer(GL_RENDERBUFFER, m_stencilBuffer); | |
| 747 if (m_antiAliasingMode == MSAAImplicitResolve) | |
| 748 m_context->renderbufferStorageMultisampleEXT(GL_RENDERBUFFER, m_
sampleCount, GL_STENCIL_INDEX8, size.width(), size.height()); | |
| 749 else if (m_antiAliasingMode == MSAAExplicitResolve) | |
| 750 m_context->renderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFE
R, m_sampleCount, GL_STENCIL_INDEX8, size.width(), size.height()); | |
| 751 else | |
| 752 m_context->renderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX
8, size.width(), size.height()); | |
| 753 m_context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACH
MENT, GL_RENDERBUFFER, m_stencilBuffer); | |
| 754 } | |
| 755 } | 723 } |
| 756 m_context->bindRenderbuffer(GL_RENDERBUFFER, 0); | 724 m_context->bindRenderbuffer(GL_RENDERBUFFER, 0); |
| 757 } | 725 } |
| 758 | 726 |
| 759 | 727 |
| 760 | 728 |
| 761 void DrawingBuffer::clearFramebuffers(GLbitfield clearMask) | 729 void DrawingBuffer::clearFramebuffers(GLbitfield clearMask) |
| 762 { | 730 { |
| 763 // We will clear the multisample FBO, but we also need to clear the non-mult
isampled buffer. | 731 // We will clear the multisample FBO, but we also need to clear the non-mult
isampled buffer. |
| 764 if (m_multisampleFBO) { | 732 if (m_multisampleFBO) { |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1085 | 1053 |
| 1086 if (m_antiAliasingMode == MSAAImplicitResolve) | 1054 if (m_antiAliasingMode == MSAAImplicitResolve) |
| 1087 m_context->framebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_A
TTACHMENT0, target, m_colorBuffer.textureId, 0, m_sampleCount); | 1055 m_context->framebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_A
TTACHMENT0, target, m_colorBuffer.textureId, 0, m_sampleCount); |
| 1088 else | 1056 else |
| 1089 m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, ta
rget, m_colorBuffer.textureId, 0); | 1057 m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, ta
rget, m_colorBuffer.textureId, 0); |
| 1090 | 1058 |
| 1091 m_context->bindTexture(GL_TEXTURE_2D, m_texture2DBinding); | 1059 m_context->bindTexture(GL_TEXTURE_2D, m_texture2DBinding); |
| 1092 } | 1060 } |
| 1093 | 1061 |
| 1094 } // namespace blink | 1062 } // namespace blink |
| OLD | NEW |