Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(283)

Side by Side Diff: cc/CCLayerTreeHostImplTest.cpp

Issue 11083003: Revert 160631 - [cc] Store CCLayerImpls as scoped_ptrs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/CCLayerTreeHostImpl.cpp ('k') | cc/CCLayerTreeHostTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 6
7 #include "CCLayerTreeHostImpl.h" 7 #include "CCLayerTreeHostImpl.h"
8 8
9 #include "CCAnimationTestCommon.h" 9 #include "CCAnimationTestCommon.h"
10 #include "CCDelegatedRendererLayerImpl.h" 10 #include "CCDelegatedRendererLayerImpl.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 67
68 virtual void didLoseContextOnImplThread() OVERRIDE { } 68 virtual void didLoseContextOnImplThread() OVERRIDE { }
69 virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { } 69 virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { }
70 virtual void onVSyncParametersChanged(double, double) OVERRIDE { } 70 virtual void onVSyncParametersChanged(double, double) OVERRIDE { }
71 virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE { m_onCanDrawState ChangedCalled = true; } 71 virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE { m_onCanDrawState ChangedCalled = true; }
72 virtual void setNeedsRedrawOnImplThread() OVERRIDE { m_didRequestRedraw = tr ue; } 72 virtual void setNeedsRedrawOnImplThread() OVERRIDE { m_didRequestRedraw = tr ue; }
73 virtual void setNeedsCommitOnImplThread() OVERRIDE { m_didRequestCommit = tr ue; } 73 virtual void setNeedsCommitOnImplThread() OVERRIDE { m_didRequestCommit = tr ue; }
74 virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<CCAnimat ionEventsVector>, double wallClockTime) OVERRIDE { } 74 virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<CCAnimat ionEventsVector>, double wallClockTime) OVERRIDE { }
75 virtual void releaseContentsTexturesOnImplThread() OVERRIDE { } 75 virtual void releaseContentsTexturesOnImplThread() OVERRIDE { }
76 76
77 scoped_ptr<CCLayerTreeHostImpl> createLayerTreeHost(bool partialSwap, scoped _ptr<CCGraphicsContext> graphicsContext, scoped_ptr<CCLayerImpl> root) 77 scoped_ptr<CCLayerTreeHostImpl> createLayerTreeHost(bool partialSwap, scoped _ptr<CCGraphicsContext> graphicsContext, PassOwnPtr<CCLayerImpl> rootPtr)
78 { 78 {
79 CCSettings::setPartialSwapEnabled(partialSwap); 79 CCSettings::setPartialSwapEnabled(partialSwap);
80 80
81 CCLayerTreeSettings settings; 81 CCLayerTreeSettings settings;
82 settings.minimumOcclusionTrackingSize = IntSize(); 82 settings.minimumOcclusionTrackingSize = IntSize();
83 83
84 scoped_ptr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create (settings, this); 84 scoped_ptr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create (settings, this);
85 85
86 myHostImpl->initializeRenderer(graphicsContext.Pass()); 86 myHostImpl->initializeRenderer(graphicsContext.Pass());
87 myHostImpl->setViewportSize(IntSize(10, 10), IntSize(10, 10)); 87 myHostImpl->setViewportSize(IntSize(10, 10), IntSize(10, 10));
88 88
89 OwnPtr<CCLayerImpl> root = rootPtr;
90
89 root->setAnchorPoint(FloatPoint(0, 0)); 91 root->setAnchorPoint(FloatPoint(0, 0));
90 root->setPosition(FloatPoint(0, 0)); 92 root->setPosition(FloatPoint(0, 0));
91 root->setBounds(IntSize(10, 10)); 93 root->setBounds(IntSize(10, 10));
92 root->setContentBounds(IntSize(10, 10)); 94 root->setContentBounds(IntSize(10, 10));
93 root->setVisibleContentRect(IntRect(0, 0, 10, 10)); 95 root->setVisibleContentRect(IntRect(0, 0, 10, 10));
94 root->setDrawsContent(true); 96 root->setDrawsContent(true);
95 myHostImpl->setRootLayer(root.Pass()); 97 myHostImpl->setRootLayer(root.release());
96 return myHostImpl.Pass(); 98 return myHostImpl.Pass();
97 } 99 }
98 100
99 static void expectClearedScrollDeltasRecursive(CCLayerImpl* layer) 101 static void expectClearedScrollDeltasRecursive(CCLayerImpl* layer)
100 { 102 {
101 ASSERT_EQ(layer->scrollDelta(), IntSize()); 103 ASSERT_EQ(layer->scrollDelta(), IntSize());
102 for (size_t i = 0; i < layer->children().size(); ++i) 104 for (size_t i = 0; i < layer->children().size(); ++i)
103 expectClearedScrollDeltasRecursive(layer->children()[i]); 105 expectClearedScrollDeltasRecursive(layer->children()[i]);
104 } 106 }
105 107
106 static void expectContains(const CCScrollAndScaleSet& scrollInfo, int id, co nst IntSize& scrollDelta) 108 static void expectContains(const CCScrollAndScaleSet& scrollInfo, int id, co nst IntSize& scrollDelta)
107 { 109 {
108 int timesEncountered = 0; 110 int timesEncountered = 0;
109 111
110 for (size_t i = 0; i < scrollInfo.scrolls.size(); ++i) { 112 for (size_t i = 0; i < scrollInfo.scrolls.size(); ++i) {
111 if (scrollInfo.scrolls[i].layerId != id) 113 if (scrollInfo.scrolls[i].layerId != id)
112 continue; 114 continue;
113 EXPECT_EQ(scrollDelta.width(), scrollInfo.scrolls[i].scrollDelta.wid th()); 115 EXPECT_EQ(scrollDelta.width(), scrollInfo.scrolls[i].scrollDelta.wid th());
114 EXPECT_EQ(scrollDelta.height(), scrollInfo.scrolls[i].scrollDelta.he ight()); 116 EXPECT_EQ(scrollDelta.height(), scrollInfo.scrolls[i].scrollDelta.he ight());
115 timesEncountered++; 117 timesEncountered++;
116 } 118 }
117 119
118 ASSERT_EQ(timesEncountered, 1); 120 ASSERT_EQ(timesEncountered, 1);
119 } 121 }
120 122
121 void setupScrollAndContentsLayers(const IntSize& contentSize) 123 void setupScrollAndContentsLayers(const IntSize& contentSize)
122 { 124 {
123 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); 125 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
124 root->setScrollable(true); 126 root->setScrollable(true);
125 root->setScrollPosition(IntPoint(0, 0)); 127 root->setScrollPosition(IntPoint(0, 0));
126 root->setMaxScrollPosition(contentSize); 128 root->setMaxScrollPosition(contentSize);
127 root->setBounds(contentSize); 129 root->setBounds(contentSize);
128 root->setContentBounds(contentSize); 130 root->setContentBounds(contentSize);
129 root->setPosition(FloatPoint(0, 0)); 131 root->setPosition(FloatPoint(0, 0));
130 root->setAnchorPoint(FloatPoint(0, 0)); 132 root->setAnchorPoint(FloatPoint(0, 0));
131 133
132 scoped_ptr<CCLayerImpl> contents = CCLayerImpl::create(2); 134 OwnPtr<CCLayerImpl> contents = CCLayerImpl::create(2);
133 contents->setDrawsContent(true); 135 contents->setDrawsContent(true);
134 contents->setBounds(contentSize); 136 contents->setBounds(contentSize);
135 contents->setContentBounds(contentSize); 137 contents->setContentBounds(contentSize);
136 contents->setPosition(FloatPoint(0, 0)); 138 contents->setPosition(FloatPoint(0, 0));
137 contents->setAnchorPoint(FloatPoint(0, 0)); 139 contents->setAnchorPoint(FloatPoint(0, 0));
138 root->addChild(contents.Pass()); 140 root->addChild(contents.release());
139 m_hostImpl->setRootLayer(root.Pass()); 141 m_hostImpl->setRootLayer(root.release());
140 } 142 }
141 143
142 static scoped_ptr<CCLayerImpl> createScrollableLayer(int id, const IntSize& size) 144 static PassOwnPtr<CCLayerImpl> createScrollableLayer(int id, const IntSize& size)
143 { 145 {
144 scoped_ptr<CCLayerImpl> layer = CCLayerImpl::create(id); 146 OwnPtr<CCLayerImpl> layer = CCLayerImpl::create(id);
145 layer->setScrollable(true); 147 layer->setScrollable(true);
146 layer->setDrawsContent(true); 148 layer->setDrawsContent(true);
147 layer->setBounds(size); 149 layer->setBounds(size);
148 layer->setContentBounds(size); 150 layer->setContentBounds(size);
149 layer->setMaxScrollPosition(IntSize(size.width() * 2, size.height() * 2) ); 151 layer->setMaxScrollPosition(IntSize(size.width() * 2, size.height() * 2) );
150 return layer.Pass(); 152 return layer.release();
151 } 153 }
152 154
153 void initializeRendererAndDrawFrame() 155 void initializeRendererAndDrawFrame()
154 { 156 {
155 m_hostImpl->initializeRenderer(createContext()); 157 m_hostImpl->initializeRenderer(createContext());
156 CCLayerTreeHostImpl::FrameData frame; 158 CCLayerTreeHostImpl::FrameData frame;
157 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 159 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
158 m_hostImpl->drawLayers(frame); 160 m_hostImpl->drawLayers(frame);
159 m_hostImpl->didDrawAllLayers(frame); 161 m_hostImpl->didDrawAllLayers(frame);
160 } 162 }
(...skipping 26 matching lines...) Expand all
187 // that canDraw changed. 189 // that canDraw changed.
188 EXPECT_FALSE(m_hostImpl->canDraw()); 190 EXPECT_FALSE(m_hostImpl->canDraw());
189 m_onCanDrawStateChangedCalled = false; 191 m_onCanDrawStateChangedCalled = false;
190 192
191 setupScrollAndContentsLayers(IntSize(100, 100)); 193 setupScrollAndContentsLayers(IntSize(100, 100));
192 EXPECT_TRUE(m_hostImpl->canDraw()); 194 EXPECT_TRUE(m_hostImpl->canDraw());
193 EXPECT_TRUE(m_onCanDrawStateChangedCalled); 195 EXPECT_TRUE(m_onCanDrawStateChangedCalled);
194 m_onCanDrawStateChangedCalled = false; 196 m_onCanDrawStateChangedCalled = false;
195 197
196 // Toggle the root layer to make sure it toggles canDraw 198 // Toggle the root layer to make sure it toggles canDraw
197 m_hostImpl->setRootLayer(scoped_ptr<CCLayerImpl>()); 199 m_hostImpl->setRootLayer(adoptPtr<CCLayerImpl>(0));
198 EXPECT_FALSE(m_hostImpl->canDraw()); 200 EXPECT_FALSE(m_hostImpl->canDraw());
199 EXPECT_TRUE(m_onCanDrawStateChangedCalled); 201 EXPECT_TRUE(m_onCanDrawStateChangedCalled);
200 m_onCanDrawStateChangedCalled = false; 202 m_onCanDrawStateChangedCalled = false;
201 203
202 setupScrollAndContentsLayers(IntSize(100, 100)); 204 setupScrollAndContentsLayers(IntSize(100, 100));
203 EXPECT_TRUE(m_hostImpl->canDraw()); 205 EXPECT_TRUE(m_hostImpl->canDraw());
204 EXPECT_TRUE(m_onCanDrawStateChangedCalled); 206 EXPECT_TRUE(m_onCanDrawStateChangedCalled);
205 m_onCanDrawStateChangedCalled = false; 207 m_onCanDrawStateChangedCalled = false;
206 208
207 // Toggle the device viewport size to make sure it toggles canDraw. 209 // Toggle the device viewport size to make sure it toggles canDraw.
(...skipping 23 matching lines...) Expand all
231 { 233 {
232 ASSERT_FALSE(m_hostImpl->rootLayer()); 234 ASSERT_FALSE(m_hostImpl->rootLayer());
233 235
234 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); 236 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
235 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); 237 ASSERT_EQ(scrollInfo->scrolls.size(), 0u);
236 } 238 }
237 239
238 TEST_F(CCLayerTreeHostImplTest, scrollDeltaTreeButNoChanges) 240 TEST_F(CCLayerTreeHostImplTest, scrollDeltaTreeButNoChanges)
239 { 241 {
240 { 242 {
241 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); 243 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
242 root->addChild(CCLayerImpl::create(2)); 244 root->addChild(CCLayerImpl::create(2));
243 root->addChild(CCLayerImpl::create(3)); 245 root->addChild(CCLayerImpl::create(3));
244 root->children()[1]->addChild(CCLayerImpl::create(4)); 246 root->children()[1]->addChild(CCLayerImpl::create(4));
245 root->children()[1]->addChild(CCLayerImpl::create(5)); 247 root->children()[1]->addChild(CCLayerImpl::create(5));
246 root->children()[1]->children()[0]->addChild(CCLayerImpl::create(6)); 248 root->children()[1]->children()[0]->addChild(CCLayerImpl::create(6));
247 m_hostImpl->setRootLayer(root.Pass()); 249 m_hostImpl->setRootLayer(root.release());
248 } 250 }
249 CCLayerImpl* root = m_hostImpl->rootLayer(); 251 CCLayerImpl* root = m_hostImpl->rootLayer();
250 252
251 expectClearedScrollDeltasRecursive(root); 253 expectClearedScrollDeltasRecursive(root);
252 254
253 OwnPtr<CCScrollAndScaleSet> scrollInfo; 255 OwnPtr<CCScrollAndScaleSet> scrollInfo;
254 256
255 scrollInfo = m_hostImpl->processScrollDeltas(); 257 scrollInfo = m_hostImpl->processScrollDeltas();
256 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); 258 ASSERT_EQ(scrollInfo->scrolls.size(), 0u);
257 expectClearedScrollDeltasRecursive(root); 259 expectClearedScrollDeltasRecursive(root);
258 260
259 scrollInfo = m_hostImpl->processScrollDeltas(); 261 scrollInfo = m_hostImpl->processScrollDeltas();
260 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); 262 ASSERT_EQ(scrollInfo->scrolls.size(), 0u);
261 expectClearedScrollDeltasRecursive(root); 263 expectClearedScrollDeltasRecursive(root);
262 } 264 }
263 265
264 TEST_F(CCLayerTreeHostImplTest, scrollDeltaRepeatedScrolls) 266 TEST_F(CCLayerTreeHostImplTest, scrollDeltaRepeatedScrolls)
265 { 267 {
266 IntPoint scrollPosition(20, 30); 268 IntPoint scrollPosition(20, 30);
267 IntSize scrollDelta(11, -15); 269 IntSize scrollDelta(11, -15);
268 { 270 {
269 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); 271 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
270 root->setScrollPosition(scrollPosition); 272 root->setScrollPosition(scrollPosition);
271 root->setScrollable(true); 273 root->setScrollable(true);
272 root->setMaxScrollPosition(IntSize(100, 100)); 274 root->setMaxScrollPosition(IntSize(100, 100));
273 root->scrollBy(scrollDelta); 275 root->scrollBy(scrollDelta);
274 m_hostImpl->setRootLayer(root.Pass()); 276 m_hostImpl->setRootLayer(root.release());
275 } 277 }
276 CCLayerImpl* root = m_hostImpl->rootLayer(); 278 CCLayerImpl* root = m_hostImpl->rootLayer();
277 279
278 OwnPtr<CCScrollAndScaleSet> scrollInfo; 280 OwnPtr<CCScrollAndScaleSet> scrollInfo;
279 281
280 scrollInfo = m_hostImpl->processScrollDeltas(); 282 scrollInfo = m_hostImpl->processScrollDeltas();
281 ASSERT_EQ(scrollInfo->scrolls.size(), 1u); 283 ASSERT_EQ(scrollInfo->scrolls.size(), 1u);
282 EXPECT_EQ(root->sentScrollDelta(), scrollDelta); 284 EXPECT_EQ(root->sentScrollDelta(), scrollDelta);
283 expectContains(*scrollInfo, root->id(), scrollDelta); 285 expectContains(*scrollInfo, root->id(), scrollDelta);
284 286
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 // The final page scale and scroll deltas should match what we got 673 // The final page scale and scroll deltas should match what we got
672 // earlier. 674 // earlier.
673 m_hostImpl->animate(endTime, endTime); 675 m_hostImpl->animate(endTime, endTime);
674 scrollInfo = m_hostImpl->processScrollDeltas(); 676 scrollInfo = m_hostImpl->processScrollDeltas();
675 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); 677 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta);
676 expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25)); 678 expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25));
677 } 679 }
678 680
679 class DidDrawCheckLayer : public CCTiledLayerImpl { 681 class DidDrawCheckLayer : public CCTiledLayerImpl {
680 public: 682 public:
681 static scoped_ptr<CCLayerImpl> create(int id) { return scoped_ptr<CCLayerImp l>(new DidDrawCheckLayer(id)); } 683 static PassOwnPtr<DidDrawCheckLayer> create(int id) { return adoptPtr(new Di dDrawCheckLayer(id)); }
682 684
683 virtual void didDraw(CCResourceProvider*) OVERRIDE 685 virtual void didDraw(CCResourceProvider*) OVERRIDE
684 { 686 {
685 m_didDrawCalled = true; 687 m_didDrawCalled = true;
686 } 688 }
687 689
688 virtual void willDraw(CCResourceProvider*) OVERRIDE 690 virtual void willDraw(CCResourceProvider*) OVERRIDE
689 { 691 {
690 m_willDrawCalled = true; 692 m_willDrawCalled = true;
691 } 693 }
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 EXPECT_TRUE(root->didDrawCalled()); 830 EXPECT_TRUE(root->didDrawCalled());
829 EXPECT_TRUE(layer1->didDrawCalled()); 831 EXPECT_TRUE(layer1->didDrawCalled());
830 EXPECT_TRUE(layer2->didDrawCalled()); 832 EXPECT_TRUE(layer2->didDrawCalled());
831 833
832 EXPECT_NE(root->renderSurface(), layer1->renderSurface()); 834 EXPECT_NE(root->renderSurface(), layer1->renderSurface());
833 EXPECT_TRUE(!!layer1->renderSurface()); 835 EXPECT_TRUE(!!layer1->renderSurface());
834 } 836 }
835 837
836 class MissingTextureAnimatingLayer : public DidDrawCheckLayer { 838 class MissingTextureAnimatingLayer : public DidDrawCheckLayer {
837 public: 839 public:
838 static scoped_ptr<CCLayerImpl> create(int id, bool tileMissing, bool skipsDr aw, bool animating, CCResourceProvider* resourceProvider) 840 static PassOwnPtr<MissingTextureAnimatingLayer> create(int id, bool tileMiss ing, bool skipsDraw, bool animating, CCResourceProvider* resourceProvider) { ret urn adoptPtr(new MissingTextureAnimatingLayer(id, tileMissing, skipsDraw, animat ing, resourceProvider)); }
839 {
840 return scoped_ptr<CCLayerImpl>(new MissingTextureAnimatingLayer(id, tile Missing, skipsDraw, animating, resourceProvider));
841 }
842 841
843 private: 842 private:
844 explicit MissingTextureAnimatingLayer(int id, bool tileMissing, bool skipsDr aw, bool animating, CCResourceProvider* resourceProvider) 843 explicit MissingTextureAnimatingLayer(int id, bool tileMissing, bool skipsDr aw, bool animating, CCResourceProvider* resourceProvider)
845 : DidDrawCheckLayer(id) 844 : DidDrawCheckLayer(id)
846 { 845 {
847 OwnPtr<CCLayerTilingData> tilingData = CCLayerTilingData::create(IntSize (10, 10), CCLayerTilingData::NoBorderTexels); 846 OwnPtr<CCLayerTilingData> tilingData = CCLayerTilingData::create(IntSize (10, 10), CCLayerTilingData::NoBorderTexels);
848 tilingData->setBounds(bounds()); 847 tilingData->setBounds(bounds());
849 setTilingData(*tilingData.get()); 848 setTilingData(*tilingData.get());
850 setSkipsDraw(skipsDraw); 849 setSkipsDraw(skipsDraw);
851 if (!tileMissing) { 850 if (!tileMissing) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); 892 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer());
894 root->addChild(MissingTextureAnimatingLayer::create(2, false, true, true, m_ hostImpl->resourceProvider())); 893 root->addChild(MissingTextureAnimatingLayer::create(2, false, true, true, m_ hostImpl->resourceProvider()));
895 894
896 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 895 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
897 m_hostImpl->drawLayers(frame); 896 m_hostImpl->drawLayers(frame);
898 m_hostImpl->didDrawAllLayers(frame); 897 m_hostImpl->didDrawAllLayers(frame);
899 } 898 }
900 899
901 TEST_F(CCLayerTreeHostImplTest, scrollRootIgnored) 900 TEST_F(CCLayerTreeHostImplTest, scrollRootIgnored)
902 { 901 {
903 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); 902 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
904 root->setScrollable(false); 903 root->setScrollable(false);
905 m_hostImpl->setRootLayer(root.Pass()); 904 m_hostImpl->setRootLayer(root.release());
906 initializeRendererAndDrawFrame(); 905 initializeRendererAndDrawFrame();
907 906
908 // Scroll event is ignored because layer is not scrollable. 907 // Scroll event is ignored because layer is not scrollable.
909 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollIgnored); 908 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollIgnored);
910 EXPECT_FALSE(m_didRequestRedraw); 909 EXPECT_FALSE(m_didRequestRedraw);
911 EXPECT_FALSE(m_didRequestCommit); 910 EXPECT_FALSE(m_didRequestCommit);
912 } 911 }
913 912
914 TEST_F(CCLayerTreeHostImplTest, scrollNonCompositedRoot) 913 TEST_F(CCLayerTreeHostImplTest, scrollNonCompositedRoot)
915 { 914 {
916 // Test the configuration where a non-composited root layer is embedded in a 915 // Test the configuration where a non-composited root layer is embedded in a
917 // scrollable outer layer. 916 // scrollable outer layer.
918 IntSize surfaceSize(10, 10); 917 IntSize surfaceSize(10, 10);
919 918
920 scoped_ptr<CCLayerImpl> contentLayer = CCLayerImpl::create(1); 919 OwnPtr<CCLayerImpl> contentLayer = CCLayerImpl::create(1);
921 contentLayer->setUseLCDText(true); 920 contentLayer->setUseLCDText(true);
922 contentLayer->setDrawsContent(true); 921 contentLayer->setDrawsContent(true);
923 contentLayer->setPosition(FloatPoint(0, 0)); 922 contentLayer->setPosition(FloatPoint(0, 0));
924 contentLayer->setAnchorPoint(FloatPoint(0, 0)); 923 contentLayer->setAnchorPoint(FloatPoint(0, 0));
925 contentLayer->setBounds(surfaceSize); 924 contentLayer->setBounds(surfaceSize);
926 contentLayer->setContentBounds(IntSize(surfaceSize.width() * 2, surfaceSize. height() * 2)); 925 contentLayer->setContentBounds(IntSize(surfaceSize.width() * 2, surfaceSize. height() * 2));
927 926
928 scoped_ptr<CCLayerImpl> scrollLayer = CCLayerImpl::create(2); 927 OwnPtr<CCLayerImpl> scrollLayer = CCLayerImpl::create(2);
929 scrollLayer->setScrollable(true); 928 scrollLayer->setScrollable(true);
930 scrollLayer->setMaxScrollPosition(surfaceSize); 929 scrollLayer->setMaxScrollPosition(surfaceSize);
931 scrollLayer->setBounds(surfaceSize); 930 scrollLayer->setBounds(surfaceSize);
932 scrollLayer->setContentBounds(surfaceSize); 931 scrollLayer->setContentBounds(surfaceSize);
933 scrollLayer->setPosition(FloatPoint(0, 0)); 932 scrollLayer->setPosition(FloatPoint(0, 0));
934 scrollLayer->setAnchorPoint(FloatPoint(0, 0)); 933 scrollLayer->setAnchorPoint(FloatPoint(0, 0));
935 scrollLayer->addChild(contentLayer.Pass()); 934 scrollLayer->addChild(contentLayer.release());
936 935
937 m_hostImpl->setRootLayer(scrollLayer.Pass()); 936 m_hostImpl->setRootLayer(scrollLayer.release());
938 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 937 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
939 initializeRendererAndDrawFrame(); 938 initializeRendererAndDrawFrame();
940 939
941 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted); 940 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted);
942 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); 941 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10));
943 m_hostImpl->scrollEnd(); 942 m_hostImpl->scrollEnd();
944 EXPECT_TRUE(m_didRequestRedraw); 943 EXPECT_TRUE(m_didRequestRedraw);
945 EXPECT_TRUE(m_didRequestCommit); 944 EXPECT_TRUE(m_didRequestCommit);
946 } 945 }
947 946
948 TEST_F(CCLayerTreeHostImplTest, scrollChildCallsCommitAndRedraw) 947 TEST_F(CCLayerTreeHostImplTest, scrollChildCallsCommitAndRedraw)
949 { 948 {
950 IntSize surfaceSize(10, 10); 949 IntSize surfaceSize(10, 10);
951 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); 950 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
952 root->setBounds(surfaceSize); 951 root->setBounds(surfaceSize);
953 root->setContentBounds(surfaceSize); 952 root->setContentBounds(surfaceSize);
954 root->addChild(createScrollableLayer(2, surfaceSize)); 953 root->addChild(createScrollableLayer(2, surfaceSize));
955 m_hostImpl->setRootLayer(root.Pass()); 954 m_hostImpl->setRootLayer(root.release());
956 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 955 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
957 initializeRendererAndDrawFrame(); 956 initializeRendererAndDrawFrame();
958 957
959 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted); 958 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted);
960 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); 959 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10));
961 m_hostImpl->scrollEnd(); 960 m_hostImpl->scrollEnd();
962 EXPECT_TRUE(m_didRequestRedraw); 961 EXPECT_TRUE(m_didRequestRedraw);
963 EXPECT_TRUE(m_didRequestCommit); 962 EXPECT_TRUE(m_didRequestCommit);
964 } 963 }
965 964
966 TEST_F(CCLayerTreeHostImplTest, scrollMissesChild) 965 TEST_F(CCLayerTreeHostImplTest, scrollMissesChild)
967 { 966 {
968 IntSize surfaceSize(10, 10); 967 IntSize surfaceSize(10, 10);
969 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); 968 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
970 root->addChild(createScrollableLayer(2, surfaceSize)); 969 root->addChild(createScrollableLayer(2, surfaceSize));
971 m_hostImpl->setRootLayer(root.Pass()); 970 m_hostImpl->setRootLayer(root.release());
972 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 971 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
973 initializeRendererAndDrawFrame(); 972 initializeRendererAndDrawFrame();
974 973
975 // Scroll event is ignored because the input coordinate is outside the layer boundaries. 974 // Scroll event is ignored because the input coordinate is outside the layer boundaries.
976 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(15, 5), CCInputHandlerClient::Whe el), CCInputHandlerClient::ScrollIgnored); 975 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(15, 5), CCInputHandlerClient::Whe el), CCInputHandlerClient::ScrollIgnored);
977 EXPECT_FALSE(m_didRequestRedraw); 976 EXPECT_FALSE(m_didRequestRedraw);
978 EXPECT_FALSE(m_didRequestCommit); 977 EXPECT_FALSE(m_didRequestCommit);
979 } 978 }
980 979
981 TEST_F(CCLayerTreeHostImplTest, scrollMissesBackfacingChild) 980 TEST_F(CCLayerTreeHostImplTest, scrollMissesBackfacingChild)
982 { 981 {
983 IntSize surfaceSize(10, 10); 982 IntSize surfaceSize(10, 10);
984 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); 983 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
985 scoped_ptr<CCLayerImpl> child = createScrollableLayer(2, surfaceSize); 984 OwnPtr<CCLayerImpl> child = createScrollableLayer(2, surfaceSize);
986 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 985 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
987 986
988 WebTransformationMatrix matrix; 987 WebTransformationMatrix matrix;
989 matrix.rotate3d(180, 0, 0); 988 matrix.rotate3d(180, 0, 0);
990 child->setTransform(matrix); 989 child->setTransform(matrix);
991 child->setDoubleSided(false); 990 child->setDoubleSided(false);
992 991
993 root->addChild(child.Pass()); 992 root->addChild(child.release());
994 m_hostImpl->setRootLayer(root.Pass()); 993 m_hostImpl->setRootLayer(root.release());
995 initializeRendererAndDrawFrame(); 994 initializeRendererAndDrawFrame();
996 995
997 // Scroll event is ignored because the scrollable layer is not facing the vi ewer and there is 996 // Scroll event is ignored because the scrollable layer is not facing the vi ewer and there is
998 // nothing scrollable behind it. 997 // nothing scrollable behind it.
999 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollIgnored); 998 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollIgnored);
1000 EXPECT_FALSE(m_didRequestRedraw); 999 EXPECT_FALSE(m_didRequestRedraw);
1001 EXPECT_FALSE(m_didRequestCommit); 1000 EXPECT_FALSE(m_didRequestCommit);
1002 } 1001 }
1003 1002
1004 TEST_F(CCLayerTreeHostImplTest, scrollBlockedByContentLayer) 1003 TEST_F(CCLayerTreeHostImplTest, scrollBlockedByContentLayer)
1005 { 1004 {
1006 IntSize surfaceSize(10, 10); 1005 IntSize surfaceSize(10, 10);
1007 scoped_ptr<CCLayerImpl> contentLayer = createScrollableLayer(1, surfaceSize) ; 1006 OwnPtr<CCLayerImpl> contentLayer = createScrollableLayer(1, surfaceSize);
1008 contentLayer->setShouldScrollOnMainThread(true); 1007 contentLayer->setShouldScrollOnMainThread(true);
1009 contentLayer->setScrollable(false); 1008 contentLayer->setScrollable(false);
1010 1009
1011 scoped_ptr<CCLayerImpl> scrollLayer = createScrollableLayer(2, surfaceSize); 1010 OwnPtr<CCLayerImpl> scrollLayer = createScrollableLayer(2, surfaceSize);
1012 scrollLayer->addChild(contentLayer.Pass()); 1011 scrollLayer->addChild(contentLayer.release());
1013 1012
1014 m_hostImpl->setRootLayer(scrollLayer.Pass()); 1013 m_hostImpl->setRootLayer(scrollLayer.release());
1015 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1014 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1016 initializeRendererAndDrawFrame(); 1015 initializeRendererAndDrawFrame();
1017 1016
1018 // Scrolling fails because the content layer is asking to be scrolled on the main thread. 1017 // Scrolling fails because the content layer is asking to be scrolled on the main thread.
1019 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollOnMainThread); 1018 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollOnMainThread);
1020 } 1019 }
1021 1020
1022 TEST_F(CCLayerTreeHostImplTest, scrollRootAndChangePageScaleOnMainThread) 1021 TEST_F(CCLayerTreeHostImplTest, scrollRootAndChangePageScaleOnMainThread)
1023 { 1022 {
1024 IntSize surfaceSize(10, 10); 1023 IntSize surfaceSize(10, 10);
1025 float pageScale = 2; 1024 float pageScale = 2;
1026 scoped_ptr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize); 1025 OwnPtr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize);
1027 m_hostImpl->setRootLayer(root.Pass()); 1026 m_hostImpl->setRootLayer(root.release());
1028 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1027 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1029 initializeRendererAndDrawFrame(); 1028 initializeRendererAndDrawFrame();
1030 1029
1031 IntSize scrollDelta(0, 10); 1030 IntSize scrollDelta(0, 10);
1032 IntSize expectedScrollDelta(scrollDelta); 1031 IntSize expectedScrollDelta(scrollDelta);
1033 IntSize expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollPosition()); 1032 IntSize expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollPosition());
1034 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted); 1033 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted);
1035 m_hostImpl->scrollBy(IntPoint(), scrollDelta); 1034 m_hostImpl->scrollBy(IntPoint(), scrollDelta);
1036 m_hostImpl->scrollEnd(); 1035 m_hostImpl->scrollEnd();
1037 1036
1038 // Set new page scale from main thread. 1037 // Set new page scale from main thread.
1039 m_hostImpl->setPageScaleFactorAndLimits(pageScale, pageScale, pageScale); 1038 m_hostImpl->setPageScaleFactorAndLimits(pageScale, pageScale, pageScale);
1040 1039
1041 // The scale should apply to the scroll delta. 1040 // The scale should apply to the scroll delta.
1042 expectedScrollDelta.scale(pageScale); 1041 expectedScrollDelta.scale(pageScale);
1043 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); 1042 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
1044 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); 1043 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta);
1045 1044
1046 // The scroll range should also have been updated. 1045 // The scroll range should also have been updated.
1047 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), expectedMaxScroll); 1046 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), expectedMaxScroll);
1048 1047
1049 // The page scale delta remains constant because the impl thread did not sca le. 1048 // The page scale delta remains constant because the impl thread did not sca le.
1050 EXPECT_EQ(m_hostImpl->rootLayer()->pageScaleDelta(), 1); 1049 EXPECT_EQ(m_hostImpl->rootLayer()->pageScaleDelta(), 1);
1051 } 1050 }
1052 1051
1053 TEST_F(CCLayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread) 1052 TEST_F(CCLayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread)
1054 { 1053 {
1055 IntSize surfaceSize(10, 10); 1054 IntSize surfaceSize(10, 10);
1056 float pageScale = 2; 1055 float pageScale = 2;
1057 scoped_ptr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize); 1056 OwnPtr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize);
1058 m_hostImpl->setRootLayer(root.Pass()); 1057 m_hostImpl->setRootLayer(root.release());
1059 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1058 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1060 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); 1059 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
1061 initializeRendererAndDrawFrame(); 1060 initializeRendererAndDrawFrame();
1062 1061
1063 IntSize scrollDelta(0, 10); 1062 IntSize scrollDelta(0, 10);
1064 IntSize expectedScrollDelta(scrollDelta); 1063 IntSize expectedScrollDelta(scrollDelta);
1065 IntSize expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollPosition()); 1064 IntSize expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollPosition());
1066 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted); 1065 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted);
1067 m_hostImpl->scrollBy(IntPoint(), scrollDelta); 1066 m_hostImpl->scrollBy(IntPoint(), scrollDelta);
1068 m_hostImpl->scrollEnd(); 1067 m_hostImpl->scrollEnd();
(...skipping 18 matching lines...) Expand all
1087 { 1086 {
1088 IntSize surfaceSize(10, 10); 1087 IntSize surfaceSize(10, 10);
1089 float defaultPageScale = 1; 1088 float defaultPageScale = 1;
1090 float newPageScale = 2; 1089 float newPageScale = 2;
1091 1090
1092 // Create a normal scrollable root layer and another scrollable child layer. 1091 // Create a normal scrollable root layer and another scrollable child layer.
1093 setupScrollAndContentsLayers(surfaceSize); 1092 setupScrollAndContentsLayers(surfaceSize);
1094 CCLayerImpl* root = m_hostImpl->rootLayer(); 1093 CCLayerImpl* root = m_hostImpl->rootLayer();
1095 CCLayerImpl* child = root->children()[0]; 1094 CCLayerImpl* child = root->children()[0];
1096 1095
1097 scoped_ptr<CCLayerImpl> scrollableChild = createScrollableLayer(3, surfaceSi ze); 1096 OwnPtr<CCLayerImpl> scrollableChild = createScrollableLayer(3, surfaceSize);
1098 child->addChild(scrollableChild.Pass()); 1097 child->addChild(scrollableChild.release());
1099 CCLayerImpl* grandChild = child->children()[0]; 1098 CCLayerImpl* grandChild = child->children()[0];
1100 1099
1101 // Set new page scale on impl thread by pinching. 1100 // Set new page scale on impl thread by pinching.
1102 m_hostImpl->pinchGestureBegin(); 1101 m_hostImpl->pinchGestureBegin();
1103 m_hostImpl->pinchGestureUpdate(newPageScale, IntPoint()); 1102 m_hostImpl->pinchGestureUpdate(newPageScale, IntPoint());
1104 m_hostImpl->pinchGestureEnd(); 1103 m_hostImpl->pinchGestureEnd();
1105 1104
1106 // The page scale delta should only be applied to the scrollable root layer. 1105 // The page scale delta should only be applied to the scrollable root layer.
1107 EXPECT_EQ(root->pageScaleDelta(), newPageScale); 1106 EXPECT_EQ(root->pageScaleDelta(), newPageScale);
1108 EXPECT_EQ(child->pageScaleDelta(), defaultPageScale); 1107 EXPECT_EQ(child->pageScaleDelta(), defaultPageScale);
(...skipping 10 matching lines...) Expand all
1119 EXPECT_EQ(root->drawTransform().m22(), newPageScale); 1118 EXPECT_EQ(root->drawTransform().m22(), newPageScale);
1120 EXPECT_EQ(child->drawTransform().m11(), newPageScale); 1119 EXPECT_EQ(child->drawTransform().m11(), newPageScale);
1121 EXPECT_EQ(child->drawTransform().m22(), newPageScale); 1120 EXPECT_EQ(child->drawTransform().m22(), newPageScale);
1122 EXPECT_EQ(grandChild->drawTransform().m11(), newPageScale); 1121 EXPECT_EQ(grandChild->drawTransform().m11(), newPageScale);
1123 EXPECT_EQ(grandChild->drawTransform().m22(), newPageScale); 1122 EXPECT_EQ(grandChild->drawTransform().m22(), newPageScale);
1124 } 1123 }
1125 1124
1126 TEST_F(CCLayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread) 1125 TEST_F(CCLayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread)
1127 { 1126 {
1128 IntSize surfaceSize(10, 10); 1127 IntSize surfaceSize(10, 10);
1129 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); 1128 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
1130 root->setBounds(surfaceSize); 1129 root->setBounds(surfaceSize);
1131 root->setContentBounds(surfaceSize); 1130 root->setContentBounds(surfaceSize);
1132 // Also mark the root scrollable so it becomes the root scroll layer. 1131 // Also mark the root scrollable so it becomes the root scroll layer.
1133 root->setScrollable(true); 1132 root->setScrollable(true);
1134 int scrollLayerId = 2; 1133 int scrollLayerId = 2;
1135 root->addChild(createScrollableLayer(scrollLayerId, surfaceSize)); 1134 root->addChild(createScrollableLayer(scrollLayerId, surfaceSize));
1136 m_hostImpl->setRootLayer(root.Pass()); 1135 m_hostImpl->setRootLayer(root.release());
1137 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1136 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1138 initializeRendererAndDrawFrame(); 1137 initializeRendererAndDrawFrame();
1139 1138
1140 CCLayerImpl* child = m_hostImpl->rootLayer()->children()[0]; 1139 CCLayerImpl* child = m_hostImpl->rootLayer()->children()[0];
1141 1140
1142 IntSize scrollDelta(0, 10); 1141 IntSize scrollDelta(0, 10);
1143 IntSize expectedScrollDelta(scrollDelta); 1142 IntSize expectedScrollDelta(scrollDelta);
1144 IntSize expectedMaxScroll(child->maxScrollPosition()); 1143 IntSize expectedMaxScroll(child->maxScrollPosition());
1145 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted); 1144 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted);
1146 m_hostImpl->scrollBy(IntPoint(), scrollDelta); 1145 m_hostImpl->scrollBy(IntPoint(), scrollDelta);
(...skipping 13 matching lines...) Expand all
1160 // The page scale delta remains constant because the impl thread did not sca le. 1159 // The page scale delta remains constant because the impl thread did not sca le.
1161 EXPECT_EQ(child->pageScaleDelta(), 1); 1160 EXPECT_EQ(child->pageScaleDelta(), 1);
1162 } 1161 }
1163 1162
1164 TEST_F(CCLayerTreeHostImplTest, scrollChildBeyondLimit) 1163 TEST_F(CCLayerTreeHostImplTest, scrollChildBeyondLimit)
1165 { 1164 {
1166 // Scroll a child layer beyond its maximum scroll range and make sure the 1165 // Scroll a child layer beyond its maximum scroll range and make sure the
1167 // parent layer is scrolled on the axis on which the child was unable to 1166 // parent layer is scrolled on the axis on which the child was unable to
1168 // scroll. 1167 // scroll.
1169 IntSize surfaceSize(10, 10); 1168 IntSize surfaceSize(10, 10);
1170 scoped_ptr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize); 1169 OwnPtr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize);
1171 1170
1172 scoped_ptr<CCLayerImpl> grandChild = createScrollableLayer(3, surfaceSize); 1171 OwnPtr<CCLayerImpl> grandChild = createScrollableLayer(3, surfaceSize);
1173 grandChild->setScrollPosition(IntPoint(0, 5)); 1172 grandChild->setScrollPosition(IntPoint(0, 5));
1174 1173
1175 scoped_ptr<CCLayerImpl> child = createScrollableLayer(2, surfaceSize); 1174 OwnPtr<CCLayerImpl> child = createScrollableLayer(2, surfaceSize);
1176 child->setScrollPosition(IntPoint(3, 0)); 1175 child->setScrollPosition(IntPoint(3, 0));
1177 child->addChild(grandChild.Pass()); 1176 child->addChild(grandChild.release());
1178 1177
1179 root->addChild(child.Pass()); 1178 root->addChild(child.release());
1180 m_hostImpl->setRootLayer(root.Pass()); 1179 m_hostImpl->setRootLayer(root.release());
1181 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1180 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1182 initializeRendererAndDrawFrame(); 1181 initializeRendererAndDrawFrame();
1183 { 1182 {
1184 IntSize scrollDelta(-8, -7); 1183 IntSize scrollDelta(-8, -7);
1185 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient:: Wheel), CCInputHandlerClient::ScrollStarted); 1184 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient:: Wheel), CCInputHandlerClient::ScrollStarted);
1186 m_hostImpl->scrollBy(IntPoint(), scrollDelta); 1185 m_hostImpl->scrollBy(IntPoint(), scrollDelta);
1187 m_hostImpl->scrollEnd(); 1186 m_hostImpl->scrollEnd();
1188 1187
1189 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); 1188 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas ();
1190 1189
1191 // The grand child should have scrolled up to its limit. 1190 // The grand child should have scrolled up to its limit.
1192 CCLayerImpl* child = m_hostImpl->rootLayer()->children()[0]; 1191 CCLayerImpl* child = m_hostImpl->rootLayer()->children()[0];
1193 CCLayerImpl* grandChild = child->children()[0]; 1192 CCLayerImpl* grandChild = child->children()[0];
1194 expectContains(*scrollInfo.get(), grandChild->id(), IntSize(0, -5)); 1193 expectContains(*scrollInfo.get(), grandChild->id(), IntSize(0, -5));
1195 1194
1196 // The child should have only scrolled on the other axis. 1195 // The child should have only scrolled on the other axis.
1197 expectContains(*scrollInfo.get(), child->id(), IntSize(-3, 0)); 1196 expectContains(*scrollInfo.get(), child->id(), IntSize(-3, 0));
1198 } 1197 }
1199 } 1198 }
1200 1199
1201 TEST_F(CCLayerTreeHostImplTest, scrollEventBubbling) 1200 TEST_F(CCLayerTreeHostImplTest, scrollEventBubbling)
1202 { 1201 {
1203 // When we try to scroll a non-scrollable child layer, the scroll delta 1202 // When we try to scroll a non-scrollable child layer, the scroll delta
1204 // should be applied to one of its ancestors if possible. 1203 // should be applied to one of its ancestors if possible.
1205 IntSize surfaceSize(10, 10); 1204 IntSize surfaceSize(10, 10);
1206 scoped_ptr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize); 1205 OwnPtr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize);
1207 scoped_ptr<CCLayerImpl> child = createScrollableLayer(2, surfaceSize); 1206 OwnPtr<CCLayerImpl> child = createScrollableLayer(2, surfaceSize);
1208 1207
1209 child->setScrollable(false); 1208 child->setScrollable(false);
1210 root->addChild(child.Pass()); 1209 root->addChild(child.release());
1211 1210
1212 m_hostImpl->setRootLayer(root.Pass()); 1211 m_hostImpl->setRootLayer(root.release());
1213 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1212 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1214 initializeRendererAndDrawFrame(); 1213 initializeRendererAndDrawFrame();
1215 { 1214 {
1216 IntSize scrollDelta(0, 4); 1215 IntSize scrollDelta(0, 4);
1217 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient:: Wheel), CCInputHandlerClient::ScrollStarted); 1216 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient:: Wheel), CCInputHandlerClient::ScrollStarted);
1218 m_hostImpl->scrollBy(IntPoint(), scrollDelta); 1217 m_hostImpl->scrollBy(IntPoint(), scrollDelta);
1219 m_hostImpl->scrollEnd(); 1218 m_hostImpl->scrollEnd();
1220 1219
1221 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); 1220 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas ();
1222 1221
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1276 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), wheelScroll Delta); 1275 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), wheelScroll Delta);
1277 } 1276 }
1278 1277
1279 TEST_F(CCLayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer) 1278 TEST_F(CCLayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer)
1280 { 1279 {
1281 setupScrollAndContentsLayers(IntSize(100, 100)); 1280 setupScrollAndContentsLayers(IntSize(100, 100));
1282 int childLayerId = 3; 1281 int childLayerId = 3;
1283 float childLayerAngle = -20; 1282 float childLayerAngle = -20;
1284 1283
1285 // Create a child layer that is rotated to a non-axis-aligned angle. 1284 // Create a child layer that is rotated to a non-axis-aligned angle.
1286 scoped_ptr<CCLayerImpl> child = createScrollableLayer(childLayerId, m_hostIm pl->rootLayer()->contentBounds()); 1285 OwnPtr<CCLayerImpl> child = createScrollableLayer(childLayerId, m_hostImpl-> rootLayer()->contentBounds());
1287 WebTransformationMatrix rotateTransform; 1286 WebTransformationMatrix rotateTransform;
1288 rotateTransform.translate(-50, -50); 1287 rotateTransform.translate(-50, -50);
1289 rotateTransform.rotate(childLayerAngle); 1288 rotateTransform.rotate(childLayerAngle);
1290 rotateTransform.translate(50, 50); 1289 rotateTransform.translate(50, 50);
1291 child->setTransform(rotateTransform); 1290 child->setTransform(rotateTransform);
1292 1291
1293 // Only allow vertical scrolling. 1292 // Only allow vertical scrolling.
1294 child->setMaxScrollPosition(IntSize(0, child->contentBounds().height())); 1293 child->setMaxScrollPosition(IntSize(0, child->contentBounds().height()));
1295 m_hostImpl->rootLayer()->addChild(child.Pass()); 1294 m_hostImpl->rootLayer()->addChild(child.release());
1296 1295
1297 IntSize surfaceSize(50, 50); 1296 IntSize surfaceSize(50, 50);
1298 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1297 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1299 initializeRendererAndDrawFrame(); 1298 initializeRendererAndDrawFrame();
1300 1299
1301 { 1300 {
1302 // Scroll down in screen coordinates with a gesture. 1301 // Scroll down in screen coordinates with a gesture.
1303 IntSize gestureScrollDelta(0, 10); 1302 IntSize gestureScrollDelta(0, 10);
1304 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient:: Gesture), CCInputHandlerClient::ScrollStarted); 1303 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient:: Gesture), CCInputHandlerClient::ScrollStarted);
1305 m_hostImpl->scrollBy(IntPoint(), gestureScrollDelta); 1304 m_hostImpl->scrollBy(IntPoint(), gestureScrollDelta);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1390 } 1389 }
1391 1390
1392 bool blend() const { return m_blend; } 1391 bool blend() const { return m_blend; }
1393 1392
1394 private: 1393 private:
1395 bool m_blend; 1394 bool m_blend;
1396 }; 1395 };
1397 1396
1398 class BlendStateCheckLayer : public CCLayerImpl { 1397 class BlendStateCheckLayer : public CCLayerImpl {
1399 public: 1398 public:
1400 static scoped_ptr<CCLayerImpl> create(int id, CCResourceProvider* resourcePr ovider) { return scoped_ptr<CCLayerImpl>(new BlendStateCheckLayer(id, resourcePr ovider)); } 1399 static PassOwnPtr<BlendStateCheckLayer> create(int id, CCResourceProvider* r esourceProvider) { return adoptPtr(new BlendStateCheckLayer(id, resourceProvider )); }
1401 1400
1402 virtual void appendQuads(CCQuadSink& quadSink, CCAppendQuadsData& appendQuad sData) OVERRIDE 1401 virtual void appendQuads(CCQuadSink& quadSink, CCAppendQuadsData& appendQuad sData) OVERRIDE
1403 { 1402 {
1404 m_quadsAppended = true; 1403 m_quadsAppended = true;
1405 1404
1406 IntRect opaqueRect; 1405 IntRect opaqueRect;
1407 if (contentsOpaque()) 1406 if (contentsOpaque())
1408 opaqueRect = m_quadRect; 1407 opaqueRect = m_quadRect;
1409 else 1408 else
1410 opaqueRect = m_opaqueContentRect; 1409 opaqueRect = m_opaqueContentRect;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1451 bool m_quadsAppended; 1450 bool m_quadsAppended;
1452 IntRect m_quadRect; 1451 IntRect m_quadRect;
1453 IntRect m_opaqueContentRect; 1452 IntRect m_opaqueContentRect;
1454 IntRect m_quadVisibleRect; 1453 IntRect m_quadVisibleRect;
1455 CCResourceProvider::ResourceId m_resourceId; 1454 CCResourceProvider::ResourceId m_resourceId;
1456 }; 1455 };
1457 1456
1458 TEST_F(CCLayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers) 1457 TEST_F(CCLayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers)
1459 { 1458 {
1460 { 1459 {
1461 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); 1460 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
1462 root->setAnchorPoint(FloatPoint(0, 0)); 1461 root->setAnchorPoint(FloatPoint(0, 0));
1463 root->setBounds(IntSize(10, 10)); 1462 root->setBounds(IntSize(10, 10));
1464 root->setContentBounds(root->bounds()); 1463 root->setContentBounds(root->bounds());
1465 root->setDrawsContent(false); 1464 root->setDrawsContent(false);
1466 m_hostImpl->setRootLayer(root.Pass()); 1465 m_hostImpl->setRootLayer(root.release());
1467 } 1466 }
1468 CCLayerImpl* root = m_hostImpl->rootLayer(); 1467 CCLayerImpl* root = m_hostImpl->rootLayer();
1469 1468
1470 root->addChild(BlendStateCheckLayer::create(2, m_hostImpl->resourceProvider( ))); 1469 root->addChild(BlendStateCheckLayer::create(2, m_hostImpl->resourceProvider( )));
1471 BlendStateCheckLayer* layer1 = static_cast<BlendStateCheckLayer*>(root->chil dren()[0]); 1470 BlendStateCheckLayer* layer1 = static_cast<BlendStateCheckLayer*>(root->chil dren()[0]);
1472 layer1->setPosition(FloatPoint(2, 2)); 1471 layer1->setPosition(FloatPoint(2, 2));
1473 1472
1474 CCLayerTreeHostImpl::FrameData frame; 1473 CCLayerTreeHostImpl::FrameData frame;
1475 1474
1476 // Opaque layer, drawn without blending. 1475 // Opaque layer, drawn without blending.
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
1743 } 1742 }
1744 1743
1745 bool reshapeCalled() const { return m_reshapeCalled; } 1744 bool reshapeCalled() const { return m_reshapeCalled; }
1746 1745
1747 private: 1746 private:
1748 bool m_reshapeCalled; 1747 bool m_reshapeCalled;
1749 }; 1748 };
1750 1749
1751 class FakeDrawableCCLayerImpl: public CCLayerImpl { 1750 class FakeDrawableCCLayerImpl: public CCLayerImpl {
1752 public: 1751 public:
1753 static scoped_ptr<CCLayerImpl> create(int id) { return scoped_ptr<CCLayerImp l>(new FakeDrawableCCLayerImpl(id)); }
1754 protected:
1755 explicit FakeDrawableCCLayerImpl(int id) : CCLayerImpl(id) { } 1752 explicit FakeDrawableCCLayerImpl(int id) : CCLayerImpl(id) { }
1756 }; 1753 };
1757 1754
1758 // Only reshape when we know we are going to draw. Otherwise, the reshape 1755 // Only reshape when we know we are going to draw. Otherwise, the reshape
1759 // can leave the window at the wrong size if we never draw and the proper 1756 // can leave the window at the wrong size if we never draw and the proper
1760 // viewport size is never set. 1757 // viewport size is never set.
1761 TEST_F(CCLayerTreeHostImplTest, reshapeNotCalledUntilDraw) 1758 TEST_F(CCLayerTreeHostImplTest, reshapeNotCalledUntilDraw)
1762 { 1759 {
1763 scoped_ptr<CCGraphicsContext> ccContext = FakeWebCompositorOutputSurface::cr eate(adoptPtr(new ReshapeTrackerContext)).PassAs<CCGraphicsContext>(); 1760 scoped_ptr<CCGraphicsContext> ccContext = FakeWebCompositorOutputSurface::cr eate(adoptPtr(new ReshapeTrackerContext)).PassAs<CCGraphicsContext>();
1764 ReshapeTrackerContext* reshapeTracker = static_cast<ReshapeTrackerContext*>( ccContext->context3D()); 1761 ReshapeTrackerContext* reshapeTracker = static_cast<ReshapeTrackerContext*>( ccContext->context3D());
1765 m_hostImpl->initializeRenderer(ccContext.Pass()); 1762 m_hostImpl->initializeRenderer(ccContext.Pass());
1766 1763
1767 scoped_ptr<CCLayerImpl> root = FakeDrawableCCLayerImpl::create(1); 1764 CCLayerImpl* root = new FakeDrawableCCLayerImpl(1);
1768 root->setAnchorPoint(FloatPoint(0, 0)); 1765 root->setAnchorPoint(FloatPoint(0, 0));
1769 root->setBounds(IntSize(10, 10)); 1766 root->setBounds(IntSize(10, 10));
1770 root->setDrawsContent(true); 1767 root->setDrawsContent(true);
1771 m_hostImpl->setRootLayer(root.Pass()); 1768 m_hostImpl->setRootLayer(adoptPtr(root));
1772 EXPECT_FALSE(reshapeTracker->reshapeCalled()); 1769 EXPECT_FALSE(reshapeTracker->reshapeCalled());
1773 1770
1774 CCLayerTreeHostImpl::FrameData frame; 1771 CCLayerTreeHostImpl::FrameData frame;
1775 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 1772 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
1776 m_hostImpl->drawLayers(frame); 1773 m_hostImpl->drawLayers(frame);
1777 EXPECT_TRUE(reshapeTracker->reshapeCalled()); 1774 EXPECT_TRUE(reshapeTracker->reshapeCalled());
1778 m_hostImpl->didDrawAllLayers(frame); 1775 m_hostImpl->didDrawAllLayers(frame);
1779 } 1776 }
1780 1777
1781 class PartialSwapTrackerContext : public FakeWebGraphicsContext3D { 1778 class PartialSwapTrackerContext : public FakeWebGraphicsContext3D {
(...skipping 25 matching lines...) Expand all
1807 PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrack erContext*>(ccContext->context3D()); 1804 PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrack erContext*>(ccContext->context3D());
1808 1805
1809 // This test creates its own CCLayerTreeHostImpl, so 1806 // This test creates its own CCLayerTreeHostImpl, so
1810 // that we can force partial swap enabled. 1807 // that we can force partial swap enabled.
1811 CCLayerTreeSettings settings; 1808 CCLayerTreeSettings settings;
1812 CCSettings::setPartialSwapEnabled(true); 1809 CCSettings::setPartialSwapEnabled(true);
1813 scoped_ptr<CCLayerTreeHostImpl> layerTreeHostImpl = CCLayerTreeHostImpl::cre ate(settings, this); 1810 scoped_ptr<CCLayerTreeHostImpl> layerTreeHostImpl = CCLayerTreeHostImpl::cre ate(settings, this);
1814 layerTreeHostImpl->initializeRenderer(ccContext.Pass()); 1811 layerTreeHostImpl->initializeRenderer(ccContext.Pass());
1815 layerTreeHostImpl->setViewportSize(IntSize(500, 500), IntSize(500, 500)); 1812 layerTreeHostImpl->setViewportSize(IntSize(500, 500), IntSize(500, 500));
1816 1813
1817 scoped_ptr<CCLayerImpl> root = FakeDrawableCCLayerImpl::create(1); 1814 CCLayerImpl* root = new FakeDrawableCCLayerImpl(1);
1818 scoped_ptr<CCLayerImpl> child = FakeDrawableCCLayerImpl::create(2); 1815 CCLayerImpl* child = new FakeDrawableCCLayerImpl(2);
1819 child->setPosition(FloatPoint(12, 13)); 1816 child->setPosition(FloatPoint(12, 13));
1820 child->setAnchorPoint(FloatPoint(0, 0)); 1817 child->setAnchorPoint(FloatPoint(0, 0));
1821 child->setBounds(IntSize(14, 15)); 1818 child->setBounds(IntSize(14, 15));
1822 child->setContentBounds(IntSize(14, 15)); 1819 child->setContentBounds(IntSize(14, 15));
1823 child->setDrawsContent(true); 1820 child->setDrawsContent(true);
1824 root->setAnchorPoint(FloatPoint(0, 0)); 1821 root->setAnchorPoint(FloatPoint(0, 0));
1825 root->setBounds(IntSize(500, 500)); 1822 root->setBounds(IntSize(500, 500));
1826 root->setContentBounds(IntSize(500, 500)); 1823 root->setContentBounds(IntSize(500, 500));
1827 root->setDrawsContent(true); 1824 root->setDrawsContent(true);
1828 root->addChild(child.Pass()); 1825 root->addChild(adoptPtr(child));
1829 layerTreeHostImpl->setRootLayer(root.Pass()); 1826 layerTreeHostImpl->setRootLayer(adoptPtr(root));
1830 1827
1831 CCLayerTreeHostImpl::FrameData frame; 1828 CCLayerTreeHostImpl::FrameData frame;
1832 1829
1833 // First frame, the entire screen should get swapped. 1830 // First frame, the entire screen should get swapped.
1834 EXPECT_TRUE(layerTreeHostImpl->prepareToDraw(frame)); 1831 EXPECT_TRUE(layerTreeHostImpl->prepareToDraw(frame));
1835 layerTreeHostImpl->drawLayers(frame); 1832 layerTreeHostImpl->drawLayers(frame);
1836 layerTreeHostImpl->didDrawAllLayers(frame); 1833 layerTreeHostImpl->didDrawAllLayers(frame);
1837 layerTreeHostImpl->swapBuffers(); 1834 layerTreeHostImpl->swapBuffers();
1838 IntRect actualSwapRect = partialSwapTracker->partialSwapRect(); 1835 IntRect actualSwapRect = partialSwapTracker->partialSwapRect();
1839 IntRect expectedSwapRect = IntRect(IntPoint::zero(), IntSize(500, 500)); 1836 IntRect expectedSwapRect = IntRect(IntPoint::zero(), IntSize(500, 500));
(...skipping 30 matching lines...) Expand all
1870 actualSwapRect = partialSwapTracker->partialSwapRect(); 1867 actualSwapRect = partialSwapTracker->partialSwapRect();
1871 expectedSwapRect = IntRect(IntPoint::zero(), IntSize(10, 10)); 1868 expectedSwapRect = IntRect(IntPoint::zero(), IntSize(10, 10));
1872 EXPECT_EQ(expectedSwapRect.x(), actualSwapRect.x()); 1869 EXPECT_EQ(expectedSwapRect.x(), actualSwapRect.x());
1873 EXPECT_EQ(expectedSwapRect.y(), actualSwapRect.y()); 1870 EXPECT_EQ(expectedSwapRect.y(), actualSwapRect.y());
1874 EXPECT_EQ(expectedSwapRect.width(), actualSwapRect.width()); 1871 EXPECT_EQ(expectedSwapRect.width(), actualSwapRect.width());
1875 EXPECT_EQ(expectedSwapRect.height(), actualSwapRect.height()); 1872 EXPECT_EQ(expectedSwapRect.height(), actualSwapRect.height());
1876 } 1873 }
1877 1874
1878 TEST_F(CCLayerTreeHostImplTest, rootLayerDoesntCreateExtraSurface) 1875 TEST_F(CCLayerTreeHostImplTest, rootLayerDoesntCreateExtraSurface)
1879 { 1876 {
1880 scoped_ptr<CCLayerImpl> root = FakeDrawableCCLayerImpl::create(1); 1877 CCLayerImpl* root = new FakeDrawableCCLayerImpl(1);
1881 scoped_ptr<CCLayerImpl> child = FakeDrawableCCLayerImpl::create(2); 1878 CCLayerImpl* child = new FakeDrawableCCLayerImpl(2);
1882 child->setAnchorPoint(FloatPoint(0, 0)); 1879 child->setAnchorPoint(FloatPoint(0, 0));
1883 child->setBounds(IntSize(10, 10)); 1880 child->setBounds(IntSize(10, 10));
1884 child->setContentBounds(IntSize(10, 10)); 1881 child->setContentBounds(IntSize(10, 10));
1885 child->setDrawsContent(true); 1882 child->setDrawsContent(true);
1886 root->setAnchorPoint(FloatPoint(0, 0)); 1883 root->setAnchorPoint(FloatPoint(0, 0));
1887 root->setBounds(IntSize(10, 10)); 1884 root->setBounds(IntSize(10, 10));
1888 root->setContentBounds(IntSize(10, 10)); 1885 root->setContentBounds(IntSize(10, 10));
1889 root->setDrawsContent(true); 1886 root->setDrawsContent(true);
1890 root->setOpacity(0.7f); 1887 root->setOpacity(0.7f);
1891 root->addChild(child.Pass()); 1888 root->addChild(adoptPtr(child));
1892 1889
1893 m_hostImpl->setRootLayer(root.Pass()); 1890 m_hostImpl->setRootLayer(adoptPtr(root));
1894 1891
1895 CCLayerTreeHostImpl::FrameData frame; 1892 CCLayerTreeHostImpl::FrameData frame;
1896 1893
1897 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 1894 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
1898 EXPECT_EQ(1u, frame.renderSurfaceLayerList->size()); 1895 EXPECT_EQ(1u, frame.renderSurfaceLayerList->size());
1899 EXPECT_EQ(1u, frame.renderPasses.size()); 1896 EXPECT_EQ(1u, frame.renderPasses.size());
1900 m_hostImpl->didDrawAllLayers(frame); 1897 m_hostImpl->didDrawAllLayers(frame);
1901 } 1898 }
1902 1899
1903 } // namespace 1900 } // namespace
1904 1901
1905 class FakeLayerWithQuads : public CCLayerImpl { 1902 class FakeLayerWithQuads : public CCLayerImpl {
1906 public: 1903 public:
1907 static scoped_ptr<CCLayerImpl> create(int id) { return scoped_ptr<CCLayerImp l>(new FakeLayerWithQuads(id)); } 1904 static PassOwnPtr<FakeLayerWithQuads> create(int id) { return adoptPtr(new F akeLayerWithQuads(id)); }
1908 1905
1909 virtual void appendQuads(CCQuadSink& quadSink, CCAppendQuadsData& appendQuad sData) OVERRIDE 1906 virtual void appendQuads(CCQuadSink& quadSink, CCAppendQuadsData& appendQuad sData) OVERRIDE
1910 { 1907 {
1911 CCSharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createS haredQuadState()); 1908 CCSharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createS haredQuadState());
1912 1909
1913 SkColor gray = SkColorSetRGB(100, 100, 100); 1910 SkColor gray = SkColorSetRGB(100, 100, 100);
1914 IntRect quadRect(IntPoint(0, 0), contentBounds()); 1911 IntRect quadRect(IntPoint(0, 0), contentBounds());
1915 scoped_ptr<CCSolidColorDrawQuad> myQuad = CCSolidColorDrawQuad::create(s haredQuadState, quadRect, gray); 1912 scoped_ptr<CCSolidColorDrawQuad> myQuad = CCSolidColorDrawQuad::create(s haredQuadState, quadRect, gray);
1916 quadSink.append(myQuad.PassAs<CCDrawQuad>(), appendQuadsData); 1913 quadSink.append(myQuad.PassAs<CCDrawQuad>(), appendQuadsData);
1917 } 1914 }
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
2112 | | | 3 | 2109 | | | 3 |
2113 | | +-------------------+ 2110 | | +-------------------+
2114 | | | | 2111 | | | |
2115 | +-----------+ | 2112 | +-----------+ |
2116 | | 2113 | |
2117 | | 2114 | |
2118 +--------------------+ 2115 +--------------------+
2119 2116
2120 Layers 1, 2 have render surfaces 2117 Layers 1, 2 have render surfaces
2121 */ 2118 */
2122 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); 2119 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
2123 scoped_ptr<CCLayerImpl> child = CCLayerImpl::create(2); 2120 OwnPtr<CCLayerImpl> child = CCLayerImpl::create(2);
2124 scoped_ptr<CCLayerImpl> grandChild = FakeLayerWithQuads::create(3); 2121 OwnPtr<CCLayerImpl> grandChild = FakeLayerWithQuads::create(3);
2125 2122
2126 IntRect rootRect(0, 0, 100, 100); 2123 IntRect rootRect(0, 0, 100, 100);
2127 IntRect childRect(10, 10, 50, 50); 2124 IntRect childRect(10, 10, 50, 50);
2128 IntRect grandChildRect(5, 5, 150, 150); 2125 IntRect grandChildRect(5, 5, 150, 150);
2129 2126
2130 root->createRenderSurface(); 2127 root->createRenderSurface();
2131 root->setAnchorPoint(FloatPoint(0, 0)); 2128 root->setAnchorPoint(FloatPoint(0, 0));
2132 root->setPosition(FloatPoint(rootRect.x(), rootRect.y())); 2129 root->setPosition(FloatPoint(rootRect.x(), rootRect.y()));
2133 root->setBounds(IntSize(rootRect.width(), rootRect.height())); 2130 root->setBounds(IntSize(rootRect.width(), rootRect.height()));
2134 root->setContentBounds(root->bounds()); 2131 root->setContentBounds(root->bounds());
2135 root->setVisibleContentRect(rootRect); 2132 root->setVisibleContentRect(rootRect);
2136 root->setDrawsContent(false); 2133 root->setDrawsContent(false);
2137 root->renderSurface()->setContentRect(IntRect(IntPoint(), IntSize(rootRect.w idth(), rootRect.height()))); 2134 root->renderSurface()->setContentRect(IntRect(IntPoint(), IntSize(rootRect.w idth(), rootRect.height())));
2138 2135
2139 child->setAnchorPoint(FloatPoint(0, 0)); 2136 child->setAnchorPoint(FloatPoint(0, 0));
2140 child->setPosition(FloatPoint(childRect.x(), childRect.y())); 2137 child->setPosition(FloatPoint(childRect.x(), childRect.y()));
2141 child->setOpacity(0.5f); 2138 child->setOpacity(0.5f);
2142 child->setBounds(IntSize(childRect.width(), childRect.height())); 2139 child->setBounds(IntSize(childRect.width(), childRect.height()));
2143 child->setContentBounds(child->bounds()); 2140 child->setContentBounds(child->bounds());
2144 child->setVisibleContentRect(childRect); 2141 child->setVisibleContentRect(childRect);
2145 child->setDrawsContent(false); 2142 child->setDrawsContent(false);
2146 2143
2147 grandChild->setAnchorPoint(FloatPoint(0, 0)); 2144 grandChild->setAnchorPoint(FloatPoint(0, 0));
2148 grandChild->setPosition(IntPoint(grandChildRect.x(), grandChildRect.y())); 2145 grandChild->setPosition(IntPoint(grandChildRect.x(), grandChildRect.y()));
2149 grandChild->setBounds(IntSize(grandChildRect.width(), grandChildRect.height( ))); 2146 grandChild->setBounds(IntSize(grandChildRect.width(), grandChildRect.height( )));
2150 grandChild->setContentBounds(grandChild->bounds()); 2147 grandChild->setContentBounds(grandChild->bounds());
2151 grandChild->setVisibleContentRect(grandChildRect); 2148 grandChild->setVisibleContentRect(grandChildRect);
2152 grandChild->setDrawsContent(true); 2149 grandChild->setDrawsContent(true);
2153 2150
2154 child->addChild(grandChild.Pass()); 2151 child->addChild(grandChild.release());
2155 root->addChild(child.Pass()); 2152 root->addChild(child.release());
2156 2153
2157 myHostImpl->setRootLayer(root.Pass()); 2154 myHostImpl->setRootLayer(root.release());
2158 return myHostImpl.Pass(); 2155 return myHostImpl.Pass();
2159 } 2156 }
2160 2157
2161 TEST_F(CCLayerTreeHostImplTest, contributingLayerEmptyScissorPartialSwap) 2158 TEST_F(CCLayerTreeHostImplTest, contributingLayerEmptyScissorPartialSwap)
2162 { 2159 {
2163 scoped_ptr<CCLayerTreeHostImpl> myHostImpl = setupLayersForOpacity(true, thi s); 2160 scoped_ptr<CCLayerTreeHostImpl> myHostImpl = setupLayersForOpacity(true, thi s);
2164 2161
2165 { 2162 {
2166 CCLayerTreeHostImpl::FrameData frame; 2163 CCLayerTreeHostImpl::FrameData frame;
2167 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 2164 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
(...skipping 28 matching lines...) Expand all
2196 ASSERT_EQ(1U, frame.renderPasses[0]->quadList().size()); 2193 ASSERT_EQ(1U, frame.renderPasses[0]->quadList().size());
2197 ASSERT_EQ(1U, frame.renderPasses[1]->quadList().size()); 2194 ASSERT_EQ(1U, frame.renderPasses[1]->quadList().size());
2198 EXPECT_EQ(CCDrawQuad::SolidColor, frame.renderPasses[0]->quadList()[0]-> material()); 2195 EXPECT_EQ(CCDrawQuad::SolidColor, frame.renderPasses[0]->quadList()[0]-> material());
2199 EXPECT_EQ(CCDrawQuad::RenderPass, frame.renderPasses[1]->quadList()[0]-> material()); 2196 EXPECT_EQ(CCDrawQuad::RenderPass, frame.renderPasses[1]->quadList()[0]-> material());
2200 } 2197 }
2201 } 2198 }
2202 2199
2203 // Make sure that context lost notifications are propagated through the tree. 2200 // Make sure that context lost notifications are propagated through the tree.
2204 class ContextLostNotificationCheckLayer : public CCLayerImpl { 2201 class ContextLostNotificationCheckLayer : public CCLayerImpl {
2205 public: 2202 public:
2206 static scoped_ptr<CCLayerImpl> create(int id) { return scoped_ptr<CCLayerImp l>(new ContextLostNotificationCheckLayer(id)); } 2203 static PassOwnPtr<ContextLostNotificationCheckLayer> create(int id) { return adoptPtr(new ContextLostNotificationCheckLayer(id)); }
2207 2204
2208 virtual void didLoseContext() OVERRIDE 2205 virtual void didLoseContext() OVERRIDE
2209 { 2206 {
2210 m_didLoseContextCalled = true; 2207 m_didLoseContextCalled = true;
2211 } 2208 }
2212 2209
2213 bool didLoseContextCalled() const { return m_didLoseContextCalled; } 2210 bool didLoseContextCalled() const { return m_didLoseContextCalled; }
2214 2211
2215 private: 2212 private:
2216 explicit ContextLostNotificationCheckLayer(int id) 2213 explicit ContextLostNotificationCheckLayer(int id)
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
2471 virtual void splitTrack(WebScrollbar*, const WebRect& track, WebRect& startT rack, WebRect& thumb, WebRect& endTrack) OVERRIDE 2468 virtual void splitTrack(WebScrollbar*, const WebRect& track, WebRect& startT rack, WebRect& thumb, WebRect& endTrack) OVERRIDE
2472 { 2469 {
2473 thumb = WebRect(0, 5, 5, 2); 2470 thumb = WebRect(0, 5, 5, 2);
2474 startTrack = WebRect(0, 5, 0, 5); 2471 startTrack = WebRect(0, 5, 0, 5);
2475 endTrack = WebRect(0, 0, 0, 5); 2472 endTrack = WebRect(0, 0, 0, 5);
2476 } 2473 }
2477 }; 2474 };
2478 2475
2479 class FakeScrollbarLayerImpl : public CCScrollbarLayerImpl { 2476 class FakeScrollbarLayerImpl : public CCScrollbarLayerImpl {
2480 public: 2477 public:
2481 static scoped_ptr<FakeScrollbarLayerImpl> create(int id) 2478 static PassOwnPtr<FakeScrollbarLayerImpl> create(int id)
2482 { 2479 {
2483 return make_scoped_ptr(new FakeScrollbarLayerImpl(id)); 2480 return adoptPtr(new FakeScrollbarLayerImpl(id));
2484 } 2481 }
2485 2482
2486 void createResources(CCResourceProvider* provider) 2483 void createResources(CCResourceProvider* provider)
2487 { 2484 {
2488 ASSERT(provider); 2485 ASSERT(provider);
2489 int pool = 0; 2486 int pool = 0;
2490 IntSize size(10, 10); 2487 IntSize size(10, 10);
2491 GC3Denum format = GraphicsContext3D::RGBA; 2488 GC3Denum format = GraphicsContext3D::RGBA;
2492 CCResourceProvider::TextureUsageHint hint = CCResourceProvider::TextureU sageAny; 2489 CCResourceProvider::TextureUsageHint hint = CCResourceProvider::TextureU sageAny;
2493 setScrollbarGeometry(CCScrollbarGeometryFixedThumb::create(FakeWebScroll barThemeGeometryNonEmpty::create())); 2490 setScrollbarGeometry(CCScrollbarGeometryFixedThumb::create(FakeWebScroll barThemeGeometryNonEmpty::create()));
(...skipping 21 matching lines...) Expand all
2515 static_cast<CCTestRenderPass*>(pass.get())->appendSharedQuadState(sharedStat e.Pass()); 2512 static_cast<CCTestRenderPass*>(pass.get())->appendSharedQuadState(sharedStat e.Pass());
2516 static_cast<CCTestRenderPass*>(pass.get())->appendQuad(quad.PassAs<CCDrawQua d>()); 2513 static_cast<CCTestRenderPass*>(pass.get())->appendQuad(quad.PassAs<CCDrawQua d>());
2517 2514
2518 return pass.Pass(); 2515 return pass.Pass();
2519 } 2516 }
2520 2517
2521 TEST_F(CCLayerTreeHostImplTest, dontUseOldResourcesAfterLostContext) 2518 TEST_F(CCLayerTreeHostImplTest, dontUseOldResourcesAfterLostContext)
2522 { 2519 {
2523 int layerId = 1; 2520 int layerId = 1;
2524 2521
2525 scoped_ptr<CCLayerImpl> rootLayer(CCLayerImpl::create(layerId++)); 2522 OwnPtr<CCLayerImpl> rootLayer(CCLayerImpl::create(layerId++));
2526 rootLayer->setBounds(IntSize(10, 10)); 2523 rootLayer->setBounds(IntSize(10, 10));
2527 rootLayer->setAnchorPoint(FloatPoint(0, 0)); 2524 rootLayer->setAnchorPoint(FloatPoint(0, 0));
2528 2525
2529 scoped_ptr<CCTiledLayerImpl> tileLayer = CCTiledLayerImpl::create(layerId++) ; 2526 OwnPtr<CCTiledLayerImpl> tileLayer = CCTiledLayerImpl::create(layerId++);
2530 tileLayer->setBounds(IntSize(10, 10)); 2527 tileLayer->setBounds(IntSize(10, 10));
2531 tileLayer->setAnchorPoint(FloatPoint(0, 0)); 2528 tileLayer->setAnchorPoint(FloatPoint(0, 0));
2532 tileLayer->setContentBounds(IntSize(10, 10)); 2529 tileLayer->setContentBounds(IntSize(10, 10));
2533 tileLayer->setDrawsContent(true); 2530 tileLayer->setDrawsContent(true);
2534 tileLayer->setSkipsDraw(false); 2531 tileLayer->setSkipsDraw(false);
2535 OwnPtr<CCLayerTilingData> tilingData(CCLayerTilingData::create(IntSize(10, 1 0), CCLayerTilingData::NoBorderTexels)); 2532 OwnPtr<CCLayerTilingData> tilingData(CCLayerTilingData::create(IntSize(10, 1 0), CCLayerTilingData::NoBorderTexels));
2536 tilingData->setBounds(IntSize(10, 10)); 2533 tilingData->setBounds(IntSize(10, 10));
2537 tileLayer->setTilingData(*tilingData); 2534 tileLayer->setTilingData(*tilingData);
2538 tileLayer->pushTileProperties(0, 0, 1, IntRect(0, 0, 10, 10)); 2535 tileLayer->pushTileProperties(0, 0, 1, IntRect(0, 0, 10, 10));
2539 rootLayer->addChild(tileLayer.PassAs<CCLayerImpl>()); 2536 rootLayer->addChild(tileLayer.release());
2540 2537
2541 scoped_ptr<CCTextureLayerImpl> textureLayer = CCTextureLayerImpl::create(lay erId++); 2538 OwnPtr<CCTextureLayerImpl> textureLayer = CCTextureLayerImpl::create(layerId ++);
2542 textureLayer->setBounds(IntSize(10, 10)); 2539 textureLayer->setBounds(IntSize(10, 10));
2543 textureLayer->setAnchorPoint(FloatPoint(0, 0)); 2540 textureLayer->setAnchorPoint(FloatPoint(0, 0));
2544 textureLayer->setContentBounds(IntSize(10, 10)); 2541 textureLayer->setContentBounds(IntSize(10, 10));
2545 textureLayer->setDrawsContent(true); 2542 textureLayer->setDrawsContent(true);
2546 textureLayer->setTextureId(1); 2543 textureLayer->setTextureId(1);
2547 rootLayer->addChild(textureLayer.PassAs<CCLayerImpl>()); 2544 rootLayer->addChild(textureLayer.release());
2548 2545
2549 scoped_ptr<CCTiledLayerImpl> maskLayer = CCTiledLayerImpl::create(layerId++) ; 2546 OwnPtr<CCTiledLayerImpl> maskLayer = CCTiledLayerImpl::create(layerId++);
2550 maskLayer->setBounds(IntSize(10, 10)); 2547 maskLayer->setBounds(IntSize(10, 10));
2551 maskLayer->setAnchorPoint(FloatPoint(0, 0)); 2548 maskLayer->setAnchorPoint(FloatPoint(0, 0));
2552 maskLayer->setContentBounds(IntSize(10, 10)); 2549 maskLayer->setContentBounds(IntSize(10, 10));
2553 maskLayer->setDrawsContent(true); 2550 maskLayer->setDrawsContent(true);
2554 maskLayer->setSkipsDraw(false); 2551 maskLayer->setSkipsDraw(false);
2555 maskLayer->setTilingData(*tilingData); 2552 maskLayer->setTilingData(*tilingData);
2556 maskLayer->pushTileProperties(0, 0, 1, IntRect(0, 0, 10, 10)); 2553 maskLayer->pushTileProperties(0, 0, 1, IntRect(0, 0, 10, 10));
2557 2554
2558 scoped_ptr<CCTextureLayerImpl> textureLayerWithMask = CCTextureLayerImpl::cr eate(layerId++); 2555 OwnPtr<CCTextureLayerImpl> textureLayerWithMask = CCTextureLayerImpl::create (layerId++);
2559 textureLayerWithMask->setBounds(IntSize(10, 10)); 2556 textureLayerWithMask->setBounds(IntSize(10, 10));
2560 textureLayerWithMask->setAnchorPoint(FloatPoint(0, 0)); 2557 textureLayerWithMask->setAnchorPoint(FloatPoint(0, 0));
2561 textureLayerWithMask->setContentBounds(IntSize(10, 10)); 2558 textureLayerWithMask->setContentBounds(IntSize(10, 10));
2562 textureLayerWithMask->setDrawsContent(true); 2559 textureLayerWithMask->setDrawsContent(true);
2563 textureLayerWithMask->setTextureId(1); 2560 textureLayerWithMask->setTextureId(1);
2564 textureLayerWithMask->setMaskLayer(maskLayer.PassAs<CCLayerImpl>()); 2561 textureLayerWithMask->setMaskLayer(maskLayer.release());
2565 rootLayer->addChild(textureLayerWithMask.PassAs<CCLayerImpl>()); 2562 rootLayer->addChild(textureLayerWithMask.release());
2566 2563
2567 FakeVideoFrame videoFrame; 2564 FakeVideoFrame videoFrame;
2568 FakeVideoFrameProvider provider; 2565 FakeVideoFrameProvider provider;
2569 provider.setFrame(&videoFrame); 2566 provider.setFrame(&videoFrame);
2570 scoped_ptr<CCVideoLayerImpl> videoLayer = CCVideoLayerImpl::create(layerId++ , &provider); 2567 OwnPtr<CCVideoLayerImpl> videoLayer = CCVideoLayerImpl::create(layerId++, &p rovider);
2571 videoLayer->setBounds(IntSize(10, 10)); 2568 videoLayer->setBounds(IntSize(10, 10));
2572 videoLayer->setAnchorPoint(FloatPoint(0, 0)); 2569 videoLayer->setAnchorPoint(FloatPoint(0, 0));
2573 videoLayer->setContentBounds(IntSize(10, 10)); 2570 videoLayer->setContentBounds(IntSize(10, 10));
2574 videoLayer->setDrawsContent(true); 2571 videoLayer->setDrawsContent(true);
2575 videoLayer->setLayerTreeHostImpl(m_hostImpl.get()); 2572 videoLayer->setLayerTreeHostImpl(m_hostImpl.get());
2576 rootLayer->addChild(videoLayer.PassAs<CCLayerImpl>()); 2573 rootLayer->addChild(videoLayer.release());
2577 2574
2578 FakeVideoFrame hwVideoFrame; 2575 FakeVideoFrame hwVideoFrame;
2579 FakeVideoFrameProvider hwProvider; 2576 FakeVideoFrameProvider hwProvider;
2580 hwProvider.setFrame(&hwVideoFrame); 2577 hwProvider.setFrame(&hwVideoFrame);
2581 scoped_ptr<CCVideoLayerImpl> hwVideoLayer = CCVideoLayerImpl::create(layerId ++, &hwProvider); 2578 OwnPtr<CCVideoLayerImpl> hwVideoLayer = CCVideoLayerImpl::create(layerId++, &hwProvider);
2582 hwVideoLayer->setBounds(IntSize(10, 10)); 2579 hwVideoLayer->setBounds(IntSize(10, 10));
2583 hwVideoLayer->setAnchorPoint(FloatPoint(0, 0)); 2580 hwVideoLayer->setAnchorPoint(FloatPoint(0, 0));
2584 hwVideoLayer->setContentBounds(IntSize(10, 10)); 2581 hwVideoLayer->setContentBounds(IntSize(10, 10));
2585 hwVideoLayer->setDrawsContent(true); 2582 hwVideoLayer->setDrawsContent(true);
2586 hwVideoLayer->setLayerTreeHostImpl(m_hostImpl.get()); 2583 hwVideoLayer->setLayerTreeHostImpl(m_hostImpl.get());
2587 rootLayer->addChild(hwVideoLayer.PassAs<CCLayerImpl>()); 2584 rootLayer->addChild(hwVideoLayer.release());
2588 2585
2589 scoped_ptr<CCIOSurfaceLayerImpl> ioSurfaceLayer = CCIOSurfaceLayerImpl::crea te(layerId++); 2586 OwnPtr<CCIOSurfaceLayerImpl> ioSurfaceLayer = CCIOSurfaceLayerImpl::create(l ayerId++);
2590 ioSurfaceLayer->setBounds(IntSize(10, 10)); 2587 ioSurfaceLayer->setBounds(IntSize(10, 10));
2591 ioSurfaceLayer->setAnchorPoint(FloatPoint(0, 0)); 2588 ioSurfaceLayer->setAnchorPoint(FloatPoint(0, 0));
2592 ioSurfaceLayer->setContentBounds(IntSize(10, 10)); 2589 ioSurfaceLayer->setContentBounds(IntSize(10, 10));
2593 ioSurfaceLayer->setDrawsContent(true); 2590 ioSurfaceLayer->setDrawsContent(true);
2594 ioSurfaceLayer->setIOSurfaceProperties(1, IntSize(10, 10)); 2591 ioSurfaceLayer->setIOSurfaceProperties(1, IntSize(10, 10));
2595 ioSurfaceLayer->setLayerTreeHostImpl(m_hostImpl.get()); 2592 ioSurfaceLayer->setLayerTreeHostImpl(m_hostImpl.get());
2596 rootLayer->addChild(ioSurfaceLayer.PassAs<CCLayerImpl>()); 2593 rootLayer->addChild(ioSurfaceLayer.release());
2597 2594
2598 scoped_ptr<CCHeadsUpDisplayLayerImpl> hudLayer = CCHeadsUpDisplayLayerImpl:: create(layerId++); 2595 OwnPtr<CCHeadsUpDisplayLayerImpl> hudLayer = CCHeadsUpDisplayLayerImpl::crea te(layerId++);
2599 hudLayer->setBounds(IntSize(10, 10)); 2596 hudLayer->setBounds(IntSize(10, 10));
2600 hudLayer->setAnchorPoint(FloatPoint(0, 0)); 2597 hudLayer->setAnchorPoint(FloatPoint(0, 0));
2601 hudLayer->setContentBounds(IntSize(10, 10)); 2598 hudLayer->setContentBounds(IntSize(10, 10));
2602 hudLayer->setDrawsContent(true); 2599 hudLayer->setDrawsContent(true);
2603 hudLayer->setLayerTreeHostImpl(m_hostImpl.get()); 2600 hudLayer->setLayerTreeHostImpl(m_hostImpl.get());
2604 rootLayer->addChild(hudLayer.PassAs<CCLayerImpl>()); 2601 rootLayer->addChild(hudLayer.release());
2605 2602
2606 scoped_ptr<FakeScrollbarLayerImpl> scrollbarLayer(FakeScrollbarLayerImpl::cr eate(layerId++)); 2603 OwnPtr<FakeScrollbarLayerImpl> scrollbarLayer(FakeScrollbarLayerImpl::create (layerId++));
2607 scrollbarLayer->setBounds(IntSize(10, 10)); 2604 scrollbarLayer->setBounds(IntSize(10, 10));
2608 scrollbarLayer->setContentBounds(IntSize(10, 10)); 2605 scrollbarLayer->setContentBounds(IntSize(10, 10));
2609 scrollbarLayer->setDrawsContent(true); 2606 scrollbarLayer->setDrawsContent(true);
2610 scrollbarLayer->setLayerTreeHostImpl(m_hostImpl.get()); 2607 scrollbarLayer->setLayerTreeHostImpl(m_hostImpl.get());
2611 scrollbarLayer->createResources(m_hostImpl->resourceProvider()); 2608 scrollbarLayer->createResources(m_hostImpl->resourceProvider());
2612 rootLayer->addChild(scrollbarLayer.PassAs<CCLayerImpl>()); 2609 rootLayer->addChild(scrollbarLayer.release());
2613 2610
2614 scoped_ptr<CCDelegatedRendererLayerImpl> delegatedRendererLayer(CCDelegatedR endererLayerImpl::create(layerId++)); 2611 OwnPtr<CCDelegatedRendererLayerImpl> delegatedRendererLayer(CCDelegatedRende rerLayerImpl::create(layerId++));
2615 delegatedRendererLayer->setBounds(IntSize(10, 10)); 2612 delegatedRendererLayer->setBounds(IntSize(10, 10));
2616 delegatedRendererLayer->setContentBounds(IntSize(10, 10)); 2613 delegatedRendererLayer->setContentBounds(IntSize(10, 10));
2617 delegatedRendererLayer->setDrawsContent(true); 2614 delegatedRendererLayer->setDrawsContent(true);
2618 delegatedRendererLayer->setLayerTreeHostImpl(m_hostImpl.get()); 2615 delegatedRendererLayer->setLayerTreeHostImpl(m_hostImpl.get());
2619 ScopedPtrVector<CCRenderPass> passList; 2616 ScopedPtrVector<CCRenderPass> passList;
2620 passList.append(createRenderPassWithResource(m_hostImpl->resourceProvider()) ); 2617 passList.append(createRenderPassWithResource(m_hostImpl->resourceProvider()) );
2621 delegatedRendererLayer->setRenderPasses(passList); 2618 delegatedRendererLayer->setRenderPasses(passList);
2622 EXPECT_TRUE(passList.isEmpty()); 2619 EXPECT_TRUE(passList.isEmpty());
2623 rootLayer->addChild(delegatedRendererLayer.PassAs<CCLayerImpl>()); 2620 rootLayer->addChild(delegatedRendererLayer.release());
2624 2621
2625 // Use a context that supports IOSurfaces 2622 // Use a context that supports IOSurfaces
2626 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(adoptP tr(new FakeWebGraphicsContext3DWithIOSurface)).PassAs<CCGraphicsContext>()); 2623 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(adoptP tr(new FakeWebGraphicsContext3DWithIOSurface)).PassAs<CCGraphicsContext>());
2627 2624
2628 hwVideoFrame.setTextureId(m_hostImpl->resourceProvider()->graphicsContext3D( )->createTexture()); 2625 hwVideoFrame.setTextureId(m_hostImpl->resourceProvider()->graphicsContext3D( )->createTexture());
2629 2626
2630 m_hostImpl->setRootLayer(rootLayer.Pass()); 2627 m_hostImpl->setRootLayer(rootLayer.release());
2631 2628
2632 CCLayerTreeHostImpl::FrameData frame; 2629 CCLayerTreeHostImpl::FrameData frame;
2633 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 2630 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
2634 m_hostImpl->drawLayers(frame); 2631 m_hostImpl->drawLayers(frame);
2635 m_hostImpl->didDrawAllLayers(frame); 2632 m_hostImpl->didDrawAllLayers(frame);
2636 m_hostImpl->swapBuffers(); 2633 m_hostImpl->swapBuffers();
2637 2634
2638 unsigned numResources = m_hostImpl->resourceProvider()->numResources(); 2635 unsigned numResources = m_hostImpl->resourceProvider()->numResources();
2639 2636
2640 // Lose the context, replacing it with a StrictWebGraphicsContext3DWithIOSur face, 2637 // Lose the context, replacing it with a StrictWebGraphicsContext3DWithIOSur face,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
2700 2697
2701 unsigned numTextures() const { return m_numTextures; } 2698 unsigned numTextures() const { return m_numTextures; }
2702 2699
2703 private: 2700 private:
2704 HashMap<WebGLId, bool> m_textures; 2701 HashMap<WebGLId, bool> m_textures;
2705 unsigned m_numTextures; 2702 unsigned m_numTextures;
2706 }; 2703 };
2707 2704
2708 TEST_F(CCLayerTreeHostImplTest, layersFreeTextures) 2705 TEST_F(CCLayerTreeHostImplTest, layersFreeTextures)
2709 { 2706 {
2710 scoped_ptr<CCLayerImpl> rootLayer(CCLayerImpl::create(1)); 2707 OwnPtr<CCLayerImpl> rootLayer(CCLayerImpl::create(1));
2711 rootLayer->setBounds(IntSize(10, 10)); 2708 rootLayer->setBounds(IntSize(10, 10));
2712 rootLayer->setAnchorPoint(FloatPoint(0, 0)); 2709 rootLayer->setAnchorPoint(FloatPoint(0, 0));
2713 2710
2714 scoped_ptr<CCTiledLayerImpl> tileLayer = CCTiledLayerImpl::create(2); 2711 OwnPtr<CCTiledLayerImpl> tileLayer = CCTiledLayerImpl::create(2);
2715 tileLayer->setBounds(IntSize(10, 10)); 2712 tileLayer->setBounds(IntSize(10, 10));
2716 tileLayer->setAnchorPoint(FloatPoint(0, 0)); 2713 tileLayer->setAnchorPoint(FloatPoint(0, 0));
2717 tileLayer->setContentBounds(IntSize(10, 10)); 2714 tileLayer->setContentBounds(IntSize(10, 10));
2718 tileLayer->setDrawsContent(true); 2715 tileLayer->setDrawsContent(true);
2719 tileLayer->setSkipsDraw(false); 2716 tileLayer->setSkipsDraw(false);
2720 OwnPtr<CCLayerTilingData> tilingData(CCLayerTilingData::create(IntSize(10, 1 0), CCLayerTilingData::NoBorderTexels)); 2717 OwnPtr<CCLayerTilingData> tilingData(CCLayerTilingData::create(IntSize(10, 1 0), CCLayerTilingData::NoBorderTexels));
2721 tilingData->setBounds(IntSize(10, 10)); 2718 tilingData->setBounds(IntSize(10, 10));
2722 tileLayer->setTilingData(*tilingData); 2719 tileLayer->setTilingData(*tilingData);
2723 tileLayer->pushTileProperties(0, 0, 1, IntRect(0, 0, 10, 10)); 2720 tileLayer->pushTileProperties(0, 0, 1, IntRect(0, 0, 10, 10));
2724 rootLayer->addChild(tileLayer.PassAs<CCLayerImpl>()); 2721 rootLayer->addChild(tileLayer.release());
2725 2722
2726 scoped_ptr<CCTextureLayerImpl> textureLayer = CCTextureLayerImpl::create(3); 2723 OwnPtr<CCTextureLayerImpl> textureLayer = CCTextureLayerImpl::create(3);
2727 textureLayer->setBounds(IntSize(10, 10)); 2724 textureLayer->setBounds(IntSize(10, 10));
2728 textureLayer->setAnchorPoint(FloatPoint(0, 0)); 2725 textureLayer->setAnchorPoint(FloatPoint(0, 0));
2729 textureLayer->setContentBounds(IntSize(10, 10)); 2726 textureLayer->setContentBounds(IntSize(10, 10));
2730 textureLayer->setDrawsContent(true); 2727 textureLayer->setDrawsContent(true);
2731 textureLayer->setTextureId(1); 2728 textureLayer->setTextureId(1);
2732 rootLayer->addChild(textureLayer.PassAs<CCLayerImpl>()); 2729 rootLayer->addChild(textureLayer.release());
2733 2730
2734 FakeVideoFrameProvider provider; 2731 FakeVideoFrameProvider provider;
2735 scoped_ptr<CCVideoLayerImpl> videoLayer = CCVideoLayerImpl::create(4, &provi der); 2732 OwnPtr<CCVideoLayerImpl> videoLayer = CCVideoLayerImpl::create(4, &provider) ;
2736 videoLayer->setBounds(IntSize(10, 10)); 2733 videoLayer->setBounds(IntSize(10, 10));
2737 videoLayer->setAnchorPoint(FloatPoint(0, 0)); 2734 videoLayer->setAnchorPoint(FloatPoint(0, 0));
2738 videoLayer->setContentBounds(IntSize(10, 10)); 2735 videoLayer->setContentBounds(IntSize(10, 10));
2739 videoLayer->setDrawsContent(true); 2736 videoLayer->setDrawsContent(true);
2740 videoLayer->setLayerTreeHostImpl(m_hostImpl.get()); 2737 videoLayer->setLayerTreeHostImpl(m_hostImpl.get());
2741 rootLayer->addChild(videoLayer.PassAs<CCLayerImpl>()); 2738 rootLayer->addChild(videoLayer.release());
2742 2739
2743 scoped_ptr<CCIOSurfaceLayerImpl> ioSurfaceLayer = CCIOSurfaceLayerImpl::crea te(5); 2740 OwnPtr<CCIOSurfaceLayerImpl> ioSurfaceLayer = CCIOSurfaceLayerImpl::create(5 );
2744 ioSurfaceLayer->setBounds(IntSize(10, 10)); 2741 ioSurfaceLayer->setBounds(IntSize(10, 10));
2745 ioSurfaceLayer->setAnchorPoint(FloatPoint(0, 0)); 2742 ioSurfaceLayer->setAnchorPoint(FloatPoint(0, 0));
2746 ioSurfaceLayer->setContentBounds(IntSize(10, 10)); 2743 ioSurfaceLayer->setContentBounds(IntSize(10, 10));
2747 ioSurfaceLayer->setDrawsContent(true); 2744 ioSurfaceLayer->setDrawsContent(true);
2748 ioSurfaceLayer->setIOSurfaceProperties(1, IntSize(10, 10)); 2745 ioSurfaceLayer->setIOSurfaceProperties(1, IntSize(10, 10));
2749 ioSurfaceLayer->setLayerTreeHostImpl(m_hostImpl.get()); 2746 ioSurfaceLayer->setLayerTreeHostImpl(m_hostImpl.get());
2750 rootLayer->addChild(ioSurfaceLayer.PassAs<CCLayerImpl>()); 2747 rootLayer->addChild(ioSurfaceLayer.release());
2751 2748
2752 // Lose the context, replacing it with a TrackingWebGraphicsContext3D (which the CCLayerTreeHostImpl takes ownership of). 2749 // Lose the context, replacing it with a TrackingWebGraphicsContext3D (which the CCLayerTreeHostImpl takes ownership of).
2753 scoped_ptr<CCGraphicsContext> ccContext(FakeWebCompositorOutputSurface::crea te(adoptPtr(new TrackingWebGraphicsContext3D))); 2750 scoped_ptr<CCGraphicsContext> ccContext(FakeWebCompositorOutputSurface::crea te(adoptPtr(new TrackingWebGraphicsContext3D)));
2754 TrackingWebGraphicsContext3D* trackingWebGraphicsContext = static_cast<Track ingWebGraphicsContext3D*>(ccContext->context3D()); 2751 TrackingWebGraphicsContext3D* trackingWebGraphicsContext = static_cast<Track ingWebGraphicsContext3D*>(ccContext->context3D());
2755 m_hostImpl->initializeRenderer(ccContext.Pass()); 2752 m_hostImpl->initializeRenderer(ccContext.Pass());
2756 2753
2757 m_hostImpl->setRootLayer(rootLayer.Pass()); 2754 m_hostImpl->setRootLayer(rootLayer.release());
2758 2755
2759 CCLayerTreeHostImpl::FrameData frame; 2756 CCLayerTreeHostImpl::FrameData frame;
2760 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 2757 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
2761 m_hostImpl->drawLayers(frame); 2758 m_hostImpl->drawLayers(frame);
2762 m_hostImpl->didDrawAllLayers(frame); 2759 m_hostImpl->didDrawAllLayers(frame);
2763 m_hostImpl->swapBuffers(); 2760 m_hostImpl->swapBuffers();
2764 2761
2765 EXPECT_GT(trackingWebGraphicsContext->numTextures(), 0u); 2762 EXPECT_GT(trackingWebGraphicsContext->numTextures(), 0u);
2766 2763
2767 // Kill the layer tree. 2764 // Kill the layer tree.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2800 // Verify no quads are drawn when transparent background is set. 2797 // Verify no quads are drawn when transparent background is set.
2801 myHostImpl->setHasTransparentBackground(true); 2798 myHostImpl->setHasTransparentBackground(true);
2802 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 2799 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
2803 myHostImpl->drawLayers(frame); 2800 myHostImpl->drawLayers(frame);
2804 myHostImpl->didDrawAllLayers(frame); 2801 myHostImpl->didDrawAllLayers(frame);
2805 Mock::VerifyAndClearExpectations(&mockContext); 2802 Mock::VerifyAndClearExpectations(&mockContext);
2806 } 2803 }
2807 2804
2808 static void addDrawingLayerTo(CCLayerImpl* parent, int id, const IntRect& layerR ect, CCLayerImpl** result) 2805 static void addDrawingLayerTo(CCLayerImpl* parent, int id, const IntRect& layerR ect, CCLayerImpl** result)
2809 { 2806 {
2810 scoped_ptr<CCLayerImpl> layer = FakeLayerWithQuads::create(id); 2807 OwnPtr<CCLayerImpl> layer = FakeLayerWithQuads::create(id);
2811 CCLayerImpl* layerPtr = layer.get(); 2808 CCLayerImpl* layerPtr = layer.get();
2812 layerPtr->setAnchorPoint(FloatPoint(0, 0)); 2809 layerPtr->setAnchorPoint(FloatPoint(0, 0));
2813 layerPtr->setPosition(FloatPoint(layerRect.location())); 2810 layerPtr->setPosition(FloatPoint(layerRect.location()));
2814 layerPtr->setBounds(layerRect.size()); 2811 layerPtr->setBounds(layerRect.size());
2815 layerPtr->setContentBounds(layerRect.size()); 2812 layerPtr->setContentBounds(layerRect.size());
2816 layerPtr->setDrawsContent(true); // only children draw content 2813 layerPtr->setDrawsContent(true); // only children draw content
2817 layerPtr->setContentsOpaque(true); 2814 layerPtr->setContentsOpaque(true);
2818 parent->addChild(layer.Pass()); 2815 parent->addChild(layer.release());
2819 if (result) 2816 if (result)
2820 *result = layerPtr; 2817 *result = layerPtr;
2821 } 2818 }
2822 2819
2823 static void setupLayersForTextureCaching(CCLayerTreeHostImpl* layerTreeHostImpl, CCLayerImpl*& rootPtr, CCLayerImpl*& intermediateLayerPtr, CCLayerImpl*& surfac eLayerPtr, CCLayerImpl*& childPtr, const IntSize& rootSize) 2820 static void setupLayersForTextureCaching(CCLayerTreeHostImpl* layerTreeHostImpl, CCLayerImpl*& rootPtr, CCLayerImpl*& intermediateLayerPtr, CCLayerImpl*& surfac eLayerPtr, CCLayerImpl*& childPtr, const IntSize& rootSize)
2824 { 2821 {
2825 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>(); 2822 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>();
2826 2823
2827 layerTreeHostImpl->initializeRenderer(context.Pass()); 2824 layerTreeHostImpl->initializeRenderer(context.Pass());
2828 layerTreeHostImpl->setViewportSize(rootSize, rootSize); 2825 layerTreeHostImpl->setViewportSize(rootSize, rootSize);
2829 2826
2830 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); 2827 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
2831 rootPtr = root.get(); 2828 rootPtr = root.get();
2832 2829
2833 root->setAnchorPoint(FloatPoint(0, 0)); 2830 root->setAnchorPoint(FloatPoint(0, 0));
2834 root->setPosition(FloatPoint(0, 0)); 2831 root->setPosition(FloatPoint(0, 0));
2835 root->setBounds(rootSize); 2832 root->setBounds(rootSize);
2836 root->setContentBounds(rootSize); 2833 root->setContentBounds(rootSize);
2837 root->setDrawsContent(true); 2834 root->setDrawsContent(true);
2838 layerTreeHostImpl->setRootLayer(root.Pass()); 2835 layerTreeHostImpl->setRootLayer(root.release());
2839 2836
2840 addDrawingLayerTo(rootPtr, 2, IntRect(10, 10, rootSize.width(), rootSize.hei ght()), &intermediateLayerPtr); 2837 addDrawingLayerTo(rootPtr, 2, IntRect(10, 10, rootSize.width(), rootSize.hei ght()), &intermediateLayerPtr);
2841 intermediateLayerPtr->setDrawsContent(false); // only children draw content 2838 intermediateLayerPtr->setDrawsContent(false); // only children draw content
2842 2839
2843 // Surface layer is the layer that changes its opacity 2840 // Surface layer is the layer that changes its opacity
2844 // It will contain other layers that draw content. 2841 // It will contain other layers that draw content.
2845 addDrawingLayerTo(intermediateLayerPtr, 3, IntRect(10, 10, rootSize.width(), rootSize.height()), &surfaceLayerPtr); 2842 addDrawingLayerTo(intermediateLayerPtr, 3, IntRect(10, 10, rootSize.width(), rootSize.height()), &surfaceLayerPtr);
2846 surfaceLayerPtr->setDrawsContent(false); // only children draw content 2843 surfaceLayerPtr->setDrawsContent(false); // only children draw content
2847 surfaceLayerPtr->setOpacity(0.5f); // This will cause it to have a surface 2844 surfaceLayerPtr->setOpacity(0.5f); // This will cause it to have a surface
2848 2845
(...skipping 17 matching lines...) Expand all
2866 CCLayerImpl* rootPtr; 2863 CCLayerImpl* rootPtr;
2867 CCLayerImpl* surfaceLayerPtr; 2864 CCLayerImpl* surfaceLayerPtr;
2868 2865
2869 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>(); 2866 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>();
2870 2867
2871 IntSize rootSize(100, 100); 2868 IntSize rootSize(100, 100);
2872 2869
2873 myHostImpl->initializeRenderer(context.Pass()); 2870 myHostImpl->initializeRenderer(context.Pass());
2874 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In tSize(rootSize.width(), rootSize.height())); 2871 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In tSize(rootSize.width(), rootSize.height()));
2875 2872
2876 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); 2873 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
2877 rootPtr = root.get(); 2874 rootPtr = root.get();
2878 2875
2879 root->setAnchorPoint(FloatPoint(0, 0)); 2876 root->setAnchorPoint(FloatPoint(0, 0));
2880 root->setPosition(FloatPoint(0, 0)); 2877 root->setPosition(FloatPoint(0, 0));
2881 root->setBounds(rootSize); 2878 root->setBounds(rootSize);
2882 root->setContentBounds(rootSize); 2879 root->setContentBounds(rootSize);
2883 root->setDrawsContent(true); 2880 root->setDrawsContent(true);
2884 root->setMasksToBounds(true); 2881 root->setMasksToBounds(true);
2885 myHostImpl->setRootLayer(root.Pass()); 2882 myHostImpl->setRootLayer(root.release());
2886 2883
2887 addDrawingLayerTo(rootPtr, 3, IntRect(0, 0, rootSize.width(), rootSize.heigh t()), &surfaceLayerPtr); 2884 addDrawingLayerTo(rootPtr, 3, IntRect(0, 0, rootSize.width(), rootSize.heigh t()), &surfaceLayerPtr);
2888 surfaceLayerPtr->setDrawsContent(false); 2885 surfaceLayerPtr->setDrawsContent(false);
2889 2886
2890 // Surface layer is the layer that changes its opacity 2887 // Surface layer is the layer that changes its opacity
2891 // It will contain other layers that draw content. 2888 // It will contain other layers that draw content.
2892 surfaceLayerPtr->setOpacity(0.5f); // This will cause it to have a surface 2889 surfaceLayerPtr->setOpacity(0.5f); // This will cause it to have a surface
2893 2890
2894 addDrawingLayerTo(surfaceLayerPtr, 4, IntRect(0, 0, 100, 3), 0); 2891 addDrawingLayerTo(surfaceLayerPtr, 4, IntRect(0, 0, 100, 3), 0);
2895 addDrawingLayerTo(surfaceLayerPtr, 5, IntRect(0, 97, 100, 3), 0); 2892 addDrawingLayerTo(surfaceLayerPtr, 5, IntRect(0, 97, 100, 3), 0);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
2978 CCLayerImpl* layerS1Ptr; 2975 CCLayerImpl* layerS1Ptr;
2979 CCLayerImpl* layerS2Ptr; 2976 CCLayerImpl* layerS2Ptr;
2980 2977
2981 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>(); 2978 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>();
2982 2979
2983 IntSize rootSize(1000, 1000); 2980 IntSize rootSize(1000, 1000);
2984 2981
2985 myHostImpl->initializeRenderer(context.Pass()); 2982 myHostImpl->initializeRenderer(context.Pass());
2986 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In tSize(rootSize.width(), rootSize.height())); 2983 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In tSize(rootSize.width(), rootSize.height()));
2987 2984
2988 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); 2985 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
2989 rootPtr = root.get(); 2986 rootPtr = root.get();
2990 2987
2991 root->setAnchorPoint(FloatPoint(0, 0)); 2988 root->setAnchorPoint(FloatPoint(0, 0));
2992 root->setPosition(FloatPoint(0, 0)); 2989 root->setPosition(FloatPoint(0, 0));
2993 root->setBounds(rootSize); 2990 root->setBounds(rootSize);
2994 root->setContentBounds(rootSize); 2991 root->setContentBounds(rootSize);
2995 root->setDrawsContent(true); 2992 root->setDrawsContent(true);
2996 root->setMasksToBounds(true); 2993 root->setMasksToBounds(true);
2997 myHostImpl->setRootLayer(root.Pass()); 2994 myHostImpl->setRootLayer(root.release());
2998 2995
2999 addDrawingLayerTo(rootPtr, 2, IntRect(300, 300, 300, 300), &layerS1Ptr); 2996 addDrawingLayerTo(rootPtr, 2, IntRect(300, 300, 300, 300), &layerS1Ptr);
3000 layerS1Ptr->setForceRenderSurface(true); 2997 layerS1Ptr->setForceRenderSurface(true);
3001 2998
3002 addDrawingLayerTo(layerS1Ptr, 3, IntRect(10, 10, 10, 10), 0); // L11 2999 addDrawingLayerTo(layerS1Ptr, 3, IntRect(10, 10, 10, 10), 0); // L11
3003 addDrawingLayerTo(layerS1Ptr, 4, IntRect(0, 0, 30, 30), 0); // L12 3000 addDrawingLayerTo(layerS1Ptr, 4, IntRect(0, 0, 30, 30), 0); // L12
3004 3001
3005 addDrawingLayerTo(rootPtr, 5, IntRect(550, 250, 300, 400), &layerS2Ptr); 3002 addDrawingLayerTo(rootPtr, 5, IntRect(550, 250, 300, 400), &layerS2Ptr);
3006 layerS2Ptr->setForceRenderSurface(true); 3003 layerS2Ptr->setForceRenderSurface(true);
3007 3004
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
3091 CCLayerImpl* layerS1Ptr; 3088 CCLayerImpl* layerS1Ptr;
3092 CCLayerImpl* layerS2Ptr; 3089 CCLayerImpl* layerS2Ptr;
3093 3090
3094 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>(); 3091 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>();
3095 3092
3096 IntSize rootSize(1000, 1000); 3093 IntSize rootSize(1000, 1000);
3097 3094
3098 myHostImpl->initializeRenderer(context.Pass()); 3095 myHostImpl->initializeRenderer(context.Pass());
3099 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In tSize(rootSize.width(), rootSize.height())); 3096 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In tSize(rootSize.width(), rootSize.height()));
3100 3097
3101 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); 3098 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
3102 rootPtr = root.get(); 3099 rootPtr = root.get();
3103 3100
3104 root->setAnchorPoint(FloatPoint(0, 0)); 3101 root->setAnchorPoint(FloatPoint(0, 0));
3105 root->setPosition(FloatPoint(0, 0)); 3102 root->setPosition(FloatPoint(0, 0));
3106 root->setBounds(rootSize); 3103 root->setBounds(rootSize);
3107 root->setContentBounds(rootSize); 3104 root->setContentBounds(rootSize);
3108 root->setDrawsContent(true); 3105 root->setDrawsContent(true);
3109 root->setMasksToBounds(true); 3106 root->setMasksToBounds(true);
3110 myHostImpl->setRootLayer(root.Pass()); 3107 myHostImpl->setRootLayer(root.release());
3111 3108
3112 addDrawingLayerTo(rootPtr, 2, IntRect(0, 0, 800, 800), &layerS1Ptr); 3109 addDrawingLayerTo(rootPtr, 2, IntRect(0, 0, 800, 800), &layerS1Ptr);
3113 layerS1Ptr->setForceRenderSurface(true); 3110 layerS1Ptr->setForceRenderSurface(true);
3114 layerS1Ptr->setDrawsContent(false); 3111 layerS1Ptr->setDrawsContent(false);
3115 3112
3116 addDrawingLayerTo(layerS1Ptr, 3, IntRect(0, 0, 300, 300), 0); // L11 3113 addDrawingLayerTo(layerS1Ptr, 3, IntRect(0, 0, 300, 300), 0); // L11
3117 addDrawingLayerTo(layerS1Ptr, 4, IntRect(0, 500, 300, 300), 0); // L12 3114 addDrawingLayerTo(layerS1Ptr, 4, IntRect(0, 500, 300, 300), 0); // L12
3118 addDrawingLayerTo(layerS1Ptr, 5, IntRect(500, 0, 300, 300), 0); // L13 3115 addDrawingLayerTo(layerS1Ptr, 5, IntRect(500, 0, 300, 300), 0); // L13
3119 addDrawingLayerTo(layerS1Ptr, 6, IntRect(500, 500, 300, 300), 0); // L14 3116 addDrawingLayerTo(layerS1Ptr, 6, IntRect(500, 500, 300, 300), 0); // L14
3120 addDrawingLayerTo(layerS1Ptr, 9, IntRect(500, 500, 300, 300), 0); // L14 3117 addDrawingLayerTo(layerS1Ptr, 9, IntRect(500, 500, 300, 300), 0); // L14
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
3205 CCLayerImpl* layerS1Ptr; 3202 CCLayerImpl* layerS1Ptr;
3206 CCLayerImpl* layerS2Ptr; 3203 CCLayerImpl* layerS2Ptr;
3207 3204
3208 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>(); 3205 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>();
3209 3206
3210 IntSize rootSize(1000, 1000); 3207 IntSize rootSize(1000, 1000);
3211 3208
3212 myHostImpl->initializeRenderer(context.Pass()); 3209 myHostImpl->initializeRenderer(context.Pass());
3213 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In tSize(rootSize.width(), rootSize.height())); 3210 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In tSize(rootSize.width(), rootSize.height()));
3214 3211
3215 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); 3212 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
3216 rootPtr = root.get(); 3213 rootPtr = root.get();
3217 3214
3218 root->setAnchorPoint(FloatPoint(0, 0)); 3215 root->setAnchorPoint(FloatPoint(0, 0));
3219 root->setPosition(FloatPoint(0, 0)); 3216 root->setPosition(FloatPoint(0, 0));
3220 root->setBounds(rootSize); 3217 root->setBounds(rootSize);
3221 root->setContentBounds(rootSize); 3218 root->setContentBounds(rootSize);
3222 root->setDrawsContent(true); 3219 root->setDrawsContent(true);
3223 root->setMasksToBounds(true); 3220 root->setMasksToBounds(true);
3224 myHostImpl->setRootLayer(root.Pass()); 3221 myHostImpl->setRootLayer(root.release());
3225 3222
3226 addDrawingLayerTo(rootPtr, 2, IntRect(0, 0, 400, 400), &layerS1Ptr); 3223 addDrawingLayerTo(rootPtr, 2, IntRect(0, 0, 400, 400), &layerS1Ptr);
3227 layerS1Ptr->setForceRenderSurface(true); 3224 layerS1Ptr->setForceRenderSurface(true);
3228 3225
3229 addDrawingLayerTo(layerS1Ptr, 3, IntRect(0, 0, 300, 300), 0); // L11 3226 addDrawingLayerTo(layerS1Ptr, 3, IntRect(0, 0, 300, 300), 0); // L11
3230 addDrawingLayerTo(layerS1Ptr, 4, IntRect(100, 0, 300, 300), 0); // L12 3227 addDrawingLayerTo(layerS1Ptr, 4, IntRect(100, 0, 300, 300), 0); // L12
3231 3228
3232 addDrawingLayerTo(rootPtr, 7, IntRect(200, 0, 300, 300), &layerS2Ptr); 3229 addDrawingLayerTo(rootPtr, 7, IntRect(200, 0, 300, 300), &layerS2Ptr);
3233 layerS2Ptr->setForceRenderSurface(true); 3230 layerS2Ptr->setForceRenderSurface(true);
3234 3231
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
3288 CCLayerImpl* rootPtr; 3285 CCLayerImpl* rootPtr;
3289 CCLayerImpl* layerS1Ptr; 3286 CCLayerImpl* layerS1Ptr;
3290 3287
3291 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>(); 3288 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>();
3292 3289
3293 IntSize rootSize(1000, 1000); 3290 IntSize rootSize(1000, 1000);
3294 3291
3295 myHostImpl->initializeRenderer(context.Pass()); 3292 myHostImpl->initializeRenderer(context.Pass());
3296 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In tSize(rootSize.width(), rootSize.height())); 3293 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In tSize(rootSize.width(), rootSize.height()));
3297 3294
3298 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); 3295 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
3299 rootPtr = root.get(); 3296 rootPtr = root.get();
3300 3297
3301 root->setAnchorPoint(FloatPoint(0, 0)); 3298 root->setAnchorPoint(FloatPoint(0, 0));
3302 root->setPosition(FloatPoint(0, 0)); 3299 root->setPosition(FloatPoint(0, 0));
3303 root->setBounds(rootSize); 3300 root->setBounds(rootSize);
3304 root->setContentBounds(rootSize); 3301 root->setContentBounds(rootSize);
3305 root->setDrawsContent(true); 3302 root->setDrawsContent(true);
3306 root->setMasksToBounds(true); 3303 root->setMasksToBounds(true);
3307 myHostImpl->setRootLayer(root.Pass()); 3304 myHostImpl->setRootLayer(root.release());
3308 3305
3309 addDrawingLayerTo(rootPtr, 2, IntRect(0, 0, 400, 400), &layerS1Ptr); 3306 addDrawingLayerTo(rootPtr, 2, IntRect(0, 0, 400, 400), &layerS1Ptr);
3310 layerS1Ptr->setForceRenderSurface(true); 3307 layerS1Ptr->setForceRenderSurface(true);
3311 WebTransformationMatrix transform = layerS1Ptr->transform(); 3308 WebTransformationMatrix transform = layerS1Ptr->transform();
3312 transform.translate(200, 200); 3309 transform.translate(200, 200);
3313 transform.rotate(45); 3310 transform.rotate(45);
3314 transform.translate(-200, -200); 3311 transform.translate(-200, -200);
3315 layerS1Ptr->setTransform(transform); 3312 layerS1Ptr->setTransform(transform);
3316 3313
3317 addDrawingLayerTo(layerS1Ptr, 3, IntRect(200, 0, 200, 400), 0); // L11 3314 addDrawingLayerTo(layerS1Ptr, 3, IntRect(200, 0, 200, 400), 0); // L11
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
3373 CCLayerImpl* layerS1Ptr; 3370 CCLayerImpl* layerS1Ptr;
3374 CCLayerImpl* layerS2Ptr; 3371 CCLayerImpl* layerS2Ptr;
3375 3372
3376 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>(); 3373 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>();
3377 3374
3378 IntSize rootSize(1000, 1000); 3375 IntSize rootSize(1000, 1000);
3379 3376
3380 myHostImpl->initializeRenderer(context.Pass()); 3377 myHostImpl->initializeRenderer(context.Pass());
3381 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In tSize(rootSize.width(), rootSize.height())); 3378 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In tSize(rootSize.width(), rootSize.height()));
3382 3379
3383 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); 3380 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
3384 rootPtr = root.get(); 3381 rootPtr = root.get();
3385 3382
3386 root->setAnchorPoint(FloatPoint(0, 0)); 3383 root->setAnchorPoint(FloatPoint(0, 0));
3387 root->setPosition(FloatPoint(0, 0)); 3384 root->setPosition(FloatPoint(0, 0));
3388 root->setBounds(rootSize); 3385 root->setBounds(rootSize);
3389 root->setContentBounds(rootSize); 3386 root->setContentBounds(rootSize);
3390 root->setDrawsContent(true); 3387 root->setDrawsContent(true);
3391 root->setMasksToBounds(true); 3388 root->setMasksToBounds(true);
3392 myHostImpl->setRootLayer(root.Pass()); 3389 myHostImpl->setRootLayer(root.release());
3393 3390
3394 addDrawingLayerTo(rootPtr, 2, IntRect(300, 300, 300, 300), &layerS1Ptr); 3391 addDrawingLayerTo(rootPtr, 2, IntRect(300, 300, 300, 300), &layerS1Ptr);
3395 layerS1Ptr->setForceRenderSurface(true); 3392 layerS1Ptr->setForceRenderSurface(true);
3396 3393
3397 addDrawingLayerTo(layerS1Ptr, 3, IntRect(10, 10, 10, 10), 0); // L11 3394 addDrawingLayerTo(layerS1Ptr, 3, IntRect(10, 10, 10, 10), 0); // L11
3398 addDrawingLayerTo(layerS1Ptr, 4, IntRect(0, 0, 30, 30), 0); // L12 3395 addDrawingLayerTo(layerS1Ptr, 4, IntRect(0, 0, 30, 30), 0); // L12
3399 3396
3400 addDrawingLayerTo(rootPtr, 5, IntRect(550, 250, 300, 400), &layerS2Ptr); 3397 addDrawingLayerTo(rootPtr, 5, IntRect(550, 250, 300, 400), &layerS2Ptr);
3401 layerS2Ptr->setForceRenderSurface(true); 3398 layerS2Ptr->setForceRenderSurface(true);
3402 3399
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
3479 | | | 3 | 3476 | | | 3 |
3480 | | +-------------------+ 3477 | | +-------------------+
3481 | | | | 3478 | | | |
3482 | +-----------+ | 3479 | +-----------+ |
3483 | | 3480 | |
3484 | | 3481 | |
3485 +--------------------+ 3482 +--------------------+
3486 3483
3487 Layers 1, 2 have render surfaces 3484 Layers 1, 2 have render surfaces
3488 */ 3485 */
3489 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); 3486 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
3490 scoped_ptr<CCTiledLayerImpl> child = CCTiledLayerImpl::create(2); 3487 OwnPtr<CCTiledLayerImpl> child = CCTiledLayerImpl::create(2);
3491 scoped_ptr<CCLayerImpl> grandChild = CCLayerImpl::create(3); 3488 OwnPtr<CCLayerImpl> grandChild = CCLayerImpl::create(3);
3492 3489
3493 IntRect rootRect(0, 0, 100, 100); 3490 IntRect rootRect(0, 0, 100, 100);
3494 IntRect childRect(10, 10, 50, 50); 3491 IntRect childRect(10, 10, 50, 50);
3495 IntRect grandChildRect(5, 5, 150, 150); 3492 IntRect grandChildRect(5, 5, 150, 150);
3496 3493
3497 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>(); 3494 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>();
3498 myHostImpl->initializeRenderer(context.Pass()); 3495 myHostImpl->initializeRenderer(context.Pass());
3499 3496
3500 root->setAnchorPoint(FloatPoint(0, 0)); 3497 root->setAnchorPoint(FloatPoint(0, 0));
3501 root->setPosition(FloatPoint(rootRect.x(), rootRect.y())); 3498 root->setPosition(FloatPoint(rootRect.x(), rootRect.y()));
(...skipping 17 matching lines...) Expand all
3519 3516
3520 grandChild->setAnchorPoint(FloatPoint(0, 0)); 3517 grandChild->setAnchorPoint(FloatPoint(0, 0));
3521 grandChild->setPosition(IntPoint(grandChildRect.x(), grandChildRect.y())); 3518 grandChild->setPosition(IntPoint(grandChildRect.x(), grandChildRect.y()));
3522 grandChild->setBounds(IntSize(grandChildRect.width(), grandChildRect.height( ))); 3519 grandChild->setBounds(IntSize(grandChildRect.width(), grandChildRect.height( )));
3523 grandChild->setContentBounds(grandChild->bounds()); 3520 grandChild->setContentBounds(grandChild->bounds());
3524 grandChild->setDrawsContent(true); 3521 grandChild->setDrawsContent(true);
3525 3522
3526 CCTiledLayerImpl* childPtr = child.get(); 3523 CCTiledLayerImpl* childPtr = child.get();
3527 CCRenderPass::Id childPassId(childPtr->id(), 0); 3524 CCRenderPass::Id childPassId(childPtr->id(), 0);
3528 3525
3529 child->addChild(grandChild.Pass()); 3526 child->addChild(grandChild.release());
3530 root->addChild(child.PassAs<CCLayerImpl>()); 3527 root->addChild(child.release());
3531 myHostImpl->setRootLayer(root.Pass()); 3528 myHostImpl->setRootLayer(root.release());
3532 myHostImpl->setViewportSize(rootRect.size(), rootRect.size()); 3529 myHostImpl->setViewportSize(rootRect.size(), rootRect.size());
3533 3530
3534 EXPECT_FALSE(myHostImpl->renderer()->haveCachedResourcesForRenderPassId(chil dPassId)); 3531 EXPECT_FALSE(myHostImpl->renderer()->haveCachedResourcesForRenderPassId(chil dPassId));
3535 3532
3536 { 3533 {
3537 CCLayerTreeHostImpl::FrameData frame; 3534 CCLayerTreeHostImpl::FrameData frame;
3538 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3535 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3539 myHostImpl->drawLayers(frame); 3536 myHostImpl->drawLayers(frame);
3540 myHostImpl->didDrawAllLayers(frame); 3537 myHostImpl->didDrawAllLayers(frame);
3541 } 3538 }
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
4218 while (removeRenderPassesCases[testCaseIndex].name) { 4215 while (removeRenderPassesCases[testCaseIndex].name) {
4219 RenderPassRemovalTestData testData; 4216 RenderPassRemovalTestData testData;
4220 configureRenderPassTestData(removeRenderPassesCases[testCaseIndex].initS cript, testData, renderer.get()); 4217 configureRenderPassTestData(removeRenderPassesCases[testCaseIndex].initS cript, testData, renderer.get());
4221 CCLayerTreeHostImpl::removeRenderPasses(CCLayerTreeHostImpl::CullRenderP assesWithCachedTextures(*renderer), testData); 4218 CCLayerTreeHostImpl::removeRenderPasses(CCLayerTreeHostImpl::CullRenderP assesWithCachedTextures(*renderer), testData);
4222 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat a); 4219 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat a);
4223 testCaseIndex++; 4220 testCaseIndex++;
4224 } 4221 }
4225 } 4222 }
4226 4223
4227 } // namespace 4224 } // namespace
OLDNEW
« no previous file with comments | « cc/CCLayerTreeHostImpl.cpp ('k') | cc/CCLayerTreeHostTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698