[chromium] Cleanup texture memory eviction when LayerTreeHost becomes invisible
authordanakj@chromium.org <danakj@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 14 Apr 2012 03:32:40 +0000 (03:32 +0000)
committerdanakj@chromium.org <danakj@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 14 Apr 2012 03:32:40 +0000 (03:32 +0000)
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
Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp

index 88f4f3a..483165d 100644 (file)
@@ -1,3 +1,22 @@
+2012-04-13  Dana Jansens  <danakj@chromium.org>
+
+        [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  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r114036.
index 9a4eabb..8a5f306 100644 (file)
@@ -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()));