Changeset 261876 in webkit


Ignore:
Timestamp:
May 19, 2020, 11:41:14 AM (5 years ago)
Author:
Simon Fraser
Message:

Push a PlatformDisplayID to scrolling trees, and allow the scrolling thread to get displayDidRefresh notifications
https://bugs.webkit.org/show_bug.cgi?id=211034

Reviewed by Sam Weinig.

Source/WebCore:

As work towards scrolling thread synchronization with main thread (webkit.org/b210884), allow
ScrollingTree to get a displayDidRefresh() call on the scrolling thread. Each
tree is associated with a Page which is associated with a display, so the ScrollingTree
needs to have a PlatformDisplayID to know which notifications to respond to.

Eventually, displayDidRefresh() will be used to trigger layer updates on the scrolling
thread if the main thread is periodically unresponsive.

  • page/Page.cpp:

(WebCore::Page::scrollingCoordinator):
(WebCore::Page::windowScreenDidChange):

  • page/scrolling/AsyncScrollingCoordinator.cpp:

(WebCore::AsyncScrollingCoordinator::windowScreenDidChange):

  • page/scrolling/AsyncScrollingCoordinator.h:
  • page/scrolling/ScrollingCoordinator.h:

(WebCore::ScrollingCoordinator::windowScreenDidChange):

  • page/scrolling/ScrollingTree.cpp:

(WebCore::ScrollingTree::windowScreenDidChange):
(WebCore::ScrollingTree::displayID):

  • page/scrolling/ScrollingTree.h:

(WebCore::ScrollingTree::displayDidRefresh):

  • page/scrolling/ThreadedScrollingTree.cpp:

(WebCore::ThreadedScrollingTree::displayDidRefresh):

  • page/scrolling/ThreadedScrollingTree.h:

Source/WebKit:

Prep work for webkit.org/b210884.

Have EventDispatcher call displayDidRefresh() on each scrolling tree it knows about. It calls this
on the EventDispatcher thread; the scrolling tree is responsible for bouncing that to the scrolling thread.

  • WebProcess/WebPage/EventDispatcher.cpp:

(WebKit::EventDispatcher::displayDidRefreshOnScrollingThread):
(WebKit::EventDispatcher::displayWasRefreshed):

  • WebProcess/WebPage/EventDispatcher.h:
Location:
trunk/Source
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r261874 r261876  
     12020-05-19  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Push a PlatformDisplayID to scrolling trees, and allow the scrolling thread to get displayDidRefresh notifications
     4        https://bugs.webkit.org/show_bug.cgi?id=211034
     5
     6        Reviewed by Sam Weinig.
     7
     8        As work towards scrolling thread synchronization with main thread (webkit.org/b210884), allow
     9        ScrollingTree to get a displayDidRefresh() call on the scrolling thread. Each
     10        tree is associated with a Page which is associated with a display, so the ScrollingTree
     11        needs to have a PlatformDisplayID to know which notifications to respond to.
     12
     13        Eventually, displayDidRefresh() will be used to trigger layer updates on the scrolling
     14        thread if the main thread is periodically unresponsive.
     15
     16        * page/Page.cpp:
     17        (WebCore::Page::scrollingCoordinator):
     18        (WebCore::Page::windowScreenDidChange):
     19        * page/scrolling/AsyncScrollingCoordinator.cpp:
     20        (WebCore::AsyncScrollingCoordinator::windowScreenDidChange):
     21        * page/scrolling/AsyncScrollingCoordinator.h:
     22        * page/scrolling/ScrollingCoordinator.h:
     23        (WebCore::ScrollingCoordinator::windowScreenDidChange):
     24        * page/scrolling/ScrollingTree.cpp:
     25        (WebCore::ScrollingTree::windowScreenDidChange):
     26        (WebCore::ScrollingTree::displayID):
     27        * page/scrolling/ScrollingTree.h:
     28        (WebCore::ScrollingTree::displayDidRefresh):
     29        * page/scrolling/ThreadedScrollingTree.cpp:
     30        (WebCore::ThreadedScrollingTree::displayDidRefresh):
     31        * page/scrolling/ThreadedScrollingTree.h:
     32
    1332020-05-19  Simon Fraser  <simon.fraser@apple.com>
    234
  • trunk/Source/WebCore/page/Page.cpp

    r261741 r261876  
    435435        if (!m_scrollingCoordinator)
    436436            m_scrollingCoordinator = ScrollingCoordinator::create(this);
     437
     438        m_scrollingCoordinator->windowScreenDidChange(m_displayID);
    437439    }
    438440
     
    11201122            frame->document()->windowScreenDidChange(displayID);
    11211123    }
     1124
     1125    if (m_scrollingCoordinator)
     1126        m_scrollingCoordinator->windowScreenDidChange(displayID);
    11221127
    11231128    renderingUpdateScheduler().windowScreenDidChange(displayID);
  • trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp

    r261849 r261876  
    817817}
    818818
     819void AsyncScrollingCoordinator::windowScreenDidChange(PlatformDisplayID displayID)
     820{
     821    if (m_scrollingTree)
     822        m_scrollingTree->windowScreenDidChange(displayID);
     823}
     824
    819825bool AsyncScrollingCoordinator::isRubberBandInProgress() const
    820826{
  • trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h

    r261052 r261876  
    139139    WEBCORE_EXPORT bool hasSynchronousScrollingReasons(ScrollingNodeID) const final;
    140140
     141    WEBCORE_EXPORT void windowScreenDidChange(PlatformDisplayID) final;
     142
    141143    virtual void scheduleTreeStateCommit() = 0;
    142144
  • trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h

    r261539 r261876  
    6969#endif
    7070
     71using PlatformDisplayID = uint32_t;
     72
    7173class ScrollingCoordinator : public ThreadSafeRefCounted<ScrollingCoordinator> {
    7274public:
     
    180182    virtual void scrollableAreaScrollbarLayerDidChange(ScrollableArea&, ScrollbarOrientation) { }
    181183
     184    virtual void windowScreenDidChange(PlatformDisplayID) { }
     185
    182186    static String synchronousScrollingReasonsAsText(OptionSet<SynchronousScrollingReason>);
    183187    String synchronousScrollingReasonsAsText() const;
  • trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp

    r261849 r261876  
    528528}
    529529
     530void ScrollingTree::windowScreenDidChange(PlatformDisplayID displayID)
     531{
     532    LockHolder locker(m_treeStateMutex);
     533    m_treeState.displayID = displayID;
     534}
     535
     536PlatformDisplayID ScrollingTree::displayID()
     537{
     538    LockHolder locker(m_treeStateMutex);
     539    return m_treeState.displayID;
     540}
     541
    530542void ScrollingTree::setScrollingPerformanceLoggingEnabled(bool flag)
    531543{
  • trunk/Source/WebCore/page/scrolling/ScrollingTree.h

    r261602 r261876  
    5555class ScrollingTreeScrollingNode;
    5656enum class EventListenerRegionType : uint8_t;
     57using PlatformDisplayID = uint32_t;
    5758
    5859class ScrollingTree : public ThreadSafeRefCounted<ScrollingTree> {
     
    179180    virtual void unlockLayersForHitTesting() { }
    180181
     182    void windowScreenDidChange(PlatformDisplayID);
     183    PlatformDisplayID displayID();
     184
    181185protected:
    182186    FloatPoint mainFrameScrollPosition() const;
     
    217221        EventTrackingRegions eventTrackingRegions;
    218222        FloatPoint mainFrameScrollPosition;
     223        PlatformDisplayID displayID { 0 };
    219224        bool mainFrameIsRubberBanding { false };
    220225        bool mainFrameIsScrollSnapping { false };
  • trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp

    r261849 r261876  
    203203#endif
    204204
     205void ThreadedScrollingTree::displayDidRefresh(PlatformDisplayID displayID)
     206{
     207    if (displayID != this->displayID())
     208        return;
     209
     210    // We're on the EventDispatcher thread here.
     211
     212#if ENABLE(SCROLLING_THREAD)
     213    ScrollingThread::dispatch([protectedThis = makeRef(*this)]() {
     214        protectedThis->displayDidRefreshOnScrollingThread();
     215    });
     216#endif
     217}
     218
     219void ThreadedScrollingTree::displayDidRefreshOnScrollingThread()
     220{
     221    ASSERT(ScrollingThread::isCurrentThread());
     222}
     223
    205224} // namespace WebCore
    206225
  • trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.h

    r261427 r261876  
    5656    void invalidate() override;
    5757
     58    WEBCORE_EXPORT void displayDidRefresh(PlatformDisplayID);
     59
    5860protected:
    5961    explicit ThreadedScrollingTree(AsyncScrollingCoordinator&);
     
    7779    void propagateSynchronousScrollingReasons(const HashSet<ScrollingNodeID>&) override;
    7880
     81    void displayDidRefreshOnScrollingThread();
     82
    7983    RefPtr<AsyncScrollingCoordinator> m_scrollingCoordinator;
    8084};
  • trunk/Source/WebKit/ChangeLog

    r261875 r261876  
     12020-05-19  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Push a PlatformDisplayID to scrolling trees, and allow the scrolling thread to get displayDidRefresh notifications
     4        https://bugs.webkit.org/show_bug.cgi?id=211034
     5
     6        Reviewed by Sam Weinig.
     7
     8        Prep work for webkit.org/b210884.
     9
     10        Have EventDispatcher call displayDidRefresh() on each scrolling tree it knows about. It calls this
     11        on the EventDispatcher thread; the scrolling tree is responsible for bouncing that to the scrolling thread.
     12
     13        * WebProcess/WebPage/EventDispatcher.cpp:
     14        (WebKit::EventDispatcher::displayDidRefreshOnScrollingThread):
     15        (WebKit::EventDispatcher::displayWasRefreshed):
     16        * WebProcess/WebPage/EventDispatcher.h:
     17
    1182020-05-19  Wenson Hsieh  <wenson_hsieh@apple.com>
    219
  • trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp

    r260614 r261876  
    266266void EventDispatcher::displayWasRefreshed(PlatformDisplayID displayID)
    267267{
     268#if ENABLE(SCROLLING_THREAD)
     269    LockHolder locker(m_scrollingTreesMutex);
     270    for (auto keyValuePair : m_scrollingTrees)
     271        keyValuePair.value->displayDidRefresh(displayID);
     272#endif
     273
    268274    RunLoop::main().dispatch([displayID]() {
    269275        DisplayRefreshMonitorManager::sharedManager().displayWasUpdated(displayID);
  • trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.h

    r260614 r261876  
    103103#endif
    104104
     105#if ENABLE(SCROLLING_THREAD)
     106    void displayDidRefreshOnScrollingThread(WebCore::PlatformDisplayID);
     107#endif
     108
    105109    Ref<WorkQueue> m_queue;
    106110
Note: See TracChangeset for help on using the changeset viewer.