Use std::unique_ptr for GraphicsLayer creation
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Sep 2013 18:38:51 +0000 (18:38 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Sep 2013 18:38:51 +0000 (18:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=122020

Reviewed by Antti Koivisto.

Source/WebCore:

* platform/graphics/GraphicsLayer.h:
* platform/graphics/GraphicsLayerFactory.h:
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayer::create):
* platform/graphics/ca/GraphicsLayerCA.h:
* platform/graphics/texmap/coordinated/CompositingCoordinator.cpp:
(WebCore::CompositingCoordinator::createGraphicsLayer):
* platform/graphics/texmap/coordinated/CompositingCoordinator.h:
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::createGraphicsLayer):
(WebCore::RenderLayerBacking::updateGraphicsLayerConfiguration):
(WebCore::RenderLayerBacking::paintIntoLayer):
* rendering/RenderLayerBacking.h:
(WebCore::RenderLayerBacking::hasScrollingLayer):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::updateRootLayerPosition):
* rendering/RenderLayerCompositor.h:

Source/WebKit2:

* UIProcess/mac/RemoteLayerTreeHost.h:
* UIProcess/mac/RemoteLayerTreeHost.mm:
(WebKit::RemoteLayerTreeHost::getOrCreateLayer):
* WebProcess/WebPage/mac/LayerTreeHostMac.h:
* WebProcess/WebPage/mac/LayerTreeHostMac.mm:
(WebKit::LayerTreeHostMac::paintContents):
(WebKit::LayerTreeHostMac::createPageOverlayLayer):
(WebKit::LayerTreeHostMac::destroyPageOverlayLayer):
* WebProcess/WebPage/mac/RemoteGraphicsLayer.h:
* WebProcess/WebPage/mac/RemoteGraphicsLayer.mm:
* WebProcess/WebPage/mac/RemoteLayerTreeContext.h:
* WebProcess/WebPage/mac/RemoteLayerTreeContext.mm:
(WebKit::RemoteLayerTreeContext::createGraphicsLayer):
* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h:
* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
(WebKit::TiledCoreAnimationDrawingArea::paintContents):
(WebKit::TiledCoreAnimationDrawingArea::createPageOverlayLayer):
(WebKit::TiledCoreAnimationDrawingArea::destroyPageOverlayLayer):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@156560 268f45cc-cd09-0410-ab3c-d52691b4dbfc

27 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/GraphicsLayer.h
Source/WebCore/platform/graphics/GraphicsLayerFactory.h
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h
Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp
Source/WebCore/platform/graphics/texmap/coordinated/CompositingCoordinator.cpp
Source/WebCore/platform/graphics/texmap/coordinated/CompositingCoordinator.h
Source/WebCore/rendering/RenderLayerBacking.cpp
Source/WebCore/rendering/RenderLayerBacking.h
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebCore/rendering/RenderLayerCompositor.h
Source/WebKit/efl/WebCoreSupport/AcceleratedCompositingContextEfl.cpp
Source/WebKit/efl/WebCoreSupport/AcceleratedCompositingContextEfl.h
Source/WebKit/qt/WebCoreSupport/TextureMapperLayerClientQt.cpp
Source/WebKit/qt/WebCoreSupport/TextureMapperLayerClientQt.h
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.h
Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.mm
Source/WebKit2/WebProcess/WebPage/mac/LayerTreeHostMac.h
Source/WebKit2/WebProcess/WebPage/mac/LayerTreeHostMac.mm
Source/WebKit2/WebProcess/WebPage/mac/RemoteGraphicsLayer.h
Source/WebKit2/WebProcess/WebPage/mac/RemoteGraphicsLayer.mm
Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeContext.h
Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeContext.mm
Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h
Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm

index 55d7382..ec3ec42 100644 (file)
@@ -1,3 +1,28 @@
+2013-09-27  Anders Carlsson  <andersca@apple.com>
+
+        Use std::unique_ptr for GraphicsLayer creation
+        https://bugs.webkit.org/show_bug.cgi?id=122020
+
+        Reviewed by Antti Koivisto.
+
+        * platform/graphics/GraphicsLayer.h:
+        * platform/graphics/GraphicsLayerFactory.h:
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayer::create):
+        * platform/graphics/ca/GraphicsLayerCA.h:
+        * platform/graphics/texmap/coordinated/CompositingCoordinator.cpp:
+        (WebCore::CompositingCoordinator::createGraphicsLayer):
+        * platform/graphics/texmap/coordinated/CompositingCoordinator.h:
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::createGraphicsLayer):
+        (WebCore::RenderLayerBacking::updateGraphicsLayerConfiguration):
+        (WebCore::RenderLayerBacking::paintIntoLayer):
+        * rendering/RenderLayerBacking.h:
+        (WebCore::RenderLayerBacking::hasScrollingLayer):
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::updateRootLayerPosition):
+        * rendering/RenderLayerCompositor.h:
+
 2013-09-27  Beth Dakin  <bdakin@apple.com>
 
         ScrollbarPainterController should adopt the api to lock overlay scrollbar state
index 1429dc2..eba43dd 100644 (file)
@@ -224,7 +224,7 @@ protected:
 class GraphicsLayer {
     WTF_MAKE_NONCOPYABLE(GraphicsLayer); WTF_MAKE_FAST_ALLOCATED;
 public:
-    static PassOwnPtr<GraphicsLayer> create(GraphicsLayerFactory*, GraphicsLayerClient*);
+    static std::unique_ptr<GraphicsLayer> create(GraphicsLayerFactory*, GraphicsLayerClient*);
     
     virtual ~GraphicsLayer();
 
index c747bb8..6413e93 100644 (file)
@@ -39,7 +39,7 @@ class GraphicsLayerFactory {
 public:
     virtual ~GraphicsLayerFactory() { }
 
-    virtual PassOwnPtr<GraphicsLayer> createGraphicsLayer(GraphicsLayerClient*) = 0;
+    virtual std::unique_ptr<GraphicsLayer> createGraphicsLayer(GraphicsLayerClient*) = 0;
 };
 
 } // namespace WebCore
index b1b5291..7124a0f 100644 (file)
@@ -273,10 +273,10 @@ static inline bool supportsAcceleratedFilterAnimations()
 }
 #endif
 
-PassOwnPtr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerFactory* factory, GraphicsLayerClient* client)
+std::unique_ptr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerFactory* factory, GraphicsLayerClient* client)
 {
     if (!factory)
-        return adoptPtr(new GraphicsLayerCA(client));
+        return std::make_unique<GraphicsLayerCA>(client);
 
     return factory->createGraphicsLayer(client);
 }
index 9681273..f3e4c8b 100644 (file)
@@ -194,7 +194,7 @@ private:
     typedef String CloneID; // Identifier for a given clone, based on original/replica branching down the tree.
     static bool isReplicatedRootClone(const CloneID& cloneID) { return cloneID[0U] & 1; }
 
-    typedef HashMap<CloneID, RefPtr<PlatformCALayer> > LayerMap;
+    typedef HashMap<CloneID, RefPtr<PlatformCALayer>> LayerMap;
     LayerMap* primaryLayerClones() const { return m_structuralLayer.get() ? m_structuralLayerClones.get() : m_layerClones.get(); }
     LayerMap* animatedLayerClones(AnimatedPropertyID) const;
 
index c99c808..f9a209d 100644 (file)
@@ -35,10 +35,10 @@ TextureMapperLayer* toTextureMapperLayer(GraphicsLayer* layer)
     return layer ? toGraphicsLayerTextureMapper(layer)->layer() : 0;
 }
 
-PassOwnPtr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerFactory* factory, GraphicsLayerClient* client)
+std::unique_ptr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerFactory* factory, GraphicsLayerClient* client)
 {
     if (!factory)
-        return adoptPtr(new GraphicsLayerTextureMapper(client));
+        return std::make_unique<GraphicsLayerTextureMapper>(client);
 
     return factory->createGraphicsLayer(client);
 }
index d0968b9..407821c 100644 (file)
@@ -264,7 +264,7 @@ void CompositingCoordinator::paintContents(const GraphicsLayer* graphicsLayer, G
     m_client->paintLayerContents(graphicsLayer, graphicsContext, clipRect);
 }
 
-PassOwnPtr<GraphicsLayer> CompositingCoordinator::createGraphicsLayer(GraphicsLayerClient* client)
+std::unique_ptr<GraphicsLayer> CompositingCoordinator::createGraphicsLayer(GraphicsLayerClient* client)
 {
     CoordinatedGraphicsLayer* layer = new CoordinatedGraphicsLayer(client);
     layer->setCoordinator(this);
@@ -272,7 +272,7 @@ PassOwnPtr<GraphicsLayer> CompositingCoordinator::createGraphicsLayer(GraphicsLa
     m_state.layersToCreate.append(layer->id());
     layer->setNeedsVisibleRectAdjustment();
     m_client->notifyFlushRequired();
-    return adoptPtr(layer);
+    return std::unique_ptr<GraphicsLayer>(layer);
 }
 
 float CompositingCoordinator::deviceScaleFactor() const
index fd41cb8..583a7c7 100644 (file)
@@ -122,7 +122,7 @@ private:
     virtual void removeUpdateAtlas(uint32_t atlasID) OVERRIDE;
 
     // GraphicsLayerFactory
-    virtual PassOwnPtr<GraphicsLayer> createGraphicsLayer(GraphicsLayerClient*) OVERRIDE;
+    virtual std::unique_ptr<GraphicsLayer> createGraphicsLayer(GraphicsLayerClient*) OVERRIDE;
 
     void initializeRootCompositingLayerIfNeeded();
     void flushPendingImageBackingChanges();
@@ -135,7 +135,7 @@ private:
     Page* m_page;
     CompositingCoordinator::Client* m_client;
 
-    OwnPtr<GraphicsLayer> m_rootLayer;
+    std::unique_ptr<GraphicsLayer> m_rootLayer;
     GraphicsLayer* m_rootCompositingLayer;
 
     CoordinatedGraphicsState m_state;
index 60f2700..68b9b92 100644 (file)
@@ -161,13 +161,13 @@ void RenderLayerBacking::willDestroyLayer(const GraphicsLayer* layer)
         compositor().layerTiledBackingUsageChanged(layer, false);
 }
 
-PassOwnPtr<GraphicsLayer> RenderLayerBacking::createGraphicsLayer(const String& name)
+std::unique_ptr<GraphicsLayer> RenderLayerBacking::createGraphicsLayer(const String& name)
 {
     GraphicsLayerFactory* graphicsLayerFactory = 0;
     if (Page* page = renderer().frame().page())
         graphicsLayerFactory = page->chrome().client().graphicsLayerFactory();
 
-    OwnPtr<GraphicsLayer> graphicsLayer = GraphicsLayer::create(graphicsLayerFactory, this);
+    std::unique_ptr<GraphicsLayer> graphicsLayer = GraphicsLayer::create(graphicsLayerFactory, this);
 
 #ifndef NDEBUG
     graphicsLayer->setName(name);
@@ -180,7 +180,7 @@ PassOwnPtr<GraphicsLayer> RenderLayerBacking::createGraphicsLayer(const String&
     graphicsLayer->setAcceleratesDrawing(compositor().acceleratedDrawingEnabled());
 #endif    
     
-    return graphicsLayer.release();
+    return graphicsLayer;
 }
 
 bool RenderLayerBacking::shouldUseTiledBacking(const GraphicsLayer*) const
@@ -523,7 +523,7 @@ bool RenderLayerBacking::updateGraphicsLayerConfiguration()
         updateInternalHierarchy();
 
     if (GraphicsLayer* flatteningLayer = tileCacheFlatteningLayer()) {
-        if (layerConfigChanged || flatteningLayer->parent() != m_graphicsLayer)
+        if (layerConfigChanged || flatteningLayer->parent() != m_graphicsLayer.get())
             m_graphicsLayer->addChild(flatteningLayer);
     }
 
@@ -1980,7 +1980,7 @@ void RenderLayerBacking::paintIntoLayer(const GraphicsLayer* graphicsLayer, Grap
     if (paintingPhase & GraphicsLayerPaintCompositedScroll)
         paintFlags |= RenderLayer::PaintLayerPaintingCompositingScrollingPhase;
 
-    if (graphicsLayer == m_backgroundLayer)
+    if (graphicsLayer == m_backgroundLayer.get())
         paintFlags |= (RenderLayer::PaintLayerPaintingRootBackgroundOnly | RenderLayer::PaintLayerPaintingCompositingForegroundPhase); // Need PaintLayerPaintingCompositingForegroundPhase to walk child layers.
     else if (compositor().fixedRootBackgroundLayer())
         paintFlags |= RenderLayer::PaintLayerPaintingSkipRootBackground;
index 56f17c0..8598ba4 100644 (file)
@@ -95,7 +95,7 @@ public:
     GraphicsLayer* backgroundLayer() const { return m_backgroundLayer.get(); }
     bool backgroundLayerPaintsFixedRootBackground() const { return m_backgroundLayerPaintsFixedRootBackground; }
     
-    bool hasScrollingLayer() const { return m_scrollingLayer; }
+    bool hasScrollingLayer() const { return m_scrollingLayer != nullptr; }
     GraphicsLayer* scrollingLayer() const { return m_scrollingLayer.get(); }
     GraphicsLayer* scrollingContentsLayer() const { return m_scrollingContentsLayer.get(); }
 
@@ -208,7 +208,7 @@ private:
     
     void willDestroyLayer(const GraphicsLayer*);
     
-    PassOwnPtr<GraphicsLayer> createGraphicsLayer(const String&);
+    std::unique_ptr<GraphicsLayer> createGraphicsLayer(const String&);
 
     RenderLayerModelObject& renderer() const { return m_owningLayer->renderer(); }
     RenderLayerCompositor& compositor() const { return m_owningLayer->compositor(); }
@@ -283,20 +283,20 @@ private:
 
     RenderLayer* m_owningLayer;
 
-    OwnPtr<GraphicsLayer> m_ancestorClippingLayer; // Only used if we are clipped by an ancestor which is not a stacking context.
-    OwnPtr<GraphicsLayer> m_contentsContainmentLayer; // Only used if we have a background layer; takes the transform.
-    OwnPtr<GraphicsLayer> m_graphicsLayer;
-    OwnPtr<GraphicsLayer> m_foregroundLayer; // Only used in cases where we need to draw the foreground separately.
-    OwnPtr<GraphicsLayer> m_backgroundLayer; // Only used in cases where we need to draw the background separately.
-    OwnPtr<GraphicsLayer> m_childContainmentLayer; // Only used if we have clipping on a stacking context with compositing children, or if the layer has a tile cache.
-    OwnPtr<GraphicsLayer> m_maskLayer; // Only used if we have a mask.
+    std::unique_ptr<GraphicsLayer> m_ancestorClippingLayer; // Only used if we are clipped by an ancestor which is not a stacking context.
+    std::unique_ptr<GraphicsLayer> m_contentsContainmentLayer; // Only used if we have a background layer; takes the transform.
+    std::unique_ptr<GraphicsLayer> m_graphicsLayer;
+    std::unique_ptr<GraphicsLayer> m_foregroundLayer; // Only used in cases where we need to draw the foreground separately.
+    std::unique_ptr<GraphicsLayer> m_backgroundLayer; // Only used in cases where we need to draw the background separately.
+    std::unique_ptr<GraphicsLayer> m_childContainmentLayer; // Only used if we have clipping on a stacking context with compositing children, or if the layer has a tile cache.
+    std::unique_ptr<GraphicsLayer> m_maskLayer; // Only used if we have a mask.
 
-    OwnPtr<GraphicsLayer> m_layerForHorizontalScrollbar;
-    OwnPtr<GraphicsLayer> m_layerForVerticalScrollbar;
-    OwnPtr<GraphicsLayer> m_layerForScrollCorner;
+    std::unique_ptr<GraphicsLayer> m_layerForHorizontalScrollbar;
+    std::unique_ptr<GraphicsLayer> m_layerForVerticalScrollbar;
+    std::unique_ptr<GraphicsLayer> m_layerForScrollCorner;
 
-    OwnPtr<GraphicsLayer> m_scrollingLayer; // Only used if the layer is using composited scrolling.
-    OwnPtr<GraphicsLayer> m_scrollingContentsLayer; // Only used if the layer is using composited scrolling.
+    std::unique_ptr<GraphicsLayer> m_scrollingLayer; // Only used if the layer is using composited scrolling.
+    std::unique_ptr<GraphicsLayer> m_scrollingContentsLayer; // Only used if the layer is using composited scrolling.
 
     uint64_t m_scrollLayerID;
 
index f04d055..caf1c01 100644 (file)
@@ -1711,10 +1711,10 @@ void RenderLayerCompositor::updateRootLayerPosition()
         }
     }
 
-    updateLayerForTopOverhangArea(m_layerForTopOverhangArea);
-    updateLayerForBottomOverhangArea(m_layerForBottomOverhangArea);
-    updateLayerForHeader(m_layerForHeader);
-    updateLayerForFooter(m_layerForFooter);
+    updateLayerForTopOverhangArea(m_layerForTopOverhangArea != nullptr);
+    updateLayerForBottomOverhangArea(m_layerForBottomOverhangArea != nullptr);
+    updateLayerForHeader(m_layerForHeader != nullptr);
+    updateLayerForFooter(m_layerForFooter != nullptr);
 #endif
 }
 
index c2f3d07..00b69f6 100644 (file)
@@ -410,7 +410,7 @@ private:
 
 private:
     RenderView& m_renderView;
-    OwnPtr<GraphicsLayer> m_rootContentLayer;
+    std::unique_ptr<GraphicsLayer> m_rootContentLayer;
     Timer<RenderLayerCompositor> m_updateCompositingLayersTimer;
 
     bool m_hasAcceleratedCompositing;
@@ -439,26 +439,26 @@ private:
     RootLayerAttachment m_rootLayerAttachment;
 
     // Enclosing clipping layer for iframe content
-    OwnPtr<GraphicsLayer> m_clipLayer;
-    OwnPtr<GraphicsLayer> m_scrollLayer;
+    std::unique_ptr<GraphicsLayer> m_clipLayer;
+    std::unique_ptr<GraphicsLayer> m_scrollLayer;
 
     HashSet<RenderLayer*> m_viewportConstrainedLayers;
     HashSet<RenderLayer*> m_viewportConstrainedLayersNeedingUpdate;
 
     // Enclosing layer for overflow controls and the clipping layer
-    OwnPtr<GraphicsLayer> m_overflowControlsHostLayer;
+    std::unique_ptr<GraphicsLayer> m_overflowControlsHostLayer;
 
     // Layers for overflow controls
-    OwnPtr<GraphicsLayer> m_layerForHorizontalScrollbar;
-    OwnPtr<GraphicsLayer> m_layerForVerticalScrollbar;
-    OwnPtr<GraphicsLayer> m_layerForScrollCorner;
+    std::unique_ptr<GraphicsLayer> m_layerForHorizontalScrollbar;
+    std::unique_ptr<GraphicsLayer> m_layerForVerticalScrollbar;
+    std::unique_ptr<GraphicsLayer> m_layerForScrollCorner;
 #if ENABLE(RUBBER_BANDING)
-    OwnPtr<GraphicsLayer> m_layerForOverhangAreas;
-    OwnPtr<GraphicsLayer> m_contentShadowLayer;
-    OwnPtr<GraphicsLayer> m_layerForTopOverhangArea;
-    OwnPtr<GraphicsLayer> m_layerForBottomOverhangArea;
-    OwnPtr<GraphicsLayer> m_layerForHeader;
-    OwnPtr<GraphicsLayer> m_layerForFooter;
+    std::unique_ptr<GraphicsLayer> m_layerForOverhangAreas;
+    std::unique_ptr<GraphicsLayer> m_contentShadowLayer;
+    std::unique_ptr<GraphicsLayer> m_layerForTopOverhangArea;
+    std::unique_ptr<GraphicsLayer> m_layerForBottomOverhangArea;
+    std::unique_ptr<GraphicsLayer> m_layerForHeader;
+    std::unique_ptr<GraphicsLayer> m_layerForFooter;
 #endif
 
     OwnPtr<GraphicsLayerUpdater> m_layerUpdater; // Updates tiled layer visible area periodically while animations are running.
index 0f1f6c9..732ddc1 100644 (file)
@@ -97,7 +97,7 @@ void AcceleratedCompositingContext::renderLayers()
 void AcceleratedCompositingContext::attachRootGraphicsLayer(GraphicsLayer* rootLayer)
 {
     if (!rootLayer) {
-        m_rootGraphicsLayer.clear();
+        m_rootGraphicsLayer = nullptr;
         m_rootTextureMapperLayer = 0;
         return;
     }
index d2869a4..1eb796b 100644 (file)
@@ -53,7 +53,7 @@ private:
     Evas_Object* m_view;
 
     OwnPtr<TextureMapper> m_textureMapper;
-    OwnPtr<GraphicsLayer> m_rootGraphicsLayer;
+    std::unique_ptr<GraphicsLayer> m_rootGraphicsLayer;
     TextureMapperLayer* m_rootTextureMapperLayer;
 
     RefPtr<GraphicsContext3D> m_context3D;
index 465857f..21c39b6 100644 (file)
@@ -77,7 +77,7 @@ void TextureMapperLayerClientQt::setRootGraphicsLayer(GraphicsLayer* layer)
         m_rootTextureMapperLayer->setTextureMapper(m_textureMapper.get());
         syncRootLayer();
     } else {
-        m_rootGraphicsLayer.clear();
+        m_rootGraphicsLayer = nullptr;
         m_rootTextureMapperLayer = 0;
     }
 }
index 2ffb5f0..9ac5e7e 100644 (file)
@@ -50,7 +50,7 @@ public:
     void renderCompositedLayers(GraphicsContext*, const IntRect& clip);
 private:
     QWebFrameAdapter* m_frame;
-    OwnPtr<GraphicsLayer> m_rootGraphicsLayer;
+    std::unique_ptr<GraphicsLayer> m_rootGraphicsLayer;
     Timer<TextureMapperLayerClientQt> m_syncTimer;
     WebCore::TextureMapperLayer* m_rootTextureMapperLayer;
     OwnPtr<WebCore::TextureMapper> m_textureMapper;
index ddbb5b1..67340e6 100644 (file)
@@ -1,3 +1,29 @@
+2013-09-27  Anders Carlsson  <andersca@apple.com>
+
+        Use std::unique_ptr for GraphicsLayer creation
+        https://bugs.webkit.org/show_bug.cgi?id=122020
+
+        Reviewed by Antti Koivisto.
+
+        * UIProcess/mac/RemoteLayerTreeHost.h:
+        * UIProcess/mac/RemoteLayerTreeHost.mm:
+        (WebKit::RemoteLayerTreeHost::getOrCreateLayer):
+        * WebProcess/WebPage/mac/LayerTreeHostMac.h:
+        * WebProcess/WebPage/mac/LayerTreeHostMac.mm:
+        (WebKit::LayerTreeHostMac::paintContents):
+        (WebKit::LayerTreeHostMac::createPageOverlayLayer):
+        (WebKit::LayerTreeHostMac::destroyPageOverlayLayer):
+        * WebProcess/WebPage/mac/RemoteGraphicsLayer.h:
+        * WebProcess/WebPage/mac/RemoteGraphicsLayer.mm:
+        * WebProcess/WebPage/mac/RemoteLayerTreeContext.h:
+        * WebProcess/WebPage/mac/RemoteLayerTreeContext.mm:
+        (WebKit::RemoteLayerTreeContext::createGraphicsLayer):
+        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h:
+        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
+        (WebKit::TiledCoreAnimationDrawingArea::paintContents):
+        (WebKit::TiledCoreAnimationDrawingArea::createPageOverlayLayer):
+        (WebKit::TiledCoreAnimationDrawingArea::destroyPageOverlayLayer):
+
 2013-09-27  Beth Dakin  <bdakin@apple.com>
 
         ScrollbarPainterController should adopt the api to lock overlay scrollbar state
index c4b952a..bfbfc1f 100644 (file)
@@ -57,7 +57,7 @@ private:
     WebPageProxy* m_webPageProxy;
 
     WebCore::GraphicsLayer* m_rootLayer;
-    HashMap<uint64_t, OwnPtr<WebCore::GraphicsLayer>> m_layers;
+    HashMap<uint64_t, std::unique_ptr<WebCore::GraphicsLayer>> m_layers;
 };
 
 } // namespace WebKit
index 5934e07..323ab8e 100644 (file)
@@ -76,11 +76,11 @@ void RemoteLayerTreeHost::commit(const RemoteLayerTreeTransaction& transaction)
 
 GraphicsLayer* RemoteLayerTreeHost::getOrCreateLayer(uint64_t layerID)
 {
-    auto addResult = m_layers.add(layerID, nullptr);
-    if (addResult.isNewEntry)
-        addResult.iterator->value = GraphicsLayer::create(0, this);
+    std::unique_ptr<GraphicsLayer>& layer = m_layers.add(layerID, nullptr).iterator->value;
+    if (!layer)
+        layer = GraphicsLayer::create(0, this);
 
-    return addResult.iterator->value.get();
+    return layer.get();
 }
 
 } // namespace WebKit
index 3747cb7..46ba2d7 100644 (file)
@@ -92,9 +92,9 @@ private:
 
     LayerTreeContext m_layerTreeContext;
 
-    OwnPtr<WebCore::GraphicsLayer> m_rootLayer;
-    OwnPtr<WebCore::GraphicsLayer> m_nonCompositedContentLayer;
-    typedef HashMap<PageOverlay*, OwnPtr<WebCore::GraphicsLayer>> PageOverlayLayerMap;
+    std::unique_ptr<WebCore::GraphicsLayer> m_rootLayer;
+    std::unique_ptr<WebCore::GraphicsLayer> m_nonCompositedContentLayer;
+    typedef HashMap<PageOverlay*, std::unique_ptr<WebCore::GraphicsLayer>> PageOverlayLayerMap;
     PageOverlayLayerMap m_pageOverlayLayers;
 
     OwnPtr<LayerHostingContext> m_layerHostingContext;
index 392718b..3b786f0 100644 (file)
@@ -274,15 +274,14 @@ void LayerTreeHostMac::notifyFlushRequired(const WebCore::GraphicsLayer*)
 
 void LayerTreeHostMac::paintContents(const GraphicsLayer* graphicsLayer, GraphicsContext& graphicsContext, GraphicsLayerPaintingPhase, const IntRect& clipRect)
 {
-    if (graphicsLayer == m_nonCompositedContentLayer) {
+    if (graphicsLayer == m_nonCompositedContentLayer.get()) {
         m_webPage->drawRect(graphicsContext, clipRect);
         return;
     }
 
-    PageOverlayLayerMap::iterator end = m_pageOverlayLayers.end();
-    for (PageOverlayLayerMap::iterator it = m_pageOverlayLayers.begin(); it != end; ++it) {
-        if (it->value == graphicsLayer) {
-            m_webPage->drawPageOverlay(it->key, graphicsContext, clipRect);
+    for (auto& pageOverlayLayer : m_pageOverlayLayers) {
+        if (pageOverlayLayer.value.get() == graphicsLayer) {
+            m_webPage->drawPageOverlay(pageOverlayLayer.key, graphicsContext, clipRect);
             break;
         }
     }
@@ -385,7 +384,7 @@ bool LayerTreeHostMac::flushPendingLayerChanges()
 
 void LayerTreeHostMac::createPageOverlayLayer(PageOverlay* pageOverlay)
 {
-    OwnPtr<GraphicsLayer> layer = GraphicsLayer::create(graphicsLayerFactory(), this);
+    std::unique_ptr<GraphicsLayer> layer = GraphicsLayer::create(graphicsLayerFactory(), this);
 #ifndef NDEBUG
     layer->setName("LayerTreeHost page overlay content");
 #endif
@@ -398,12 +397,12 @@ void LayerTreeHostMac::createPageOverlayLayer(PageOverlay* pageOverlay)
 
     m_rootLayer->addChild(layer.get());
 
-    m_pageOverlayLayers.add(pageOverlay, layer.release());
+    m_pageOverlayLayers.add(pageOverlay, std::move(layer));
 }
 
 void LayerTreeHostMac::destroyPageOverlayLayer(PageOverlay* pageOverlay)
 {
-    OwnPtr<GraphicsLayer> layer = m_pageOverlayLayers.take(pageOverlay);
+    std::unique_ptr<GraphicsLayer> layer = m_pageOverlayLayers.take(pageOverlay);
     ASSERT(layer);
 
     layer->removeFromParent();
index c65cd65..1bc3926 100644 (file)
@@ -34,14 +34,12 @@ class RemoteLayerTreeContext;
 
 class RemoteGraphicsLayer : public WebCore::GraphicsLayer {
 public:
-    static PassOwnPtr<WebCore::GraphicsLayer> create(WebCore::GraphicsLayerClient*, RemoteLayerTreeContext*);
+    RemoteGraphicsLayer(WebCore::GraphicsLayerClient*, RemoteLayerTreeContext*);
     virtual ~RemoteGraphicsLayer();
 
     uint64_t layerID() const { return m_layerID; }
 
 private:
-    RemoteGraphicsLayer(WebCore::GraphicsLayerClient*, RemoteLayerTreeContext*);
-
     // WebCore::GraphicsLayer
     virtual void setName(const String&) OVERRIDE;
 
index ec201c2..043675d 100644 (file)
@@ -42,11 +42,6 @@ static uint64_t generateLayerID()
     return ++layerID;
 }
 
-PassOwnPtr<GraphicsLayer> RemoteGraphicsLayer::create(GraphicsLayerClient* client, RemoteLayerTreeContext* context)
-{
-    return adoptPtr(new RemoteGraphicsLayer(client, context));
-}
-
 RemoteGraphicsLayer::RemoteGraphicsLayer(GraphicsLayerClient* client, RemoteLayerTreeContext* context)
     : GraphicsLayer(client)
     , m_layerID(generateLayerID())
index f5d7973..77a0954 100644 (file)
@@ -52,7 +52,7 @@ private:
     explicit RemoteLayerTreeContext(WebPage*);
 
     // WebCore::GraphicsLayerFactory
-    virtual PassOwnPtr<WebCore::GraphicsLayer> createGraphicsLayer(WebCore::GraphicsLayerClient*) OVERRIDE;
+    virtual std::unique_ptr<WebCore::GraphicsLayer> createGraphicsLayer(WebCore::GraphicsLayerClient*) OVERRIDE;
 
     void layerFlushTimerFired(WebCore::Timer<RemoteLayerTreeContext>*);
     void flushLayers();
index b864540..8993dcb 100644 (file)
@@ -86,9 +86,9 @@ RemoteLayerTreeTransaction& RemoteLayerTreeContext::currentTransaction()
     return *m_currentTransaction;
 }
 
-PassOwnPtr<GraphicsLayer> RemoteLayerTreeContext::createGraphicsLayer(GraphicsLayerClient* client)
+std::unique_ptr<GraphicsLayer> RemoteLayerTreeContext::createGraphicsLayer(GraphicsLayerClient* client)
 {
-    return RemoteGraphicsLayer::create(client, this);
+    return std::make_unique<RemoteGraphicsLayer>(client, this);
 }
 
 void RemoteLayerTreeContext::layerFlushTimerFired(WebCore::Timer<RemoteLayerTreeContext>*)
index 9f92b0e..038b32b 100644 (file)
@@ -127,7 +127,7 @@ private:
 
     RetainPtr<CALayer> m_debugInfoLayer;
 
-    typedef HashMap<PageOverlay*, OwnPtr<WebCore::GraphicsLayer>> PageOverlayLayerMap;
+    typedef HashMap<PageOverlay*, std::unique_ptr<WebCore::GraphicsLayer>> PageOverlayLayerMap;
     PageOverlayLayerMap m_pageOverlayLayers;
     mutable HashMap<const WebCore::GraphicsLayer*, RetainPtr<CALayer>> m_pageOverlayPlatformLayers;
 
index 46b1049..720929f 100644 (file)
@@ -344,8 +344,8 @@ void TiledCoreAnimationDrawingArea::notifyFlushRequired(const GraphicsLayer*)
 
 void TiledCoreAnimationDrawingArea::paintContents(const GraphicsLayer* graphicsLayer, GraphicsContext& graphicsContext, GraphicsLayerPaintingPhase, const IntRect& clipRect)
 {
-    for (PageOverlayLayerMap::iterator it = m_pageOverlayLayers.begin(), end = m_pageOverlayLayers.end(); it != end; ++it) {
-        if (it->value == graphicsLayer) {
+    for (auto it = m_pageOverlayLayers.begin(), end = m_pageOverlayLayers.end(); it != end; ++it) {
+        if (it->value.get() == graphicsLayer) {
             m_webPage->drawPageOverlay(it->key, graphicsContext, clipRect);
             break;
         }
@@ -613,7 +613,7 @@ void TiledCoreAnimationDrawingArea::setRootCompositingLayer(CALayer *layer)
 
 void TiledCoreAnimationDrawingArea::createPageOverlayLayer(PageOverlay* pageOverlay)
 {
-    OwnPtr<GraphicsLayer> layer = GraphicsLayer::create(graphicsLayerFactory(), this);
+    std::unique_ptr<GraphicsLayer> layer = GraphicsLayer::create(graphicsLayerFactory(), this);
 #ifndef NDEBUG
     layer->setName("page overlay content");
 #endif
@@ -636,12 +636,12 @@ void TiledCoreAnimationDrawingArea::createPageOverlayLayer(PageOverlay* pageOver
 
     [CATransaction commit];
 
-    m_pageOverlayLayers.add(pageOverlay, layer.release());
+    m_pageOverlayLayers.add(pageOverlay, std::move(layer));
 }
 
 void TiledCoreAnimationDrawingArea::destroyPageOverlayLayer(PageOverlay* pageOverlay)
 {
-    OwnPtr<GraphicsLayer> layer = m_pageOverlayLayers.take(pageOverlay);
+    std::unique_ptr<GraphicsLayer> layer = m_pageOverlayLayers.take(pageOverlay);
     ASSERT(layer);
 
     [CATransaction begin];