Title: [125156] trunk/Source
Revision
125156
Author
timothy_hor...@apple.com
Date
2012-08-09 00:26:35 -0700 (Thu, 09 Aug 2012)

Log Message

Add optional debug logging for tiled scrolling
https://bugs.webkit.org/show_bug.cgi?id=93305

Reviewed by Simon Fraser.

Add scrolling performance logging to ScrollingTreeNodeMac and WebTileLayer, which will log
the amount of unpainted area exposed during scrolling and painting, respectively.

The logging output looks like this:

    SCROLLING: Exposed tileless area. Time: 1344464850.154839 Unfilled Pixels: 1122008
    SCROLLING: Filled visible fresh tile. Time: 1344464850.575303 Unfilled Pixels: 1078272
    SCROLLING: Filled visible fresh tile. Time: 1344464850.676569 Unfilled Pixels: 823808
    SCROLLING: Filled visible fresh tile. Time: 1344464850.795877 Unfilled Pixels: 569344
    SCROLLING: Filled visible fresh tile. Time: 1344464850.846940 Unfilled Pixels: 524288
    SCROLLING: Filled visible fresh tile. Time: 1344464850.984113 Unfilled Pixels: 262144
    SCROLLING: Filled visible fresh tile. Time: 1344464851.027985 Unfilled Pixels: 0

No new tests, as this is just debugging logging.

* WebCore.exp.in:
* page/FrameView.cpp:
(WebCore::FrameView::setScrollingPerformanceLoggingEnabled):
Added setScrollingPerformanceLoggingEnabled, passes flag into TiledBacking.

* page/FrameView.h:
* page/Settings.cpp:
(WebCore::Settings::Settings):
(WebCore::Settings::setScrollingPerformanceLoggingEnabled):
Added setScrollingPerformanceLoggingEnabled, passes flag into FrameView.

* page/Settings.h:
(WebCore::Settings::scrollingPerformanceLoggingEnabled):
* page/scrolling/ScrollingTree.cpp:
(WebCore::ScrollingTree::ScrollingTree):
(WebCore::ScrollingTree::setScrollingPerformanceLoggingEnabled):
(WebCore::ScrollingTree::scrollingPeformanceLoggingEnabled):
Added ScrollingPerformanceLoggingEnabled setter/getter; this is where it's accessed from ScrollingTreeNodeMac.

* page/scrolling/ScrollingTree.h:
* page/scrolling/mac/ScrollingTreeNodeMac.h:
(ScrollingTreeNodeMac):
* page/scrolling/mac/ScrollingTreeNodeMac.mm:
(WebCore::ScrollingTreeNodeMac::setScrollPosition):
When updating scroll position, conditionally log the amount of unpainted area that was just exposed.

(WebCore::ScrollingTreeNodeMac::logExposedTilelessArea):
* platform/graphics/TiledBacking.h:
(WebCore::TiledBacking::TiledBacking):
(WebCore::TiledBacking::setScrollingPerformanceLoggingEnabled):
(WebCore::TiledBacking::scrollingPerformanceLoggingEnabled):
Added ScrollingPerformanceLoggingEnabled setter/getter; this is where it's accessed from WebTileLayer.

* platform/graphics/ca/mac/TileCache.h:
(WebCore::TileCache::visibleRect):
* platform/graphics/ca/mac/TileCache.mm:
(WebCore::TileCache::blankPixelCount):
(WebCore::TileCache::blankPixelCountForTiles):
Compute the exposed, unpainted area of the tile cache by iterating over the layers,
checking if they've been painted, and subtracting painted layers from the total visible area.

* platform/graphics/ca/mac/WebTileLayer.h:
* platform/graphics/ca/mac/WebTileLayer.mm:
(-[WebTileLayer drawInContext:]):
(-[WebTileLayer repaintCount]):
(-[WebTileLayer logFilledFreshTile]):
When painting a WebTileLayer, conditionally log the amount of unpainted area remaining after painting said tile.

* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::RenderLayerBacking):
Plumb ScrollingPerformanceLoggingEnabled through to TiledBacking.

Add a new boolean preference, ScrollingPerformanceLoggingEnabled, which will be used to toggle
the WebCore parts of this change.

* Shared/WebPreferencesStore.h: Add ScrollingPerformanceLoggingEnabled.
* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesSetScrollingPerformanceLoggingEnabled): Added.
(WKPreferencesGetScrollingPerformanceLoggingEnabled): Added.
* UIProcess/API/C/WKPreferencesPrivate.h: Add getters and setters for ScrollingPerformanceLoggingEnabled.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage): Add ScrollingPerformanceLoggingEnabled.
(WebKit::WebPage::updatePreferences): Add ScrollingPerformanceLoggingEnabled.
(WebKit::WebPage::setScrollingPerformanceLoggingEnabled): Propagate settings changes through to FrameView.
* WebProcess/WebPage/WebPage.h:
(WebKit::WebPage::scrollingPerformanceLoggingEnabled): Add a getter for the setting so that TiledCoreAnimationDrawingArea can access it.
* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
(WebKit::TiledCoreAnimationDrawingArea::updatePreferences): Pass ScrollingPerformanceLoggingEnabled down into the scrolling thread.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (125155 => 125156)


--- trunk/Source/WebCore/ChangeLog	2012-08-09 06:39:05 UTC (rev 125155)
+++ trunk/Source/WebCore/ChangeLog	2012-08-09 07:26:35 UTC (rev 125156)
@@ -1,3 +1,77 @@
+2012-08-09  Tim Horton  <timothy_hor...@apple.com>
+
+        Add optional debug logging for tiled scrolling
+        https://bugs.webkit.org/show_bug.cgi?id=93305
+
+        Reviewed by Simon Fraser.
+
+        Add scrolling performance logging to ScrollingTreeNodeMac and WebTileLayer, which will log
+        the amount of unpainted area exposed during scrolling and painting, respectively.
+
+        The logging output looks like this:
+
+            SCROLLING: Exposed tileless area. Time: 1344464850.154839 Unfilled Pixels: 1122008
+            SCROLLING: Filled visible fresh tile. Time: 1344464850.575303 Unfilled Pixels: 1078272
+            SCROLLING: Filled visible fresh tile. Time: 1344464850.676569 Unfilled Pixels: 823808
+            SCROLLING: Filled visible fresh tile. Time: 1344464850.795877 Unfilled Pixels: 569344
+            SCROLLING: Filled visible fresh tile. Time: 1344464850.846940 Unfilled Pixels: 524288
+            SCROLLING: Filled visible fresh tile. Time: 1344464850.984113 Unfilled Pixels: 262144
+            SCROLLING: Filled visible fresh tile. Time: 1344464851.027985 Unfilled Pixels: 0
+
+        No new tests, as this is just debugging logging.
+
+        * WebCore.exp.in:
+        * page/FrameView.cpp:
+        (WebCore::FrameView::setScrollingPerformanceLoggingEnabled):
+        Added setScrollingPerformanceLoggingEnabled, passes flag into TiledBacking.
+
+        * page/FrameView.h:
+        * page/Settings.cpp:
+        (WebCore::Settings::Settings):
+        (WebCore::Settings::setScrollingPerformanceLoggingEnabled):
+        Added setScrollingPerformanceLoggingEnabled, passes flag into FrameView.
+
+        * page/Settings.h:
+        (WebCore::Settings::scrollingPerformanceLoggingEnabled):
+        * page/scrolling/ScrollingTree.cpp:
+        (WebCore::ScrollingTree::ScrollingTree):
+        (WebCore::ScrollingTree::setScrollingPerformanceLoggingEnabled):
+        (WebCore::ScrollingTree::scrollingPeformanceLoggingEnabled):
+        Added ScrollingPerformanceLoggingEnabled setter/getter; this is where it's accessed from ScrollingTreeNodeMac.
+
+        * page/scrolling/ScrollingTree.h:
+        * page/scrolling/mac/ScrollingTreeNodeMac.h:
+        (ScrollingTreeNodeMac):
+        * page/scrolling/mac/ScrollingTreeNodeMac.mm:
+        (WebCore::ScrollingTreeNodeMac::setScrollPosition):
+        When updating scroll position, conditionally log the amount of unpainted area that was just exposed.
+
+        (WebCore::ScrollingTreeNodeMac::logExposedTilelessArea):
+        * platform/graphics/TiledBacking.h:
+        (WebCore::TiledBacking::TiledBacking):
+        (WebCore::TiledBacking::setScrollingPerformanceLoggingEnabled):
+        (WebCore::TiledBacking::scrollingPerformanceLoggingEnabled):
+        Added ScrollingPerformanceLoggingEnabled setter/getter; this is where it's accessed from WebTileLayer.
+
+        * platform/graphics/ca/mac/TileCache.h:
+        (WebCore::TileCache::visibleRect):
+        * platform/graphics/ca/mac/TileCache.mm:
+        (WebCore::TileCache::blankPixelCount):
+        (WebCore::TileCache::blankPixelCountForTiles):
+        Compute the exposed, unpainted area of the tile cache by iterating over the layers,
+        checking if they've been painted, and subtracting painted layers from the total visible area.
+
+        * platform/graphics/ca/mac/WebTileLayer.h:
+        * platform/graphics/ca/mac/WebTileLayer.mm:
+        (-[WebTileLayer drawInContext:]):
+        (-[WebTileLayer repaintCount]):
+        (-[WebTileLayer logFilledFreshTile]):
+        When painting a WebTileLayer, conditionally log the amount of unpainted area remaining after painting said tile.
+
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::RenderLayerBacking):
+        Plumb ScrollingPerformanceLoggingEnabled through to TiledBacking.
+
 2012-08-08  Alpha Lam  <hc...@chromium.org>
 
         Remove image decoding in some BitmapImage metadata functions

Modified: trunk/Source/WebCore/WebCore.exp.in (125155 => 125156)


--- trunk/Source/WebCore/WebCore.exp.in	2012-08-09 06:39:05 UTC (rev 125155)
+++ trunk/Source/WebCore/WebCore.exp.in	2012-08-09 07:26:35 UTC (rev 125156)
@@ -914,6 +914,7 @@
 __ZN7WebCore8Settings35setTreatsAnyTextCSSLinkAsStylesheetEb
 __ZN7WebCore8Settings36setOfflineWebApplicationCacheEnabledEb
 __ZN7WebCore8Settings37setFixedElementsLayoutRelativeToFrameEb
+__ZN7WebCore8Settings37setScrollingPerformanceLoggingEnabledEb
 __ZN7WebCore8Settings40setJavaScriptCanOpenWindowsAutomaticallyEb
 __ZN7WebCore8Settings40setTextDirectionSubmenuInclusionBehaviorENS_37TextDirectionSubmenuInclusionBehaviorE
 __ZN7WebCore8Settings41setNeedsKeyboardEventDisambiguationQuirksEb
@@ -959,6 +960,7 @@
 __ZN7WebCore9FrameView26adjustPageHeightDeprecatedEPffff
 __ZN7WebCore9FrameView29setShouldUpdateWhileOffscreenEb
 __ZN7WebCore9FrameView37updateLayoutAndStyleIfNeededRecursiveEv
+__ZN7WebCore9FrameView37setScrollingPerformanceLoggingEnabledEb
 __ZN7WebCore9FrameView38scrollPositionChangedViaPlatformWidgetEv
 __ZN7WebCore9FrameView38syncCompositingStateIncludingSubframesEv
 __ZN7WebCore9FrameView6createEPNS_5FrameE
@@ -2502,6 +2504,7 @@
 
 #if ENABLE(THREADED_SCROLLING)
 __ZN7WebCore13ScrollingTree17setDebugRootLayerEP7CALayer
+__ZN7WebCore13ScrollingTree37setScrollingPerformanceLoggingEnabledEb
 __ZN7WebCore13ScrollingTree21tryToHandleWheelEventERKNS_18PlatformWheelEventE
 __ZN7WebCore13ScrollingTree22updateBackForwardStateEbb
 __ZN7WebCore13ScrollingTreeD1Ev

Modified: trunk/Source/WebCore/page/FrameView.cpp (125155 => 125156)


--- trunk/Source/WebCore/page/FrameView.cpp	2012-08-09 06:39:05 UTC (rev 125155)
+++ trunk/Source/WebCore/page/FrameView.cpp	2012-08-09 07:26:35 UTC (rev 125156)
@@ -3601,4 +3601,12 @@
     return 0;
 }
     
+void FrameView::setScrollingPerformanceLoggingEnabled(bool flag)
+{
+#if USE(ACCELERATED_COMPOSITING)
+    if (TiledBacking* tiledBacking = this->tiledBacking())
+        tiledBacking->setScrollingPerformanceLoggingEnabled(flag);
+#endif
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/page/FrameView.h (125155 => 125156)


--- trunk/Source/WebCore/page/FrameView.h	2012-08-09 06:39:05 UTC (rev 125155)
+++ trunk/Source/WebCore/page/FrameView.h	2012-08-09 07:26:35 UTC (rev 125156)
@@ -342,6 +342,8 @@
     // we need this function in order to do the scroll ourselves.
     bool wheelEvent(const PlatformWheelEvent&);
 
+    void setScrollingPerformanceLoggingEnabled(bool);
+
 protected:
     virtual bool scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect);
     virtual void scrollContentsSlowPath(const IntRect& updateRect);

Modified: trunk/Source/WebCore/page/Settings.cpp (125155 => 125156)


--- trunk/Source/WebCore/page/Settings.cpp	2012-08-09 06:39:05 UTC (rev 125155)
+++ trunk/Source/WebCore/page/Settings.cpp	2012-08-09 07:26:35 UTC (rev 125156)
@@ -285,6 +285,7 @@
     , m_windowFocusRestricted(true)
     , m_diagnosticLoggingEnabled(false)
     , m_thirdPartyStorageBlockingEnabled(false)
+    , m_scrollingPerformanceLoggingEnabled(false)
     , m_loadsImagesAutomaticallyTimer(this, &Settings::loadsImagesAutomaticallyTimerFired)
     , m_incrementalRenderingSuppressionTimeoutInSeconds(defaultIncrementalRenderingSuppressionTimeoutInSeconds)
 {
@@ -939,6 +940,14 @@
 #endif
 }
 
+void Settings::setScrollingPerformanceLoggingEnabled(bool enabled)
+{
+    m_scrollingPerformanceLoggingEnabled = enabled;
+
+    if (m_page->mainFrame() && m_page->mainFrame()->view())
+        m_page->mainFrame()->view()->setScrollingPerformanceLoggingEnabled(enabled);
+}
+
 void Settings::setMockScrollbarsEnabled(bool flag)
 {
     gMockScrollbarsEnabled = flag;

Modified: trunk/Source/WebCore/page/Settings.h (125155 => 125156)


--- trunk/Source/WebCore/page/Settings.h	2012-08-09 06:39:05 UTC (rev 125155)
+++ trunk/Source/WebCore/page/Settings.h	2012-08-09 07:26:35 UTC (rev 125156)
@@ -604,6 +604,9 @@
         void setThirdPartyStorageBlockingEnabled(bool enabled) { m_thirdPartyStorageBlockingEnabled = enabled; }
         bool thirdPartyStorageBlockingEnabled() const { return m_thirdPartyStorageBlockingEnabled; }
 
+        void setScrollingPerformanceLoggingEnabled(bool);
+        bool scrollingPerformanceLoggingEnabled() { return m_scrollingPerformanceLoggingEnabled; }
+
 #if USE(JSC)
         static void setShouldRespectPriorityInCSSAttributeSetters(bool);
         static bool shouldRespectPriorityInCSSAttributeSetters();
@@ -794,6 +797,8 @@
 
         bool m_thirdPartyStorageBlockingEnabled : 1;
 
+        bool m_scrollingPerformanceLoggingEnabled : 1;
+
         Timer<Settings> m_loadsImagesAutomaticallyTimer;
         void loadsImagesAutomaticallyTimerFired(Timer<Settings>*);
         

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp (125155 => 125156)


--- trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp	2012-08-09 06:39:05 UTC (rev 125155)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp	2012-08-09 07:26:35 UTC (rev 125156)
@@ -50,6 +50,7 @@
     , m_canGoForward(false)
     , m_mainFramePinnedToTheLeft(false)
     , m_mainFramePinnedToTheRight(false)
+    , m_scrollingPerformanceLoggingEnabled(false)
 {
 }
 
@@ -218,6 +219,16 @@
     return false;
 }
 
+void ScrollingTree::setScrollingPerformanceLoggingEnabled(bool flag)
+{
+    m_scrollingPerformanceLoggingEnabled = flag;
+}
+
+bool ScrollingTree::scrollingPeformanceLoggingEnabled()
+{
+    return m_scrollingPerformanceLoggingEnabled;
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(THREADED_SCROLLING)

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTree.h (125155 => 125156)


--- trunk/Source/WebCore/page/scrolling/ScrollingTree.h	2012-08-09 06:39:05 UTC (rev 125155)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTree.h	2012-08-09 07:26:35 UTC (rev 125156)
@@ -97,6 +97,9 @@
     void setDebugRootLayer(CALayer *);
 #endif
 
+    void setScrollingPerformanceLoggingEnabled(bool flag);
+    bool scrollingPeformanceLoggingEnabled();
+
 private:
     explicit ScrollingTree(ScrollingCoordinator*);
 
@@ -116,6 +119,8 @@
     bool m_mainFramePinnedToTheLeft;
     bool m_mainFramePinnedToTheRight;
 
+    bool m_scrollingPerformanceLoggingEnabled;
+
 #if PLATFORM(MAC)
     RetainPtr<CALayer> m_debugInfoLayer;
 #endif

Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeNodeMac.h (125155 => 125156)


--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeNodeMac.h	2012-08-09 06:39:05 UTC (rev 125155)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeNodeMac.h	2012-08-09 07:26:35 UTC (rev 125156)
@@ -74,6 +74,8 @@
 
     void updateMainFramePinState(const IntPoint& scrollPosition);
 
+    void logExposedUnfilledArea();
+
     ScrollElasticityController m_scrollElasticityController;
     RetainPtr<CFRunLoopTimerRef> m_snapRubberbandTimer;
 

Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeNodeMac.mm (125155 => 125156)


--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeNodeMac.mm	2012-08-09 06:39:05 UTC (rev 125155)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeNodeMac.mm	2012-08-09 07:26:35 UTC (rev 125156)
@@ -31,7 +31,13 @@
 #include "PlatformWheelEvent.h"
 #include "ScrollingTree.h"
 #include "ScrollingTreeState.h"
+#include "Settings.h"
+#include "TileCache.h"
+#include "WebTileLayer.h"
 
+#include <wtf/CurrentTime.h>
+#include <wtf/Deque.h>
+
 namespace WebCore {
 
 PassOwnPtr<ScrollingTreeNode> ScrollingTreeNode::create(ScrollingTree* scrollingTree)
@@ -233,6 +239,9 @@
     newScrollPosition = newScrollPosition.expandedTo(minimumScrollPosition());
 
     setScrollPositionWithoutContentEdgeConstraints(newScrollPosition);
+
+    if (scrollingTree()->scrollingPeformanceLoggingEnabled())
+        logExposedUnfilledArea();
 }
 
 void ScrollingTreeNodeMac::setScrollPositionWithoutContentEdgeConstraints(const IntPoint& scrollPosition)
@@ -288,6 +297,39 @@
     scrollingTree()->setMainFramePinState(pinnedToTheLeft, pinnedToTheRight);
 }
 
+void ScrollingTreeNodeMac::logExposedUnfilledArea()
+{
+    Region paintedVisibleTiles;
+
+    Deque<CALayer*> layerQueue;
+    layerQueue.append(m_scrollLayer.get());
+    WebTileLayerList tiles;
+
+    while(!layerQueue.isEmpty() && tiles.isEmpty()) {
+        CALayer* layer = layerQueue.takeFirst();
+        NSArray* sublayers = [[layer sublayers] copy];
+
+        // If this layer is the parent of a tile, it is the parent of all of the tiles and nothing else.
+        if ([[sublayers objectAtIndex:0] isKindOfClass:[WebTileLayer class]]) {
+            for (CALayer* sublayer in sublayers) {
+                ASSERT([sublayer isKindOfClass:[WebTileLayer class]]);
+                tiles.append(static_cast<WebTileLayer*>(sublayer));
+            }
+        } else {
+            for (CALayer* sublayer in sublayers)
+                layerQueue.append(sublayer);
+        }
+
+        [sublayers release];
+    }
+
+    IntPoint scrollPosition = this->scrollPosition();
+    unsigned unfilledArea = TileCache::blankPixelCountForTiles(tiles, viewportRect(), IntPoint(-scrollPosition.x(), -scrollPosition.y()));
+
+    if (unfilledArea)
+        printf("SCROLLING: Exposed tileless area. Time: %f Unfilled Pixels: %u\n", WTF::monotonicallyIncreasingTime(), unfilledArea);
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(THREADED_SCROLLING)

Modified: trunk/Source/WebCore/platform/graphics/TiledBacking.h (125155 => 125156)


--- trunk/Source/WebCore/platform/graphics/TiledBacking.h	2012-08-09 06:39:05 UTC (rev 125155)
+++ trunk/Source/WebCore/platform/graphics/TiledBacking.h	2012-08-09 07:26:35 UTC (rev 125156)
@@ -32,11 +32,20 @@
 
 class TiledBacking {
 public:
+    TiledBacking()
+        : m_scrollingPerformanceLoggingEnabled(0)
+    { }
     virtual ~TiledBacking() { }
 
     virtual void visibleRectChanged(const IntRect&) = 0;
     virtual void setIsInWindow(bool) = 0;
     virtual void setCanHaveScrollbars(bool) = 0;
+
+    void setScrollingPerformanceLoggingEnabled(bool flag)  { m_scrollingPerformanceLoggingEnabled = flag; }
+    bool scrollingPerformanceLoggingEnabled() const { return m_scrollingPerformanceLoggingEnabled; }
+
+private:
+    bool m_scrollingPerformanceLoggingEnabled;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/ca/mac/TileCache.h (125155 => 125156)


--- trunk/Source/WebCore/platform/graphics/ca/mac/TileCache.h	2012-08-09 06:39:05 UTC (rev 125155)
+++ trunk/Source/WebCore/platform/graphics/ca/mac/TileCache.h	2012-08-09 07:26:35 UTC (rev 125156)
@@ -45,6 +45,8 @@
 class IntPoint;
 class IntRect;
 
+typedef Vector<RetainPtr<WebTileLayer> > WebTileLayerList;
+
 class TileCache : public TiledBacking {
     WTF_MAKE_NONCOPYABLE(TileCache);
 
@@ -68,6 +70,11 @@
     void setTileDebugBorderWidth(float);
     void setTileDebugBorderColor(CGColorRef);
 
+    IntRect visibleRect() const { return m_visibleRect; }
+
+    unsigned blankPixelCount() const;
+    static unsigned blankPixelCountForTiles(const WebTileLayerList&, IntRect, IntPoint);
+
 private:
     TileCache(WebTileCacheLayer*, const IntSize& tileSize);
 

Modified: trunk/Source/WebCore/platform/graphics/ca/mac/TileCache.mm (125155 => 125156)


--- trunk/Source/WebCore/platform/graphics/ca/mac/TileCache.mm	2012-08-09 06:39:05 UTC (rev 125155)
+++ trunk/Source/WebCore/platform/graphics/ca/mac/TileCache.mm	2012-08-09 07:26:35 UTC (rev 125156)
@@ -28,6 +28,7 @@
 
 #import "IntRect.h"
 #import "PlatformCALayer.h"
+#import "Region.h"
 #import "WebLayer.h"
 #import "WebTileCacheLayer.h"
 #import "WebTileLayer.h"
@@ -311,6 +312,34 @@
     revalidateTiles();
 }
 
+unsigned TileCache::blankPixelCount() const
+{
+    WebTileLayerList tiles(m_tiles.size());
+    tiles.appendRange(m_tiles.begin().values(), m_tiles.end().values());
+
+    return blankPixelCountForTiles(tiles, m_visibleRect, IntPoint(0,0));
+}
+
+unsigned TileCache::blankPixelCountForTiles(const WebTileLayerList& tiles, IntRect visibleRect, IntPoint tileTranslation)
+{
+    Region paintedVisibleTiles;
+
+    for (WebTileLayerList::const_iterator it = tiles.begin(), end = tiles.end(); it != end; ++it) {
+        const WebTileLayer* tileLayer = it->get();
+
+        IntRect visiblePart(CGRectOffset([tileLayer frame], tileTranslation.x(), tileTranslation.y()));
+        visiblePart.intersect(visibleRect);
+
+        if (!visiblePart.isEmpty() && [tileLayer repaintCount])
+            paintedVisibleTiles.unite(visiblePart);
+    }
+
+    Region uncoveredRegion(visibleRect);
+    uncoveredRegion.subtract(paintedVisibleTiles);
+
+    return uncoveredRegion.totalArea();
+}
+
 void TileCache::revalidateTiles()
 {
     // If the underlying PlatformLayer has been destroyed, but the WebTileCacheLayer hasn't

Modified: trunk/Source/WebCore/platform/graphics/ca/mac/WebTileLayer.h (125155 => 125156)


--- trunk/Source/WebCore/platform/graphics/ca/mac/WebTileLayer.h	2012-08-09 06:39:05 UTC (rev 125155)
+++ trunk/Source/WebCore/platform/graphics/ca/mac/WebTileLayer.h	2012-08-09 07:26:35 UTC (rev 125156)
@@ -37,6 +37,7 @@
 
 - (void)setTileCache:(WebCore::TileCache*)tileCache;
 - (unsigned)incrementRepaintCount;
+- (unsigned)repaintCount;
 @end
 
 

Modified: trunk/Source/WebCore/platform/graphics/ca/mac/WebTileLayer.mm (125155 => 125156)


--- trunk/Source/WebCore/platform/graphics/ca/mac/WebTileLayer.mm	2012-08-09 06:39:05 UTC (rev 125155)
+++ trunk/Source/WebCore/platform/graphics/ca/mac/WebTileLayer.mm	2012-08-09 07:26:35 UTC (rev 125156)
@@ -27,10 +27,15 @@
 #import "WebTileLayer.h"
 
 #import "TileCache.h"
+#import <wtf/CurrentTime.h>
 #import <wtf/UnusedParam.h>
 
 using namespace WebCore;
 
+@interface WebTileLayer (ScrollingPerformanceLoggingInternal)
+- (void)logFilledFreshTile;
+@end
+
 @implementation WebTileLayer
 
 - (id<CAAction>)actionForKey:(NSString *)key
@@ -43,8 +48,12 @@
 
 - (void)drawInContext:(CGContextRef)context
 {
-    if (_tileCache)
+    if (_tileCache) {
         _tileCache->drawLayer(self, context);
+
+        if (_tileCache->scrollingPerformanceLoggingEnabled())
+            [self logFilledFreshTile];
+    }
 }
 
 - (void)setTileCache:(WebCore::TileCache*)tileCache
@@ -57,5 +66,19 @@
     return ++_repaintCount;
 }
 
+- (unsigned)repaintCount
+{
+    return _repaintCount;
+}
+
+- (void)logFilledFreshTile
+{
+    IntRect visiblePart(enclosingIntRect([self frame]));
+    visiblePart.intersect(_tileCache->visibleRect());
+
+    if ([self repaintCount] == 1 && !visiblePart.isEmpty())
+        printf("SCROLLING: Filled visible fresh tile. Time: %f Unfilled Pixels: %u\n", WTF::monotonicallyIncreasingTime(), _tileCache->blankPixelCount());
+}
+
 @end
 

Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (125155 => 125156)


--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2012-08-09 06:39:05 UTC (rev 125155)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2012-08-09 07:26:35 UTC (rev 125156)
@@ -52,6 +52,7 @@
 #include "RenderVideo.h"
 #include "RenderView.h"
 #include "ScrollingCoordinator.h"
+#include "Settings.h"
 #include "StyleResolver.h"
 #include "TiledBacking.h"
 
@@ -121,8 +122,11 @@
     if (m_usingTiledCacheLayer) {
         if (Page* page = renderer()->frame()->page()) {
             if (TiledBacking* tiledBacking = m_graphicsLayer->tiledBacking()) {
+                Frame* frame = renderer()->frame();
+
                 tiledBacking->setIsInWindow(page->isOnscreen());
-                tiledBacking->setCanHaveScrollbars(renderer()->frame()->view()->canHaveScrollbars());
+                tiledBacking->setCanHaveScrollbars(frame->view()->canHaveScrollbars());
+                tiledBacking->setScrollingPerformanceLoggingEnabled(frame->settings() && frame->settings()->scrollingPerformanceLoggingEnabled());
             }
         }
     }

Modified: trunk/Source/WebKit2/ChangeLog (125155 => 125156)


--- trunk/Source/WebKit2/ChangeLog	2012-08-09 06:39:05 UTC (rev 125155)
+++ trunk/Source/WebKit2/ChangeLog	2012-08-09 07:26:35 UTC (rev 125156)
@@ -1,3 +1,27 @@
+2012-08-09  Tim Horton  <timothy_hor...@apple.com>
+
+        Add optional debug logging for tiled scrolling
+        https://bugs.webkit.org/show_bug.cgi?id=93305
+
+        Reviewed by Simon Fraser.
+
+        Add a new boolean preference, ScrollingPerformanceLoggingEnabled, which will be used to toggle
+        the WebCore parts of this change.
+
+        * Shared/WebPreferencesStore.h: Add ScrollingPerformanceLoggingEnabled.
+        * UIProcess/API/C/WKPreferences.cpp:
+        (WKPreferencesSetScrollingPerformanceLoggingEnabled): Added.
+        (WKPreferencesGetScrollingPerformanceLoggingEnabled): Added.
+        * UIProcess/API/C/WKPreferencesPrivate.h: Add getters and setters for ScrollingPerformanceLoggingEnabled.
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::WebPage): Add ScrollingPerformanceLoggingEnabled.
+        (WebKit::WebPage::updatePreferences): Add ScrollingPerformanceLoggingEnabled.
+        (WebKit::WebPage::setScrollingPerformanceLoggingEnabled): Propagate settings changes through to FrameView.
+        * WebProcess/WebPage/WebPage.h:
+        (WebKit::WebPage::scrollingPerformanceLoggingEnabled): Add a getter for the setting so that TiledCoreAnimationDrawingArea can access it.
+        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
+        (WebKit::TiledCoreAnimationDrawingArea::updatePreferences): Pass ScrollingPerformanceLoggingEnabled down into the scrolling thread.
+
 2012-08-08  Shane Stephens  <shanesteph...@google.com>
 
         Compile flag for CSS Hierarchies

Modified: trunk/Source/WebKit2/Shared/WebPreferencesStore.h (125155 => 125156)


--- trunk/Source/WebKit2/Shared/WebPreferencesStore.h	2012-08-09 06:39:05 UTC (rev 125155)
+++ trunk/Source/WebKit2/Shared/WebPreferencesStore.h	2012-08-09 07:26:35 UTC (rev 125156)
@@ -117,6 +117,7 @@
     macro(AsynchronousPluginInitializationEnabled, asynchronousPluginInitializationEnabled, Bool, bool, false) \
     macro(AsynchronousPluginInitializationEnabledForAllPlugins, asynchronousPluginInitializationEnabledForAllPlugins, Bool, bool, false) \
     macro(ArtificialPluginInitializationDelayEnabled, artificialPluginInitializationDelayEnabled, Bool, bool, false) \
+    macro(ScrollingPerformanceLoggingEnabled, scrollingPerformanceLoggingEnabled, Bool, bool, false) \
     macro(ThirdPartyStorageBlockingEnabled, thirdPartyStorageBlockingEnabled, Bool, bool, false) \
     \
 

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp (125155 => 125156)


--- trunk/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp	2012-08-09 06:39:05 UTC (rev 125155)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp	2012-08-09 07:26:35 UTC (rev 125156)
@@ -873,3 +873,13 @@
 {
     return toImpl(preferencesRef)->artificialPluginInitializationDelayEnabled();
 }
+
+void WKPreferencesSetScrollingPerformanceLoggingEnabled(WKPreferencesRef preferencesRef, bool enabled)
+{
+    toImpl(preferencesRef)->setScrollingPerformanceLoggingEnabled(enabled);
+}
+
+bool WKPreferencesGetScrollingPerformanceLoggingEnabled(WKPreferencesRef preferencesRef)
+{
+    return toImpl(preferencesRef)->scrollingPerformanceLoggingEnabled();
+}

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h (125155 => 125156)


--- trunk/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h	2012-08-09 06:39:05 UTC (rev 125155)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h	2012-08-09 07:26:35 UTC (rev 125156)
@@ -203,6 +203,10 @@
 WK_EXPORT void WKPreferencesSetArtificialPluginInitializationDelayEnabled(WKPreferencesRef preferencesRef, bool enabled);
 WK_EXPORT bool WKPreferencesGetArtificialPluginInitializationDelayEnabled(WKPreferencesRef preferencesRef);
 
+// Defaults to false
+WK_EXPORT void WKPreferencesSetScrollingPerformanceLoggingEnabled(WKPreferencesRef preferencesRef, bool enabled);
+WK_EXPORT bool WKPreferencesGetScrollingPerformanceLoggingEnabled(WKPreferencesRef preferencesRef);
+
 WK_EXPORT void WKPreferencesResetTestRunnerOverrides(WKPreferencesRef preferencesRef);
 
 #ifdef __cplusplus

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (125155 => 125156)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2012-08-09 06:39:05 UTC (rev 125155)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2012-08-09 07:26:35 UTC (rev 125156)
@@ -214,6 +214,7 @@
     , m_asynchronousPluginInitializationEnabled(false)
     , m_asynchronousPluginInitializationEnabledForAllPlugins(false)
     , m_artificialPluginInitializationDelayEnabled(false)
+    , m_scrollingPerformanceLoggingEnabled(false)
 #if PLATFORM(MAC)
     , m_windowIsVisible(false)
     , m_isSmartInsertDeleteEnabled(parameters.isSmartInsertDeleteEnabled)
@@ -1975,6 +1976,8 @@
     m_asynchronousPluginInitializationEnabledForAllPlugins = store.getBoolValueForKey(WebPreferencesKey::asynchronousPluginInitializationEnabledForAllPluginsKey());
     m_artificialPluginInitializationDelayEnabled = store.getBoolValueForKey(WebPreferencesKey::artificialPluginInitializationDelayEnabledKey());
 
+    m_scrollingPerformanceLoggingEnabled = store.getBoolValueForKey(WebPreferencesKey::scrollingPerformanceLoggingEnabledKey());
+
     // FIXME: This should be generated from macro expansion for all preferences,
     // but we currently don't match the naming of WebCore exactly so we are
     // handrolling the boolean and integer preferences until that is fixed.
@@ -2092,6 +2095,8 @@
 
     settings->setDiagnosticLoggingEnabled(store.getBoolValueForKey(WebPreferencesKey::diagnosticLoggingEnabledKey()));
 
+    settings->setScrollingPerformanceLoggingEnabled(m_scrollingPerformanceLoggingEnabled);
+
     platformPreferencesDidChange(store);
 
     if (m_drawingArea)
@@ -3285,4 +3290,15 @@
 }
 #endif
 
+void WebPage::setScrollingPerformanceLoggingEnabled(bool enabled)
+{
+    m_scrollingPerformanceLoggingEnabled = enabled;
+
+    FrameView* frameView = m_mainFrame->coreFrame()->view();
+    if (!frameView)
+        return;
+
+    frameView->setScrollingPerformanceLoggingEnabled(enabled);
+}
+
 } // namespace WebKit

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (125155 => 125156)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2012-08-09 06:39:05 UTC (rev 125155)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2012-08-09 07:26:35 UTC (rev 125156)
@@ -575,6 +575,9 @@
     bool artificialPluginInitializationDelayEnabled() const { return m_artificialPluginInitializationDelayEnabled; }
     void setArtificialPluginInitializationDelayEnabled(bool enabled) { m_artificialPluginInitializationDelayEnabled = enabled; }
 
+    bool scrollingPerformanceLoggingEnabled() const { return m_scrollingPerformanceLoggingEnabled; }
+    void setScrollingPerformanceLoggingEnabled(bool);
+
 private:
     WebPage(uint64_t pageID, const WebPageCreationParameters&);
 
@@ -771,6 +774,8 @@
     bool m_asynchronousPluginInitializationEnabledForAllPlugins;
     bool m_artificialPluginInitializationDelayEnabled;
 
+    bool m_scrollingPerformanceLoggingEnabled;
+
 #if PLATFORM(MAC)
     // Whether the containing window is visible or not.
     bool m_windowIsVisible;

Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm (125155 => 125156)


--- trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm	2012-08-09 06:39:05 UTC (rev 125155)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm	2012-08-09 07:26:35 UTC (rev 125156)
@@ -212,7 +212,10 @@
         m_debugInfoLayer = nullptr;
     }
 
+    bool scrollingPerformanceLoggingEnabled = m_webPage->scrollingPerformanceLoggingEnabled();
+
     ScrollingThread::dispatch(bind(&ScrollingTree::setDebugRootLayer, m_webPage->corePage()->scrollingCoordinator()->scrollingTree(), m_debugInfoLayer));
+    ScrollingThread::dispatch(bind(&ScrollingTree::setScrollingPerformanceLoggingEnabled, m_webPage->corePage()->scrollingCoordinator()->scrollingTree(), scrollingPerformanceLoggingEnabled));
 }
 
 void TiledCoreAnimationDrawingArea::dispatchAfterEnsuringUpdatedScrollPosition(const Function<void ()>& functionRef)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to