Chromium Code Reviews| Index: Source/core/html/canvas/WebGLRenderingContextBase.cpp |
| diff --git a/Source/core/html/canvas/WebGLRenderingContextBase.cpp b/Source/core/html/canvas/WebGLRenderingContextBase.cpp |
| index 71e6f1022aec0114bced0f9d3fee4b4e4a32b73b..700485f902ca552a852dbe746d514871d89ea99d 100644 |
| --- a/Source/core/html/canvas/WebGLRenderingContextBase.cpp |
| +++ b/Source/core/html/canvas/WebGLRenderingContextBase.cpp |
| @@ -5339,6 +5339,21 @@ void WebGLRenderingContextBase::maybeRestoreContext(Timer<WebGLRenderingContextB |
| blink::WebGraphicsContext3D::Attributes attributes = m_requestedAttributes->attributes(canvas()->document().topDocument().url().string(), settings); |
| OwnPtr<blink::WebGraphicsContext3D> context = adoptPtr(blink::Platform::current()->createOffscreenGraphicsContext3D(attributes)); |
| + RefPtr<DrawingBuffer> drawingBuffer; |
| + if (context) { |
| + // If the context was lost due to RealLostContext, we need to release FBOs before creating new DrawingBuffer to ensure resource budget enough. |
| + m_drawingBuffer->releaseResources(); |
| + RefPtr<WebGLRenderingContextEvictionManager> contextEvictionManager = adoptRef(new WebGLRenderingContextEvictionManager()); |
| + |
| + // Construct a new drawing buffer with the new WebGraphicsContext3D. |
| + DrawingBuffer::PreserveDrawingBuffer preserve = m_requestedAttributes->preserveDrawingBuffer() ? DrawingBuffer::Preserve : DrawingBuffer::Discard; |
| + drawingBuffer = DrawingBuffer::create(context.get(), clampedCanvasSize(), preserve, contextEvictionManager.release()); |
| + |
| + if (drawingBuffer->isZeroSized()) { |
| + drawingBuffer.clear(); |
| + context.clear(); |
| + } |
| + } |
| if (!context) { |
| if (m_contextLostMode == RealLostContext) { |
| m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts, FROM_HERE); |
| @@ -5349,16 +5364,7 @@ void WebGLRenderingContextBase::maybeRestoreContext(Timer<WebGLRenderingContextB |
| return; |
| } |
| - RefPtr<WebGLRenderingContextEvictionManager> contextEvictionManager = adoptRef(new WebGLRenderingContextEvictionManager()); |
| - |
| - // Construct a new drawing buffer with the new WebGraphicsContext3D. |
| - m_drawingBuffer->releaseResources(); |
| - DrawingBuffer::PreserveDrawingBuffer preserve = m_requestedAttributes->preserveDrawingBuffer() ? DrawingBuffer::Preserve : DrawingBuffer::Discard; |
| - m_drawingBuffer = DrawingBuffer::create(context.get(), clampedCanvasSize(), preserve, contextEvictionManager.release()); |
| - |
| - if (m_drawingBuffer->isZeroSized()) |
| - return; |
|
dshwang
2014/03/14 07:48:34
Unfortunately, this change is very hard to be cove
|
| - |
| + m_drawingBuffer = drawingBuffer.release(); |
| m_drawingBuffer->bind(); |
|
Ken Russell (switch to Gerrit)
2014/03/14 01:49:19
If the code path "if (drawingBuffer->isZeroSized()
Ken Russell (switch to Gerrit)
2014/03/14 02:56:46
Never mind, I'm wrong.
|
| m_lostContextErrors.clear(); |