[iOS WK2] Use larger tiles when possible to reduce per-tile painting overhead
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 Mar 2016 22:25:08 +0000 (22:25 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 Mar 2016 22:25:08 +0000 (22:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=155734
rdar://problem/24968144

Reviewed by Tim Horton.

Source/WebCore:

The existing tile size logic is wired to adjustScrollbars, which doesn't fire
when scrolling is delegated. For iOS WK2, key off of a new unobscuredContentSizeChanged()
function that runs when the UI process tells told WebCore that the unobscured size
has changed. In addition, contentsResized() is used to update scrollability when
page changes size.

* page/FrameView.cpp:
(WebCore::FrameView::contentsResized):
(WebCore::FrameView::addedOrRemovedScrollbar):
(WebCore::FrameView::adjustTiledBackingScrollability): Handle both delegated and non-delegated
scrolling; the former looks at the visible size (based on the unobscuredVisibleContentRect),
the latter at the presence of scrollbars.
(WebCore::FrameView::unobscuredContentSizeChanged):
* page/FrameView.h:
* platform/ScrollView.h:
(WebCore::ScrollView::unobscuredContentSizeChanged):
* platform/graphics/ca/TileController.cpp:
(WebCore::TileController::adjustTileCoverageRect): Use kDefaultTileSize rather than the
tile size, to retain the old amount of overdraw.
(WebCore::TileController::tileSize): There was a bug in the not-scrollable case; we need
to scale.
* platform/ios/ScrollViewIOS.mm:
(WebCore::ScrollView::setUnobscuredContentSize):

LayoutTests:

New results with larger page tiles in WK2.

* platform/ios-simulator-wk2/compositing/tiling/rotated-tiled-clamped-expected.txt: Added.
* platform/ios-simulator-wk2/compositing/tiling/rotated-tiled-preserve3d-clamped-expected.txt: Added.
* platform/ios-simulator-wk2/compositing/tiling/transform-origin-tiled-expected.txt: Added.

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

LayoutTests/ChangeLog
LayoutTests/platform/ios-simulator-wk2/compositing/tiling/rotated-tiled-clamped-expected.txt [new file with mode: 0644]
LayoutTests/platform/ios-simulator-wk2/compositing/tiling/rotated-tiled-preserve3d-clamped-expected.txt [new file with mode: 0644]
LayoutTests/platform/ios-simulator-wk2/compositing/tiling/transform-origin-tiled-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/FrameView.h
Source/WebCore/platform/ScrollView.h
Source/WebCore/platform/graphics/ca/TileController.cpp
Source/WebCore/platform/ios/ScrollViewIOS.mm

index 148dc028db5f0328747904c8147ae5cfbea79c9f..a7b005738a1e9988cd5c132a487544ff33fd4fe6 100644 (file)
@@ -1,3 +1,17 @@
+2016-03-21  Simon Fraser  <simon.fraser@apple.com>
+
+        [iOS WK2] Use larger tiles when possible to reduce per-tile painting overhead
+        https://bugs.webkit.org/show_bug.cgi?id=155734
+        rdar://problem/24968144
+
+        Reviewed by Tim Horton.
+
+        New results with larger page tiles in WK2.
+
+        * platform/ios-simulator-wk2/compositing/tiling/rotated-tiled-clamped-expected.txt: Added.
+        * platform/ios-simulator-wk2/compositing/tiling/rotated-tiled-preserve3d-clamped-expected.txt: Added.
+        * platform/ios-simulator-wk2/compositing/tiling/transform-origin-tiled-expected.txt: Added.
+
 2016-03-21  Hyungwook Lee  <hyungwook.lee@navercorp.com>
 
         [Win] Connect layoutTestController.findString() to support testing
diff --git a/LayoutTests/platform/ios-simulator-wk2/compositing/tiling/rotated-tiled-clamped-expected.txt b/LayoutTests/platform/ios-simulator-wk2/compositing/tiling/rotated-tiled-clamped-expected.txt
new file mode 100644 (file)
index 0000000..c7aa0c3
--- /dev/null
@@ -0,0 +1,61 @@
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 600.00)
+  (visible rect 0.00, 0.00 800.00 x 600.00)
+  (coverage rect 0.00, 0.00 800.00 x 600.00)
+  (intersects coverage rect 1)
+  (contentsScale 2.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (visible rect 0.00, 0.00 800.00 x 600.00)
+      (coverage rect 0.00, 0.00 800.00 x 600.00)
+      (intersects coverage rect 1)
+      (contentsScale 2.00)
+      (tile cache coverage 0, 0 800 x 600)
+      (tile size 800 x 600)
+      (top left tile 0, 0 tiles grid 1 x 1)
+      (children 1
+        (GraphicsLayer
+          (position 58.00 50.00)
+          (bounds 502.00 302.00)
+          (visible rect 0.00, 0.00 502.00 x 302.00)
+          (coverage rect -58.00, -50.00 800.00 x 600.00)
+          (intersects coverage rect 1)
+          (contentsScale 2.00)
+          (children 1
+            (GraphicsLayer
+              (position 1.00 1.00)
+              (bounds 500.00 300.00)
+              (childrenTransform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.00 0.00 1.00 -0.00] [0.00 0.00 0.00 1.00])
+              (visible rect 0.00, 0.00 500.00 x 300.00)
+              (coverage rect 0.00, 0.00 500.00 x 300.00)
+              (intersects coverage rect 1)
+              (contentsScale 2.00)
+              (children 1
+                (GraphicsLayer
+                  (position -1250.00 0.00)
+                  (anchor 0.54 0.50)
+                  (bounds 2800.00 300.00)
+                  (usingTiledLayer 1)
+                  (contentsOpaque 1)
+                  (drawsContent 1)
+                  (transform [0.17 0.00 -0.98 0.00] [0.00 1.00 0.00 0.00] [0.98 0.00 0.17 0.00] [0.00 0.00 0.00 1.00])
+                  (visible rect 0.00, 0.00 2800.00 x 300.00)
+                  (coverage rect 0.00, 0.00 2800.00 x 300.00)
+                  (intersects coverage rect 1)
+                  (contentsScale 2.00)
+                  (tile cache coverage 0, 0 2800 x 300)
+                  (tile size 512 x 512)
+                  (top left tile 0, 0 tiles grid 6 x 1)
+                )
+              )
+            )
+          )
+        )
+      )
+    )
+  )
+)
+
diff --git a/LayoutTests/platform/ios-simulator-wk2/compositing/tiling/rotated-tiled-preserve3d-clamped-expected.txt b/LayoutTests/platform/ios-simulator-wk2/compositing/tiling/rotated-tiled-preserve3d-clamped-expected.txt
new file mode 100644 (file)
index 0000000..0cc19a4
--- /dev/null
@@ -0,0 +1,70 @@
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 600.00)
+  (visible rect 0.00, 0.00 800.00 x 600.00)
+  (coverage rect 0.00, 0.00 800.00 x 600.00)
+  (intersects coverage rect 1)
+  (contentsScale 2.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (visible rect 0.00, 0.00 800.00 x 600.00)
+      (coverage rect 0.00, 0.00 800.00 x 600.00)
+      (intersects coverage rect 1)
+      (contentsScale 2.00)
+      (tile cache coverage 0, 0 800 x 600)
+      (tile size 800 x 600)
+      (top left tile 0, 0 tiles grid 1 x 1)
+      (children 1
+        (GraphicsLayer
+          (position 58.00 50.00)
+          (bounds 502.00 302.00)
+          (visible rect 0.00, 0.00 502.00 x 302.00)
+          (coverage rect -58.00, -50.00 800.00 x 600.00)
+          (intersects coverage rect 1)
+          (contentsScale 2.00)
+          (children 1
+            (GraphicsLayer
+              (position 1.00 1.00)
+              (bounds 500.00 300.00)
+              (childrenTransform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.00 0.00 1.00 -0.00] [0.00 0.00 0.00 1.00])
+              (visible rect 0.00, 0.00 500.00 x 300.00)
+              (coverage rect 0.00, 0.00 500.00 x 300.00)
+              (intersects coverage rect 1)
+              (contentsScale 2.00)
+              (children 1
+                (GraphicsLayer
+                  (preserves3D 1)
+                  (visible rect 0.00, 0.00 0.00 x 0.00)
+                  (coverage rect 0.00, 0.00 500.00 x 300.00)
+                  (intersects coverage rect 0)
+                  (contentsScale 2.00)
+                  (children 1
+                    (GraphicsLayer
+                      (position -1250.00 0.00)
+                      (anchor 0.54 0.50)
+                      (bounds 2800.00 300.00)
+                      (usingTiledLayer 1)
+                      (contentsOpaque 1)
+                      (drawsContent 1)
+                      (transform [0.17 0.00 -0.98 0.00] [0.00 1.00 0.00 0.00] [0.98 0.00 0.17 0.00] [0.00 0.00 0.00 1.00])
+                      (visible rect 0.00, 0.00 2800.00 x 300.00)
+                      (coverage rect 0.00, 0.00 2800.00 x 300.00)
+                      (intersects coverage rect 1)
+                      (contentsScale 2.00)
+                      (tile cache coverage 0, 0 2800 x 300)
+                      (tile size 512 x 512)
+                      (top left tile 0, 0 tiles grid 6 x 1)
+                    )
+                  )
+                )
+              )
+            )
+          )
+        )
+      )
+    )
+  )
+)
+
diff --git a/LayoutTests/platform/ios-simulator-wk2/compositing/tiling/transform-origin-tiled-expected.txt b/LayoutTests/platform/ios-simulator-wk2/compositing/tiling/transform-origin-tiled-expected.txt
new file mode 100644 (file)
index 0000000..1f8fd73
--- /dev/null
@@ -0,0 +1,60 @@
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 600.00)
+  (visible rect 0.00, 0.00 800.00 x 600.00)
+  (coverage rect 0.00, 0.00 800.00 x 600.00)
+  (intersects coverage rect 1)
+  (contentsScale 2.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (visible rect 0.00, 0.00 800.00 x 600.00)
+      (coverage rect 0.00, 0.00 800.00 x 600.00)
+      (intersects coverage rect 1)
+      (contentsScale 2.00)
+      (tile cache coverage 0, 0 800 x 600)
+      (tile size 800 x 600)
+      (top left tile 0, 0 tiles grid 1 x 1)
+      (children 1
+        (GraphicsLayer
+          (position 58.00 50.00)
+          (bounds 502.00 302.00)
+          (visible rect 0.00, 0.00 502.00 x 302.00)
+          (coverage rect -58.00, -50.00 800.00 x 600.00)
+          (intersects coverage rect 1)
+          (contentsScale 2.00)
+          (children 1
+            (GraphicsLayer
+              (position 1.00 1.00)
+              (bounds 500.00 300.00)
+              (childrenTransform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.00 0.00 1.00 -0.00] [0.00 0.00 0.00 1.00])
+              (visible rect 0.00, 0.00 500.00 x 300.00)
+              (coverage rect 0.00, 0.00 500.00 x 300.00)
+              (intersects coverage rect 1)
+              (contentsScale 2.00)
+              (children 1
+                (GraphicsLayer
+                  (position -1250.00 0.00)
+                  (anchor 0.54 0.50)
+                  (bounds 2800.00 300.00)
+                  (usingTiledLayer 1)
+                  (contentsOpaque 1)
+                  (drawsContent 1)
+                  (visible rect 1250.00, 0.00 500.00 x 300.00)
+                  (coverage rect 1250.00, 0.00 500.00 x 300.00)
+                  (intersects coverage rect 1)
+                  (contentsScale 2.00)
+                  (tile cache coverage 1024, 0 1024 x 300)
+                  (tile size 512 x 512)
+                  (top left tile 2, 0 tiles grid 2 x 1)
+                )
+              )
+            )
+          )
+        )
+      )
+    )
+  )
+)
+
index be97d1457ff9dead0fdbb887fa5c6e1e5b65ca22..b9a5d28e772dccac9bc2bcd0a4d8293daf45f2b4 100644 (file)
@@ -1,3 +1,35 @@
+2016-03-21  Simon Fraser  <simon.fraser@apple.com>
+
+        [iOS WK2] Use larger tiles when possible to reduce per-tile painting overhead
+        https://bugs.webkit.org/show_bug.cgi?id=155734
+        rdar://problem/24968144
+
+        Reviewed by Tim Horton.
+
+        The existing tile size logic is wired to adjustScrollbars, which doesn't fire
+        when scrolling is delegated. For iOS WK2, key off of a new unobscuredContentSizeChanged()
+        function that runs when the UI process tells told WebCore that the unobscured size
+        has changed. In addition, contentsResized() is used to update scrollability when
+        page changes size.
+
+        * page/FrameView.cpp:
+        (WebCore::FrameView::contentsResized):
+        (WebCore::FrameView::addedOrRemovedScrollbar):
+        (WebCore::FrameView::adjustTiledBackingScrollability): Handle both delegated and non-delegated
+        scrolling; the former looks at the visible size (based on the unobscuredVisibleContentRect),
+        the latter at the presence of scrollbars.
+        (WebCore::FrameView::unobscuredContentSizeChanged):
+        * page/FrameView.h:
+        * platform/ScrollView.h:
+        (WebCore::ScrollView::unobscuredContentSizeChanged):
+        * platform/graphics/ca/TileController.cpp:
+        (WebCore::TileController::adjustTileCoverageRect): Use kDefaultTileSize rather than the
+        tile size, to retain the old amount of overdraw.
+        (WebCore::TileController::tileSize): There was a bug in the not-scrollable case; we need
+        to scale.
+        * platform/ios/ScrollViewIOS.mm:
+        (WebCore::ScrollView::setUnobscuredContentSize):
+
 2016-03-21  Chris Dumez  <cdumez@apple.com>
 
         Unreviewed, rolling out r197552.
index ffbc77ec2ffc62998fc0d50c36b1c5caa58272bb..650424246ed44c9d03b9ed510d2c6639a70c4f5b 100644 (file)
@@ -2136,6 +2136,13 @@ void FrameView::setScrollPosition(const ScrollPosition& scrollPosition)
     ScrollView::setScrollPosition(scrollPosition);
 }
 
+void FrameView::contentsResized()
+{
+    // For non-delegated scrolling, adjustTiledBackingScrollability() is called via addedOrRemovedScrollbar() which occurs less often.
+    if (delegatesScrolling())
+        adjustTiledBackingScrollability();
+}
+
 void FrameView::delegatesScrollingDidChange()
 {
     // When we switch to delgatesScrolling mode, we should destroy the scrolling/clipping layers in RenderLayerCompositor.
@@ -2466,18 +2473,46 @@ void FrameView::addedOrRemovedScrollbar()
             renderView->compositor().frameViewDidAddOrRemoveScrollbars();
     }
 
-    if (auto* tiledBacking = this->tiledBacking()) {
-        TiledBacking::Scrollability scrollability = TiledBacking::NotScrollable;
-        if (horizontalScrollbar())
-            scrollability = TiledBacking::HorizontallyScrollable;
+    adjustTiledBackingScrollability();
+}
 
-        if (verticalScrollbar())
-            scrollability |= TiledBacking::VerticallyScrollable;
+void FrameView::adjustTiledBackingScrollability()
+{
+    auto* tiledBacking = this->tiledBacking();
+    if (!tiledBacking)
+        return;
+    
+    bool horizontallyScrollable;
+    bool verticallyScrollable;
 
-        tiledBacking->setScrollability(scrollability);
+    if (delegatesScrolling()) {
+        IntSize documentSize = contentsSize();
+        IntSize visibleSize = this->visibleSize();
+        
+        horizontallyScrollable = documentSize.width() > visibleSize.width();
+        verticallyScrollable = documentSize.height() > visibleSize.height();
+    } else {
+        horizontallyScrollable = horizontalScrollbar();
+        verticallyScrollable = verticalScrollbar();
     }
+
+    TiledBacking::Scrollability scrollability = TiledBacking::NotScrollable;
+    if (horizontallyScrollable)
+        scrollability = TiledBacking::HorizontallyScrollable;
+
+    if (verticallyScrollable)
+        scrollability |= TiledBacking::VerticallyScrollable;
+
+    tiledBacking->setScrollability(scrollability);
 }
 
+#if PLATFORM(IOS)
+void FrameView::unobscuredContentSizeChanged()
+{
+    adjustTiledBackingScrollability();
+}
+#endif
+
 static LayerFlushThrottleState::Flags determineLayerFlushThrottleState(Page& page)
 {
     // We only throttle when constantly receiving new data during the inital page load.
index d6d2589b1c08854ef6364acfe93ddc0814c6f9da..2eb5d3d313ccd390bc88ed4950bd058b6670fbd4 100644 (file)
@@ -510,6 +510,8 @@ public:
 
     WEBCORE_EXPORT void availableContentSizeChanged(AvailableSizeChangeReason) override;
 
+    void adjustTiledBackingScrollability();
+
     void addPaintPendingMilestones(LayoutMilestones);
     void firePaintRelatedMilestonesIfNeeded();
     void fireLayoutRelatedMilestonesIfNeeded();
@@ -636,6 +638,11 @@ private:
 #if ENABLE(RUBBER_BANDING)
     GraphicsLayer* layerForOverhangAreas() const override;
 #endif
+    void contentsResized() override;
+
+#if PLATFORM(IOS)
+    void unobscuredContentSizeChanged() override;
+#endif
 
     bool usesCompositedScrolling() const override;
     bool usesAsyncScrolling() const override;
index 7d7d9e88324d0a7ba2317fd54fe6b29d6ce1cbfc..35feaab8fba041602eeb965cd80d402ffda1e627 100644 (file)
@@ -419,6 +419,10 @@ protected:
 
     virtual void scrollOffsetChangedViaPlatformWidgetImpl(const ScrollOffset&, const ScrollOffset&) { }
 
+#if PLATFORM(IOS)
+    virtual void unobscuredContentSizeChanged() { }
+#endif
+
 private:
     IntRect visibleContentRectInternal(VisibleContentRectIncludesScrollbars, VisibleContentRectBehavior) const override;
     WEBCORE_EXPORT IntRect unobscuredContentRectInternal(VisibleContentRectIncludesScrollbars = ExcludeScrollbars) const;
index f5bc18d888f824a2f750934e391953099f683eeb..99b5b620f19c5cafaca07b63828c76574f05b91d 100644 (file)
@@ -363,8 +363,8 @@ void TileController::adjustTileCoverageRect(FloatRect& coverageRect, const Float
         return;
     }
 
-    double horizontalMargin = tileSize().width() / contentsScale;
-    double verticalMargin = tileSize().height() / contentsScale;
+    double horizontalMargin = kDefaultTileSize / contentsScale;
+    double verticalMargin = kDefaultTileSize / contentsScale;
 
     double currentTime = monotonicallyIncreasingTime();
     double timeDelta = currentTime - m_velocity.lastUpdateTime;
@@ -494,10 +494,13 @@ IntSize TileController::tileSize() const
 
     IntSize tileSize(kDefaultTileSize, kDefaultTileSize);
 
-    if (m_scrollability == NotScrollable)
-        tileSize = boundsWithoutMargin().size().constrainedBetween(IntSize(kDefaultTileSize, kDefaultTileSize), IntSize(kGiantTileSize, kGiantTileSize));
-    else if (m_scrollability == VerticallyScrollable)
-        tileSize.setWidth(std::min(std::max(boundsWithoutMargin().width(), kDefaultTileSize), kGiantTileSize));
+    if (m_scrollability == NotScrollable) {
+        IntSize scaledSize = expandedIntSize(boundsWithoutMargin().size() * tileGrid().scale());
+        tileSize = scaledSize.constrainedBetween(IntSize(kDefaultTileSize, kDefaultTileSize), IntSize(kGiantTileSize, kGiantTileSize));
+    } else if (m_scrollability == VerticallyScrollable)
+        tileSize.setWidth(std::min(std::max<int>(ceilf(boundsWithoutMargin().width() * tileGrid().scale()), kDefaultTileSize), kGiantTileSize));
+
+    LOG_WITH_STREAM(Scrolling, stream << "TileController::tileSize newSize=" << tileSize);
 
     m_tileSizeLocked = true;
     return tileSize;
index 5251ea06b5f3337ea3b784a0082638190fdd007f..c85118435257fdac689f5d4472801dd0c474a761 100644 (file)
@@ -116,7 +116,11 @@ IntRect ScrollView::unobscuredContentRect(VisibleContentRectIncludesScrollbars)
 void ScrollView::setUnobscuredContentSize(const FloatSize& size)
 {
     ASSERT(!platformWidget());
+    if (size == m_unobscuredContentSize)
+        return;
+
     m_unobscuredContentSize = size;
+    unobscuredContentSizeChanged();
 }
 
 FloatRect ScrollView::exposedContentRect() const