Changeset 202812 in webkit


Ignore:
Timestamp:
Jul 4, 2016 11:16:09 PM (8 years ago)
Author:
Carlos Garcia Campos
Message:

[Coordinated Graphics] Modernize and cleanup CompositingCoordinator
https://bugs.webkit.org/show_bug.cgi?id=159212

Reviewed by Žan Doberšek.

Source/WebCore:

Use references instead of pointers when possible.

  • platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:

(WebCore::CoordinatedGraphicsLayer::paintToSurface):

  • platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
  • platform/graphics/texmap/coordinated/CoordinatedImageBacking.cpp:

(WebCore::CoordinatedImageBacking::update):

  • platform/graphics/texmap/coordinated/CoordinatedImageBacking.h:
  • platform/graphics/texmap/coordinated/CoordinatedSurface.h:
  • platform/graphics/texmap/coordinated/Tile.cpp:

(WebCore::Tile::updateBackBuffer):

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

Source/WebKit2:

Changes done:

  • Use references instead of pointers when possible.
  • Add missing final/override keywords.
  • Reduce the use of PassRefPtr
  • Move member initializations to the declaration.
  • Use nullptr instead of 0.
  • Use HashMap::ensure() instead of complicated code with iterators.
  • Avoid heap allocation when possible.
  • Shared/CoordinatedGraphics/WebCoordinatedSurface.cpp:

(WebKit::WebCoordinatedSurface::paintToSurface):

  • Shared/CoordinatedGraphics/WebCoordinatedSurface.h:
  • Shared/CoordinatedGraphics/threadedcompositor/ThreadSafeCoordinatedSurface.cpp:

(WebKit::ThreadSafeCoordinatedSurface::paintToSurface):

  • Shared/CoordinatedGraphics/threadedcompositor/ThreadSafeCoordinatedSurface.h:
  • WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.cpp:

(WebKit::GeneralAreaAllocator::expand):
(WebKit::GeneralAreaAllocator::splitNode):
(WebKit::GeneralAreaAllocator::release):
(WebKit::GeneralAreaAllocator::GeneralAreaAllocator): Deleted.

  • WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.h:
  • WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp:

(WebKit::CompositingCoordinator::CompositingCoordinator):
(WebKit::CompositingCoordinator::flushPendingLayerChanges):
(WebKit::CompositingCoordinator::createImageBackingIfNeeded):
(WebKit::CompositingCoordinator::updateImageBacking):
(WebKit::CompositingCoordinator::notifyFlushRequired):
(WebKit::CompositingCoordinator::paintContents):
(WebKit::CompositingCoordinator::createUpdateAtlas):
(WebKit::CompositingCoordinator::commitScrollOffset):
(WebKit::CompositingCoordinator::paintToSurface):

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

(WebKit::CoordinatedLayerTreeHost::CoordinatedLayerTreeHost):
(WebKit::CoordinatedLayerTreeHost::setViewOverlayRootLayer):
(WebKit::CoordinatedLayerTreeHost::setRootCompositingLayer):
(WebKit::CoordinatedLayerTreeHost::invalidate):
(WebKit::CoordinatedLayerTreeHost::forceRepaint):
(WebKit::CoordinatedLayerTreeHost::sizeDidChange):
(WebKit::CoordinatedLayerTreeHost::setVisibleContentsRect):
(WebKit::CoordinatedLayerTreeHost::renderNextFrame):
(WebKit::CoordinatedLayerTreeHost::purgeBackingStores):
(WebKit::CoordinatedLayerTreeHost::layerFlushTimerFired):
(WebKit::CoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged):
(WebKit::CoordinatedLayerTreeHost::graphicsLayerFactory):
(WebKit::CoordinatedLayerTreeHost::scheduleAnimation):
(WebKit::CoordinatedLayerTreeHost::commitScrollOffset):

  • WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h:
  • WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.cpp:

(WebKit::UpdateAtlas::UpdateAtlas):
(WebKit::UpdateAtlas::~UpdateAtlas):
(WebKit::UpdateAtlas::buildLayoutIfNeeded):
(WebKit::UpdateAtlas::paintOnAvailableBuffer):
(WebKit::UpdateAtlasSurfaceClient::UpdateAtlasSurfaceClient): Deleted.

  • WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.h:
Location:
trunk/Source
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r202811 r202812  
     12016-07-04  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [Coordinated Graphics] Modernize and cleanup CompositingCoordinator
     4        https://bugs.webkit.org/show_bug.cgi?id=159212
     5
     6        Reviewed by Žan Doberšek.
     7
     8        Use references instead of pointers when possible.
     9
     10        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
     11        (WebCore::CoordinatedGraphicsLayer::paintToSurface):
     12        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
     13        * platform/graphics/texmap/coordinated/CoordinatedImageBacking.cpp:
     14        (WebCore::CoordinatedImageBacking::update):
     15        * platform/graphics/texmap/coordinated/CoordinatedImageBacking.h:
     16        * platform/graphics/texmap/coordinated/CoordinatedSurface.h:
     17        * platform/graphics/texmap/coordinated/Tile.cpp:
     18        (WebCore::Tile::updateBackBuffer):
     19        * platform/graphics/texmap/coordinated/TiledBackingStoreClient.h:
     20
    1212016-07-04  Youenn Fablet  <youenn@apple.com>
    222
  • trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp

    r200813 r202812  
    951951}
    952952
    953 bool CoordinatedGraphicsLayer::paintToSurface(const IntSize& size, uint32_t& atlas, IntPoint& offset, CoordinatedSurface::Client* client)
     953bool CoordinatedGraphicsLayer::paintToSurface(const IntSize& size, uint32_t& atlas, IntPoint& offset, CoordinatedSurface::Client& client)
    954954{
    955955    ASSERT(m_coordinator);
  • trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h

    r197563 r202812  
    5050    virtual bool isFlushingLayerChanges() const = 0;
    5151    virtual FloatRect visibleContentsRect() const = 0;
    52     virtual PassRefPtr<CoordinatedImageBacking> createImageBackingIfNeeded(Image*) = 0;
     52    virtual Ref<CoordinatedImageBacking> createImageBackingIfNeeded(Image*) = 0;
    5353    virtual void detachLayer(CoordinatedGraphicsLayer*) = 0;
    54     virtual bool paintToSurface(const IntSize&, CoordinatedSurface::Flags, uint32_t& atlasID, IntPoint&, CoordinatedSurface::Client*) = 0;
     54    virtual bool paintToSurface(const IntSize&, CoordinatedSurface::Flags, uint32_t& atlasID, IntPoint&, CoordinatedSurface::Client&) = 0;
    5555
    5656    virtual void syncLayerState(CoordinatedLayerID, CoordinatedGraphicsLayerState&) = 0;
     
    140140    void updateTile(uint32_t tileID, const SurfaceUpdateInfo&, const IntRect&) override;
    141141    void removeTile(uint32_t tileID) override;
    142     bool paintToSurface(const IntSize&, uint32_t& /* atlasID */, IntPoint&, CoordinatedSurface::Client*) override;
     142    bool paintToSurface(const IntSize&, uint32_t& /* atlasID */, IntPoint&, CoordinatedSurface::Client&) override;
    143143
    144144    void setCoordinator(CoordinatedGraphicsLayerClient*);
  • trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedImageBacking.cpp

    r197563 r202812  
    130130
    131131    ImageBackingSurfaceClient surfaceClient(*m_image, rect);
    132     m_surface->paintToSurface(rect, &surfaceClient);
     132    m_surface->paintToSurface(rect, surfaceClient);
    133133
    134134    m_nativeImagePtr = m_image->nativeImageForCurrentFrame();
    135135
    136     m_client->updateImageBacking(id(), m_surface);
     136    m_client->updateImageBacking(id(), m_surface.copyRef());
    137137    m_isDirty = false;
    138138}
  • trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedImageBacking.h

    r176495 r202812  
    4343    public:
    4444        virtual void createImageBacking(CoordinatedImageBackingID) = 0;
    45         virtual void updateImageBacking(CoordinatedImageBackingID, PassRefPtr<CoordinatedSurface>) = 0;
     45        virtual void updateImageBacking(CoordinatedImageBackingID, RefPtr<CoordinatedSurface>&&) = 0;
    4646        virtual void clearImageBackingContents(CoordinatedImageBackingID) = 0;
    4747        virtual void removeImageBacking(CoordinatedImageBackingID) = 0;
  • trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedSurface.h

    r198655 r202812  
    5454    IntSize size() const { return m_size; }
    5555
    56     virtual void paintToSurface(const IntRect&, Client*) = 0;
     56    virtual void paintToSurface(const IntRect&, Client&) = 0;
    5757
    5858#if USE(TEXTURE_MAPPER)
  • trunk/Source/WebCore/platform/graphics/texmap/coordinated/Tile.cpp

    r190095 r202812  
    7373    SurfaceUpdateInfo updateInfo;
    7474
    75     if (!m_tiledBackingStore.client()->paintToSurface(m_dirtyRect.size(), updateInfo.atlasID, updateInfo.surfaceOffset, this))
     75    if (!m_tiledBackingStore.client()->paintToSurface(m_dirtyRect.size(), updateInfo.atlasID, updateInfo.surfaceOffset, *this))
    7676        return false;
    7777
  • trunk/Source/WebCore/platform/graphics/texmap/coordinated/TiledBackingStoreClient.h

    r190095 r202812  
    4040    virtual void updateTile(uint32_t tileID, const SurfaceUpdateInfo&, const IntRect&) = 0;
    4141    virtual void removeTile(uint32_t tileID) = 0;
    42     virtual bool paintToSurface(const IntSize&, uint32_t& atlasID, IntPoint&, CoordinatedSurface::Client*) = 0;
     42    virtual bool paintToSurface(const IntSize&, uint32_t& atlasID, IntPoint&, CoordinatedSurface::Client&) = 0;
    4343};
    4444
  • trunk/Source/WebKit2/ChangeLog

    r202809 r202812  
     12016-07-04  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [Coordinated Graphics] Modernize and cleanup CompositingCoordinator
     4        https://bugs.webkit.org/show_bug.cgi?id=159212
     5
     6        Reviewed by Žan Doberšek.
     7
     8        Changes done:
     9
     10          - Use references instead of pointers when possible.
     11          - Add missing final/override keywords.
     12          - Reduce the use of PassRefPtr
     13          - Move member initializations to the declaration.
     14          - Use nullptr instead of 0.
     15          - Use HashMap::ensure() instead of complicated code with iterators.
     16          - Avoid heap allocation when possible.
     17
     18        * Shared/CoordinatedGraphics/WebCoordinatedSurface.cpp:
     19        (WebKit::WebCoordinatedSurface::paintToSurface):
     20        * Shared/CoordinatedGraphics/WebCoordinatedSurface.h:
     21        * Shared/CoordinatedGraphics/threadedcompositor/ThreadSafeCoordinatedSurface.cpp:
     22        (WebKit::ThreadSafeCoordinatedSurface::paintToSurface):
     23        * Shared/CoordinatedGraphics/threadedcompositor/ThreadSafeCoordinatedSurface.h:
     24        * WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.cpp:
     25        (WebKit::GeneralAreaAllocator::expand):
     26        (WebKit::GeneralAreaAllocator::splitNode):
     27        (WebKit::GeneralAreaAllocator::release):
     28        (WebKit::GeneralAreaAllocator::GeneralAreaAllocator): Deleted.
     29        * WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.h:
     30        * WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp:
     31        (WebKit::CompositingCoordinator::CompositingCoordinator):
     32        (WebKit::CompositingCoordinator::flushPendingLayerChanges):
     33        (WebKit::CompositingCoordinator::createImageBackingIfNeeded):
     34        (WebKit::CompositingCoordinator::updateImageBacking):
     35        (WebKit::CompositingCoordinator::notifyFlushRequired):
     36        (WebKit::CompositingCoordinator::paintContents):
     37        (WebKit::CompositingCoordinator::createUpdateAtlas):
     38        (WebKit::CompositingCoordinator::commitScrollOffset):
     39        (WebKit::CompositingCoordinator::paintToSurface):
     40        * WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h:
     41        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:
     42        (WebKit::CoordinatedLayerTreeHost::CoordinatedLayerTreeHost):
     43        (WebKit::CoordinatedLayerTreeHost::setViewOverlayRootLayer):
     44        (WebKit::CoordinatedLayerTreeHost::setRootCompositingLayer):
     45        (WebKit::CoordinatedLayerTreeHost::invalidate):
     46        (WebKit::CoordinatedLayerTreeHost::forceRepaint):
     47        (WebKit::CoordinatedLayerTreeHost::sizeDidChange):
     48        (WebKit::CoordinatedLayerTreeHost::setVisibleContentsRect):
     49        (WebKit::CoordinatedLayerTreeHost::renderNextFrame):
     50        (WebKit::CoordinatedLayerTreeHost::purgeBackingStores):
     51        (WebKit::CoordinatedLayerTreeHost::layerFlushTimerFired):
     52        (WebKit::CoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged):
     53        (WebKit::CoordinatedLayerTreeHost::graphicsLayerFactory):
     54        (WebKit::CoordinatedLayerTreeHost::scheduleAnimation):
     55        (WebKit::CoordinatedLayerTreeHost::commitScrollOffset):
     56        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h:
     57        * WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.cpp:
     58        (WebKit::UpdateAtlas::UpdateAtlas):
     59        (WebKit::UpdateAtlas::~UpdateAtlas):
     60        (WebKit::UpdateAtlas::buildLayoutIfNeeded):
     61        (WebKit::UpdateAtlas::paintOnAvailableBuffer):
     62        (WebKit::UpdateAtlasSurfaceClient::UpdateAtlasSurfaceClient): Deleted.
     63        * WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.h:
     64
    1652016-07-04  Brady Eidson  <beidson@apple.com>
    266
  • trunk/Source/WebKit2/Shared/CoordinatedGraphics/WebCoordinatedSurface.cpp

    r198655 r202812  
    182182}
    183183
    184 void WebCoordinatedSurface::paintToSurface(const IntRect& rect, CoordinatedSurface::Client* client)
    185 {
    186     ASSERT(client);
    187 
     184void WebCoordinatedSurface::paintToSurface(const IntRect& rect, CoordinatedSurface::Client& client)
     185{
    188186    auto context = createGraphicsContext(rect);
    189     client->paintToSurfaceContext(*context);
     187    client.paintToSurfaceContext(*context);
    190188}
    191189
  • trunk/Source/WebKit2/Shared/CoordinatedGraphics/WebCoordinatedSurface.h

    r198655 r202812  
    7272    virtual ~WebCoordinatedSurface();
    7373
    74     void paintToSurface(const WebCore::IntRect&, WebCore::CoordinatedSurface::Client*) override;
     74    void paintToSurface(const WebCore::IntRect&, WebCore::CoordinatedSurface::Client&) override;
    7575
    7676#if USE(TEXTURE_MAPPER)
  • trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadSafeCoordinatedSurface.cpp

    r198730 r202812  
    5353}
    5454
    55 void ThreadSafeCoordinatedSurface::paintToSurface(const IntRect& rect, CoordinatedSurface::Client* client)
     55void ThreadSafeCoordinatedSurface::paintToSurface(const IntRect& rect, CoordinatedSurface::Client& client)
    5656{
    57     ASSERT(client);
    58 
    5957    GraphicsContext& context = beginPaint(rect);
    60     client->paintToSurfaceContext(context);
     58    client.paintToSurfaceContext(context);
    6159    endPaint();
    6260}
  • trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadSafeCoordinatedSurface.h

    r198730 r202812  
    4040    static Ref<ThreadSafeCoordinatedSurface> create(const WebCore::IntSize&, WebCore::CoordinatedSurface::Flags);
    4141
    42     void paintToSurface(const WebCore::IntRect&, WebCore::CoordinatedSurface::Client*) override;
     42    void paintToSurface(const WebCore::IntRect&, WebCore::CoordinatedSurface::Client&) override;
    4343    void copyToTexture(RefPtr<WebCore::BitmapTexture>, const WebCore::IntRect& target, const WebCore::IntPoint& sourceOffset) override;
    4444
  • trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.cpp

    r202675 r202812  
    7777    m_root->rect = IntRect(0, 0, m_size.width(), m_size.height());
    7878    m_root->largestFree = m_size;
    79     m_root->parent = 0;
    80     m_root->left = 0;
    81     m_root->right = 0;
    8279    m_nodeCount = 1;
    8380    setMinimumAllocation(IntSize(8, 8));
     
    129126        m_nodeCount += 2;
    130127        m_root->parent = parent;
    131         parent->parent = 0;
     128        parent->parent = nullptr;
    132129        parent->left = m_root;
    133130        parent->right = right;
    134131        parent->largestFree = m_root->rect.size();
    135132        right->parent = parent;
    136         right->left = 0;
    137         right->right = 0;
     133        right->left = nullptr;
     134        right->right = nullptr;
    138135        right->largestFree = m_root->rect.size();
    139136        if (split == SplitOnX) {
     
    241238}
    242239
    243 GeneralAreaAllocator::Node* GeneralAreaAllocator::splitNode
    244     (Node* node, Split split)
     240GeneralAreaAllocator::Node* GeneralAreaAllocator::splitNode(Node* node, Split split)
    245241{
    246242    Node* left = new Node();
     243    left->parent = node;
    247244    Node* right = new Node();
    248     m_nodeCount += 2;
    249     left->parent = node;
    250     left->left = 0;
    251     left->right = 0;
    252245    right->parent = node;
    253     right->left = 0;
    254     right->right = 0;
    255246    node->left = left;
    256247    node->right = right;
     248    m_nodeCount += 2;
    257249
    258250    if (split == SplitOnX) {
     
    318310        freeNode(node->right);
    319311        m_nodeCount -= 2;
    320         node->left = 0;
    321         node->right = 0;
     312        node->left = nullptr;
     313        node->right = nullptr;
    322314        node->largestFree = node->rect.size();
    323315    }
  • trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/AreaAllocator.h

    r202675 r202812  
    7777};
    7878
    79 class GeneralAreaAllocator : public AreaAllocator {
     79class GeneralAreaAllocator final : public AreaAllocator {
    8080    WTF_MAKE_FAST_ALLOCATED;
    8181public:
     
    8383    virtual ~GeneralAreaAllocator();
    8484
    85     void expand(const WebCore::IntSize&);
    86     WebCore::IntRect allocate(const WebCore::IntSize&);
    87     void release(const WebCore::IntRect&);
    88     int overhead() const;
     85    void expand(const WebCore::IntSize&) override;
     86    WebCore::IntRect allocate(const WebCore::IntSize&) override;
     87    void release(const WebCore::IntRect&) override;
     88    int overhead() const override;
    8989
    9090private:
     
    9292
    9393    struct Node {
     94        WTF_MAKE_FAST_ALLOCATED;
     95    public:
    9496        WebCore::IntRect rect;
    9597        WebCore::IntSize largestFree;
    96         Node* parent;
    97         Node* left;
    98         Node* right;
     98        Node* parent { nullptr };
     99        Node* left { nullptr };
     100        Node* right { nullptr };
    99101    };
    100102
  • trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp

    r202675 r202812  
    3737#include <WebCore/MainFrame.h>
    3838#include <WebCore/Page.h>
    39 #include <WebCore/Settings.h>
    40 #include <wtf/CurrentTime.h>
    4139#include <wtf/TemporaryChange.h>
    4240
     
    4543namespace WebKit {
    4644
    47 CompositingCoordinator::CompositingCoordinator(Page* page, CompositingCoordinator::Client* client)
     45CompositingCoordinator::CompositingCoordinator(Page* page, CompositingCoordinator::Client& client)
    4846    : m_page(page)
    4947    , m_client(client)
    50     , m_rootCompositingLayer(nullptr)
    51     , m_overlayCompositingLayer(nullptr)
    52     , m_isDestructing(false)
    53     , m_isPurging(false)
    54     , m_isFlushingLayerChanges(false)
    55     , m_shouldSyncFrame(false)
    56     , m_didInitializeRootCompositingLayer(false)
    5748    , m_releaseInactiveAtlasesTimer(*this, &CompositingCoordinator::releaseInactiveAtlasesTimerFired)
    58 #if ENABLE(REQUEST_ANIMATION_FRAME)
    59     , m_lastAnimationServiceTime(0)
    60 #endif
    6149{
    6250}
     
    112100    bool viewportIsStable = m_page->mainFrame().view()->viewportIsStable();
    113101    m_rootLayer->flushCompositingStateForThisLayerOnly(viewportIsStable);
    114     m_client->didFlushRootLayer(m_visibleContentsRect);
     102    m_client.didFlushRootLayer(m_visibleContentsRect);
    115103
    116104    if (m_overlayCompositingLayer)
     
    134122        m_state.scrollPosition = m_visibleContentsRect.location();
    135123
    136         m_client->commitSceneState(m_state);
     124        m_client.commitSceneState(m_state);
    137125
    138126        clearPendingStateChanges();
     
    213201}
    214202
    215 PassRefPtr<CoordinatedImageBacking> CompositingCoordinator::createImageBackingIfNeeded(Image* image)
     203Ref<CoordinatedImageBacking> CompositingCoordinator::createImageBackingIfNeeded(Image* image)
    216204{
    217205    CoordinatedImageBackingID imageID = CoordinatedImageBacking::getCoordinatedImageBackingID(image);
    218     ImageBackingMap::iterator it = m_imageBackings.find(imageID);
    219     RefPtr<CoordinatedImageBacking> imageBacking;
    220     if (it == m_imageBackings.end()) {
    221         imageBacking = CoordinatedImageBacking::create(this, image);
    222         m_imageBackings.add(imageID, imageBacking);
    223     } else
    224         imageBacking = it->value;
    225 
    226     return imageBacking;
     206    auto addResult = m_imageBackings.ensure(imageID, [this, image] {
     207        return CoordinatedImageBacking::create(this, image);
     208    });
     209    return *addResult.iterator->value;
    227210}
    228211
     
    232215}
    233216
    234 void CompositingCoordinator::updateImageBacking(CoordinatedImageBackingID imageID, PassRefPtr<CoordinatedSurface> coordinatedSurface)
     217void CompositingCoordinator::updateImageBacking(CoordinatedImageBackingID imageID, RefPtr<CoordinatedSurface>&& coordinatedSurface)
    235218{
    236219    m_shouldSyncFrame = true;
    237     m_state.imagesToUpdate.append(std::make_pair(imageID, coordinatedSurface));
     220    m_state.imagesToUpdate.append(std::make_pair(imageID, WTFMove(coordinatedSurface)));
    238221}
    239222
     
    272255{
    273256    if (!m_isDestructing && !isFlushingLayerChanges())
    274         m_client->notifyFlushRequired();
     257        m_client.notifyFlushRequired();
    275258}
    276259
    277260void CompositingCoordinator::paintContents(const GraphicsLayer* graphicsLayer, GraphicsContext& graphicsContext, GraphicsLayerPaintingPhase, const FloatRect& clipRect)
    278261{
    279     m_client->paintLayerContents(graphicsLayer, graphicsContext, enclosingIntRect(clipRect));
     262    m_client.paintLayerContents(graphicsLayer, graphicsContext, enclosingIntRect(clipRect));
    280263}
    281264
     
    301284}
    302285
    303 void CompositingCoordinator::createUpdateAtlas(uint32_t atlasID, PassRefPtr<CoordinatedSurface> coordinatedSurface)
    304 {
    305     m_state.updateAtlasesToCreate.append(std::make_pair(atlasID, coordinatedSurface));
     286void CompositingCoordinator::createUpdateAtlas(uint32_t atlasID, RefPtr<CoordinatedSurface>&& coordinatedSurface)
     287{
     288    m_state.updateAtlasesToCreate.append(std::make_pair(atlasID, WTFMove(coordinatedSurface)));
    306289}
    307290
     
    372355void CompositingCoordinator::commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset)
    373356{
    374     LayerMap::iterator i = m_registeredLayers.find(layerID);
    375     if (i == m_registeredLayers.end())
    376         return;
    377 
    378     i->value->commitScrollOffset(offset);
     357    if (auto* layer = m_registeredLayers.get(layerID))
     358        layer->commitScrollOffset(offset);
    379359}
    380360
     
    396376}
    397377
    398 bool CompositingCoordinator::paintToSurface(const IntSize& size, CoordinatedSurface::Flags flags, uint32_t& atlasID, IntPoint& offset, CoordinatedSurface::Client* client)
     378bool CompositingCoordinator::paintToSurface(const IntSize& size, CoordinatedSurface::Flags flags, uint32_t& atlasID, IntPoint& offset, CoordinatedSurface::Client& client)
    399379{
    400380    for (auto& updateAtlas : m_updateAtlases) {
     
    408388
    409389    static const int ScratchBufferDimension = 1024; // Should be a power of two.
    410     m_updateAtlases.append(std::make_unique<UpdateAtlas>(this, ScratchBufferDimension, flags));
     390    m_updateAtlases.append(std::make_unique<UpdateAtlas>(*this, ScratchBufferDimension, flags));
    411391    scheduleReleaseInactiveAtlases();
    412392    return m_updateAtlases.last()->paintOnAvailableBuffer(size, atlasID, offset, client);
  • trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h

    r202675 r202812  
    4949namespace WebKit {
    5050
    51 class CompositingCoordinator : public WebCore::GraphicsLayerClient
     51class CompositingCoordinator final : public WebCore::GraphicsLayerClient
    5252    , public WebCore::CoordinatedGraphicsLayerClient
    5353    , public WebCore::CoordinatedImageBacking::Client
    5454    , public UpdateAtlas::Client
    5555    , public WebCore::GraphicsLayerFactory {
    56     WTF_MAKE_NONCOPYABLE(CompositingCoordinator); WTF_MAKE_FAST_ALLOCATED;
     56    WTF_MAKE_NONCOPYABLE(CompositingCoordinator);
    5757public:
    5858    class Client {
     
    6464    };
    6565
    66     CompositingCoordinator(WebCore::Page*, CompositingCoordinator::Client*);
     66    CompositingCoordinator(WebCore::Page*, CompositingCoordinator::Client&);
    6767    virtual ~CompositingCoordinator();
    6868
     
    101101    // CoordinatedImageBacking::Client
    102102    void createImageBacking(WebCore::CoordinatedImageBackingID) override;
    103     void updateImageBacking(WebCore::CoordinatedImageBackingID, PassRefPtr<WebCore::CoordinatedSurface>) override;
     103    void updateImageBacking(WebCore::CoordinatedImageBackingID, RefPtr<WebCore::CoordinatedSurface>&&) override;
    104104    void clearImageBackingContents(WebCore::CoordinatedImageBackingID) override;
    105105    void removeImageBacking(WebCore::CoordinatedImageBackingID) override;
     
    108108    bool isFlushingLayerChanges() const override { return m_isFlushingLayerChanges; }
    109109    WebCore::FloatRect visibleContentsRect() const override;
    110     PassRefPtr<WebCore::CoordinatedImageBacking> createImageBackingIfNeeded(WebCore::Image*) override;
     110    Ref<WebCore::CoordinatedImageBacking> createImageBackingIfNeeded(WebCore::Image*) override;
    111111    void detachLayer(WebCore::CoordinatedGraphicsLayer*) override;
    112     bool paintToSurface(const WebCore::IntSize&, WebCore::CoordinatedSurface::Flags, uint32_t& /* atlasID */, WebCore::IntPoint&, WebCore::CoordinatedSurface::Client*) override;
     112    bool paintToSurface(const WebCore::IntSize&, WebCore::CoordinatedSurface::Flags, uint32_t& /* atlasID */, WebCore::IntPoint&, WebCore::CoordinatedSurface::Client&) override;
    113113    void syncLayerState(WebCore::CoordinatedLayerID, WebCore::CoordinatedGraphicsLayerState&) override;
    114114
    115115    // UpdateAtlas::Client
    116     void createUpdateAtlas(uint32_t atlasID, PassRefPtr<WebCore::CoordinatedSurface>) override;
     116    void createUpdateAtlas(uint32_t atlasID, RefPtr<WebCore::CoordinatedSurface>&&) override;
    117117    void removeUpdateAtlas(uint32_t atlasID) override;
    118118
     
    131131
    132132    WebCore::Page* m_page;
    133     CompositingCoordinator::Client* m_client;
     133    CompositingCoordinator::Client& m_client;
    134134
    135135    std::unique_ptr<WebCore::GraphicsLayer> m_rootLayer;
    136     WebCore::GraphicsLayer* m_rootCompositingLayer;
    137     WebCore::GraphicsLayer* m_overlayCompositingLayer;
     136    WebCore::GraphicsLayer* m_rootCompositingLayer { nullptr };
     137    WebCore::GraphicsLayer* m_overlayCompositingLayer { nullptr };
    138138
    139139    WebCore::CoordinatedGraphicsState m_state;
     
    146146
    147147    // We don't send the messages related to releasing resources to renderer during purging, because renderer already had removed all resources.
    148     bool m_isDestructing;
    149     bool m_isPurging;
    150     bool m_isFlushingLayerChanges;
     148    bool m_isDestructing { false };
     149    bool m_isPurging { false };
     150    bool m_isFlushingLayerChanges { false };
     151    bool m_shouldSyncFrame { false };
     152    bool m_didInitializeRootCompositingLayer { false };
    151153
    152154    WebCore::FloatRect m_visibleContentsRect;
    153 
    154     bool m_shouldSyncFrame;
    155     bool m_didInitializeRootCompositingLayer;
    156155    WebCore::Timer m_releaseInactiveAtlasesTimer;
    157156
    158157#if ENABLE(REQUEST_ANIMATION_FRAME)
    159     double m_lastAnimationServiceTime;
     158    double m_lastAnimationServiceTime { 0 };
    160159#endif
    161160};
  • trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp

    r202621 r202812  
    6262CoordinatedLayerTreeHost::CoordinatedLayerTreeHost(WebPage& webPage)
    6363    : LayerTreeHost(webPage)
    64     , m_coordinator(std::make_unique<CompositingCoordinator>(webPage.corePage(), this))
     64    , m_coordinator(webPage.corePage(), *this)
    6565    , m_layerFlushTimer(RunLoop::main(), this, &CoordinatedLayerTreeHost::layerFlushTimerFired)
    6666{
    67     m_coordinator->createRootLayer(m_webPage.size());
     67    m_coordinator.createRootLayer(m_webPage.size());
    6868#if USE(COORDINATED_GRAPHICS_MULTIPROCESS)
    69     m_layerTreeContext.contextID = toCoordinatedGraphicsLayer(m_coordinator->rootLayer())->id();
     69    m_layerTreeContext.contextID = toCoordinatedGraphicsLayer(m_coordinator.rootLayer())->id();
    7070#endif
    7171
     
    9191{
    9292    LayerTreeHost::setViewOverlayRootLayer(viewOverlayRootLayer);
    93     m_coordinator->setViewOverlayRootLayer(viewOverlayRootLayer);
     93    m_coordinator.setViewOverlayRootLayer(viewOverlayRootLayer);
    9494}
    9595
    9696void CoordinatedLayerTreeHost::setRootCompositingLayer(GraphicsLayer* graphicsLayer)
    9797{
    98     m_coordinator->setRootCompositingLayer(graphicsLayer);
     98    m_coordinator.setRootCompositingLayer(graphicsLayer);
    9999}
    100100
     
    103103    cancelPendingLayerFlush();
    104104
    105     m_coordinator->clearRootLayer();
     105    m_coordinator.clearRootLayer();
    106106    LayerTreeHost::invalidate();
    107107}
     
    111111    // This is necessary for running layout tests. Since in this case we are not waiting for a UIProcess to reply nicely.
    112112    // Instead we are just triggering forceRepaint. But we still want to have the scripted animation callbacks being executed.
    113     m_coordinator->syncDisplayState();
     113    m_coordinator.syncDisplayState();
    114114
    115115    // We need to schedule another flush, otherwise the forced paint might cancel a later expected flush.
     
    120120        return;
    121121
    122     m_coordinator->flushPendingLayerChanges();
     122    m_coordinator.flushPendingLayerChanges();
    123123}
    124124
     
    134134void CoordinatedLayerTreeHost::sizeDidChange(const IntSize& newSize)
    135135{
    136     m_coordinator->sizeDidChange(newSize);
     136    m_coordinator.sizeDidChange(newSize);
    137137    scheduleLayerFlush();
    138138}
     
    140140void CoordinatedLayerTreeHost::setVisibleContentsRect(const FloatRect& rect, const FloatPoint& trajectoryVector)
    141141{
    142     m_coordinator->setVisibleContentsRect(rect, trajectoryVector);
     142    m_coordinator.setVisibleContentsRect(rect, trajectoryVector);
    143143    scheduleLayerFlush();
    144144}
     
    148148    m_isWaitingForRenderer = false;
    149149    scheduleLayerFlush();
    150     m_coordinator->renderNextFrame();
     150    m_coordinator.renderNextFrame();
    151151}
    152152
    153153void CoordinatedLayerTreeHost::purgeBackingStores()
    154154{
    155     m_coordinator->purgeBackingStores();
     155    m_coordinator.purgeBackingStores();
    156156}
    157157
     
    168168        return;
    169169
    170     m_coordinator->syncDisplayState();
     170    m_coordinator.syncDisplayState();
    171171
    172172    if (!m_isValid)
    173173        return;
    174174
    175     bool didSync = m_coordinator->flushPendingLayerChanges();
     175    bool didSync = m_coordinator.flushPendingLayerChanges();
    176176
    177177    if (m_forceRepaintAsyncCallbackID) {
     
    213213void CoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged()
    214214{
    215     m_coordinator->deviceOrPageScaleFactorChanged();
     215    m_coordinator.deviceOrPageScaleFactorChanged();
    216216    m_webPage.mainFrame()->pageOverlayController().didChangeDeviceScaleFactor();
    217217}
     
    223223GraphicsLayerFactory* CoordinatedLayerTreeHost::graphicsLayerFactory()
    224224{
    225     return m_coordinator.get();
     225    return &m_coordinator;
    226226}
    227227
     
    236236
    237237    scheduleLayerFlush();
    238     m_layerFlushTimer.startOneShot(m_coordinator->nextAnimationServiceTime());
     238    m_layerFlushTimer.startOneShot(m_coordinator.nextAnimationServiceTime());
    239239}
    240240#endif
     
    242242void CoordinatedLayerTreeHost::commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset)
    243243{
    244     m_coordinator->commitScrollOffset(layerID, offset);
     244    m_coordinator.commitScrollOffset(layerID, offset);
    245245}
    246246
  • trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h

    r202675 r202812  
    8686    static RefPtr<WebCore::CoordinatedSurface> createCoordinatedSurface(const WebCore::IntSize&, WebCore::CoordinatedSurface::Flags);
    8787
    88     std::unique_ptr<CompositingCoordinator> m_coordinator;
     88    CompositingCoordinator m_coordinator;
    8989    bool m_isWaitingForRenderer { true };
    9090    uint64_t m_forceRepaintAsyncCallbackID { 0 };
  • trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.cpp

    r202675 r202812  
    3333namespace WebKit {
    3434
    35 class UpdateAtlasSurfaceClient : public CoordinatedSurface::Client {
     35class UpdateAtlasSurfaceClient final : public CoordinatedSurface::Client {
    3636public:
    37     UpdateAtlasSurfaceClient(CoordinatedSurface::Client* client, const IntSize& size, bool supportsAlpha)
     37    UpdateAtlasSurfaceClient(CoordinatedSurface::Client& client, const IntSize& size, bool supportsAlpha)
    3838        : m_client(client)
    3939        , m_size(size)
     
    5050        }
    5151
    52         m_client->paintToSurfaceContext(context);
     52        m_client.paintToSurfaceContext(context);
    5353    }
    5454
    5555private:
    56     CoordinatedSurface::Client* m_client;
     56    CoordinatedSurface::Client& m_client;
    5757    IntSize m_size;
    5858    bool m_supportsAlpha;
    5959};
    6060
    61 UpdateAtlas::UpdateAtlas(Client* client, int dimension, CoordinatedSurface::Flags flags)
     61UpdateAtlas::UpdateAtlas(Client& client, int dimension, CoordinatedSurface::Flags flags)
    6262    : m_client(client)
    63     , m_inactivityInSeconds(0)
    6463{
    6564    static uint32_t nextID = 0;
     
    6867    m_surface = CoordinatedSurface::create(size, flags);
    6968
    70     m_client->createUpdateAtlas(m_ID, m_surface);
     69    m_client.createUpdateAtlas(m_ID, m_surface.copyRef());
    7170}
    7271
     
    7473{
    7574    if (m_surface)
    76         m_client->removeUpdateAtlas(m_ID);
     75        m_client.removeUpdateAtlas(m_ID);
    7776}
    7877
    7978void UpdateAtlas::buildLayoutIfNeeded()
    8079{
    81     if (!m_areaAllocator) {
    82         m_areaAllocator = std::make_unique<GeneralAreaAllocator>(size());
    83         m_areaAllocator->setMinimumAllocation(IntSize(32, 32));
    84     }
     80    if (m_areaAllocator)
     81        return;
     82    m_areaAllocator = std::make_unique<GeneralAreaAllocator>(size());
     83    m_areaAllocator->setMinimumAllocation(IntSize(32, 32));
    8584}
    8685
     
    9089}
    9190
    92 
    93 bool UpdateAtlas::paintOnAvailableBuffer(const IntSize& size, uint32_t& atlasID, IntPoint& offset, CoordinatedSurface::Client* client)
     91bool UpdateAtlas::paintOnAvailableBuffer(const IntSize& size, uint32_t& atlasID, IntPoint& offset, CoordinatedSurface::Client& client)
    9492{
    9593    m_inactivityInSeconds = 0;
     
    110108
    111109    UpdateAtlasSurfaceClient surfaceClient(client, size, supportsAlpha());
    112     m_surface->paintToSurface(rect, &surfaceClient);
     110    m_surface->paintToSurface(rect, surfaceClient);
    113111
    114112    return true;
  • trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.h

    r202675 r202812  
    4242    class Client {
    4343    public:
    44         virtual void createUpdateAtlas(uint32_t /* id */, PassRefPtr<WebCore::CoordinatedSurface>) = 0;
     44        virtual void createUpdateAtlas(uint32_t /* id */, RefPtr<WebCore::CoordinatedSurface>&&) = 0;
    4545        virtual void removeUpdateAtlas(uint32_t /* id */) = 0;
    4646    };
    4747
    48     UpdateAtlas(Client*, int dimension, WebCore::CoordinatedSurface::Flags);
     48    UpdateAtlas(Client&, int dimension, WebCore::CoordinatedSurface::Flags);
    4949    ~UpdateAtlas();
    5050
     
    5252
    5353    // Returns false if there is no available buffer.
    54     bool paintOnAvailableBuffer(const WebCore::IntSize&, uint32_t& atlasID, WebCore::IntPoint& offset, WebCore::CoordinatedSurface::Client*);
     54    bool paintOnAvailableBuffer(const WebCore::IntSize&, uint32_t& atlasID, WebCore::IntPoint& offset, WebCore::CoordinatedSurface::Client&);
    5555    void didSwapBuffers();
    5656    bool supportsAlpha() const { return m_surface->supportsAlpha(); }
     
    7272
    7373private:
    74     Client* m_client;
     74    Client& m_client;
    7575    std::unique_ptr<GeneralAreaAllocator> m_areaAllocator;
    7676    RefPtr<WebCore::CoordinatedSurface> m_surface;
    77     double m_inactivityInSeconds;
    78     uint32_t m_ID;
     77    double m_inactivityInSeconds { 0 };
     78    uint32_t m_ID { 0 };
    7979};
    8080
Note: See TracChangeset for help on using the changeset viewer.