Chromium Code Reviews| Index: Source/platform/graphics/gpu/DrawingBuffer.cpp |
| diff --git a/Source/platform/graphics/gpu/DrawingBuffer.cpp b/Source/platform/graphics/gpu/DrawingBuffer.cpp |
| index 607a68216facf6a5eb479a95ecc0656f587caf7c..c57a44d7e82e4d2126ed8152c75c69e25a2a4a8f 100644 |
| --- a/Source/platform/graphics/gpu/DrawingBuffer.cpp |
| +++ b/Source/platform/graphics/gpu/DrawingBuffer.cpp |
| @@ -81,24 +81,29 @@ private: |
| PassRefPtr<DrawingBuffer> DrawingBuffer::create(PassOwnPtr<blink::WebGraphicsContext3D> context, const IntSize& size, PreserveDrawingBuffer preserve, PassRefPtr<ContextEvictionManager> contextEvictionManager) |
| { |
| ASSERT(context); |
| - Extensions3DUtil extensionsUtil(context.get()); |
| - bool multisampleSupported = extensionsUtil.supportsExtension("GL_CHROMIUM_framebuffer_multisample") |
| - && extensionsUtil.supportsExtension("GL_OES_rgb8_rgba8"); |
| + OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(context.get()); |
|
bajones
2014/04/23 23:52:52
I wonder if the patch couldn't be made cleaner by:
|
| + if (!extensionsUtil) { |
| + // This might be the first time we notice that the WebGraphicsContext3D is lost. |
| + return nullptr; |
| + } |
| + bool multisampleSupported = extensionsUtil->supportsExtension("GL_CHROMIUM_framebuffer_multisample") |
| + && extensionsUtil->supportsExtension("GL_OES_rgb8_rgba8"); |
| if (multisampleSupported) { |
| - extensionsUtil.ensureExtensionEnabled("GL_CHROMIUM_framebuffer_multisample"); |
| - extensionsUtil.ensureExtensionEnabled("GL_OES_rgb8_rgba8"); |
| + extensionsUtil->ensureExtensionEnabled("GL_CHROMIUM_framebuffer_multisample"); |
| + extensionsUtil->ensureExtensionEnabled("GL_OES_rgb8_rgba8"); |
| } |
| - bool packedDepthStencilSupported = extensionsUtil.supportsExtension("GL_OES_packed_depth_stencil"); |
| + bool packedDepthStencilSupported = extensionsUtil->supportsExtension("GL_OES_packed_depth_stencil"); |
| if (packedDepthStencilSupported) |
| - extensionsUtil.ensureExtensionEnabled("GL_OES_packed_depth_stencil"); |
| + extensionsUtil->ensureExtensionEnabled("GL_OES_packed_depth_stencil"); |
| - RefPtr<DrawingBuffer> drawingBuffer = adoptRef(new DrawingBuffer(context, multisampleSupported, packedDepthStencilSupported, preserve, contextEvictionManager)); |
| + RefPtr<DrawingBuffer> drawingBuffer = adoptRef(new DrawingBuffer(context, extensionsUtil.release(), multisampleSupported, packedDepthStencilSupported, preserve, contextEvictionManager)); |
| if (!drawingBuffer->initialize(size)) |
| return PassRefPtr<DrawingBuffer>(); |
| return drawingBuffer.release(); |
| } |
| DrawingBuffer::DrawingBuffer(PassOwnPtr<blink::WebGraphicsContext3D> context, |
| + PassOwnPtr<Extensions3DUtil> extensionsUtil, |
| bool multisampleExtensionSupported, |
| bool packedDepthStencilExtensionSupported, |
| PreserveDrawingBuffer preserve, |
| @@ -109,6 +114,7 @@ DrawingBuffer::DrawingBuffer(PassOwnPtr<blink::WebGraphicsContext3D> context, |
| , m_framebufferBinding(0) |
| , m_activeTextureUnit(GL_TEXTURE0) |
| , m_context(context) |
| + , m_extensionsUtil(extensionsUtil) |
| , m_size(-1, -1) |
| , m_multisampleExtensionSupported(multisampleExtensionSupported) |
| , m_packedDepthStencilExtensionSupported(packedDepthStencilExtensionSupported) |
| @@ -281,8 +287,13 @@ PassRefPtr<DrawingBuffer::MailboxInfo> DrawingBuffer::createNewMailbox(unsigned |
| bool DrawingBuffer::initialize(const IntSize& size) |
| { |
| + if (!m_context->makeContextCurrent()) { |
| + // The new context is lost; it wasn't allocated successfully. |
| + // Need to try to restore the context again later. |
| + return false; |
| + } |
| + |
| m_attributes = m_context->getContextAttributes(); |
| - Extensions3DUtil extensionsUtil(m_context.get()); |
| if (m_attributes.alpha) { |
| m_internalColorFormat = GL_RGBA; |
| @@ -301,7 +312,7 @@ bool DrawingBuffer::initialize(const IntSize& size) |
| if (m_attributes.antialias && m_multisampleExtensionSupported) { |
| m_context->getIntegerv(GL_MAX_SAMPLES_ANGLE, &maxSampleCount); |
| m_multisampleMode = ExplicitResolve; |
| - if (extensionsUtil.supportsExtension("GL_EXT_multisampled_render_to_texture")) |
| + if (m_extensionsUtil->supportsExtension("GL_EXT_multisampled_render_to_texture")) |
| m_multisampleMode = ImplicitResolve; |
| } |
| m_sampleCount = std::min(4, maxSampleCount); |