[chromium] Remove viewport memory restrictions
authordanakj@chromium.org <danakj@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 14 Apr 2012 00:42:00 +0000 (00:42 +0000)
committerdanakj@chromium.org <danakj@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 14 Apr 2012 00:42:00 +0000 (00:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=83316

Reviewed by Adrienne Walker.

We remove the memory restriction on web pages based on viewport size
on desktop. This is causing pages that have complex use of layers to
end up hitting our memory limits, and moreso when the window is small.
Page complexity is not really a function of the viewport size.

We drop the mininum memory limit entirely, and just evict all
unprotected textures instead.

Covered by existing tests.

* platform/graphics/chromium/TextureManager.cpp:
(WebCore::TextureManager::highLimitBytes):
(WebCore::TextureManager::reclaimLimitBytes):
* platform/graphics/chromium/TextureManager.h:
(TextureManager):
* platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
(WebCore::CCLayerTreeHost::beginCommitOnImplThread):
(WebCore::CCLayerTreeHost::setVisible):
(WebCore::CCLayerTreeHost::didBecomeInvisibleOnImplThread):
(WebCore::CCLayerTreeHost::updateLayers):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@114191 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/chromium/TextureManager.cpp
Source/WebCore/platform/graphics/chromium/TextureManager.h
Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp

index 4e2c1b8..6e0d56c 100644 (file)
@@ -1,3 +1,31 @@
+2012-04-13  Dana Jansens  <danakj@chromium.org>
+
+        [chromium] Remove viewport memory restrictions
+        https://bugs.webkit.org/show_bug.cgi?id=83316
+
+        Reviewed by Adrienne Walker.
+
+        We remove the memory restriction on web pages based on viewport size
+        on desktop. This is causing pages that have complex use of layers to
+        end up hitting our memory limits, and moreso when the window is small.
+        Page complexity is not really a function of the viewport size.
+
+        We drop the mininum memory limit entirely, and just evict all
+        unprotected textures instead.
+
+        Covered by existing tests.
+
+        * platform/graphics/chromium/TextureManager.cpp:
+        (WebCore::TextureManager::highLimitBytes):
+        (WebCore::TextureManager::reclaimLimitBytes):
+        * platform/graphics/chromium/TextureManager.h:
+        (TextureManager):
+        * platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
+        (WebCore::CCLayerTreeHost::beginCommitOnImplThread):
+        (WebCore::CCLayerTreeHost::setVisible):
+        (WebCore::CCLayerTreeHost::didBecomeInvisibleOnImplThread):
+        (WebCore::CCLayerTreeHost::updateLayers):
+
 2012-04-13  Ken Buchanan  <kenrb@chromium.org>
 
         Optimize tracking of intruding floats being removed from RenderBlock during layout
index 0c6fe14..d4d8c18 100644 (file)
@@ -39,6 +39,8 @@ namespace WebCore {
 namespace {
 size_t memoryLimitBytes(size_t viewportMultiplier, const IntSize& viewportSize, size_t minMegabytes, size_t maxMegabytes)
 {
+    if (!viewportMultiplier)
+        return maxMegabytes * 1024 * 1024;
     if (viewportSize.isEmpty())
         return minMegabytes * 1024 * 1024;
     return max(minMegabytes * 1024 * 1024, min(maxMegabytes * 1024 * 1024, viewportMultiplier * TextureManager::memoryUseBytes(viewportSize, GraphicsContext3D::RGBA)));
@@ -48,12 +50,13 @@ size_t memoryLimitBytes(size_t viewportMultiplier, const IntSize& viewportSize,
 size_t TextureManager::highLimitBytes(const IntSize& viewportSize)
 {
     size_t viewportMultiplier, minMegabytes, maxMegabytes;
-    viewportMultiplier = 12;
 #if OS(ANDROID)
-    minMegabytes = 24;
-    maxMegabytes = 40;
+    viewportMultiplier = 16;
+    minMegabytes = 32;
+    maxMegabytes = 64;
 #else
-    minMegabytes = 64;
+    viewportMultiplier = 0;
+    minMegabytes = 0;
     maxMegabytes = 128;
 #endif
     return memoryLimitBytes(viewportMultiplier, viewportSize, minMegabytes, maxMegabytes);
@@ -62,26 +65,18 @@ size_t TextureManager::highLimitBytes(const IntSize& viewportSize)
 size_t TextureManager::reclaimLimitBytes(const IntSize& viewportSize)
 {
     size_t viewportMultiplier, minMegabytes, maxMegabytes;
-    viewportMultiplier = 6;
 #if OS(ANDROID)
-    minMegabytes = 9;
+    viewportMultiplier = 8;
+    minMegabytes = 16;
     maxMegabytes = 32;
 #else
-    minMegabytes = 32;
+    viewportMultiplier = 0;
+    minMegabytes = 0;
     maxMegabytes = 64;
 #endif
     return memoryLimitBytes(viewportMultiplier, viewportSize, minMegabytes, maxMegabytes);
 }
 
-size_t TextureManager::lowLimitBytes(const IntSize& viewportSize)
-{
-    size_t viewportMultiplier, minMegabytes, maxMegabytes;
-    viewportMultiplier = 1;
-    minMegabytes = 2;
-    maxMegabytes = 3;
-    return memoryLimitBytes(viewportMultiplier, viewportSize, minMegabytes, maxMegabytes);
-}
-
 size_t TextureManager::memoryUseBytes(const IntSize& size, GC3Denum textureFormat)
 {
     // FIXME: This assumes all textures are 1 byte/component.
index e4d6d38..70d0861 100644 (file)
@@ -62,8 +62,6 @@ public:
     static size_t highLimitBytes(const IntSize& viewportSize);
     // Preferred texture size limit given the viewport size.
     static size_t reclaimLimitBytes(const IntSize& viewportSize);
-    // The maximum texture memory usage when asked to release textures.
-    static size_t lowLimitBytes(const IntSize& viewport);
 
     static size_t memoryUseBytes(const IntSize&, GC3Denum format);
 
index d6e1fe2..9a4eabb 100644 (file)
@@ -202,7 +202,7 @@ void CCLayerTreeHost::beginCommitOnImplThread(CCLayerTreeHostImpl* hostImpl)
     ASSERT(CCProxy::isImplThread());
     TRACE_EVENT("CCLayerTreeHost::commitTo", this, 0);
 
-    m_contentsTextureManager->reduceMemoryToLimit(TextureManager::reclaimLimitBytes(viewportSize()));
+    m_contentsTextureManager->reduceMemoryToLimit(m_contentsTextureManager->preferredMemoryLimitBytes());
     m_contentsTextureManager->deleteEvictedTextures(hostImpl->contentsTextureAllocator());
 }
 
@@ -370,7 +370,8 @@ void CCLayerTreeHost::setVisible(bool visible)
     m_visible = visible;
 
     if (!visible && m_layerRendererInitialized) {
-        m_contentsTextureManager->reduceMemoryToLimit(TextureManager::lowLimitBytes(viewportSize()));
+        // Drop all unprotected textures.
+        m_contentsTextureManager->reduceMemoryToLimit(0);
         m_contentsTextureManager->unprotectAllTextures();
     }
 
@@ -389,7 +390,7 @@ void CCLayerTreeHost::didBecomeInvisibleOnImplThread(CCLayerTreeHostImpl* hostIm
     if (m_proxy->layerRendererCapabilities().contextHasCachedFrontBuffer)
         contentsTextureManager()->evictAndDeleteAllTextures(hostImpl->contentsTextureAllocator());
     else {
-        contentsTextureManager()->reduceMemoryToLimit(TextureManager::reclaimLimitBytes(viewportSize()));
+        contentsTextureManager()->reduceMemoryToLimit(m_contentsTextureManager->preferredMemoryLimitBytes());
         contentsTextureManager()->deleteEvictedTextures(hostImpl->contentsTextureAllocator());
     }
 
@@ -481,8 +482,8 @@ void CCLayerTreeHost::updateLayers(LayerChromium* rootLayer, CCTextureUpdater& u
     if (!m_triggerIdlePaints)
         return;
 
-    size_t preferredLimitBytes = TextureManager::reclaimLimitBytes(m_viewportSize);
-    size_t maxLimitBytes = TextureManager::highLimitBytes(m_viewportSize);
+    size_t preferredLimitBytes = m_contentsTextureManager->preferredMemoryLimitBytes();
+    size_t maxLimitBytes = m_contentsTextureManager->maxMemoryLimitBytes();
     m_contentsTextureManager->reduceMemoryToLimit(preferredLimitBytes);
     if (m_contentsTextureManager->currentMemoryUseBytes() >= preferredLimitBytes)
         return;