| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 return nullptr; | 97 return nullptr; |
| 98 } | 98 } |
| 99 | 99 |
| 100 OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(context.g
et()); | 100 OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(context.g
et()); |
| 101 if (!extensionsUtil->isValid()) { | 101 if (!extensionsUtil->isValid()) { |
| 102 // This might be the first time we notice that the WebGraphicsContext3D
is lost. | 102 // This might be the first time we notice that the WebGraphicsContext3D
is lost. |
| 103 return nullptr; | 103 return nullptr; |
| 104 } | 104 } |
| 105 ASSERT(extensionsUtil->supportsExtension("GL_OES_packed_depth_stencil")); | 105 ASSERT(extensionsUtil->supportsExtension("GL_OES_packed_depth_stencil")); |
| 106 extensionsUtil->ensureExtensionEnabled("GL_OES_packed_depth_stencil"); | 106 extensionsUtil->ensureExtensionEnabled("GL_OES_packed_depth_stencil"); |
| 107 bool multisampleSupported = (extensionsUtil->supportsExtension("GL_CHROMIUM_
framebuffer_multisample") | 107 |
| 108 SupportedExtensions exts; |
| 109 exts.multisample = (extensionsUtil->supportsExtension("GL_CHROMIUM_framebuff
er_multisample") |
| 108 || extensionsUtil->supportsExtension("GL_EXT_multisampled_render_to_text
ure")) | 110 || extensionsUtil->supportsExtension("GL_EXT_multisampled_render_to_text
ure")) |
| 109 && extensionsUtil->supportsExtension("GL_OES_rgb8_rgba8"); | 111 && extensionsUtil->supportsExtension("GL_OES_rgb8_rgba8"); |
| 110 if (multisampleSupported) { | 112 if (exts.multisample) { |
| 111 extensionsUtil->ensureExtensionEnabled("GL_OES_rgb8_rgba8"); | 113 extensionsUtil->ensureExtensionEnabled("GL_OES_rgb8_rgba8"); |
| 112 if (extensionsUtil->supportsExtension("GL_CHROMIUM_framebuffer_multisamp
le")) | 114 if (extensionsUtil->supportsExtension("GL_CHROMIUM_framebuffer_multisamp
le")) |
| 113 extensionsUtil->ensureExtensionEnabled("GL_CHROMIUM_framebuffer_mult
isample"); | 115 extensionsUtil->ensureExtensionEnabled("GL_CHROMIUM_framebuffer_mult
isample"); |
| 114 else | 116 else |
| 115 extensionsUtil->ensureExtensionEnabled("GL_EXT_multisampled_render_t
o_texture"); | 117 extensionsUtil->ensureExtensionEnabled("GL_EXT_multisampled_render_t
o_texture"); |
| 116 } | 118 } |
| 117 bool discardFramebufferSupported = extensionsUtil->supportsExtension("GL_EXT
_discard_framebuffer"); | 119 exts.packedDepthStencil = true; |
| 118 if (discardFramebufferSupported) | 120 exts.depth24 = extensionsUtil->supportsExtension("GL_OES_depth24"); |
| 121 if (exts.depth24) |
| 122 extensionsUtil->ensureExtensionEnabled("GL_OES_depth24"); |
| 123 exts.discardFramebuffer = extensionsUtil->supportsExtension("GL_EXT_discard_
framebuffer"); |
| 124 if (exts.discardFramebuffer) |
| 119 extensionsUtil->ensureExtensionEnabled("GL_EXT_discard_framebuffer"); | 125 extensionsUtil->ensureExtensionEnabled("GL_EXT_discard_framebuffer"); |
| 120 | 126 |
| 121 RefPtr<DrawingBuffer> drawingBuffer = adoptRef(new DrawingBuffer(std::move(c
ontext), extensionsUtil.release(), multisampleSupported, true, discardFramebuffe
rSupported, preserve, requestedAttributes)); | 127 RefPtr<DrawingBuffer> drawingBuffer = adoptRef(new DrawingBuffer(std::move(c
ontext), extensionsUtil.release(), exts, preserve, requestedAttributes)); |
| 122 if (!drawingBuffer->initialize(size)) { | 128 if (!drawingBuffer->initialize(size)) { |
| 123 drawingBuffer->beginDestruction(); | 129 drawingBuffer->beginDestruction(); |
| 124 return PassRefPtr<DrawingBuffer>(); | 130 return PassRefPtr<DrawingBuffer>(); |
| 125 } | 131 } |
| 126 return drawingBuffer.release(); | 132 return drawingBuffer.release(); |
| 127 } | 133 } |
| 128 | 134 |
| 129 void DrawingBuffer::forceNextDrawingBufferCreationToFail() | 135 void DrawingBuffer::forceNextDrawingBufferCreationToFail() |
| 130 { | 136 { |
| 131 shouldFailDrawingBufferCreationForTesting = true; | 137 shouldFailDrawingBufferCreationForTesting = true; |
| 132 } | 138 } |
| 133 | 139 |
| 140 DrawingBuffer::SupportedExtensions::SupportedExtensions() : |
| 141 multisample(false), packedDepthStencil(false), depth24(false), discardFrameb
uffer(false) {} |
| 142 |
| 134 DrawingBuffer::DrawingBuffer(PassOwnPtr<WebGraphicsContext3D> context, | 143 DrawingBuffer::DrawingBuffer(PassOwnPtr<WebGraphicsContext3D> context, |
| 135 PassOwnPtr<Extensions3DUtil> extensionsUtil, | 144 PassOwnPtr<Extensions3DUtil> extensionsUtil, |
| 136 bool multisampleExtensionSupported, | 145 const SupportedExtensions& supportedExtensions, |
| 137 bool packedDepthStencilExtensionSupported, | |
| 138 bool discardFramebufferSupported, | |
| 139 PreserveDrawingBuffer preserve, | 146 PreserveDrawingBuffer preserve, |
| 140 WebGraphicsContext3D::Attributes requestedAttributes) | 147 WebGraphicsContext3D::Attributes requestedAttributes) |
| 141 : m_preserveDrawingBuffer(preserve) | 148 : m_preserveDrawingBuffer(preserve) |
| 142 , m_scissorEnabled(false) | 149 , m_scissorEnabled(false) |
| 143 , m_texture2DBinding(0) | 150 , m_texture2DBinding(0) |
| 144 , m_drawFramebufferBinding(0) | 151 , m_drawFramebufferBinding(0) |
| 145 , m_readFramebufferBinding(0) | 152 , m_readFramebufferBinding(0) |
| 146 , m_activeTextureUnit(GL_TEXTURE0) | 153 , m_activeTextureUnit(GL_TEXTURE0) |
| 147 , m_context(std::move(context)) | 154 , m_context(std::move(context)) |
| 148 , m_extensionsUtil(std::move(extensionsUtil)) | 155 , m_extensionsUtil(std::move(extensionsUtil)) |
| 149 , m_size(-1, -1) | 156 , m_size(-1, -1) |
| 150 , m_requestedAttributes(requestedAttributes) | 157 , m_requestedAttributes(requestedAttributes) |
| 151 , m_multisampleExtensionSupported(multisampleExtensionSupported) | 158 , m_multisampleExtensionSupported(supportedExtensions.multisample) |
| 152 , m_packedDepthStencilExtensionSupported(packedDepthStencilExtensionSupporte
d) | 159 , m_packedDepthStencilExtensionSupported(supportedExtensions.packedDepthSten
cil) |
| 153 , m_discardFramebufferSupported(discardFramebufferSupported) | 160 , m_depth24ExtensionSupported(supportedExtensions.depth24) |
| 161 , m_discardFramebufferSupported(supportedExtensions.discardFramebuffer) |
| 154 , m_fbo(0) | 162 , m_fbo(0) |
| 155 , m_depthStencilBuffer(0) | 163 , m_depthStencilBuffer(0) |
| 156 , m_depthBuffer(0) | 164 , m_depthBuffer(0) |
| 157 , m_stencilBuffer(0) | 165 , m_stencilBuffer(0) |
| 158 , m_multisampleFBO(0) | 166 , m_multisampleFBO(0) |
| 159 , m_multisampleColorBuffer(0) | 167 , m_multisampleColorBuffer(0) |
| 160 , m_contentsChanged(true) | 168 , m_contentsChanged(true) |
| 161 , m_contentsChangeCommitted(false) | 169 , m_contentsChangeCommitted(false) |
| 162 , m_bufferClearNeeded(false) | 170 , m_bufferClearNeeded(false) |
| 163 , m_antiAliasingMode(None) | 171 , m_antiAliasingMode(None) |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 } | 698 } |
| 691 | 699 |
| 692 return true; | 700 return true; |
| 693 } | 701 } |
| 694 | 702 |
| 695 void DrawingBuffer::resizeDepthStencil(const IntSize& size) | 703 void DrawingBuffer::resizeDepthStencil(const IntSize& size) |
| 696 { | 704 { |
| 697 if (!m_requestedAttributes.depth && !m_requestedAttributes.stencil) | 705 if (!m_requestedAttributes.depth && !m_requestedAttributes.stencil) |
| 698 return; | 706 return; |
| 699 | 707 |
| 700 if (m_packedDepthStencilExtensionSupported) { | 708 if (m_requestedAttributes.depth && !m_requestedAttributes.stencil && m_depth
24ExtensionSupported) { |
| 709 if (!m_depthBuffer) |
| 710 m_depthBuffer = m_context->createRenderbuffer(); |
| 711 m_context->bindRenderbuffer(GL_RENDERBUFFER, m_depthBuffer); |
| 712 if (m_antiAliasingMode == MSAAImplicitResolve) |
| 713 m_context->renderbufferStorageMultisampleEXT(GL_RENDERBUFFER, m_samp
leCount, GL_DEPTH_COMPONENT24, size.width(), size.height()); |
| 714 else if (m_antiAliasingMode == MSAAExplicitResolve) |
| 715 m_context->renderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, m
_sampleCount, GL_DEPTH_COMPONENT24, size.width(), size.height()); |
| 716 else |
| 717 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); |
| 719 } else if (m_packedDepthStencilExtensionSupported) { |
| 701 if (!m_depthStencilBuffer) | 720 if (!m_depthStencilBuffer) |
| 702 m_depthStencilBuffer = m_context->createRenderbuffer(); | 721 m_depthStencilBuffer = m_context->createRenderbuffer(); |
| 703 m_context->bindRenderbuffer(GL_RENDERBUFFER, m_depthStencilBuffer); | 722 m_context->bindRenderbuffer(GL_RENDERBUFFER, m_depthStencilBuffer); |
| 704 if (m_antiAliasingMode == MSAAImplicitResolve) | 723 if (m_antiAliasingMode == MSAAImplicitResolve) |
| 705 m_context->renderbufferStorageMultisampleEXT(GL_RENDERBUFFER, m_samp
leCount, GL_DEPTH24_STENCIL8_OES, size.width(), size.height()); | 724 m_context->renderbufferStorageMultisampleEXT(GL_RENDERBUFFER, m_samp
leCount, GL_DEPTH24_STENCIL8_OES, size.width(), size.height()); |
| 706 else if (m_antiAliasingMode == MSAAExplicitResolve) | 725 else if (m_antiAliasingMode == MSAAExplicitResolve) |
| 707 m_context->renderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, m
_sampleCount, GL_DEPTH24_STENCIL8_OES, size.width(), size.height()); | 726 m_context->renderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, m
_sampleCount, GL_DEPTH24_STENCIL8_OES, size.width(), size.height()); |
| 708 else | 727 else |
| 709 m_context->renderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_
OES, size.width(), size.height()); | 728 m_context->renderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_
OES, size.width(), size.height()); |
| 710 m_context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTA
CHMENT, GL_RENDERBUFFER, m_depthStencilBuffer); | 729 m_context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTA
CHMENT, GL_RENDERBUFFER, m_depthStencilBuffer); |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1066 | 1085 |
| 1067 if (m_antiAliasingMode == MSAAImplicitResolve) | 1086 if (m_antiAliasingMode == MSAAImplicitResolve) |
| 1068 m_context->framebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_A
TTACHMENT0, target, m_colorBuffer.textureId, 0, m_sampleCount); | 1087 m_context->framebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_A
TTACHMENT0, target, m_colorBuffer.textureId, 0, m_sampleCount); |
| 1069 else | 1088 else |
| 1070 m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, ta
rget, m_colorBuffer.textureId, 0); | 1089 m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, ta
rget, m_colorBuffer.textureId, 0); |
| 1071 | 1090 |
| 1072 m_context->bindTexture(GL_TEXTURE_2D, m_texture2DBinding); | 1091 m_context->bindTexture(GL_TEXTURE_2D, m_texture2DBinding); |
| 1073 } | 1092 } |
| 1074 | 1093 |
| 1075 } // namespace blink | 1094 } // namespace blink |
| OLD | NEW |