Title: [237629] trunk/Source/WebKit
Revision
237629
Author
an...@apple.com
Date
2018-10-31 02:56:48 -0700 (Wed, 31 Oct 2018)

Log Message

Stop using LayerFlushScheduler in WK2
https://bugs.webkit.org/show_bug.cgi?id=191065

Reviewed by Tim Horton.

Code gets more understandable when TiledCoreAnimationDrawingArea simply uses RunLoopObserver
directly for flush scheduling. LayerFlushScheduler can be later moved to WK1.

* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h:
* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
(WebKit::TiledCoreAnimationDrawingArea::TiledCoreAnimationDrawingArea):
(WebKit::TiledCoreAnimationDrawingArea::~TiledCoreAnimationDrawingArea):
(WebKit::TiledCoreAnimationDrawingArea::setLayerTreeStateIsFrozen):
(WebKit::TiledCoreAnimationDrawingArea::scheduleCompositingLayerFlush):
(WebKit::TiledCoreAnimationDrawingArea::dispatchAfterEnsuringUpdatedScrollPosition):
(WebKit::TiledCoreAnimationDrawingArea::layerFlushRunLoopCallback):
(WebKit::TiledCoreAnimationDrawingArea::invalidateLayerFlushRunLoopObserver):
(WebKit::TiledCoreAnimationDrawingArea::scheduleLayerFlushRunLoopObserver):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (237628 => 237629)


--- trunk/Source/WebKit/ChangeLog	2018-10-31 07:29:19 UTC (rev 237628)
+++ trunk/Source/WebKit/ChangeLog	2018-10-31 09:56:48 UTC (rev 237629)
@@ -1,3 +1,24 @@
+2018-10-31  Antti Koivisto  <an...@apple.com>
+
+        Stop using LayerFlushScheduler in WK2
+        https://bugs.webkit.org/show_bug.cgi?id=191065
+
+        Reviewed by Tim Horton.
+
+        Code gets more understandable when TiledCoreAnimationDrawingArea simply uses RunLoopObserver
+        directly for flush scheduling. LayerFlushScheduler can be later moved to WK1.
+
+        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h:
+        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
+        (WebKit::TiledCoreAnimationDrawingArea::TiledCoreAnimationDrawingArea):
+        (WebKit::TiledCoreAnimationDrawingArea::~TiledCoreAnimationDrawingArea):
+        (WebKit::TiledCoreAnimationDrawingArea::setLayerTreeStateIsFrozen):
+        (WebKit::TiledCoreAnimationDrawingArea::scheduleCompositingLayerFlush):
+        (WebKit::TiledCoreAnimationDrawingArea::dispatchAfterEnsuringUpdatedScrollPosition):
+        (WebKit::TiledCoreAnimationDrawingArea::layerFlushRunLoopCallback):
+        (WebKit::TiledCoreAnimationDrawingArea::invalidateLayerFlushRunLoopObserver):
+        (WebKit::TiledCoreAnimationDrawingArea::scheduleLayerFlushRunLoopObserver):
+
 2018-10-31  Claudio Saavedra  <csaave...@igalia.com>
 
         [WPE][GTK] Certificates loaded from the cache don't include the certificate chain

Modified: trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h (237628 => 237629)


--- trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h	2018-10-31 07:29:19 UTC (rev 237628)
+++ trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h	2018-10-31 09:56:48 UTC (rev 237629)
@@ -31,8 +31,6 @@
 #include "DrawingArea.h"
 #include "LayerTreeContext.h"
 #include <WebCore/FloatRect.h>
-#include <WebCore/LayerFlushScheduler.h>
-#include <WebCore/LayerFlushSchedulerClient.h>
 #include <WebCore/TransformationMatrix.h>
 #include <wtf/HashMap.h>
 #include <wtf/RetainPtr.h>
@@ -43,6 +41,7 @@
 namespace WebCore {
 class FrameView;
 class PlatformCALayer;
+class RunLoopObserver;
 class TiledBacking;
 }
 
@@ -50,7 +49,7 @@
 
 class LayerHostingContext;
 
-class TiledCoreAnimationDrawingArea : public DrawingArea, WebCore::LayerFlushSchedulerClient {
+class TiledCoreAnimationDrawingArea : public DrawingArea {
 public:
     TiledCoreAnimationDrawingArea(WebPage&, const WebPageCreationParameters&);
     virtual ~TiledCoreAnimationDrawingArea();
@@ -88,8 +87,7 @@
 
     bool dispatchDidReachLayoutMilestone(WebCore::LayoutMilestones) override;
 
-    // WebCore::LayerFlushSchedulerClient
-    bool flushLayers() override;
+    bool flushLayers();
 
     // Message handlers.
     void updateGeometry(const WebCore::IntSize& viewSize, bool flushSynchronously, const WTF::MachSendRight& fencePort) override;
@@ -127,8 +125,11 @@
 
     void sendPendingNewlyReachedLayoutMilestones();
 
+    void layerFlushRunLoopCallback();
+    void invalidateLayerFlushRunLoopObserver();
+    void scheduleLayerFlushRunLoopObserver();
+
     bool m_layerTreeStateIsFrozen;
-    WebCore::LayerFlushScheduler m_layerFlushScheduler;
 
     std::unique_ptr<LayerHostingContext> m_layerHostingContext;
 
@@ -164,6 +165,8 @@
 
     WebCore::LayoutMilestones m_pendingNewlyReachedLayoutMilestones { 0 };
     Vector<CallbackID> m_pendingCallbackIDs;
+
+    std::unique_ptr<WebCore::RunLoopObserver> m_layerFlushRunLoopObserver;
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm (237628 => 237629)


--- trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm	2018-10-31 07:29:19 UTC (rev 237628)
+++ trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm	2018-10-31 09:56:48 UTC (rev 237629)
@@ -51,6 +51,7 @@
 #import <WebCore/RenderLayerBacking.h>
 #import <WebCore/RenderLayerCompositor.h>
 #import <WebCore/RenderView.h>
+#import <WebCore/RunLoopObserver.h>
 #import <WebCore/ScrollbarTheme.h>
 #import <WebCore/Settings.h>
 #import <WebCore/TiledBacking.h>
@@ -75,7 +76,6 @@
 TiledCoreAnimationDrawingArea::TiledCoreAnimationDrawingArea(WebPage& webPage, const WebPageCreationParameters& parameters)
     : DrawingArea(DrawingAreaTypeTiledCoreAnimation, webPage)
     , m_layerTreeStateIsFrozen(false)
-    , m_layerFlushScheduler(this)
     , m_isPaintingSuspended(!(parameters.activityState & ActivityState::IsVisible))
     , m_transientZoomScale(1)
     , m_sendDidUpdateActivityStateTimer(RunLoop::main(), this, &TiledCoreAnimationDrawingArea::didUpdateActivityStateTimerFired)
@@ -89,6 +89,10 @@
     [m_hostingLayer setOpaque:YES];
     [m_hostingLayer setGeometryFlipped:YES];
 
+    m_layerFlushRunLoopObserver = std::make_unique<WebCore::RunLoopObserver>(static_cast<CFIndex>(RunLoopObserver::WellKnownRunLoopOrders::LayerFlush), [this]() {
+        this->layerFlushRunLoopCallback();
+    });
+
     updateLayerHostingContext();
     setColorSpace(parameters.colorSpace);
 
@@ -98,10 +102,9 @@
 
 TiledCoreAnimationDrawingArea::~TiledCoreAnimationDrawingArea()
 {
-    m_layerFlushScheduler.invalidate();
+    invalidateLayerFlushRunLoopObserver();
 }
 
-
 void TiledCoreAnimationDrawingArea::attach()
 {
     LayerTreeContext layerTreeContext;
@@ -170,10 +173,11 @@
         return;
 
     m_layerTreeStateIsFrozen = layerTreeStateIsFrozen;
+
     if (m_layerTreeStateIsFrozen)
-        m_layerFlushScheduler.suspend();
+        invalidateLayerFlushRunLoopObserver();
     else
-        m_layerFlushScheduler.resume();
+        scheduleLayerFlushRunLoopObserver();
 }
 
 bool TiledCoreAnimationDrawingArea::layerTreeStateIsFrozen() const
@@ -183,7 +187,10 @@
 
 void TiledCoreAnimationDrawingArea::scheduleCompositingLayerFlush()
 {
-    m_layerFlushScheduler.schedule();
+    if (m_layerTreeStateIsFrozen)
+        return;
+
+    scheduleLayerFlushRunLoopObserver();
 }
 
 void TiledCoreAnimationDrawingArea::scheduleCompositingLayerFlushImmediately()
@@ -374,7 +381,7 @@
     m_webPage.corePage()->scrollingCoordinator()->commitTreeStateIfNeeded();
 
     if (!m_layerTreeStateIsFrozen)
-        m_layerFlushScheduler.suspend();
+        invalidateLayerFlushRunLoopObserver();
 
     // It is possible for the drawing area to be destroyed before the bound block
     // is invoked, so grab a reference to the web page here so we can access the drawing area through it.
@@ -389,7 +396,7 @@
         function();
 
         if (!m_layerTreeStateIsFrozen)
-            m_layerFlushScheduler.resume();
+            scheduleLayerFlushRunLoopObserver();
 
         webPage->deref();
     });
@@ -415,7 +422,8 @@
 
 bool TiledCoreAnimationDrawingArea::flushLayers()
 {
-    ASSERT(!m_layerTreeStateIsFrozen);
+    if (layerTreeStateIsFrozen())
+        return false;
 
     @autoreleasepool {
         scaleViewToFitDocumentIfNeeded();
@@ -567,8 +575,7 @@
         size = contentSize;
     }
 
-    if (!m_layerTreeStateIsFrozen)
-        flushLayers();
+    flushLayers();
 
     [CATransaction begin];
     [CATransaction setDisableActions:YES];
@@ -889,6 +896,22 @@
     return true;
 }
 
+void TiledCoreAnimationDrawingArea::layerFlushRunLoopCallback()
+{
+    if (flushLayers())
+        invalidateLayerFlushRunLoopObserver();
+}
+
+void TiledCoreAnimationDrawingArea::invalidateLayerFlushRunLoopObserver()
+{
+    m_layerFlushRunLoopObserver->invalidate();
+}
+
+void TiledCoreAnimationDrawingArea::scheduleLayerFlushRunLoopObserver()
+{
+    m_layerFlushRunLoopObserver->schedule(CFRunLoopGetCurrent());
+}
+
 } // namespace WebKit
 
 #endif // !PLATFORM(IOS_FAMILY)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to