Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1012)

Unified Diff: Source/core/html/canvas/WebGLRenderingContextBase.cpp

Issue 189423003: WebGL: Restore atomically both WebGraphicsContext3D and DrawingBuffer together. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698