Title: [198502] trunk
Revision
198502
Author
simon.fra...@apple.com
Date
2016-03-21 15:25:08 -0700 (Mon, 21 Mar 2016)

Log Message

[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.

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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (198501 => 198502)


--- trunk/LayoutTests/ChangeLog	2016-03-21 22:22:16 UTC (rev 198501)
+++ trunk/LayoutTests/ChangeLog	2016-03-21 22:25:08 UTC (rev 198502)
@@ -1,3 +1,17 @@
+2016-03-21  Simon Fraser  <simon.fra...@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....@navercorp.com>
 
         [Win] Connect layoutTestController.findString() to support testing

Added: trunk/LayoutTests/platform/ios-simulator-wk2/compositing/tiling/rotated-tiled-clamped-expected.txt (0 => 198502)


--- trunk/LayoutTests/platform/ios-simulator-wk2/compositing/tiling/rotated-tiled-clamped-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/ios-simulator-wk2/compositing/tiling/rotated-tiled-clamped-expected.txt	2016-03-21 22:25:08 UTC (rev 198502)
@@ -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)
+                )
+              )
+            )
+          )
+        )
+      )
+    )
+  )
+)
+

Added: trunk/LayoutTests/platform/ios-simulator-wk2/compositing/tiling/rotated-tiled-preserve3d-clamped-expected.txt (0 => 198502)


--- trunk/LayoutTests/platform/ios-simulator-wk2/compositing/tiling/rotated-tiled-preserve3d-clamped-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/ios-simulator-wk2/compositing/tiling/rotated-tiled-preserve3d-clamped-expected.txt	2016-03-21 22:25:08 UTC (rev 198502)
@@ -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)
+                    )
+                  )
+                )
+              )
+            )
+          )
+        )
+      )
+    )
+  )
+)
+

Added: trunk/LayoutTests/platform/ios-simulator-wk2/compositing/tiling/transform-origin-tiled-expected.txt (0 => 198502)


--- trunk/LayoutTests/platform/ios-simulator-wk2/compositing/tiling/transform-origin-tiled-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/ios-simulator-wk2/compositing/tiling/transform-origin-tiled-expected.txt	2016-03-21 22:25:08 UTC (rev 198502)
@@ -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)
+                )
+              )
+            )
+          )
+        )
+      )
+    )
+  )
+)
+

Modified: trunk/Source/WebCore/ChangeLog (198501 => 198502)


--- trunk/Source/WebCore/ChangeLog	2016-03-21 22:22:16 UTC (rev 198501)
+++ trunk/Source/WebCore/ChangeLog	2016-03-21 22:25:08 UTC (rev 198502)
@@ -1,3 +1,35 @@
+2016-03-21  Simon Fraser  <simon.fra...@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  <cdu...@apple.com>
 
         Unreviewed, rolling out r197552.

Modified: trunk/Source/WebCore/page/FrameView.cpp (198501 => 198502)


--- trunk/Source/WebCore/page/FrameView.cpp	2016-03-21 22:22:16 UTC (rev 198501)
+++ trunk/Source/WebCore/page/FrameView.cpp	2016-03-21 22:25:08 UTC (rev 198502)
@@ -2136,6 +2136,13 @@
     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 @@
             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.

Modified: trunk/Source/WebCore/page/FrameView.h (198501 => 198502)


--- trunk/Source/WebCore/page/FrameView.h	2016-03-21 22:22:16 UTC (rev 198501)
+++ trunk/Source/WebCore/page/FrameView.h	2016-03-21 22:25:08 UTC (rev 198502)
@@ -510,6 +510,8 @@
 
     WEBCORE_EXPORT void availableContentSizeChanged(AvailableSizeChangeReason) override;
 
+    void adjustTiledBackingScrollability();
+
     void addPaintPendingMilestones(LayoutMilestones);
     void firePaintRelatedMilestonesIfNeeded();
     void fireLayoutRelatedMilestonesIfNeeded();
@@ -636,7 +638,12 @@
 #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;
     bool usesMockScrollAnimator() const override;

Modified: trunk/Source/WebCore/platform/ScrollView.h (198501 => 198502)


--- trunk/Source/WebCore/platform/ScrollView.h	2016-03-21 22:22:16 UTC (rev 198501)
+++ trunk/Source/WebCore/platform/ScrollView.h	2016-03-21 22:25:08 UTC (rev 198502)
@@ -419,6 +419,10 @@
 
     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;

Modified: trunk/Source/WebCore/platform/graphics/ca/TileController.cpp (198501 => 198502)


--- trunk/Source/WebCore/platform/graphics/ca/TileController.cpp	2016-03-21 22:22:16 UTC (rev 198501)
+++ trunk/Source/WebCore/platform/graphics/ca/TileController.cpp	2016-03-21 22:25:08 UTC (rev 198502)
@@ -363,8 +363,8 @@
         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,11 +494,14 @@
 
     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;
 }

Modified: trunk/Source/WebCore/platform/ios/ScrollViewIOS.mm (198501 => 198502)


--- trunk/Source/WebCore/platform/ios/ScrollViewIOS.mm	2016-03-21 22:22:16 UTC (rev 198501)
+++ trunk/Source/WebCore/platform/ios/ScrollViewIOS.mm	2016-03-21 22:25:08 UTC (rev 198502)
@@ -116,7 +116,11 @@
 void ScrollView::setUnobscuredContentSize(const FloatSize& size)
 {
     ASSERT(!platformWidget());
+    if (size == m_unobscuredContentSize)
+        return;
+
     m_unobscuredContentSize = size;
+    unobscuredContentSizeChanged();
 }
 
 FloatRect ScrollView::exposedContentRect() const
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to