[GTK] Reduce TiledBackingStore tile coverage when on memory pressure state
authormagomez@igalia.com <magomez@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Feb 2017 12:19:05 +0000 (12:19 +0000)
committermagomez@igalia.com <magomez@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Feb 2017 12:19:05 +0000 (12:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=167980

Reviewed by Carlos Garcia Campos.

Use a smaller coverAreaMultiplier in the TiledBackingStore when in memory pressure situation, to reduce
the amount of tiles created.

No new tests.

* platform/graphics/texmap/coordinated/TiledBackingStore.cpp:
(WebCore::TiledBackingStore::createTilesIfNeeded):
(WebCore::TiledBackingStore::createTiles):
* platform/graphics/texmap/coordinated/TiledBackingStore.h:

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/texmap/coordinated/TiledBackingStore.cpp
Source/WebCore/platform/graphics/texmap/coordinated/TiledBackingStore.h

index 885e351..77d0677 100644 (file)
@@ -1,3 +1,20 @@
+2017-02-08  Miguel Gomez  <magomez@igalia.com>
+
+        [GTK] Reduce TiledBackingStore tile coverage when on memory pressure state
+        https://bugs.webkit.org/show_bug.cgi?id=167980
+
+        Reviewed by Carlos Garcia Campos.
+
+        Use a smaller coverAreaMultiplier in the TiledBackingStore when in memory pressure situation, to reduce
+        the amount of tiles created.
+
+        No new tests.
+
+        * platform/graphics/texmap/coordinated/TiledBackingStore.cpp:
+        (WebCore::TiledBackingStore::createTilesIfNeeded):
+        (WebCore::TiledBackingStore::createTiles):
+        * platform/graphics/texmap/coordinated/TiledBackingStore.h:
+
 2017-02-08  Zan Dobersek  <zdobersek@igalia.com>
 
         [EME] Implement MediaKeySession::remove()
index ac8da7a..b638916 100644 (file)
@@ -22,6 +22,7 @@
 
 #if USE(COORDINATED_GRAPHICS)
 #include "GraphicsContext.h"
+#include "MemoryPressureHandler.h"
 #include "TiledBackingStoreClient.h"
 #include <wtf/CheckedArithmetic.h>
 
@@ -59,10 +60,11 @@ void TiledBackingStore::createTilesIfNeeded(const IntRect& unscaledVisibleRect,
 {
     IntRect scaledContentsRect = mapFromContents(contentsRect);
     IntRect visibleRect = mapFromContents(unscaledVisibleRect);
+    float coverAreaMultiplier = MemoryPressureHandler::singleton().isUnderMemoryPressure() ? 1.0f : 2.0f;
 
-    bool didChange = m_trajectoryVector != m_pendingTrajectoryVector || m_visibleRect != visibleRect || m_rect != scaledContentsRect;
+    bool didChange = m_trajectoryVector != m_pendingTrajectoryVector || m_visibleRect != visibleRect || m_rect != scaledContentsRect || m_coverAreaMultiplier != coverAreaMultiplier;
     if (didChange || m_pendingTileCreation)
-        createTiles(visibleRect, scaledContentsRect);
+        createTiles(visibleRect, scaledContentsRect, coverAreaMultiplier);
 }
 
 void TiledBackingStore::invalidate(const IntRect& contentsDirtyRect)
@@ -143,13 +145,14 @@ bool TiledBackingStore::visibleAreaIsCovered() const
     return coverageRatio(intersection(m_visibleRect, m_rect)) == 1.0f;
 }
 
-void TiledBackingStore::createTiles(const IntRect& visibleRect, const IntRect& scaledContentsRect)
+void TiledBackingStore::createTiles(const IntRect& visibleRect, const IntRect& scaledContentsRect, float coverAreaMultiplier)
 {
     // Update our backing store geometry.
     const IntRect previousRect = m_rect;
     m_rect = scaledContentsRect;
     m_trajectoryVector = m_pendingTrajectoryVector;
     m_visibleRect = visibleRect;
+    m_coverAreaMultiplier = coverAreaMultiplier;
 
     if (m_rect.isEmpty()) {
         setCoverRect(IntRect());
index 3ae3295..c17f764 100644 (file)
@@ -66,7 +66,7 @@ public:
     void setSupportsAlpha(bool);
 
 private:
-    void createTiles(const IntRect& visibleRect, const IntRect& scaledContentsRect);
+    void createTiles(const IntRect& visibleRect, const IntRect& scaledContentsRect, float coverAreaMultiplier);
     void computeCoverAndKeepRect(const IntRect& visibleRect, IntRect& coverRect, IntRect& keepRect) const;
 
     bool resizeEdgeTiles();