OLD | NEW |
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 | 80 |
81 virtual void didLoseContextOnImplThread() OVERRIDE { } | 81 virtual void didLoseContextOnImplThread() OVERRIDE { } |
82 virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { } | 82 virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { } |
83 virtual void onVSyncParametersChanged(double, double) OVERRIDE { } | 83 virtual void onVSyncParametersChanged(double, double) OVERRIDE { } |
84 virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE { m_onCanDrawState
ChangedCalled = true; } | 84 virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE { m_onCanDrawState
ChangedCalled = true; } |
85 virtual void setNeedsRedrawOnImplThread() OVERRIDE { m_didRequestRedraw = tr
ue; } | 85 virtual void setNeedsRedrawOnImplThread() OVERRIDE { m_didRequestRedraw = tr
ue; } |
86 virtual void setNeedsCommitOnImplThread() OVERRIDE { m_didRequestCommit = tr
ue; } | 86 virtual void setNeedsCommitOnImplThread() OVERRIDE { m_didRequestCommit = tr
ue; } |
87 virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<CCAnimat
ionEventsVector>, double wallClockTime) OVERRIDE { } | 87 virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<CCAnimat
ionEventsVector>, double wallClockTime) OVERRIDE { } |
88 virtual void releaseContentsTexturesOnImplThread() OVERRIDE { } | 88 virtual void releaseContentsTexturesOnImplThread() OVERRIDE { } |
89 | 89 |
90 scoped_ptr<CCLayerTreeHostImpl> createLayerTreeHost(bool partialSwap, scoped
_ptr<CCGraphicsContext> graphicsContext, PassOwnPtr<CCLayerImpl> rootPtr) | 90 scoped_ptr<CCLayerTreeHostImpl> createLayerTreeHost(bool partialSwap, scoped
_ptr<CCGraphicsContext> graphicsContext, scoped_ptr<CCLayerImpl> root) |
91 { | 91 { |
92 CCSettings::setPartialSwapEnabled(partialSwap); | 92 CCSettings::setPartialSwapEnabled(partialSwap); |
93 | 93 |
94 CCLayerTreeSettings settings; | 94 CCLayerTreeSettings settings; |
95 settings.minimumOcclusionTrackingSize = IntSize(); | 95 settings.minimumOcclusionTrackingSize = IntSize(); |
96 | 96 |
97 scoped_ptr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create
(settings, this); | 97 scoped_ptr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create
(settings, this); |
98 | 98 |
99 myHostImpl->initializeRenderer(graphicsContext.Pass()); | 99 myHostImpl->initializeRenderer(graphicsContext.Pass()); |
100 myHostImpl->setViewportSize(IntSize(10, 10), IntSize(10, 10)); | 100 myHostImpl->setViewportSize(IntSize(10, 10), IntSize(10, 10)); |
101 | 101 |
102 OwnPtr<CCLayerImpl> root = rootPtr; | |
103 | |
104 root->setAnchorPoint(FloatPoint(0, 0)); | 102 root->setAnchorPoint(FloatPoint(0, 0)); |
105 root->setPosition(FloatPoint(0, 0)); | 103 root->setPosition(FloatPoint(0, 0)); |
106 root->setBounds(IntSize(10, 10)); | 104 root->setBounds(IntSize(10, 10)); |
107 root->setContentBounds(IntSize(10, 10)); | 105 root->setContentBounds(IntSize(10, 10)); |
108 root->setVisibleContentRect(IntRect(0, 0, 10, 10)); | 106 root->setVisibleContentRect(IntRect(0, 0, 10, 10)); |
109 root->setDrawsContent(true); | 107 root->setDrawsContent(true); |
110 myHostImpl->setRootLayer(root.release()); | 108 myHostImpl->setRootLayer(root.Pass()); |
111 return myHostImpl.Pass(); | 109 return myHostImpl.Pass(); |
112 } | 110 } |
113 | 111 |
114 static void expectClearedScrollDeltasRecursive(CCLayerImpl* layer) | 112 static void expectClearedScrollDeltasRecursive(CCLayerImpl* layer) |
115 { | 113 { |
116 ASSERT_EQ(layer->scrollDelta(), IntSize()); | 114 ASSERT_EQ(layer->scrollDelta(), IntSize()); |
117 for (size_t i = 0; i < layer->children().size(); ++i) | 115 for (size_t i = 0; i < layer->children().size(); ++i) |
118 expectClearedScrollDeltasRecursive(layer->children()[i]); | 116 expectClearedScrollDeltasRecursive(layer->children()[i]); |
119 } | 117 } |
120 | 118 |
121 static void expectContains(const CCScrollAndScaleSet& scrollInfo, int id, co
nst IntSize& scrollDelta) | 119 static void expectContains(const CCScrollAndScaleSet& scrollInfo, int id, co
nst IntSize& scrollDelta) |
122 { | 120 { |
123 int timesEncountered = 0; | 121 int timesEncountered = 0; |
124 | 122 |
125 for (size_t i = 0; i < scrollInfo.scrolls.size(); ++i) { | 123 for (size_t i = 0; i < scrollInfo.scrolls.size(); ++i) { |
126 if (scrollInfo.scrolls[i].layerId != id) | 124 if (scrollInfo.scrolls[i].layerId != id) |
127 continue; | 125 continue; |
128 EXPECT_EQ(scrollDelta.width(), scrollInfo.scrolls[i].scrollDelta.wid
th()); | 126 EXPECT_EQ(scrollDelta.width(), scrollInfo.scrolls[i].scrollDelta.wid
th()); |
129 EXPECT_EQ(scrollDelta.height(), scrollInfo.scrolls[i].scrollDelta.he
ight()); | 127 EXPECT_EQ(scrollDelta.height(), scrollInfo.scrolls[i].scrollDelta.he
ight()); |
130 timesEncountered++; | 128 timesEncountered++; |
131 } | 129 } |
132 | 130 |
133 ASSERT_EQ(timesEncountered, 1); | 131 ASSERT_EQ(timesEncountered, 1); |
134 } | 132 } |
135 | 133 |
136 void setupScrollAndContentsLayers(const IntSize& contentSize) | 134 void setupScrollAndContentsLayers(const IntSize& contentSize) |
137 { | 135 { |
138 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 136 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
139 root->setScrollable(true); | 137 root->setScrollable(true); |
140 root->setScrollPosition(IntPoint(0, 0)); | 138 root->setScrollPosition(IntPoint(0, 0)); |
141 root->setMaxScrollPosition(contentSize); | 139 root->setMaxScrollPosition(contentSize); |
142 root->setBounds(contentSize); | 140 root->setBounds(contentSize); |
143 root->setContentBounds(contentSize); | 141 root->setContentBounds(contentSize); |
144 root->setPosition(FloatPoint(0, 0)); | 142 root->setPosition(FloatPoint(0, 0)); |
145 root->setAnchorPoint(FloatPoint(0, 0)); | 143 root->setAnchorPoint(FloatPoint(0, 0)); |
146 | 144 |
147 OwnPtr<CCLayerImpl> contents = CCLayerImpl::create(2); | 145 scoped_ptr<CCLayerImpl> contents = CCLayerImpl::create(2); |
148 contents->setDrawsContent(true); | 146 contents->setDrawsContent(true); |
149 contents->setBounds(contentSize); | 147 contents->setBounds(contentSize); |
150 contents->setContentBounds(contentSize); | 148 contents->setContentBounds(contentSize); |
151 contents->setPosition(FloatPoint(0, 0)); | 149 contents->setPosition(FloatPoint(0, 0)); |
152 contents->setAnchorPoint(FloatPoint(0, 0)); | 150 contents->setAnchorPoint(FloatPoint(0, 0)); |
153 root->addChild(contents.release()); | 151 root->addChild(contents.Pass()); |
154 m_hostImpl->setRootLayer(root.release()); | 152 m_hostImpl->setRootLayer(root.Pass()); |
155 } | 153 } |
156 | 154 |
157 static PassOwnPtr<CCLayerImpl> createScrollableLayer(int id, const IntSize&
size) | 155 static scoped_ptr<CCLayerImpl> createScrollableLayer(int id, const IntSize&
size) |
158 { | 156 { |
159 OwnPtr<CCLayerImpl> layer = CCLayerImpl::create(id); | 157 scoped_ptr<CCLayerImpl> layer = CCLayerImpl::create(id); |
160 layer->setScrollable(true); | 158 layer->setScrollable(true); |
161 layer->setDrawsContent(true); | 159 layer->setDrawsContent(true); |
162 layer->setBounds(size); | 160 layer->setBounds(size); |
163 layer->setContentBounds(size); | 161 layer->setContentBounds(size); |
164 layer->setMaxScrollPosition(IntSize(size.width() * 2, size.height() * 2)
); | 162 layer->setMaxScrollPosition(IntSize(size.width() * 2, size.height() * 2)
); |
165 return layer.release(); | 163 return layer.Pass(); |
166 } | 164 } |
167 | 165 |
168 void initializeRendererAndDrawFrame() | 166 void initializeRendererAndDrawFrame() |
169 { | 167 { |
170 m_hostImpl->initializeRenderer(createContext()); | 168 m_hostImpl->initializeRenderer(createContext()); |
171 CCLayerTreeHostImpl::FrameData frame; | 169 CCLayerTreeHostImpl::FrameData frame; |
172 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 170 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
173 m_hostImpl->drawLayers(frame); | 171 m_hostImpl->drawLayers(frame); |
174 m_hostImpl->didDrawAllLayers(frame); | 172 m_hostImpl->didDrawAllLayers(frame); |
175 } | 173 } |
(...skipping 26 matching lines...) Expand all Loading... |
202 // that canDraw changed. | 200 // that canDraw changed. |
203 EXPECT_FALSE(m_hostImpl->canDraw()); | 201 EXPECT_FALSE(m_hostImpl->canDraw()); |
204 m_onCanDrawStateChangedCalled = false; | 202 m_onCanDrawStateChangedCalled = false; |
205 | 203 |
206 setupScrollAndContentsLayers(IntSize(100, 100)); | 204 setupScrollAndContentsLayers(IntSize(100, 100)); |
207 EXPECT_TRUE(m_hostImpl->canDraw()); | 205 EXPECT_TRUE(m_hostImpl->canDraw()); |
208 EXPECT_TRUE(m_onCanDrawStateChangedCalled); | 206 EXPECT_TRUE(m_onCanDrawStateChangedCalled); |
209 m_onCanDrawStateChangedCalled = false; | 207 m_onCanDrawStateChangedCalled = false; |
210 | 208 |
211 // Toggle the root layer to make sure it toggles canDraw | 209 // Toggle the root layer to make sure it toggles canDraw |
212 m_hostImpl->setRootLayer(adoptPtr<CCLayerImpl>(0)); | 210 m_hostImpl->setRootLayer(scoped_ptr<CCLayerImpl>()); |
213 EXPECT_FALSE(m_hostImpl->canDraw()); | 211 EXPECT_FALSE(m_hostImpl->canDraw()); |
214 EXPECT_TRUE(m_onCanDrawStateChangedCalled); | 212 EXPECT_TRUE(m_onCanDrawStateChangedCalled); |
215 m_onCanDrawStateChangedCalled = false; | 213 m_onCanDrawStateChangedCalled = false; |
216 | 214 |
217 setupScrollAndContentsLayers(IntSize(100, 100)); | 215 setupScrollAndContentsLayers(IntSize(100, 100)); |
218 EXPECT_TRUE(m_hostImpl->canDraw()); | 216 EXPECT_TRUE(m_hostImpl->canDraw()); |
219 EXPECT_TRUE(m_onCanDrawStateChangedCalled); | 217 EXPECT_TRUE(m_onCanDrawStateChangedCalled); |
220 m_onCanDrawStateChangedCalled = false; | 218 m_onCanDrawStateChangedCalled = false; |
221 | 219 |
222 // Toggle the device viewport size to make sure it toggles canDraw. | 220 // Toggle the device viewport size to make sure it toggles canDraw. |
(...skipping 23 matching lines...) Expand all Loading... |
246 { | 244 { |
247 ASSERT_FALSE(m_hostImpl->rootLayer()); | 245 ASSERT_FALSE(m_hostImpl->rootLayer()); |
248 | 246 |
249 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); | 247 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); |
250 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); | 248 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); |
251 } | 249 } |
252 | 250 |
253 TEST_P(CCLayerTreeHostImplTest, scrollDeltaTreeButNoChanges) | 251 TEST_P(CCLayerTreeHostImplTest, scrollDeltaTreeButNoChanges) |
254 { | 252 { |
255 { | 253 { |
256 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 254 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
257 root->addChild(CCLayerImpl::create(2)); | 255 root->addChild(CCLayerImpl::create(2)); |
258 root->addChild(CCLayerImpl::create(3)); | 256 root->addChild(CCLayerImpl::create(3)); |
259 root->children()[1]->addChild(CCLayerImpl::create(4)); | 257 root->children()[1]->addChild(CCLayerImpl::create(4)); |
260 root->children()[1]->addChild(CCLayerImpl::create(5)); | 258 root->children()[1]->addChild(CCLayerImpl::create(5)); |
261 root->children()[1]->children()[0]->addChild(CCLayerImpl::create(6)); | 259 root->children()[1]->children()[0]->addChild(CCLayerImpl::create(6)); |
262 m_hostImpl->setRootLayer(root.release()); | 260 m_hostImpl->setRootLayer(root.Pass()); |
263 } | 261 } |
264 CCLayerImpl* root = m_hostImpl->rootLayer(); | 262 CCLayerImpl* root = m_hostImpl->rootLayer(); |
265 | 263 |
266 expectClearedScrollDeltasRecursive(root); | 264 expectClearedScrollDeltasRecursive(root); |
267 | 265 |
268 OwnPtr<CCScrollAndScaleSet> scrollInfo; | 266 OwnPtr<CCScrollAndScaleSet> scrollInfo; |
269 | 267 |
270 scrollInfo = m_hostImpl->processScrollDeltas(); | 268 scrollInfo = m_hostImpl->processScrollDeltas(); |
271 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); | 269 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); |
272 expectClearedScrollDeltasRecursive(root); | 270 expectClearedScrollDeltasRecursive(root); |
273 | 271 |
274 scrollInfo = m_hostImpl->processScrollDeltas(); | 272 scrollInfo = m_hostImpl->processScrollDeltas(); |
275 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); | 273 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); |
276 expectClearedScrollDeltasRecursive(root); | 274 expectClearedScrollDeltasRecursive(root); |
277 } | 275 } |
278 | 276 |
279 TEST_P(CCLayerTreeHostImplTest, scrollDeltaRepeatedScrolls) | 277 TEST_P(CCLayerTreeHostImplTest, scrollDeltaRepeatedScrolls) |
280 { | 278 { |
281 IntPoint scrollPosition(20, 30); | 279 IntPoint scrollPosition(20, 30); |
282 IntSize scrollDelta(11, -15); | 280 IntSize scrollDelta(11, -15); |
283 { | 281 { |
284 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 282 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
285 root->setScrollPosition(scrollPosition); | 283 root->setScrollPosition(scrollPosition); |
286 root->setScrollable(true); | 284 root->setScrollable(true); |
287 root->setMaxScrollPosition(IntSize(100, 100)); | 285 root->setMaxScrollPosition(IntSize(100, 100)); |
288 root->scrollBy(scrollDelta); | 286 root->scrollBy(scrollDelta); |
289 m_hostImpl->setRootLayer(root.release()); | 287 m_hostImpl->setRootLayer(root.Pass()); |
290 } | 288 } |
291 CCLayerImpl* root = m_hostImpl->rootLayer(); | 289 CCLayerImpl* root = m_hostImpl->rootLayer(); |
292 | 290 |
293 OwnPtr<CCScrollAndScaleSet> scrollInfo; | 291 OwnPtr<CCScrollAndScaleSet> scrollInfo; |
294 | 292 |
295 scrollInfo = m_hostImpl->processScrollDeltas(); | 293 scrollInfo = m_hostImpl->processScrollDeltas(); |
296 ASSERT_EQ(scrollInfo->scrolls.size(), 1u); | 294 ASSERT_EQ(scrollInfo->scrolls.size(), 1u); |
297 EXPECT_EQ(root->sentScrollDelta(), scrollDelta); | 295 EXPECT_EQ(root->sentScrollDelta(), scrollDelta); |
298 expectContains(*scrollInfo, root->id(), scrollDelta); | 296 expectContains(*scrollInfo, root->id(), scrollDelta); |
299 | 297 |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 // The final page scale and scroll deltas should match what we got | 771 // The final page scale and scroll deltas should match what we got |
774 // earlier. | 772 // earlier. |
775 m_hostImpl->animate(endTime, endTime); | 773 m_hostImpl->animate(endTime, endTime); |
776 scrollInfo = m_hostImpl->processScrollDeltas(); | 774 scrollInfo = m_hostImpl->processScrollDeltas(); |
777 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); | 775 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); |
778 expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25)); | 776 expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25)); |
779 } | 777 } |
780 | 778 |
781 class DidDrawCheckLayer : public CCTiledLayerImpl { | 779 class DidDrawCheckLayer : public CCTiledLayerImpl { |
782 public: | 780 public: |
783 static PassOwnPtr<DidDrawCheckLayer> create(int id) { return adoptPtr(new Di
dDrawCheckLayer(id)); } | 781 static scoped_ptr<CCLayerImpl> create(int id) { return scoped_ptr<CCLayerImp
l>(new DidDrawCheckLayer(id)); } |
784 | 782 |
785 virtual void didDraw(CCResourceProvider*) OVERRIDE | 783 virtual void didDraw(CCResourceProvider*) OVERRIDE |
786 { | 784 { |
787 m_didDrawCalled = true; | 785 m_didDrawCalled = true; |
788 } | 786 } |
789 | 787 |
790 virtual void willDraw(CCResourceProvider*) OVERRIDE | 788 virtual void willDraw(CCResourceProvider*) OVERRIDE |
791 { | 789 { |
792 m_willDrawCalled = true; | 790 m_willDrawCalled = true; |
793 } | 791 } |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 EXPECT_TRUE(root->didDrawCalled()); | 928 EXPECT_TRUE(root->didDrawCalled()); |
931 EXPECT_TRUE(layer1->didDrawCalled()); | 929 EXPECT_TRUE(layer1->didDrawCalled()); |
932 EXPECT_TRUE(layer2->didDrawCalled()); | 930 EXPECT_TRUE(layer2->didDrawCalled()); |
933 | 931 |
934 EXPECT_NE(root->renderSurface(), layer1->renderSurface()); | 932 EXPECT_NE(root->renderSurface(), layer1->renderSurface()); |
935 EXPECT_TRUE(!!layer1->renderSurface()); | 933 EXPECT_TRUE(!!layer1->renderSurface()); |
936 } | 934 } |
937 | 935 |
938 class MissingTextureAnimatingLayer : public DidDrawCheckLayer { | 936 class MissingTextureAnimatingLayer : public DidDrawCheckLayer { |
939 public: | 937 public: |
940 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)); } | 938 static scoped_ptr<CCLayerImpl> create(int id, bool tileMissing, bool skipsDr
aw, bool animating, CCResourceProvider* resourceProvider) |
| 939 { |
| 940 return scoped_ptr<CCLayerImpl>(new MissingTextureAnimatingLayer(id, tile
Missing, skipsDraw, animating, resourceProvider)); |
| 941 } |
941 | 942 |
942 private: | 943 private: |
943 explicit MissingTextureAnimatingLayer(int id, bool tileMissing, bool skipsDr
aw, bool animating, CCResourceProvider* resourceProvider) | 944 explicit MissingTextureAnimatingLayer(int id, bool tileMissing, bool skipsDr
aw, bool animating, CCResourceProvider* resourceProvider) |
944 : DidDrawCheckLayer(id) | 945 : DidDrawCheckLayer(id) |
945 { | 946 { |
946 OwnPtr<CCLayerTilingData> tilingData = CCLayerTilingData::create(IntSize
(10, 10), CCLayerTilingData::NoBorderTexels); | 947 OwnPtr<CCLayerTilingData> tilingData = CCLayerTilingData::create(IntSize
(10, 10), CCLayerTilingData::NoBorderTexels); |
947 tilingData->setBounds(bounds()); | 948 tilingData->setBounds(bounds()); |
948 setTilingData(*tilingData.get()); | 949 setTilingData(*tilingData.get()); |
949 setSkipsDraw(skipsDraw); | 950 setSkipsDraw(skipsDraw); |
950 if (!tileMissing) { | 951 if (!tileMissing) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
992 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); | 993 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); |
993 root->addChild(MissingTextureAnimatingLayer::create(2, false, true, true, m_
hostImpl->resourceProvider())); | 994 root->addChild(MissingTextureAnimatingLayer::create(2, false, true, true, m_
hostImpl->resourceProvider())); |
994 | 995 |
995 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 996 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
996 m_hostImpl->drawLayers(frame); | 997 m_hostImpl->drawLayers(frame); |
997 m_hostImpl->didDrawAllLayers(frame); | 998 m_hostImpl->didDrawAllLayers(frame); |
998 } | 999 } |
999 | 1000 |
1000 TEST_P(CCLayerTreeHostImplTest, scrollRootIgnored) | 1001 TEST_P(CCLayerTreeHostImplTest, scrollRootIgnored) |
1001 { | 1002 { |
1002 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 1003 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
1003 root->setScrollable(false); | 1004 root->setScrollable(false); |
1004 m_hostImpl->setRootLayer(root.release()); | 1005 m_hostImpl->setRootLayer(root.Pass()); |
1005 initializeRendererAndDrawFrame(); | 1006 initializeRendererAndDrawFrame(); |
1006 | 1007 |
1007 // Scroll event is ignored because layer is not scrollable. | 1008 // Scroll event is ignored because layer is not scrollable. |
1008 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollIgnored); | 1009 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollIgnored); |
1009 EXPECT_FALSE(m_didRequestRedraw); | 1010 EXPECT_FALSE(m_didRequestRedraw); |
1010 EXPECT_FALSE(m_didRequestCommit); | 1011 EXPECT_FALSE(m_didRequestCommit); |
1011 } | 1012 } |
1012 | 1013 |
1013 TEST_P(CCLayerTreeHostImplTest, scrollNonCompositedRoot) | 1014 TEST_P(CCLayerTreeHostImplTest, scrollNonCompositedRoot) |
1014 { | 1015 { |
1015 // Test the configuration where a non-composited root layer is embedded in a | 1016 // Test the configuration where a non-composited root layer is embedded in a |
1016 // scrollable outer layer. | 1017 // scrollable outer layer. |
1017 IntSize surfaceSize(10, 10); | 1018 IntSize surfaceSize(10, 10); |
1018 | 1019 |
1019 OwnPtr<CCLayerImpl> contentLayer = CCLayerImpl::create(1); | 1020 scoped_ptr<CCLayerImpl> contentLayer = CCLayerImpl::create(1); |
1020 contentLayer->setUseLCDText(true); | 1021 contentLayer->setUseLCDText(true); |
1021 contentLayer->setDrawsContent(true); | 1022 contentLayer->setDrawsContent(true); |
1022 contentLayer->setPosition(FloatPoint(0, 0)); | 1023 contentLayer->setPosition(FloatPoint(0, 0)); |
1023 contentLayer->setAnchorPoint(FloatPoint(0, 0)); | 1024 contentLayer->setAnchorPoint(FloatPoint(0, 0)); |
1024 contentLayer->setBounds(surfaceSize); | 1025 contentLayer->setBounds(surfaceSize); |
1025 contentLayer->setContentBounds(IntSize(surfaceSize.width() * 2, surfaceSize.
height() * 2)); | 1026 contentLayer->setContentBounds(IntSize(surfaceSize.width() * 2, surfaceSize.
height() * 2)); |
1026 | 1027 |
1027 OwnPtr<CCLayerImpl> scrollLayer = CCLayerImpl::create(2); | 1028 scoped_ptr<CCLayerImpl> scrollLayer = CCLayerImpl::create(2); |
1028 scrollLayer->setScrollable(true); | 1029 scrollLayer->setScrollable(true); |
1029 scrollLayer->setMaxScrollPosition(surfaceSize); | 1030 scrollLayer->setMaxScrollPosition(surfaceSize); |
1030 scrollLayer->setBounds(surfaceSize); | 1031 scrollLayer->setBounds(surfaceSize); |
1031 scrollLayer->setContentBounds(surfaceSize); | 1032 scrollLayer->setContentBounds(surfaceSize); |
1032 scrollLayer->setPosition(FloatPoint(0, 0)); | 1033 scrollLayer->setPosition(FloatPoint(0, 0)); |
1033 scrollLayer->setAnchorPoint(FloatPoint(0, 0)); | 1034 scrollLayer->setAnchorPoint(FloatPoint(0, 0)); |
1034 scrollLayer->addChild(contentLayer.release()); | 1035 scrollLayer->addChild(contentLayer.Pass()); |
1035 | 1036 |
1036 m_hostImpl->setRootLayer(scrollLayer.release()); | 1037 m_hostImpl->setRootLayer(scrollLayer.Pass()); |
1037 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1038 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1038 initializeRendererAndDrawFrame(); | 1039 initializeRendererAndDrawFrame(); |
1039 | 1040 |
1040 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollStarted); | 1041 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollStarted); |
1041 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); | 1042 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); |
1042 m_hostImpl->scrollEnd(); | 1043 m_hostImpl->scrollEnd(); |
1043 EXPECT_TRUE(m_didRequestRedraw); | 1044 EXPECT_TRUE(m_didRequestRedraw); |
1044 EXPECT_TRUE(m_didRequestCommit); | 1045 EXPECT_TRUE(m_didRequestCommit); |
1045 } | 1046 } |
1046 | 1047 |
1047 TEST_P(CCLayerTreeHostImplTest, scrollChildCallsCommitAndRedraw) | 1048 TEST_P(CCLayerTreeHostImplTest, scrollChildCallsCommitAndRedraw) |
1048 { | 1049 { |
1049 IntSize surfaceSize(10, 10); | 1050 IntSize surfaceSize(10, 10); |
1050 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 1051 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
1051 root->setBounds(surfaceSize); | 1052 root->setBounds(surfaceSize); |
1052 root->setContentBounds(surfaceSize); | 1053 root->setContentBounds(surfaceSize); |
1053 root->addChild(createScrollableLayer(2, surfaceSize)); | 1054 root->addChild(createScrollableLayer(2, surfaceSize)); |
1054 m_hostImpl->setRootLayer(root.release()); | 1055 m_hostImpl->setRootLayer(root.Pass()); |
1055 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1056 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1056 initializeRendererAndDrawFrame(); | 1057 initializeRendererAndDrawFrame(); |
1057 | 1058 |
1058 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollStarted); | 1059 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollStarted); |
1059 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); | 1060 m_hostImpl->scrollBy(IntPoint(), IntSize(0, 10)); |
1060 m_hostImpl->scrollEnd(); | 1061 m_hostImpl->scrollEnd(); |
1061 EXPECT_TRUE(m_didRequestRedraw); | 1062 EXPECT_TRUE(m_didRequestRedraw); |
1062 EXPECT_TRUE(m_didRequestCommit); | 1063 EXPECT_TRUE(m_didRequestCommit); |
1063 } | 1064 } |
1064 | 1065 |
1065 TEST_P(CCLayerTreeHostImplTest, scrollMissesChild) | 1066 TEST_P(CCLayerTreeHostImplTest, scrollMissesChild) |
1066 { | 1067 { |
1067 IntSize surfaceSize(10, 10); | 1068 IntSize surfaceSize(10, 10); |
1068 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 1069 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
1069 root->addChild(createScrollableLayer(2, surfaceSize)); | 1070 root->addChild(createScrollableLayer(2, surfaceSize)); |
1070 m_hostImpl->setRootLayer(root.release()); | 1071 m_hostImpl->setRootLayer(root.Pass()); |
1071 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1072 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1072 initializeRendererAndDrawFrame(); | 1073 initializeRendererAndDrawFrame(); |
1073 | 1074 |
1074 // Scroll event is ignored because the input coordinate is outside the layer
boundaries. | 1075 // Scroll event is ignored because the input coordinate is outside the layer
boundaries. |
1075 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(15, 5), CCInputHandlerClient::Whe
el), CCInputHandlerClient::ScrollIgnored); | 1076 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(15, 5), CCInputHandlerClient::Whe
el), CCInputHandlerClient::ScrollIgnored); |
1076 EXPECT_FALSE(m_didRequestRedraw); | 1077 EXPECT_FALSE(m_didRequestRedraw); |
1077 EXPECT_FALSE(m_didRequestCommit); | 1078 EXPECT_FALSE(m_didRequestCommit); |
1078 } | 1079 } |
1079 | 1080 |
1080 TEST_P(CCLayerTreeHostImplTest, scrollMissesBackfacingChild) | 1081 TEST_P(CCLayerTreeHostImplTest, scrollMissesBackfacingChild) |
1081 { | 1082 { |
1082 IntSize surfaceSize(10, 10); | 1083 IntSize surfaceSize(10, 10); |
1083 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 1084 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
1084 OwnPtr<CCLayerImpl> child = createScrollableLayer(2, surfaceSize); | 1085 scoped_ptr<CCLayerImpl> child = createScrollableLayer(2, surfaceSize); |
1085 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1086 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1086 | 1087 |
1087 WebTransformationMatrix matrix; | 1088 WebTransformationMatrix matrix; |
1088 matrix.rotate3d(180, 0, 0); | 1089 matrix.rotate3d(180, 0, 0); |
1089 child->setTransform(matrix); | 1090 child->setTransform(matrix); |
1090 child->setDoubleSided(false); | 1091 child->setDoubleSided(false); |
1091 | 1092 |
1092 root->addChild(child.release()); | 1093 root->addChild(child.Pass()); |
1093 m_hostImpl->setRootLayer(root.release()); | 1094 m_hostImpl->setRootLayer(root.Pass()); |
1094 initializeRendererAndDrawFrame(); | 1095 initializeRendererAndDrawFrame(); |
1095 | 1096 |
1096 // Scroll event is ignored because the scrollable layer is not facing the vi
ewer and there is | 1097 // Scroll event is ignored because the scrollable layer is not facing the vi
ewer and there is |
1097 // nothing scrollable behind it. | 1098 // nothing scrollable behind it. |
1098 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollIgnored); | 1099 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollIgnored); |
1099 EXPECT_FALSE(m_didRequestRedraw); | 1100 EXPECT_FALSE(m_didRequestRedraw); |
1100 EXPECT_FALSE(m_didRequestCommit); | 1101 EXPECT_FALSE(m_didRequestCommit); |
1101 } | 1102 } |
1102 | 1103 |
1103 TEST_P(CCLayerTreeHostImplTest, scrollBlockedByContentLayer) | 1104 TEST_P(CCLayerTreeHostImplTest, scrollBlockedByContentLayer) |
1104 { | 1105 { |
1105 IntSize surfaceSize(10, 10); | 1106 IntSize surfaceSize(10, 10); |
1106 OwnPtr<CCLayerImpl> contentLayer = createScrollableLayer(1, surfaceSize); | 1107 scoped_ptr<CCLayerImpl> contentLayer = createScrollableLayer(1, surfaceSize)
; |
1107 contentLayer->setShouldScrollOnMainThread(true); | 1108 contentLayer->setShouldScrollOnMainThread(true); |
1108 contentLayer->setScrollable(false); | 1109 contentLayer->setScrollable(false); |
1109 | 1110 |
1110 OwnPtr<CCLayerImpl> scrollLayer = createScrollableLayer(2, surfaceSize); | 1111 scoped_ptr<CCLayerImpl> scrollLayer = createScrollableLayer(2, surfaceSize); |
1111 scrollLayer->addChild(contentLayer.release()); | 1112 scrollLayer->addChild(contentLayer.Pass()); |
1112 | 1113 |
1113 m_hostImpl->setRootLayer(scrollLayer.release()); | 1114 m_hostImpl->setRootLayer(scrollLayer.Pass()); |
1114 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1115 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1115 initializeRendererAndDrawFrame(); | 1116 initializeRendererAndDrawFrame(); |
1116 | 1117 |
1117 // Scrolling fails because the content layer is asking to be scrolled on the
main thread. | 1118 // Scrolling fails because the content layer is asking to be scrolled on the
main thread. |
1118 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollOnMainThread); | 1119 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollOnMainThread); |
1119 } | 1120 } |
1120 | 1121 |
1121 TEST_P(CCLayerTreeHostImplTest, scrollRootAndChangePageScaleOnMainThread) | 1122 TEST_P(CCLayerTreeHostImplTest, scrollRootAndChangePageScaleOnMainThread) |
1122 { | 1123 { |
1123 IntSize surfaceSize(10, 10); | 1124 IntSize surfaceSize(10, 10); |
1124 float pageScale = 2; | 1125 float pageScale = 2; |
1125 OwnPtr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize); | 1126 scoped_ptr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize); |
1126 m_hostImpl->setRootLayer(root.release()); | 1127 m_hostImpl->setRootLayer(root.Pass()); |
1127 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1128 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1128 initializeRendererAndDrawFrame(); | 1129 initializeRendererAndDrawFrame(); |
1129 | 1130 |
1130 IntSize scrollDelta(0, 10); | 1131 IntSize scrollDelta(0, 10); |
1131 IntSize expectedScrollDelta(scrollDelta); | 1132 IntSize expectedScrollDelta(scrollDelta); |
1132 IntSize expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollPosition()); | 1133 IntSize expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollPosition()); |
1133 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollStarted); | 1134 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollStarted); |
1134 m_hostImpl->scrollBy(IntPoint(), scrollDelta); | 1135 m_hostImpl->scrollBy(IntPoint(), scrollDelta); |
1135 m_hostImpl->scrollEnd(); | 1136 m_hostImpl->scrollEnd(); |
1136 | 1137 |
(...skipping 11 matching lines...) Expand all Loading... |
1148 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), expectedMaxScroll); | 1149 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), expectedMaxScroll); |
1149 | 1150 |
1150 // The page scale delta remains constant because the impl thread did not sca
le. | 1151 // The page scale delta remains constant because the impl thread did not sca
le. |
1151 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), WebTransformationMatrix(
)); | 1152 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), WebTransformationMatrix(
)); |
1152 } | 1153 } |
1153 | 1154 |
1154 TEST_P(CCLayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread) | 1155 TEST_P(CCLayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread) |
1155 { | 1156 { |
1156 IntSize surfaceSize(10, 10); | 1157 IntSize surfaceSize(10, 10); |
1157 float pageScale = 2; | 1158 float pageScale = 2; |
1158 OwnPtr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize); | 1159 scoped_ptr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize); |
1159 m_hostImpl->setRootLayer(root.release()); | 1160 m_hostImpl->setRootLayer(root.Pass()); |
1160 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1161 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1161 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); | 1162 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); |
1162 initializeRendererAndDrawFrame(); | 1163 initializeRendererAndDrawFrame(); |
1163 | 1164 |
1164 IntSize scrollDelta(0, 10); | 1165 IntSize scrollDelta(0, 10); |
1165 IntSize expectedScrollDelta(scrollDelta); | 1166 IntSize expectedScrollDelta(scrollDelta); |
1166 IntSize expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollPosition()); | 1167 IntSize expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollPosition()); |
1167 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollStarted); | 1168 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollStarted); |
1168 m_hostImpl->scrollBy(IntPoint(), scrollDelta); | 1169 m_hostImpl->scrollBy(IntPoint(), scrollDelta); |
1169 m_hostImpl->scrollEnd(); | 1170 m_hostImpl->scrollEnd(); |
(...skipping 25 matching lines...) Expand all Loading... |
1195 | 1196 |
1196 float newPageScale = 2; | 1197 float newPageScale = 2; |
1197 WebTransformationMatrix newPageScaleMatrix; | 1198 WebTransformationMatrix newPageScaleMatrix; |
1198 newPageScaleMatrix.scale(newPageScale); | 1199 newPageScaleMatrix.scale(newPageScale); |
1199 | 1200 |
1200 // Create a normal scrollable root layer and another scrollable child layer. | 1201 // Create a normal scrollable root layer and another scrollable child layer. |
1201 setupScrollAndContentsLayers(surfaceSize); | 1202 setupScrollAndContentsLayers(surfaceSize); |
1202 CCLayerImpl* root = m_hostImpl->rootLayer(); | 1203 CCLayerImpl* root = m_hostImpl->rootLayer(); |
1203 CCLayerImpl* child = root->children()[0]; | 1204 CCLayerImpl* child = root->children()[0]; |
1204 | 1205 |
1205 OwnPtr<CCLayerImpl> scrollableChild = createScrollableLayer(3, surfaceSize); | 1206 scoped_ptr<CCLayerImpl> scrollableChild = createScrollableLayer(3, surfaceSi
ze); |
1206 child->addChild(scrollableChild.release()); | 1207 child->addChild(scrollableChild.Pass()); |
1207 CCLayerImpl* grandChild = child->children()[0]; | 1208 CCLayerImpl* grandChild = child->children()[0]; |
1208 | 1209 |
1209 // Set new page scale on impl thread by pinching. | 1210 // Set new page scale on impl thread by pinching. |
1210 m_hostImpl->pinchGestureBegin(); | 1211 m_hostImpl->pinchGestureBegin(); |
1211 m_hostImpl->pinchGestureUpdate(newPageScale, IntPoint()); | 1212 m_hostImpl->pinchGestureUpdate(newPageScale, IntPoint()); |
1212 m_hostImpl->pinchGestureEnd(); | 1213 m_hostImpl->pinchGestureEnd(); |
1213 m_hostImpl->updateRootScrollLayerImplTransform(); | 1214 m_hostImpl->updateRootScrollLayerImplTransform(); |
1214 | 1215 |
1215 // The page scale delta should only be applied to the scrollable root layer. | 1216 // The page scale delta should only be applied to the scrollable root layer. |
1216 EXPECT_EQ(root->implTransform(), newPageScaleMatrix); | 1217 EXPECT_EQ(root->implTransform(), newPageScaleMatrix); |
(...skipping 11 matching lines...) Expand all Loading... |
1228 EXPECT_EQ(root->drawTransform().m22(), newPageScale); | 1229 EXPECT_EQ(root->drawTransform().m22(), newPageScale); |
1229 EXPECT_EQ(child->drawTransform().m11(), newPageScale); | 1230 EXPECT_EQ(child->drawTransform().m11(), newPageScale); |
1230 EXPECT_EQ(child->drawTransform().m22(), newPageScale); | 1231 EXPECT_EQ(child->drawTransform().m22(), newPageScale); |
1231 EXPECT_EQ(grandChild->drawTransform().m11(), newPageScale); | 1232 EXPECT_EQ(grandChild->drawTransform().m11(), newPageScale); |
1232 EXPECT_EQ(grandChild->drawTransform().m22(), newPageScale); | 1233 EXPECT_EQ(grandChild->drawTransform().m22(), newPageScale); |
1233 } | 1234 } |
1234 | 1235 |
1235 TEST_P(CCLayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread) | 1236 TEST_P(CCLayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread) |
1236 { | 1237 { |
1237 IntSize surfaceSize(10, 10); | 1238 IntSize surfaceSize(10, 10); |
1238 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 1239 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
1239 root->setBounds(surfaceSize); | 1240 root->setBounds(surfaceSize); |
1240 root->setContentBounds(surfaceSize); | 1241 root->setContentBounds(surfaceSize); |
1241 // Also mark the root scrollable so it becomes the root scroll layer. | 1242 // Also mark the root scrollable so it becomes the root scroll layer. |
1242 root->setScrollable(true); | 1243 root->setScrollable(true); |
1243 int scrollLayerId = 2; | 1244 int scrollLayerId = 2; |
1244 root->addChild(createScrollableLayer(scrollLayerId, surfaceSize)); | 1245 root->addChild(createScrollableLayer(scrollLayerId, surfaceSize)); |
1245 m_hostImpl->setRootLayer(root.release()); | 1246 m_hostImpl->setRootLayer(root.Pass()); |
1246 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1247 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1247 initializeRendererAndDrawFrame(); | 1248 initializeRendererAndDrawFrame(); |
1248 | 1249 |
1249 CCLayerImpl* child = m_hostImpl->rootLayer()->children()[0]; | 1250 CCLayerImpl* child = m_hostImpl->rootLayer()->children()[0]; |
1250 | 1251 |
1251 IntSize scrollDelta(0, 10); | 1252 IntSize scrollDelta(0, 10); |
1252 IntSize expectedScrollDelta(scrollDelta); | 1253 IntSize expectedScrollDelta(scrollDelta); |
1253 IntSize expectedMaxScroll(child->maxScrollPosition()); | 1254 IntSize expectedMaxScroll(child->maxScrollPosition()); |
1254 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollStarted); | 1255 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee
l), CCInputHandlerClient::ScrollStarted); |
1255 m_hostImpl->scrollBy(IntPoint(), scrollDelta); | 1256 m_hostImpl->scrollBy(IntPoint(), scrollDelta); |
(...skipping 18 matching lines...) Expand all Loading... |
1274 WebTransformationMatrix identityTransform; | 1275 WebTransformationMatrix identityTransform; |
1275 EXPECT_EQ(child->implTransform(), WebTransformationMatrix()); | 1276 EXPECT_EQ(child->implTransform(), WebTransformationMatrix()); |
1276 } | 1277 } |
1277 | 1278 |
1278 TEST_P(CCLayerTreeHostImplTest, scrollChildBeyondLimit) | 1279 TEST_P(CCLayerTreeHostImplTest, scrollChildBeyondLimit) |
1279 { | 1280 { |
1280 // Scroll a child layer beyond its maximum scroll range and make sure the | 1281 // Scroll a child layer beyond its maximum scroll range and make sure the |
1281 // parent layer is scrolled on the axis on which the child was unable to | 1282 // parent layer is scrolled on the axis on which the child was unable to |
1282 // scroll. | 1283 // scroll. |
1283 IntSize surfaceSize(10, 10); | 1284 IntSize surfaceSize(10, 10); |
1284 OwnPtr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize); | 1285 scoped_ptr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize); |
1285 | 1286 |
1286 OwnPtr<CCLayerImpl> grandChild = createScrollableLayer(3, surfaceSize); | 1287 scoped_ptr<CCLayerImpl> grandChild = createScrollableLayer(3, surfaceSize); |
1287 grandChild->setScrollPosition(IntPoint(0, 5)); | 1288 grandChild->setScrollPosition(IntPoint(0, 5)); |
1288 | 1289 |
1289 OwnPtr<CCLayerImpl> child = createScrollableLayer(2, surfaceSize); | 1290 scoped_ptr<CCLayerImpl> child = createScrollableLayer(2, surfaceSize); |
1290 child->setScrollPosition(IntPoint(3, 0)); | 1291 child->setScrollPosition(IntPoint(3, 0)); |
1291 child->addChild(grandChild.release()); | 1292 child->addChild(grandChild.Pass()); |
1292 | 1293 |
1293 root->addChild(child.release()); | 1294 root->addChild(child.Pass()); |
1294 m_hostImpl->setRootLayer(root.release()); | 1295 m_hostImpl->setRootLayer(root.Pass()); |
1295 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1296 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1296 initializeRendererAndDrawFrame(); | 1297 initializeRendererAndDrawFrame(); |
1297 { | 1298 { |
1298 IntSize scrollDelta(-8, -7); | 1299 IntSize scrollDelta(-8, -7); |
1299 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::
Wheel), CCInputHandlerClient::ScrollStarted); | 1300 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::
Wheel), CCInputHandlerClient::ScrollStarted); |
1300 m_hostImpl->scrollBy(IntPoint(), scrollDelta); | 1301 m_hostImpl->scrollBy(IntPoint(), scrollDelta); |
1301 m_hostImpl->scrollEnd(); | 1302 m_hostImpl->scrollEnd(); |
1302 | 1303 |
1303 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas
(); | 1304 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas
(); |
1304 | 1305 |
1305 // The grand child should have scrolled up to its limit. | 1306 // The grand child should have scrolled up to its limit. |
1306 CCLayerImpl* child = m_hostImpl->rootLayer()->children()[0]; | 1307 CCLayerImpl* child = m_hostImpl->rootLayer()->children()[0]; |
1307 CCLayerImpl* grandChild = child->children()[0]; | 1308 CCLayerImpl* grandChild = child->children()[0]; |
1308 expectContains(*scrollInfo.get(), grandChild->id(), IntSize(0, -5)); | 1309 expectContains(*scrollInfo.get(), grandChild->id(), IntSize(0, -5)); |
1309 | 1310 |
1310 // The child should have only scrolled on the other axis. | 1311 // The child should have only scrolled on the other axis. |
1311 expectContains(*scrollInfo.get(), child->id(), IntSize(-3, 0)); | 1312 expectContains(*scrollInfo.get(), child->id(), IntSize(-3, 0)); |
1312 } | 1313 } |
1313 } | 1314 } |
1314 | 1315 |
1315 TEST_P(CCLayerTreeHostImplTest, scrollEventBubbling) | 1316 TEST_P(CCLayerTreeHostImplTest, scrollEventBubbling) |
1316 { | 1317 { |
1317 // When we try to scroll a non-scrollable child layer, the scroll delta | 1318 // When we try to scroll a non-scrollable child layer, the scroll delta |
1318 // should be applied to one of its ancestors if possible. | 1319 // should be applied to one of its ancestors if possible. |
1319 IntSize surfaceSize(10, 10); | 1320 IntSize surfaceSize(10, 10); |
1320 OwnPtr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize); | 1321 scoped_ptr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize); |
1321 OwnPtr<CCLayerImpl> child = createScrollableLayer(2, surfaceSize); | 1322 scoped_ptr<CCLayerImpl> child = createScrollableLayer(2, surfaceSize); |
1322 | 1323 |
1323 child->setScrollable(false); | 1324 child->setScrollable(false); |
1324 root->addChild(child.release()); | 1325 root->addChild(child.Pass()); |
1325 | 1326 |
1326 m_hostImpl->setRootLayer(root.release()); | 1327 m_hostImpl->setRootLayer(root.Pass()); |
1327 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1328 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1328 initializeRendererAndDrawFrame(); | 1329 initializeRendererAndDrawFrame(); |
1329 { | 1330 { |
1330 IntSize scrollDelta(0, 4); | 1331 IntSize scrollDelta(0, 4); |
1331 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::
Wheel), CCInputHandlerClient::ScrollStarted); | 1332 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::
Wheel), CCInputHandlerClient::ScrollStarted); |
1332 m_hostImpl->scrollBy(IntPoint(), scrollDelta); | 1333 m_hostImpl->scrollBy(IntPoint(), scrollDelta); |
1333 m_hostImpl->scrollEnd(); | 1334 m_hostImpl->scrollEnd(); |
1334 | 1335 |
1335 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas
(); | 1336 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas
(); |
1336 | 1337 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1390 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), wheelScroll
Delta); | 1391 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), wheelScroll
Delta); |
1391 } | 1392 } |
1392 | 1393 |
1393 TEST_P(CCLayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer) | 1394 TEST_P(CCLayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer) |
1394 { | 1395 { |
1395 setupScrollAndContentsLayers(IntSize(100, 100)); | 1396 setupScrollAndContentsLayers(IntSize(100, 100)); |
1396 int childLayerId = 3; | 1397 int childLayerId = 3; |
1397 float childLayerAngle = -20; | 1398 float childLayerAngle = -20; |
1398 | 1399 |
1399 // Create a child layer that is rotated to a non-axis-aligned angle. | 1400 // Create a child layer that is rotated to a non-axis-aligned angle. |
1400 OwnPtr<CCLayerImpl> child = createScrollableLayer(childLayerId, m_hostImpl->
rootLayer()->contentBounds()); | 1401 scoped_ptr<CCLayerImpl> child = createScrollableLayer(childLayerId, m_hostIm
pl->rootLayer()->contentBounds()); |
1401 WebTransformationMatrix rotateTransform; | 1402 WebTransformationMatrix rotateTransform; |
1402 rotateTransform.translate(-50, -50); | 1403 rotateTransform.translate(-50, -50); |
1403 rotateTransform.rotate(childLayerAngle); | 1404 rotateTransform.rotate(childLayerAngle); |
1404 rotateTransform.translate(50, 50); | 1405 rotateTransform.translate(50, 50); |
1405 child->setTransform(rotateTransform); | 1406 child->setTransform(rotateTransform); |
1406 | 1407 |
1407 // Only allow vertical scrolling. | 1408 // Only allow vertical scrolling. |
1408 child->setMaxScrollPosition(IntSize(0, child->contentBounds().height())); | 1409 child->setMaxScrollPosition(IntSize(0, child->contentBounds().height())); |
1409 m_hostImpl->rootLayer()->addChild(child.release()); | 1410 m_hostImpl->rootLayer()->addChild(child.Pass()); |
1410 | 1411 |
1411 IntSize surfaceSize(50, 50); | 1412 IntSize surfaceSize(50, 50); |
1412 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1413 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1413 initializeRendererAndDrawFrame(); | 1414 initializeRendererAndDrawFrame(); |
1414 | 1415 |
1415 { | 1416 { |
1416 // Scroll down in screen coordinates with a gesture. | 1417 // Scroll down in screen coordinates with a gesture. |
1417 IntSize gestureScrollDelta(0, 10); | 1418 IntSize gestureScrollDelta(0, 10); |
1418 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::
Gesture), CCInputHandlerClient::ScrollStarted); | 1419 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::
Gesture), CCInputHandlerClient::ScrollStarted); |
1419 m_hostImpl->scrollBy(IntPoint(), gestureScrollDelta); | 1420 m_hostImpl->scrollBy(IntPoint(), gestureScrollDelta); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1504 } | 1505 } |
1505 | 1506 |
1506 bool blend() const { return m_blend; } | 1507 bool blend() const { return m_blend; } |
1507 | 1508 |
1508 private: | 1509 private: |
1509 bool m_blend; | 1510 bool m_blend; |
1510 }; | 1511 }; |
1511 | 1512 |
1512 class BlendStateCheckLayer : public CCLayerImpl { | 1513 class BlendStateCheckLayer : public CCLayerImpl { |
1513 public: | 1514 public: |
1514 static PassOwnPtr<BlendStateCheckLayer> create(int id, CCResourceProvider* r
esourceProvider) { return adoptPtr(new BlendStateCheckLayer(id, resourceProvider
)); } | 1515 static scoped_ptr<CCLayerImpl> create(int id, CCResourceProvider* resourcePr
ovider) { return scoped_ptr<CCLayerImpl>(new BlendStateCheckLayer(id, resourcePr
ovider)); } |
1515 | 1516 |
1516 virtual void appendQuads(CCQuadSink& quadSink, CCAppendQuadsData& appendQuad
sData) OVERRIDE | 1517 virtual void appendQuads(CCQuadSink& quadSink, CCAppendQuadsData& appendQuad
sData) OVERRIDE |
1517 { | 1518 { |
1518 m_quadsAppended = true; | 1519 m_quadsAppended = true; |
1519 | 1520 |
1520 IntRect opaqueRect; | 1521 IntRect opaqueRect; |
1521 if (contentsOpaque()) | 1522 if (contentsOpaque()) |
1522 opaqueRect = m_quadRect; | 1523 opaqueRect = m_quadRect; |
1523 else | 1524 else |
1524 opaqueRect = m_opaqueContentRect; | 1525 opaqueRect = m_opaqueContentRect; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1565 bool m_quadsAppended; | 1566 bool m_quadsAppended; |
1566 IntRect m_quadRect; | 1567 IntRect m_quadRect; |
1567 IntRect m_opaqueContentRect; | 1568 IntRect m_opaqueContentRect; |
1568 IntRect m_quadVisibleRect; | 1569 IntRect m_quadVisibleRect; |
1569 CCResourceProvider::ResourceId m_resourceId; | 1570 CCResourceProvider::ResourceId m_resourceId; |
1570 }; | 1571 }; |
1571 | 1572 |
1572 TEST_P(CCLayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers) | 1573 TEST_P(CCLayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers) |
1573 { | 1574 { |
1574 { | 1575 { |
1575 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 1576 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
1576 root->setAnchorPoint(FloatPoint(0, 0)); | 1577 root->setAnchorPoint(FloatPoint(0, 0)); |
1577 root->setBounds(IntSize(10, 10)); | 1578 root->setBounds(IntSize(10, 10)); |
1578 root->setContentBounds(root->bounds()); | 1579 root->setContentBounds(root->bounds()); |
1579 root->setDrawsContent(false); | 1580 root->setDrawsContent(false); |
1580 m_hostImpl->setRootLayer(root.release()); | 1581 m_hostImpl->setRootLayer(root.Pass()); |
1581 } | 1582 } |
1582 CCLayerImpl* root = m_hostImpl->rootLayer(); | 1583 CCLayerImpl* root = m_hostImpl->rootLayer(); |
1583 | 1584 |
1584 root->addChild(BlendStateCheckLayer::create(2, m_hostImpl->resourceProvider(
))); | 1585 root->addChild(BlendStateCheckLayer::create(2, m_hostImpl->resourceProvider(
))); |
1585 BlendStateCheckLayer* layer1 = static_cast<BlendStateCheckLayer*>(root->chil
dren()[0]); | 1586 BlendStateCheckLayer* layer1 = static_cast<BlendStateCheckLayer*>(root->chil
dren()[0]); |
1586 layer1->setPosition(FloatPoint(2, 2)); | 1587 layer1->setPosition(FloatPoint(2, 2)); |
1587 | 1588 |
1588 CCLayerTreeHostImpl::FrameData frame; | 1589 CCLayerTreeHostImpl::FrameData frame; |
1589 | 1590 |
1590 // Opaque layer, drawn without blending. | 1591 // Opaque layer, drawn without blending. |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1857 } | 1858 } |
1858 | 1859 |
1859 bool reshapeCalled() const { return m_reshapeCalled; } | 1860 bool reshapeCalled() const { return m_reshapeCalled; } |
1860 | 1861 |
1861 private: | 1862 private: |
1862 bool m_reshapeCalled; | 1863 bool m_reshapeCalled; |
1863 }; | 1864 }; |
1864 | 1865 |
1865 class FakeDrawableCCLayerImpl: public CCLayerImpl { | 1866 class FakeDrawableCCLayerImpl: public CCLayerImpl { |
1866 public: | 1867 public: |
| 1868 static scoped_ptr<CCLayerImpl> create(int id) { return scoped_ptr<CCLayerImp
l>(new FakeDrawableCCLayerImpl(id)); } |
| 1869 protected: |
1867 explicit FakeDrawableCCLayerImpl(int id) : CCLayerImpl(id) { } | 1870 explicit FakeDrawableCCLayerImpl(int id) : CCLayerImpl(id) { } |
1868 }; | 1871 }; |
1869 | 1872 |
1870 // Only reshape when we know we are going to draw. Otherwise, the reshape | 1873 // Only reshape when we know we are going to draw. Otherwise, the reshape |
1871 // can leave the window at the wrong size if we never draw and the proper | 1874 // can leave the window at the wrong size if we never draw and the proper |
1872 // viewport size is never set. | 1875 // viewport size is never set. |
1873 TEST_P(CCLayerTreeHostImplTest, reshapeNotCalledUntilDraw) | 1876 TEST_P(CCLayerTreeHostImplTest, reshapeNotCalledUntilDraw) |
1874 { | 1877 { |
1875 scoped_ptr<CCGraphicsContext> ccContext = FakeWebCompositorOutputSurface::cr
eate(adoptPtr(new ReshapeTrackerContext)).PassAs<CCGraphicsContext>(); | 1878 scoped_ptr<CCGraphicsContext> ccContext = FakeWebCompositorOutputSurface::cr
eate(adoptPtr(new ReshapeTrackerContext)).PassAs<CCGraphicsContext>(); |
1876 ReshapeTrackerContext* reshapeTracker = static_cast<ReshapeTrackerContext*>(
ccContext->context3D()); | 1879 ReshapeTrackerContext* reshapeTracker = static_cast<ReshapeTrackerContext*>(
ccContext->context3D()); |
1877 m_hostImpl->initializeRenderer(ccContext.Pass()); | 1880 m_hostImpl->initializeRenderer(ccContext.Pass()); |
1878 | 1881 |
1879 CCLayerImpl* root = new FakeDrawableCCLayerImpl(1); | 1882 scoped_ptr<CCLayerImpl> root = FakeDrawableCCLayerImpl::create(1); |
1880 root->setAnchorPoint(FloatPoint(0, 0)); | 1883 root->setAnchorPoint(FloatPoint(0, 0)); |
1881 root->setBounds(IntSize(10, 10)); | 1884 root->setBounds(IntSize(10, 10)); |
1882 root->setDrawsContent(true); | 1885 root->setDrawsContent(true); |
1883 m_hostImpl->setRootLayer(adoptPtr(root)); | 1886 m_hostImpl->setRootLayer(root.Pass()); |
1884 EXPECT_FALSE(reshapeTracker->reshapeCalled()); | 1887 EXPECT_FALSE(reshapeTracker->reshapeCalled()); |
1885 | 1888 |
1886 CCLayerTreeHostImpl::FrameData frame; | 1889 CCLayerTreeHostImpl::FrameData frame; |
1887 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1890 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
1888 m_hostImpl->drawLayers(frame); | 1891 m_hostImpl->drawLayers(frame); |
1889 EXPECT_TRUE(reshapeTracker->reshapeCalled()); | 1892 EXPECT_TRUE(reshapeTracker->reshapeCalled()); |
1890 m_hostImpl->didDrawAllLayers(frame); | 1893 m_hostImpl->didDrawAllLayers(frame); |
1891 } | 1894 } |
1892 | 1895 |
1893 class PartialSwapTrackerContext : public FakeWebGraphicsContext3D { | 1896 class PartialSwapTrackerContext : public FakeWebGraphicsContext3D { |
(...skipping 25 matching lines...) Expand all Loading... |
1919 PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrack
erContext*>(ccContext->context3D()); | 1922 PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrack
erContext*>(ccContext->context3D()); |
1920 | 1923 |
1921 // This test creates its own CCLayerTreeHostImpl, so | 1924 // This test creates its own CCLayerTreeHostImpl, so |
1922 // that we can force partial swap enabled. | 1925 // that we can force partial swap enabled. |
1923 CCLayerTreeSettings settings; | 1926 CCLayerTreeSettings settings; |
1924 CCSettings::setPartialSwapEnabled(true); | 1927 CCSettings::setPartialSwapEnabled(true); |
1925 scoped_ptr<CCLayerTreeHostImpl> layerTreeHostImpl = CCLayerTreeHostImpl::cre
ate(settings, this); | 1928 scoped_ptr<CCLayerTreeHostImpl> layerTreeHostImpl = CCLayerTreeHostImpl::cre
ate(settings, this); |
1926 layerTreeHostImpl->initializeRenderer(ccContext.Pass()); | 1929 layerTreeHostImpl->initializeRenderer(ccContext.Pass()); |
1927 layerTreeHostImpl->setViewportSize(IntSize(500, 500), IntSize(500, 500)); | 1930 layerTreeHostImpl->setViewportSize(IntSize(500, 500), IntSize(500, 500)); |
1928 | 1931 |
1929 CCLayerImpl* root = new FakeDrawableCCLayerImpl(1); | 1932 scoped_ptr<CCLayerImpl> root = FakeDrawableCCLayerImpl::create(1); |
1930 CCLayerImpl* child = new FakeDrawableCCLayerImpl(2); | 1933 scoped_ptr<CCLayerImpl> child = FakeDrawableCCLayerImpl::create(2); |
1931 child->setPosition(FloatPoint(12, 13)); | 1934 child->setPosition(FloatPoint(12, 13)); |
1932 child->setAnchorPoint(FloatPoint(0, 0)); | 1935 child->setAnchorPoint(FloatPoint(0, 0)); |
1933 child->setBounds(IntSize(14, 15)); | 1936 child->setBounds(IntSize(14, 15)); |
1934 child->setContentBounds(IntSize(14, 15)); | 1937 child->setContentBounds(IntSize(14, 15)); |
1935 child->setDrawsContent(true); | 1938 child->setDrawsContent(true); |
1936 root->setAnchorPoint(FloatPoint(0, 0)); | 1939 root->setAnchorPoint(FloatPoint(0, 0)); |
1937 root->setBounds(IntSize(500, 500)); | 1940 root->setBounds(IntSize(500, 500)); |
1938 root->setContentBounds(IntSize(500, 500)); | 1941 root->setContentBounds(IntSize(500, 500)); |
1939 root->setDrawsContent(true); | 1942 root->setDrawsContent(true); |
1940 root->addChild(adoptPtr(child)); | 1943 root->addChild(child.Pass()); |
1941 layerTreeHostImpl->setRootLayer(adoptPtr(root)); | 1944 layerTreeHostImpl->setRootLayer(root.Pass()); |
1942 | 1945 |
1943 CCLayerTreeHostImpl::FrameData frame; | 1946 CCLayerTreeHostImpl::FrameData frame; |
1944 | 1947 |
1945 // First frame, the entire screen should get swapped. | 1948 // First frame, the entire screen should get swapped. |
1946 EXPECT_TRUE(layerTreeHostImpl->prepareToDraw(frame)); | 1949 EXPECT_TRUE(layerTreeHostImpl->prepareToDraw(frame)); |
1947 layerTreeHostImpl->drawLayers(frame); | 1950 layerTreeHostImpl->drawLayers(frame); |
1948 layerTreeHostImpl->didDrawAllLayers(frame); | 1951 layerTreeHostImpl->didDrawAllLayers(frame); |
1949 layerTreeHostImpl->swapBuffers(); | 1952 layerTreeHostImpl->swapBuffers(); |
1950 IntRect actualSwapRect = partialSwapTracker->partialSwapRect(); | 1953 IntRect actualSwapRect = partialSwapTracker->partialSwapRect(); |
1951 IntRect expectedSwapRect = IntRect(IntPoint::zero(), IntSize(500, 500)); | 1954 IntRect expectedSwapRect = IntRect(IntPoint::zero(), IntSize(500, 500)); |
(...skipping 30 matching lines...) Expand all Loading... |
1982 actualSwapRect = partialSwapTracker->partialSwapRect(); | 1985 actualSwapRect = partialSwapTracker->partialSwapRect(); |
1983 expectedSwapRect = IntRect(IntPoint::zero(), IntSize(10, 10)); | 1986 expectedSwapRect = IntRect(IntPoint::zero(), IntSize(10, 10)); |
1984 EXPECT_EQ(expectedSwapRect.x(), actualSwapRect.x()); | 1987 EXPECT_EQ(expectedSwapRect.x(), actualSwapRect.x()); |
1985 EXPECT_EQ(expectedSwapRect.y(), actualSwapRect.y()); | 1988 EXPECT_EQ(expectedSwapRect.y(), actualSwapRect.y()); |
1986 EXPECT_EQ(expectedSwapRect.width(), actualSwapRect.width()); | 1989 EXPECT_EQ(expectedSwapRect.width(), actualSwapRect.width()); |
1987 EXPECT_EQ(expectedSwapRect.height(), actualSwapRect.height()); | 1990 EXPECT_EQ(expectedSwapRect.height(), actualSwapRect.height()); |
1988 } | 1991 } |
1989 | 1992 |
1990 TEST_P(CCLayerTreeHostImplTest, rootLayerDoesntCreateExtraSurface) | 1993 TEST_P(CCLayerTreeHostImplTest, rootLayerDoesntCreateExtraSurface) |
1991 { | 1994 { |
1992 CCLayerImpl* root = new FakeDrawableCCLayerImpl(1); | 1995 scoped_ptr<CCLayerImpl> root = FakeDrawableCCLayerImpl::create(1); |
1993 CCLayerImpl* child = new FakeDrawableCCLayerImpl(2); | 1996 scoped_ptr<CCLayerImpl> child = FakeDrawableCCLayerImpl::create(2); |
1994 child->setAnchorPoint(FloatPoint(0, 0)); | 1997 child->setAnchorPoint(FloatPoint(0, 0)); |
1995 child->setBounds(IntSize(10, 10)); | 1998 child->setBounds(IntSize(10, 10)); |
1996 child->setContentBounds(IntSize(10, 10)); | 1999 child->setContentBounds(IntSize(10, 10)); |
1997 child->setDrawsContent(true); | 2000 child->setDrawsContent(true); |
1998 root->setAnchorPoint(FloatPoint(0, 0)); | 2001 root->setAnchorPoint(FloatPoint(0, 0)); |
1999 root->setBounds(IntSize(10, 10)); | 2002 root->setBounds(IntSize(10, 10)); |
2000 root->setContentBounds(IntSize(10, 10)); | 2003 root->setContentBounds(IntSize(10, 10)); |
2001 root->setDrawsContent(true); | 2004 root->setDrawsContent(true); |
2002 root->setOpacity(0.7f); | 2005 root->setOpacity(0.7f); |
2003 root->addChild(adoptPtr(child)); | 2006 root->addChild(child.Pass()); |
2004 | 2007 |
2005 m_hostImpl->setRootLayer(adoptPtr(root)); | 2008 m_hostImpl->setRootLayer(root.Pass()); |
2006 | 2009 |
2007 CCLayerTreeHostImpl::FrameData frame; | 2010 CCLayerTreeHostImpl::FrameData frame; |
2008 | 2011 |
2009 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2012 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
2010 EXPECT_EQ(1u, frame.renderSurfaceLayerList->size()); | 2013 EXPECT_EQ(1u, frame.renderSurfaceLayerList->size()); |
2011 EXPECT_EQ(1u, frame.renderPasses.size()); | 2014 EXPECT_EQ(1u, frame.renderPasses.size()); |
2012 m_hostImpl->didDrawAllLayers(frame); | 2015 m_hostImpl->didDrawAllLayers(frame); |
2013 } | 2016 } |
2014 | 2017 |
2015 } // namespace | 2018 } // namespace |
2016 | 2019 |
2017 class FakeLayerWithQuads : public CCLayerImpl { | 2020 class FakeLayerWithQuads : public CCLayerImpl { |
2018 public: | 2021 public: |
2019 static PassOwnPtr<FakeLayerWithQuads> create(int id) { return adoptPtr(new F
akeLayerWithQuads(id)); } | 2022 static scoped_ptr<CCLayerImpl> create(int id) { return scoped_ptr<CCLayerImp
l>(new FakeLayerWithQuads(id)); } |
2020 | 2023 |
2021 virtual void appendQuads(CCQuadSink& quadSink, CCAppendQuadsData& appendQuad
sData) OVERRIDE | 2024 virtual void appendQuads(CCQuadSink& quadSink, CCAppendQuadsData& appendQuad
sData) OVERRIDE |
2022 { | 2025 { |
2023 CCSharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createS
haredQuadState()); | 2026 CCSharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createS
haredQuadState()); |
2024 | 2027 |
2025 SkColor gray = SkColorSetRGB(100, 100, 100); | 2028 SkColor gray = SkColorSetRGB(100, 100, 100); |
2026 IntRect quadRect(IntPoint(0, 0), contentBounds()); | 2029 IntRect quadRect(IntPoint(0, 0), contentBounds()); |
2027 scoped_ptr<CCSolidColorDrawQuad> myQuad = CCSolidColorDrawQuad::create(s
haredQuadState, quadRect, gray); | 2030 scoped_ptr<CCSolidColorDrawQuad> myQuad = CCSolidColorDrawQuad::create(s
haredQuadState, quadRect, gray); |
2028 quadSink.append(myQuad.PassAs<CCDrawQuad>(), appendQuadsData); | 2031 quadSink.append(myQuad.PassAs<CCDrawQuad>(), appendQuadsData); |
2029 } | 2032 } |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2224 | | | 3 | | 2227 | | | 3 | |
2225 | | +-------------------+ | 2228 | | +-------------------+ |
2226 | | | | | 2229 | | | | |
2227 | +-----------+ | | 2230 | +-----------+ | |
2228 | | | 2231 | | |
2229 | | | 2232 | | |
2230 +--------------------+ | 2233 +--------------------+ |
2231 | 2234 |
2232 Layers 1, 2 have render surfaces | 2235 Layers 1, 2 have render surfaces |
2233 */ | 2236 */ |
2234 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 2237 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
2235 OwnPtr<CCLayerImpl> child = CCLayerImpl::create(2); | 2238 scoped_ptr<CCLayerImpl> child = CCLayerImpl::create(2); |
2236 OwnPtr<CCLayerImpl> grandChild = FakeLayerWithQuads::create(3); | 2239 scoped_ptr<CCLayerImpl> grandChild = FakeLayerWithQuads::create(3); |
2237 | 2240 |
2238 IntRect rootRect(0, 0, 100, 100); | 2241 IntRect rootRect(0, 0, 100, 100); |
2239 IntRect childRect(10, 10, 50, 50); | 2242 IntRect childRect(10, 10, 50, 50); |
2240 IntRect grandChildRect(5, 5, 150, 150); | 2243 IntRect grandChildRect(5, 5, 150, 150); |
2241 | 2244 |
2242 root->createRenderSurface(); | 2245 root->createRenderSurface(); |
2243 root->setAnchorPoint(FloatPoint(0, 0)); | 2246 root->setAnchorPoint(FloatPoint(0, 0)); |
2244 root->setPosition(FloatPoint(rootRect.x(), rootRect.y())); | 2247 root->setPosition(FloatPoint(rootRect.x(), rootRect.y())); |
2245 root->setBounds(IntSize(rootRect.width(), rootRect.height())); | 2248 root->setBounds(IntSize(rootRect.width(), rootRect.height())); |
2246 root->setContentBounds(root->bounds()); | 2249 root->setContentBounds(root->bounds()); |
2247 root->setVisibleContentRect(rootRect); | 2250 root->setVisibleContentRect(rootRect); |
2248 root->setDrawsContent(false); | 2251 root->setDrawsContent(false); |
2249 root->renderSurface()->setContentRect(IntRect(IntPoint(), IntSize(rootRect.w
idth(), rootRect.height()))); | 2252 root->renderSurface()->setContentRect(IntRect(IntPoint(), IntSize(rootRect.w
idth(), rootRect.height()))); |
2250 | 2253 |
2251 child->setAnchorPoint(FloatPoint(0, 0)); | 2254 child->setAnchorPoint(FloatPoint(0, 0)); |
2252 child->setPosition(FloatPoint(childRect.x(), childRect.y())); | 2255 child->setPosition(FloatPoint(childRect.x(), childRect.y())); |
2253 child->setOpacity(0.5f); | 2256 child->setOpacity(0.5f); |
2254 child->setBounds(IntSize(childRect.width(), childRect.height())); | 2257 child->setBounds(IntSize(childRect.width(), childRect.height())); |
2255 child->setContentBounds(child->bounds()); | 2258 child->setContentBounds(child->bounds()); |
2256 child->setVisibleContentRect(childRect); | 2259 child->setVisibleContentRect(childRect); |
2257 child->setDrawsContent(false); | 2260 child->setDrawsContent(false); |
2258 | 2261 |
2259 grandChild->setAnchorPoint(FloatPoint(0, 0)); | 2262 grandChild->setAnchorPoint(FloatPoint(0, 0)); |
2260 grandChild->setPosition(IntPoint(grandChildRect.x(), grandChildRect.y())); | 2263 grandChild->setPosition(IntPoint(grandChildRect.x(), grandChildRect.y())); |
2261 grandChild->setBounds(IntSize(grandChildRect.width(), grandChildRect.height(
))); | 2264 grandChild->setBounds(IntSize(grandChildRect.width(), grandChildRect.height(
))); |
2262 grandChild->setContentBounds(grandChild->bounds()); | 2265 grandChild->setContentBounds(grandChild->bounds()); |
2263 grandChild->setVisibleContentRect(grandChildRect); | 2266 grandChild->setVisibleContentRect(grandChildRect); |
2264 grandChild->setDrawsContent(true); | 2267 grandChild->setDrawsContent(true); |
2265 | 2268 |
2266 child->addChild(grandChild.release()); | 2269 child->addChild(grandChild.Pass()); |
2267 root->addChild(child.release()); | 2270 root->addChild(child.Pass()); |
2268 | 2271 |
2269 myHostImpl->setRootLayer(root.release()); | 2272 myHostImpl->setRootLayer(root.Pass()); |
2270 return myHostImpl.Pass(); | 2273 return myHostImpl.Pass(); |
2271 } | 2274 } |
2272 | 2275 |
2273 TEST_P(CCLayerTreeHostImplTest, contributingLayerEmptyScissorPartialSwap) | 2276 TEST_P(CCLayerTreeHostImplTest, contributingLayerEmptyScissorPartialSwap) |
2274 { | 2277 { |
2275 scoped_ptr<CCLayerTreeHostImpl> myHostImpl = setupLayersForOpacity(true, thi
s); | 2278 scoped_ptr<CCLayerTreeHostImpl> myHostImpl = setupLayersForOpacity(true, thi
s); |
2276 | 2279 |
2277 { | 2280 { |
2278 CCLayerTreeHostImpl::FrameData frame; | 2281 CCLayerTreeHostImpl::FrameData frame; |
2279 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 2282 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
(...skipping 28 matching lines...) Expand all Loading... |
2308 ASSERT_EQ(1U, frame.renderPasses[0]->quadList().size()); | 2311 ASSERT_EQ(1U, frame.renderPasses[0]->quadList().size()); |
2309 ASSERT_EQ(1U, frame.renderPasses[1]->quadList().size()); | 2312 ASSERT_EQ(1U, frame.renderPasses[1]->quadList().size()); |
2310 EXPECT_EQ(CCDrawQuad::SolidColor, frame.renderPasses[0]->quadList()[0]->
material()); | 2313 EXPECT_EQ(CCDrawQuad::SolidColor, frame.renderPasses[0]->quadList()[0]->
material()); |
2311 EXPECT_EQ(CCDrawQuad::RenderPass, frame.renderPasses[1]->quadList()[0]->
material()); | 2314 EXPECT_EQ(CCDrawQuad::RenderPass, frame.renderPasses[1]->quadList()[0]->
material()); |
2312 } | 2315 } |
2313 } | 2316 } |
2314 | 2317 |
2315 // Make sure that context lost notifications are propagated through the tree. | 2318 // Make sure that context lost notifications are propagated through the tree. |
2316 class ContextLostNotificationCheckLayer : public CCLayerImpl { | 2319 class ContextLostNotificationCheckLayer : public CCLayerImpl { |
2317 public: | 2320 public: |
2318 static PassOwnPtr<ContextLostNotificationCheckLayer> create(int id) { return
adoptPtr(new ContextLostNotificationCheckLayer(id)); } | 2321 static scoped_ptr<CCLayerImpl> create(int id) { return scoped_ptr<CCLayerImp
l>(new ContextLostNotificationCheckLayer(id)); } |
2319 | 2322 |
2320 virtual void didLoseContext() OVERRIDE | 2323 virtual void didLoseContext() OVERRIDE |
2321 { | 2324 { |
2322 m_didLoseContextCalled = true; | 2325 m_didLoseContextCalled = true; |
2323 } | 2326 } |
2324 | 2327 |
2325 bool didLoseContextCalled() const { return m_didLoseContextCalled; } | 2328 bool didLoseContextCalled() const { return m_didLoseContextCalled; } |
2326 | 2329 |
2327 private: | 2330 private: |
2328 explicit ContextLostNotificationCheckLayer(int id) | 2331 explicit ContextLostNotificationCheckLayer(int id) |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2583 virtual void splitTrack(WebScrollbar*, const WebRect& track, WebRect& startT
rack, WebRect& thumb, WebRect& endTrack) OVERRIDE | 2586 virtual void splitTrack(WebScrollbar*, const WebRect& track, WebRect& startT
rack, WebRect& thumb, WebRect& endTrack) OVERRIDE |
2584 { | 2587 { |
2585 thumb = WebRect(0, 5, 5, 2); | 2588 thumb = WebRect(0, 5, 5, 2); |
2586 startTrack = WebRect(0, 5, 0, 5); | 2589 startTrack = WebRect(0, 5, 0, 5); |
2587 endTrack = WebRect(0, 0, 0, 5); | 2590 endTrack = WebRect(0, 0, 0, 5); |
2588 } | 2591 } |
2589 }; | 2592 }; |
2590 | 2593 |
2591 class FakeScrollbarLayerImpl : public CCScrollbarLayerImpl { | 2594 class FakeScrollbarLayerImpl : public CCScrollbarLayerImpl { |
2592 public: | 2595 public: |
2593 static PassOwnPtr<FakeScrollbarLayerImpl> create(int id) | 2596 static scoped_ptr<FakeScrollbarLayerImpl> create(int id) |
2594 { | 2597 { |
2595 return adoptPtr(new FakeScrollbarLayerImpl(id)); | 2598 return make_scoped_ptr(new FakeScrollbarLayerImpl(id)); |
2596 } | 2599 } |
2597 | 2600 |
2598 void createResources(CCResourceProvider* provider) | 2601 void createResources(CCResourceProvider* provider) |
2599 { | 2602 { |
2600 ASSERT(provider); | 2603 ASSERT(provider); |
2601 int pool = 0; | 2604 int pool = 0; |
2602 IntSize size(10, 10); | 2605 IntSize size(10, 10); |
2603 GC3Denum format = GraphicsContext3D::RGBA; | 2606 GC3Denum format = GraphicsContext3D::RGBA; |
2604 CCResourceProvider::TextureUsageHint hint = CCResourceProvider::TextureU
sageAny; | 2607 CCResourceProvider::TextureUsageHint hint = CCResourceProvider::TextureU
sageAny; |
2605 setScrollbarGeometry(CCScrollbarGeometryFixedThumb::create(FakeWebScroll
barThemeGeometryNonEmpty::create())); | 2608 setScrollbarGeometry(CCScrollbarGeometryFixedThumb::create(FakeWebScroll
barThemeGeometryNonEmpty::create())); |
(...skipping 21 matching lines...) Expand all Loading... |
2627 static_cast<CCTestRenderPass*>(pass.get())->appendSharedQuadState(sharedStat
e.Pass()); | 2630 static_cast<CCTestRenderPass*>(pass.get())->appendSharedQuadState(sharedStat
e.Pass()); |
2628 static_cast<CCTestRenderPass*>(pass.get())->appendQuad(quad.PassAs<CCDrawQua
d>()); | 2631 static_cast<CCTestRenderPass*>(pass.get())->appendQuad(quad.PassAs<CCDrawQua
d>()); |
2629 | 2632 |
2630 return pass.Pass(); | 2633 return pass.Pass(); |
2631 } | 2634 } |
2632 | 2635 |
2633 TEST_P(CCLayerTreeHostImplTest, dontUseOldResourcesAfterLostContext) | 2636 TEST_P(CCLayerTreeHostImplTest, dontUseOldResourcesAfterLostContext) |
2634 { | 2637 { |
2635 int layerId = 1; | 2638 int layerId = 1; |
2636 | 2639 |
2637 OwnPtr<CCLayerImpl> rootLayer(CCLayerImpl::create(layerId++)); | 2640 scoped_ptr<CCLayerImpl> rootLayer(CCLayerImpl::create(layerId++)); |
2638 rootLayer->setBounds(IntSize(10, 10)); | 2641 rootLayer->setBounds(IntSize(10, 10)); |
2639 rootLayer->setAnchorPoint(FloatPoint(0, 0)); | 2642 rootLayer->setAnchorPoint(FloatPoint(0, 0)); |
2640 | 2643 |
2641 OwnPtr<CCTiledLayerImpl> tileLayer = CCTiledLayerImpl::create(layerId++); | 2644 scoped_ptr<CCTiledLayerImpl> tileLayer = CCTiledLayerImpl::create(layerId++)
; |
2642 tileLayer->setBounds(IntSize(10, 10)); | 2645 tileLayer->setBounds(IntSize(10, 10)); |
2643 tileLayer->setAnchorPoint(FloatPoint(0, 0)); | 2646 tileLayer->setAnchorPoint(FloatPoint(0, 0)); |
2644 tileLayer->setContentBounds(IntSize(10, 10)); | 2647 tileLayer->setContentBounds(IntSize(10, 10)); |
2645 tileLayer->setDrawsContent(true); | 2648 tileLayer->setDrawsContent(true); |
2646 tileLayer->setSkipsDraw(false); | 2649 tileLayer->setSkipsDraw(false); |
2647 OwnPtr<CCLayerTilingData> tilingData(CCLayerTilingData::create(IntSize(10, 1
0), CCLayerTilingData::NoBorderTexels)); | 2650 OwnPtr<CCLayerTilingData> tilingData(CCLayerTilingData::create(IntSize(10, 1
0), CCLayerTilingData::NoBorderTexels)); |
2648 tilingData->setBounds(IntSize(10, 10)); | 2651 tilingData->setBounds(IntSize(10, 10)); |
2649 tileLayer->setTilingData(*tilingData); | 2652 tileLayer->setTilingData(*tilingData); |
2650 tileLayer->pushTileProperties(0, 0, 1, IntRect(0, 0, 10, 10)); | 2653 tileLayer->pushTileProperties(0, 0, 1, IntRect(0, 0, 10, 10)); |
2651 rootLayer->addChild(tileLayer.release()); | 2654 rootLayer->addChild(tileLayer.PassAs<CCLayerImpl>()); |
2652 | 2655 |
2653 OwnPtr<CCTextureLayerImpl> textureLayer = CCTextureLayerImpl::create(layerId
++); | 2656 scoped_ptr<CCTextureLayerImpl> textureLayer = CCTextureLayerImpl::create(lay
erId++); |
2654 textureLayer->setBounds(IntSize(10, 10)); | 2657 textureLayer->setBounds(IntSize(10, 10)); |
2655 textureLayer->setAnchorPoint(FloatPoint(0, 0)); | 2658 textureLayer->setAnchorPoint(FloatPoint(0, 0)); |
2656 textureLayer->setContentBounds(IntSize(10, 10)); | 2659 textureLayer->setContentBounds(IntSize(10, 10)); |
2657 textureLayer->setDrawsContent(true); | 2660 textureLayer->setDrawsContent(true); |
2658 textureLayer->setTextureId(1); | 2661 textureLayer->setTextureId(1); |
2659 rootLayer->addChild(textureLayer.release()); | 2662 rootLayer->addChild(textureLayer.PassAs<CCLayerImpl>()); |
2660 | 2663 |
2661 OwnPtr<CCTiledLayerImpl> maskLayer = CCTiledLayerImpl::create(layerId++); | 2664 scoped_ptr<CCTiledLayerImpl> maskLayer = CCTiledLayerImpl::create(layerId++)
; |
2662 maskLayer->setBounds(IntSize(10, 10)); | 2665 maskLayer->setBounds(IntSize(10, 10)); |
2663 maskLayer->setAnchorPoint(FloatPoint(0, 0)); | 2666 maskLayer->setAnchorPoint(FloatPoint(0, 0)); |
2664 maskLayer->setContentBounds(IntSize(10, 10)); | 2667 maskLayer->setContentBounds(IntSize(10, 10)); |
2665 maskLayer->setDrawsContent(true); | 2668 maskLayer->setDrawsContent(true); |
2666 maskLayer->setSkipsDraw(false); | 2669 maskLayer->setSkipsDraw(false); |
2667 maskLayer->setTilingData(*tilingData); | 2670 maskLayer->setTilingData(*tilingData); |
2668 maskLayer->pushTileProperties(0, 0, 1, IntRect(0, 0, 10, 10)); | 2671 maskLayer->pushTileProperties(0, 0, 1, IntRect(0, 0, 10, 10)); |
2669 | 2672 |
2670 OwnPtr<CCTextureLayerImpl> textureLayerWithMask = CCTextureLayerImpl::create
(layerId++); | 2673 scoped_ptr<CCTextureLayerImpl> textureLayerWithMask = CCTextureLayerImpl::cr
eate(layerId++); |
2671 textureLayerWithMask->setBounds(IntSize(10, 10)); | 2674 textureLayerWithMask->setBounds(IntSize(10, 10)); |
2672 textureLayerWithMask->setAnchorPoint(FloatPoint(0, 0)); | 2675 textureLayerWithMask->setAnchorPoint(FloatPoint(0, 0)); |
2673 textureLayerWithMask->setContentBounds(IntSize(10, 10)); | 2676 textureLayerWithMask->setContentBounds(IntSize(10, 10)); |
2674 textureLayerWithMask->setDrawsContent(true); | 2677 textureLayerWithMask->setDrawsContent(true); |
2675 textureLayerWithMask->setTextureId(1); | 2678 textureLayerWithMask->setTextureId(1); |
2676 textureLayerWithMask->setMaskLayer(maskLayer.release()); | 2679 textureLayerWithMask->setMaskLayer(maskLayer.PassAs<CCLayerImpl>()); |
2677 rootLayer->addChild(textureLayerWithMask.release()); | 2680 rootLayer->addChild(textureLayerWithMask.PassAs<CCLayerImpl>()); |
2678 | 2681 |
2679 FakeVideoFrame videoFrame; | 2682 FakeVideoFrame videoFrame; |
2680 FakeVideoFrameProvider provider; | 2683 FakeVideoFrameProvider provider; |
2681 provider.setFrame(&videoFrame); | 2684 provider.setFrame(&videoFrame); |
2682 OwnPtr<CCVideoLayerImpl> videoLayer = CCVideoLayerImpl::create(layerId++, &p
rovider); | 2685 scoped_ptr<CCVideoLayerImpl> videoLayer = CCVideoLayerImpl::create(layerId++
, &provider); |
2683 videoLayer->setBounds(IntSize(10, 10)); | 2686 videoLayer->setBounds(IntSize(10, 10)); |
2684 videoLayer->setAnchorPoint(FloatPoint(0, 0)); | 2687 videoLayer->setAnchorPoint(FloatPoint(0, 0)); |
2685 videoLayer->setContentBounds(IntSize(10, 10)); | 2688 videoLayer->setContentBounds(IntSize(10, 10)); |
2686 videoLayer->setDrawsContent(true); | 2689 videoLayer->setDrawsContent(true); |
2687 videoLayer->setLayerTreeHostImpl(m_hostImpl.get()); | 2690 videoLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
2688 rootLayer->addChild(videoLayer.release()); | 2691 rootLayer->addChild(videoLayer.PassAs<CCLayerImpl>()); |
2689 | 2692 |
2690 FakeVideoFrame hwVideoFrame; | 2693 FakeVideoFrame hwVideoFrame; |
2691 FakeVideoFrameProvider hwProvider; | 2694 FakeVideoFrameProvider hwProvider; |
2692 hwProvider.setFrame(&hwVideoFrame); | 2695 hwProvider.setFrame(&hwVideoFrame); |
2693 OwnPtr<CCVideoLayerImpl> hwVideoLayer = CCVideoLayerImpl::create(layerId++,
&hwProvider); | 2696 scoped_ptr<CCVideoLayerImpl> hwVideoLayer = CCVideoLayerImpl::create(layerId
++, &hwProvider); |
2694 hwVideoLayer->setBounds(IntSize(10, 10)); | 2697 hwVideoLayer->setBounds(IntSize(10, 10)); |
2695 hwVideoLayer->setAnchorPoint(FloatPoint(0, 0)); | 2698 hwVideoLayer->setAnchorPoint(FloatPoint(0, 0)); |
2696 hwVideoLayer->setContentBounds(IntSize(10, 10)); | 2699 hwVideoLayer->setContentBounds(IntSize(10, 10)); |
2697 hwVideoLayer->setDrawsContent(true); | 2700 hwVideoLayer->setDrawsContent(true); |
2698 hwVideoLayer->setLayerTreeHostImpl(m_hostImpl.get()); | 2701 hwVideoLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
2699 rootLayer->addChild(hwVideoLayer.release()); | 2702 rootLayer->addChild(hwVideoLayer.PassAs<CCLayerImpl>()); |
2700 | 2703 |
2701 OwnPtr<CCIOSurfaceLayerImpl> ioSurfaceLayer = CCIOSurfaceLayerImpl::create(l
ayerId++); | 2704 scoped_ptr<CCIOSurfaceLayerImpl> ioSurfaceLayer = CCIOSurfaceLayerImpl::crea
te(layerId++); |
2702 ioSurfaceLayer->setBounds(IntSize(10, 10)); | 2705 ioSurfaceLayer->setBounds(IntSize(10, 10)); |
2703 ioSurfaceLayer->setAnchorPoint(FloatPoint(0, 0)); | 2706 ioSurfaceLayer->setAnchorPoint(FloatPoint(0, 0)); |
2704 ioSurfaceLayer->setContentBounds(IntSize(10, 10)); | 2707 ioSurfaceLayer->setContentBounds(IntSize(10, 10)); |
2705 ioSurfaceLayer->setDrawsContent(true); | 2708 ioSurfaceLayer->setDrawsContent(true); |
2706 ioSurfaceLayer->setIOSurfaceProperties(1, IntSize(10, 10)); | 2709 ioSurfaceLayer->setIOSurfaceProperties(1, IntSize(10, 10)); |
2707 ioSurfaceLayer->setLayerTreeHostImpl(m_hostImpl.get()); | 2710 ioSurfaceLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
2708 rootLayer->addChild(ioSurfaceLayer.release()); | 2711 rootLayer->addChild(ioSurfaceLayer.PassAs<CCLayerImpl>()); |
2709 | 2712 |
2710 OwnPtr<CCHeadsUpDisplayLayerImpl> hudLayer = CCHeadsUpDisplayLayerImpl::crea
te(layerId++); | 2713 scoped_ptr<CCHeadsUpDisplayLayerImpl> hudLayer = CCHeadsUpDisplayLayerImpl::
create(layerId++); |
2711 hudLayer->setBounds(IntSize(10, 10)); | 2714 hudLayer->setBounds(IntSize(10, 10)); |
2712 hudLayer->setAnchorPoint(FloatPoint(0, 0)); | 2715 hudLayer->setAnchorPoint(FloatPoint(0, 0)); |
2713 hudLayer->setContentBounds(IntSize(10, 10)); | 2716 hudLayer->setContentBounds(IntSize(10, 10)); |
2714 hudLayer->setDrawsContent(true); | 2717 hudLayer->setDrawsContent(true); |
2715 hudLayer->setLayerTreeHostImpl(m_hostImpl.get()); | 2718 hudLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
2716 rootLayer->addChild(hudLayer.release()); | 2719 rootLayer->addChild(hudLayer.PassAs<CCLayerImpl>()); |
2717 | 2720 |
2718 OwnPtr<FakeScrollbarLayerImpl> scrollbarLayer(FakeScrollbarLayerImpl::create
(layerId++)); | 2721 scoped_ptr<FakeScrollbarLayerImpl> scrollbarLayer(FakeScrollbarLayerImpl::cr
eate(layerId++)); |
2719 scrollbarLayer->setBounds(IntSize(10, 10)); | 2722 scrollbarLayer->setBounds(IntSize(10, 10)); |
2720 scrollbarLayer->setContentBounds(IntSize(10, 10)); | 2723 scrollbarLayer->setContentBounds(IntSize(10, 10)); |
2721 scrollbarLayer->setDrawsContent(true); | 2724 scrollbarLayer->setDrawsContent(true); |
2722 scrollbarLayer->setLayerTreeHostImpl(m_hostImpl.get()); | 2725 scrollbarLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
2723 scrollbarLayer->createResources(m_hostImpl->resourceProvider()); | 2726 scrollbarLayer->createResources(m_hostImpl->resourceProvider()); |
2724 rootLayer->addChild(scrollbarLayer.release()); | 2727 rootLayer->addChild(scrollbarLayer.PassAs<CCLayerImpl>()); |
2725 | 2728 |
2726 OwnPtr<CCDelegatedRendererLayerImpl> delegatedRendererLayer(CCDelegatedRende
rerLayerImpl::create(layerId++)); | 2729 scoped_ptr<CCDelegatedRendererLayerImpl> delegatedRendererLayer(CCDelegatedR
endererLayerImpl::create(layerId++)); |
2727 delegatedRendererLayer->setBounds(IntSize(10, 10)); | 2730 delegatedRendererLayer->setBounds(IntSize(10, 10)); |
2728 delegatedRendererLayer->setContentBounds(IntSize(10, 10)); | 2731 delegatedRendererLayer->setContentBounds(IntSize(10, 10)); |
2729 delegatedRendererLayer->setDrawsContent(true); | 2732 delegatedRendererLayer->setDrawsContent(true); |
2730 delegatedRendererLayer->setLayerTreeHostImpl(m_hostImpl.get()); | 2733 delegatedRendererLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
2731 ScopedPtrVector<CCRenderPass> passList; | 2734 ScopedPtrVector<CCRenderPass> passList; |
2732 passList.append(createRenderPassWithResource(m_hostImpl->resourceProvider())
); | 2735 passList.append(createRenderPassWithResource(m_hostImpl->resourceProvider())
); |
2733 delegatedRendererLayer->setRenderPasses(passList); | 2736 delegatedRendererLayer->setRenderPasses(passList); |
2734 EXPECT_TRUE(passList.isEmpty()); | 2737 EXPECT_TRUE(passList.isEmpty()); |
2735 rootLayer->addChild(delegatedRendererLayer.release()); | 2738 rootLayer->addChild(delegatedRendererLayer.PassAs<CCLayerImpl>()); |
2736 | 2739 |
2737 // Use a context that supports IOSurfaces | 2740 // Use a context that supports IOSurfaces |
2738 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(adoptP
tr(new FakeWebGraphicsContext3DWithIOSurface)).PassAs<CCGraphicsContext>()); | 2741 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(adoptP
tr(new FakeWebGraphicsContext3DWithIOSurface)).PassAs<CCGraphicsContext>()); |
2739 | 2742 |
2740 hwVideoFrame.setTextureId(m_hostImpl->resourceProvider()->graphicsContext3D(
)->createTexture()); | 2743 hwVideoFrame.setTextureId(m_hostImpl->resourceProvider()->graphicsContext3D(
)->createTexture()); |
2741 | 2744 |
2742 m_hostImpl->setRootLayer(rootLayer.release()); | 2745 m_hostImpl->setRootLayer(rootLayer.Pass()); |
2743 | 2746 |
2744 CCLayerTreeHostImpl::FrameData frame; | 2747 CCLayerTreeHostImpl::FrameData frame; |
2745 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2748 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
2746 m_hostImpl->drawLayers(frame); | 2749 m_hostImpl->drawLayers(frame); |
2747 m_hostImpl->didDrawAllLayers(frame); | 2750 m_hostImpl->didDrawAllLayers(frame); |
2748 m_hostImpl->swapBuffers(); | 2751 m_hostImpl->swapBuffers(); |
2749 | 2752 |
2750 unsigned numResources = m_hostImpl->resourceProvider()->numResources(); | 2753 unsigned numResources = m_hostImpl->resourceProvider()->numResources(); |
2751 | 2754 |
2752 // Lose the context, replacing it with a StrictWebGraphicsContext3DWithIOSur
face, | 2755 // Lose the context, replacing it with a StrictWebGraphicsContext3DWithIOSur
face, |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2812 | 2815 |
2813 unsigned numTextures() const { return m_numTextures; } | 2816 unsigned numTextures() const { return m_numTextures; } |
2814 | 2817 |
2815 private: | 2818 private: |
2816 HashMap<WebGLId, bool> m_textures; | 2819 HashMap<WebGLId, bool> m_textures; |
2817 unsigned m_numTextures; | 2820 unsigned m_numTextures; |
2818 }; | 2821 }; |
2819 | 2822 |
2820 TEST_P(CCLayerTreeHostImplTest, layersFreeTextures) | 2823 TEST_P(CCLayerTreeHostImplTest, layersFreeTextures) |
2821 { | 2824 { |
2822 OwnPtr<CCLayerImpl> rootLayer(CCLayerImpl::create(1)); | 2825 scoped_ptr<CCLayerImpl> rootLayer(CCLayerImpl::create(1)); |
2823 rootLayer->setBounds(IntSize(10, 10)); | 2826 rootLayer->setBounds(IntSize(10, 10)); |
2824 rootLayer->setAnchorPoint(FloatPoint(0, 0)); | 2827 rootLayer->setAnchorPoint(FloatPoint(0, 0)); |
2825 | 2828 |
2826 OwnPtr<CCTiledLayerImpl> tileLayer = CCTiledLayerImpl::create(2); | 2829 scoped_ptr<CCTiledLayerImpl> tileLayer = CCTiledLayerImpl::create(2); |
2827 tileLayer->setBounds(IntSize(10, 10)); | 2830 tileLayer->setBounds(IntSize(10, 10)); |
2828 tileLayer->setAnchorPoint(FloatPoint(0, 0)); | 2831 tileLayer->setAnchorPoint(FloatPoint(0, 0)); |
2829 tileLayer->setContentBounds(IntSize(10, 10)); | 2832 tileLayer->setContentBounds(IntSize(10, 10)); |
2830 tileLayer->setDrawsContent(true); | 2833 tileLayer->setDrawsContent(true); |
2831 tileLayer->setSkipsDraw(false); | 2834 tileLayer->setSkipsDraw(false); |
2832 OwnPtr<CCLayerTilingData> tilingData(CCLayerTilingData::create(IntSize(10, 1
0), CCLayerTilingData::NoBorderTexels)); | 2835 OwnPtr<CCLayerTilingData> tilingData(CCLayerTilingData::create(IntSize(10, 1
0), CCLayerTilingData::NoBorderTexels)); |
2833 tilingData->setBounds(IntSize(10, 10)); | 2836 tilingData->setBounds(IntSize(10, 10)); |
2834 tileLayer->setTilingData(*tilingData); | 2837 tileLayer->setTilingData(*tilingData); |
2835 tileLayer->pushTileProperties(0, 0, 1, IntRect(0, 0, 10, 10)); | 2838 tileLayer->pushTileProperties(0, 0, 1, IntRect(0, 0, 10, 10)); |
2836 rootLayer->addChild(tileLayer.release()); | 2839 rootLayer->addChild(tileLayer.PassAs<CCLayerImpl>()); |
2837 | 2840 |
2838 OwnPtr<CCTextureLayerImpl> textureLayer = CCTextureLayerImpl::create(3); | 2841 scoped_ptr<CCTextureLayerImpl> textureLayer = CCTextureLayerImpl::create(3); |
2839 textureLayer->setBounds(IntSize(10, 10)); | 2842 textureLayer->setBounds(IntSize(10, 10)); |
2840 textureLayer->setAnchorPoint(FloatPoint(0, 0)); | 2843 textureLayer->setAnchorPoint(FloatPoint(0, 0)); |
2841 textureLayer->setContentBounds(IntSize(10, 10)); | 2844 textureLayer->setContentBounds(IntSize(10, 10)); |
2842 textureLayer->setDrawsContent(true); | 2845 textureLayer->setDrawsContent(true); |
2843 textureLayer->setTextureId(1); | 2846 textureLayer->setTextureId(1); |
2844 rootLayer->addChild(textureLayer.release()); | 2847 rootLayer->addChild(textureLayer.PassAs<CCLayerImpl>()); |
2845 | 2848 |
2846 FakeVideoFrameProvider provider; | 2849 FakeVideoFrameProvider provider; |
2847 OwnPtr<CCVideoLayerImpl> videoLayer = CCVideoLayerImpl::create(4, &provider)
; | 2850 scoped_ptr<CCVideoLayerImpl> videoLayer = CCVideoLayerImpl::create(4, &provi
der); |
2848 videoLayer->setBounds(IntSize(10, 10)); | 2851 videoLayer->setBounds(IntSize(10, 10)); |
2849 videoLayer->setAnchorPoint(FloatPoint(0, 0)); | 2852 videoLayer->setAnchorPoint(FloatPoint(0, 0)); |
2850 videoLayer->setContentBounds(IntSize(10, 10)); | 2853 videoLayer->setContentBounds(IntSize(10, 10)); |
2851 videoLayer->setDrawsContent(true); | 2854 videoLayer->setDrawsContent(true); |
2852 videoLayer->setLayerTreeHostImpl(m_hostImpl.get()); | 2855 videoLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
2853 rootLayer->addChild(videoLayer.release()); | 2856 rootLayer->addChild(videoLayer.PassAs<CCLayerImpl>()); |
2854 | 2857 |
2855 OwnPtr<CCIOSurfaceLayerImpl> ioSurfaceLayer = CCIOSurfaceLayerImpl::create(5
); | 2858 scoped_ptr<CCIOSurfaceLayerImpl> ioSurfaceLayer = CCIOSurfaceLayerImpl::crea
te(5); |
2856 ioSurfaceLayer->setBounds(IntSize(10, 10)); | 2859 ioSurfaceLayer->setBounds(IntSize(10, 10)); |
2857 ioSurfaceLayer->setAnchorPoint(FloatPoint(0, 0)); | 2860 ioSurfaceLayer->setAnchorPoint(FloatPoint(0, 0)); |
2858 ioSurfaceLayer->setContentBounds(IntSize(10, 10)); | 2861 ioSurfaceLayer->setContentBounds(IntSize(10, 10)); |
2859 ioSurfaceLayer->setDrawsContent(true); | 2862 ioSurfaceLayer->setDrawsContent(true); |
2860 ioSurfaceLayer->setIOSurfaceProperties(1, IntSize(10, 10)); | 2863 ioSurfaceLayer->setIOSurfaceProperties(1, IntSize(10, 10)); |
2861 ioSurfaceLayer->setLayerTreeHostImpl(m_hostImpl.get()); | 2864 ioSurfaceLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
2862 rootLayer->addChild(ioSurfaceLayer.release()); | 2865 rootLayer->addChild(ioSurfaceLayer.PassAs<CCLayerImpl>()); |
2863 | 2866 |
2864 // Lose the context, replacing it with a TrackingWebGraphicsContext3D (which
the CCLayerTreeHostImpl takes ownership of). | 2867 // Lose the context, replacing it with a TrackingWebGraphicsContext3D (which
the CCLayerTreeHostImpl takes ownership of). |
2865 scoped_ptr<CCGraphicsContext> ccContext(FakeWebCompositorOutputSurface::crea
te(adoptPtr(new TrackingWebGraphicsContext3D))); | 2868 scoped_ptr<CCGraphicsContext> ccContext(FakeWebCompositorOutputSurface::crea
te(adoptPtr(new TrackingWebGraphicsContext3D))); |
2866 TrackingWebGraphicsContext3D* trackingWebGraphicsContext = static_cast<Track
ingWebGraphicsContext3D*>(ccContext->context3D()); | 2869 TrackingWebGraphicsContext3D* trackingWebGraphicsContext = static_cast<Track
ingWebGraphicsContext3D*>(ccContext->context3D()); |
2867 m_hostImpl->initializeRenderer(ccContext.Pass()); | 2870 m_hostImpl->initializeRenderer(ccContext.Pass()); |
2868 | 2871 |
2869 m_hostImpl->setRootLayer(rootLayer.release()); | 2872 m_hostImpl->setRootLayer(rootLayer.Pass()); |
2870 | 2873 |
2871 CCLayerTreeHostImpl::FrameData frame; | 2874 CCLayerTreeHostImpl::FrameData frame; |
2872 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2875 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
2873 m_hostImpl->drawLayers(frame); | 2876 m_hostImpl->drawLayers(frame); |
2874 m_hostImpl->didDrawAllLayers(frame); | 2877 m_hostImpl->didDrawAllLayers(frame); |
2875 m_hostImpl->swapBuffers(); | 2878 m_hostImpl->swapBuffers(); |
2876 | 2879 |
2877 EXPECT_GT(trackingWebGraphicsContext->numTextures(), 0u); | 2880 EXPECT_GT(trackingWebGraphicsContext->numTextures(), 0u); |
2878 | 2881 |
2879 // Kill the layer tree. | 2882 // Kill the layer tree. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2912 // Verify no quads are drawn when transparent background is set. | 2915 // Verify no quads are drawn when transparent background is set. |
2913 myHostImpl->setHasTransparentBackground(true); | 2916 myHostImpl->setHasTransparentBackground(true); |
2914 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 2917 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
2915 myHostImpl->drawLayers(frame); | 2918 myHostImpl->drawLayers(frame); |
2916 myHostImpl->didDrawAllLayers(frame); | 2919 myHostImpl->didDrawAllLayers(frame); |
2917 Mock::VerifyAndClearExpectations(&mockContext); | 2920 Mock::VerifyAndClearExpectations(&mockContext); |
2918 } | 2921 } |
2919 | 2922 |
2920 static void addDrawingLayerTo(CCLayerImpl* parent, int id, const IntRect& layerR
ect, CCLayerImpl** result) | 2923 static void addDrawingLayerTo(CCLayerImpl* parent, int id, const IntRect& layerR
ect, CCLayerImpl** result) |
2921 { | 2924 { |
2922 OwnPtr<CCLayerImpl> layer = FakeLayerWithQuads::create(id); | 2925 scoped_ptr<CCLayerImpl> layer = FakeLayerWithQuads::create(id); |
2923 CCLayerImpl* layerPtr = layer.get(); | 2926 CCLayerImpl* layerPtr = layer.get(); |
2924 layerPtr->setAnchorPoint(FloatPoint(0, 0)); | 2927 layerPtr->setAnchorPoint(FloatPoint(0, 0)); |
2925 layerPtr->setPosition(FloatPoint(layerRect.location())); | 2928 layerPtr->setPosition(FloatPoint(layerRect.location())); |
2926 layerPtr->setBounds(layerRect.size()); | 2929 layerPtr->setBounds(layerRect.size()); |
2927 layerPtr->setContentBounds(layerRect.size()); | 2930 layerPtr->setContentBounds(layerRect.size()); |
2928 layerPtr->setDrawsContent(true); // only children draw content | 2931 layerPtr->setDrawsContent(true); // only children draw content |
2929 layerPtr->setContentsOpaque(true); | 2932 layerPtr->setContentsOpaque(true); |
2930 parent->addChild(layer.release()); | 2933 parent->addChild(layer.Pass()); |
2931 if (result) | 2934 if (result) |
2932 *result = layerPtr; | 2935 *result = layerPtr; |
2933 } | 2936 } |
2934 | 2937 |
2935 static void setupLayersForTextureCaching(CCLayerTreeHostImpl* layerTreeHostImpl,
CCLayerImpl*& rootPtr, CCLayerImpl*& intermediateLayerPtr, CCLayerImpl*& surfac
eLayerPtr, CCLayerImpl*& childPtr, const IntSize& rootSize) | 2938 static void setupLayersForTextureCaching(CCLayerTreeHostImpl* layerTreeHostImpl,
CCLayerImpl*& rootPtr, CCLayerImpl*& intermediateLayerPtr, CCLayerImpl*& surfac
eLayerPtr, CCLayerImpl*& childPtr, const IntSize& rootSize) |
2936 { | 2939 { |
2937 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea
te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>(); | 2940 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea
te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>(); |
2938 | 2941 |
2939 layerTreeHostImpl->initializeRenderer(context.Pass()); | 2942 layerTreeHostImpl->initializeRenderer(context.Pass()); |
2940 layerTreeHostImpl->setViewportSize(rootSize, rootSize); | 2943 layerTreeHostImpl->setViewportSize(rootSize, rootSize); |
2941 | 2944 |
2942 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 2945 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
2943 rootPtr = root.get(); | 2946 rootPtr = root.get(); |
2944 | 2947 |
2945 root->setAnchorPoint(FloatPoint(0, 0)); | 2948 root->setAnchorPoint(FloatPoint(0, 0)); |
2946 root->setPosition(FloatPoint(0, 0)); | 2949 root->setPosition(FloatPoint(0, 0)); |
2947 root->setBounds(rootSize); | 2950 root->setBounds(rootSize); |
2948 root->setContentBounds(rootSize); | 2951 root->setContentBounds(rootSize); |
2949 root->setDrawsContent(true); | 2952 root->setDrawsContent(true); |
2950 layerTreeHostImpl->setRootLayer(root.release()); | 2953 layerTreeHostImpl->setRootLayer(root.Pass()); |
2951 | 2954 |
2952 addDrawingLayerTo(rootPtr, 2, IntRect(10, 10, rootSize.width(), rootSize.hei
ght()), &intermediateLayerPtr); | 2955 addDrawingLayerTo(rootPtr, 2, IntRect(10, 10, rootSize.width(), rootSize.hei
ght()), &intermediateLayerPtr); |
2953 intermediateLayerPtr->setDrawsContent(false); // only children draw content | 2956 intermediateLayerPtr->setDrawsContent(false); // only children draw content |
2954 | 2957 |
2955 // Surface layer is the layer that changes its opacity | 2958 // Surface layer is the layer that changes its opacity |
2956 // It will contain other layers that draw content. | 2959 // It will contain other layers that draw content. |
2957 addDrawingLayerTo(intermediateLayerPtr, 3, IntRect(10, 10, rootSize.width(),
rootSize.height()), &surfaceLayerPtr); | 2960 addDrawingLayerTo(intermediateLayerPtr, 3, IntRect(10, 10, rootSize.width(),
rootSize.height()), &surfaceLayerPtr); |
2958 surfaceLayerPtr->setDrawsContent(false); // only children draw content | 2961 surfaceLayerPtr->setDrawsContent(false); // only children draw content |
2959 surfaceLayerPtr->setOpacity(0.5f); // This will cause it to have a surface | 2962 surfaceLayerPtr->setOpacity(0.5f); // This will cause it to have a surface |
2960 | 2963 |
(...skipping 17 matching lines...) Expand all Loading... |
2978 CCLayerImpl* rootPtr; | 2981 CCLayerImpl* rootPtr; |
2979 CCLayerImpl* surfaceLayerPtr; | 2982 CCLayerImpl* surfaceLayerPtr; |
2980 | 2983 |
2981 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea
te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>(); | 2984 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea
te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>(); |
2982 | 2985 |
2983 IntSize rootSize(100, 100); | 2986 IntSize rootSize(100, 100); |
2984 | 2987 |
2985 myHostImpl->initializeRenderer(context.Pass()); | 2988 myHostImpl->initializeRenderer(context.Pass()); |
2986 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In
tSize(rootSize.width(), rootSize.height())); | 2989 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In
tSize(rootSize.width(), rootSize.height())); |
2987 | 2990 |
2988 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 2991 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
2989 rootPtr = root.get(); | 2992 rootPtr = root.get(); |
2990 | 2993 |
2991 root->setAnchorPoint(FloatPoint(0, 0)); | 2994 root->setAnchorPoint(FloatPoint(0, 0)); |
2992 root->setPosition(FloatPoint(0, 0)); | 2995 root->setPosition(FloatPoint(0, 0)); |
2993 root->setBounds(rootSize); | 2996 root->setBounds(rootSize); |
2994 root->setContentBounds(rootSize); | 2997 root->setContentBounds(rootSize); |
2995 root->setDrawsContent(true); | 2998 root->setDrawsContent(true); |
2996 root->setMasksToBounds(true); | 2999 root->setMasksToBounds(true); |
2997 myHostImpl->setRootLayer(root.release()); | 3000 myHostImpl->setRootLayer(root.Pass()); |
2998 | 3001 |
2999 addDrawingLayerTo(rootPtr, 3, IntRect(0, 0, rootSize.width(), rootSize.heigh
t()), &surfaceLayerPtr); | 3002 addDrawingLayerTo(rootPtr, 3, IntRect(0, 0, rootSize.width(), rootSize.heigh
t()), &surfaceLayerPtr); |
3000 surfaceLayerPtr->setDrawsContent(false); | 3003 surfaceLayerPtr->setDrawsContent(false); |
3001 | 3004 |
3002 // Surface layer is the layer that changes its opacity | 3005 // Surface layer is the layer that changes its opacity |
3003 // It will contain other layers that draw content. | 3006 // It will contain other layers that draw content. |
3004 surfaceLayerPtr->setOpacity(0.5f); // This will cause it to have a surface | 3007 surfaceLayerPtr->setOpacity(0.5f); // This will cause it to have a surface |
3005 | 3008 |
3006 addDrawingLayerTo(surfaceLayerPtr, 4, IntRect(0, 0, 100, 3), 0); | 3009 addDrawingLayerTo(surfaceLayerPtr, 4, IntRect(0, 0, 100, 3), 0); |
3007 addDrawingLayerTo(surfaceLayerPtr, 5, IntRect(0, 97, 100, 3), 0); | 3010 addDrawingLayerTo(surfaceLayerPtr, 5, IntRect(0, 97, 100, 3), 0); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3090 CCLayerImpl* layerS1Ptr; | 3093 CCLayerImpl* layerS1Ptr; |
3091 CCLayerImpl* layerS2Ptr; | 3094 CCLayerImpl* layerS2Ptr; |
3092 | 3095 |
3093 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea
te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>(); | 3096 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea
te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>(); |
3094 | 3097 |
3095 IntSize rootSize(1000, 1000); | 3098 IntSize rootSize(1000, 1000); |
3096 | 3099 |
3097 myHostImpl->initializeRenderer(context.Pass()); | 3100 myHostImpl->initializeRenderer(context.Pass()); |
3098 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In
tSize(rootSize.width(), rootSize.height())); | 3101 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In
tSize(rootSize.width(), rootSize.height())); |
3099 | 3102 |
3100 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 3103 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
3101 rootPtr = root.get(); | 3104 rootPtr = root.get(); |
3102 | 3105 |
3103 root->setAnchorPoint(FloatPoint(0, 0)); | 3106 root->setAnchorPoint(FloatPoint(0, 0)); |
3104 root->setPosition(FloatPoint(0, 0)); | 3107 root->setPosition(FloatPoint(0, 0)); |
3105 root->setBounds(rootSize); | 3108 root->setBounds(rootSize); |
3106 root->setContentBounds(rootSize); | 3109 root->setContentBounds(rootSize); |
3107 root->setDrawsContent(true); | 3110 root->setDrawsContent(true); |
3108 root->setMasksToBounds(true); | 3111 root->setMasksToBounds(true); |
3109 myHostImpl->setRootLayer(root.release()); | 3112 myHostImpl->setRootLayer(root.Pass()); |
3110 | 3113 |
3111 addDrawingLayerTo(rootPtr, 2, IntRect(300, 300, 300, 300), &layerS1Ptr); | 3114 addDrawingLayerTo(rootPtr, 2, IntRect(300, 300, 300, 300), &layerS1Ptr); |
3112 layerS1Ptr->setForceRenderSurface(true); | 3115 layerS1Ptr->setForceRenderSurface(true); |
3113 | 3116 |
3114 addDrawingLayerTo(layerS1Ptr, 3, IntRect(10, 10, 10, 10), 0); // L11 | 3117 addDrawingLayerTo(layerS1Ptr, 3, IntRect(10, 10, 10, 10), 0); // L11 |
3115 addDrawingLayerTo(layerS1Ptr, 4, IntRect(0, 0, 30, 30), 0); // L12 | 3118 addDrawingLayerTo(layerS1Ptr, 4, IntRect(0, 0, 30, 30), 0); // L12 |
3116 | 3119 |
3117 addDrawingLayerTo(rootPtr, 5, IntRect(550, 250, 300, 400), &layerS2Ptr); | 3120 addDrawingLayerTo(rootPtr, 5, IntRect(550, 250, 300, 400), &layerS2Ptr); |
3118 layerS2Ptr->setForceRenderSurface(true); | 3121 layerS2Ptr->setForceRenderSurface(true); |
3119 | 3122 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3203 CCLayerImpl* layerS1Ptr; | 3206 CCLayerImpl* layerS1Ptr; |
3204 CCLayerImpl* layerS2Ptr; | 3207 CCLayerImpl* layerS2Ptr; |
3205 | 3208 |
3206 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea
te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>(); | 3209 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea
te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>(); |
3207 | 3210 |
3208 IntSize rootSize(1000, 1000); | 3211 IntSize rootSize(1000, 1000); |
3209 | 3212 |
3210 myHostImpl->initializeRenderer(context.Pass()); | 3213 myHostImpl->initializeRenderer(context.Pass()); |
3211 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In
tSize(rootSize.width(), rootSize.height())); | 3214 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In
tSize(rootSize.width(), rootSize.height())); |
3212 | 3215 |
3213 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 3216 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
3214 rootPtr = root.get(); | 3217 rootPtr = root.get(); |
3215 | 3218 |
3216 root->setAnchorPoint(FloatPoint(0, 0)); | 3219 root->setAnchorPoint(FloatPoint(0, 0)); |
3217 root->setPosition(FloatPoint(0, 0)); | 3220 root->setPosition(FloatPoint(0, 0)); |
3218 root->setBounds(rootSize); | 3221 root->setBounds(rootSize); |
3219 root->setContentBounds(rootSize); | 3222 root->setContentBounds(rootSize); |
3220 root->setDrawsContent(true); | 3223 root->setDrawsContent(true); |
3221 root->setMasksToBounds(true); | 3224 root->setMasksToBounds(true); |
3222 myHostImpl->setRootLayer(root.release()); | 3225 myHostImpl->setRootLayer(root.Pass()); |
3223 | 3226 |
3224 addDrawingLayerTo(rootPtr, 2, IntRect(0, 0, 800, 800), &layerS1Ptr); | 3227 addDrawingLayerTo(rootPtr, 2, IntRect(0, 0, 800, 800), &layerS1Ptr); |
3225 layerS1Ptr->setForceRenderSurface(true); | 3228 layerS1Ptr->setForceRenderSurface(true); |
3226 layerS1Ptr->setDrawsContent(false); | 3229 layerS1Ptr->setDrawsContent(false); |
3227 | 3230 |
3228 addDrawingLayerTo(layerS1Ptr, 3, IntRect(0, 0, 300, 300), 0); // L11 | 3231 addDrawingLayerTo(layerS1Ptr, 3, IntRect(0, 0, 300, 300), 0); // L11 |
3229 addDrawingLayerTo(layerS1Ptr, 4, IntRect(0, 500, 300, 300), 0); // L12 | 3232 addDrawingLayerTo(layerS1Ptr, 4, IntRect(0, 500, 300, 300), 0); // L12 |
3230 addDrawingLayerTo(layerS1Ptr, 5, IntRect(500, 0, 300, 300), 0); // L13 | 3233 addDrawingLayerTo(layerS1Ptr, 5, IntRect(500, 0, 300, 300), 0); // L13 |
3231 addDrawingLayerTo(layerS1Ptr, 6, IntRect(500, 500, 300, 300), 0); // L14 | 3234 addDrawingLayerTo(layerS1Ptr, 6, IntRect(500, 500, 300, 300), 0); // L14 |
3232 addDrawingLayerTo(layerS1Ptr, 9, IntRect(500, 500, 300, 300), 0); // L14 | 3235 addDrawingLayerTo(layerS1Ptr, 9, IntRect(500, 500, 300, 300), 0); // L14 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3317 CCLayerImpl* layerS1Ptr; | 3320 CCLayerImpl* layerS1Ptr; |
3318 CCLayerImpl* layerS2Ptr; | 3321 CCLayerImpl* layerS2Ptr; |
3319 | 3322 |
3320 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea
te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>(); | 3323 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea
te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>(); |
3321 | 3324 |
3322 IntSize rootSize(1000, 1000); | 3325 IntSize rootSize(1000, 1000); |
3323 | 3326 |
3324 myHostImpl->initializeRenderer(context.Pass()); | 3327 myHostImpl->initializeRenderer(context.Pass()); |
3325 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In
tSize(rootSize.width(), rootSize.height())); | 3328 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In
tSize(rootSize.width(), rootSize.height())); |
3326 | 3329 |
3327 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 3330 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
3328 rootPtr = root.get(); | 3331 rootPtr = root.get(); |
3329 | 3332 |
3330 root->setAnchorPoint(FloatPoint(0, 0)); | 3333 root->setAnchorPoint(FloatPoint(0, 0)); |
3331 root->setPosition(FloatPoint(0, 0)); | 3334 root->setPosition(FloatPoint(0, 0)); |
3332 root->setBounds(rootSize); | 3335 root->setBounds(rootSize); |
3333 root->setContentBounds(rootSize); | 3336 root->setContentBounds(rootSize); |
3334 root->setDrawsContent(true); | 3337 root->setDrawsContent(true); |
3335 root->setMasksToBounds(true); | 3338 root->setMasksToBounds(true); |
3336 myHostImpl->setRootLayer(root.release()); | 3339 myHostImpl->setRootLayer(root.Pass()); |
3337 | 3340 |
3338 addDrawingLayerTo(rootPtr, 2, IntRect(0, 0, 400, 400), &layerS1Ptr); | 3341 addDrawingLayerTo(rootPtr, 2, IntRect(0, 0, 400, 400), &layerS1Ptr); |
3339 layerS1Ptr->setForceRenderSurface(true); | 3342 layerS1Ptr->setForceRenderSurface(true); |
3340 | 3343 |
3341 addDrawingLayerTo(layerS1Ptr, 3, IntRect(0, 0, 300, 300), 0); // L11 | 3344 addDrawingLayerTo(layerS1Ptr, 3, IntRect(0, 0, 300, 300), 0); // L11 |
3342 addDrawingLayerTo(layerS1Ptr, 4, IntRect(100, 0, 300, 300), 0); // L12 | 3345 addDrawingLayerTo(layerS1Ptr, 4, IntRect(100, 0, 300, 300), 0); // L12 |
3343 | 3346 |
3344 addDrawingLayerTo(rootPtr, 7, IntRect(200, 0, 300, 300), &layerS2Ptr); | 3347 addDrawingLayerTo(rootPtr, 7, IntRect(200, 0, 300, 300), &layerS2Ptr); |
3345 layerS2Ptr->setForceRenderSurface(true); | 3348 layerS2Ptr->setForceRenderSurface(true); |
3346 | 3349 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3400 CCLayerImpl* rootPtr; | 3403 CCLayerImpl* rootPtr; |
3401 CCLayerImpl* layerS1Ptr; | 3404 CCLayerImpl* layerS1Ptr; |
3402 | 3405 |
3403 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea
te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>(); | 3406 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea
te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>(); |
3404 | 3407 |
3405 IntSize rootSize(1000, 1000); | 3408 IntSize rootSize(1000, 1000); |
3406 | 3409 |
3407 myHostImpl->initializeRenderer(context.Pass()); | 3410 myHostImpl->initializeRenderer(context.Pass()); |
3408 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In
tSize(rootSize.width(), rootSize.height())); | 3411 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In
tSize(rootSize.width(), rootSize.height())); |
3409 | 3412 |
3410 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 3413 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
3411 rootPtr = root.get(); | 3414 rootPtr = root.get(); |
3412 | 3415 |
3413 root->setAnchorPoint(FloatPoint(0, 0)); | 3416 root->setAnchorPoint(FloatPoint(0, 0)); |
3414 root->setPosition(FloatPoint(0, 0)); | 3417 root->setPosition(FloatPoint(0, 0)); |
3415 root->setBounds(rootSize); | 3418 root->setBounds(rootSize); |
3416 root->setContentBounds(rootSize); | 3419 root->setContentBounds(rootSize); |
3417 root->setDrawsContent(true); | 3420 root->setDrawsContent(true); |
3418 root->setMasksToBounds(true); | 3421 root->setMasksToBounds(true); |
3419 myHostImpl->setRootLayer(root.release()); | 3422 myHostImpl->setRootLayer(root.Pass()); |
3420 | 3423 |
3421 addDrawingLayerTo(rootPtr, 2, IntRect(0, 0, 400, 400), &layerS1Ptr); | 3424 addDrawingLayerTo(rootPtr, 2, IntRect(0, 0, 400, 400), &layerS1Ptr); |
3422 layerS1Ptr->setForceRenderSurface(true); | 3425 layerS1Ptr->setForceRenderSurface(true); |
3423 WebTransformationMatrix transform = layerS1Ptr->transform(); | 3426 WebTransformationMatrix transform = layerS1Ptr->transform(); |
3424 transform.translate(200, 200); | 3427 transform.translate(200, 200); |
3425 transform.rotate(45); | 3428 transform.rotate(45); |
3426 transform.translate(-200, -200); | 3429 transform.translate(-200, -200); |
3427 layerS1Ptr->setTransform(transform); | 3430 layerS1Ptr->setTransform(transform); |
3428 | 3431 |
3429 addDrawingLayerTo(layerS1Ptr, 3, IntRect(200, 0, 200, 400), 0); // L11 | 3432 addDrawingLayerTo(layerS1Ptr, 3, IntRect(200, 0, 200, 400), 0); // L11 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3485 CCLayerImpl* layerS1Ptr; | 3488 CCLayerImpl* layerS1Ptr; |
3486 CCLayerImpl* layerS2Ptr; | 3489 CCLayerImpl* layerS2Ptr; |
3487 | 3490 |
3488 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea
te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>(); | 3491 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea
te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>(); |
3489 | 3492 |
3490 IntSize rootSize(1000, 1000); | 3493 IntSize rootSize(1000, 1000); |
3491 | 3494 |
3492 myHostImpl->initializeRenderer(context.Pass()); | 3495 myHostImpl->initializeRenderer(context.Pass()); |
3493 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In
tSize(rootSize.width(), rootSize.height())); | 3496 myHostImpl->setViewportSize(IntSize(rootSize.width(), rootSize.height()), In
tSize(rootSize.width(), rootSize.height())); |
3494 | 3497 |
3495 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 3498 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
3496 rootPtr = root.get(); | 3499 rootPtr = root.get(); |
3497 | 3500 |
3498 root->setAnchorPoint(FloatPoint(0, 0)); | 3501 root->setAnchorPoint(FloatPoint(0, 0)); |
3499 root->setPosition(FloatPoint(0, 0)); | 3502 root->setPosition(FloatPoint(0, 0)); |
3500 root->setBounds(rootSize); | 3503 root->setBounds(rootSize); |
3501 root->setContentBounds(rootSize); | 3504 root->setContentBounds(rootSize); |
3502 root->setDrawsContent(true); | 3505 root->setDrawsContent(true); |
3503 root->setMasksToBounds(true); | 3506 root->setMasksToBounds(true); |
3504 myHostImpl->setRootLayer(root.release()); | 3507 myHostImpl->setRootLayer(root.Pass()); |
3505 | 3508 |
3506 addDrawingLayerTo(rootPtr, 2, IntRect(300, 300, 300, 300), &layerS1Ptr); | 3509 addDrawingLayerTo(rootPtr, 2, IntRect(300, 300, 300, 300), &layerS1Ptr); |
3507 layerS1Ptr->setForceRenderSurface(true); | 3510 layerS1Ptr->setForceRenderSurface(true); |
3508 | 3511 |
3509 addDrawingLayerTo(layerS1Ptr, 3, IntRect(10, 10, 10, 10), 0); // L11 | 3512 addDrawingLayerTo(layerS1Ptr, 3, IntRect(10, 10, 10, 10), 0); // L11 |
3510 addDrawingLayerTo(layerS1Ptr, 4, IntRect(0, 0, 30, 30), 0); // L12 | 3513 addDrawingLayerTo(layerS1Ptr, 4, IntRect(0, 0, 30, 30), 0); // L12 |
3511 | 3514 |
3512 addDrawingLayerTo(rootPtr, 5, IntRect(550, 250, 300, 400), &layerS2Ptr); | 3515 addDrawingLayerTo(rootPtr, 5, IntRect(550, 250, 300, 400), &layerS2Ptr); |
3513 layerS2Ptr->setForceRenderSurface(true); | 3516 layerS2Ptr->setForceRenderSurface(true); |
3514 | 3517 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3591 | | | 3 | | 3594 | | | 3 | |
3592 | | +-------------------+ | 3595 | | +-------------------+ |
3593 | | | | | 3596 | | | | |
3594 | +-----------+ | | 3597 | +-----------+ | |
3595 | | | 3598 | | |
3596 | | | 3599 | | |
3597 +--------------------+ | 3600 +--------------------+ |
3598 | 3601 |
3599 Layers 1, 2 have render surfaces | 3602 Layers 1, 2 have render surfaces |
3600 */ | 3603 */ |
3601 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 3604 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
3602 OwnPtr<CCTiledLayerImpl> child = CCTiledLayerImpl::create(2); | 3605 scoped_ptr<CCTiledLayerImpl> child = CCTiledLayerImpl::create(2); |
3603 OwnPtr<CCLayerImpl> grandChild = CCLayerImpl::create(3); | 3606 scoped_ptr<CCLayerImpl> grandChild = CCLayerImpl::create(3); |
3604 | 3607 |
3605 IntRect rootRect(0, 0, 100, 100); | 3608 IntRect rootRect(0, 0, 100, 100); |
3606 IntRect childRect(10, 10, 50, 50); | 3609 IntRect childRect(10, 10, 50, 50); |
3607 IntRect grandChildRect(5, 5, 150, 150); | 3610 IntRect grandChildRect(5, 5, 150, 150); |
3608 | 3611 |
3609 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea
te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>(); | 3612 scoped_ptr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::crea
te(adoptPtr(new PartialSwapContext)).PassAs<CCGraphicsContext>(); |
3610 myHostImpl->initializeRenderer(context.Pass()); | 3613 myHostImpl->initializeRenderer(context.Pass()); |
3611 | 3614 |
3612 root->setAnchorPoint(FloatPoint(0, 0)); | 3615 root->setAnchorPoint(FloatPoint(0, 0)); |
3613 root->setPosition(FloatPoint(rootRect.x(), rootRect.y())); | 3616 root->setPosition(FloatPoint(rootRect.x(), rootRect.y())); |
(...skipping 17 matching lines...) Expand all Loading... |
3631 | 3634 |
3632 grandChild->setAnchorPoint(FloatPoint(0, 0)); | 3635 grandChild->setAnchorPoint(FloatPoint(0, 0)); |
3633 grandChild->setPosition(IntPoint(grandChildRect.x(), grandChildRect.y())); | 3636 grandChild->setPosition(IntPoint(grandChildRect.x(), grandChildRect.y())); |
3634 grandChild->setBounds(IntSize(grandChildRect.width(), grandChildRect.height(
))); | 3637 grandChild->setBounds(IntSize(grandChildRect.width(), grandChildRect.height(
))); |
3635 grandChild->setContentBounds(grandChild->bounds()); | 3638 grandChild->setContentBounds(grandChild->bounds()); |
3636 grandChild->setDrawsContent(true); | 3639 grandChild->setDrawsContent(true); |
3637 | 3640 |
3638 CCTiledLayerImpl* childPtr = child.get(); | 3641 CCTiledLayerImpl* childPtr = child.get(); |
3639 CCRenderPass::Id childPassId(childPtr->id(), 0); | 3642 CCRenderPass::Id childPassId(childPtr->id(), 0); |
3640 | 3643 |
3641 child->addChild(grandChild.release()); | 3644 child->addChild(grandChild.Pass()); |
3642 root->addChild(child.release()); | 3645 root->addChild(child.PassAs<CCLayerImpl>()); |
3643 myHostImpl->setRootLayer(root.release()); | 3646 myHostImpl->setRootLayer(root.Pass()); |
3644 myHostImpl->setViewportSize(rootRect.size(), rootRect.size()); | 3647 myHostImpl->setViewportSize(rootRect.size(), rootRect.size()); |
3645 | 3648 |
3646 EXPECT_FALSE(myHostImpl->renderer()->haveCachedResourcesForRenderPassId(chil
dPassId)); | 3649 EXPECT_FALSE(myHostImpl->renderer()->haveCachedResourcesForRenderPassId(chil
dPassId)); |
3647 | 3650 |
3648 { | 3651 { |
3649 CCLayerTreeHostImpl::FrameData frame; | 3652 CCLayerTreeHostImpl::FrameData frame; |
3650 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 3653 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
3651 myHostImpl->drawLayers(frame); | 3654 myHostImpl->drawLayers(frame); |
3652 myHostImpl->didDrawAllLayers(frame); | 3655 myHostImpl->didDrawAllLayers(frame); |
3653 } | 3656 } |
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4334 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat
a); | 4337 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat
a); |
4335 testCaseIndex++; | 4338 testCaseIndex++; |
4336 } | 4339 } |
4337 } | 4340 } |
4338 | 4341 |
4339 INSTANTIATE_TEST_CASE_P(CCLayerTreeHostImplTests, | 4342 INSTANTIATE_TEST_CASE_P(CCLayerTreeHostImplTests, |
4340 CCLayerTreeHostImplTest, | 4343 CCLayerTreeHostImplTest, |
4341 ::testing::Values(false, true)); | 4344 ::testing::Values(false, true)); |
4342 | 4345 |
4343 } // namespace | 4346 } // namespace |
OLD | NEW |