From ecbdc5a64e24df1a4777c84fe7b65b4609ef02ac Mon Sep 17 00:00:00 2001 From: "danakj@chromium.org" Date: Sat, 14 Apr 2012 03:32:40 +0000 Subject: [PATCH] [chromium] Cleanup texture memory eviction when LayerTreeHost becomes invisible https://bugs.webkit.org/show_bug.cgi?id=83899 Reviewed by Adrienne Walker. When a LTH becomes invisible, the texture eviction is spread out across two different functions and is not entirely clear. We move all the logic together into a single place in didBecomeInvisibleOnImplThread() and make the consequences of the current code more clear. Covered by existing tests. * platform/graphics/chromium/cc/CCLayerTreeHost.cpp: (WebCore::CCLayerTreeHost::deleteContentsTexturesOnImplThread): (WebCore::CCLayerTreeHost::setVisible): (WebCore::CCLayerTreeHost::didBecomeInvisibleOnImplThread): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@114202 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebCore/ChangeLog | 19 ++++++++++++++++++ .../graphics/chromium/cc/CCLayerTreeHost.cpp | 23 +++++++++++----------- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 88f4f3a..483165d 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,22 @@ +2012-04-13 Dana Jansens + + [chromium] Cleanup texture memory eviction when LayerTreeHost becomes invisible + https://bugs.webkit.org/show_bug.cgi?id=83899 + + Reviewed by Adrienne Walker. + + When a LTH becomes invisible, the texture eviction is spread out across + two different functions and is not entirely clear. We move all the logic + together into a single place in didBecomeInvisibleOnImplThread() and + make the consequences of the current code more clear. + + Covered by existing tests. + + * platform/graphics/chromium/cc/CCLayerTreeHost.cpp: + (WebCore::CCLayerTreeHost::deleteContentsTexturesOnImplThread): + (WebCore::CCLayerTreeHost::setVisible): + (WebCore::CCLayerTreeHost::didBecomeInvisibleOnImplThread): + 2012-04-13 Sheriff Bot Unreviewed, rolling out r114036. diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp index 9a4eabb..8a5f306 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp +++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp @@ -180,7 +180,7 @@ CCLayerTreeHost::RecreateResult CCLayerTreeHost::recreateContext() void CCLayerTreeHost::deleteContentsTexturesOnImplThread(TextureAllocator* allocator) { ASSERT(CCProxy::isImplThread()); - if (m_contentsTextureManager) + if (m_layerRendererInitialized) m_contentsTextureManager->evictAndDeleteAllTextures(allocator); } @@ -369,12 +369,6 @@ void CCLayerTreeHost::setVisible(bool visible) m_visible = visible; - if (!visible && m_layerRendererInitialized) { - // Drop all unprotected textures. - m_contentsTextureManager->reduceMemoryToLimit(0); - m_contentsTextureManager->unprotectAllTextures(); - } - // Tells the proxy that visibility state has changed. This will in turn call // CCLayerTreeHost::didBecomeInvisibleOnImplThread on the appropriate thread, for // the case where !visible. @@ -387,12 +381,17 @@ void CCLayerTreeHost::didBecomeInvisibleOnImplThread(CCLayerTreeHostImpl* hostIm if (!m_layerRendererInitialized) return; - if (m_proxy->layerRendererCapabilities().contextHasCachedFrontBuffer) - contentsTextureManager()->evictAndDeleteAllTextures(hostImpl->contentsTextureAllocator()); - else { - contentsTextureManager()->reduceMemoryToLimit(m_contentsTextureManager->preferredMemoryLimitBytes()); - contentsTextureManager()->deleteEvictedTextures(hostImpl->contentsTextureAllocator()); + if (m_proxy->layerRendererCapabilities().contextHasCachedFrontBuffer) { + // Unprotect and delete all textures. + m_contentsTextureManager->unprotectAllTextures(); + m_contentsTextureManager->reduceMemoryToLimit(0); + } else { + // Delete all unprotected textures, and only save textures that fit in the preferred memory limit. + m_contentsTextureManager->reduceMemoryToLimit(0); + m_contentsTextureManager->unprotectAllTextures(); + m_contentsTextureManager->reduceMemoryToLimit(m_contentsTextureManager->preferredMemoryLimitBytes()); } + m_contentsTextureManager->deleteEvictedTextures(hostImpl->contentsTextureAllocator()); hostImpl->setRootLayer(TreeSynchronizer::synchronizeTrees(rootLayer(), hostImpl->releaseRootLayer())); -- 2.7.4