Title: [170557] trunk/Source
Revision
170557
Author
an...@apple.com
Date
2014-06-27 14:58:06 -0700 (Fri, 27 Jun 2014)

Log Message

Flush throttling with remote layers
https://bugs.webkit.org/show_bug.cgi?id=134398

Reviewed by Darin Adler.


Source/WebCore: 
With remote layer trees the flush scheduling lives in the WebKit2 layer. The throttling code
needs to live there as well.
        
Add the required callbacks and disable the existing throttling code in RenderLayerCompositor
when remote layers are in use. Later we can get rid of the RenderLayerCompositor throttling code.

* WebCore.xcodeproj/project.pbxproj:
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::loadProgressingStatusChanged):
* page/ChromeClient.h:
(WebCore::ChromeClient::adjustLayerFlushThrottling):
* page/FrameView.cpp:
(WebCore::FrameView::disableLayerFlushThrottlingTemporarilyForInteraction):
(WebCore::FrameView::loadProgressingStatusChanged):
        
    Factor the progress status change activities to a function.

(WebCore::FrameView::updateLayerFlushThrottling):
(WebCore::FrameView::setExposedRect):
        
    Move the call to adjustTiledBackingCoverage from WebKit to here.

(WebCore::FrameView::updateLayerFlushThrottlingInAllFrames): Deleted.
* page/FrameView.h:
* page/LayerFlushThrottleState.h: Added.
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::RenderLayerCompositor):

Source/WebKit2: 
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::adjustLayerFlushThrottling):
* WebProcess/WebCoreSupport/WebChromeClient.h:
* WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm:
* WebProcess/WebPage/DrawingArea.h:
(WebKit::DrawingArea::adjustLayerFlushThrottling):
* WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h:
* WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:
(WebKit::RemoteLayerTreeDrawingArea::RemoteLayerTreeDrawingArea):
(WebKit::RemoteLayerTreeDrawingArea::updateScrolledExposedRect):
(WebKit::RemoteLayerTreeDrawingArea::scheduleCompositingLayerFlush):

    Delay layer flushes during page loading.
    If use interacts with the page the next flush in unthrottled even if loading is in progress.

(WebKit::RemoteLayerTreeDrawingArea::adjustLayerFlushThrottling):
        
    Compute the new delay. The first visual flush uses a shorter delay.
    Flush immediately when we are no longer throttling.

* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
(WebKit::TiledCoreAnimationDrawingArea::updateScrolledExposedRect):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (170556 => 170557)


--- trunk/Source/WebCore/ChangeLog	2014-06-27 21:57:25 UTC (rev 170556)
+++ trunk/Source/WebCore/ChangeLog	2014-06-27 21:58:06 UTC (rev 170557)
@@ -1,3 +1,38 @@
+2014-06-27  Antti Koivisto  <an...@apple.com>
+
+        Flush throttling with remote layers
+        https://bugs.webkit.org/show_bug.cgi?id=134398
+
+        Reviewed by Darin Adler.
+
+        With remote layer trees the flush scheduling lives in the WebKit2 layer. The throttling code
+        needs to live there as well.
+        
+        Add the required callbacks and disable the existing throttling code in RenderLayerCompositor
+        when remote layers are in use. Later we can get rid of the RenderLayerCompositor throttling code.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::loadProgressingStatusChanged):
+        * page/ChromeClient.h:
+        (WebCore::ChromeClient::adjustLayerFlushThrottling):
+        * page/FrameView.cpp:
+        (WebCore::FrameView::disableLayerFlushThrottlingTemporarilyForInteraction):
+        (WebCore::FrameView::loadProgressingStatusChanged):
+        
+            Factor the progress status change activities to a function.
+
+        (WebCore::FrameView::updateLayerFlushThrottling):
+        (WebCore::FrameView::setExposedRect):
+        
+            Move the call to adjustTiledBackingCoverage from WebKit to here.
+
+        (WebCore::FrameView::updateLayerFlushThrottlingInAllFrames): Deleted.
+        * page/FrameView.h:
+        * page/LayerFlushThrottleState.h: Added.
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::RenderLayerCompositor):
+
 2014-06-27  Brady Eidson  <beid...@apple.com>
 
         The user pressing a button on a gamepad should cause gamepads to become visible to all NavigatorGamepads.

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (170556 => 170557)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2014-06-27 21:57:25 UTC (rev 170556)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2014-06-27 21:58:06 UTC (rev 170557)
@@ -6150,6 +6150,7 @@
 		E47E276816036EDC00EE2AFB /* DocumentStyleSheetCollection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E47E276716036EDC00EE2AFB /* DocumentStyleSheetCollection.cpp */; };
 		E48944A2180B57D800F165D8 /* SimpleLineLayout.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E48944A0180B57D800F165D8 /* SimpleLineLayout.cpp */; };
 		E48944A3180B57D800F165D8 /* SimpleLineLayout.h in Headers */ = {isa = PBXBuildFile; fileRef = E48944A1180B57D800F165D8 /* SimpleLineLayout.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		E4916FF7195DF6A0005AB349 /* LayerFlushThrottleState.h in Headers */ = {isa = PBXBuildFile; fileRef = E4916FF6195DF6A0005AB349 /* LayerFlushThrottleState.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		E4946EAE156E64DD00D3297F /* StyleRuleImport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4946EAC156E64DD00D3297F /* StyleRuleImport.cpp */; };
 		E4946EAF156E64DD00D3297F /* StyleRuleImport.h in Headers */ = {isa = PBXBuildFile; fileRef = E4946EAD156E64DD00D3297F /* StyleRuleImport.h */; };
 		E49BD9FA131FD2ED003C56F0 /* CSSValuePool.h in Headers */ = {isa = PBXBuildFile; fileRef = E49BD9F9131FD2ED003C56F0 /* CSSValuePool.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -13647,6 +13648,7 @@
 		E47E276716036EDC00EE2AFB /* DocumentStyleSheetCollection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentStyleSheetCollection.cpp; sourceTree = "<group>"; };
 		E48944A0180B57D800F165D8 /* SimpleLineLayout.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SimpleLineLayout.cpp; sourceTree = "<group>"; };
 		E48944A1180B57D800F165D8 /* SimpleLineLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleLineLayout.h; sourceTree = "<group>"; };
+		E4916FF6195DF6A0005AB349 /* LayerFlushThrottleState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayerFlushThrottleState.h; sourceTree = "<group>"; };
 		E4946EAC156E64DD00D3297F /* StyleRuleImport.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleRuleImport.cpp; sourceTree = "<group>"; };
 		E4946EAD156E64DD00D3297F /* StyleRuleImport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleRuleImport.h; sourceTree = "<group>"; };
 		E49BD9F9131FD2ED003C56F0 /* CSSValuePool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSValuePool.h; sourceTree = "<group>"; };
@@ -16572,6 +16574,7 @@
 				BC94D1500C275C8B006BC617 /* History.cpp */,
 				BC94D1510C275C8B006BC617 /* History.h */,
 				BC94D1520C275C8B006BC617 /* History.idl */,
+				E4916FF6195DF6A0005AB349 /* LayerFlushThrottleState.h */,
 				931D72F515FE695300C4C07E /* LayoutMilestones.h */,
 				BCE1C41A0D982980003B02F2 /* Location.cpp */,
 				BCE1C4190D982980003B02F2 /* Location.h */,
@@ -24362,6 +24365,7 @@
 				977B37241228721700B81FF8 /* HTMLElementStack.h in Headers */,
 				B562DB6017D3CD630010AF96 /* HTMLElementTypeHelpers.h in Headers */,
 				A871D45C0A127CBC00B12A68 /* HTMLEmbedElement.h in Headers */,
+				E4916FF7195DF6A0005AB349 /* LayerFlushThrottleState.h in Headers */,
 				977B386A122883E900B81FF8 /* HTMLEntityParser.h in Headers */,
 				977B386C122883E900B81FF8 /* HTMLEntitySearch.h in Headers */,
 				977B386D122883E900B81FF8 /* HTMLEntityTable.h in Headers */,

Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (170556 => 170557)


--- trunk/Source/WebCore/loader/FrameLoader.cpp	2014-06-27 21:57:25 UTC (rev 170556)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp	2014-06-27 21:58:06 UTC (rev 170557)
@@ -3408,12 +3408,8 @@
 
 void FrameLoader::loadProgressingStatusChanged()
 {
-    FrameView* view = m_frame.mainFrame().view();
-    if (!view)
-        return;
-
-    view->updateLayerFlushThrottlingInAllFrames();
-    view->adjustTiledBackingCoverage();
+    if (auto* view = m_frame.mainFrame().view())
+        view->loadProgressingStatusChanged();
 }
 
 void FrameLoader::forcePageTransitionIfNeeded()

Modified: trunk/Source/WebCore/page/ChromeClient.h (170556 => 170557)


--- trunk/Source/WebCore/page/ChromeClient.h	2014-06-27 21:57:25 UTC (rev 170556)
+++ trunk/Source/WebCore/page/ChromeClient.h	2014-06-27 21:58:06 UTC (rev 170557)
@@ -29,6 +29,7 @@
 #include "FrameLoader.h"
 #include "GraphicsContext.h"
 #include "HostWindow.h"
+#include "LayerFlushThrottleState.h"
 #include "PopupMenu.h"
 #include "PopupMenuClient.h"
 #include "RenderEmbeddedObject.h"
@@ -327,6 +328,8 @@
     // Returns true if layer tree updates are disabled.
     virtual bool layerTreeStateIsFrozen() const { return false; }
 
+    virtual bool adjustLayerFlushThrottling(LayerFlushThrottleState::Flags) { return false; }
+
     virtual PassRefPtr<ScrollingCoordinator> createScrollingCoordinator(Page*) const { return nullptr; }
 
 #if PLATFORM(WIN) && USE(AVFOUNDATION)

Modified: trunk/Source/WebCore/page/FrameView.cpp (170556 => 170557)


--- trunk/Source/WebCore/page/FrameView.cpp	2014-06-27 21:57:25 UTC (rev 170556)
+++ trunk/Source/WebCore/page/FrameView.cpp	2014-06-27 21:58:06 UTC (rev 170557)
@@ -2253,13 +2253,33 @@
 
 void FrameView::disableLayerFlushThrottlingTemporarilyForInteraction()
 {
+    bool mainLoadProgressing = frame().page()->progress().isMainLoadProgressing();
+
+    LayerFlushThrottleState::Flags flags = LayerFlushThrottleState::UserIsInteracting | (mainLoadProgressing ? LayerFlushThrottleState::MainLoadProgressing : 0);
+    if (frame().page()->chrome().client().adjustLayerFlushThrottling(flags))
+        return;
+
     if (RenderView* view = renderView())
         view->compositor().disableLayerFlushThrottlingTemporarilyForInteraction();
 }
 
-void FrameView::updateLayerFlushThrottlingInAllFrames()
+void FrameView::loadProgressingStatusChanged()
 {
+    updateLayerFlushThrottling();
+    adjustTiledBackingCoverage();
+}
+
+void FrameView::updateLayerFlushThrottling()
+{
+    ASSERT(frame().isMainFrame());
+
     bool isMainLoadProgressing = frame().page()->progress().isMainLoadProgressing();
+
+    // See if the client is handling throttling.
+    LayerFlushThrottleState::Flags flags = isMainLoadProgressing ? LayerFlushThrottleState::MainLoadProgressing : 0;
+    if (frame().page()->chrome().client().adjustLayerFlushThrottling(flags))
+        return;
+
     for (Frame* frame = m_frame.get(); frame; frame = frame->tree().traverseNext(m_frame.get())) {
         if (RenderView* renderView = frame->contentRenderer())
             renderView->compositor().setLayerFlushThrottlingEnabled(isMainLoadProgressing);
@@ -4420,8 +4440,10 @@
     // FIXME: We should support clipping to the exposed rect for subframes as well.
     if (!m_frame->isMainFrame())
         return;
-    if (TiledBacking* tiledBacking = this->tiledBacking())
+    if (TiledBacking* tiledBacking = this->tiledBacking()) {
+        adjustTiledBackingCoverage();
         tiledBacking->setTiledScrollingIndicatorPosition(exposedRect.location());
+    }
 
     if (auto* view = renderView())
         view->compositor().scheduleLayerFlush(false /* canThrottle */);

Modified: trunk/Source/WebCore/page/FrameView.h (170556 => 170557)


--- trunk/Source/WebCore/page/FrameView.h	2014-06-27 21:57:25 UTC (rev 170556)
+++ trunk/Source/WebCore/page/FrameView.h	2014-06-27 21:58:06 UTC (rev 170557)
@@ -290,9 +290,8 @@
     bool fixedElementsLayoutRelativeToFrame() const;
 
     void disableLayerFlushThrottlingTemporarilyForInteraction();
-    void updateLayerFlushThrottlingInAllFrames();
-    void adjustTiledBackingCoverage();
     bool speculativeTilingEnabled() const { return m_speculativeTilingEnabled; }
+    void loadProgressingStatusChanged();
 
 #if ENABLE(DASHBOARD_SUPPORT)
     void updateAnnotatedRegions();
@@ -544,6 +543,9 @@
     void performPostLayoutTasks();
     void autoSizeIfEnabled();
 
+    void updateLayerFlushThrottling();
+    void adjustTiledBackingCoverage();
+
     virtual void repaintContentRectangle(const IntRect&) override;
     virtual void contentsResized() override;
     virtual void visibleContentsResized() override;

Added: trunk/Source/WebCore/page/LayerFlushThrottleState.h (0 => 170557)


--- trunk/Source/WebCore/page/LayerFlushThrottleState.h	                        (rev 0)
+++ trunk/Source/WebCore/page/LayerFlushThrottleState.h	2014-06-27 21:58:06 UTC (rev 170557)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2014 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 LayerFlushThrottleState_h
+#define LayerFlushThrottleState_h
+
+namespace WebCore {
+
+struct LayerFlushThrottleState {
+    enum {
+        MainLoadProgressing = 1 << 0,
+        UserIsInteracting = 1 << 1
+    };
+    typedef unsigned Flags;
+};
+
+} // namespace WebCore
+
+#endif // LayerFlushThrottleState_h

Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (170556 => 170557)


--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2014-06-27 21:57:25 UTC (rev 170556)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2014-06-27 21:58:06 UTC (rev 170557)
@@ -45,7 +45,6 @@
 #include "MainFrame.h"
 #include "NodeList.h"
 #include "Page.h"
-#include "ProgressTracker.h"
 #include "RenderEmbeddedObject.h"
 #include "RenderFlowThread.h"
 #include "RenderFullScreen.h"
@@ -284,7 +283,7 @@
     , m_layersWithTiledBackingCount(0)
     , m_rootLayerAttachment(RootLayerUnattached)
     , m_layerFlushTimer(this, &RenderLayerCompositor::layerFlushTimerFired)
-    , m_layerFlushThrottlingEnabled(page() && page()->progress().isMainLoadProgressing())
+    , m_layerFlushThrottlingEnabled(false)
     , m_layerFlushThrottlingTemporarilyDisabledForInteraction(false)
     , m_hasPendingLayerFlush(false)
     , m_paintRelatedMilestonesTimer(this, &RenderLayerCompositor::paintRelatedMilestonesTimerFired)

Modified: trunk/Source/WebKit2/ChangeLog (170556 => 170557)


--- trunk/Source/WebKit2/ChangeLog	2014-06-27 21:57:25 UTC (rev 170556)
+++ trunk/Source/WebKit2/ChangeLog	2014-06-27 21:58:06 UTC (rev 170557)
@@ -1,3 +1,33 @@
+2014-06-27  Antti Koivisto  <an...@apple.com>
+
+        Flush throttling with remote layers
+        https://bugs.webkit.org/show_bug.cgi?id=134398
+
+        Reviewed by Darin Adler.
+
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::adjustLayerFlushThrottling):
+        * WebProcess/WebCoreSupport/WebChromeClient.h:
+        * WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm:
+        * WebProcess/WebPage/DrawingArea.h:
+        (WebKit::DrawingArea::adjustLayerFlushThrottling):
+        * WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h:
+        * WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:
+        (WebKit::RemoteLayerTreeDrawingArea::RemoteLayerTreeDrawingArea):
+        (WebKit::RemoteLayerTreeDrawingArea::updateScrolledExposedRect):
+        (WebKit::RemoteLayerTreeDrawingArea::scheduleCompositingLayerFlush):
+
+            Delay layer flushes during page loading.
+            If use interacts with the page the next flush in unthrottled even if loading is in progress.
+
+        (WebKit::RemoteLayerTreeDrawingArea::adjustLayerFlushThrottling):
+        
+            Compute the new delay. The first visual flush uses a shorter delay.
+            Flush immediately when we are no longer throttling.
+
+        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
+        (WebKit::TiledCoreAnimationDrawingArea::updateScrolledExposedRect):
+
 2014-06-27  Joseph Pecoraro  <pecor...@apple.com>
 
         [iOS][WK2] <select> tapping "next" does not save new picker value

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp (170556 => 170557)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp	2014-06-27 21:57:25 UTC (rev 170556)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp	2014-06-27 21:58:06 UTC (rev 170557)
@@ -843,6 +843,10 @@
         m_page->drawingArea()->scheduleCompositingLayerFlush();
 }
 
+bool WebChromeClient::adjustLayerFlushThrottling(WebCore::LayerFlushThrottleState::Flags flags)
+{
+    return m_page->drawingArea() && m_page->drawingArea()->adjustLayerFlushThrottling(flags);
+}
 
 bool WebChromeClient::layerTreeStateIsFrozen() const
 {

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h (170556 => 170557)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h	2014-06-27 21:57:25 UTC (rev 170556)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h	2014-06-27 21:58:06 UTC (rev 170557)
@@ -210,6 +210,7 @@
     virtual void attachRootGraphicsLayer(WebCore::Frame*, WebCore::GraphicsLayer*) override;
     virtual void setNeedsOneShotDrawingSynchronization() override;
     virtual void scheduleCompositingLayerFlush() override;
+    virtual bool adjustLayerFlushThrottling(WebCore::LayerFlushThrottleState::Flags) override;
     virtual WebCore::GraphicsLayer* documentOverlayLayerForFrame(WebCore::Frame&) override;
 
 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm (170556 => 170557)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm	2014-06-27 21:57:25 UTC (rev 170556)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm	2014-06-27 21:58:06 UTC (rev 170557)
@@ -28,11 +28,12 @@
 
 #if PLATFORM(IOS)
 
-#import <WebCore/NotImplemented.h>
+#import "DrawingArea.h"
 #import "WebCoreArgumentCoders.h"
 #import "WebFrame.h"
 #import "WebPage.h"
 #import "WebPageProxyMessages.h"
+#import <WebCore/NotImplemented.h>
 
 namespace WebKit {
 

Modified: trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.h (170556 => 170557)


--- trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.h	2014-06-27 21:57:25 UTC (rev 170556)
+++ trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.h	2014-06-27 21:58:06 UTC (rev 170557)
@@ -30,6 +30,7 @@
 #include "LayerTreeContext.h"
 #include <WebCore/FloatRect.h>
 #include <WebCore/IntRect.h>
+#include <WebCore/LayerFlushThrottleState.h>
 #include <WebCore/PlatformScreen.h>
 #include <WebCore/ViewState.h>
 #include <functional>
@@ -119,6 +120,8 @@
 
     virtual bool markLayersVolatileImmediatelyIfPossible() { return true; }
 
+    virtual bool adjustLayerFlushThrottling(WebCore::LayerFlushThrottleState::Flags) { return false; }
+
 protected:
     DrawingArea(DrawingAreaType, WebPage&);
 

Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h (170556 => 170557)


--- trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h	2014-06-27 21:57:25 UTC (rev 170556)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h	2014-06-27 21:58:06 UTC (rev 170557)
@@ -99,6 +99,8 @@
 
     virtual void viewStateDidChange(WebCore::ViewState::Flags changed, bool wantsDidUpdateViewState) override;
 
+    virtual bool adjustLayerFlushThrottling(WebCore::LayerFlushThrottleState::Flags) override;
+
     // GraphicsLayerClient
     virtual void notifyAnimationStarted(const WebCore::GraphicsLayer*, double time) override { }
     virtual void notifyFlushRequired(const WebCore::GraphicsLayer*) override { }
@@ -143,6 +145,9 @@
     WebCore::Timer<RemoteLayerTreeDrawingArea> m_layerFlushTimer;
     bool m_isFlushingSuspended;
     bool m_hasDeferredFlush;
+    bool m_isThrottlingLayerFlushes;
+    bool m_isLayerFlushThrottlingTemporarilyDisabledForInteraction;
+    bool m_isInitialThrottledLayerFlush;
 
     bool m_waitingForBackingStoreSwap;
     bool m_hadFlushDeferredWhileWaitingForBackingStoreSwap;

Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm (170556 => 170557)


--- trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm	2014-06-27 21:57:25 UTC (rev 170556)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm	2014-06-27 21:58:06 UTC (rev 170557)
@@ -59,6 +59,9 @@
     , m_layerFlushTimer(this, &RemoteLayerTreeDrawingArea::layerFlushTimerFired)
     , m_isFlushingSuspended(false)
     , m_hasDeferredFlush(false)
+    , m_isThrottlingLayerFlushes(false)
+    , m_isLayerFlushThrottlingTemporarilyDisabledForInteraction(false)
+    , m_isInitialThrottledLayerFlush(false)
     , m_waitingForBackingStoreSwap(false)
     , m_hadFlushDeferredWhileWaitingForBackingStoreSwap(false)
     , m_displayRefreshMonitorsToNotify(nullptr)
@@ -226,7 +229,6 @@
 #endif
 
     frameView->setExposedRect(m_scrolledExposedRect);
-    frameView->adjustTiledBackingCoverage();
 
     m_webPage.pageOverlayController().didChangeExposedRect();
 }
@@ -239,12 +241,47 @@
 
 void RemoteLayerTreeDrawingArea::scheduleCompositingLayerFlush()
 {
+    if (m_isFlushingSuspended) {
+        m_isLayerFlushThrottlingTemporarilyDisabledForInteraction = false;
+        m_hasDeferredFlush = true;
+        return;
+    }
+    if (m_isLayerFlushThrottlingTemporarilyDisabledForInteraction) {
+        m_isLayerFlushThrottlingTemporarilyDisabledForInteraction = false;
+        m_layerFlushTimer.startOneShot(0_ms);
+        return;
+    }
+
     if (m_layerFlushTimer.isActive())
         return;
 
-    m_layerFlushTimer.startOneShot(0);
+    const auto initialFlushDelay = 500_ms;
+    const auto flushDelay = 1500_ms;
+    auto throttleDelay = m_isThrottlingLayerFlushes ? (m_isInitialThrottledLayerFlush ? initialFlushDelay : flushDelay) : 0_ms;
+    m_isInitialThrottledLayerFlush = false;
+
+    m_layerFlushTimer.startOneShot(throttleDelay);
 }
 
+bool RemoteLayerTreeDrawingArea::adjustLayerFlushThrottling(WebCore::LayerFlushThrottleState::Flags flags)
+{
+    if (flags & WebCore::LayerFlushThrottleState::UserIsInteracting)
+        m_isLayerFlushThrottlingTemporarilyDisabledForInteraction = true;
+
+    bool wasThrottlingLayerFlushes = m_isThrottlingLayerFlushes;
+    m_isThrottlingLayerFlushes = flags & WebCore::LayerFlushThrottleState::MainLoadProgressing;
+
+    if (!wasThrottlingLayerFlushes && m_isThrottlingLayerFlushes)
+        m_isInitialThrottledLayerFlush = true;
+
+    // Re-schedule the flush if we stopped throttling.
+    if (wasThrottlingLayerFlushes && !m_isThrottlingLayerFlushes && m_layerFlushTimer.isActive()) {
+        m_layerFlushTimer.stop();
+        scheduleCompositingLayerFlush();
+    }
+    return true;
+}
+
 void RemoteLayerTreeDrawingArea::layerFlushTimerFired(WebCore::Timer<RemoteLayerTreeDrawingArea>*)
 {
     flushLayers();

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


--- trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm	2014-06-27 21:57:25 UTC (rev 170556)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm	2014-06-27 21:58:06 UTC (rev 170557)
@@ -358,7 +358,6 @@
 #endif
 
     frameView->setExposedRect(m_scrolledExposedRect);
-    frameView->adjustTiledBackingCoverage();
 
     m_webPage.pageOverlayController().didChangeExposedRect();
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to