Changeset 216101 in webkit


Ignore:
Timestamp:
May 2, 2017, 3:50:46 PM (8 years ago)
Author:
yoon@igalia.com
Message:

[GTK] Drop coordinated surfaces from the compositing thread as soon as possible
https://bugs.webkit.org/show_bug.cgi?id=171544

Reviewed by Žan Doberšek.

Source/WebCore:

  • platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h:

Remove atlasesToRemove from the GraphicsState. It is not a commit
state anymore.

Source/WebKit2:

Released coordinated surface from the main thread didn't be freed until
next commit message because the deletion of coordinated surfaces is
considered as a part of scene state. We need to release corresponding
surfaces whenever the compositing coordinator drops update atlases to
reduce memory usages.

No new tests, only an optimization.

  • Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp:

Remove atlasesToRemove from the GraphicsState. it is not a commit
state anymore.

  • Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp:

(WebKit::CoordinatedGraphicsScene::syncUpdateAtlases):
(WebKit::CoordinatedGraphicsScene::releaseUpdateAtlases):

  • Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h:
  • Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:

(WebKit::CompositingCoordinator::releaseAtlases): Pass the list of
released update atlases to the compositing thread right after cleaning
up deactivated update atlases.

  • Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h:
  • WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp:

(WebKit::CompositingCoordinator::clearPendingStateChanges):
(WebKit::CompositingCoordinator::removeUpdateAtlas):
(WebKit::CompositingCoordinator::releaseAtlases):

  • WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h:
  • WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h:
  • WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp:

(WebKit::ThreadedCoordinatedLayerTreeHost::releaseUpdateAtlases):

  • WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h:
Location:
trunk/Source
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r216097 r216101  
     12017-05-02  Gwang Yoon Hwang  <yoon@igalia.com>
     2
     3        [GTK] Drop coordinated surfaces from the compositing thread as soon as possible
     4        https://bugs.webkit.org/show_bug.cgi?id=171544
     5
     6        Reviewed by Žan Doberšek.
     7
     8        * platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h:
     9        Remove atlasesToRemove from the GraphicsState. It is not a commit
     10        state anymore.
     11
    1122017-05-02  Gwang Yoon Hwang  <yoon@igalia.com>
    213
  • trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h

    r215259 r216101  
    187187
    188188    Vector<std::pair<uint32_t /* atlasID */, RefPtr<CoordinatedSurface> > > updateAtlasesToCreate;
    189     Vector<uint32_t /* atlasID */> updateAtlasesToRemove;
    190189};
    191190
  • trunk/Source/WebKit2/ChangeLog

    r216098 r216101  
     12017-05-02  Gwang Yoon Hwang  <yoon@igalia.com>
     2
     3        [GTK] Drop coordinated surfaces from the compositing thread as soon as possible
     4        https://bugs.webkit.org/show_bug.cgi?id=171544
     5
     6        Reviewed by Žan Doberšek.
     7
     8        Released coordinated surface from the main thread didn't be freed until
     9        next commit message because the deletion of coordinated surfaces is
     10        considered as a part of scene state.  We need to release corresponding
     11        surfaces whenever the compositing coordinator drops update atlases to
     12        reduce memory usages.
     13
     14        No new tests, only an optimization.
     15
     16        * Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp:
     17        Remove atlasesToRemove from the GraphicsState. it is not a commit
     18        state anymore.
     19        * Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp:
     20        (WebKit::CoordinatedGraphicsScene::syncUpdateAtlases):
     21        (WebKit::CoordinatedGraphicsScene::releaseUpdateAtlases):
     22        * Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h:
     23        * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
     24        (WebKit::CompositingCoordinator::releaseAtlases): Pass the list of
     25        released update atlases to the compositing thread right after cleaning
     26        up deactivated update atlases.
     27        * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h:
     28        * WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp:
     29        (WebKit::CompositingCoordinator::clearPendingStateChanges):
     30        (WebKit::CompositingCoordinator::removeUpdateAtlas):
     31        (WebKit::CompositingCoordinator::releaseAtlases):
     32        * WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h:
     33        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h:
     34        * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp:
     35        (WebKit::ThreadedCoordinatedLayerTreeHost::releaseUpdateAtlases):
     36        * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h:
     37
    1382017-05-02  Timothy Horton  <timothy_horton@apple.com>
    239
  • trunk/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp

    r212638 r216101  
    847847        encodeCoordinatedSurface(encoder, state.updateAtlasesToCreate[i].second);
    848848    }
    849     encoder << state.updateAtlasesToRemove;
    850849}
    851850
     
    914913    }
    915914
    916     if (!decoder.decode(state.updateAtlasesToRemove))
    917         return false;
    918 
    919915    return true;
    920916}
  • trunk/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp

    r215259 r216101  
    425425    for (auto& atlas : state.updateAtlasesToCreate)
    426426        createUpdateAtlas(atlas.first, atlas.second);
    427 
    428     for (auto& atlas : state.updateAtlasesToRemove)
    429         removeUpdateAtlas(atlas);
    430427}
    431428
     
    440437    ASSERT(m_surfaces.contains(atlasID));
    441438    m_surfaces.remove(atlasID);
     439}
     440
     441void CoordinatedGraphicsScene::releaseUpdateAtlases(const Vector<uint32_t>& atlasesToRemove)
     442{
     443    for (auto& atlas : atlasesToRemove)
     444        removeUpdateAtlas(atlas);
    442445}
    443446
  • trunk/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h

    r215259 r216101  
    8585    void setViewBackgroundColor(const WebCore::Color& color) { m_viewBackgroundColor = color; }
    8686    WebCore::Color viewBackgroundColor() const { return m_viewBackgroundColor; }
     87
     88    void releaseUpdateAtlases(const Vector<uint32_t>&);
    8789
    8890private:
  • trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp

    r215259 r216101  
    245245}
    246246
     247void ThreadedCompositor::releaseUpdateAtlases(Vector<uint32_t>&& atlasesToRemove)
     248{
     249    ASSERT(isMainThread());
     250    m_compositingRunLoop->performTask([scene = makeRef(*m_scene), atlasesToRemove = WTFMove(atlasesToRemove)] {
     251        scene->releaseUpdateAtlases(atlasesToRemove);
     252    });
     253}
     254
    247255#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
    248256RefPtr<WebCore::DisplayRefreshMonitor> ThreadedCompositor::displayRefreshMonitor(PlatformDisplayID)
  • trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h

    r215259 r216101  
    7575
    7676    void updateSceneState(const WebCore::CoordinatedGraphicsState&);
     77    void releaseUpdateAtlases(Vector<uint32_t>&&);
    7778
    7879    void invalidate();
  • trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp

    r215167 r216101  
    182182
    183183    m_state.updateAtlasesToCreate.clear();
    184     m_state.updateAtlasesToRemove.clear();
    185184}
    186185
     
    305304    if (m_isPurging)
    306305        return;
    307     m_state.updateAtlasesToRemove.append(atlasID);
     306    m_atlasesToRemove.append(atlasID);
    308307}
    309308
     
    444443    if (m_updateAtlases.size() <= 1)
    445444        m_releaseInactiveAtlasesTimer.stop();
     445
     446    if (!m_atlasesToRemove.isEmpty())
     447        m_client.releaseUpdateAtlases(WTFMove(m_atlasesToRemove));
    446448}
    447449
  • trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h

    r215088 r216101  
    6161        virtual void commitSceneState(const WebCore::CoordinatedGraphicsState&) = 0;
    6262        virtual void paintLayerContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, const WebCore::IntRect& clipRect) = 0;
     63        virtual void releaseUpdateAtlases(Vector<uint32_t>&&) = 0;
    6364    };
    6465
     
    149150    ImageBackingMap m_imageBackings;
    150151    Vector<std::unique_ptr<UpdateAtlas>> m_updateAtlases;
     152    Vector<uint32_t> m_atlasesToRemove;
    151153
    152154    // We don't send the messages related to releasing resources to renderer during purging, because renderer already had removed all resources.
  • trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h

    r212608 r216101  
    7373    void commitSceneState(const WebCore::CoordinatedGraphicsState&) override;
    7474    void paintLayerContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, const WebCore::IntRect& clipRect) override;
     75    void releaseUpdateAtlases(Vector<uint32_t>&&) override { };
    7576
    7677private:
  • trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp

    r215259 r216101  
    221221}
    222222
     223void ThreadedCoordinatedLayerTreeHost::releaseUpdateAtlases(Vector<uint32_t>&& atlasesToRemove)
     224{
     225    m_compositor->releaseUpdateAtlases(WTFMove(atlasesToRemove));
     226}
     227
    223228void ThreadedCoordinatedLayerTreeHost::setIsDiscardable(bool discardable)
    224229{
  • trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h

    r215259 r216101  
    101101    void didFlushRootLayer(const WebCore::FloatRect&) override { }
    102102    void commitSceneState(const WebCore::CoordinatedGraphicsState&) override;
     103    void releaseUpdateAtlases(Vector<uint32_t>&&) override;
    103104
    104105#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
Note: See TracChangeset for help on using the changeset viewer.