[chromium] Replace RefPtr with OwnPtr for CCLayerImpl tree structure
authorjamesr@google.com <jamesr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 25 Feb 2012 04:09:52 +0000 (04:09 +0000)
committerjamesr@google.com <jamesr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 25 Feb 2012 04:09:52 +0000 (04:09 +0000)
https://bugs.webkit.org/show_bug.cgi?id=78404

Patch by Tien-Ren Chen <trchen@chromium.org> on 2012-02-24
Reviewed by James Robinson.

Source/WebCore:

No new tests. Updated existing test to reflect changes.

* platform/graphics/chromium/CanvasLayerChromium.cpp:
(WebCore::CanvasLayerChromium::createCCLayerImpl):
* platform/graphics/chromium/CanvasLayerChromium.h:
(CanvasLayerChromium):
* platform/graphics/chromium/LayerChromium.cpp:
(WebCore::LayerChromium::createCCLayerImpl):
* platform/graphics/chromium/LayerChromium.h:
(LayerChromium):
* platform/graphics/chromium/PluginLayerChromium.cpp:
(WebCore::PluginLayerChromium::createCCLayerImpl):
* platform/graphics/chromium/PluginLayerChromium.h:
(PluginLayerChromium):
* platform/graphics/chromium/SolidColorLayerChromium.cpp:
(WebCore::SolidColorLayerChromium::createCCLayerImpl):
* platform/graphics/chromium/SolidColorLayerChromium.h:
(SolidColorLayerChromium):
* platform/graphics/chromium/TiledLayerChromium.cpp:
(WebCore::TiledLayerChromium::createCCLayerImpl):
* platform/graphics/chromium/TiledLayerChromium.h:
(TiledLayerChromium):
* platform/graphics/chromium/TreeSynchronizer.cpp:
(WebCore::TreeSynchronizer::synchronizeTrees):
(WebCore::TreeSynchronizer::collectExistingCCLayerImplRecursive):
(WebCore):
(WebCore::TreeSynchronizer::reuseOrCreateCCLayerImpl):
(WebCore::TreeSynchronizer::synchronizeTreeRecursive):
* platform/graphics/chromium/TreeSynchronizer.h:
(TreeSynchronizer):
* platform/graphics/chromium/VideoLayerChromium.cpp:
(WebCore::VideoLayerChromium::createCCLayerImpl):
* platform/graphics/chromium/VideoLayerChromium.h:
(VideoLayerChromium):
* platform/graphics/chromium/cc/CCCanvasLayerImpl.h:
(WebCore::CCCanvasLayerImpl::create):
* platform/graphics/chromium/cc/CCDamageTracker.cpp:
(WebCore::CCDamageTracker::updateDamageTrackingState):
(WebCore::CCDamageTracker::trackDamageFromActiveLayers):
* platform/graphics/chromium/cc/CCDamageTracker.h:
(CCDamageTracker):
* platform/graphics/chromium/cc/CCLayerImpl.cpp:
(WebCore::CCLayerImpl::CCLayerImpl):
(WebCore::CCLayerImpl::addChild):
(WebCore::sortLayers):
(WebCore::CCLayerImpl::setMaskLayer):
(WebCore::CCLayerImpl::setReplicaLayer):
* platform/graphics/chromium/cc/CCLayerImpl.h:
(WebCore::CCLayerImpl::create):
(WebCore::CCLayerImpl::children):
(CCLayerImpl):
(WebCore):
* platform/graphics/chromium/cc/CCLayerIterator.cpp:
(WebCore):
(WebCore::CCLayerIteratorActions::BackToFront::begin):
(WebCore::CCLayerIteratorActions::BackToFront::end):
(WebCore::CCLayerIteratorActions::BackToFront::next):
(WebCore::CCLayerIteratorActions::FrontToBack::begin):
(WebCore::CCLayerIteratorActions::FrontToBack::end):
(WebCore::CCLayerIteratorActions::FrontToBack::next):
(WebCore::CCLayerIteratorActions::FrontToBack::goToHighestInSubtree):
* platform/graphics/chromium/cc/CCLayerIterator.h:
(WebCore):
(CCLayerIterator):
(WebCore::CCLayerIterator::begin):
(WebCore::CCLayerIterator::end):
(WebCore::CCLayerIterator::targetRenderSurfaceLayer):
(WebCore::CCLayerIterator::CCLayerIterator):
(WebCore::CCLayerIterator::getRawPtr):
(WebCore::CCLayerIterator::currentLayer):
(WebCore::CCLayerIterator::targetRenderSurfaceChildren):
(BackToFront):
(FrontToBack):
* platform/graphics/chromium/cc/CCLayerSorter.cpp:
(WebCore::CCLayerSorter::createGraphNodes):
* platform/graphics/chromium/cc/CCLayerSorter.h:
(CCLayerSorter):
* platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
(WebCore::CCLayerTreeHost::finishCommitOnImplThread):
(WebCore::CCLayerTreeHost::didBecomeInvisibleOnImplThread):
(WebCore::CCLayerTreeHost::reserveTextures):
(WebCore::CCLayerTreeHost::paintLayerContents):
(WebCore::CCLayerTreeHost::updateCompositorResources):
* platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp:
(WebCore):
(WebCore::calculateDrawTransformsAndVisibilityInternal):
(WebCore::walkLayersAndCalculateVisibleLayerRects):
(WebCore::CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility):
* platform/graphics/chromium/cc/CCLayerTreeHostCommon.h:
(CCLayerTreeHostCommon):
* platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
(WebCore::CCLayerTreeHostImpl::CCLayerTreeHostImpl):
(WebCore::CCLayerTreeHostImpl::trackDamageForAllSurfaces):
(WebCore::CCLayerTreeHostImpl::calculateRenderPasses):
(WebCore::CCLayerTreeHostImpl::drawLayers):
(WebCore::CCLayerTreeHostImpl::setRootLayer):
* platform/graphics/chromium/cc/CCLayerTreeHostImpl.h:
(CCLayerTreeHostImpl):
(WebCore::CCLayerTreeHostImpl::releaseRootLayer):
(WebCore::CCLayerTreeHostImpl::scrollLayer):
* platform/graphics/chromium/cc/CCPluginLayerImpl.h:
(WebCore::CCPluginLayerImpl::create):
* platform/graphics/chromium/cc/CCRenderSurface.h:
(WebCore::CCRenderSurface::layerList):
(CCRenderSurface):
* platform/graphics/chromium/cc/CCSolidColorLayerImpl.h:
(WebCore::CCSolidColorLayerImpl::create):
* platform/graphics/chromium/cc/CCTiledLayerImpl.h:
(WebCore::CCTiledLayerImpl::create):
* platform/graphics/chromium/cc/CCVideoLayerImpl.h:
(WebCore::CCVideoLayerImpl::create):

Source/WebKit/chromium:

* tests/CCDamageTrackerTest.cpp:
(WebKitTests::executeCalculateDrawTransformsAndVisibility):
(WebKitTests::emulateDrawingOneFrame):
(WebKitTests::createTestTreeWithOneSurface):
(WebKitTests::createTestTreeWithTwoSurfaces):
(WebKitTests::createAndSetUpTestTreeWithOneSurface):
(WebKitTests::createAndSetUpTestTreeWithTwoSurfaces):
(WebKitTests::TEST_F):
* tests/CCLayerImplTest.cpp:
(WebCore::TEST):
* tests/CCLayerIteratorTest.cpp:
* tests/CCLayerSorterTest.cpp:
(WebCore::TEST):
* tests/CCLayerTreeHostCommonTest.cpp:
(WebCore::TEST):
* tests/CCLayerTreeHostImplTest.cpp:
(WebKit::CCLayerTreeHostImplTest::setupScrollAndContentsLayers):
(WebKit::TEST_F):
(WebKit::DidDrawCheckLayer::create):
(WebKit::BlendStateCheckLayer::create):
* tests/CCRenderSurfaceTest.cpp:
(WebCore::TEST):
* tests/CCSolidColorLayerImplTest.cpp:
(CCLayerTestCommon::TEST):
* tests/CCTiledLayerImplTest.cpp:
(CCLayerTestCommon::createLayer):
(CCLayerTestCommon::TEST):
(CCLayerTestCommon::getQuads):
* tests/Canvas2DLayerChromiumTest.cpp:
(WebCore::Canvas2DLayerChromiumTest::fullLifecycleTest):
* tests/TiledLayerChromiumTest.cpp:
(WTF::TEST):
* tests/TreeSynchronizerTest.cpp:
(WebKitTests::MockCCLayerImpl::create):
(WebKitTests::MockLayerChromium::createCCLayerImpl):
(WebKitTests::expectTreesAreIdentical):
(WebKitTests::TEST):

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

47 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/chromium/CanvasLayerChromium.cpp
Source/WebCore/platform/graphics/chromium/CanvasLayerChromium.h
Source/WebCore/platform/graphics/chromium/LayerChromium.cpp
Source/WebCore/platform/graphics/chromium/LayerChromium.h
Source/WebCore/platform/graphics/chromium/PluginLayerChromium.cpp
Source/WebCore/platform/graphics/chromium/PluginLayerChromium.h
Source/WebCore/platform/graphics/chromium/SolidColorLayerChromium.cpp
Source/WebCore/platform/graphics/chromium/SolidColorLayerChromium.h
Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp
Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h
Source/WebCore/platform/graphics/chromium/TreeSynchronizer.cpp
Source/WebCore/platform/graphics/chromium/TreeSynchronizer.h
Source/WebCore/platform/graphics/chromium/VideoLayerChromium.cpp
Source/WebCore/platform/graphics/chromium/VideoLayerChromium.h
Source/WebCore/platform/graphics/chromium/cc/CCCanvasLayerImpl.h
Source/WebCore/platform/graphics/chromium/cc/CCDamageTracker.cpp
Source/WebCore/platform/graphics/chromium/cc/CCDamageTracker.h
Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.cpp
Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.h
Source/WebCore/platform/graphics/chromium/cc/CCLayerIterator.cpp
Source/WebCore/platform/graphics/chromium/cc/CCLayerIterator.h
Source/WebCore/platform/graphics/chromium/cc/CCLayerSorter.cpp
Source/WebCore/platform/graphics/chromium/cc/CCLayerSorter.h
Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp
Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp
Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommon.h
Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp
Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h
Source/WebCore/platform/graphics/chromium/cc/CCPluginLayerImpl.h
Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.h
Source/WebCore/platform/graphics/chromium/cc/CCSolidColorLayerImpl.h
Source/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.h
Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/tests/CCDamageTrackerTest.cpp
Source/WebKit/chromium/tests/CCLayerImplTest.cpp
Source/WebKit/chromium/tests/CCLayerIteratorTest.cpp
Source/WebKit/chromium/tests/CCLayerSorterTest.cpp
Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp
Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp
Source/WebKit/chromium/tests/CCRenderSurfaceTest.cpp
Source/WebKit/chromium/tests/CCSolidColorLayerImplTest.cpp
Source/WebKit/chromium/tests/CCTiledLayerImplTest.cpp
Source/WebKit/chromium/tests/Canvas2DLayerChromiumTest.cpp
Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp
Source/WebKit/chromium/tests/TreeSynchronizerTest.cpp

index 89642099a36ffdda1c0db8c1645945f74ac2c8f2..eea05a3a003858e3e0e2870d9b3fc489c25138bf 100644 (file)
@@ -1,3 +1,122 @@
+2012-02-24  Tien-Ren Chen  <trchen@chromium.org>
+
+        [chromium] Replace RefPtr with OwnPtr for CCLayerImpl tree structure
+        https://bugs.webkit.org/show_bug.cgi?id=78404
+
+        Reviewed by James Robinson.
+
+        No new tests. Updated existing test to reflect changes.
+
+        * platform/graphics/chromium/CanvasLayerChromium.cpp:
+        (WebCore::CanvasLayerChromium::createCCLayerImpl):
+        * platform/graphics/chromium/CanvasLayerChromium.h:
+        (CanvasLayerChromium):
+        * platform/graphics/chromium/LayerChromium.cpp:
+        (WebCore::LayerChromium::createCCLayerImpl):
+        * platform/graphics/chromium/LayerChromium.h:
+        (LayerChromium):
+        * platform/graphics/chromium/PluginLayerChromium.cpp:
+        (WebCore::PluginLayerChromium::createCCLayerImpl):
+        * platform/graphics/chromium/PluginLayerChromium.h:
+        (PluginLayerChromium):
+        * platform/graphics/chromium/SolidColorLayerChromium.cpp:
+        (WebCore::SolidColorLayerChromium::createCCLayerImpl):
+        * platform/graphics/chromium/SolidColorLayerChromium.h:
+        (SolidColorLayerChromium):
+        * platform/graphics/chromium/TiledLayerChromium.cpp:
+        (WebCore::TiledLayerChromium::createCCLayerImpl):
+        * platform/graphics/chromium/TiledLayerChromium.h:
+        (TiledLayerChromium):
+        * platform/graphics/chromium/TreeSynchronizer.cpp:
+        (WebCore::TreeSynchronizer::synchronizeTrees):
+        (WebCore::TreeSynchronizer::collectExistingCCLayerImplRecursive):
+        (WebCore):
+        (WebCore::TreeSynchronizer::reuseOrCreateCCLayerImpl):
+        (WebCore::TreeSynchronizer::synchronizeTreeRecursive):
+        * platform/graphics/chromium/TreeSynchronizer.h:
+        (TreeSynchronizer):
+        * platform/graphics/chromium/VideoLayerChromium.cpp:
+        (WebCore::VideoLayerChromium::createCCLayerImpl):
+        * platform/graphics/chromium/VideoLayerChromium.h:
+        (VideoLayerChromium):
+        * platform/graphics/chromium/cc/CCCanvasLayerImpl.h:
+        (WebCore::CCCanvasLayerImpl::create):
+        * platform/graphics/chromium/cc/CCDamageTracker.cpp:
+        (WebCore::CCDamageTracker::updateDamageTrackingState):
+        (WebCore::CCDamageTracker::trackDamageFromActiveLayers):
+        * platform/graphics/chromium/cc/CCDamageTracker.h:
+        (CCDamageTracker):
+        * platform/graphics/chromium/cc/CCLayerImpl.cpp:
+        (WebCore::CCLayerImpl::CCLayerImpl):
+        (WebCore::CCLayerImpl::addChild):
+        (WebCore::sortLayers):
+        (WebCore::CCLayerImpl::setMaskLayer):
+        (WebCore::CCLayerImpl::setReplicaLayer):
+        * platform/graphics/chromium/cc/CCLayerImpl.h:
+        (WebCore::CCLayerImpl::create):
+        (WebCore::CCLayerImpl::children):
+        (CCLayerImpl):
+        (WebCore):
+        * platform/graphics/chromium/cc/CCLayerIterator.cpp:
+        (WebCore):
+        (WebCore::CCLayerIteratorActions::BackToFront::begin):
+        (WebCore::CCLayerIteratorActions::BackToFront::end):
+        (WebCore::CCLayerIteratorActions::BackToFront::next):
+        (WebCore::CCLayerIteratorActions::FrontToBack::begin):
+        (WebCore::CCLayerIteratorActions::FrontToBack::end):
+        (WebCore::CCLayerIteratorActions::FrontToBack::next):
+        (WebCore::CCLayerIteratorActions::FrontToBack::goToHighestInSubtree):
+        * platform/graphics/chromium/cc/CCLayerIterator.h:
+        (WebCore):
+        (CCLayerIterator):
+        (WebCore::CCLayerIterator::begin):
+        (WebCore::CCLayerIterator::end):
+        (WebCore::CCLayerIterator::targetRenderSurfaceLayer):
+        (WebCore::CCLayerIterator::CCLayerIterator):
+        (WebCore::CCLayerIterator::getRawPtr):
+        (WebCore::CCLayerIterator::currentLayer):
+        (WebCore::CCLayerIterator::targetRenderSurfaceChildren):
+        (BackToFront):
+        (FrontToBack):
+        * platform/graphics/chromium/cc/CCLayerSorter.cpp:
+        (WebCore::CCLayerSorter::createGraphNodes):
+        * platform/graphics/chromium/cc/CCLayerSorter.h:
+        (CCLayerSorter):
+        * platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
+        (WebCore::CCLayerTreeHost::finishCommitOnImplThread):
+        (WebCore::CCLayerTreeHost::didBecomeInvisibleOnImplThread):
+        (WebCore::CCLayerTreeHost::reserveTextures):
+        (WebCore::CCLayerTreeHost::paintLayerContents):
+        (WebCore::CCLayerTreeHost::updateCompositorResources):
+        * platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp:
+        (WebCore):
+        (WebCore::calculateDrawTransformsAndVisibilityInternal):
+        (WebCore::walkLayersAndCalculateVisibleLayerRects):
+        (WebCore::CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility):
+        * platform/graphics/chromium/cc/CCLayerTreeHostCommon.h:
+        (CCLayerTreeHostCommon):
+        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
+        (WebCore::CCLayerTreeHostImpl::CCLayerTreeHostImpl):
+        (WebCore::CCLayerTreeHostImpl::trackDamageForAllSurfaces):
+        (WebCore::CCLayerTreeHostImpl::calculateRenderPasses):
+        (WebCore::CCLayerTreeHostImpl::drawLayers):
+        (WebCore::CCLayerTreeHostImpl::setRootLayer):
+        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.h:
+        (CCLayerTreeHostImpl):
+        (WebCore::CCLayerTreeHostImpl::releaseRootLayer):
+        (WebCore::CCLayerTreeHostImpl::scrollLayer):
+        * platform/graphics/chromium/cc/CCPluginLayerImpl.h:
+        (WebCore::CCPluginLayerImpl::create):
+        * platform/graphics/chromium/cc/CCRenderSurface.h:
+        (WebCore::CCRenderSurface::layerList):
+        (CCRenderSurface):
+        * platform/graphics/chromium/cc/CCSolidColorLayerImpl.h:
+        (WebCore::CCSolidColorLayerImpl::create):
+        * platform/graphics/chromium/cc/CCTiledLayerImpl.h:
+        (WebCore::CCTiledLayerImpl::create):
+        * platform/graphics/chromium/cc/CCVideoLayerImpl.h:
+        (WebCore::CCVideoLayerImpl::create):
+
 2012-02-24  Andreas Kling  <awesomekling@apple.com>
 
         Don't pass constant strings to CSSParser for presentation attributes.
index 181ba4e5812ce8878a17920258f8ede8dfb4621e..d533699af9f1f7aa08528d41f8b6bcc260b03531 100644 (file)
@@ -45,7 +45,7 @@ CanvasLayerChromium::CanvasLayerChromium()
 {
 }
 
-PassRefPtr<CCLayerImpl> CanvasLayerChromium::createCCLayerImpl()
+PassOwnPtr<CCLayerImpl> CanvasLayerChromium::createCCLayerImpl()
 {
     return CCCanvasLayerImpl::create(m_layerId);
 }
index 9e8ce7d8cc82aa883c36a8586309448f33620271..722cc1a667389b35710582528b6d1cc763a35745 100644 (file)
@@ -41,7 +41,7 @@ namespace WebCore {
 // Base class for WebGL and accelerated 2d canvases.
 class CanvasLayerChromium : public LayerChromium {
 public:
-    virtual PassRefPtr<CCLayerImpl> createCCLayerImpl();
+    virtual PassOwnPtr<CCLayerImpl> createCCLayerImpl();
 
 protected:
     CanvasLayerChromium();
index bd67b756f668a715bc210aac97607dd36ae71aa1..95081f3308f381cadf0e682fbf7594f29770ff0d 100644 (file)
@@ -527,7 +527,7 @@ void LayerChromium::pushPropertiesTo(CCLayerImpl* layer)
     m_updateRect = FloatRect();
 }
 
-PassRefPtr<CCLayerImpl> LayerChromium::createCCLayerImpl()
+PassOwnPtr<CCLayerImpl> LayerChromium::createCCLayerImpl()
 {
     return CCLayerImpl::create(m_layerId);
 }
index 8e51e7e9533c7b185175b249b337d72d46d517f2..775d67e3f77557b58f2016ae7fab70fd82def76e 100644 (file)
@@ -44,6 +44,7 @@
 #include "TransformationMatrix.h"
 
 #include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
 #include <wtf/Vector.h>
@@ -256,7 +257,7 @@ protected:
     RefPtr<LayerChromium> m_maskLayer;
 
     // Constructs a CCLayerImpl of the correct runtime type for this LayerChromium type.
-    virtual PassRefPtr<CCLayerImpl> createCCLayerImpl();
+    virtual PassOwnPtr<CCLayerImpl> createCCLayerImpl();
     int m_layerId;
 
 private:
index 079ad2ede95475582b870729a71a5d61bd28ab4b..625f4b21dfb8a51d3c9e7af092e4a029bcb366e0 100644 (file)
@@ -63,7 +63,7 @@ void PluginLayerChromium::updateCompositorResources(GraphicsContext3D* rendererC
     m_dirtyRect = FloatRect();
 }
 
-PassRefPtr<CCLayerImpl> PluginLayerChromium::createCCLayerImpl()
+PassOwnPtr<CCLayerImpl> PluginLayerChromium::createCCLayerImpl()
 {
     return CCPluginLayerImpl::create(m_layerId);
 }
index 84365695bb1ddc65231add04f6f0d8300091e0d0..c30f77ac5d1b7ba5a74dadb08fde4a13b3ea4483 100644 (file)
@@ -39,7 +39,7 @@ public:
     static PassRefPtr<PluginLayerChromium> create();
     virtual void updateCompositorResources(GraphicsContext3D*, CCTextureUpdater&);
 
-    virtual PassRefPtr<CCLayerImpl> createCCLayerImpl();
+    virtual PassOwnPtr<CCLayerImpl> createCCLayerImpl();
 
     // Code path for plugins which supply their own texture ID.
     void setTextureId(unsigned textureId);
index ed13546bae87f4051b30e3494c0f2fde853f1e33..0dc77ada822602325e679e315488336893b94e3a 100644 (file)
@@ -33,7 +33,7 @@
 
 namespace WebCore {
 
-PassRefPtr<CCLayerImpl> SolidColorLayerChromium::createCCLayerImpl()
+PassOwnPtr<CCLayerImpl> SolidColorLayerChromium::createCCLayerImpl()
 {
     return CCSolidColorLayerImpl::create(id());
 }
index 1d14890bd0e1f0c20c63c6d231715948d21894fc..94a54a0ac5ade119786dd06bd349dbb217bbd59c 100644 (file)
@@ -38,7 +38,7 @@ class LayerTilerChromium;
 // setBackgroundColor() on the base class.
 class SolidColorLayerChromium : public LayerChromium {
 public:
-    virtual PassRefPtr<CCLayerImpl> createCCLayerImpl();
+    virtual PassOwnPtr<CCLayerImpl> createCCLayerImpl();
     static PassRefPtr<SolidColorLayerChromium> create();
 
     virtual ~SolidColorLayerChromium();
index a9cf7d6fd2cde69e3d31db090b568f21d1353c9b..7bf0c97572c60b9c3ec87bf9854b875158feebc2 100644 (file)
@@ -97,7 +97,7 @@ TiledLayerChromium::~TiledLayerChromium()
 {
 }
 
-PassRefPtr<CCLayerImpl> TiledLayerChromium::createCCLayerImpl()
+PassOwnPtr<CCLayerImpl> TiledLayerChromium::createCCLayerImpl()
 {
     return CCTiledLayerImpl::create(id());
 }
index 2d9995367ad2436affafe6dcc323af953aed3072..a6c211951d78514340f567bdf360ea6741094e94 100644 (file)
@@ -102,7 +102,7 @@ protected:
     virtual TextureManager* textureManager() const;
 
 private:
-    virtual PassRefPtr<CCLayerImpl> createCCLayerImpl();
+    virtual PassOwnPtr<CCLayerImpl> createCCLayerImpl();
 
     void createTilerIfNeeded();
     void setTilingOption(TilingOption);
index d0fd0ce523d63884be932e1bd416582f25762e40..ebd1ac730b194541c2b4c4eef1f6cca599b4e5c8 100644 (file)
 
 namespace WebCore {
 
-void TreeSynchronizer::addCCLayerImplsToMapRecursive(CCLayerImplMap& map, CCLayerImpl* ccLayerImpl)
+PassOwnPtr<CCLayerImpl> TreeSynchronizer::synchronizeTrees(LayerChromium* layerChromiumRoot, PassOwnPtr<CCLayerImpl> oldCCLayerImplRoot)
 {
-    map.set(ccLayerImpl->id(), ccLayerImpl);
-
-    const Vector<RefPtr<CCLayerImpl> >& children = ccLayerImpl->children();
-    for (size_t i = 0; i < children.size(); ++i)
-        addCCLayerImplsToMapRecursive(map, children[i].get());
-
-    if (CCLayerImpl* maskLayer = ccLayerImpl->maskLayer())
-        addCCLayerImplsToMapRecursive(map, maskLayer);
+    CCLayerImplMap map;
+    collectExistingCCLayerImplRecursive(map, oldCCLayerImplRoot);
 
-    if (CCLayerImpl* replicaLayer = ccLayerImpl->replicaLayer())
-        addCCLayerImplsToMapRecursive(map, replicaLayer);
+    return synchronizeTreeRecursive(map, layerChromiumRoot);
 }
 
-PassRefPtr<CCLayerImpl> TreeSynchronizer::synchronizeTreeRecursive(LayerChromium* layer, CCLayerImplMap& map)
+void TreeSynchronizer::collectExistingCCLayerImplRecursive(CCLayerImplMap& map, PassOwnPtr<CCLayerImpl> popCCLayerImpl)
 {
-    RefPtr<CCLayerImpl> ccLayerImpl;
-    CCLayerImplMap::iterator it = map.find(layer->id());
-    if (it != map.end()) {
-        ccLayerImpl = it->second; // We already have an entry for this, we just need to reparent it.
-        ccLayerImpl->clearChildList();
-    } else {
-        ccLayerImpl = layer->createCCLayerImpl();
-        map.set(layer->id(), ccLayerImpl); // Add it to the map so other layers referencing this one can pick it up.
-    }
+    OwnPtr<CCLayerImpl> ccLayerImpl = popCCLayerImpl;
 
-    const Vector<RefPtr<LayerChromium> >& children = layer->children();
+    if (!ccLayerImpl)
+        return;
+
+    Vector<OwnPtr<CCLayerImpl> >& children = ccLayerImpl->m_children;
     for (size_t i = 0; i < children.size(); ++i)
-        ccLayerImpl->addChild(synchronizeTreeRecursive(children[i].get(), map));
+        collectExistingCCLayerImplRecursive(map, children[i].release());
 
-    if (LayerChromium* maskLayer = layer->maskLayer())
-        ccLayerImpl->setMaskLayer(synchronizeTreeRecursive(maskLayer, map));
-    else
-        ccLayerImpl->setMaskLayer(0);
+    collectExistingCCLayerImplRecursive(map, ccLayerImpl->m_maskLayer.release());
+    collectExistingCCLayerImplRecursive(map, ccLayerImpl->m_replicaLayer.release());
 
-    if (LayerChromium* replicaLayer = layer->replicaLayer())
-        ccLayerImpl->setReplicaLayer(synchronizeTreeRecursive(replicaLayer, map));
-    else
-        ccLayerImpl->setReplicaLayer(0);
+    int id = ccLayerImpl->id();
+    map.set(id, ccLayerImpl.release());
+}
+
+PassOwnPtr<CCLayerImpl> TreeSynchronizer::reuseOrCreateCCLayerImpl(CCLayerImplMap& map, LayerChromium* layer)
+{
+    OwnPtr<CCLayerImpl> ccLayerImpl = map.take(layer->id());
+
+    if (!ccLayerImpl)
+        return layer->createCCLayerImpl();
 
-    layer->pushPropertiesTo(ccLayerImpl.get());
     return ccLayerImpl.release();
 }
 
-PassRefPtr<CCLayerImpl> TreeSynchronizer::synchronizeTrees(LayerChromium* layerChromiumRoot, PassRefPtr<CCLayerImpl> prpOldCCLayerImplRoot)
+PassOwnPtr<CCLayerImpl> TreeSynchronizer::synchronizeTreeRecursive(CCLayerImplMap& map, LayerChromium* layer)
 {
-    RefPtr<CCLayerImpl> oldCCLayerImplRoot = prpOldCCLayerImplRoot;
-    // Build a map from layer IDs to CCLayerImpls so we can reuse layers from the old tree.
-    CCLayerImplMap map;
-    if (oldCCLayerImplRoot)
-        addCCLayerImplsToMapRecursive(map, oldCCLayerImplRoot.get());
+    if (!layer)
+        return nullptr;
 
-    // Recursively build the new layer tree.
-    RefPtr<CCLayerImpl> newCCLayerImplRoot = synchronizeTreeRecursive(layerChromiumRoot, map);
+    OwnPtr<CCLayerImpl> ccLayerImpl = reuseOrCreateCCLayerImpl(map, layer);
 
-    return newCCLayerImplRoot.release();
+    ccLayerImpl->clearChildList();
+    const Vector<RefPtr<LayerChromium> >& children = layer->children();
+    for (size_t i = 0; i < children.size(); ++i)
+        ccLayerImpl->addChild(synchronizeTreeRecursive(map, children[i].get()));
+
+    ccLayerImpl->setMaskLayer(synchronizeTreeRecursive(map, layer->maskLayer()));
+    ccLayerImpl->setReplicaLayer(synchronizeTreeRecursive(map, layer->replicaLayer()));
+
+    layer->pushPropertiesTo(ccLayerImpl.get());
+    return ccLayerImpl.release();
 }
 
 } // namespace WebCore
index a4e494217395e8d2e1296bd656662e32b119acff..134708ca43bd89ecbdf2fd21592fd07286dcc179 100644 (file)
@@ -28,7 +28,8 @@
 
 #include <wtf/HashMap.h>
 #include <wtf/Noncopyable.h>
-#include <wtf/PassRefPtr.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
 
 namespace WebCore {
 
@@ -40,16 +41,17 @@ WTF_MAKE_NONCOPYABLE(TreeSynchronizer);
 public:
     // Accepts a LayerChromium tree and returns a reference to a CCLayerImpl tree that duplicates the structure
     // of the LayerChromium tree, reusing the CCLayerImpls in the tree provided by oldCCLayerImplRoot if possible.
-    static PassRefPtr<CCLayerImpl> synchronizeTrees(LayerChromium* layerRoot, PassRefPtr<CCLayerImpl> oldCCLayerImplRoot);
+    static PassOwnPtr<CCLayerImpl> synchronizeTrees(LayerChromium* layerRoot, PassOwnPtr<CCLayerImpl> oldCCLayerImplRoot);
 
 private:
     TreeSynchronizer(); // Not instantiable.
 
-    typedef HashMap<int, RefPtr<CCLayerImpl> > CCLayerImplMap;
+    typedef HashMap<int, OwnPtr<CCLayerImpl> > CCLayerImplMap;
 
     // Declared as static member functions so they can access functions on LayerChromium as a friend class.
-    static void addCCLayerImplsToMapRecursive(CCLayerImplMap&, CCLayerImpl*);
-    static PassRefPtr<CCLayerImpl> synchronizeTreeRecursive(LayerChromium*, CCLayerImplMap&);
+    static PassOwnPtr<CCLayerImpl> reuseOrCreateCCLayerImpl(CCLayerImplMap&, LayerChromium*);
+    static void collectExistingCCLayerImplRecursive(CCLayerImplMap&, PassOwnPtr<CCLayerImpl>);
+    static PassOwnPtr<CCLayerImpl> synchronizeTreeRecursive(CCLayerImplMap&, LayerChromium*);
 };
 
 } // namespace WebCore
index 3b44eda386d6105a6dc2bcb78b3faf1bc5d39d2d..d99f5e511c12a3c698cc8e8875171012a35ec1bf 100644 (file)
@@ -52,7 +52,7 @@ VideoLayerChromium::~VideoLayerChromium()
 {
 }
 
-PassRefPtr<CCLayerImpl> VideoLayerChromium::createCCLayerImpl()
+PassOwnPtr<CCLayerImpl> VideoLayerChromium::createCCLayerImpl()
 {
     return CCVideoLayerImpl::create(m_layerId, m_provider);
 }
index 65cf5c668de548e569c07c98be188092311a1a71..77984806b82fc6e766c2d43c34c27c4deec4faac 100644 (file)
@@ -48,7 +48,7 @@ public:
     static PassRefPtr<VideoLayerChromium> create(VideoFrameProvider* = 0);
     virtual ~VideoLayerChromium();
 
-    virtual PassRefPtr<CCLayerImpl> createCCLayerImpl();
+    virtual PassOwnPtr<CCLayerImpl> createCCLayerImpl();
 
     void contentChanged();
 
index 9126a7d44501e6325b5efd4b57cba9e46bc8a75a..c96af246ed3ba75895bbef552d4c98d4e80b5bc4 100644 (file)
@@ -34,9 +34,9 @@ namespace WebCore {
 
 class CCCanvasLayerImpl : public CCLayerImpl {
 public:
-    static PassRefPtr<CCCanvasLayerImpl> create(int id)
+    static PassOwnPtr<CCCanvasLayerImpl> create(int id)
     {
-        return adoptRef(new CCCanvasLayerImpl(id));
+        return adoptPtr(new CCCanvasLayerImpl(id));
     }
     virtual ~CCCanvasLayerImpl();
 
index 2d6f43f3185fc445ca9959fe804f624b3b4e133f..6a062caca7cc5875f2c92599856b6a5ec8e53c79 100644 (file)
@@ -56,7 +56,7 @@ CCDamageTracker::~CCDamageTracker()
 {
 }
 
-void CCDamageTracker::updateDamageTrackingState(const Vector<RefPtr<CCLayerImpl> >& layerList, int targetSurfaceLayerID, CCLayerImpl* targetSurfaceMaskLayer)
+void CCDamageTracker::updateDamageTrackingState(const Vector<CCLayerImpl*>& layerList, int targetSurfaceLayerID, CCLayerImpl* targetSurfaceMaskLayer)
 {
     //
     // This function computes the "damage rect" of a target surface, and updates the state
@@ -130,7 +130,7 @@ void CCDamageTracker::updateDamageTrackingState(const Vector<RefPtr<CCLayerImpl>
 
     // If the target surface already knows its entire region is damaged, we can return early.
     // FIXME: this should go away, or will be cleaner, after refactoring into RenderPass/RenderSchedule.
-    CCLayerImpl* layer = layerList[0].get();
+    CCLayerImpl* layer = layerList[0];
     CCRenderSurface* targetSurface = layer->targetRenderSurface();
 
     if (m_forceFullDamageNextUpdate || targetSurface->surfacePropertyChangedOnlyFromDescendant()) {
@@ -161,12 +161,12 @@ void CCDamageTracker::saveRectForNextFrame(int layerID, const FloatRect& targetS
     m_nextRectHistory->set(layerID, targetSpaceRect);
 }
 
-FloatRect CCDamageTracker::trackDamageFromActiveLayers(const Vector<RefPtr<CCLayerImpl> >& layerList, int targetSurfaceLayerID)
+FloatRect CCDamageTracker::trackDamageFromActiveLayers(const Vector<CCLayerImpl*>& layerList, int targetSurfaceLayerID)
 {
     FloatRect damageRect = FloatRect();
 
     for (unsigned layerIndex = 0; layerIndex < layerList.size(); ++layerIndex) {
-        CCLayerImpl* layer = layerList[layerIndex].get();
+        CCLayerImpl* layer = layerList[layerIndex];
 
         if (CCLayerTreeHostCommon::renderSurfaceContributesToTarget<CCLayerImpl>(layer, targetSurfaceLayerID))
             extendDamageForRenderSurface(layer, damageRect);
index d428f26d1a0c25ca0c481c093eb3a8ffba3bb809..7a629c4781281be4dfa1c49dd13b11e4f9550f76 100644 (file)
@@ -44,13 +44,13 @@ public:
     ~CCDamageTracker();
 
     void forceFullDamageNextUpdate() { m_forceFullDamageNextUpdate = true; }
-    void updateDamageTrackingState(const Vector<RefPtr<CCLayerImpl> >& layerList, int targetSurfaceLayerID, CCLayerImpl* targetSurfaceMaskLayer);
+    void updateDamageTrackingState(const Vector<CCLayerImpl*>& layerList, int targetSurfaceLayerID, CCLayerImpl* targetSurfaceMaskLayer);
     const FloatRect& currentDamageRect() { return m_currentDamageRect; }
 
 private:
     CCDamageTracker();
 
-    FloatRect trackDamageFromActiveLayers(const Vector<RefPtr<CCLayerImpl> >& layerList, int targetSurfaceLayerID);
+    FloatRect trackDamageFromActiveLayers(const Vector<CCLayerImpl*>& layerList, int targetSurfaceLayerID);
     FloatRect trackDamageFromSurfaceMask(CCLayerImpl* targetSurfaceMaskLayer);
     FloatRect trackDamageFromLeftoverRects();
 
index 0589dca8afaa0d31c82c68b4b6ffe732071b179d..28d1d99a46f675c622ba142665d7e5f63e63b5e9 100644 (file)
@@ -42,6 +42,8 @@ namespace WebCore {
 
 CCLayerImpl::CCLayerImpl(int id)
     : m_parent(0)
+    , m_maskLayerId(-1)
+    , m_replicaLayerId(-1)
     , m_layerId(id)
     , m_anchorPoint(0.5, 0.5)
     , m_anchorPointZ(0)
@@ -73,7 +75,7 @@ CCLayerImpl::~CCLayerImpl()
     ASSERT(CCProxy::isImplThread());
 }
 
-void CCLayerImpl::addChild(PassRefPtr<CCLayerImpl> child)
+void CCLayerImpl::addChild(PassOwnPtr<CCLayerImpl> child)
 {
     child->setParent(this);
     m_children.append(child);
@@ -83,13 +85,16 @@ void CCLayerImpl::removeFromParent()
 {
     if (!m_parent)
         return;
-    for (size_t i = 0; i < m_parent->m_children.size(); ++i) {
-        if (m_parent->m_children[i].get() == this) {
-            m_parent->m_children.remove(i);
-            break;
+
+    CCLayerImpl* parent = m_parent;
+    m_parent = 0;
+
+    for (size_t i = 0; i < parent->m_children.size(); ++i) {
+        if (parent->m_children[i].get() == this) {
+            parent->m_children.remove(i);
+            return;
         }
     }
-    m_parent = 0;
 }
 
 void CCLayerImpl::removeAllChildren()
@@ -244,7 +249,7 @@ void CCLayerImpl::dumpLayerProperties(TextStream& ts, int indent) const
     ts << "drawsContent: " << (m_drawsContent ? "yes" : "no") << "\n";
 }
 
-void sortLayers(Vector<RefPtr<CCLayerImpl> >::iterator first, Vector<RefPtr<CCLayerImpl> >::iterator end, CCLayerSorter* layerSorter)
+void sortLayers(Vector<CCLayerImpl*>::iterator first, Vector<CCLayerImpl*>::iterator end, CCLayerSorter* layerSorter)
 {
     TRACE_EVENT("LayerRendererChromium::sortLayers", 0, 0);
     layerSorter->sort(first, end);
@@ -319,21 +324,27 @@ void CCLayerImpl::setBounds(const IntSize& bounds)
         m_layerPropertyChanged = true;
 }
 
-void CCLayerImpl::setMaskLayer(PassRefPtr<CCLayerImpl> maskLayer)
+void CCLayerImpl::setMaskLayer(PassOwnPtr<CCLayerImpl> maskLayer)
 {
-    if (m_maskLayer == maskLayer)
+    m_maskLayer = maskLayer;
+
+    int newLayerId = m_maskLayer ? m_maskLayer->id() : -1;
+    if (newLayerId == m_maskLayerId)
         return;
 
-    m_maskLayer = maskLayer;
+    m_maskLayerId = newLayerId;
     noteLayerPropertyChangedForSubtree();
 }
 
-void CCLayerImpl::setReplicaLayer(PassRefPtr<CCLayerImpl> replicaLayer)
+void CCLayerImpl::setReplicaLayer(PassOwnPtr<CCLayerImpl> replicaLayer)
 {
-    if (m_replicaLayer == replicaLayer)
+    m_replicaLayer = replicaLayer;
+
+    int newLayerId = m_replicaLayer ? m_replicaLayer->id() : -1;
+    if (newLayerId == m_replicaLayerId)
         return;
 
-    m_replicaLayer = replicaLayer;
+    m_replicaLayerId = newLayerId;
     noteLayerPropertyChangedForSubtree();
 }
 
index c7a4f0856f955a556eecd54136d5116155565318..156b9896573882acdc7a74e7e88831fe04d08044 100644 (file)
@@ -46,11 +46,11 @@ class CCLayerSorter;
 class LayerChromium;
 class LayerRendererChromium;
 
-class CCLayerImpl : public RefCounted<CCLayerImpl>, public CCLayerAnimationControllerImplClient {
+class CCLayerImpl : public CCLayerAnimationControllerImplClient {
 public:
-    static PassRefPtr<CCLayerImpl> create(int id)
+    static PassOwnPtr<CCLayerImpl> create(int id)
     {
-        return adoptRef(new CCLayerImpl(id));
+        return adoptPtr(new CCLayerImpl(id));
     }
 
     // CCLayerAnimationControllerImplClient implementation.
@@ -65,15 +65,15 @@ public:
 
     // Tree structure.
     CCLayerImpl* parent() const { return m_parent; }
-    const Vector<RefPtr<CCLayerImpl> >& children() const { return m_children; }
-    void addChild(PassRefPtr<CCLayerImpl>);
+    const Vector<OwnPtr<CCLayerImpl> >& children() const { return m_children; }
+    void addChild(PassOwnPtr<CCLayerImpl>);
     void removeFromParent();
     void removeAllChildren();
 
-    void setMaskLayer(PassRefPtr<CCLayerImpl>);
+    void setMaskLayer(PassOwnPtr<CCLayerImpl>);
     CCLayerImpl* maskLayer() const { return m_maskLayer.get(); }
 
-    void setReplicaLayer(PassRefPtr<CCLayerImpl>);
+    void setReplicaLayer(PassOwnPtr<CCLayerImpl>);
     CCLayerImpl* replicaLayer() const { return m_replicaLayer.get(); }
 
 #ifndef NDEBUG
@@ -236,9 +236,12 @@ private:
 
     // Properties internal to CCLayerImpl
     CCLayerImpl* m_parent;
-    Vector<RefPtr<CCLayerImpl> > m_children;
-    RefPtr<CCLayerImpl> m_maskLayer;
-    RefPtr<CCLayerImpl> m_replicaLayer;
+    Vector<OwnPtr<CCLayerImpl> > m_children;
+    // m_maskLayer can be temporarily stolen during tree sync, we need this ID to confirm newly assigned layer is still the previous one
+    int m_maskLayerId;
+    OwnPtr<CCLayerImpl> m_maskLayer;
+    int m_replicaLayerId; // ditto
+    OwnPtr<CCLayerImpl> m_replicaLayer;
     int m_layerId;
 
     // Properties synchronized from the associated LayerChromium.
@@ -324,7 +327,7 @@ private:
     OwnPtr<CCLayerAnimationControllerImpl> m_layerAnimationController;
 };
 
-void sortLayers(Vector<RefPtr<CCLayerImpl> >::iterator first, Vector<RefPtr<CCLayerImpl> >::iterator end, CCLayerSorter*);
+void sortLayers(Vector<CCLayerImpl*>::iterator first, Vector<CCLayerImpl*>::iterator end, CCLayerSorter*);
 
 }
 
index 97d6d185a04c7211ebbb2ac82f553c422399ef48..2d6d2f7f7a9ec054d09091561a0c8b4772a5b30b 100644 (file)
@@ -35,8 +35,8 @@
 
 namespace WebCore {
 
-template <typename LayerType, typename RenderSurfaceType, typename ActionType>
-void CCLayerIteratorActions::BackToFront::begin(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>& it)
+template <typename LayerType, typename LayerList, typename RenderSurfaceType, typename ActionType>
+void CCLayerIteratorActions::BackToFront::begin(CCLayerIterator<LayerType, LayerList, RenderSurfaceType, ActionType>& it)
 {
     it.m_targetRenderSurfaceLayerIndex = 0;
     it.m_currentLayerIndex = CCLayerIteratorValue::LayerIndexRepresentingTargetRenderSurface;
@@ -44,15 +44,15 @@ void CCLayerIteratorActions::BackToFront::begin(CCLayerIterator<LayerType, Rende
     m_highestTargetRenderSurfaceLayer = 0;
 }
 
-template <typename LayerType, typename RenderSurfaceType, typename ActionType>
-void CCLayerIteratorActions::BackToFront::end(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>& it)
+template <typename LayerType, typename LayerList, typename RenderSurfaceType, typename ActionType>
+void CCLayerIteratorActions::BackToFront::end(CCLayerIterator<LayerType, LayerList, RenderSurfaceType, ActionType>& it)
 {
     it.m_targetRenderSurfaceLayerIndex = CCLayerIteratorValue::InvalidTargetRenderSurfaceLayerIndex;
     it.m_currentLayerIndex = 0;
 }
 
-template <typename LayerType, typename RenderSurfaceType, typename ActionType>
-void CCLayerIteratorActions::BackToFront::next(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>& it)
+template <typename LayerType, typename LayerList, typename RenderSurfaceType, typename ActionType>
+void CCLayerIteratorActions::BackToFront::next(CCLayerIterator<LayerType, LayerList, RenderSurfaceType, ActionType>& it)
 {
     // If the current layer has a RS, move to its layer list. Otherwise, visit the next layer in the current RS layer list.
     if (it.currentLayerRepresentsContributingRenderSurface()) {
@@ -85,23 +85,23 @@ void CCLayerIteratorActions::BackToFront::next(CCLayerIterator<LayerType, Render
     }
 }
 
-template <typename LayerType, typename RenderSurfaceType, typename ActionType>
-void CCLayerIteratorActions::FrontToBack::begin(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>& it)
+template <typename LayerType, typename LayerList, typename RenderSurfaceType, typename ActionType>
+void CCLayerIteratorActions::FrontToBack::begin(CCLayerIterator<LayerType, LayerList, RenderSurfaceType, ActionType>& it)
 {
     it.m_targetRenderSurfaceLayerIndex = 0;
     it.m_currentLayerIndex = it.targetRenderSurfaceChildren().size() - 1;
     goToHighestInSubtree(it);
 }
 
-template <typename LayerType, typename RenderSurfaceType, typename ActionType>
-void CCLayerIteratorActions::FrontToBack::end(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>& it)
+template <typename LayerType, typename LayerList, typename RenderSurfaceType, typename ActionType>
+void CCLayerIteratorActions::FrontToBack::end(CCLayerIterator<LayerType, LayerList, RenderSurfaceType, ActionType>& it)
 {
     it.m_targetRenderSurfaceLayerIndex = CCLayerIteratorValue::InvalidTargetRenderSurfaceLayerIndex;
     it.m_currentLayerIndex = 0;
 }
 
-template <typename LayerType, typename RenderSurfaceType, typename ActionType>
-void CCLayerIteratorActions::FrontToBack::next(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>& it)
+template <typename LayerType, typename LayerList, typename RenderSurfaceType, typename ActionType>
+void CCLayerIteratorActions::FrontToBack::next(CCLayerIterator<LayerType, LayerList, RenderSurfaceType, ActionType>& it)
 {
     // Moves to the previous layer in the current RS layer list. Then we check if the
     // new current layer has its own RS, in which case there are things in that RS layer list that are higher, so
@@ -128,8 +128,8 @@ void CCLayerIteratorActions::FrontToBack::next(CCLayerIterator<LayerType, Render
     }
 }
 
-template <typename LayerType, typename RenderSurfaceType, typename ActionType>
-void CCLayerIteratorActions::FrontToBack::goToHighestInSubtree(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>& it)
+template <typename LayerType, typename LayerList, typename RenderSurfaceType, typename ActionType>
+void CCLayerIteratorActions::FrontToBack::goToHighestInSubtree(CCLayerIterator<LayerType, LayerList, RenderSurfaceType, ActionType>& it)
 {
     if (it.currentLayerRepresentsTargetRenderSurface())
         return;
@@ -147,23 +147,23 @@ void CCLayerIteratorActions::FrontToBack::goToHighestInSubtree(CCLayerIterator<L
 }
 
 // Declare each of the above functions for LayerChromium and CCLayerImpl classes so that they are linked.
-template void CCLayerIteratorActions::BackToFront::begin(CCLayerIterator<LayerChromium, RenderSurfaceChromium, BackToFront> &);
-template void CCLayerIteratorActions::BackToFront::end(CCLayerIterator<LayerChromium, RenderSurfaceChromium, BackToFront>&);
-template void CCLayerIteratorActions::BackToFront::next(CCLayerIterator<LayerChromium, RenderSurfaceChromium, BackToFront>&);
-
-template void CCLayerIteratorActions::BackToFront::begin(CCLayerIterator<CCLayerImpl, CCRenderSurface, BackToFront>&);
-template void CCLayerIteratorActions::BackToFront::end(CCLayerIterator<CCLayerImpl, CCRenderSurface, BackToFront>&);
-template void CCLayerIteratorActions::BackToFront::next(CCLayerIterator<CCLayerImpl, CCRenderSurface, BackToFront>&);
-
-template void CCLayerIteratorActions::FrontToBack::next(CCLayerIterator<LayerChromium, RenderSurfaceChromium, FrontToBack>&);
-template void CCLayerIteratorActions::FrontToBack::end(CCLayerIterator<LayerChromium, RenderSurfaceChromium, FrontToBack>&);
-template void CCLayerIteratorActions::FrontToBack::begin(CCLayerIterator<LayerChromium, RenderSurfaceChromium, FrontToBack>&);
-template void CCLayerIteratorActions::FrontToBack::goToHighestInSubtree(CCLayerIterator<LayerChromium, RenderSurfaceChromium, FrontToBack>&);
-
-template void CCLayerIteratorActions::FrontToBack::next(CCLayerIterator<CCLayerImpl, CCRenderSurface, FrontToBack>&);
-template void CCLayerIteratorActions::FrontToBack::end(CCLayerIterator<CCLayerImpl, CCRenderSurface, FrontToBack>&);
-template void CCLayerIteratorActions::FrontToBack::begin(CCLayerIterator<CCLayerImpl, CCRenderSurface, FrontToBack>&);
-template void CCLayerIteratorActions::FrontToBack::goToHighestInSubtree(CCLayerIterator<CCLayerImpl, CCRenderSurface, FrontToBack>&);
+template void CCLayerIteratorActions::BackToFront::begin(CCLayerIterator<LayerChromium, Vector<RefPtr<LayerChromium> >, RenderSurfaceChromium, BackToFront> &);
+template void CCLayerIteratorActions::BackToFront::end(CCLayerIterator<LayerChromium, Vector<RefPtr<LayerChromium> >, RenderSurfaceChromium, BackToFront>&);
+template void CCLayerIteratorActions::BackToFront::next(CCLayerIterator<LayerChromium, Vector<RefPtr<LayerChromium> >, RenderSurfaceChromium, BackToFront>&);
+
+template void CCLayerIteratorActions::BackToFront::begin(CCLayerIterator<CCLayerImpl, Vector<CCLayerImpl*>, CCRenderSurface, BackToFront>&);
+template void CCLayerIteratorActions::BackToFront::end(CCLayerIterator<CCLayerImpl, Vector<CCLayerImpl*>, CCRenderSurface, BackToFront>&);
+template void CCLayerIteratorActions::BackToFront::next(CCLayerIterator<CCLayerImpl, Vector<CCLayerImpl*>, CCRenderSurface, BackToFront>&);
+
+template void CCLayerIteratorActions::FrontToBack::next(CCLayerIterator<LayerChromium, Vector<RefPtr<LayerChromium> >, RenderSurfaceChromium, FrontToBack>&);
+template void CCLayerIteratorActions::FrontToBack::end(CCLayerIterator<LayerChromium, Vector<RefPtr<LayerChromium> >, RenderSurfaceChromium, FrontToBack>&);
+template void CCLayerIteratorActions::FrontToBack::begin(CCLayerIterator<LayerChromium, Vector<RefPtr<LayerChromium> >, RenderSurfaceChromium, FrontToBack>&);
+template void CCLayerIteratorActions::FrontToBack::goToHighestInSubtree(CCLayerIterator<LayerChromium, Vector<RefPtr<LayerChromium> >, RenderSurfaceChromium, FrontToBack>&);
+
+template void CCLayerIteratorActions::FrontToBack::next(CCLayerIterator<CCLayerImpl, Vector<CCLayerImpl*>, CCRenderSurface, FrontToBack>&);
+template void CCLayerIteratorActions::FrontToBack::end(CCLayerIterator<CCLayerImpl, Vector<CCLayerImpl*>, CCRenderSurface, FrontToBack>&);
+template void CCLayerIteratorActions::FrontToBack::begin(CCLayerIterator<CCLayerImpl, Vector<CCLayerImpl*>, CCRenderSurface, FrontToBack>&);
+template void CCLayerIteratorActions::FrontToBack::goToHighestInSubtree(CCLayerIterator<CCLayerImpl, Vector<CCLayerImpl*>, CCRenderSurface, FrontToBack>&);
 
 } // namespace WebCore
 
index be985e153103f508ea4522b9998f90a094d5a670..d89bd69127717a597155e5740904f7ea46bf7cda 100644 (file)
@@ -92,15 +92,15 @@ struct CCLayerIteratorValue {
 };
 
 // An iterator class for walking over layers in the RenderSurface-Layer tree.
-template <typename LayerType, typename RenderSurfaceType, typename IteratorActionType>
+template <typename LayerType, typename LayerList, typename RenderSurfaceType, typename IteratorActionType>
 class CCLayerIterator {
-    typedef CCLayerIterator<LayerType, RenderSurfaceType, IteratorActionType> CCLayerIteratorType;
+    typedef CCLayerIterator<LayerType, LayerList, RenderSurfaceType, IteratorActionType> CCLayerIteratorType;
 
 public:
     CCLayerIterator() : m_renderSurfaceLayerList(0) { }
 
-    static CCLayerIteratorType begin(const Vector<RefPtr<LayerType> >* renderSurfaceLayerList) { return CCLayerIteratorType(renderSurfaceLayerList, true); }
-    static CCLayerIteratorType end(const Vector<RefPtr<LayerType> >* renderSurfaceLayerList) { return CCLayerIteratorType(renderSurfaceLayerList, false); }
+    static CCLayerIteratorType begin(const LayerList* renderSurfaceLayerList) { return CCLayerIteratorType(renderSurfaceLayerList, true); }
+    static CCLayerIteratorType end(const LayerList* renderSurfaceLayerList) { return CCLayerIteratorType(renderSurfaceLayerList, false); }
 
     CCLayerIteratorType& operator++() { m_actions.next(*this); return *this; }
     bool operator==(const CCLayerIterator& other) const
@@ -117,10 +117,10 @@ public:
     bool representsContributingRenderSurface() const { return !representsTargetRenderSurface() && currentLayerRepresentsContributingRenderSurface(); }
     bool representsItself() const { return !representsTargetRenderSurface() && !representsContributingRenderSurface(); }
 
-    LayerType* targetRenderSurfaceLayer() const { return (*m_renderSurfaceLayerList)[m_targetRenderSurfaceLayerIndex].get(); }
+    LayerType* targetRenderSurfaceLayer() const { return getRawPtr((*m_renderSurfaceLayerList)[m_targetRenderSurfaceLayerIndex]); }
 
 private:
-    CCLayerIterator(const Vector<RefPtr<LayerType> >* renderSurfaceLayerList, bool start)
+    CCLayerIterator(const LayerList* renderSurfaceLayerList, bool start)
         : m_renderSurfaceLayerList(renderSurfaceLayerList)
     {
         if (start && !renderSurfaceLayerList->isEmpty())
@@ -129,16 +129,19 @@ private:
             m_actions.end(*this);
     }
 
-    inline LayerType* currentLayer() const { return currentLayerRepresentsTargetRenderSurface() ? targetRenderSurfaceLayer() : targetRenderSurfaceChildren()[m_currentLayerIndex].get(); }
+    inline static LayerChromium* getRawPtr(const RefPtr<LayerChromium>& ptr) { return ptr.get(); }
+    inline static CCLayerImpl* getRawPtr(CCLayerImpl* ptr) { return ptr; }
+
+    inline LayerType* currentLayer() const { return currentLayerRepresentsTargetRenderSurface() ? targetRenderSurfaceLayer() : getRawPtr(targetRenderSurfaceChildren()[m_currentLayerIndex]); }
 
     inline bool currentLayerRepresentsContributingRenderSurface() const { return CCLayerTreeHostCommon::renderSurfaceContributesToTarget<LayerType>(currentLayer(), targetRenderSurfaceLayer()->id()); }
     inline bool currentLayerRepresentsTargetRenderSurface() const { return m_currentLayerIndex == CCLayerIteratorValue::LayerIndexRepresentingTargetRenderSurface; }
 
     inline RenderSurfaceType* targetRenderSurface() const { return targetRenderSurfaceLayer()->renderSurface(); }
-    inline const Vector<RefPtr<LayerType> >& targetRenderSurfaceChildren() const { return targetRenderSurface()->layerList(); }
+    inline const LayerList& targetRenderSurfaceChildren() const { return targetRenderSurface()->layerList(); }
 
     IteratorActionType m_actions;
-    const Vector<RefPtr<LayerType> >* m_renderSurfaceLayerList;
+    const LayerList* m_renderSurfaceLayerList;
 
     // The iterator's current position.
 
@@ -161,14 +164,14 @@ struct CCLayerIteratorActions {
     // Walks layers sorted by z-order from back to front.
     class BackToFront {
     public:
-        template <typename LayerType, typename RenderSurfaceType, typename ActionType>
-        void begin(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>&);
+        template <typename LayerType, typename LayerList, typename RenderSurfaceType, typename ActionType>
+        void begin(CCLayerIterator<LayerType, LayerList, RenderSurfaceType, ActionType>&);
 
-        template <typename LayerType, typename RenderSurfaceType, typename ActionType>
-        void end(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>&);
+        template <typename LayerType, typename LayerList, typename RenderSurfaceType, typename ActionType>
+        void end(CCLayerIterator<LayerType, LayerList, RenderSurfaceType, ActionType>&);
 
-        template <typename LayerType, typename RenderSurfaceType, typename ActionType>
-        void next(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>&);
+        template <typename LayerType, typename LayerList, typename RenderSurfaceType, typename ActionType>
+        void next(CCLayerIterator<LayerType, LayerList, RenderSurfaceType, ActionType>&);
 
     private:
         int m_highestTargetRenderSurfaceLayer;
@@ -177,18 +180,18 @@ struct CCLayerIteratorActions {
     // Walks layers sorted by z-order from front to back
     class FrontToBack {
     public:
-        template <typename LayerType, typename RenderSurfaceType, typename ActionType>
-        void begin(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>&);
+        template <typename LayerType, typename LayerList, typename RenderSurfaceType, typename ActionType>
+        void begin(CCLayerIterator<LayerType, LayerList, RenderSurfaceType, ActionType>&);
 
-        template <typename LayerType, typename RenderSurfaceType, typename ActionType>
-        void end(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>&);
+        template <typename LayerType, typename LayerList, typename RenderSurfaceType, typename ActionType>
+        void end(CCLayerIterator<LayerType, LayerList, RenderSurfaceType, ActionType>&);
 
-        template <typename LayerType, typename RenderSurfaceType, typename ActionType>
-        void next(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>&);
+        template <typename LayerType, typename LayerList, typename RenderSurfaceType, typename ActionType>
+        void next(CCLayerIterator<LayerType, LayerList, RenderSurfaceType, ActionType>&);
 
     private:
-        template <typename LayerType, typename RenderSurfaceType, typename ActionType>
-        void goToHighestInSubtree(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>&);
+        template <typename LayerType, typename LayerList, typename RenderSurfaceType, typename ActionType>
+        void goToHighestInSubtree(CCLayerIterator<LayerType, LayerList, RenderSurfaceType, ActionType>&);
     };
 };
 
index 75285544717cfdb5a9a2cd3caf7dfd30cb271964..c434a1d951246355377276728209073ec49f00d1 100644 (file)
@@ -295,7 +295,7 @@ void CCLayerSorter::createGraphNodes(LayerList::iterator first, LayerList::itera
     float minZ = FLT_MAX;
     float maxZ = -FLT_MAX;
     for (LayerList::const_iterator it = first; it < last; it++) {
-        m_nodes.append(GraphNode(it->get()));
+        m_nodes.append(GraphNode(*it));
         GraphNode& node = m_nodes.at(m_nodes.size() - 1);
         CCRenderSurface* renderSurface = node.layer->renderSurface();
         if (!node.layer->drawsContent() && !renderSurface)
index 2c30d5dae4a0990f4c214e0eefd060374a71cb96..8ab9b75814e8cc6fa2ecbb1cbde8871d2130c97e 100644 (file)
@@ -39,7 +39,7 @@ class CCLayerSorter {
 public:
     CCLayerSorter();
 
-    typedef Vector<RefPtr<CCLayerImpl> > LayerList;
+    typedef Vector<CCLayerImpl*> LayerList;
 
     void sort(LayerList::iterator first, LayerList::iterator last);
 
index 67599ccc5e577ad521487fbcd3e460548c3a0e26..9ae0279b01f1e8171274de5979cf3e2c5682b29d 100644 (file)
@@ -169,13 +169,11 @@ void CCLayerTreeHost::finishCommitOnImplThread(CCLayerTreeHostImpl* hostImpl)
 {
     ASSERT(CCProxy::isImplThread());
 
-    // Synchronize trees, if one exists at all...
-    if (rootLayer()) {
-        hostImpl->setRootLayer(TreeSynchronizer::synchronizeTrees(rootLayer(), hostImpl->rootLayer()));
-        // We may have added an animation during the tree sync. This will cause hostImpl to visit its controllers.
+    hostImpl->setRootLayer(TreeSynchronizer::synchronizeTrees(rootLayer(), hostImpl->releaseRootLayer()));
+
+    // We may have added an animation during the tree sync. This will cause hostImpl to visit its controllers.
+    if (rootLayer())
         hostImpl->setNeedsAnimateLayers();
-    } else
-        hostImpl->setRootLayer(0);
 
     hostImpl->setSourceFrameNumber(frameNumber());
     hostImpl->setViewportSize(viewportSize());
@@ -337,16 +335,15 @@ void CCLayerTreeHost::didBecomeInvisibleOnImplThread(CCLayerTreeHostImpl* hostIm
     // If the frontbuffer is cached, then clobber the impl tree. Otherwise,
     // push over the tree changes.
     if (m_proxy->layerRendererCapabilities().contextHasCachedFrontBuffer) {
-        hostImpl->setRootLayer(0);
+        hostImpl->setRootLayer(nullptr);
         return;
     }
 
-    if (rootLayer()) {
-        hostImpl->setRootLayer(TreeSynchronizer::synchronizeTrees(rootLayer(), hostImpl->rootLayer()));
-        // We may have added an animation during the tree sync. This will cause hostImpl to visit its controllers.
+    hostImpl->setRootLayer(TreeSynchronizer::synchronizeTrees(rootLayer(), hostImpl->releaseRootLayer()));
+
+    // We may have added an animation during the tree sync. This will cause hostImpl to visit its controllers.
+    if (rootLayer())
         hostImpl->setNeedsAnimateLayers();
-    } else
-        hostImpl->setRootLayer(0);
 }
 
 void CCLayerTreeHost::startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, double durationSec)
@@ -440,7 +437,7 @@ void CCLayerTreeHost::updateLayers(LayerChromium* rootLayer)
 void CCLayerTreeHost::reserveTextures()
 {
     // Use BackToFront since it's cheap and this isn't order-dependent.
-    typedef CCLayerIterator<LayerChromium, RenderSurfaceChromium, CCLayerIteratorActions::BackToFront> CCLayerIteratorType;
+    typedef CCLayerIterator<LayerChromium, Vector<RefPtr<LayerChromium> >, RenderSurfaceChromium, CCLayerIteratorActions::BackToFront> CCLayerIteratorType;
 
     CCLayerIteratorType end = CCLayerIteratorType::end(&m_updateList);
     for (CCLayerIteratorType it = CCLayerIteratorType::begin(&m_updateList); it != end; ++it) {
@@ -532,7 +529,7 @@ static void leaveTargetRenderSurface(Vector<RenderSurfaceRegion>& stack, RenderS
 void CCLayerTreeHost::paintLayerContents(const LayerList& renderSurfaceLayerList, PaintType paintType)
 {
     // Use FrontToBack to allow for testing occlusion and performing culling during the tree walk.
-    typedef CCLayerIterator<LayerChromium, RenderSurfaceChromium, CCLayerIteratorActions::FrontToBack> CCLayerIteratorType;
+    typedef CCLayerIterator<LayerChromium, Vector<RefPtr<LayerChromium> >, RenderSurfaceChromium, CCLayerIteratorActions::FrontToBack> CCLayerIteratorType;
 
     // The stack holds occluded regions for subtrees in the RenderSurface-Layer tree, so that when we leave a subtree we may
     // apply a mask to it, but not to the parts outside the subtree.
@@ -569,7 +566,7 @@ void CCLayerTreeHost::paintLayerContents(const LayerList& renderSurfaceLayerList
 void CCLayerTreeHost::updateCompositorResources(GraphicsContext3D* context, CCTextureUpdater& updater)
 {
     // Use BackToFront since it's cheap and this isn't order-dependent.
-    typedef CCLayerIterator<LayerChromium, RenderSurfaceChromium, CCLayerIteratorActions::BackToFront> CCLayerIteratorType;
+    typedef CCLayerIterator<LayerChromium, Vector<RefPtr<LayerChromium> >, RenderSurfaceChromium, CCLayerIteratorActions::BackToFront> CCLayerIteratorType;
 
     CCLayerIteratorType end = CCLayerIteratorType::end(&m_updateList);
     for (CCLayerIteratorType it = CCLayerIteratorType::begin(&m_updateList); it != end; ++it) {
index 4fc86940096f97389e83ecc98debc14f2d24a26d..c86d74d861daf4e6e325d1c53fd47f49864f86a9 100644 (file)
@@ -149,11 +149,9 @@ static bool subtreeShouldRenderToSeparateSurface(LayerType* layer, bool axisAlig
 
 // Recursively walks the layer tree starting at the given node and computes all the
 // necessary transformations, clipRects, render surfaces, etc.
-template<typename LayerType, typename RenderSurfaceType, typename LayerSorter>
-static bool calculateDrawTransformsAndVisibilityInternal(LayerType* layer, LayerType* rootLayer, const TransformationMatrix& parentMatrix, const TransformationMatrix& fullHierarchyMatrix, RenderSurfaceType* nearestAncestorThatMovesPixels, Vector<RefPtr<LayerType> >& renderSurfaceLayerList, Vector<RefPtr<LayerType> >& layerList, LayerSorter* layerSorter, int maxTextureSize)
+template<typename LayerType, typename LayerList, typename RenderSurfaceType, typename LayerSorter>
+static bool calculateDrawTransformsAndVisibilityInternal(LayerType* layer, LayerType* rootLayer, const TransformationMatrix& parentMatrix, const TransformationMatrix& fullHierarchyMatrix, RenderSurfaceType* nearestAncestorThatMovesPixels, LayerList& renderSurfaceLayerList, LayerList& layerList, LayerSorter* layerSorter, int maxTextureSize)
 {
-    typedef Vector<RefPtr<LayerType> > LayerList;
-
     // This function computes the new matrix transformations recursively for this
     // layer and all its descendants. It also computes the appropriate render surfaces.
     // Some important points to remember:
@@ -390,7 +388,7 @@ static bool calculateDrawTransformsAndVisibilityInternal(LayerType* layer, Layer
 
     for (size_t i = 0; i < layer->children().size(); ++i) {
         LayerType* child = layer->children()[i].get();
-        bool drawsContent = calculateDrawTransformsAndVisibilityInternal<LayerType, RenderSurfaceType, LayerSorter>(child, rootLayer, sublayerMatrix, nextHierarchyMatrix, nearestAncestorThatMovesPixels, renderSurfaceLayerList, descendants, layerSorter, maxTextureSize);
+        bool drawsContent = calculateDrawTransformsAndVisibilityInternal<LayerType, LayerList, RenderSurfaceType, LayerSorter>(child, rootLayer, sublayerMatrix, nextHierarchyMatrix, nearestAncestorThatMovesPixels, renderSurfaceLayerList, descendants, layerSorter, maxTextureSize);
 
         if (drawsContent) {
             if (child->renderSurface()) {
@@ -495,11 +493,11 @@ static bool calculateDrawTransformsAndVisibilityInternal(LayerType* layer, Layer
 // FIXME: Instead of using the following function to set visibility rects on a second
 // tree pass, revise calculateVisibleLayerRect() so that this can be done in a single
 // pass inside calculateDrawTransformsAndVisibilityInternal<>().
-template<typename LayerType, typename RenderSurfaceType>
-static void walkLayersAndCalculateVisibleLayerRects(const Vector<RefPtr<LayerType> >& renderSurfaceLayerList)
+template<typename LayerType, typename LayerList, typename RenderSurfaceType>
+static void walkLayersAndCalculateVisibleLayerRects(const LayerList& renderSurfaceLayerList)
 {
     // Use BackToFront since it's cheap and this isn't order-dependent.
-    typedef CCLayerIterator<LayerType, RenderSurfaceType, CCLayerIteratorActions::BackToFront> CCLayerIteratorType;
+    typedef CCLayerIterator<LayerType, LayerList, RenderSurfaceType, CCLayerIteratorActions::BackToFront> CCLayerIteratorType;
 
     CCLayerIteratorType end = CCLayerIteratorType::end(&renderSurfaceLayerList);
     for (CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayerList); it != end; ++it) {
@@ -512,14 +510,14 @@ static void walkLayersAndCalculateVisibleLayerRects(const Vector<RefPtr<LayerTyp
 
 void CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(LayerChromium* layer, LayerChromium* rootLayer, const TransformationMatrix& parentMatrix, const TransformationMatrix& fullHierarchyMatrix, Vector<RefPtr<LayerChromium> >& renderSurfaceLayerList, Vector<RefPtr<LayerChromium> >& layerList, int maxTextureSize)
 {
-    WebCore::calculateDrawTransformsAndVisibilityInternal<LayerChromium, RenderSurfaceChromium, void*>(layer, rootLayer, parentMatrix, fullHierarchyMatrix, 0, renderSurfaceLayerList, layerList, 0, maxTextureSize);
-    walkLayersAndCalculateVisibleLayerRects<LayerChromium, RenderSurfaceChromium>(renderSurfaceLayerList);
+    WebCore::calculateDrawTransformsAndVisibilityInternal<LayerChromium, Vector<RefPtr<LayerChromium> >, RenderSurfaceChromium, void>(layer, rootLayer, parentMatrix, fullHierarchyMatrix, 0, renderSurfaceLayerList, layerList, 0, maxTextureSize);
+    walkLayersAndCalculateVisibleLayerRects<LayerChromium, Vector<RefPtr<LayerChromium> >, RenderSurfaceChromium>(renderSurfaceLayerList);
 }
 
-void CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(CCLayerImpl* layer, CCLayerImpl* rootLayer, const TransformationMatrix& parentMatrix, const TransformationMatrix& fullHierarchyMatrix, Vector<RefPtr<CCLayerImpl> >& renderSurfaceLayerList, Vector<RefPtr<CCLayerImpl> >& layerList, CCLayerSorter* layerSorter, int maxTextureSize)
+void CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(CCLayerImpl* layer, CCLayerImpl* rootLayer, const TransformationMatrix& parentMatrix, const TransformationMatrix& fullHierarchyMatrix, Vector<CCLayerImpl*>& renderSurfaceLayerList, Vector<CCLayerImpl*>& layerList, CCLayerSorter* layerSorter, int maxTextureSize)
 {
-    calculateDrawTransformsAndVisibilityInternal<CCLayerImpl, CCRenderSurface, CCLayerSorter>(layer, rootLayer, parentMatrix, fullHierarchyMatrix, 0, renderSurfaceLayerList, layerList, layerSorter, maxTextureSize);
-    walkLayersAndCalculateVisibleLayerRects<CCLayerImpl, CCRenderSurface>(renderSurfaceLayerList);
+    calculateDrawTransformsAndVisibilityInternal<CCLayerImpl, Vector<CCLayerImpl*>, CCRenderSurface, CCLayerSorter>(layer, rootLayer, parentMatrix, fullHierarchyMatrix, 0, renderSurfaceLayerList, layerList, layerSorter, maxTextureSize);
+    walkLayersAndCalculateVisibleLayerRects<CCLayerImpl, Vector<CCLayerImpl*>, CCRenderSurface>(renderSurfaceLayerList);
 }
 
 } // namespace WebCore
index 2e0cbcf2c585e8215d286dee9b61e535180cffad..df23cd01feab584e5bc8c67aa5642dfa237b608c 100644 (file)
@@ -43,7 +43,7 @@ public:
     template<typename LayerType> static IntRect calculateVisibleLayerRect(LayerType*);
 
     static void calculateDrawTransformsAndVisibility(LayerChromium*, LayerChromium* rootLayer, const TransformationMatrix& parentMatrix, const TransformationMatrix& fullHierarchyMatrix, Vector<RefPtr<LayerChromium> >& renderSurfaceLayerList, Vector<RefPtr<LayerChromium> >& layerList, int maxTextureSize);
-    static void calculateDrawTransformsAndVisibility(CCLayerImpl*, CCLayerImpl* rootLayer, const TransformationMatrix& parentMatrix, const TransformationMatrix& fullHierarchyMatrix, Vector<RefPtr<CCLayerImpl> >& renderSurfaceLayerList, Vector<RefPtr<CCLayerImpl> >& layerList, CCLayerSorter*, int maxTextureSize);
+    static void calculateDrawTransformsAndVisibility(CCLayerImpl*, CCLayerImpl* rootLayer, const TransformationMatrix& parentMatrix, const TransformationMatrix& fullHierarchyMatrix, Vector<CCLayerImpl*>& renderSurfaceLayerList, Vector<CCLayerImpl*>& layerList, CCLayerSorter*, int maxTextureSize);
 
     template<typename LayerType> static bool renderSurfaceContributesToTarget(LayerType*, int targetSurfaceLayerID);
 
index d30c68c3786211d85ad5bdc2c97db7163066dc97..e68b9e9802e0f887b8ba3b1d75bcdcb8f24fee92 100644 (file)
@@ -50,6 +50,7 @@ CCLayerTreeHostImpl::CCLayerTreeHostImpl(const CCSettings& settings, CCLayerTree
     : m_client(client)
     , m_sourceFrameNumber(-1)
     , m_frameNumber(0)
+    , m_scrollLayerImpl(0)
     , m_settings(settings)
     , m_visible(true)
     , m_pageScale(1)
@@ -134,7 +135,7 @@ void CCLayerTreeHostImpl::trackDamageForAllSurfaces(CCLayerImpl* rootDrawLayer,
     // damage rect. The root damage rect is then used to scissor each surface.
 
     for (int surfaceIndex = renderSurfaceLayerList.size() - 1; surfaceIndex >= 0 ; --surfaceIndex) {
-        CCLayerImpl* renderSurfaceLayer = renderSurfaceLayerList[surfaceIndex].get();
+        CCLayerImpl* renderSurfaceLayer = renderSurfaceLayerList[surfaceIndex];
         CCRenderSurface* renderSurface = renderSurfaceLayer->renderSurface();
         ASSERT(renderSurface);
         renderSurface->damageTracker()->updateDamageTrackingState(renderSurface->layerList(), renderSurfaceLayer->id(), renderSurfaceLayer->maskLayer());
@@ -198,7 +199,7 @@ void CCLayerTreeHostImpl::calculateRenderPasses(CCRenderPassList& passes, CCLaye
     m_rootDamageRect = rootLayer()->renderSurface()->damageTracker()->currentDamageRect();
 
     for (int surfaceIndex = renderSurfaceLayerList.size() - 1; surfaceIndex >= 0 ; --surfaceIndex) {
-        CCLayerImpl* renderSurfaceLayer = renderSurfaceLayerList[surfaceIndex].get();
+        CCLayerImpl* renderSurfaceLayer = renderSurfaceLayerList[surfaceIndex];
         CCRenderSurface* renderSurface = renderSurfaceLayer->renderSurface();
 
         OwnPtr<CCRenderPass> pass = CCRenderPass::create(renderSurface);
@@ -210,7 +211,7 @@ void CCLayerTreeHostImpl::calculateRenderPasses(CCRenderPassList& passes, CCLaye
 
         const CCLayerList& layerList = renderSurface->layerList();
         for (unsigned layerIndex = 0; layerIndex < layerList.size(); ++layerIndex) {
-            CCLayerImpl* layer = layerList[layerIndex].get();
+            CCLayerImpl* layer = layerList[layerIndex];
             if (layer->visibleLayerRect().isEmpty())
                 continue;
 
@@ -294,7 +295,7 @@ void CCLayerTreeHostImpl::drawLayers()
     for (size_t i = 0; i < passes.size(); ++i)
         m_layerRenderer->drawRenderPass(passes[i].get());
 
-    typedef CCLayerIterator<CCLayerImpl, CCRenderSurface, CCLayerIteratorActions::BackToFront> CCLayerIteratorType;
+    typedef CCLayerIterator<CCLayerImpl, Vector<CCLayerImpl*>, CCRenderSurface, CCLayerIteratorActions::BackToFront> CCLayerIteratorType;
 
     CCLayerIteratorType end = CCLayerIteratorType::end(&renderSurfaceLayerList);
     for (CCLayerIteratorType it = CCLayerIteratorType::begin(&renderSurfaceLayerList); it != end; ++it) {
@@ -363,7 +364,7 @@ static CCLayerImpl* findScrollLayer(CCLayerImpl* layer)
     return 0;
 }
 
-void CCLayerTreeHostImpl::setRootLayer(PassRefPtr<CCLayerImpl> layer)
+void CCLayerTreeHostImpl::setRootLayer(PassOwnPtr<CCLayerImpl> layer)
 {
     m_rootLayerImpl = layer;
 
index e438db0c4a3b31000ab9b2eb81016e33cc9ba190..f77e0eb842173f71cfa477774e95b33473912af1 100644 (file)
@@ -94,9 +94,10 @@ public:
     void readback(void* pixels, const IntRect&);
 
     CCLayerImpl* rootLayer() const { return m_rootLayerImpl.get(); }
-    void setRootLayer(PassRefPtr<CCLayerImpl>);
+    void setRootLayer(PassOwnPtr<CCLayerImpl>);
+    PassOwnPtr<CCLayerImpl> releaseRootLayer() { return m_rootLayerImpl.release(); }
 
-    CCLayerImpl* scrollLayer() const { return m_scrollLayerImpl.get(); }
+    CCLayerImpl* scrollLayer() const { return m_scrollLayerImpl; }
 
     bool visible() const { return m_visible; }
     void setVisible(bool);
@@ -136,7 +137,7 @@ protected:
     int m_frameNumber;
 
 private:
-    typedef Vector<RefPtr<CCLayerImpl> > CCLayerList;
+    typedef Vector<CCLayerImpl*> CCLayerList;
 
     void computeDoubleTapZoomDeltas(CCScrollAndScaleSet* scrollInfo);
     void computePinchZoomDeltas(CCScrollAndScaleSet* scrollInfo);
@@ -153,8 +154,8 @@ private:
     IntSize contentSize() const;
 
     OwnPtr<LayerRendererChromium> m_layerRenderer;
-    RefPtr<CCLayerImpl> m_rootLayerImpl;
-    RefPtr<CCLayerImpl> m_scrollLayerImpl;
+    OwnPtr<CCLayerImpl> m_rootLayerImpl;
+    CCLayerImpl* m_scrollLayerImpl;
     CCSettings m_settings;
     IntSize m_viewportSize;
     bool m_visible;
index 39a95951ddf3bc9f449754427229e5c593c287c7..9d9a4dd104e99238048cc3c56db11c838a0ccd0d 100644 (file)
@@ -35,9 +35,9 @@ namespace WebCore {
 
 class CCPluginLayerImpl : public CCLayerImpl {
 public:
-    static PassRefPtr<CCPluginLayerImpl> create(int id)
+    static PassOwnPtr<CCPluginLayerImpl> create(int id)
     {
-        return adoptRef(new CCPluginLayerImpl(id));
+        return adoptPtr(new CCPluginLayerImpl(id));
     }
     virtual ~CCPluginLayerImpl();
 
index 1bcec9260e6476b2cf0f639a874d915f068a7231..e5e683a5236ead5955a8b37df187de1eeff867d0 100644 (file)
@@ -95,7 +95,7 @@ public:
     bool skipsDraw() const { return m_skipsDraw; }
 
     void clearLayerList() { m_layerList.clear(); }
-    Vector<RefPtr<CCLayerImpl> >& layerList() { return m_layerList; }
+    Vector<CCLayerImpl*>& layerList() { return m_layerList; }
 
     void setMaskLayer(CCLayerImpl* maskLayer) { m_maskLayer = maskLayer; }
 
@@ -133,7 +133,7 @@ private:
     TransformationMatrix m_originTransform;
     FilterOperations m_filters;
     IntRect m_clipRect;
-    Vector<RefPtr<CCLayerImpl> > m_layerList;
+    Vector<CCLayerImpl*> m_layerList;
 
     // The nearest ancestor target surface that will contain the contents of this surface, and that is going
     // to move pixels within the surface (such as with a blur). This can point to itself.
index c7edc18b2c284c228a92157a6a97c19345b8fb7f..2e7441666f99f369819254a0c4570c7d66d6bcc7 100644 (file)
@@ -35,9 +35,9 @@ class LayerRendererChromium;
 
 class CCSolidColorLayerImpl : public CCLayerImpl {
 public:
-    static PassRefPtr<CCSolidColorLayerImpl> create(int id)
+    static PassOwnPtr<CCSolidColorLayerImpl> create(int id)
     {
-        return adoptRef(new CCSolidColorLayerImpl(id));
+        return adoptPtr(new CCSolidColorLayerImpl(id));
     }
     virtual ~CCSolidColorLayerImpl();
 
index 7ad71599b21365858a1c5a5f7a9cf4241ea068b0..7e637cffb4cc7bf7bdaaf9d609bd2a356149ff03 100644 (file)
@@ -37,9 +37,9 @@ class DrawableTile;
 
 class CCTiledLayerImpl : public CCLayerImpl {
 public:
-    static PassRefPtr<CCTiledLayerImpl> create(int id)
+    static PassOwnPtr<CCTiledLayerImpl> create(int id)
     {
-        return adoptRef(new CCTiledLayerImpl(id));
+        return adoptPtr(new CCTiledLayerImpl(id));
     }
     virtual ~CCTiledLayerImpl();
 
index caa72dfb9274fb08bb837a2eb8f929b165968a27..4c4e23102b8894a0622ecf0a44748f70a5fc6df4 100644 (file)
@@ -43,9 +43,9 @@ template<class VertexShader, class FragmentShader> class ProgramBinding;
 class CCVideoLayerImpl : public CCLayerImpl
                        , public VideoFrameProvider::Client {
 public:
-    static PassRefPtr<CCVideoLayerImpl> create(int id, VideoFrameProvider* provider)
+    static PassOwnPtr<CCVideoLayerImpl> create(int id, VideoFrameProvider* provider)
     {
-        return adoptRef(new CCVideoLayerImpl(id, provider));
+        return adoptPtr(new CCVideoLayerImpl(id, provider));
     }
     virtual ~CCVideoLayerImpl();
 
index 9400d1a6f5cdae2d94032b4adb7fa2c4cedfd34b..68b190625d2f0505cb0bedf19d0df19fa0a3243a 100644 (file)
@@ -1,3 +1,48 @@
+2012-02-24  Tien-Ren Chen  <trchen@chromium.org>
+
+        [chromium] Replace RefPtr with OwnPtr for CCLayerImpl tree structure
+        https://bugs.webkit.org/show_bug.cgi?id=78404
+
+        Reviewed by James Robinson.
+
+        * tests/CCDamageTrackerTest.cpp:
+        (WebKitTests::executeCalculateDrawTransformsAndVisibility):
+        (WebKitTests::emulateDrawingOneFrame):
+        (WebKitTests::createTestTreeWithOneSurface):
+        (WebKitTests::createTestTreeWithTwoSurfaces):
+        (WebKitTests::createAndSetUpTestTreeWithOneSurface):
+        (WebKitTests::createAndSetUpTestTreeWithTwoSurfaces):
+        (WebKitTests::TEST_F):
+        * tests/CCLayerImplTest.cpp:
+        (WebCore::TEST):
+        * tests/CCLayerIteratorTest.cpp:
+        * tests/CCLayerSorterTest.cpp:
+        (WebCore::TEST):
+        * tests/CCLayerTreeHostCommonTest.cpp:
+        (WebCore::TEST):
+        * tests/CCLayerTreeHostImplTest.cpp:
+        (WebKit::CCLayerTreeHostImplTest::setupScrollAndContentsLayers):
+        (WebKit::TEST_F):
+        (WebKit::DidDrawCheckLayer::create):
+        (WebKit::BlendStateCheckLayer::create):
+        * tests/CCRenderSurfaceTest.cpp:
+        (WebCore::TEST):
+        * tests/CCSolidColorLayerImplTest.cpp:
+        (CCLayerTestCommon::TEST):
+        * tests/CCTiledLayerImplTest.cpp:
+        (CCLayerTestCommon::createLayer):
+        (CCLayerTestCommon::TEST):
+        (CCLayerTestCommon::getQuads):
+        * tests/Canvas2DLayerChromiumTest.cpp:
+        (WebCore::Canvas2DLayerChromiumTest::fullLifecycleTest):
+        * tests/TiledLayerChromiumTest.cpp:
+        (WTF::TEST):
+        * tests/TreeSynchronizerTest.cpp:
+        (WebKitTests::MockCCLayerImpl::create):
+        (WebKitTests::MockLayerChromium::createCCLayerImpl):
+        (WebKitTests::expectTreesAreIdentical):
+        (WebKitTests::TEST):
+
 2012-02-08  James Robinson  <jamesr@chromium.org>
 
         [chromium] Make WebViewImpl depend on WebLayerTreeView instead of CCLayerTreeHost
index a9f7b1c1a1e89f1dbcf9f50334c05f3a133e038a..74d635b40d717530d76b9c82444bc6db2d7341b9 100644 (file)
@@ -39,11 +39,11 @@ using namespace WebKitTests;
 
 namespace {
 
-void executeCalculateDrawTransformsAndVisibility(CCLayerImpl* root, Vector<RefPtr<CCLayerImpl> >& renderSurfaceLayerList)
+void executeCalculateDrawTransformsAndVisibility(CCLayerImpl* root, Vector<CCLayerImpl*>& renderSurfaceLayerList)
 {
     CCLayerSorter layerSorter;
     TransformationMatrix identityMatrix;
-    Vector<RefPtr<CCLayerImpl> > dummyLayerList;
+    Vector<CCLayerImpl*> dummyLayerList;
     int dummyMaxTextureSize = 512;
 
     // Sanity check: The test itself should create the root layer's render surface, so
@@ -64,7 +64,7 @@ void emulateDrawingOneFrame(CCLayerImpl* root)
     //   2. updating all damage trackers in the correct order
     //   3. resetting all updateRects and propertyChanged flags for all layers and surfaces.
 
-    Vector<RefPtr<CCLayerImpl> > renderSurfaceLayerList;
+    Vector<CCLayerImpl*> renderSurfaceLayerList;
     executeCalculateDrawTransformsAndVisibility(root, renderSurfaceLayerList);
 
     // Iterate back-to-front, so that damage correctly propagates from descendant surfaces to ancestors.
@@ -76,10 +76,10 @@ void emulateDrawingOneFrame(CCLayerImpl* root)
     root->resetAllChangeTrackingForSubtree();
 }
 
-PassRefPtr<CCLayerImpl> createTestTreeWithOneSurface()
+PassOwnPtr<CCLayerImpl> createTestTreeWithOneSurface()
 {
-    RefPtr<CCLayerImpl> root = CCLayerImpl::create(1);
-    RefPtr<CCLayerImpl> child = CCLayerImpl::create(2);
+    OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
+    OwnPtr<CCLayerImpl> child = CCLayerImpl::create(2);
 
     root->setPosition(FloatPoint::zero());
     root->setAnchorPoint(FloatPoint::zero());
@@ -92,22 +92,22 @@ PassRefPtr<CCLayerImpl> createTestTreeWithOneSurface()
     child->setAnchorPoint(FloatPoint::zero());
     child->setBounds(IntSize(30, 30));
     child->setDrawsContent(true);
-    root->addChild(child);
+    root->addChild(child.release());
 
     return root.release();
 }
 
-PassRefPtr<CCLayerImpl> createTestTreeWithTwoSurfaces()
+PassOwnPtr<CCLayerImpl> createTestTreeWithTwoSurfaces()
 {
     // This test tree has two render surfaces: one for the root, and one for
     // child1. Additionally, the root has a second child layer, and child1 has two
     // children of its own.
 
-    RefPtr<CCLayerImpl> root = CCLayerImpl::create(1);
-    RefPtr<CCLayerImpl> child1 = CCLayerImpl::create(2);
-    RefPtr<CCLayerImpl> child2 = CCLayerImpl::create(3);
-    RefPtr<CCLayerImpl> grandChild1 = CCLayerImpl::create(4);
-    RefPtr<CCLayerImpl> grandChild2 = CCLayerImpl::create(5);
+    OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
+    OwnPtr<CCLayerImpl> child1 = CCLayerImpl::create(2);
+    OwnPtr<CCLayerImpl> child2 = CCLayerImpl::create(3);
+    OwnPtr<CCLayerImpl> grandChild1 = CCLayerImpl::create(4);
+    OwnPtr<CCLayerImpl> grandChild2 = CCLayerImpl::create(5);
 
     root->setPosition(FloatPoint::zero());
     root->setAnchorPoint(FloatPoint::zero());
@@ -137,17 +137,17 @@ PassRefPtr<CCLayerImpl> createTestTreeWithTwoSurfaces()
     grandChild2->setBounds(IntSize(6, 8));
     grandChild2->setDrawsContent(true);
 
-    child1->addChild(grandChild1);
-    child1->addChild(grandChild2);
-    root->addChild(child1);
-    root->addChild(child2);
+    child1->addChild(grandChild1.release());
+    child1->addChild(grandChild2.release());
+    root->addChild(child1.release());
+    root->addChild(child2.release());
 
     return root.release();
 }
 
-PassRefPtr<CCLayerImpl> createAndSetUpTestTreeWithOneSurface()
+PassOwnPtr<CCLayerImpl> createAndSetUpTestTreeWithOneSurface()
 {
-    RefPtr<CCLayerImpl> root = createTestTreeWithOneSurface();
+    OwnPtr<CCLayerImpl> root = createTestTreeWithOneSurface();
 
     // Setup includes going past the first frame which always damages everything, so
     // that we can actually perform specific tests.
@@ -156,9 +156,9 @@ PassRefPtr<CCLayerImpl> createAndSetUpTestTreeWithOneSurface()
     return root.release();
 }
 
-PassRefPtr<CCLayerImpl> createAndSetUpTestTreeWithTwoSurfaces()
+PassOwnPtr<CCLayerImpl> createAndSetUpTestTreeWithTwoSurfaces()
 {
-    RefPtr<CCLayerImpl> root = createTestTreeWithTwoSurfaces();
+    OwnPtr<CCLayerImpl> root = createTestTreeWithTwoSurfaces();
 
     // Setup includes going past the first frame which always damages everything, so
     // that we can actually perform specific tests.
@@ -178,7 +178,7 @@ TEST_F(CCDamageTrackerTest, sanityCheckTestTreeWithOneSurface)
     // Sanity check that the simple test tree will actually produce the expected render
     // surfaces and layer lists.
 
-    RefPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface();
+    OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface();
 
     EXPECT_EQ(static_cast<size_t>(2), root->renderSurface()->layerList().size());
     EXPECT_EQ(1, root->renderSurface()->layerList()[0]->id());
@@ -193,10 +193,10 @@ TEST_F(CCDamageTrackerTest, sanityCheckTestTreeWithTwoSurfaces)
     // Sanity check that the complex test tree will actually produce the expected render
     // surfaces and layer lists.
 
-    RefPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces();
+    OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces();
 
-    RefPtr<CCLayerImpl> child1 = root->children()[0];
-    RefPtr<CCLayerImpl> child2 = root->children()[1];
+    CCLayerImpl* child1 = root->children()[0].get();
+    CCLayerImpl* child2 = root->children()[1].get();
     FloatRect childDamageRect = child1->renderSurface()->damageTracker()->currentDamageRect();
     FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect();
 
@@ -212,8 +212,8 @@ TEST_F(CCDamageTrackerTest, sanityCheckTestTreeWithTwoSurfaces)
 
 TEST_F(CCDamageTrackerTest, verifyDamageForUpdateRects)
 {
-    RefPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface();
-    RefPtr<CCLayerImpl> child = root->children()[0];
+    OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface();
+    CCLayerImpl* child = root->children()[0].get();
 
     // CASE 1: Setting the update rect should cause the corresponding damage to the surface.
     //
@@ -243,8 +243,8 @@ TEST_F(CCDamageTrackerTest, verifyDamageForUpdateRects)
 
 TEST_F(CCDamageTrackerTest, verifyDamageForPropertyChanges)
 {
-    RefPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface();
-    RefPtr<CCLayerImpl> child = root->children()[0];
+    OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface();
+    CCLayerImpl* child = root->children()[0].get();
 
     // CASE 1: The layer's property changed flag takes priority over update rect.
     //
@@ -284,8 +284,8 @@ TEST_F(CCDamageTrackerTest, verifyDamageForTransformedLayer)
     // If a layer is transformed, the damage rect should still enclose the entire
     // transformed layer.
 
-    RefPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface();
-    RefPtr<CCLayerImpl> child = root->children()[0];
+    OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface();
+    CCLayerImpl* child = root->children()[0].get();
 
     TransformationMatrix rotation;
     rotation.rotate(45);
@@ -317,18 +317,20 @@ TEST_F(CCDamageTrackerTest, verifyDamageForTransformedLayer)
 
 TEST_F(CCDamageTrackerTest, verifyDamageForAddingAndRemovingLayer)
 {
-    RefPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface();
-    RefPtr<CCLayerImpl> child1 = root->children()[0];
-
-    RefPtr<CCLayerImpl> child2 = CCLayerImpl::create(3);
-    child2->setPosition(FloatPoint(400, 380));
-    child2->setAnchorPoint(FloatPoint::zero());
-    child2->setBounds(IntSize(6, 8));
-    child2->setDrawsContent(true);
+    OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface();
+    CCLayerImpl* child1 = root->children()[0].get();
+
+    {
+        OwnPtr<CCLayerImpl> child2 = CCLayerImpl::create(3);
+        child2->setPosition(FloatPoint(400, 380));
+        child2->setAnchorPoint(FloatPoint::zero());
+        child2->setBounds(IntSize(6, 8));
+        child2->setDrawsContent(true);
+        root->addChild(child2.release());
+    }
 
     // CASE 1: Adding a new layer should cause the appropriate damage.
     //
-    root->addChild(child2);
     emulateDrawingOneFrame(root.get());
 
     // Sanity check - all 3 layers should be on the same render surface; render surfaces are tested elsewhere.
@@ -353,15 +355,18 @@ TEST_F(CCDamageTrackerTest, verifyDamageForAddingAndRemovingLayer)
 
 TEST_F(CCDamageTrackerTest, verifyDamageForMultipleLayers)
 {
-    RefPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface();
-    RefPtr<CCLayerImpl> child1 = root->children()[0];
-
-    RefPtr<CCLayerImpl> child2 = CCLayerImpl::create(3);
-    child2->setPosition(FloatPoint(400, 380));
-    child2->setAnchorPoint(FloatPoint::zero());
-    child2->setBounds(IntSize(6, 8));
-    child2->setDrawsContent(true);
-    root->addChild(child2);
+    OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface();
+    CCLayerImpl* child1 = root->children()[0].get();
+
+    {
+        OwnPtr<CCLayerImpl> child2 = CCLayerImpl::create(3);
+        child2->setPosition(FloatPoint(400, 380));
+        child2->setAnchorPoint(FloatPoint::zero());
+        child2->setBounds(IntSize(6, 8));
+        child2->setDrawsContent(true);
+        root->addChild(child2.release());
+    }
+    CCLayerImpl* child2 = root->children()[1].get();
 
     // In this test we don't want the above tree manipulation to be considered part of the same frame.
     emulateDrawingOneFrame(root.get());
@@ -378,10 +383,10 @@ TEST_F(CCDamageTrackerTest, verifyDamageForMultipleLayers)
 
 TEST_F(CCDamageTrackerTest, verifyDamageForNestedSurfaces)
 {
-    RefPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces();
-    RefPtr<CCLayerImpl> child1 = root->children()[0];
-    RefPtr<CCLayerImpl> child2 = root->children()[1];
-    RefPtr<CCLayerImpl> grandChild1 = root->children()[0]->children()[0];
+    OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces();
+    CCLayerImpl* child1 = root->children()[0].get();
+    CCLayerImpl* child2 = root->children()[1].get();
+    CCLayerImpl* grandChild1 = root->children()[0]->children()[0].get();
     FloatRect childDamageRect;
     FloatRect rootDamageRect;
 
@@ -415,9 +420,9 @@ TEST_F(CCDamageTrackerTest, verifyDamageForSurfaceChangeFromDescendantLayer)
     // This is a tricky case, since only the first grandChild changes, but the entire
     // surface should be marked dirty.
 
-    RefPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces();
-    RefPtr<CCLayerImpl> child1 = root->children()[0];
-    RefPtr<CCLayerImpl> grandChild1 = root->children()[0]->children()[0];
+    OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces();
+    CCLayerImpl* child1 = root->children()[0].get();
+    CCLayerImpl* grandChild1 = root->children()[0]->children()[0].get();
     FloatRect childDamageRect;
     FloatRect rootDamageRect;
 
@@ -447,9 +452,8 @@ TEST_F(CCDamageTrackerTest, verifyDamageForSurfaceChangeFromAncestorLayer)
     //        should be completely unchanged, since we are only transforming it, while the
     //        root surface would be damaged appropriately.
 
-    RefPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces();
-    RefPtr<CCLayerImpl> child1 = root->children()[0];
-    RefPtr<CCLayerImpl> grandChild1 = root->children()[0]->children()[0];
+    OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces();
+    CCLayerImpl* child1 = root->children()[0].get();
     FloatRect childDamageRect;
     FloatRect rootDamageRect;
 
@@ -469,8 +473,8 @@ TEST_F(CCDamageTrackerTest, verifyDamageForSurfaceChangeFromAncestorLayer)
 
 TEST_F(CCDamageTrackerTest, verifyDamageForAddingAndRemovingRenderSurfaces)
 {
-    RefPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces();
-    RefPtr<CCLayerImpl> child1 = root->children()[0];
+    OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces();
+    CCLayerImpl* child1 = root->children()[0].get();
     FloatRect childDamageRect;
     FloatRect rootDamageRect;
 
@@ -510,8 +514,8 @@ TEST_F(CCDamageTrackerTest, verifyDamageForAddingAndRemovingRenderSurfaces)
 
 TEST_F(CCDamageTrackerTest, verifyNoDamageWhenNothingChanged)
 {
-    RefPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces();
-    RefPtr<CCLayerImpl> child1 = root->children()[0];
+    OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces();
+    CCLayerImpl* child1 = root->children()[0].get();
     FloatRect childDamageRect;
     FloatRect rootDamageRect;
 
@@ -534,8 +538,8 @@ TEST_F(CCDamageTrackerTest, verifyNoDamageWhenNothingChanged)
 
 TEST_F(CCDamageTrackerTest, verifyNoDamageForUpdateRectThatDoesNotDrawContent)
 {
-    RefPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces();
-    RefPtr<CCLayerImpl> child1 = root->children()[0];
+    OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces();
+    CCLayerImpl* child1 = root->children()[0].get();
     FloatRect childDamageRect;
     FloatRect rootDamageRect;
 
@@ -551,10 +555,10 @@ TEST_F(CCDamageTrackerTest, verifyNoDamageForUpdateRectThatDoesNotDrawContent)
 
 TEST_F(CCDamageTrackerTest, verifyDamageForReplica)
 {
-    RefPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces();
-    RefPtr<CCLayerImpl> child1 = root->children()[0];
-    RefPtr<CCLayerImpl> grandChild1 = child1->children()[0];
-    RefPtr<CCLayerImpl> grandChild2 = child1->children()[1];
+    OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces();
+    CCLayerImpl* child1 = root->children()[0].get();
+    CCLayerImpl* grandChild1 = child1->children()[0].get();
+    CCLayerImpl* grandChild2 = child1->children()[1].get();
 
     // Damage on a surface that has a reflection should cause the target surface to
     // receive the surface's damage and the surface's reflected damage.
@@ -563,24 +567,28 @@ TEST_F(CCDamageTrackerTest, verifyDamageForReplica)
     // of child1's surface. This way, we can test reflection changes without changing
     // contentBounds of the surface.
     grandChild2->setPosition(FloatPoint(180, 180));
-    RefPtr<CCLayerImpl> grandChild3 = CCLayerImpl::create(6);
-    grandChild3->setPosition(FloatPoint(240, 240));
-    grandChild3->setAnchorPoint(FloatPoint::zero());
-    grandChild3->setBounds(IntSize(10, 10));
-    grandChild3->setDrawsContent(true);
+    {
+        OwnPtr<CCLayerImpl> grandChild3 = CCLayerImpl::create(6);
+        grandChild3->setPosition(FloatPoint(240, 240));
+        grandChild3->setAnchorPoint(FloatPoint::zero());
+        grandChild3->setBounds(IntSize(10, 10));
+        grandChild3->setDrawsContent(true);
+        child1->addChild(grandChild3.release());
+    }
     child1->setOpacity(0.5);
-    child1->addChild(grandChild3);
     emulateDrawingOneFrame(root.get());
 
     // CASE 1: adding a reflection about the left edge of grandChild1.
     //
-    RefPtr<CCLayerImpl> grandChild1Replica = CCLayerImpl::create(7);
-    grandChild1Replica->setPosition(FloatPoint::zero());
-    grandChild1Replica->setAnchorPoint(FloatPoint::zero());
-    TransformationMatrix reflection;
-    reflection.scale3d(-1.0, 1.0, 1.0);
-    grandChild1Replica->setTransform(reflection);
-    grandChild1->setReplicaLayer(grandChild1Replica);
+    {
+        OwnPtr<CCLayerImpl> grandChild1Replica = CCLayerImpl::create(7);
+        grandChild1Replica->setPosition(FloatPoint::zero());
+        grandChild1Replica->setAnchorPoint(FloatPoint::zero());
+        TransformationMatrix reflection;
+        reflection.scale3d(-1.0, 1.0, 1.0);
+        grandChild1Replica->setTransform(reflection);
+        grandChild1->setReplicaLayer(grandChild1Replica.release());
+    }
     emulateDrawingOneFrame(root.get());
 
     FloatRect grandChildDamageRect = grandChild1->renderSurface()->damageTracker()->currentDamageRect();
@@ -614,7 +622,7 @@ TEST_F(CCDamageTrackerTest, verifyDamageForReplica)
 
     // CASE 3: removing the reflection should cause the entire region including reflection
     //         to damage the target surface.
-    grandChild1->setReplicaLayer(0);
+    grandChild1->setReplicaLayer(nullptr);
     emulateDrawingOneFrame(root.get());
     ASSERT_EQ(oldContentRect.width(), child1->renderSurface()->contentRect().width());
     ASSERT_EQ(oldContentRect.height(), child1->renderSurface()->contentRect().height());
@@ -629,27 +637,32 @@ TEST_F(CCDamageTrackerTest, verifyDamageForReplica)
 
 TEST_F(CCDamageTrackerTest, verifyDamageForMask)
 {
-    RefPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface();
-    RefPtr<CCLayerImpl> child = root->children()[0];
+    OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface();
+    CCLayerImpl* child = root->children()[0].get();
 
     // In the current implementation of the damage tracker, changes to mask layers should
     // damage the entire corresponding surface.
 
     // Set up the mask layer.
-    RefPtr<CCLayerImpl> maskLayer = CCLayerImpl::create(3);
-    maskLayer->setPosition(child->position());
-    maskLayer->setAnchorPoint(FloatPoint::zero());
-    maskLayer->setBounds(child->bounds());
-    child->setMaskLayer(maskLayer);
+    {
+        OwnPtr<CCLayerImpl> maskLayer = CCLayerImpl::create(3);
+        maskLayer->setPosition(child->position());
+        maskLayer->setAnchorPoint(FloatPoint::zero());
+        maskLayer->setBounds(child->bounds());
+        child->setMaskLayer(maskLayer.release());
+    }
+    CCLayerImpl* maskLayer = child->maskLayer();
 
     // Add opacity and a grandChild so that the render surface persists even after we remove the mask.
     child->setOpacity(0.5);
-    RefPtr<CCLayerImpl> grandChild = CCLayerImpl::create(4);
-    grandChild->setPosition(FloatPoint(2.0, 2.0));
-    grandChild->setAnchorPoint(FloatPoint::zero());
-    grandChild->setBounds(IntSize(2, 2));
-    grandChild->setDrawsContent(true);
-    child->addChild(grandChild);
+    {
+        OwnPtr<CCLayerImpl> grandChild = CCLayerImpl::create(4);
+        grandChild->setPosition(FloatPoint(2.0, 2.0));
+        grandChild->setAnchorPoint(FloatPoint::zero());
+        grandChild->setBounds(IntSize(2, 2));
+        grandChild->setDrawsContent(true);
+        child->addChild(grandChild.release());
+    }
     emulateDrawingOneFrame(root.get());
 
     // Sanity check that a new surface was created for the child.
@@ -685,7 +698,7 @@ TEST_F(CCDamageTrackerTest, verifyDamageForMask)
     EXPECT_TRUE(childDamageRect.isEmpty());
 
     // Then test mask removal.
-    child->setMaskLayer(0);
+    child->setMaskLayer(nullptr);
     ASSERT_TRUE(child->layerPropertyChanged());
     emulateDrawingOneFrame(root.get());
 
@@ -698,28 +711,34 @@ TEST_F(CCDamageTrackerTest, verifyDamageForMask)
 
 TEST_F(CCDamageTrackerTest, verifyDamageForReplicaMask)
 {
-    RefPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces();
-    RefPtr<CCLayerImpl> child1 = root->children()[0];
-    RefPtr<CCLayerImpl> grandChild1 = child1->children()[0];
+    OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces();
+    CCLayerImpl* child1 = root->children()[0].get();
+    CCLayerImpl* grandChild1 = child1->children()[0].get();
 
     // Changes to a replica's mask should not damage the original surface, because it is
     // not masked. But it does damage the ancestor target surface.
 
     // Create a reflection about the left edge of grandChild1.
-    RefPtr<CCLayerImpl> grandChild1Replica = CCLayerImpl::create(6);
-    grandChild1Replica->setPosition(FloatPoint::zero());
-    grandChild1Replica->setAnchorPoint(FloatPoint::zero());
-    TransformationMatrix reflection;
-    reflection.scale3d(-1.0, 1.0, 1.0);
-    grandChild1Replica->setTransform(reflection);
-    grandChild1->setReplicaLayer(grandChild1Replica);
+    {
+        OwnPtr<CCLayerImpl> grandChild1Replica = CCLayerImpl::create(6);
+        grandChild1Replica->setPosition(FloatPoint::zero());
+        grandChild1Replica->setAnchorPoint(FloatPoint::zero());
+        TransformationMatrix reflection;
+        reflection.scale3d(-1.0, 1.0, 1.0);
+        grandChild1Replica->setTransform(reflection);
+        grandChild1->setReplicaLayer(grandChild1Replica.release());
+    }
+    CCLayerImpl* grandChild1Replica = grandChild1->replicaLayer();
 
     // Set up the mask layer on the replica layer
-    RefPtr<CCLayerImpl> replicaMaskLayer = CCLayerImpl::create(7);
-    replicaMaskLayer->setPosition(FloatPoint::zero());
-    replicaMaskLayer->setAnchorPoint(FloatPoint::zero());
-    replicaMaskLayer->setBounds(grandChild1->bounds());
-    grandChild1Replica->setMaskLayer(replicaMaskLayer);
+    {
+        OwnPtr<CCLayerImpl> replicaMaskLayer = CCLayerImpl::create(7);
+        replicaMaskLayer->setPosition(FloatPoint::zero());
+        replicaMaskLayer->setAnchorPoint(FloatPoint::zero());
+        replicaMaskLayer->setBounds(grandChild1->bounds());
+        grandChild1Replica->setMaskLayer(replicaMaskLayer.release());
+    }
+    CCLayerImpl* replicaMaskLayer = grandChild1Replica->maskLayer();
 
     emulateDrawingOneFrame(root.get());
 
@@ -738,7 +757,7 @@ TEST_F(CCDamageTrackerTest, verifyDamageForReplicaMask)
 
     // CASE 2: removing the replica mask damages only the reflected region on the target surface.
     //
-    grandChild1Replica->setMaskLayer(0);
+    grandChild1Replica->setMaskLayer(nullptr);
     emulateDrawingOneFrame(root.get());
 
     grandChildDamageRect = grandChild1->renderSurface()->damageTracker()->currentDamageRect();
@@ -750,8 +769,8 @@ TEST_F(CCDamageTrackerTest, verifyDamageForReplicaMask)
 
 TEST_F(CCDamageTrackerTest, verifyDamageWhenReset)
 {
-    RefPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface();
-    RefPtr<CCLayerImpl> child = root->children()[0];
+    OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface();
+    CCLayerImpl* child = root->children()[0].get();
 
     // Case 1: This test ensures that when the tracker is forced to have full damage, that
     //         it takes priority over any other partial damage.
index 16a25e12e979dd6012c5681a9de4a4d86d1643db..8a9f35dc8a7b89c0c94bd7537c68464fa78a6bb8 100644 (file)
@@ -65,14 +65,11 @@ TEST(CCLayerImplTest, verifyLayerChangesAreTrackedProperly)
     DebugScopedSetImplThread setImplThread;
 
     // Create a simple CCLayerImpl tree:
-    RefPtr<CCLayerImpl> root = CCLayerImpl::create(1);
-    RefPtr<CCLayerImpl> child = CCLayerImpl::create(2);
-    RefPtr<CCLayerImpl> grandChild = CCLayerImpl::create(3);
-    root->addChild(child);
-    child->addChild(grandChild);
-
-    RefPtr<CCLayerImpl> dummyMask = CCLayerImpl::create(4);
-    RefPtr<CCLayerImpl> dummyReplica = CCLayerImpl::create(5);
+    OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
+    root->addChild(CCLayerImpl::create(2));
+    CCLayerImpl* child = root->children()[0].get();
+    child->addChild(CCLayerImpl::create(3));
+    CCLayerImpl* grandChild = child->children()[0].get();
 
     // Adding children is an internal operation and should not mark layers as changed.
     EXPECT_FALSE(root->layerPropertyChanged());
@@ -95,11 +92,11 @@ TEST(CCLayerImplTest, verifyLayerChangesAreTrackedProperly)
     EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setAnchorPoint(arbitraryFloatPoint));
     EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setAnchorPointZ(arbitraryNumber));
     EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setFilters(arbitraryFilters));
-    EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setMaskLayer(dummyMask));
+    EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setMaskLayer(CCLayerImpl::create(4)));
     EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setMasksToBounds(true));
     EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setOpaque(true));
     EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setOpacity(arbitraryNumber));
-    EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setReplicaLayer(dummyReplica));
+    EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setReplicaLayer(CCLayerImpl::create(5)));
     EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setPosition(arbitraryFloatPoint));
     EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setPreserves3D(true));
     EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setTransform(arbitraryTransform));
@@ -134,9 +131,7 @@ TEST(CCLayerImplTest, verifyLayerChangesAreTrackedProperly)
     // not cause any change.
     EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setAnchorPoint(arbitraryFloatPoint));
     EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setAnchorPointZ(arbitraryNumber));
-    EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setMaskLayer(dummyMask));
     EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setMasksToBounds(true));
-    EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setReplicaLayer(dummyReplica));
     EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setPosition(arbitraryFloatPoint));
     EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setPreserves3D(true));
     EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setTransform(arbitraryTransform));
index bff7e1ba97114568cabe396cfae7746f0734098e..2f5a7a25d9ed16f2cc41981cbc4a2e6565287108 100644 (file)
@@ -67,8 +67,8 @@ private:
     EXPECT_EQ(contrib, layer->m_countRepresentingContributingSurface);   \
     EXPECT_EQ(itself, layer->m_countRepresentingItself);
 
-typedef CCLayerIterator<LayerChromium, RenderSurfaceChromium, CCLayerIteratorActions::FrontToBack> FrontToBack;
-typedef CCLayerIterator<LayerChromium, RenderSurfaceChromium, CCLayerIteratorActions::BackToFront> BackToFront;
+typedef CCLayerIterator<LayerChromium, Vector<RefPtr<LayerChromium> >, RenderSurfaceChromium, CCLayerIteratorActions::FrontToBack> FrontToBack;
+typedef CCLayerIterator<LayerChromium, Vector<RefPtr<LayerChromium> >, RenderSurfaceChromium, CCLayerIteratorActions::BackToFront> BackToFront;
 
 void resetCounts(Vector<RefPtr<LayerChromium> >& renderSurfaceLayerList)
 {
@@ -137,7 +137,7 @@ TEST(CCLayerIteratorTest, simpleTree)
 
     Vector<RefPtr<LayerChromium> > renderSurfaceLayerList;
     Vector<RefPtr<LayerChromium> > layerList;
-    renderSurfaceLayerList.append(rootLayer);
+    renderSurfaceLayerList.append(rootLayer.get());
     CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(rootLayer.get(), rootLayer.get(),
                                                                 TransformationMatrix(), TransformationMatrix(),
                                                                 renderSurfaceLayerList, layerList,
@@ -184,7 +184,7 @@ TEST(CCLayerIteratorTest, complexTree)
 
     Vector<RefPtr<LayerChromium> > renderSurfaceLayerList;
     Vector<RefPtr<LayerChromium> > layerList;
-    renderSurfaceLayerList.append(rootLayer);
+    renderSurfaceLayerList.append(rootLayer.get());
     CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(rootLayer.get(), rootLayer.get(),
                                                                 TransformationMatrix(), TransformationMatrix(),
                                                                 renderSurfaceLayerList, layerList,
@@ -243,7 +243,7 @@ TEST(CCLayerIteratorTest, complexTreeMultiSurface)
 
     Vector<RefPtr<LayerChromium> > renderSurfaceLayerList;
     Vector<RefPtr<LayerChromium> > layerList;
-    renderSurfaceLayerList.append(rootLayer);
+    renderSurfaceLayerList.append(rootLayer.get());
     CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(rootLayer.get(), rootLayer.get(),
                                                                 TransformationMatrix(), TransformationMatrix(),
                                                                 renderSurfaceLayerList, layerList,
index 69342cda7c63b615450745eabd8b1d1cdbefce5e..a533c937388eea56b7a4a1bc61c1f2821abfecbf 100644 (file)
@@ -174,11 +174,11 @@ TEST(CCLayerSorterTest, verifyExistingOrderingPreservedWhenNoZDiff)
     //    - 3 and 4 do not have a 3d z difference, and therefore their relative ordering should be retained.
     //    - 3 and 4 should be re-sorted so they are in front of 1, 2, and 5.
 
-    RefPtr<CCLayerImpl> layer1 = CCLayerImpl::create(1);
-    RefPtr<CCLayerImpl> layer2 = CCLayerImpl::create(2);
-    RefPtr<CCLayerImpl> layer3 = CCLayerImpl::create(3);
-    RefPtr<CCLayerImpl> layer4 = CCLayerImpl::create(4);
-    RefPtr<CCLayerImpl> layer5 = CCLayerImpl::create(5);
+    OwnPtr<CCLayerImpl> layer1 = CCLayerImpl::create(1);
+    OwnPtr<CCLayerImpl> layer2 = CCLayerImpl::create(2);
+    OwnPtr<CCLayerImpl> layer3 = CCLayerImpl::create(3);
+    OwnPtr<CCLayerImpl> layer4 = CCLayerImpl::create(4);
+    OwnPtr<CCLayerImpl> layer5 = CCLayerImpl::create(5);
 
     TransformationMatrix BehindMatrix;
     BehindMatrix.translate3d(0, 0, 2);
@@ -205,12 +205,12 @@ TEST(CCLayerSorterTest, verifyExistingOrderingPreservedWhenNoZDiff)
     layer5->setDrawTransform(BehindMatrix);
     layer5->setDrawsContent(true);
 
-    Vector<RefPtr<CCLayerImpl> > layerList;
-    layerList.append(layer1);
-    layerList.append(layer2);
-    layerList.append(layer3);
-    layerList.append(layer4);
-    layerList.append(layer5);
+    Vector<CCLayerImpl*> layerList;
+    layerList.append(layer1.get());
+    layerList.append(layer2.get());
+    layerList.append(layer3.get());
+    layerList.append(layer4.get());
+    layerList.append(layer5.get());
 
     ASSERT_EQ(static_cast<size_t>(5), layerList.size());
     EXPECT_EQ(1, layerList[0]->id());
index d2e1cfef93e282166da851256c95c0e6512c69ba..e6206cc58f9033b5ffcaa69eeb4d290f351ed3f3 100644 (file)
@@ -573,7 +573,7 @@ TEST(CCLayerTreeHostCommonTest, verifyClipRectCullsRenderSurfaces)
 
     // FIXME: when we fix this "root-layer special case" behavior in CCLayerTreeHost, we will have to fix it here, too.
     parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds()));
-    renderSurfaceLayerList.append(parent);
+    renderSurfaceLayerList.append(parent.get());
 
     CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize);
 
index 5e82bfb42f9230a883c8af247ec3acd67f438116..2630b8c82c785ddf0ae35160de520ee4bc7b249b 100644 (file)
@@ -78,16 +78,16 @@ public:
 
     void setupScrollAndContentsLayers(const IntSize& contentSize)
     {
-        RefPtr<CCLayerImpl> root = CCLayerImpl::create(0);
+        OwnPtr<CCLayerImpl> root = CCLayerImpl::create(0);
         root->setScrollable(true);
         root->setScrollPosition(IntPoint(0, 0));
         root->setMaxScrollPosition(contentSize);
-        RefPtr<CCLayerImpl> contents = CCLayerImpl::create(1);
+        OwnPtr<CCLayerImpl> contents = CCLayerImpl::create(1);
         contents->setDrawsContent(true);
         contents->setBounds(contentSize);
         contents->setContentBounds(contentSize);
-        root->addChild(contents);
-        m_hostImpl->setRootLayer(root);
+        root->addChild(contents.release());
+        m_hostImpl->setRootLayer(root.release());
     }
 
 protected:
@@ -112,37 +112,43 @@ TEST_F(CCLayerTreeHostImplTest, scrollDeltaNoLayers)
 
 TEST_F(CCLayerTreeHostImplTest, scrollDeltaTreeButNoChanges)
 {
-    RefPtr<CCLayerImpl> root = CCLayerImpl::create(0);
-    root->addChild(CCLayerImpl::create(1));
-    root->addChild(CCLayerImpl::create(2));
-    root->children()[1]->addChild(CCLayerImpl::create(3));
-    root->children()[1]->addChild(CCLayerImpl::create(4));
-    root->children()[1]->children()[0]->addChild(CCLayerImpl::create(5));
-    m_hostImpl->setRootLayer(root);
+    {
+        OwnPtr<CCLayerImpl> root = CCLayerImpl::create(0);
+        root->addChild(CCLayerImpl::create(1));
+        root->addChild(CCLayerImpl::create(2));
+        root->children()[1]->addChild(CCLayerImpl::create(3));
+        root->children()[1]->addChild(CCLayerImpl::create(4));
+        root->children()[1]->children()[0]->addChild(CCLayerImpl::create(5));
+        m_hostImpl->setRootLayer(root.release());
+    }
+    CCLayerImpl* root = m_hostImpl->rootLayer();
 
-    expectClearedScrollDeltasRecursive(root.get());
+    expectClearedScrollDeltasRecursive(root);
 
     OwnPtr<CCScrollAndScaleSet> scrollInfo;
 
     scrollInfo = m_hostImpl->processScrollDeltas();
     ASSERT_EQ(scrollInfo->scrolls.size(), 0u);
-    expectClearedScrollDeltasRecursive(root.get());
+    expectClearedScrollDeltasRecursive(root);
 
     scrollInfo = m_hostImpl->processScrollDeltas();
     ASSERT_EQ(scrollInfo->scrolls.size(), 0u);
-    expectClearedScrollDeltasRecursive(root.get());
+    expectClearedScrollDeltasRecursive(root);
 }
 
 TEST_F(CCLayerTreeHostImplTest, scrollDeltaRepeatedScrolls)
 {
     IntPoint scrollPosition(20, 30);
     IntSize scrollDelta(11, -15);
-    RefPtr<CCLayerImpl> root = CCLayerImpl::create(10);
-    root->setScrollPosition(scrollPosition);
-    root->setScrollable(true);
-    root->setMaxScrollPosition(IntSize(100, 100));
-    root->scrollBy(scrollDelta);
-    m_hostImpl->setRootLayer(root);
+    {
+        OwnPtr<CCLayerImpl> root = CCLayerImpl::create(10);
+        root->setScrollPosition(scrollPosition);
+        root->setScrollable(true);
+        root->setMaxScrollPosition(IntSize(100, 100));
+        root->scrollBy(scrollDelta);
+        m_hostImpl->setRootLayer(root.release());
+    }
+    CCLayerImpl* root = m_hostImpl->rootLayer();
 
     OwnPtr<CCScrollAndScaleSet> scrollInfo;
 
@@ -165,11 +171,14 @@ TEST_F(CCLayerTreeHostImplTest, scrollDeltaRepeatedScrolls)
 
 TEST_F(CCLayerTreeHostImplTest, scrollRootCallsCommitAndRedraw)
 {
-    RefPtr<CCLayerImpl> root = CCLayerImpl::create(0);
-    root->setScrollable(true);
-    root->setScrollPosition(IntPoint(0, 0));
-    root->setMaxScrollPosition(IntSize(100, 100));
-    m_hostImpl->setRootLayer(root);
+    {
+        OwnPtr<CCLayerImpl> root = CCLayerImpl::create(0);
+        root->setScrollable(true);
+        root->setScrollPosition(IntPoint(0, 0));
+        root->setMaxScrollPosition(IntSize(100, 100));
+        m_hostImpl->setRootLayer(root.release());
+    }
+
     EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Wheel), CCInputHandlerClient::ScrollStarted);
     m_hostImpl->scrollBy(IntSize(0, 10));
     m_hostImpl->scrollEnd();
@@ -179,11 +188,15 @@ TEST_F(CCLayerTreeHostImplTest, scrollRootCallsCommitAndRedraw)
 
 TEST_F(CCLayerTreeHostImplTest, wheelEventHandlers)
 {
-    RefPtr<CCLayerImpl> root = CCLayerImpl::create(0);
-    root->setScrollable(true);
-    root->setScrollPosition(IntPoint(0, 0));
-    root->setMaxScrollPosition(IntSize(100, 100));
-    m_hostImpl->setRootLayer(root);
+    {
+        OwnPtr<CCLayerImpl> root = CCLayerImpl::create(0);
+        root->setScrollable(true);
+        root->setScrollPosition(IntPoint(0, 0));
+        root->setMaxScrollPosition(IntSize(100, 100));
+        m_hostImpl->setRootLayer(root.release());
+    }
+    CCLayerImpl* root = m_hostImpl->rootLayer();
+
     root->setHaveWheelEventHandlers(true);
     // With registered event handlers, wheel scrolls have to go to the main thread.
     EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Wheel), CCInputHandlerClient::ScrollFailed);
@@ -321,7 +334,7 @@ TEST_F(CCLayerTreeHostImplTest, pageScaleAnimation)
 
 class DidDrawCheckLayer : public CCLayerImpl {
 public:
-    static PassRefPtr<DidDrawCheckLayer> create(int id) { return adoptRef(new DidDrawCheckLayer(id)); }
+    static PassOwnPtr<DidDrawCheckLayer> create(int id) { return adoptPtr(new DidDrawCheckLayer(id)); }
 
     virtual void didDraw()
     {
@@ -359,8 +372,8 @@ TEST_F(CCLayerTreeHostImplTest, didDrawNotCalledOnHiddenLayer)
     // Ensure visibleLayerRect for root layer is empty
     m_hostImpl->setViewportSize(IntSize(0, 0));
 
-    RefPtr<DidDrawCheckLayer> root = DidDrawCheckLayer::create(0);
-    m_hostImpl->setRootLayer(root);
+    m_hostImpl->setRootLayer(DidDrawCheckLayer::create(0));
+    DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer());
 
     EXPECT_FALSE(root->willDrawCalled());
     EXPECT_FALSE(root->didDrawCalled());
@@ -392,14 +405,14 @@ TEST_F(CCLayerTreeHostImplTest, didDrawCalledOnAllLayers)
     m_hostImpl->initializeLayerRenderer(context);
     m_hostImpl->setViewportSize(IntSize(10, 10));
 
-    RefPtr<DidDrawCheckLayer> root = DidDrawCheckLayer::create(0);
-    m_hostImpl->setRootLayer(root);
+    m_hostImpl->setRootLayer(DidDrawCheckLayer::create(0));
+    DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer());
 
-    RefPtr<DidDrawCheckLayer> layer1 = DidDrawCheckLayer::create(1);
-    root->addChild(layer1);
+    root->addChild(DidDrawCheckLayer::create(1));
+    DidDrawCheckLayer* layer1 = static_cast<DidDrawCheckLayer*>(root->children()[0].get());
 
-    RefPtr<DidDrawCheckLayer> layer2 = DidDrawCheckLayer::create(2);
-    layer1->addChild(layer2);
+    layer1->addChild(DidDrawCheckLayer::create(2));
+    DidDrawCheckLayer* layer2 = static_cast<DidDrawCheckLayer*>(layer1->children()[0].get());
 
     layer1->setOpacity(0.3);
     layer1->setPreserves3D(false);
@@ -442,7 +455,7 @@ private:
 
 class BlendStateCheckLayer : public CCLayerImpl {
 public:
-    static PassRefPtr<BlendStateCheckLayer> create(int id) { return adoptRef(new BlendStateCheckLayer(id)); }
+    static PassOwnPtr<BlendStateCheckLayer> create(int id) { return adoptPtr(new BlendStateCheckLayer(id)); }
 
     virtual void appendQuads(CCQuadList& quadList, const CCSharedQuadState* sharedQuadState)
     {
@@ -491,14 +504,17 @@ TEST_F(CCLayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers)
     m_hostImpl->initializeLayerRenderer(context);
     m_hostImpl->setViewportSize(IntSize(10, 10));
 
-    RefPtr<CCLayerImpl> root = CCLayerImpl::create(0);
-    root->setAnchorPoint(FloatPoint(0, 0));
-    root->setBounds(IntSize(10, 10));
-    root->setDrawsContent(false);
-    m_hostImpl->setRootLayer(root);
+    {
+        OwnPtr<CCLayerImpl> root = CCLayerImpl::create(0);
+        root->setAnchorPoint(FloatPoint(0, 0));
+        root->setBounds(IntSize(10, 10));
+        root->setDrawsContent(false);
+        m_hostImpl->setRootLayer(root.release());
+    }
+    CCLayerImpl* root = m_hostImpl->rootLayer();
 
-    RefPtr<BlendStateCheckLayer> layer1 = BlendStateCheckLayer::create(1);
-    root->addChild(layer1);
+    root->addChild(BlendStateCheckLayer::create(1));
+    BlendStateCheckLayer* layer1 = static_cast<BlendStateCheckLayer*>(root->children()[0].get());
 
     // Opaque layer, drawn without blending.
     layer1->setOpaque(true);
@@ -537,8 +553,8 @@ TEST_F(CCLayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers)
     m_hostImpl->drawLayers();
     EXPECT_TRUE(layer1->quadsAppended());
 
-    RefPtr<BlendStateCheckLayer> layer2 = BlendStateCheckLayer::create(2);
-    layer1->addChild(layer2);
+    layer1->addChild(BlendStateCheckLayer::create(2));
+    BlendStateCheckLayer* layer2 = static_cast<BlendStateCheckLayer*>(layer1->children()[0].get());
 
     // 2 opaque layers, drawn without blending.
     layer1->setOpaque(true);
@@ -656,11 +672,11 @@ TEST_F(CCLayerTreeHostImplTest, reshapeNotCalledUntilDraw)
     m_hostImpl->initializeLayerRenderer(context);
     m_hostImpl->setViewportSize(IntSize(10, 10));
 
-    RefPtr<CCLayerImpl> root = adoptRef(new FakeDrawableCCLayerImpl(1));
+    CCLayerImpl* root = new FakeDrawableCCLayerImpl(1);
     root->setAnchorPoint(FloatPoint(0, 0));
     root->setBounds(IntSize(10, 10));
     root->setDrawsContent(true);
-    m_hostImpl->setRootLayer(root);
+    m_hostImpl->setRootLayer(adoptPtr(root));
     EXPECT_FALSE(reshapeTracker->reshapeCalled());
 
     m_hostImpl->drawLayers();
@@ -703,8 +719,8 @@ TEST_F(CCLayerTreeHostImplTest, partialSwapReceivesDamageRect)
     layerTreeHostImpl->initializeLayerRenderer(context);
     layerTreeHostImpl->setViewportSize(IntSize(500, 500));
 
-    RefPtr<CCLayerImpl> root = adoptRef(new FakeDrawableCCLayerImpl(1));
-    RefPtr<CCLayerImpl> child = adoptRef(new FakeDrawableCCLayerImpl(2));
+    CCLayerImpl* root = new FakeDrawableCCLayerImpl(1);
+    CCLayerImpl* child = new FakeDrawableCCLayerImpl(2);
     child->setPosition(FloatPoint(12, 13));
     child->setAnchorPoint(FloatPoint(0, 0));
     child->setBounds(IntSize(14, 15));
@@ -712,8 +728,8 @@ TEST_F(CCLayerTreeHostImplTest, partialSwapReceivesDamageRect)
     root->setAnchorPoint(FloatPoint(0, 0));
     root->setBounds(IntSize(500, 500));
     root->setDrawsContent(true);
-    root->addChild(child);
-    layerTreeHostImpl->setRootLayer(root);
+    root->addChild(adoptPtr(child));
+    layerTreeHostImpl->setRootLayer(adoptPtr(root));
 
     // First frame, the entire screen should get swapped.
     layerTreeHostImpl->drawLayers();
index c3b366dda3237468686fbf83ed4fe3390f82f334..1201587c78df7b58402774df0c693f4eedddd600 100644 (file)
@@ -54,7 +54,7 @@ TEST(CCRenderSurfaceTest, verifySurfaceChangesAreTrackedProperly)
     // This will fake that we are on the correct thread for testing purposes.
     DebugScopedSetImplThread setImplThread;
 
-    RefPtr<CCLayerImpl> owningLayer = CCLayerImpl::create(0);
+    OwnPtr<CCLayerImpl> owningLayer = CCLayerImpl::create(0);
     owningLayer->createRenderSurface();
     ASSERT_TRUE(owningLayer->renderSurface());
     CCRenderSurface* renderSurface = owningLayer->renderSurface();
@@ -74,7 +74,7 @@ TEST(CCRenderSurfaceTest, verifySurfaceChangesAreTrackedProperly)
     EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setClipRect(testRect));
     EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setContentRect(testRect));
 
-    RefPtr<CCLayerImpl> dummyMask = CCLayerImpl::create(1);
+    OwnPtr<CCLayerImpl> dummyMask = CCLayerImpl::create(1);
     TransformationMatrix dummyMatrix;
     dummyMatrix.translate(1.0, 2.0);
 
index 059ef2adcf55ed3bfaa507914a413347886eec54..02dc908abda77453a4fa69de2b96d3db90797f23 100644 (file)
@@ -46,7 +46,7 @@ TEST(CCSolidColorLayerImplTest, verifyTilingCompleteAndNoOverlap)
     IntSize layerSize = IntSize(800, 600);
     IntRect visibleLayerRect = IntRect(IntPoint(), layerSize);
 
-    RefPtr<CCSolidColorLayerImpl> layer = CCSolidColorLayerImpl::create(0);
+    OwnPtr<CCSolidColorLayerImpl> layer = CCSolidColorLayerImpl::create(0);
     layer->setVisibleLayerRect(visibleLayerRect);
     layer->setBounds(layerSize);
 
@@ -66,7 +66,7 @@ TEST(CCSolidColorLayerImplTest, verifyCorrectBackgroundColorInQuad)
     IntSize layerSize = IntSize(100, 100);
     IntRect visibleLayerRect = IntRect(IntPoint(), layerSize);
 
-    RefPtr<CCSolidColorLayerImpl> layer = CCSolidColorLayerImpl::create(0);
+    OwnPtr<CCSolidColorLayerImpl> layer = CCSolidColorLayerImpl::create(0);
     layer->setVisibleLayerRect(visibleLayerRect);
     layer->setBounds(layerSize);
     layer->setBackgroundColor(testColor);
index d55c0bc1644e2a89074f2b89f61edf220f786fc3..ff7daa3c9b276f5a2da7a393db18b55ad458d085 100644 (file)
@@ -39,9 +39,9 @@ namespace {
 
 // Create a default tiled layer with textures for all tiles and a default
 // visibility of the entire layer size.
-static PassRefPtr<CCTiledLayerImpl> createLayer(const IntSize& tileSize, const IntSize& layerSize, CCLayerTilingData::BorderTexelOption borderTexels)
+static PassOwnPtr<CCTiledLayerImpl> createLayer(const IntSize& tileSize, const IntSize& layerSize, CCLayerTilingData::BorderTexelOption borderTexels)
 {
-    RefPtr<CCTiledLayerImpl> layer = CCTiledLayerImpl::create(0);
+    OwnPtr<CCTiledLayerImpl> layer = CCTiledLayerImpl::create(0);
     OwnPtr<CCLayerTilingData> tiler = CCLayerTilingData::create(tileSize, borderTexels);
     tiler->setBounds(layerSize);
     layer->setTilingData(*tiler);
@@ -68,7 +68,7 @@ TEST(CCTiledLayerImplTest, emptyQuadList)
 
     // Verify default layer does creates quads
     {
-        RefPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, CCLayerTilingData::NoBorderTexels);
+        OwnPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, CCLayerTilingData::NoBorderTexels);
         CCQuadList quads;
         OwnPtr<CCSharedQuadState> sharedQuadState = layer->createSharedQuadState();
         layer->appendQuads(quads, sharedQuadState.get());
@@ -78,7 +78,7 @@ TEST(CCTiledLayerImplTest, emptyQuadList)
 
     // Layer with empty visible layer rect produces no quads
     {
-        RefPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, CCLayerTilingData::NoBorderTexels);
+        OwnPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, CCLayerTilingData::NoBorderTexels);
         layer->setVisibleLayerRect(IntRect());
 
         CCQuadList quads;
@@ -89,7 +89,7 @@ TEST(CCTiledLayerImplTest, emptyQuadList)
 
     // Layer with non-intersecting visible layer rect produces no quads
     {
-        RefPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, CCLayerTilingData::NoBorderTexels);
+        OwnPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, CCLayerTilingData::NoBorderTexels);
 
         IntRect outsideBounds(IntPoint(-100, -100), IntSize(50, 50));
         layer->setVisibleLayerRect(outsideBounds);
@@ -102,7 +102,7 @@ TEST(CCTiledLayerImplTest, emptyQuadList)
 
     // Layer with skips draw produces no quads
     {
-        RefPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, CCLayerTilingData::NoBorderTexels);
+        OwnPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, CCLayerTilingData::NoBorderTexels);
         layer->setSkipsDraw(true);
 
         CCQuadList quads;
@@ -121,7 +121,7 @@ TEST(CCTiledLayerImplTest, checkerboarding)
     const int numTilesY = 2;
     const IntSize layerSize(tileSize.width() * numTilesX, tileSize.height() * numTilesY);
 
-    RefPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, CCLayerTilingData::NoBorderTexels);
+    OwnPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, CCLayerTilingData::NoBorderTexels);
     OwnPtr<CCSharedQuadState> sharedQuadState = layer->createSharedQuadState();
 
     // No checkerboarding
@@ -150,7 +150,7 @@ TEST(CCTiledLayerImplTest, checkerboarding)
 
 static PassOwnPtr<CCSharedQuadState> getQuads(CCQuadList& quads, IntSize tileSize, const IntSize& layerSize, CCLayerTilingData::BorderTexelOption borderTexelOption, const IntRect& visibleLayerRect)
 {
-    RefPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, borderTexelOption);
+    OwnPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, borderTexelOption);
     layer->setVisibleLayerRect(visibleLayerRect);
     layer->setBounds(layerSize);
 
@@ -260,7 +260,7 @@ TEST(CCTiledLayerImplTest, backgroundCoversViewport)
     const int numTilesY = 2;
     const unsigned numTiles = numTilesX * numTilesY;
     const IntSize layerSize(tileSize.width() * numTilesX, tileSize.height() * numTilesY);
-    RefPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, CCLayerTilingData::NoBorderTexels);
+    OwnPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, CCLayerTilingData::NoBorderTexels);
     layer->setBackgroundColor(Color::gray);
     layer->setBackgroundCoversViewport(true);
 
index ec0ce0c6abca124fe9b2ae979c3048a0d22ce228..bbc21c5a2ecb6bfa120ede6f4eef6fae6cf400df 100644 (file)
@@ -139,7 +139,7 @@ protected:
         {
             DebugScopedSetImplThread scopedImplThread;
 
-            RefPtr<CCLayerImpl> layerImpl = canvas->createCCLayerImpl();
+            OwnPtr<CCLayerImpl> layerImpl = canvas->createCCLayerImpl();
             EXPECT_EQ(0u, static_cast<CCCanvasLayerImpl*>(layerImpl.get())->textureId());
 
             canvas->updateCompositorResources(implContext.get(), updater);
index e035590467a6427bfcb6047dad444a36a270c88d..c672d23b19d409fd5a149b822d729f011da99df4 100644 (file)
@@ -231,7 +231,7 @@ TEST(TiledLayerChromiumTest, pushDirtyTiles)
     OwnPtr<TextureManager> textureManager = TextureManager::create(4*1024*1024, 2*1024*1024, 1024);
     RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
     DebugScopedSetImplThread implThread;
-    RefPtr<FakeCCTiledLayerImpl> layerImpl = adoptRef(new FakeCCTiledLayerImpl(0));
+    OwnPtr<FakeCCTiledLayerImpl> layerImpl = adoptPtr(new FakeCCTiledLayerImpl(0));
 
     FakeTextureAllocator textureAllocator;
     CCTextureUpdater updater(&textureAllocator);
@@ -266,7 +266,7 @@ TEST(TiledLayerChromiumTest, pushIdlePaintTiles)
     OwnPtr<TextureManager> textureManager = TextureManager::create(4*1024*1024, 2*1024*1024, 1024);
     RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
     DebugScopedSetImplThread implThread;
-    RefPtr<FakeCCTiledLayerImpl> layerImpl = adoptRef(new FakeCCTiledLayerImpl(0));
+    OwnPtr<FakeCCTiledLayerImpl> layerImpl = adoptPtr(new FakeCCTiledLayerImpl(0));
 
     FakeTextureAllocator textureAllocator;
     CCTextureUpdater updater(&textureAllocator);
@@ -332,7 +332,7 @@ TEST(TiledLayerChromiumTest, idlePaintOutOfMemory)
     OwnPtr<TextureManager> textureManager = TextureManager::create(memoryLimit, memoryLimit / 2, 1024);
     RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
     DebugScopedSetImplThread implThread;
-    RefPtr<FakeCCTiledLayerImpl> layerImpl = adoptRef(new FakeCCTiledLayerImpl(0));
+    OwnPtr<FakeCCTiledLayerImpl> layerImpl = adoptPtr(new FakeCCTiledLayerImpl(0));
 
     FakeTextureAllocator textureAllocator;
     CCTextureUpdater updater(&textureAllocator);
@@ -368,7 +368,7 @@ TEST(TiledLayerChromiumTest, invalidateFromPrepare)
     OwnPtr<TextureManager> textureManager = TextureManager::create(4*1024*1024, 2*1024*1024, 1024);
     RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
     DebugScopedSetImplThread implThread;
-    RefPtr<FakeCCTiledLayerImpl> layerImpl = adoptRef(new FakeCCTiledLayerImpl(0));
+    OwnPtr<FakeCCTiledLayerImpl> layerImpl = adoptPtr(new FakeCCTiledLayerImpl(0));
 
     FakeTextureAllocator textureAllocator;
     CCTextureUpdater updater(&textureAllocator);
@@ -448,7 +448,7 @@ TEST(TiledLayerChromiumTest, verifyInvalidationWhenContentsScaleChanges)
     OwnPtr<TextureManager> textureManager = TextureManager::create(4*1024*1024, 2*1024*1024, 1024);
     RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
     DebugScopedSetImplThread implThread;
-    RefPtr<FakeCCTiledLayerImpl> layerImpl = adoptRef(new FakeCCTiledLayerImpl(0));
+    OwnPtr<FakeCCTiledLayerImpl> layerImpl = adoptPtr(new FakeCCTiledLayerImpl(0));
 
     FakeTextureAllocator textureAllocator;
     CCTextureUpdater updater(&textureAllocator);
index 4724b4a43567b43978dda7c0d61a842d8d482984..eb3850dab1226b14b71eb26a3a5132cd2ba61003 100644 (file)
@@ -41,9 +41,9 @@ namespace {
 
 class MockCCLayerImpl : public CCLayerImpl {
 public:
-    static PassRefPtr<MockCCLayerImpl> create(int layerId)
+    static PassOwnPtr<MockCCLayerImpl> create(int layerId)
     {
-        return adoptRef(new MockCCLayerImpl(layerId));
+        return adoptPtr(new MockCCLayerImpl(layerId));
     }
     virtual ~MockCCLayerImpl()
     {
@@ -72,7 +72,7 @@ public:
 
     virtual ~MockLayerChromium() { }
 
-    virtual PassRefPtr<CCLayerImpl> createCCLayerImpl()
+    virtual PassOwnPtr<CCLayerImpl> createCCLayerImpl()
     {
         return MockCCLayerImpl::create(m_layerId);
     }
@@ -134,7 +134,7 @@ void expectTreesAreIdentical(LayerChromium* layer, CCLayerImpl* ccLayer)
         expectTreesAreIdentical(layer->replicaLayer(), ccLayer->replicaLayer());
 
     const Vector<RefPtr<LayerChromium> >& layerChildren = layer->children();
-    const Vector<RefPtr<CCLayerImpl> >& ccLayerChildren = ccLayer->children();
+    const Vector<OwnPtr<CCLayerImpl> >& ccLayerChildren = ccLayer->children();
 
     ASSERT_EQ(layerChildren.size(), ccLayerChildren.size());
 
@@ -150,7 +150,7 @@ TEST(TreeSynchronizerTest, syncSimpleTreeFromEmpty)
     layerTreeRoot->addChild(LayerChromium::create());
     layerTreeRoot->addChild(LayerChromium::create());
 
-    RefPtr<CCLayerImpl> ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), 0);
+    OwnPtr<CCLayerImpl> ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), nullptr);
 
     expectTreesAreIdentical(layerTreeRoot.get(), ccLayerTreeRoot.get());
 }
@@ -165,7 +165,7 @@ TEST(TreeSynchronizerTest, syncSimpleTreeReusingLayers)
     layerTreeRoot->addChild(MockLayerChromium::create(&ccLayerDestructionList));
     layerTreeRoot->addChild(MockLayerChromium::create(&ccLayerDestructionList));
 
-    RefPtr<CCLayerImpl> ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), 0);
+    OwnPtr<CCLayerImpl> ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), nullptr);
     expectTreesAreIdentical(layerTreeRoot.get(), ccLayerTreeRoot.get());
 
     // Add a new layer to the LayerChromium side
@@ -199,7 +199,7 @@ TEST(TreeSynchronizerTest, syncSimpleTreeAndProperties)
     IntSize secondChildBounds = IntSize(25, 53);
     layerTreeRoot->children()[1]->setBounds(secondChildBounds);
 
-    RefPtr<CCLayerImpl> ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), 0);
+    OwnPtr<CCLayerImpl> ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), nullptr);
     expectTreesAreIdentical(layerTreeRoot.get(), ccLayerTreeRoot.get());
 
     // Check that the property values we set on the LayerChromium tree are reflected in the CCLayerImpl tree.
@@ -236,7 +236,7 @@ TEST(TreeSynchronizerTest, reuseCCLayersAfterStructuralChange)
     layerB->addChild(MockLayerChromium::create(&ccLayerDestructionList));
     RefPtr<LayerChromium> layerD = layerB->children()[1].get();
 
-    RefPtr<CCLayerImpl> ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), 0);
+    OwnPtr<CCLayerImpl> ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), nullptr);
     expectTreesAreIdentical(layerTreeRoot.get(), ccLayerTreeRoot.get());
 
     // Now restructure the tree to look like this:
@@ -274,7 +274,7 @@ TEST(TreeSynchronizerTest, syncSimpleTreeThenDestroy)
     int oldTreeFirstChildLayerId = oldLayerTreeRoot->children()[0]->id();
     int oldTreeSecondChildLayerId = oldLayerTreeRoot->children()[1]->id();
 
-    RefPtr<CCLayerImpl> ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(oldLayerTreeRoot.get(), 0);
+    OwnPtr<CCLayerImpl> ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(oldLayerTreeRoot.get(), nullptr);
     expectTreesAreIdentical(oldLayerTreeRoot.get(), ccLayerTreeRoot.get());
 
     // Remove all children on the LayerChromium side.
@@ -314,23 +314,23 @@ TEST(TreeSynchronizerTest, syncMaskReplicaAndReplicaMaskLayers)
     replicaLayerWithMask->setMaskLayer(replicaMaskLayer.get());
     layerTreeRoot->children()[2]->setReplicaLayer(replicaLayerWithMask.get());
 
-    RefPtr<CCLayerImpl> ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), 0);
+    OwnPtr<CCLayerImpl> ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), nullptr);
 
     expectTreesAreIdentical(layerTreeRoot.get(), ccLayerTreeRoot.get());
 
     // Remove the mask layer.
     layerTreeRoot->children()[0]->setMaskLayer(0);
-    ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), ccLayerTreeRoot.get());
+    ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), ccLayerTreeRoot.release());
     expectTreesAreIdentical(layerTreeRoot.get(), ccLayerTreeRoot.get());
 
     // Remove the replica layer.
     layerTreeRoot->children()[1]->setReplicaLayer(0);
-    ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), ccLayerTreeRoot.get());
+    ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), ccLayerTreeRoot.release());
     expectTreesAreIdentical(layerTreeRoot.get(), ccLayerTreeRoot.get());
 
     // Remove the replica mask.
     replicaLayerWithMask->setMaskLayer(0);
-    ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), ccLayerTreeRoot.get());
+    ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), ccLayerTreeRoot.release());
     expectTreesAreIdentical(layerTreeRoot.get(), ccLayerTreeRoot.get());
 }
 
@@ -343,8 +343,8 @@ TEST(TreeSynchronizerTest, synchronizeAnimations)
 
     EXPECT_FALSE(static_cast<FakeLayerAnimationController*>(layerTreeRoot->layerAnimationController())->synchronizedAnimations());
 
-    RefPtr<CCLayerImpl> ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), 0);
-    ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), ccLayerTreeRoot.get());
+    OwnPtr<CCLayerImpl> ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), nullptr);
+    ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), ccLayerTreeRoot.release());
 
     EXPECT_TRUE(static_cast<FakeLayerAnimationController*>(layerTreeRoot->layerAnimationController())->synchronizedAnimations());
 }