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