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

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

Issue 388573004: Revert of WebGL: Refactor active context management. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 5 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 | « Source/core/html/canvas/WebGLRenderingContextBase.h ('k') | 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 d5091e0ba8133c374678d46f8c50097c38e30777..a52eb64d68173acf513ef3209fef55b7db695da7 100644
--- a/Source/core/html/canvas/WebGLRenderingContextBase.cpp
+++ b/Source/core/html/canvas/WebGLRenderingContextBase.cpp
@@ -118,6 +118,8 @@
// Must make sure that the context is not deleted until the call stack unwinds.
RefPtrWillBeRawPtr<WebGLRenderingContextBase> protect(candidate);
+ activeContexts().remove(candidateID);
+
candidate->printWarningToConsole(reason);
InspectorInstrumentation::didFireWebGLWarning(candidate->canvas());
@@ -131,12 +133,12 @@
return maxGLActiveContexts;
WebGLRenderingContextBase* candidate = activeContexts().first();
- ASSERT(!candidate->isContextLost());
+ blink::WebGraphicsContext3D* candidateWGC3D = candidate->isContextLost() ? 0 : candidate->webContext();
size_t candidateID = 0;
for (size_t ii = 1; ii < activeContexts().size(); ++ii) {
WebGLRenderingContextBase* context = activeContexts()[ii];
- ASSERT(!context->isContextLost());
- if (context->webContext()->lastFlushID() < candidate->webContext()->lastFlushID()) {
+ blink::WebGraphicsContext3D* contextWGC3D = context->isContextLost() ? 0 : context->webContext();
+ if (contextWGC3D && candidateWGC3D && contextWGC3D->lastFlushID() < candidateWGC3D->lastFlushID()) {
candidate = context;
candidateID = ii;
}
@@ -167,22 +169,17 @@
removedContexts++;
}
- ASSERT(!context->isContextLost());
if (!activeContexts().contains(context))
activeContexts().append(context);
}
-void WebGLRenderingContextBase::deactivateContext(WebGLRenderingContextBase* context)
+void WebGLRenderingContextBase::deactivateContext(WebGLRenderingContextBase* context, bool addToEvictedList)
{
size_t position = activeContexts().find(context);
if (position != WTF::kNotFound)
activeContexts().remove(position);
-}
-
-void WebGLRenderingContextBase::addToEvictedList(WebGLRenderingContextBase* context)
-{
- ASSERT(context->m_restoreAllowed);
- if (!forciblyEvictedContexts().contains(context))
+
+ if (addToEvictedList && !forciblyEvictedContexts().contains(context))
forciblyEvictedContexts().append(context);
}
@@ -192,18 +189,23 @@
if (position != WTF::kNotFound)
forciblyEvictedContexts().remove(position);
- deactivateContext(context);
+ deactivateContext(context, false);
// Try to re-enable the oldest inactive contexts.
while(activeContexts().size() < maxGLActiveContexts && forciblyEvictedContexts().size()) {
WebGLRenderingContextBase* evictedContext = forciblyEvictedContexts().first();
- ASSERT(evictedContext->m_restoreAllowed);
+ if (!evictedContext->m_restoreAllowed) {
+ forciblyEvictedContexts().remove(0);
+ continue;
+ }
+
IntSize desiredSize = DrawingBuffer::adjustSize(evictedContext->clampedCanvasSize(), IntSize(), evictedContext->m_maxTextureSize);
// If there's room in the pixel budget for this context, restore it.
if (!desiredSize.isEmpty()) {
forciblyEvictedContexts().remove(0);
evictedContext->forceRestoreContext();
+ activeContexts().append(evictedContext);
}
break;
}
@@ -4226,7 +4228,6 @@
// Don't allow restoration unless the context lost event has both been
// dispatched and its default behavior prevented.
m_restoreAllowed = false;
- deactivateContext(this);
// Always defer the dispatch of the context lost event, to implement
// the spec behavior of queueing a task.
@@ -5443,13 +5444,9 @@
RefPtrWillBeRawPtr<WebGLContextEvent> event = WebGLContextEvent::create(EventTypeNames::webglcontextlost, false, true, "");
canvas()->dispatchEvent(event);
m_restoreAllowed = event->defaultPrevented();
- if (m_restoreAllowed) {
- if ((m_contextLostMode == RealLostContext || m_contextLostMode == AutoRecoverSyntheticLostContext)) {
- m_restoreTimer.startOneShot(0, FROM_HERE);
- } else {
- addToEvictedList(this);
- }
- }
+ deactivateContext(this, m_contextLostMode != RealLostContext && m_restoreAllowed);
+ if ((m_contextLostMode == RealLostContext || m_contextLostMode == AutoRecoverSyntheticLostContext) && m_restoreAllowed)
+ m_restoreTimer.startOneShot(0, FROM_HERE);
}
void WebGLRenderingContextBase::maybeRestoreContext(Timer<WebGLRenderingContextBase>*)
« no previous file with comments | « Source/core/html/canvas/WebGLRenderingContextBase.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698