- Revision
- 127820
- Author
- [email protected]
- Date
- 2012-09-06 21:39:50 -0700 (Thu, 06 Sep 2012)
Log Message
[chromium] Do not delete texture backing structures on the main thread
https://bugs.webkit.org/show_bug.cgi?id=96018
Patch by Christopher Cameron <[email protected]> on 2012-09-06
Reviewed by James Robinson.
Do not delete CCPrioritizedTexture::Backing structures on the main
thread. Instead, unlink them from their owning CCPrioritizedTexture
in the main thread, and have the impl thread then delete all unlinked
textures.
This is towards having the main thread not access the m_backings set,
which will allow the impl thread to traverse that set when deleting
resources in response to GPU memory management events.
Tested by existing eviction tests (CCLayerTreeHostTest's
TestEvictTextures, LostContextAfterEvictTextures)
* platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
(WebCore::CCLayerTreeHost::unlinkAllContentTextures):
(WebCore):
(WebCore::CCLayerTreeHost::deleteUnlinkedTextures):
* platform/graphics/chromium/cc/CCLayerTreeHost.h:
(CCLayerTreeHost):
* platform/graphics/chromium/cc/CCPrioritizedTextureManager.cpp:
(WebCore::CCPrioritizedTextureManager::clearAllMemory):
(WebCore::CCPrioritizedTextureManager::unlinkAllBackings):
(WebCore):
(WebCore::CCPrioritizedTextureManager::deleteAllUnlinkedBackings):
* platform/graphics/chromium/cc/CCPrioritizedTextureManager.h:
(CCPrioritizedTextureManager):
* platform/graphics/chromium/cc/CCSingleThreadProxy.cpp:
(WebCore::CCSingleThreadProxy::commitAndComposite):
* platform/graphics/chromium/cc/CCThreadProxy.cpp:
(WebCore::CCThreadProxy::beginFrame):
(WebCore::CCThreadProxy::beginFrameCompleteOnImplThread):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (127819 => 127820)
--- trunk/Source/WebCore/ChangeLog 2012-09-07 04:37:55 UTC (rev 127819)
+++ trunk/Source/WebCore/ChangeLog 2012-09-07 04:39:50 UTC (rev 127820)
@@ -1,3 +1,41 @@
+2012-09-06 Christopher Cameron <[email protected]>
+
+ [chromium] Do not delete texture backing structures on the main thread
+ https://bugs.webkit.org/show_bug.cgi?id=96018
+
+ Reviewed by James Robinson.
+
+ Do not delete CCPrioritizedTexture::Backing structures on the main
+ thread. Instead, unlink them from their owning CCPrioritizedTexture
+ in the main thread, and have the impl thread then delete all unlinked
+ textures.
+
+ This is towards having the main thread not access the m_backings set,
+ which will allow the impl thread to traverse that set when deleting
+ resources in response to GPU memory management events.
+
+ Tested by existing eviction tests (CCLayerTreeHostTest's
+ TestEvictTextures, LostContextAfterEvictTextures)
+
+ * platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
+ (WebCore::CCLayerTreeHost::unlinkAllContentTextures):
+ (WebCore):
+ (WebCore::CCLayerTreeHost::deleteUnlinkedTextures):
+ * platform/graphics/chromium/cc/CCLayerTreeHost.h:
+ (CCLayerTreeHost):
+ * platform/graphics/chromium/cc/CCPrioritizedTextureManager.cpp:
+ (WebCore::CCPrioritizedTextureManager::clearAllMemory):
+ (WebCore::CCPrioritizedTextureManager::unlinkAllBackings):
+ (WebCore):
+ (WebCore::CCPrioritizedTextureManager::deleteAllUnlinkedBackings):
+ * platform/graphics/chromium/cc/CCPrioritizedTextureManager.h:
+ (CCPrioritizedTextureManager):
+ * platform/graphics/chromium/cc/CCSingleThreadProxy.cpp:
+ (WebCore::CCSingleThreadProxy::commitAndComposite):
+ * platform/graphics/chromium/cc/CCThreadProxy.cpp:
+ (WebCore::CCThreadProxy::beginFrame):
+ (WebCore::CCThreadProxy::beginFrameCompleteOnImplThread):
+
2012-09-06 Simon Hausmann <[email protected]>
[Qt] Fix debug Windows build
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp (127819 => 127820)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp 2012-09-07 04:37:55 UTC (rev 127819)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp 2012-09-07 04:39:50 UTC (rev 127820)
@@ -414,13 +414,20 @@
m_proxy->setVisible(visible);
}
-void CCLayerTreeHost::evictAllContentTextures()
+void CCLayerTreeHost::unlinkAllContentTextures()
{
ASSERT(CCProxy::isMainThread());
ASSERT(m_contentsTextureManager.get());
- m_contentsTextureManager->allBackingTexturesWereDeleted();
+ m_contentsTextureManager->unlinkAllBackings();
}
+void CCLayerTreeHost::deleteUnlinkedTextures()
+{
+ ASSERT(CCProxy::isImplThread() && CCProxy::isMainThreadBlocked());
+ ASSERT(m_contentsTextureManager.get());
+ m_contentsTextureManager->deleteAllUnlinkedBackings();
+}
+
void CCLayerTreeHost::startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, double durationSec)
{
m_proxy->startPageScaleAnimation(targetPosition, useAnchor, scale, durationSec);
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h (127819 => 127820)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h 2012-09-07 04:37:55 UTC (rev 127819)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h 2012-09-07 04:39:50 UTC (rev 127820)
@@ -212,11 +212,8 @@
CCPrioritizedTextureManager* contentsTextureManager() const;
- // This will cause contents texture manager to evict all textures, but
- // without deleting them. This happens after all content textures have
- // already been deleted on impl, after getting a 0 allocation limit.
- // Set during a commit, but before updateLayers.
- void evictAllContentTextures();
+ void unlinkAllContentTextures();
+ void deleteUnlinkedTextures();
bool visible() const { return m_visible; }
void setVisible(bool);
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTextureManager.cpp (127819 => 127820)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTextureManager.cpp 2012-09-07 04:37:55 UTC (rev 127819)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTextureManager.cpp 2012-09-07 04:39:50 UTC (rev 127820)
@@ -248,6 +248,8 @@
void CCPrioritizedTextureManager::clearAllMemory(CCResourceProvider* resourceProvider)
{
+ ASSERT(CCProxy::isImplThread() && CCProxy::isMainThreadBlocked());
+ ASSERT(resourceProvider);
// Unlink and destroy all backing textures.
while (m_backings.size() > 0) {
BackingSet::iterator it = m_backings.begin();
@@ -257,14 +259,26 @@
}
}
-void CCPrioritizedTextureManager::allBackingTexturesWereDeleted()
+void CCPrioritizedTextureManager::unlinkAllBackings()
{
- // Same as clearAllMemory, except all our textures were already
- // deleted externally, so we don't delete them. Passing no
- // resourceProvider results in leaking the (now invalid) texture ids.
- clearAllMemory(0);
+ ASSERT(CCProxy::isMainThread());
+ for (BackingSet::iterator it = m_backings.begin(); it != m_backings.end(); ++it)
+ if ((*it)->owner())
+ (*it)->owner()->unlink();
}
+void CCPrioritizedTextureManager::deleteAllUnlinkedBackings()
+{
+ ASSERT(CCProxy::isImplThread() && CCProxy::isMainThreadBlocked());
+ BackingVector backingsToDelete;
+ for (BackingSet::iterator it = m_backings.begin(); it != m_backings.end(); ++it)
+ if (!(*it)->owner())
+ backingsToDelete.append((*it));
+
+ for (BackingVector::iterator it = backingsToDelete.begin(); it != backingsToDelete.end(); ++it)
+ destroyBacking((*it), 0);
+}
+
void CCPrioritizedTextureManager::registerTexture(CCPrioritizedTexture* texture)
{
ASSERT(CCProxy::isMainThread());
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTextureManager.h (127819 => 127820)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTextureManager.h 2012-09-07 04:37:55 UTC (rev 127819)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTextureManager.h 2012-09-07 04:39:50 UTC (rev 127820)
@@ -78,7 +78,8 @@
void reduceMemory(CCResourceProvider*);
void clearAllMemory(CCResourceProvider*);
- void allBackingTexturesWereDeleted();
+ void unlinkAllBackings();
+ void deleteAllUnlinkedBackings();
void acquireBackingTextureIfNeeded(CCPrioritizedTexture*, CCResourceProvider*);
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp (127819 => 127820)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp 2012-09-07 04:37:55 UTC (rev 127819)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp 2012-09-07 04:39:50 UTC (rev 127820)
@@ -297,12 +297,14 @@
{
ASSERT(CCProxy::isMainThread());
-
if (!m_layerTreeHost->initializeRendererIfNeeded())
return false;
- if (m_layerTreeHostImpl->contentsTexturesPurged())
- m_layerTreeHost->evictAllContentTextures();
+ if (m_layerTreeHostImpl->contentsTexturesPurged()) {
+ m_layerTreeHost->unlinkAllContentTextures();
+ DebugScopedSetImplThreadAndMainThreadBlocked implAndMainBlocked;
+ m_layerTreeHost->deleteUnlinkedTextures();
+ }
CCTextureUpdateQueue queue;
m_layerTreeHost->updateLayers(queue, m_layerTreeHostImpl->memoryAllocationLimitBytes());
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp (127819 => 127820)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp 2012-09-07 04:37:55 UTC (rev 127819)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp 2012-09-07 04:39:50 UTC (rev 127820)
@@ -555,7 +555,7 @@
}
if (request->contentsTexturesWereDeleted)
- m_layerTreeHost->evictAllContentTextures();
+ m_layerTreeHost->unlinkAllContentTextures();
OwnPtr<CCTextureUpdateQueue> queue = adoptPtr(new CCTextureUpdateQueue);
m_layerTreeHost->updateLayers(*(queue.get()), request->memoryAllocationLimitBytes);
@@ -597,7 +597,7 @@
{
TRACE_EVENT0("cc", "CCThreadProxy::beginFrameCompleteOnImplThread");
ASSERT(!m_commitCompletionEventOnImplThread);
- ASSERT(isImplThread());
+ ASSERT(isImplThread() && isMainThreadBlocked());
ASSERT(m_schedulerOnImplThread);
ASSERT(m_schedulerOnImplThread->commitPending());
@@ -607,15 +607,20 @@
return;
}
- if (!contentsTexturesWereDeleted && m_layerTreeHostImpl->contentsTexturesPurged()) {
+ if (contentsTexturesWereDeleted) {
+ ASSERT(m_layerTreeHostImpl->contentsTexturesPurged());
+ // We unlinked all textures on the main thread, delete them now.
+ m_layerTreeHost->deleteUnlinkedTextures();
+ // Mark that we can start drawing again when this commit is complete.
+ m_resetContentsTexturesPurgedAfterCommitOnImplThread = true;
+ } else if (m_layerTreeHostImpl->contentsTexturesPurged()) {
// We purged the content textures on the impl thread between the time we
// posted the beginFrame task and now, meaning we have a bunch of
// uploads that are now invalid. Clear the uploads (they all go to
// content textures), and kick another commit to fill them again.
queue->clearUploads();
setNeedsCommitOnImplThread();
- } else
- m_resetContentsTexturesPurgedAfterCommitOnImplThread = true;
+ }
m_currentTextureUpdateControllerOnImplThread = CCTextureUpdateController::create(CCProxy::implThread(), queue, m_layerTreeHostImpl->resourceProvider(), m_layerTreeHostImpl->renderer()->textureCopier(), m_layerTreeHostImpl->renderer()->textureUploader());
m_commitCompletionEventOnImplThread = completion;