Title: [178723] trunk/Source
Revision
178723
Author
simon.fra...@apple.com
Date
2015-01-20 10:40:33 -0800 (Tue, 20 Jan 2015)

Log Message

Add a way to collect scrolling performance data (viewport tile coverage) with UI-side compositing
https://bugs.webkit.org/show_bug.cgi?id=140474

Reviewed by Tim Horton.
Source/WebCore:

Add accessors for standard names for container CALayer for each of the tile grids,
and when tile grids are swapped, update those names as appropriate.

* WebCore.exp.in:
* platform/graphics/ca/TileController.cpp:
(WebCore::TileController::tileGridContainerLayerName):
(WebCore::TileController::zoomedOutTileGridContainerLayerName):
(WebCore::TileController::setContentsScale):
* platform/graphics/ca/TileController.h:
* platform/graphics/ca/TileGrid.cpp:
(WebCore::TileGrid::TileGrid):
(WebCore::TileGrid::setIsZoomedOutTileGrid):
* platform/graphics/ca/TileGrid.h:

Source/WebKit2:

Add a private method to enable scrolling data collection to WKWebView. When enabled, create
a RemoteLayerTreeScrollingPerformanceData object that collects "blank pixel" data on
every layer tree commit and scroll, and stores them in a vector. A second SPI call
allows retrieval of an NSArray of this data.

To allow RemoteLayerTreeScrollingPerformanceData to find the correct layer which
contains the main tile grid, we set a layer name on the appropriate layer (even
in release builds).

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView visibleRectInScreenCoordinates]):
(-[WKWebView _didCommitLayerTree:]):
(-[WKWebView scrollViewDidScroll:]):
(-[WKWebView _setScrollPerformanceDataCollectionEnabled:]):
(-[WKWebView _scrollPerformanceDataCollectionEnabled]):
(-[WKWebView _scrollPerformanceData]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/Cocoa/RemoteLayerTreeScrollingPerformanceData.h: Added.
(WebKit::RemoteLayerTreeScrollingPerformanceData::BlankPixelCount::BlankPixelCount):
* UIProcess/Cocoa/RemoteLayerTreeScrollingPerformanceData.mm: Added.
(WebKit::RemoteLayerTreeScrollingPerformanceData::RemoteLayerTreeScrollingPerformanceData):
(WebKit::RemoteLayerTreeScrollingPerformanceData::~RemoteLayerTreeScrollingPerformanceData):
(WebKit::RemoteLayerTreeScrollingPerformanceData::didCommitLayerTree):
(WebKit::RemoteLayerTreeScrollingPerformanceData::didScroll):
(WebKit::RemoteLayerTreeScrollingPerformanceData::BlankPixelCount::canCoalesce):
(WebKit::RemoteLayerTreeScrollingPerformanceData::appendBlankPixelCount):
(WebKit::RemoteLayerTreeScrollingPerformanceData::data):
(WebKit::findTileGridContainerLayer):
(WebKit::RemoteLayerTreeScrollingPerformanceData::blankPixelCount):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy):
(WebKit::WebPageProxy::setScrollPerformanceDataCollectionEnabled):
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::scrollPerformanceDataCollectionEnabled):
(WebKit::WebPageProxy::scrollingPerformanceData):
* WebKit2.xcodeproj/project.pbxproj:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (178722 => 178723)


--- trunk/Source/WebCore/ChangeLog	2015-01-20 18:27:48 UTC (rev 178722)
+++ trunk/Source/WebCore/ChangeLog	2015-01-20 18:40:33 UTC (rev 178723)
@@ -1,3 +1,24 @@
+2015-01-19  Simon Fraser  <simon.fra...@apple.com>
+
+        Add a way to collect scrolling performance data (viewport tile coverage) with UI-side compositing
+        https://bugs.webkit.org/show_bug.cgi?id=140474
+
+        Reviewed by Tim Horton.
+
+        Add accessors for standard names for container CALayer for each of the tile grids,
+        and when tile grids are swapped, update those names as appropriate.
+        
+        * WebCore.exp.in:
+        * platform/graphics/ca/TileController.cpp:
+        (WebCore::TileController::tileGridContainerLayerName):
+        (WebCore::TileController::zoomedOutTileGridContainerLayerName):
+        (WebCore::TileController::setContentsScale):
+        * platform/graphics/ca/TileController.h:
+        * platform/graphics/ca/TileGrid.cpp:
+        (WebCore::TileGrid::TileGrid):
+        (WebCore::TileGrid::setIsZoomedOutTileGrid):
+        * platform/graphics/ca/TileGrid.h:
+
 2015-01-20  Csaba Osztrogonác  <o...@webkit.org>
 
         Fix unused-private-field warning in IconEfl.cpp

Modified: trunk/Source/WebCore/WebCore.exp.in (178722 => 178723)


--- trunk/Source/WebCore/WebCore.exp.in	2015-01-20 18:27:48 UTC (rev 178722)
+++ trunk/Source/WebCore/WebCore.exp.in	2015-01-20 18:40:33 UTC (rev 178723)
@@ -478,6 +478,7 @@
 __ZN7WebCore14TileController21setNeedsDisplayInRectERKNS_7IntRectE
 __ZN7WebCore14TileController23setTileDebugBorderColorENS_5ColorE
 __ZN7WebCore14TileController23setTileDebugBorderWidthEf
+__ZN7WebCore14TileController26tileGridContainerLayerNameEv
 __ZN7WebCore14TileController27tileCacheLayerBoundsChangedEv
 __ZN7WebCore14TileControllerC1EPNS_15PlatformCALayerE
 __ZN7WebCore14areRangesEqualEPKNS_5RangeES2_

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


--- trunk/Source/WebCore/platform/graphics/ca/TileController.cpp	2015-01-20 18:27:48 UTC (rev 178722)
+++ trunk/Source/WebCore/platform/graphics/ca/TileController.cpp	2015-01-20 18:40:33 UTC (rev 178723)
@@ -40,6 +40,16 @@
 
 namespace WebCore {
 
+String TileController::tileGridContainerLayerName()
+{
+    return ASCIILiteral("TileGrid Container Layer");
+}
+
+String TileController::zoomedOutTileGridContainerLayerName()
+{
+    return ASCIILiteral("Zoomed Out TileGrid Container Layer");
+}
+
 TileController::TileController(PlatformCALayer* rootPlatformLayer)
     : m_tileCacheLayer(rootPlatformLayer)
     , m_tileGrid(std::make_unique<TileGrid>(*this))
@@ -113,12 +123,14 @@
 
     if (m_zoomedOutTileGrid && m_zoomedOutTileGrid->scale() == scale) {
         m_tileGrid = WTF::move(m_zoomedOutTileGrid);
+        m_tileGrid->setIsZoomedOutTileGrid(false);
         m_tileGrid->revalidateTiles(0);
         return;
     }
 
     if (m_zoomedOutContentsScale && m_zoomedOutContentsScale == tileGrid().scale() && tileGrid().scale() != scale && !m_hasTilesWithTemporaryScaleFactor) {
         m_zoomedOutTileGrid = WTF::move(m_tileGrid);
+        m_zoomedOutTileGrid->setIsZoomedOutTileGrid(true);
         m_tileGrid = std::make_unique<TileGrid>(*this);
     }
 

Modified: trunk/Source/WebCore/platform/graphics/ca/TileController.h (178722 => 178723)


--- trunk/Source/WebCore/platform/graphics/ca/TileController.h	2015-01-20 18:27:48 UTC (rev 178722)
+++ trunk/Source/WebCore/platform/graphics/ca/TileController.h	2015-01-20 18:40:33 UTC (rev 178723)
@@ -54,6 +54,9 @@
 public:
     WEBCORE_EXPORT explicit TileController(PlatformCALayer*);
     ~TileController();
+    
+    static String tileGridContainerLayerName();
+    static String zoomedOutTileGridContainerLayerName();
 
     WEBCORE_EXPORT void tileCacheLayerBoundsChanged();
 

Modified: trunk/Source/WebCore/platform/graphics/ca/TileGrid.cpp (178722 => 178723)


--- trunk/Source/WebCore/platform/graphics/ca/TileGrid.cpp	2015-01-20 18:27:48 UTC (rev 178722)
+++ trunk/Source/WebCore/platform/graphics/ca/TileGrid.cpp	2015-01-20 18:40:33 UTC (rev 178723)
@@ -45,9 +45,7 @@
     , m_scale(1)
     , m_cohortRemovalTimer(*this, &TileGrid::cohortRemovalTimerFired)
 {
-#ifndef NDEBUG
-    m_containerLayer.get().setName("TileGrid Container Layer");
-#endif
+    m_containerLayer.get().setName(TileController::tileGridContainerLayerName());
 }
 
 TileGrid::~TileGrid()
@@ -58,6 +56,14 @@
         tile.layer->setOwner(nullptr);
 }
 
+void TileGrid::setIsZoomedOutTileGrid(bool isZoomedOutGrid)
+{
+    if (isZoomedOutGrid)
+        m_containerLayer.get().setName(TileController::zoomedOutTileGridContainerLayerName());
+    else
+        m_containerLayer.get().setName(TileController::tileGridContainerLayerName());
+}
+
 void TileGrid::setScale(float scale)
 {
     m_scale = scale;

Modified: trunk/Source/WebCore/platform/graphics/ca/TileGrid.h (178722 => 178723)


--- trunk/Source/WebCore/platform/graphics/ca/TileGrid.h	2015-01-20 18:27:48 UTC (rev 178722)
+++ trunk/Source/WebCore/platform/graphics/ca/TileGrid.h	2015-01-20 18:40:33 UTC (rev 178723)
@@ -53,6 +53,8 @@
 
     PlatformCALayer& containerLayer() { return m_containerLayer; }
 
+    void setIsZoomedOutTileGrid(bool);
+
     void setScale(float);
     float scale() const { return m_scale; }
 

Modified: trunk/Source/WebKit2/ChangeLog (178722 => 178723)


--- trunk/Source/WebKit2/ChangeLog	2015-01-20 18:27:48 UTC (rev 178722)
+++ trunk/Source/WebKit2/ChangeLog	2015-01-20 18:40:33 UTC (rev 178723)
@@ -1,3 +1,47 @@
+2015-01-19  Simon Fraser  <simon.fra...@apple.com>
+
+        Add a way to collect scrolling performance data (viewport tile coverage) with UI-side compositing
+        https://bugs.webkit.org/show_bug.cgi?id=140474
+
+        Reviewed by Tim Horton.
+        
+        Add a private method to enable scrolling data collection to WKWebView. When enabled, create
+        a RemoteLayerTreeScrollingPerformanceData object that collects "blank pixel" data on
+        every layer tree commit and scroll, and stores them in a vector. A second SPI call
+        allows retrieval of an NSArray of this data.
+        
+        To allow RemoteLayerTreeScrollingPerformanceData to find the correct layer which
+        contains the main tile grid, we set a layer name on the appropriate layer (even
+        in release builds).
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView visibleRectInScreenCoordinates]):
+        (-[WKWebView _didCommitLayerTree:]):
+        (-[WKWebView scrollViewDidScroll:]):
+        (-[WKWebView _setScrollPerformanceDataCollectionEnabled:]):
+        (-[WKWebView _scrollPerformanceDataCollectionEnabled]):
+        (-[WKWebView _scrollPerformanceData]):
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+        * UIProcess/Cocoa/RemoteLayerTreeScrollingPerformanceData.h: Added.
+        (WebKit::RemoteLayerTreeScrollingPerformanceData::BlankPixelCount::BlankPixelCount):
+        * UIProcess/Cocoa/RemoteLayerTreeScrollingPerformanceData.mm: Added.
+        (WebKit::RemoteLayerTreeScrollingPerformanceData::RemoteLayerTreeScrollingPerformanceData):
+        (WebKit::RemoteLayerTreeScrollingPerformanceData::~RemoteLayerTreeScrollingPerformanceData):
+        (WebKit::RemoteLayerTreeScrollingPerformanceData::didCommitLayerTree):
+        (WebKit::RemoteLayerTreeScrollingPerformanceData::didScroll):
+        (WebKit::RemoteLayerTreeScrollingPerformanceData::BlankPixelCount::canCoalesce):
+        (WebKit::RemoteLayerTreeScrollingPerformanceData::appendBlankPixelCount):
+        (WebKit::RemoteLayerTreeScrollingPerformanceData::data):
+        (WebKit::findTileGridContainerLayer):
+        (WebKit::RemoteLayerTreeScrollingPerformanceData::blankPixelCount):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::WebPageProxy):
+        (WebKit::WebPageProxy::setScrollPerformanceDataCollectionEnabled):
+        * UIProcess/WebPageProxy.h:
+        (WebKit::WebPageProxy::scrollPerformanceDataCollectionEnabled):
+        (WebKit::WebPageProxy::scrollingPerformanceData):
+        * WebKit2.xcodeproj/project.pbxproj:
+
 2015-01-19  Dean Jackson  <d...@apple.com>
 
         Support "plus-darker" in mix-blend mode

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (178722 => 178723)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2015-01-20 18:27:48 UTC (rev 178722)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2015-01-20 18:40:33 UTC (rev 178723)
@@ -35,6 +35,7 @@
 #import "FindClient.h"
 #import "LegacySessionStateCoding.h"
 #import "NavigationState.h"
+#import "RemoteLayerTreeScrollingPerformanceData.h"
 #import "RemoteLayerTreeTransaction.h"
 #import "RemoteObjectRegistry.h"
 #import "RemoteObjectRegistryMessages.h"
@@ -848,6 +849,15 @@
     scrollView.contentOffset = contentOffsetBoundedInValidRange(scrollView, contentOffset);
 }
 
+- (WebCore::FloatRect)visibleRectInViewCoordinates
+{
+    WebCore::FloatRect bounds = self.bounds;
+    bounds.moveBy([_scrollView contentOffset]);
+    WebCore::FloatRect contentViewBounds = [_contentView bounds];
+    bounds.intersect(contentViewBounds);
+    return bounds;
+}
+
 // WebCore stores the page scale factor as float instead of double. When we get a scale from WebCore,
 // we need to ignore differences that are within a small rounding error on floats.
 static inline bool areEssentiallyEqualAsFloat(float a, float b)
@@ -918,6 +928,9 @@
         }
         [self _updateVisibleContentRects];
     }
+    
+    if (WebKit::RemoteLayerTreeScrollingPerformanceData* scrollPerfData = _page->scrollingPerformanceData())
+        scrollPerfData->didCommitLayerTree([self visibleRectInViewCoordinates]);
 }
 
 - (void)_dynamicViewportUpdateChangedTargetToScale:(double)newScale position:(CGPoint)newScrollPosition nextValidLayerTreeTransactionID:(uint64_t)nextValidLayerTreeTransactionID
@@ -1376,6 +1389,9 @@
         [_customContentView scrollViewDidScroll:(UIScrollView *)scrollView];
 
     [self _updateVisibleContentRects];
+    
+    if (WebKit::RemoteLayerTreeScrollingPerformanceData* scrollPerfData = _page->scrollingPerformanceData())
+        scrollPerfData->didScroll([self visibleRectInViewCoordinates]);
 }
 
 - (void)scrollViewDidZoom:(UIScrollView *)scrollView
@@ -2114,6 +2130,27 @@
     return _page->isShowingNavigationGestureSnapshot();
 }
 
+#pragma mark scrollperf methods
+
+- (void)_setScrollPerformanceDataCollectionEnabled:(BOOL)enabled
+{
+    _page->setScrollPerformanceDataCollectionEnabled(enabled);
+}
+
+- (BOOL)_scrollPerformanceDataCollectionEnabled
+{
+    return _page->scrollPerformanceDataCollectionEnabled();
+}
+
+- (NSArray *)_scrollPerformanceData
+{
+#if PLATFORM(IOS)
+    if (WebKit::RemoteLayerTreeScrollingPerformanceData* scrollPefData = _page->scrollingPerformanceData())
+        return scrollPefData->data();
+#endif
+    return nil;
+}
+
 #pragma mark iOS-specific methods
 
 #if PLATFORM(IOS)

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h (178722 => 178723)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h	2015-01-20 18:27:48 UTC (rev 178722)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h	2015-01-20 18:40:33 UTC (rev 178723)
@@ -186,6 +186,9 @@
 
 @property (nonatomic, readonly, getter=_isDisplayingStandaloneImageDocument) BOOL _displayingStandaloneImageDocument;
 
+@property (nonatomic, setter=_setScrollPerformanceDataCollectionEnabled:) BOOL _scrollPerformanceDataCollectionEnabled WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
+@property (nonatomic, readonly) NSArray *_scrollPerformanceData WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
+
 @end
 
 #endif

Added: trunk/Source/WebKit2/UIProcess/Cocoa/RemoteLayerTreeScrollingPerformanceData.h (0 => 178723)


--- trunk/Source/WebKit2/UIProcess/Cocoa/RemoteLayerTreeScrollingPerformanceData.h	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/RemoteLayerTreeScrollingPerformanceData.h	2015-01-20 18:40:33 UTC (rev 178723)
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#ifndef RemoteLayerTreeScrollingPerformanceData_h
+#define RemoteLayerTreeScrollingPerformanceData_h
+
+#import <WebCore/FloatRect.h>
+#import <wtf/Vector.h>
+
+namespace WebKit {
+
+class RemoteLayerTreeDrawingAreaProxy;
+
+class RemoteLayerTreeScrollingPerformanceData {
+public:
+    RemoteLayerTreeScrollingPerformanceData(RemoteLayerTreeDrawingAreaProxy&);
+    ~RemoteLayerTreeScrollingPerformanceData();
+
+    void didCommitLayerTree(const WebCore::FloatRect& visibleRect);
+    void didScroll(const WebCore::FloatRect& visibleRect);
+
+    NSArray *data(); // Array of [ time, event type, unfilled pixel count ]
+
+private:
+    unsigned blankPixelCount(const WebCore::FloatRect& visibleRect) const;
+    
+    struct BlankPixelCount {
+        enum EventType { Filled, Exposed };
+
+        double startTime;
+        double endTime;
+        EventType eventType;
+        unsigned blankPixelCount;
+        
+        BlankPixelCount(double start, double end, EventType type, unsigned count)
+            : startTime(start)
+            , endTime(end)
+            , eventType(type)
+            , blankPixelCount(count)
+        { }
+        
+        bool canCoalesce(BlankPixelCount::EventType, unsigned blankPixelCount) const;
+    };
+    
+    void appendBlankPixelCount(BlankPixelCount::EventType, unsigned blankPixelCount);
+
+    RemoteLayerTreeDrawingAreaProxy& m_drawingArea;
+    Vector<BlankPixelCount> m_blankPixelCounts;
+};
+
+}
+
+#endif // RemoteLayerTreeScrollingPerformanceData_h

Added: trunk/Source/WebKit2/UIProcess/Cocoa/RemoteLayerTreeScrollingPerformanceData.mm (0 => 178723)


--- trunk/Source/WebKit2/UIProcess/Cocoa/RemoteLayerTreeScrollingPerformanceData.mm	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/RemoteLayerTreeScrollingPerformanceData.mm	2015-01-20 18:40:33 UTC (rev 178723)
@@ -0,0 +1,135 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "RemoteLayerTreeScrollingPerformanceData.h"
+
+#import "RemoteLayerTreeDrawingAreaProxy.h"
+#import "RemoteLayerTreeHost.h"
+#import <QuartzCore/CALayer.h>
+#import <WebCore/TileController.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+
+RemoteLayerTreeScrollingPerformanceData::RemoteLayerTreeScrollingPerformanceData(RemoteLayerTreeDrawingAreaProxy& drawingArea)
+    : m_drawingArea(drawingArea)
+{
+}
+
+RemoteLayerTreeScrollingPerformanceData::~RemoteLayerTreeScrollingPerformanceData()
+{
+}
+
+void RemoteLayerTreeScrollingPerformanceData::didCommitLayerTree(const FloatRect& visibleRect)
+{
+    // FIXME: maybe we only care about newly created tiles?
+    appendBlankPixelCount(BlankPixelCount::Filled, blankPixelCount(visibleRect));
+}
+
+void RemoteLayerTreeScrollingPerformanceData::didScroll(const FloatRect& visibleRect)
+{
+    appendBlankPixelCount(BlankPixelCount::Exposed, blankPixelCount(visibleRect));
+}
+
+bool RemoteLayerTreeScrollingPerformanceData::BlankPixelCount::canCoalesce(BlankPixelCount::EventType type, unsigned pixelCount) const
+{
+    return eventType == type && blankPixelCount == pixelCount;
+}
+
+void RemoteLayerTreeScrollingPerformanceData::appendBlankPixelCount(BlankPixelCount::EventType eventType, unsigned blankPixelCount)
+{
+    double now = WTF::monotonicallyIncreasingTime();
+
+    if (!m_blankPixelCounts.isEmpty() && m_blankPixelCounts.last().canCoalesce(eventType, blankPixelCount)) {
+        m_blankPixelCounts.last().endTime = now;
+        return;
+    }
+
+    m_blankPixelCounts.append(BlankPixelCount(now, now, eventType, blankPixelCount));
+}
+
+NSArray *RemoteLayerTreeScrollingPerformanceData::data()
+{
+    NSMutableArray* dataArray = [NSMutableArray arrayWithCapacity:m_blankPixelCounts.size()];
+    
+    for (auto pixelData : m_blankPixelCounts) {
+        [dataArray addObject:@[
+            @(pixelData.startTime),
+            (pixelData.eventType == BlankPixelCount::Filled) ? @"filled" : @"exposed",
+            @(pixelData.blankPixelCount)
+        ]];
+    }
+    return dataArray;
+}
+
+static CALayer *findTileGridContainerLayer(CALayer *layer)
+{
+    for (CALayer *currLayer : [layer sublayers]) {
+        String layerName = [currLayer name];
+        if (layerName == TileController::tileGridContainerLayerName())
+            return currLayer;
+
+        if (CALayer *foundLayer = findTileGridContainerLayer(currLayer))
+            return foundLayer;
+    }
+
+    return nil;
+}
+
+unsigned RemoteLayerTreeScrollingPerformanceData::blankPixelCount(const FloatRect& visibleRect) const
+{
+    CALayer *rootLayer = asLayer(m_drawingArea.remoteLayerTreeHost().rootLayer());
+
+    CALayer *tileGridContainer = findTileGridContainerLayer(rootLayer);
+    if (!tileGridContainer) {
+        NSLog(@"Failed to find TileGrid Container Layer");
+        return UINT_MAX;
+    }
+
+    FloatRect visibleRectExcludingToolbar = visibleRect;
+    if (visibleRectExcludingToolbar.y() < 0)
+        visibleRectExcludingToolbar.setY(0);
+
+    Region paintedVisibleTileRegion;
+
+    for (CALayer *tileLayer : [tileGridContainer sublayers]) {
+        FloatRect tileRect = [tileLayer convertRect:[tileLayer bounds] toLayer:tileGridContainer];
+    
+        tileRect.intersect(visibleRectExcludingToolbar);
+        
+        if (!tileRect.isEmpty())
+            paintedVisibleTileRegion.unite(enclosingIntRect(tileRect));
+    }
+
+    Region uncoveredRegion(enclosingIntRect(visibleRectExcludingToolbar));
+    uncoveredRegion.subtract(paintedVisibleTileRegion);
+
+    return uncoveredRegion.totalArea();
+}
+
+}

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (178722 => 178723)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2015-01-20 18:27:48 UTC (rev 178722)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2015-01-20 18:40:33 UTC (rev 178723)
@@ -128,12 +128,13 @@
 #endif
 
 #if PLATFORM(COCOA)
+#include "RemoteLayerTreeDrawingAreaProxy.h"
+#include "RemoteLayerTreeScrollingPerformanceData.h"
 #include "ViewSnapshotStore.h"
 #include <WebCore/RunLoopObserver.h>
 #endif
 
 #if PLATFORM(IOS)
-#include "RemoteLayerTreeDrawingAreaProxy.h"
 #include "WebVideoFullscreenManagerProxy.h"
 #include "WebVideoFullscreenManagerProxyMessages.h"
 #endif
@@ -378,6 +379,10 @@
     , m_mediaVolume(1)
     , m_muted(false)
     , m_mayStartMediaWhenInWindow(true)
+    , m_waitingForDidUpdateViewState(false)
+#if PLATFORM(COCOA)
+    , m_scrollPerformanceDataCollectionEnabled(false)
+#endif
     , m_scrollPinningBehavior(DoNotPin)
     , m_navigationID(0)
     , m_configurationPreferenceValues(configuration.preferenceValues)
@@ -5336,6 +5341,18 @@
     process().send(Messages::WebPage::ConfirmCompositionAsync(), m_pageID);
 }
 
+void WebPageProxy::setScrollPerformanceDataCollectionEnabled(bool enabled)
+{
+    if (enabled == m_scrollPerformanceDataCollectionEnabled)
+        return;
+
+    m_scrollPerformanceDataCollectionEnabled = enabled;
+
+    if (m_scrollPerformanceDataCollectionEnabled && !m_scrollingPerformanceData)
+        m_scrollingPerformanceData = std::make_unique<RemoteLayerTreeScrollingPerformanceData>(downcast<RemoteLayerTreeDrawingAreaProxy>(*m_drawingArea));
+    else if (!m_scrollPerformanceDataCollectionEnabled)
+        m_scrollingPerformanceData = nullptr;
+}
 #endif
 
 void WebPageProxy::takeSnapshot(IntRect rect, IntSize bitmapSize, SnapshotOptions options, std::function<void (const ShareableBitmap::Handle&, CallbackBase::Error)> callbackFunction)

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (178722 => 178723)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2015-01-20 18:27:48 UTC (rev 178722)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2015-01-20 18:40:33 UTC (rev 178723)
@@ -161,6 +161,7 @@
 class NativeWebMouseEvent;
 class NativeWebWheelEvent;
 class PageClient;
+class RemoteLayerTreeScrollingPerformanceData;
 class RemoteLayerTreeTransaction;
 class RemoteScrollingCoordinatorProxy;
 class StringPairVector;
@@ -527,6 +528,11 @@
     void setCompositionAsync(const String& text, Vector<WebCore::CompositionUnderline> underlines, const EditingRange& selectionRange, const EditingRange& replacementRange);
     void confirmCompositionAsync();
 
+    void setScrollPerformanceDataCollectionEnabled(bool);
+    bool scrollPerformanceDataCollectionEnabled() const { return m_scrollPerformanceDataCollectionEnabled; }
+    RemoteLayerTreeScrollingPerformanceData* scrollingPerformanceData() { return m_scrollingPerformanceData.get(); }
+#endif // PLATFORM(COCOA)
+
 #if PLATFORM(MAC)
     void insertDictatedTextAsync(const String& text, const EditingRange& replacementRange, const Vector<WebCore::TextAlternativeWithRange>& dictationAlternatives, bool registerUndoGroup);
     void attributedSubstringForCharacterRangeAsync(const EditingRange&, std::function<void (const AttributedString&, const EditingRange&, CallbackBase::Error)>);
@@ -543,24 +549,26 @@
     WebCore::IntRect firstRectForCharacterRange(const EditingRange&);
     bool executeKeypressCommands(const Vector<WebCore::KeypressCommand>&);
     void cancelComposition();
-#endif
+#endif // !USE(ASYNC_NSTEXTINPUTCLIENT)
 
     WKView* wkView() const;
     void intrinsicContentSizeDidChange(const WebCore::IntSize& intrinsicContentSize);
     CGRect boundsOfLayerInLayerBackedWindowCoordinates(CALayer *) const;
-#endif
-#endif // PLATFORM(COCOA)
+#endif // PLATFORM(MAC)
+
 #if PLATFORM(EFL)
     void handleInputMethodKeydown(bool& handled);
     void confirmComposition(const String&);
     void setComposition(const String&, Vector<WebCore::CompositionUnderline>&, int);
     void cancelComposition();
 #endif
+
 #if PLATFORM(GTK)
     PlatformWidget viewWidget();
     const WebCore::Color& backgroundColor() const { return m_backgroundColor; }
     void setBackgroundColor(const WebCore::Color& color) { m_backgroundColor = color; }
 #endif
+
 #if USE(COORDINATED_GRAPHICS_MULTIPROCESS)
     void commitPageTransitionViewport();
 #endif
@@ -568,9 +576,11 @@
     void handleMouseEvent(const NativeWebMouseEvent&);
     void handleWheelEvent(const NativeWebWheelEvent&);
     void handleKeyboardEvent(const NativeWebKeyboardEvent&);
+
 #if ENABLE(IOS_TOUCH_EVENTS)
     void handleTouchEventSynchronously(const NativeWebTouchEvent&);
     void handleTouchEventAsynchronously(const NativeWebTouchEvent&);
+
 #elif ENABLE(TOUCH_EVENTS)
     void handleTouchEvent(const NativeWebTouchEvent&);
 #endif
@@ -1617,6 +1627,9 @@
 #if PLATFORM(COCOA)
     HashMap<String, String> m_temporaryPDFFiles;
     std::unique_ptr<WebCore::RunLoopObserver> m_viewStateChangeDispatcher;
+
+    std::unique_ptr<RemoteLayerTreeScrollingPerformanceData> m_scrollingPerformanceData;
+    bool m_scrollPerformanceDataCollectionEnabled;
 #endif
     UserObservablePageToken m_pageIsUserObservableCount;
     ProcessSuppressionDisabledToken m_preventProcessSuppressionCount;

Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (178722 => 178723)


--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2015-01-20 18:27:48 UTC (rev 178722)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2015-01-20 18:40:33 UTC (rev 178723)
@@ -120,6 +120,8 @@
 		0FCB4E6D18BBF26A000FCFC9 /* WKContentViewInteraction.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0FCB4E6B18BBF26A000FCFC9 /* WKContentViewInteraction.mm */; };
 		0FF24A2D1879E4BC003ABF0C /* RemoteLayerTreeDrawingAreaProxyMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FF24A2B1879E4BC003ABF0C /* RemoteLayerTreeDrawingAreaProxyMessageReceiver.cpp */; };
 		0FF24A2E1879E4BC003ABF0C /* RemoteLayerTreeDrawingAreaProxyMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FF24A2C1879E4BC003ABF0C /* RemoteLayerTreeDrawingAreaProxyMessages.h */; };
+		0FF2649F1A1FF9C6001FE759 /* RemoteLayerTreeScrollingPerformanceData.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F707C771A1FEE8300DA7A45 /* RemoteLayerTreeScrollingPerformanceData.mm */; };
+		0FF264A01A1FF9CC001FE759 /* RemoteLayerTreeScrollingPerformanceData.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F707C791A1FEEA300DA7A45 /* RemoteLayerTreeScrollingPerformanceData.h */; };
 		1A002D43196B337000B9AD44 /* _WKSessionStateInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A002D42196B337000B9AD44 /* _WKSessionStateInternal.h */; };
 		1A002D44196B338900B9AD44 /* _WKSessionState.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A002D3F196B329400B9AD44 /* _WKSessionState.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		1A002D45196B338E00B9AD44 /* _WKSessionState.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A002D3E196B329400B9AD44 /* _WKSessionState.mm */; };
@@ -2111,6 +2113,8 @@
 		0F5947A6187B517600437857 /* RemoteScrollingCoordinatorMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteScrollingCoordinatorMessages.h; sourceTree = "<group>"; };
 		0F5E200118E77051003EC3E5 /* PlatformCAAnimationRemote.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PlatformCAAnimationRemote.mm; sourceTree = "<group>"; };
 		0F5E200218E77051003EC3E5 /* PlatformCAAnimationRemote.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformCAAnimationRemote.h; sourceTree = "<group>"; };
+		0F707C771A1FEE8300DA7A45 /* RemoteLayerTreeScrollingPerformanceData.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RemoteLayerTreeScrollingPerformanceData.mm; sourceTree = "<group>"; };
+		0F707C791A1FEEA300DA7A45 /* RemoteLayerTreeScrollingPerformanceData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteLayerTreeScrollingPerformanceData.h; sourceTree = "<group>"; };
 		0F931C1A18C5711900DBA7C3 /* ScrollingTreeOverflowScrollingNodeIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ScrollingTreeOverflowScrollingNodeIOS.h; path = Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.h; sourceTree = "<group>"; };
 		0F931C1B18C5711900DBA7C3 /* ScrollingTreeOverflowScrollingNodeIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ScrollingTreeOverflowScrollingNodeIOS.mm; path = Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm; sourceTree = "<group>"; };
 		0FB659221208B4DB0044816C /* DrawingAreaInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DrawingAreaInfo.h; sourceTree = "<group>"; };
@@ -4767,6 +4771,8 @@
 				1ABC3DF31899E437004F0626 /* NavigationState.mm */,
 				1A002D47196B345D00B9AD44 /* SessionStateCoding.h */,
 				1A002D46196B345D00B9AD44 /* SessionStateCoding.mm */,
+				0F707C791A1FEEA300DA7A45 /* RemoteLayerTreeScrollingPerformanceData.h */,
+				0F707C771A1FEE8300DA7A45 /* RemoteLayerTreeScrollingPerformanceData.mm */,
 				1AFE436418B6C081009C7A48 /* UIDelegate.h */,
 				1AFE436318B6C081009C7A48 /* UIDelegate.mm */,
 				1AC0273E196622D600C12B75 /* WebPageProxyCocoa.mm */,
@@ -7765,6 +7771,7 @@
 				BCE469561214E6CB000B98EB /* WebFormSubmissionListenerProxy.h in Headers */,
 				BC032D8D10F437A00058C15A /* WebFrame.h in Headers */,
 				BCE469771214F27B000B98EB /* WebFrameListenerProxy.h in Headers */,
+				0FF264A01A1FF9CC001FE759 /* RemoteLayerTreeScrollingPerformanceData.h in Headers */,
 				BC032D7F10F4378D0058C15A /* WebFrameLoaderClient.h in Headers */,
 				9391F2CB121B67AD00EBF7E8 /* WebFrameNetworkingContext.h in Headers */,
 				BCB9F6A01123A84B00A137E0 /* WebFramePolicyListenerProxy.h in Headers */,
@@ -9363,6 +9370,7 @@
 				1AA3D75B1651B44F008713D0 /* RemoteLayerTreeHost.mm in Sources */,
 				0F0C365818C051BA00F607D7 /* RemoteLayerTreeHostIOS.mm in Sources */,
 				2DDE0AFB18298CC900F97EAA /* RemoteLayerTreePropertyApplier.mm in Sources */,
+				0FF2649F1A1FF9C6001FE759 /* RemoteLayerTreeScrollingPerformanceData.mm in Sources */,
 				1AF1AC6B1651759E00C17D7F /* RemoteLayerTreeTransaction.mm in Sources */,
 				E1B78473163F253E0007B692 /* RemoteNetworkingContext.mm in Sources */,
 				1AC1337F18590AE400F3EC05 /* RemoteObjectRegistry.mm in Sources */,
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to