Index: trunk/Source/core/html/canvas/WebGLRenderingContextBase.cpp |
=================================================================== |
--- trunk/Source/core/html/canvas/WebGLRenderingContextBase.cpp (revision 177870) |
+++ trunk/Source/core/html/canvas/WebGLRenderingContextBase.cpp (working copy) |
@@ -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>*) |