Title: [136594] trunk/Source
Revision
136594
Author
[email protected]
Date
2012-12-04 16:49:33 -0800 (Tue, 04 Dec 2012)

Log Message

Show a mini visualizer for the tile cache tiles
https://bugs.webkit.org/show_bug.cgi?id=104053

Reviewed by Beth Dakin.

Source/WebCore:

Replace the current red/green/yellow scrolling indicator with a
mini map of the tile cache that shows the current tiles, and the
visible rect.

Visibility is controlled via a new preference.

* WebCore.exp.in: Add Settings::setShowTiledScrollingIndicator(bool),
and remove ScrollingTree::setDebugRootLayer(CALayer*)
* WebCore.xcodeproj/project.pbxproj: Remove ScrollingTreeMac.mm which
is no longer needed; it just contained debug layer stuff.
* page/Settings.cpp:
(WebCore::Settings::Settings): Support the new setting.
(WebCore::Settings::setShowTiledScrollingIndicator):
* page/Settings.h:
(WebCore::Settings::showTiledScrollingIndicator):
* page/scrolling/ScrollingTree.cpp:
(WebCore::ScrollingTree::commitNewTreeState): We no longer update the debug
indicator on tree commit.
* page/scrolling/ScrollingTree.h:
(WebCore::ScrollingTree::hasWheelEventHandlers): Needed for the tiled
scrolling indicator.
(ScrollingTree):
* page/scrolling/mac/ScrollingCoordinatorMac.mm:
(WebCore::ScrollingCoordinatorMac::commitTreeState): Tell the TiledBacking
about the current scrolling mode.
* page/scrolling/mac/ScrollingTreeMac.mm: Removed.
* platform/graphics/TiledBacking.h: Add functions to set the indicator scrolling
mode, and to get the tiled scrolling indicator layer. This has to be parented by
the DrawingArea, to ensure that it's in front of all other layers.
* platform/graphics/ca/mac/TileCache.h:
(WebCore::TileCache::scale): Exposed for the indicator drawing code to use.
* platform/graphics/ca/mac/TileCache.mm:
(-[WebTileCacheMapLayer init]): The indicator has a sublayer which renders the
visible rect frame, owned by it.
(-[WebTileCacheMapLayer drawInContext:]):
(WebCore::TileCache::TileCache): The indicator mode has to be stored here,
since it can be pushed down before we have an indicator layer.
(WebCore::TileCache::~TileCache): Clear the TileCache on the indicator layer, which
may outlive us.
(WebCore::TileCache::revalidateTiles): Call updateTileCoverageMap().
(WebCore::TileCache::updateTileCoverageMap): Resize the indicator layer to fit
within the window, and update the indicator color.
(WebCore::TileCache::tiledScrollingIndicatorLayer): Create and initialize the layer.
(WebCore::TileCache::setScrollingModeIndication):
(WebCore::TileCache::drawTileMapContents): Draw small white rects for the tiles over
an translucent gray background.

Source/WebKit2:

Plumb through a preference that controls the visibility of a tiled
scrolling indicator, and parent that layer in the TiledCoreAnimationDrawingArea.

* Shared/WebPreferencesStore.h:
* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesSetTiledScrollingIndicatorVisible):
(WKPreferencesGetTiledScrollingIndicatorVisible):
* UIProcess/API/C/WKPreferencesPrivate.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences):
* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h:
(TiledCoreAnimationDrawingArea):
* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
(WebKit::TiledCoreAnimationDrawingArea::updatePreferences):
(WebKit::TiledCoreAnimationDrawingArea::setRootCompositingLayer):
(WebKit::TiledCoreAnimationDrawingArea::mainFrameTiledBacking):
(WebKit::TiledCoreAnimationDrawingArea::updateDebugInfoLayer):

Modified Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (136593 => 136594)


--- trunk/Source/WebCore/ChangeLog	2012-12-05 00:43:13 UTC (rev 136593)
+++ trunk/Source/WebCore/ChangeLog	2012-12-05 00:49:33 UTC (rev 136594)
@@ -1,3 +1,57 @@
+2012-12-04  Simon Fraser  <[email protected]>
+
+        Show a mini visualizer for the tile cache tiles
+        https://bugs.webkit.org/show_bug.cgi?id=104053
+
+        Reviewed by Beth Dakin.
+
+        Replace the current red/green/yellow scrolling indicator with a
+        mini map of the tile cache that shows the current tiles, and the
+        visible rect.
+        
+        Visibility is controlled via a new preference.
+
+        * WebCore.exp.in: Add Settings::setShowTiledScrollingIndicator(bool),
+        and remove ScrollingTree::setDebugRootLayer(CALayer*)
+        * WebCore.xcodeproj/project.pbxproj: Remove ScrollingTreeMac.mm which
+        is no longer needed; it just contained debug layer stuff.
+        * page/Settings.cpp:
+        (WebCore::Settings::Settings): Support the new setting.
+        (WebCore::Settings::setShowTiledScrollingIndicator):
+        * page/Settings.h:
+        (WebCore::Settings::showTiledScrollingIndicator):
+        * page/scrolling/ScrollingTree.cpp:
+        (WebCore::ScrollingTree::commitNewTreeState): We no longer update the debug
+        indicator on tree commit.
+        * page/scrolling/ScrollingTree.h:
+        (WebCore::ScrollingTree::hasWheelEventHandlers): Needed for the tiled
+        scrolling indicator.
+        (ScrollingTree):
+        * page/scrolling/mac/ScrollingCoordinatorMac.mm:
+        (WebCore::ScrollingCoordinatorMac::commitTreeState): Tell the TiledBacking
+        about the current scrolling mode.
+        * page/scrolling/mac/ScrollingTreeMac.mm: Removed.
+        * platform/graphics/TiledBacking.h: Add functions to set the indicator scrolling
+        mode, and to get the tiled scrolling indicator layer. This has to be parented by
+        the DrawingArea, to ensure that it's in front of all other layers.
+        * platform/graphics/ca/mac/TileCache.h:
+        (WebCore::TileCache::scale): Exposed for the indicator drawing code to use.
+        * platform/graphics/ca/mac/TileCache.mm:
+        (-[WebTileCacheMapLayer init]): The indicator has a sublayer which renders the
+        visible rect frame, owned by it.
+        (-[WebTileCacheMapLayer drawInContext:]):
+        (WebCore::TileCache::TileCache): The indicator mode has to be stored here,
+        since it can be pushed down before we have an indicator layer.
+        (WebCore::TileCache::~TileCache): Clear the TileCache on the indicator layer, which
+        may outlive us.
+        (WebCore::TileCache::revalidateTiles): Call updateTileCoverageMap().
+        (WebCore::TileCache::updateTileCoverageMap): Resize the indicator layer to fit
+        within the window, and update the indicator color.
+        (WebCore::TileCache::tiledScrollingIndicatorLayer): Create and initialize the layer.
+        (WebCore::TileCache::setScrollingModeIndication):
+        (WebCore::TileCache::drawTileMapContents): Draw small white rects for the tiles over
+        an translucent gray background.
+
 2012-12-04  David Grogan  <[email protected]>
 
         IndexedDB: Propagate more leveldb errors to IDBIndex and IDBObjectStore

Modified: trunk/Source/WebCore/WebCore.exp.in (136593 => 136594)


--- trunk/Source/WebCore/WebCore.exp.in	2012-12-05 00:43:13 UTC (rev 136593)
+++ trunk/Source/WebCore/WebCore.exp.in	2012-12-05 00:49:33 UTC (rev 136594)
@@ -980,6 +980,7 @@
 __ZN7WebCore8Settings45setShouldRespectPriorityInCSSAttributeSettersEb
 __ZN7WebCore8Settings21setResolutionOverrideERKNS_7IntSizeE
 __ZN7WebCore8Settings20setMediaTypeOverrideERKN3WTF6StringE
+__ZN7WebCore8Settings30setShowTiledScrollingIndicatorEb
 __ZN7WebCore8blankURLEv
 __ZN7WebCore8makeRGBAEiiii
 __ZN7WebCore8openFileERKN3WTF6StringENS_12FileOpenModeE
@@ -2617,7 +2618,6 @@
 #endif
 
 #if ENABLE(THREADED_SCROLLING)
-__ZN7WebCore13ScrollingTree17setDebugRootLayerEP7CALayer
 __ZN7WebCore13ScrollingTree37setScrollingPerformanceLoggingEnabledEb
 __ZN7WebCore13ScrollingTree21tryToHandleWheelEventERKNS_18PlatformWheelEventE
 __ZN7WebCore13ScrollingTree22updateBackForwardStateEbb

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (136593 => 136594)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2012-12-05 00:43:13 UTC (rev 136593)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2012-12-05 00:49:33 UTC (rev 136594)
@@ -412,7 +412,6 @@
 		1A2E6E590CC55213004A2062 /* SQLValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2E6E570CC55213004A2062 /* SQLValue.cpp */; };
 		1A2E6E5A0CC55213004A2062 /* SQLValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2E6E580CC55213004A2062 /* SQLValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		1A2E6E7A0CC556D5004A2062 /* SQLiteAuthorizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2E6E780CC556D5004A2062 /* SQLiteAuthorizer.cpp */; };
-		1A35862C152522540022A659 /* ScrollingTreeMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A35862A152522540022A659 /* ScrollingTreeMac.mm */; };
 		1A3586DF15264C450022A659 /* RenderMultiColumnFlowThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3586DD15264C450022A659 /* RenderMultiColumnFlowThread.cpp */; };
 		1A3586E015264C450022A659 /* RenderMultiColumnFlowThread.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3586DE15264C450022A659 /* RenderMultiColumnFlowThread.h */; };
 		1A3586E115264F950022A659 /* SVGAnimatedIntegerOptionalInteger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 71E623CE151F72A60036E2F4 /* SVGAnimatedIntegerOptionalInteger.cpp */; };
@@ -7552,7 +7551,6 @@
 		1A2E6E570CC55213004A2062 /* SQLValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SQLValue.cpp; path = sql/SQLValue.cpp; sourceTree = "<group>"; };
 		1A2E6E580CC55213004A2062 /* SQLValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SQLValue.h; path = sql/SQLValue.h; sourceTree = "<group>"; };
 		1A2E6E780CC556D5004A2062 /* SQLiteAuthorizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SQLiteAuthorizer.cpp; path = sql/SQLiteAuthorizer.cpp; sourceTree = "<group>"; };
-		1A35862A152522540022A659 /* ScrollingTreeMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ScrollingTreeMac.mm; sourceTree = "<group>"; };
 		1A3586DD15264C450022A659 /* RenderMultiColumnFlowThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMultiColumnFlowThread.cpp; sourceTree = "<group>"; };
 		1A3586DE15264C450022A659 /* RenderMultiColumnFlowThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderMultiColumnFlowThread.h; sourceTree = "<group>"; };
 		1A494BBB0A122DCD00FDAFC1 /* HTMLElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = HTMLElement.idl; sourceTree = "<group>"; };
@@ -14777,7 +14775,6 @@
 				1AF62F2314DAFE910041556C /* ScrollingThreadMac.mm */,
 				93C38C01164473DD00091EB2 /* ScrollingTreeFixedNode.h */,
 				93C38C02164473DD00091EB2 /* ScrollingTreeFixedNode.mm */,
-				1A35862A152522540022A659 /* ScrollingTreeMac.mm */,
 				93C4A4131629DF5A00C3EB6E /* ScrollingTreeScrollingNodeMac.h */,
 				93C4A4141629DF5A00C3EB6E /* ScrollingTreeScrollingNodeMac.mm */,
 			);
@@ -28406,7 +28403,6 @@
 				1AF62F2514DAFE9E0041556C /* ScrollingThread.cpp in Sources */,
 				1AF62F2414DAFE910041556C /* ScrollingThreadMac.mm in Sources */,
 				1AAADDA314DB409F00AF64B3 /* ScrollingTree.cpp in Sources */,
-				1A35862C152522540022A659 /* ScrollingTreeMac.mm in Sources */,
 				1AAADDE314DC8C8F00AF64B3 /* ScrollingTreeNode.cpp in Sources */,
 				9391A99C1629D70000297330 /* ScrollingTreeScrollingNode.cpp in Sources */,
 				93C4A4161629DF5A00C3EB6E /* ScrollingTreeScrollingNodeMac.mm in Sources */,

Modified: trunk/Source/WebCore/page/Settings.cpp (136593 => 136594)


--- trunk/Source/WebCore/page/Settings.cpp	2012-12-05 00:43:13 UTC (rev 136593)
+++ trunk/Source/WebCore/page/Settings.cpp	2012-12-05 00:49:33 UTC (rev 136594)
@@ -170,6 +170,7 @@
     , m_acceleratedCompositingEnabled(true)
     , m_showDebugBorders(false)
     , m_showRepaintCounter(false)
+    , m_showTiledScrollingIndicator(false)
     , m_tiledBackingStoreEnabled(false)
     , m_dnsPrefetchingEnabled(false)
 #if USE(UNIFIED_TEXT_CHECKING)
@@ -589,6 +590,14 @@
     m_page->setNeedsRecalcStyleInAllFrames();
 }
 
+void Settings::setShowTiledScrollingIndicator(bool enabled)
+{
+    if (m_showTiledScrollingIndicator == enabled)
+        return;
+        
+    m_showTiledScrollingIndicator = enabled;
+}
+
 #if PLATFORM(WIN) || (OS(WINDOWS) && PLATFORM(WX))
 void Settings::setShouldUseHighResolutionTimers(bool shouldUseHighResolutionTimers)
 {

Modified: trunk/Source/WebCore/page/Settings.h (136593 => 136594)


--- trunk/Source/WebCore/page/Settings.h	2012-12-05 00:43:13 UTC (rev 136593)
+++ trunk/Source/WebCore/page/Settings.h	2012-12-05 00:49:33 UTC (rev 136594)
@@ -241,6 +241,9 @@
         void setShowRepaintCounter(bool);
         bool showRepaintCounter() const { return m_showRepaintCounter; }
 
+        void setShowTiledScrollingIndicator(bool);
+        bool showTiledScrollingIndicator() const { return m_showTiledScrollingIndicator; }
+
 #if PLATFORM(WIN) || (OS(WINDOWS) && PLATFORM(WX))
         static void setShouldUseHighResolutionTimers(bool);
         static bool shouldUseHighResolutionTimers() { return gShouldUseHighResolutionTimers; }
@@ -348,6 +351,7 @@
         bool m_acceleratedCompositingEnabled : 1;
         bool m_showDebugBorders : 1;
         bool m_showRepaintCounter : 1;
+        bool m_showTiledScrollingIndicator : 1;
         bool m_tiledBackingStoreEnabled : 1;
         bool m_dnsPrefetchingEnabled : 1;
         bool m_unifiedTextCheckerEnabled : 1;

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp (136593 => 136594)


--- trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp	2012-12-05 00:43:13 UTC (rev 136593)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp	2012-12-05 00:49:33 UTC (rev 136594)
@@ -141,8 +141,6 @@
 
     removeDestroyedNodes(scrollingStateTree.get());
     updateTreeFromStateNode(scrollingStateTree->rootStateNode());
-
-    updateDebugRootLayer();
 }
 
 void ScrollingTree::updateTreeFromStateNode(ScrollingStateNode* stateNode)

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTree.h (136593 => 136594)


--- trunk/Source/WebCore/page/scrolling/ScrollingTree.h	2012-12-05 00:43:13 UTC (rev 136593)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTree.h	2012-12-05 00:49:33 UTC (rev 136594)
@@ -71,6 +71,7 @@
     // Returns true if the wheel event can be handled on the scrolling thread and false if the
     // event must be sent again to the WebCore event handler.
     EventResult tryToHandleWheelEvent(const PlatformWheelEvent&);
+    bool hasWheelEventHandlers() const { return m_hasWheelEventHandlers; }
 
     // Can be called from any thread. Will update the back forward state of the page, used for rubber-banding.
     void updateBackForwardState(bool canGoBack, bool canGoForward);
@@ -95,18 +96,12 @@
 
     bool willWheelEventStartSwipeGesture(const PlatformWheelEvent&);
 
-#if PLATFORM(MAC)
-    void setDebugRootLayer(CALayer *);
-#endif
-
     void setScrollingPerformanceLoggingEnabled(bool flag);
     bool scrollingPerformanceLoggingEnabled();
 
 private:
     explicit ScrollingTree(ScrollingCoordinator*);
 
-    void updateDebugRootLayer();
-
     void removeDestroyedNodes(ScrollingStateTree*);
     void updateTreeFromStateNode(ScrollingStateNode*);
 

Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm (136593 => 136594)


--- trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm	2012-12-05 00:43:13 UTC (rev 136593)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm	2012-12-05 00:49:33 UTC (rev 136594)
@@ -45,6 +45,7 @@
 #include "ScrollingStateTree.h"
 #include "ScrollingThread.h"
 #include "ScrollingTree.h"
+#include "TiledBacking.h"
 
 #include <wtf/Functional.h>
 #include <wtf/MainThread.h>
@@ -412,6 +413,24 @@
 
     OwnPtr<ScrollingStateTree> treeState = m_scrollingStateTree->commit();
     ScrollingThread::dispatch(bind(&ScrollingTree::commitNewTreeState, m_scrollingTree.get(), treeState.release()));
+
+    FrameView* frameView = m_page->mainFrame()->view();
+    if (!frameView)
+        return;
+    
+    TiledBacking* tiledBacking = frameView->tiledBacking();
+    if (!tiledBacking)
+        return;
+
+    ScrollingModeIndication indicatorMode;
+    if (shouldUpdateScrollLayerPositionOnMainThread())
+        indicatorMode = MainThreadScrollingBecauseOfStyleIndictaion;
+    else if (scrollingTree() && scrollingTree()->hasWheelEventHandlers())
+        indicatorMode =  MainThreadScrollingBecauseOfEventHandlersIndication;
+    else
+        indicatorMode = ThreadedScrollingIndication;
+    
+    tiledBacking->setScrollingModeIndication(indicatorMode);
 }
 
 String ScrollingCoordinatorMac::scrollingStateTreeAsText() const

Deleted: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeMac.mm (136593 => 136594)


--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeMac.mm	2012-12-05 00:43:13 UTC (rev 136593)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeMac.mm	2012-12-05 00:49:33 UTC (rev 136594)
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2012 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 "ScrollingTree.h"
-
-#if ENABLE(THREADED_SCROLLING)
-
-#import "AutodrainedPool.h"
-#import "ScrollingTreeScrollingNodeMac.h"
-#import <QuartzCore/CATextLayer.h>
-
-namespace WebCore {
-
-void ScrollingTree::setDebugRootLayer(CALayer *rootLayer)
-{
-    AutodrainedPool pool;
-
-    [m_debugInfoLayer.get() removeFromSuperlayer];
-
-    if (!rootLayer)
-        return;
-
-    m_debugInfoLayer = [CALayer layer];
-    [rootLayer addSublayer:m_debugInfoLayer.get()];
-
-    [m_debugInfoLayer.get() setBorderWidth:1];
-    [m_debugInfoLayer.get() setBorderColor:CGColorGetConstantColor(kCGColorBlack)];
-    
-    [m_debugInfoLayer.get() setFrame:CGRectMake(0, 0, 25, 25)];
-    updateDebugRootLayer();
-}
-
-void ScrollingTree::updateDebugRootLayer()
-{
-    if (!m_debugInfoLayer)
-        return;
-
-    AutodrainedPool pool;
-
-    RetainPtr<CGColorRef> backgroundColor;
-
-    if (m_rootNode->shouldUpdateScrollLayerPositionOnMainThread())
-        backgroundColor = adoptCF(CGColorCreateGenericRGB(1, 0, 0, .7));
-
-    {
-        MutexLocker lock(m_mutex);
-        if (m_hasWheelEventHandlers) {
-            if (!backgroundColor)
-                backgroundColor = adoptCF(CGColorCreateGenericRGB(1, 1, 0, .7));
-        }
-    }
-
-    if (!backgroundColor)
-        backgroundColor = adoptCF(CGColorCreateGenericRGB(0, 1, 0, .7));
-
-    [m_debugInfoLayer.get() setBackgroundColor:backgroundColor.get()];
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(THREADED_SCROLLING)

Modified: trunk/Source/WebCore/platform/graphics/TiledBacking.h (136593 => 136594)


--- trunk/Source/WebCore/platform/graphics/TiledBacking.h	2012-12-05 00:43:13 UTC (rev 136593)
+++ trunk/Source/WebCore/platform/graphics/TiledBacking.h	2012-12-05 00:49:33 UTC (rev 136594)
@@ -26,10 +26,20 @@
 #ifndef TiledBacking_h
 #define TiledBacking_h
 
+#if PLATFORM(MAC)
+OBJC_CLASS CALayer;
+#endif
+
 namespace WebCore {
 
 class IntRect;
 
+enum ScrollingModeIndication {
+    MainThreadScrollingBecauseOfStyleIndictaion,
+    MainThreadScrollingBecauseOfEventHandlersIndication,
+    ThreadedScrollingIndication
+};
+
 class TiledBacking {
 public:
     virtual ~TiledBacking() { }
@@ -61,6 +71,11 @@
     // Exposed for testing
     virtual IntRect tileCoverageRect() const = 0;
     virtual IntRect tileGridExtent() const = 0;
+    virtual void setScrollingModeIndication(ScrollingModeIndication) = 0;
+
+#if PLATFORM(MAC)
+    virtual CALayer *tiledScrollingIndicatorLayer() = 0;
+#endif
 };
 
 } // namespace WebCore

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


--- trunk/Source/WebCore/platform/graphics/ca/mac/TileCache.h	2012-12-05 00:43:13 UTC (rev 136593)
+++ trunk/Source/WebCore/platform/graphics/ca/mac/TileCache.h	2012-12-05 00:49:33 UTC (rev 136594)
@@ -38,6 +38,7 @@
 OBJC_CLASS CALayer;
 OBJC_CLASS WebTileCacheLayer;
 OBJC_CLASS WebTileLayer;
+OBJC_CLASS WebTiledScrollingIndicatorLayer;
 
 namespace WebCore {
 
@@ -61,6 +62,7 @@
     void drawLayer(WebTileLayer *, CGContextRef);
 
     void setScale(CGFloat);
+    CGFloat scale() const { return m_scale; }
 
     bool acceleratesDrawing() const { return m_acceleratesDrawing; }
     void setAcceleratesDrawing(bool);
@@ -78,6 +80,9 @@
     unsigned blankPixelCount() const;
     static unsigned blankPixelCountForTiles(const WebTileLayerList&, IntRect, IntPoint);
 
+    // Only public for the WebTileCacheMapLayer.
+    void drawTileMapContents(CGContextRef, CGRect);
+    
 private:
     TileCache(WebTileCacheLayer*);
 
@@ -92,7 +97,9 @@
     virtual void setScrollingPerformanceLoggingEnabled(bool flag) OVERRIDE { m_scrollingPerformanceLoggingEnabled = flag; }
     virtual bool scrollingPerformanceLoggingEnabled() const OVERRIDE { return m_scrollingPerformanceLoggingEnabled; }
     virtual IntRect tileCoverageRect() const OVERRIDE;
-    
+    virtual CALayer *tiledScrollingIndicatorLayer() OVERRIDE;
+    virtual void setScrollingModeIndication(ScrollingModeIndication) OVERRIDE;
+
     IntRect bounds() const;
 
     typedef IntPoint TileIndex;
@@ -105,6 +112,7 @@
     void scheduleTileRevalidation(double interval);
     void tileRevalidationTimerFired(Timer<TileCache>*);
     void revalidateTiles();
+    void updateTileCoverageMap();
 
     WebTileLayer* tileLayerAtIndex(const TileIndex&) const;
     RetainPtr<WebTileLayer> createTileLayer(const IntRect&);
@@ -114,6 +122,8 @@
 
     WebTileCacheLayer* m_tileCacheLayer;
     RetainPtr<CALayer> m_tileContainerLayer;
+    RetainPtr<WebTiledScrollingIndicatorLayer> m_tiledScrollingIndicatorLayer; // Used for coverage visualization.
+
     IntSize m_tileSize;
     IntRect m_visibleRect;
 
@@ -133,6 +143,7 @@
 
     RetainPtr<CGColorRef> m_tileDebugBorderColor;
     float m_tileDebugBorderWidth;
+    ScrollingModeIndication m_indicatorMode;
 };
 
 } // namespace WebCore

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


--- trunk/Source/WebCore/platform/graphics/ca/mac/TileCache.mm	2012-12-05 00:43:13 UTC (rev 136593)
+++ trunk/Source/WebCore/platform/graphics/ca/mac/TileCache.mm	2012-12-05 00:49:33 UTC (rev 136594)
@@ -33,7 +33,9 @@
 #import "WebLayer.h"
 #import "WebTileCacheLayer.h"
 #import "WebTileLayer.h"
+#import <QuartzCore/QuartzCore.h>
 #import <wtf/MainThread.h>
+#import <WebCore/BlockExceptions.h>
 #import <utility>
 
 using namespace std;
@@ -44,6 +46,39 @@
 @end
 #endif
 
+@interface WebTiledScrollingIndicatorLayer : CALayer {
+    WebCore::TileCache* _tileCache;
+    CALayer *_visibleRectFrameLayer; // Owned by being a sublayer.
+}
+@property (assign) WebCore::TileCache* tileCache;
+@property (assign) CALayer* visibleRectFrameLayer;
+@end
+
+@implementation WebTiledScrollingIndicatorLayer
+@synthesize tileCache = _tileCache;
+@synthesize visibleRectFrameLayer = _visibleRectFrameLayer;
+- (id)init
+{
+    if ((self = [super init])) {
+        [self setStyle:[NSDictionary dictionaryWithObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNull null], @"bounds", [NSNull null], @"position", [NSNull null], @"contents", nil] forKey:@"actions"]];
+
+        _visibleRectFrameLayer = [CALayer layer];
+        [_visibleRectFrameLayer setStyle:[NSDictionary dictionaryWithObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNull null], @"bounds", [NSNull null], @"position", nil] forKey:@"actions"]];
+        [self addSublayer:_visibleRectFrameLayer];
+        [_visibleRectFrameLayer setBorderColor:WebCore::cachedCGColor(WebCore::Color(255, 0, 0), WebCore::ColorSpaceDeviceRGB)];
+        [_visibleRectFrameLayer setBorderWidth:2];
+        return self;
+    }
+    return nil;
+}
+
+- (void)drawInContext:(CGContextRef)context
+{
+    if (_tileCache)
+        _tileCache->drawTileMapContents(context, [self bounds]);
+}
+@end
+
 namespace WebCore {
 
 static const int defaultTileCacheWidth = 512;
@@ -67,6 +102,7 @@
     , m_acceleratesDrawing(false)
     , m_tilesAreOpaque(false)
     , m_tileDebugBorderWidth(0)
+    , m_indicatorMode(ThreadedScrollingIndication)
 {
     [CATransaction begin];
     [CATransaction setDisableActions:YES];
@@ -85,6 +121,9 @@
         WebTileLayer* tileLayer = it->value.get();
         [tileLayer setTileCache:0];
     }
+    
+    if (m_tiledScrollingIndicatorLayer)
+        [m_tiledScrollingIndicatorLayer.get() setTileCache:nil];
 }
 
 void TileCache::tileCacheLayerBoundsChanged()
@@ -458,11 +497,56 @@
         m_tileCoverageRect.unite(rectForTileIndex(tileIndex));
     }
 
+    if (m_tiledScrollingIndicatorLayer)
+        updateTileCoverageMap();
+
     if (dirtyRects.isEmpty())
         return;
     platformLayer->owner()->platformCALayerDidCreateTiles(dirtyRects);
 }
 
+void TileCache::updateTileCoverageMap()
+{
+    FloatRect containerBounds = bounds();
+    FloatRect visibleRect = this->visibleRect();
+
+    float widthScale = 1;
+    float scale = 1;
+    if (!containerBounds.isEmpty()) {
+        widthScale = std::min<float>(visibleRect.width() / containerBounds.width(), 0.1);
+        scale = std::min(widthScale, visibleRect.height() / containerBounds.height());
+    }
+    
+    FloatRect mapBounds = containerBounds;
+    mapBounds.scale(scale, scale);
+    
+    BEGIN_BLOCK_OBJC_EXCEPTIONS
+    
+    [m_tiledScrollingIndicatorLayer.get() setBounds:mapBounds];
+    [m_tiledScrollingIndicatorLayer.get() setNeedsDisplay];
+
+    visibleRect.scale(scale, scale);
+    visibleRect.expand(2, 2);
+    [[m_tiledScrollingIndicatorLayer.get() visibleRectFrameLayer] setFrame:visibleRect];
+
+    Color backgroundColor;
+    switch (m_indicatorMode) {
+    case MainThreadScrollingBecauseOfStyleIndictaion:
+        backgroundColor = Color(255, 0, 0);
+        break;
+    case MainThreadScrollingBecauseOfEventHandlersIndication:
+        backgroundColor = Color(255, 255, 0);
+        break;
+    case ThreadedScrollingIndication:
+        backgroundColor = Color(0, 200, 0);
+        break;
+    }
+
+    [[m_tiledScrollingIndicatorLayer.get() visibleRectFrameLayer] setBorderColor:cachedCGColor(backgroundColor, ColorSpaceDeviceRGB)];
+
+    END_BLOCK_OBJC_EXCEPTIONS
+}
+
 IntRect TileCache::tileGridExtent() const
 {
     TileIndex topLeft;
@@ -481,6 +565,31 @@
     return coverageRectInLayerCoords;
 }
 
+CALayer *TileCache::tiledScrollingIndicatorLayer()
+{
+    if (!m_tiledScrollingIndicatorLayer) {
+        m_tiledScrollingIndicatorLayer = [WebTiledScrollingIndicatorLayer layer];
+        [m_tiledScrollingIndicatorLayer.get() setTileCache:this];
+        [m_tiledScrollingIndicatorLayer.get() setOpacity:0.75];
+        [m_tiledScrollingIndicatorLayer.get() setAnchorPoint:CGPointZero];
+        [m_tiledScrollingIndicatorLayer.get() setBorderColor:cachedCGColor(Color::black, ColorSpaceDeviceRGB)];
+        [m_tiledScrollingIndicatorLayer.get() setBorderWidth:1];
+        [m_tiledScrollingIndicatorLayer.get() setPosition:CGPointMake(2, 2)];
+        updateTileCoverageMap();
+    }
+
+    return m_tiledScrollingIndicatorLayer.get();
+}
+
+void TileCache::setScrollingModeIndication(ScrollingModeIndication scrollingMode)
+{
+    if (scrollingMode == m_indicatorMode)
+        return;
+
+    m_indicatorMode = scrollingMode;
+    updateTileCoverageMap();
+}
+
 WebTileLayer* TileCache::tileLayerAtIndex(const TileIndex& index) const
 {
     return m_tiles.get(index).get();
@@ -567,4 +676,27 @@
     CGContextRestoreGState(context);
 }
 
+void TileCache::drawTileMapContents(CGContextRef context, CGRect layerBounds)
+{
+    CGContextSetRGBFillColor(context, 0.5, 0.5, 0.5, 1);
+    CGContextFillRect(context, layerBounds);
+
+    CGFloat scaleFactor = layerBounds.size.width / bounds().width();
+    
+    CGContextSetRGBFillColor(context, 1, 1, 1, 1);
+    CGContextSetRGBStrokeColor(context, 0, 0, 0, 1);
+    CGContextSetLineWidth(context, 1 / scaleFactor);
+
+    CGFloat contextScale = scaleFactor / scale();
+    CGContextScaleCTM(context, contextScale, contextScale);
+    
+    for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
+        WebTileLayer* tileLayer = it->value.get();
+        CGRect frame = [tileLayer frame];
+        CGContextStrokeRect(context, frame);
+        CGContextFillRect(context, frame);
+    }
+}
+    
+
 } // namespace WebCore

Modified: trunk/Source/WebKit2/ChangeLog (136593 => 136594)


--- trunk/Source/WebKit2/ChangeLog	2012-12-05 00:43:13 UTC (rev 136593)
+++ trunk/Source/WebKit2/ChangeLog	2012-12-05 00:49:33 UTC (rev 136594)
@@ -1,3 +1,28 @@
+2012-12-04  Simon Fraser  <[email protected]>
+
+        Show a mini visualizer for the tile cache tiles
+        https://bugs.webkit.org/show_bug.cgi?id=104053
+
+        Reviewed by Beth Dakin.
+
+        Plumb through a preference that controls the visibility of a tiled
+        scrolling indicator, and parent that layer in the TiledCoreAnimationDrawingArea.
+
+        * Shared/WebPreferencesStore.h:
+        * UIProcess/API/C/WKPreferences.cpp:
+        (WKPreferencesSetTiledScrollingIndicatorVisible):
+        (WKPreferencesGetTiledScrollingIndicatorVisible):
+        * UIProcess/API/C/WKPreferencesPrivate.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::updatePreferences):
+        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h:
+        (TiledCoreAnimationDrawingArea):
+        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
+        (WebKit::TiledCoreAnimationDrawingArea::updatePreferences):
+        (WebKit::TiledCoreAnimationDrawingArea::setRootCompositingLayer):
+        (WebKit::TiledCoreAnimationDrawingArea::mainFrameTiledBacking):
+        (WebKit::TiledCoreAnimationDrawingArea::updateDebugInfoLayer):
+
 2012-12-04  Anders Carlsson  <[email protected]>
 
         Set the visible process name before entering the sandbox

Modified: trunk/Source/WebKit2/Shared/WebPreferencesStore.h (136593 => 136594)


--- trunk/Source/WebKit2/Shared/WebPreferencesStore.h	2012-12-05 00:43:13 UTC (rev 136593)
+++ trunk/Source/WebKit2/Shared/WebPreferencesStore.h	2012-12-05 00:49:33 UTC (rev 136594)
@@ -85,6 +85,7 @@
     macro(CanvasUsesAcceleratedDrawing, canvasUsesAcceleratedDrawing, Bool, bool, true) \
     macro(CompositingBordersVisible, compositingBordersVisible, Bool, bool, false) \
     macro(CompositingRepaintCountersVisible, compositingRepaintCountersVisible, Bool, bool, false) \
+    macro(TiledScrollingIndicatorVisible, tiledScrollingIndicatorVisible, Bool, bool, false) \
     macro(CSSCustomFilterEnabled, cssCustomFilterEnabled, Bool, bool, true) \
     macro(WebGLEnabled, webGLEnabled, Bool, bool, false) \
     macro(Accelerated2dCanvasEnabled, accelerated2dCanvasEnabled, Bool, bool, false) \

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


--- trunk/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp	2012-12-05 00:43:13 UTC (rev 136593)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp	2012-12-05 00:49:33 UTC (rev 136594)
@@ -438,6 +438,16 @@
     return toImpl(preferencesRef)->compositingRepaintCountersVisible();
 }
 
+void WKPreferencesSetTiledScrollingIndicatorVisible(WKPreferencesRef preferencesRef, bool flag)
+{
+    toImpl(preferencesRef)->setTiledScrollingIndicatorVisible(flag);
+}
+
+bool WKPreferencesGetTiledScrollingIndicatorVisible(WKPreferencesRef preferencesRef)
+{
+    return toImpl(preferencesRef)->tiledScrollingIndicatorVisible();
+}
+
 void WKPreferencesSetCSSCustomFilterEnabled(WKPreferencesRef preferencesRef, bool flag)
 {
     toImpl(preferencesRef)->setCSSCustomFilterEnabled(flag);

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


--- trunk/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h	2012-12-05 00:43:13 UTC (rev 136593)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h	2012-12-05 00:49:33 UTC (rev 136594)
@@ -83,6 +83,10 @@
 WK_EXPORT void WKPreferencesSetCompositingRepaintCountersVisible(WKPreferencesRef, bool);
 WK_EXPORT bool WKPreferencesGetCompositingRepaintCountersVisible(WKPreferencesRef);
 
+// Defaults to false.
+WK_EXPORT void WKPreferencesSetTiledScrollingIndicatorVisible(WKPreferencesRef, bool);
+WK_EXPORT bool WKPreferencesGetTiledScrollingIndicatorVisible(WKPreferencesRef);
+
 // Defaults to true.
 WK_EXPORT void WKPreferencesSetCSSCustomFilterEnabled(WKPreferencesRef, bool flag);
 WK_EXPORT bool WKPreferencesGetCSSCustomFilterEnabled(WKPreferencesRef);

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (136593 => 136594)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2012-12-05 00:43:13 UTC (rev 136593)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2012-12-05 00:49:33 UTC (rev 136594)
@@ -2278,6 +2278,7 @@
     settings->setCanvasUsesAcceleratedDrawing(store.getBoolValueForKey(WebPreferencesKey::canvasUsesAcceleratedDrawingKey()) && LayerTreeHost::supportsAcceleratedCompositing());
     settings->setShowDebugBorders(store.getBoolValueForKey(WebPreferencesKey::compositingBordersVisibleKey()));
     settings->setShowRepaintCounter(store.getBoolValueForKey(WebPreferencesKey::compositingRepaintCountersVisibleKey()));
+    settings->setShowTiledScrollingIndicator(store.getBoolValueForKey(WebPreferencesKey::tiledScrollingIndicatorVisibleKey()));
     settings->setCSSCustomFilterEnabled(store.getBoolValueForKey(WebPreferencesKey::cssCustomFilterEnabledKey()));
     RuntimeEnabledFeatures::setCSSRegionsEnabled(store.getBoolValueForKey(WebPreferencesKey::cssRegionsEnabledKey()));
     settings->setCSSGridLayoutEnabled(store.getBoolValueForKey(WebPreferencesKey::cssGridLayoutEnabledKey()));

Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h (136593 => 136594)


--- trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h	2012-12-05 00:43:13 UTC (rev 136593)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h	2012-12-05 00:49:33 UTC (rev 136594)
@@ -38,6 +38,10 @@
 OBJC_CLASS CALayer;
 OBJC_CLASS WKContentLayer;
 
+namespace WebCore {
+class TiledBacking;
+}
+
 namespace WebKit {
 
 class LayerHostingContext;
@@ -92,6 +96,8 @@
 
     void createPageOverlayLayer();
     void destroyPageOverlayLayer();
+    WebCore::TiledBacking* mainFrameTiledBacking() const;
+    void updateDebugInfoLayer(bool showLayer);
 
     bool m_layerTreeStateIsFrozen;
     WebCore::LayerFlushScheduler m_layerFlushScheduler;

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


--- trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm	2012-12-05 00:43:13 UTC (rev 136593)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm	2012-12-05 00:49:33 UTC (rev 136594)
@@ -215,20 +215,11 @@
     m_webPage->corePage()->settings()->setAcceleratedCompositingForFixedPositionEnabled(true);
     m_webPage->corePage()->settings()->setFixedPositionCreatesStackingContext(true);
 
-    bool showDebugBorders = m_webPage->corePage()->settings()->showDebugBorders();
-
-    if (showDebugBorders == !!m_debugInfoLayer)
+    bool showTiledScrollingIndicator = m_webPage->corePage()->settings()->showTiledScrollingIndicator();
+    if (showTiledScrollingIndicator == !!m_debugInfoLayer)
         return;
 
-    if (showDebugBorders) {
-        m_debugInfoLayer = [CALayer layer];
-        [m_rootLayer.get() addSublayer:m_debugInfoLayer.get()];
-    } else {
-        [m_debugInfoLayer.get() removeFromSuperlayer];
-        m_debugInfoLayer = nullptr;
-    }
-
-    ScrollingThread::dispatch(bind(&ScrollingTree::setDebugRootLayer, m_webPage->corePage()->scrollingCoordinator()->scrollingTree(), m_debugInfoLayer));
+    updateDebugInfoLayer(showTiledScrollingIndicator);
 }
 
 void TiledCoreAnimationDrawingArea::mainFrameContentSizeChanged(const IntSize& contentSize)
@@ -456,8 +447,7 @@
     if (m_pageOverlayLayer)
         [m_rootLayer.get() addSublayer:m_pageOverlayLayer->platformLayer()];
 
-    if (m_debugInfoLayer)
-        [m_rootLayer.get() addSublayer:m_debugInfoLayer.get()];
+    updateDebugInfoLayer(m_webPage->corePage()->settings()->showTiledScrollingIndicator());
 
     [CATransaction commit];
 }
@@ -494,6 +484,34 @@
     m_pageOverlayLayer = nullptr;
 }
 
+TiledBacking* TiledCoreAnimationDrawingArea::mainFrameTiledBacking() const
+{
+    Frame* frame = m_webPage->corePage()->mainFrame();
+    if (!frame)
+        return 0;
+    
+    FrameView* frameView = frame->view();
+    return frameView ? frameView->tiledBacking() : 0;
+}
+
+void TiledCoreAnimationDrawingArea::updateDebugInfoLayer(bool showLayer)
+{
+    if (showLayer) {
+        if (TiledBacking* tiledBacking = mainFrameTiledBacking())
+            m_debugInfoLayer = tiledBacking->tiledScrollingIndicatorLayer();
+        
+        if (m_debugInfoLayer) {
+#ifndef NDEBUG
+            [m_debugInfoLayer.get() setName:@"Debug Info"];
+#endif
+            [m_rootLayer.get() addSublayer:m_debugInfoLayer.get()];
+        }
+    } else if (m_debugInfoLayer) {
+        [m_debugInfoLayer.get() removeFromSuperlayer];
+        m_debugInfoLayer = nullptr;
+    }
+}
+
 } // namespace WebKit
 
 #endif // ENABLE(THREADED_SCROLLING)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to