Add debug settings for using giant tiles (4096x4096)
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Oct 2015 18:46:53 +0000 (18:46 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Oct 2015 18:46:53 +0000 (18:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=149977
<rdar://problem/23017093>

Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2015-10-13
Reviewed by Tim Horton.

Source/WebCore:

Instead of creating the GraphicsLayer with a fixed size 512x512, we need
to read the useGiantTiles setting. If its value is true, we set the layer
tileSize to 4096x4096.

* page/Settings.in:
Define the name of the setting and its default value.

* platform/graphics/GraphicsLayerClient.h:
(WebCore::GraphicsLayerClient::tileSize):
Define tileSize() in the base class GraphicsLayerClient. This is going to
be overridden RenderLayerBacking.

* platform/graphics/TiledBacking.h:
(WebCore::defaultTileSize):
Define the default tileSize which will depend on the useGiantTiles
setting.

* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::platformCALayerTileSize):
Implement the virtual function GraphicsLayerCA::platformCALayerTileSize().
It passes the call to client GraphicsLayerClient which can be RenderLayerBacking
in our case.

* platform/graphics/ca/GraphicsLayerCA.h:
Override base class function PlatformCALayerClient::PlatformCALayerClient().

* platform/graphics/ca/PlatformCALayerClient.h:
(WebCore::PlatformCALayerClient::platformCALayerTileSize):
Define platformCALayerTileSize() in the base class PlatformCALayerClient.
This is going to be overridden GraphicsLayerCA.

* platform/graphics/ca/TileController.cpp:
(WebCore::TileController::TileController):
No need for the member m_tileSize.

(WebCore::TileController::computeTileCoverageRect):
Use the function tileSize() instead of using the static values.

(WebCore::TileController::tileSize):
The tileSize will be retrieved from the owning graphics layer.

* platform/graphics/ca/TileController.h:
No need for the member m_tileSize. The tileSize will be retrieved from the owning graphics layer.

* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::setTiledBackingHasMargins):
Use the function tileSize() instead of using the static values.

(WebCore::RenderLayerBacking::tileSize):
Override base class function GraphicsLayerClient::tileSize().

* rendering/RenderLayerBacking.h:
Define the concrete method RenderLayerBacking::tilSize().

Source/WebKit2:

* Shared/WebPreferencesDefinitions.h:
* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesSetUseGiantTiles):
(WKPreferencesGetUseGiantTiles):
* UIProcess/API/C/WKPreferencesRefPrivate.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences):

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

16 files changed:
Source/WebCore/ChangeLog
Source/WebCore/page/Settings.in
Source/WebCore/platform/graphics/GraphicsLayerClient.h
Source/WebCore/platform/graphics/TiledBacking.h
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h
Source/WebCore/platform/graphics/ca/PlatformCALayerClient.h
Source/WebCore/platform/graphics/ca/TileController.cpp
Source/WebCore/platform/graphics/ca/TileController.h
Source/WebCore/rendering/RenderLayerBacking.cpp
Source/WebCore/rendering/RenderLayerBacking.h
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebPreferencesDefinitions.h
Source/WebKit2/UIProcess/API/C/WKPreferences.cpp
Source/WebKit2/UIProcess/API/C/WKPreferencesRefPrivate.h
Source/WebKit2/WebProcess/WebPage/WebPage.cpp

index ac7af94..0691461 100644 (file)
@@ -1,3 +1,65 @@
+2015-10-13  Said Abou-Hallawa  <sabouhallawa@apple.com>
+
+        Add debug settings for using giant tiles (4096x4096)
+        https://bugs.webkit.org/show_bug.cgi?id=149977
+        <rdar://problem/23017093>
+
+        Reviewed by Tim Horton.
+
+        Instead of creating the GraphicsLayer with a fixed size 512x512, we need
+        to read the useGiantTiles setting. If its value is true, we set the layer
+        tileSize to 4096x4096.
+
+        * page/Settings.in:
+        Define the name of the setting and its default value.
+        
+        * platform/graphics/GraphicsLayerClient.h:
+        (WebCore::GraphicsLayerClient::tileSize):
+        Define tileSize() in the base class GraphicsLayerClient. This is going to
+        be overridden RenderLayerBacking.
+        
+        * platform/graphics/TiledBacking.h:
+        (WebCore::defaultTileSize):
+        Define the default tileSize which will depend on the useGiantTiles
+        setting.
+
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::platformCALayerTileSize):
+        Implement the virtual function GraphicsLayerCA::platformCALayerTileSize().
+        It passes the call to client GraphicsLayerClient which can be RenderLayerBacking
+        in our case.
+
+        * platform/graphics/ca/GraphicsLayerCA.h:
+        Override base class function PlatformCALayerClient::PlatformCALayerClient().
+
+        * platform/graphics/ca/PlatformCALayerClient.h:
+        (WebCore::PlatformCALayerClient::platformCALayerTileSize):
+        Define platformCALayerTileSize() in the base class PlatformCALayerClient.
+        This is going to be overridden GraphicsLayerCA.
+
+        * platform/graphics/ca/TileController.cpp:
+        (WebCore::TileController::TileController):
+        No need for the member m_tileSize.
+        
+        (WebCore::TileController::computeTileCoverageRect):
+        Use the function tileSize() instead of using the static values.
+        
+        (WebCore::TileController::tileSize):
+        The tileSize will be retrieved from the owning graphics layer.
+        
+        * platform/graphics/ca/TileController.h:
+        No need for the member m_tileSize. The tileSize will be retrieved from the owning graphics layer.
+
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::setTiledBackingHasMargins):
+        Use the function tileSize() instead of using the static values.
+        
+        (WebCore::RenderLayerBacking::tileSize):
+        Override base class function GraphicsLayerClient::tileSize().
+        
+        * rendering/RenderLayerBacking.h:
+        Define the concrete method RenderLayerBacking::tilSize().
+
 2015-10-13  Antti Koivisto  <antti@apple.com>
 
         Try to fix ENABLE(DETAILS_ELEMENT) with SHADOW_DOM disabled.
index d90589a..6421d60 100644 (file)
@@ -201,6 +201,8 @@ simpleLineLayoutDebugBordersEnabled initial=false, setNeedsStyleRecalcInAllFrame
 
 subpixelCSSOMElementMetricsEnabled initial=false
 
+useGiantTiles initial=false
+
 mediaSourceEnabled initial=true, conditional=MEDIA_SOURCE
 
 # FIXME: Rename to allowMultiElementImplicitFormSubmission once we upstream the iOS changes to WebView.mm.
index 20c874d..bb58ba0 100644 (file)
@@ -26,6 +26,8 @@
 #ifndef GraphicsLayerClient_h
 #define GraphicsLayerClient_h
 
+#include "IntSize.h"
+#include "TiledBacking.h"
 #include <wtf/Forward.h>
 
 namespace WebCore {
@@ -118,6 +120,8 @@ public:
     virtual bool shouldAggressivelyRetainTiles(const GraphicsLayer*) const { return false; }
     virtual bool shouldTemporarilyRetainTileCohorts(const GraphicsLayer*) const { return true; }
 
+    virtual IntSize tileSize() const { return defaultTileSize(); }
+
     virtual bool needsPixelAligment() const { return false; }
 
     virtual bool needsIOSDumpRenderTreeMainFrameRenderViewLayerIsAlwaysOpaqueHack(const GraphicsLayer&) const { return false; }
index 4edc140..6cb27bf 100644 (file)
 
 namespace WebCore {
 
-static const int defaultTileWidth = 512;
-static const int defaultTileHeight = 512;
+enum TileSizeMode {
+    StandardTileSizeMode,
+    GiantTileSizeMode
+};
+
+inline static IntSize defaultTileSize(TileSizeMode tileSizeMode = StandardTileSizeMode)
+{
+    static const int kTiledLayerTileSize = 512;
+
+    // This is an experimental value for debugging and evaluating the overhead which may be
+    // incurred due to a large tile size.
+    static const int kGiantTiledLayerTileSize = 4096;
+
+    if (tileSizeMode == GiantTileSizeMode)
+        return IntSize(kGiantTiledLayerTileSize, kGiantTiledLayerTileSize);
+
+    return IntSize(kTiledLayerTileSize, kTiledLayerTileSize);
+}
 
+class FloatPoint;
+class FloatRect;
 class IntRect;
 class PlatformCALayer;
 
index 9f484e0..9c208d3 100644 (file)
@@ -1449,6 +1449,11 @@ bool GraphicsLayerCA::platformCALayerShouldTemporarilyRetainTileCohorts(Platform
     return client().shouldTemporarilyRetainTileCohorts(this);
 }
 
+IntSize GraphicsLayerCA::platformCALayerTileSize() const
+{
+    return client().tileSize();
+}
+
 static PlatformCALayer::LayerType layerTypeForCustomBackdropAppearance(GraphicsLayer::CustomAppearance appearance)
 {
     return appearance == GraphicsLayer::LightBackdropAppearance ? PlatformCALayer::LayerTypeLightSystemBackdropLayer : PlatformCALayer::LayerTypeDarkSystemBackdropLayer;
index 550d200..8ea46eb 100644 (file)
@@ -47,10 +47,6 @@ class TransformState;
 
 class GraphicsLayerCA : public GraphicsLayer, public PlatformCALayerClient {
 public:
-    // The width and height of a single tile in a tiled layer. Should be large enough to
-    // avoid lots of small tiles (and therefore lots of drawing callbacks), but small enough
-    // to keep the overall tile cost low.
-    static const int kTiledLayerTileSize = 512;
 
     WEBCORE_EXPORT explicit GraphicsLayerCA(Type, GraphicsLayerClient&);
     WEBCORE_EXPORT virtual ~GraphicsLayerCA();
@@ -199,6 +195,7 @@ private:
     WEBCORE_EXPORT virtual float platformCALayerContentsScaleMultiplierForNewTiles(PlatformCALayer*) const override;
     WEBCORE_EXPORT virtual bool platformCALayerShouldAggressivelyRetainTiles(PlatformCALayer*) const override;
     WEBCORE_EXPORT virtual bool platformCALayerShouldTemporarilyRetainTileCohorts(PlatformCALayer*) const override;
+    WEBCORE_EXPORT virtual IntSize platformCALayerTileSize() const override;
 
     virtual bool isCommittingChanges() const override { return m_isCommittingChanges; }
 
index ffb62cf..49dca3f 100644 (file)
@@ -60,6 +60,8 @@ public:
     virtual bool platformCALayerShouldAggressivelyRetainTiles(PlatformCALayer*) const { return false; }
     virtual bool platformCALayerShouldTemporarilyRetainTileCohorts(PlatformCALayer*) const { return true; }
 
+    virtual IntSize platformCALayerTileSize() const { return defaultTileSize(); }
+
     virtual bool isCommittingChanges() const { return false; }
 
 protected:
index 75616d6..56f14f7 100644 (file)
@@ -54,7 +54,6 @@ String TileController::zoomedOutTileGridContainerLayerName()
 TileController::TileController(PlatformCALayer* rootPlatformLayer)
     : m_tileCacheLayer(rootPlatformLayer)
     , m_tileGrid(std::make_unique<TileGrid>(*this))
-    , m_tileSize(defaultTileWidth, defaultTileHeight)
     , m_tileRevalidationTimer(*this, &TileController::tileRevalidationTimerFired)
     , m_zoomedOutContentsScale(0)
     , m_deviceScaleFactor(owningGraphicsLayer()->platformCALayerDeviceScaleFactor())
@@ -328,8 +327,8 @@ FloatRect TileController::computeTileCoverageRect(const FloatSize& newSize, cons
     if (m_tileCoverage == CoverageForVisibleArea || MemoryPressureHandler::singleton().isUnderMemoryPressure())
         return visibleRect;
 
-    double horizontalMargin = defaultTileWidth / contentsScale;
-    double verticalMargin = defaultTileHeight / contentsScale;
+    double horizontalMargin = tileSize().width() / contentsScale;
+    double verticalMargin = tileSize().height() / contentsScale;
 
     double currentTime = monotonicallyIncreasingTime();
     double timeDelta = currentTime - m_velocity.lastUpdateTime;
@@ -428,6 +427,11 @@ bool TileController::shouldTemporarilyRetainTileCohorts() const
     return owningGraphicsLayer()->platformCALayerShouldTemporarilyRetainTileCohorts(m_tileCacheLayer);
 }
 
+IntSize TileController::tileSize() const
+{
+    return owningGraphicsLayer()->platformCALayerTileSize();
+}
+
 void TileController::clearZoomedOutTileGrid()
 {
     m_zoomedOutTileGrid = nullptr;
index 631d745..62d3108 100644 (file)
@@ -95,7 +95,7 @@ public:
     float tileDebugBorderWidth() const { return m_tileDebugBorderWidth; }
     ScrollingModeIndication indicatorMode() const { return m_indicatorMode; }
 
-    virtual IntSize tileSize() const override { return m_tileSize; }
+    virtual IntSize tileSize() const override;
     virtual IntRect bounds() const override;
     virtual IntRect boundsWithoutMargin() const override;
     virtual bool hasMargins() const override;
@@ -175,7 +175,6 @@ private:
     std::unique_ptr<TileGrid> m_tileGrid;
     std::unique_ptr<TileGrid> m_zoomedOutTileGrid;
 
-    IntSize m_tileSize;
     FloatRect m_visibleRect; // Only used for scroll performance logging.
     FloatRect m_coverageRect;
     IntRect m_boundsAtLastRevalidate;
index 618d82c..214c059 100644 (file)
@@ -223,8 +223,8 @@ void RenderLayerBacking::setTiledBackingHasMargins(bool hasExtendedBackgroundOnL
     if (!m_usingTiledCacheLayer)
         return;
 
-    int marginLeftAndRightSize = hasExtendedBackgroundOnLeftAndRight ? defaultTileWidth : 0;
-    int marginTopAndBottomSize = hasExtendedBackgroundOnTopAndBottom ? defaultTileHeight : 0;
+    int marginLeftAndRightSize = hasExtendedBackgroundOnLeftAndRight ? tileSize().width() : 0;
+    int marginTopAndBottomSize = hasExtendedBackgroundOnTopAndBottom ? tileSize().height() : 0;
     tiledBacking()->setTileMargins(marginTopAndBottomSize, marginTopAndBottomSize, marginLeftAndRightSize, marginLeftAndRightSize);
 }
 
@@ -2461,6 +2461,12 @@ bool RenderLayerBacking::shouldTemporarilyRetainTileCohorts(const GraphicsLayer*
     return true;
 }
 
+IntSize RenderLayerBacking::tileSize() const
+{
+    TileSizeMode tileSizeMode = renderer().frame().page()->settings().useGiantTiles() ? GiantTileSizeMode : StandardTileSizeMode;
+    return defaultTileSize(tileSizeMode);
+}
+
 #ifndef NDEBUG
 void RenderLayerBacking::verifyNotPainting()
 {
index d66fb82..4dc4821 100644 (file)
@@ -213,6 +213,7 @@ public:
 
     virtual bool shouldAggressivelyRetainTiles(const GraphicsLayer*) const override;
     virtual bool shouldTemporarilyRetainTileCohorts(const GraphicsLayer*) const override;
+    virtual IntSize tileSize() const override;
     virtual bool needsPixelAligment() const override { return !m_isMainFrameRenderViewLayer; }
 
 #if PLATFORM(IOS)
index be82c04..c68853c 100644 (file)
@@ -1,3 +1,19 @@
+2015-10-13  Said Abou-Hallawa  <sabouhallawa@apple.com>
+
+        Add debug settings for using giant tiles (4096x4096)
+        https://bugs.webkit.org/show_bug.cgi?id=149977
+        <rdar://problem/23017093>
+
+        Reviewed by Tim Horton.
+
+        * Shared/WebPreferencesDefinitions.h:
+        * UIProcess/API/C/WKPreferences.cpp:
+        (WKPreferencesSetUseGiantTiles):
+        (WKPreferencesGetUseGiantTiles):
+        * UIProcess/API/C/WKPreferencesRefPrivate.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::updatePreferences):
+
 2015-10-13  Brent Fulgham  <bfulgham@apple.com>
 
         [iOS] Avoid crash due to invalid screen bounds
index 2fae6e1..6961e20 100644 (file)
     macro(ThreadedScrollingEnabled, threadedScrollingEnabled, Bool, bool, true) \
     macro(SimpleLineLayoutEnabled, simpleLineLayoutEnabled, Bool, bool, true) \
     macro(SubpixelCSSOMElementMetricsEnabled, subpixelCSSOMElementMetricsEnabled, Bool, bool, false) \
+    macro(UseGiantTiles, useGiantTiles, Bool, bool, false) \
     macro(MediaStreamEnabled, mediaStreamEnabled, Bool, bool, false) \
     macro(UseLegacyTextAlignPositionedElementBehavior, useLegacyTextAlignPositionedElementBehavior, Bool, bool, false) \
     macro(SpatialNavigationEnabled, spatialNavigationEnabled, Bool, bool, false) \
index e2bdbe6..9a53dc5 100644 (file)
@@ -1217,6 +1217,16 @@ bool WKPreferencesGetSubpixelCSSOMElementMetricsEnabled(WKPreferencesRef prefere
     return toImpl(preferencesRef)->subpixelCSSOMElementMetricsEnabled();
 }
 
+void WKPreferencesSetUseGiantTiles(WKPreferencesRef preferencesRef, bool flag)
+{
+    toImpl(preferencesRef)->setUseGiantTiles(flag);
+}
+
+bool WKPreferencesGetUseGiantTiles(WKPreferencesRef preferencesRef)
+{
+    return toImpl(preferencesRef)->useGiantTiles();
+}
+
 void WKPreferencesSetMediaStreamEnabled(WKPreferencesRef preferencesRef, bool enabled)
 {
     toImpl(preferencesRef)->setMediaStreamEnabled(enabled);
index 5b87d13..a93fbb9 100644 (file)
@@ -313,6 +313,10 @@ WK_EXPORT bool WKPreferencesGetNewBlockInsideInlineModelEnabled(WKPreferencesRef
 WK_EXPORT void WKPreferencesSetSubpixelCSSOMElementMetricsEnabled(WKPreferencesRef, bool);
 WK_EXPORT bool WKPreferencesGetSubpixelCSSOMElementMetricsEnabled(WKPreferencesRef);
 
+// Defaults to false.
+WK_EXPORT void WKPreferencesSetUseGiantTiles(WKPreferencesRef, bool);
+WK_EXPORT bool WKPreferencesGetUseGiantTiles(WKPreferencesRef);
+
 WK_EXPORT void WKPreferencesResetTestRunnerOverrides(WKPreferencesRef preferencesRef);
 
 // Defaults to false.
index 2a7df35..e68cdfe 100644 (file)
@@ -2738,6 +2738,7 @@ void WebPage::updatePreferences(const WebPreferencesStore& store)
     settings.setShowRepaintCounter(store.getBoolValueForKey(WebPreferencesKey::compositingRepaintCountersVisibleKey()));
     settings.setShowTiledScrollingIndicator(store.getBoolValueForKey(WebPreferencesKey::tiledScrollingIndicatorVisibleKey()));
     settings.setVisibleDebugOverlayRegions(store.getUInt32ValueForKey(WebPreferencesKey::visibleDebugOverlayRegionsKey()));
+    settings.setUseGiantTiles(store.getBoolValueForKey(WebPreferencesKey::useGiantTilesKey()));
     
     settings.setAggressiveTileRetentionEnabled(store.getBoolValueForKey(WebPreferencesKey::aggressiveTileRetentionEnabledKey()));
     settings.setTemporaryTileCohortRetentionEnabled(store.getBoolValueForKey(WebPreferencesKey::temporaryTileCohortRetentionEnabledKey()));