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 "cc/layer_tree_host_impl.h" | 5 #include "cc/layer_tree_host_impl.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 } | 114 } |
115 | 115 |
116 void setupRootLayerImpl(scoped_ptr<LayerImpl> root) | 116 void setupRootLayerImpl(scoped_ptr<LayerImpl> root) |
117 { | 117 { |
118 root->setAnchorPoint(gfx::PointF(0, 0)); | 118 root->setAnchorPoint(gfx::PointF(0, 0)); |
119 root->setPosition(gfx::PointF(0, 0)); | 119 root->setPosition(gfx::PointF(0, 0)); |
120 root->setBounds(gfx::Size(10, 10)); | 120 root->setBounds(gfx::Size(10, 10)); |
121 root->setContentBounds(gfx::Size(10, 10)); | 121 root->setContentBounds(gfx::Size(10, 10)); |
122 root->setDrawsContent(true); | 122 root->setDrawsContent(true); |
123 root->drawProperties().visible_content_rect = gfx::Rect(0, 0, 10, 10); | 123 root->drawProperties().visible_content_rect = gfx::Rect(0, 0, 10, 10); |
124 m_hostImpl->setRootLayer(root.Pass()); | 124 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
125 } | 125 } |
126 | 126 |
127 static void expectClearedScrollDeltasRecursive(LayerImpl* layer) | 127 static void expectClearedScrollDeltasRecursive(LayerImpl* layer) |
128 { | 128 { |
129 ASSERT_EQ(layer->scrollDelta(), gfx::Vector2d()); | 129 ASSERT_EQ(layer->scrollDelta(), gfx::Vector2d()); |
130 for (size_t i = 0; i < layer->children().size(); ++i) | 130 for (size_t i = 0; i < layer->children().size(); ++i) |
131 expectClearedScrollDeltasRecursive(layer->children()[i]); | 131 expectClearedScrollDeltasRecursive(layer->children()[i]); |
132 } | 132 } |
133 | 133 |
134 static void expectContains(const ScrollAndScaleSet& scrollInfo, int id, cons
t gfx::Vector2d& scrollDelta) | 134 static void expectContains(const ScrollAndScaleSet& scrollInfo, int id, cons
t gfx::Vector2d& scrollDelta) |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 root->setPosition(gfx::PointF(0, 0)); | 169 root->setPosition(gfx::PointF(0, 0)); |
170 root->setAnchorPoint(gfx::PointF(0, 0)); | 170 root->setAnchorPoint(gfx::PointF(0, 0)); |
171 | 171 |
172 scoped_ptr<LayerImpl> contents = LayerImpl::create(m_hostImpl->activeTre
e(), 2); | 172 scoped_ptr<LayerImpl> contents = LayerImpl::create(m_hostImpl->activeTre
e(), 2); |
173 contents->setDrawsContent(true); | 173 contents->setDrawsContent(true); |
174 contents->setBounds(contentSize); | 174 contents->setBounds(contentSize); |
175 contents->setContentBounds(contentSize); | 175 contents->setContentBounds(contentSize); |
176 contents->setPosition(gfx::PointF(0, 0)); | 176 contents->setPosition(gfx::PointF(0, 0)); |
177 contents->setAnchorPoint(gfx::PointF(0, 0)); | 177 contents->setAnchorPoint(gfx::PointF(0, 0)); |
178 root->addChild(contents.Pass()); | 178 root->addChild(contents.Pass()); |
179 m_hostImpl->setRootLayer(root.Pass()); | 179 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
180 } | 180 } |
181 | 181 |
182 scoped_ptr<LayerImpl> createScrollableLayer(int id, const gfx::Size& size) | 182 scoped_ptr<LayerImpl> createScrollableLayer(int id, const gfx::Size& size) |
183 { | 183 { |
184 scoped_ptr<LayerImpl> layer = LayerImpl::create(m_hostImpl->activeTree()
, id); | 184 scoped_ptr<LayerImpl> layer = LayerImpl::create(m_hostImpl->activeTree()
, id); |
185 layer->setScrollable(true); | 185 layer->setScrollable(true); |
186 layer->setDrawsContent(true); | 186 layer->setDrawsContent(true); |
187 layer->setBounds(size); | 187 layer->setBounds(size); |
188 layer->setContentBounds(size); | 188 layer->setContentBounds(size); |
189 layer->setMaxScrollOffset(gfx::Vector2d(size.width() * 2, size.height()
* 2)); | 189 layer->setMaxScrollOffset(gfx::Vector2d(size.width() * 2, size.height()
* 2)); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 // that canDraw changed. | 237 // that canDraw changed. |
238 EXPECT_FALSE(m_hostImpl->canDraw()); | 238 EXPECT_FALSE(m_hostImpl->canDraw()); |
239 m_onCanDrawStateChangedCalled = false; | 239 m_onCanDrawStateChangedCalled = false; |
240 | 240 |
241 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 241 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
242 EXPECT_TRUE(m_hostImpl->canDraw()); | 242 EXPECT_TRUE(m_hostImpl->canDraw()); |
243 EXPECT_TRUE(m_onCanDrawStateChangedCalled); | 243 EXPECT_TRUE(m_onCanDrawStateChangedCalled); |
244 m_onCanDrawStateChangedCalled = false; | 244 m_onCanDrawStateChangedCalled = false; |
245 | 245 |
246 // Toggle the root layer to make sure it toggles canDraw | 246 // Toggle the root layer to make sure it toggles canDraw |
247 m_hostImpl->setRootLayer(scoped_ptr<LayerImpl>()); | 247 m_hostImpl->activeTree()->SetRootLayer(scoped_ptr<LayerImpl>()); |
248 EXPECT_FALSE(m_hostImpl->canDraw()); | 248 EXPECT_FALSE(m_hostImpl->canDraw()); |
249 EXPECT_TRUE(m_onCanDrawStateChangedCalled); | 249 EXPECT_TRUE(m_onCanDrawStateChangedCalled); |
250 m_onCanDrawStateChangedCalled = false; | 250 m_onCanDrawStateChangedCalled = false; |
251 | 251 |
252 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 252 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
253 EXPECT_TRUE(m_hostImpl->canDraw()); | 253 EXPECT_TRUE(m_hostImpl->canDraw()); |
254 EXPECT_TRUE(m_onCanDrawStateChangedCalled); | 254 EXPECT_TRUE(m_onCanDrawStateChangedCalled); |
255 m_onCanDrawStateChangedCalled = false; | 255 m_onCanDrawStateChangedCalled = false; |
256 | 256 |
257 // Toggle the device viewport size to make sure it toggles canDraw. | 257 // Toggle the device viewport size to make sure it toggles canDraw. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 | 298 |
299 TEST_P(LayerTreeHostImplTest, scrollDeltaTreeButNoChanges) | 299 TEST_P(LayerTreeHostImplTest, scrollDeltaTreeButNoChanges) |
300 { | 300 { |
301 { | 301 { |
302 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(),
1); | 302 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(),
1); |
303 root->addChild(LayerImpl::create(m_hostImpl->activeTree(), 2)); | 303 root->addChild(LayerImpl::create(m_hostImpl->activeTree(), 2)); |
304 root->addChild(LayerImpl::create(m_hostImpl->activeTree(), 3)); | 304 root->addChild(LayerImpl::create(m_hostImpl->activeTree(), 3)); |
305 root->children()[1]->addChild(LayerImpl::create(m_hostImpl->activeTree()
, 4)); | 305 root->children()[1]->addChild(LayerImpl::create(m_hostImpl->activeTree()
, 4)); |
306 root->children()[1]->addChild(LayerImpl::create(m_hostImpl->activeTree()
, 5)); | 306 root->children()[1]->addChild(LayerImpl::create(m_hostImpl->activeTree()
, 5)); |
307 root->children()[1]->children()[0]->addChild(LayerImpl::create(m_hostImp
l->activeTree(), 6)); | 307 root->children()[1]->children()[0]->addChild(LayerImpl::create(m_hostImp
l->activeTree(), 6)); |
308 m_hostImpl->setRootLayer(root.Pass()); | 308 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
309 } | 309 } |
310 LayerImpl* root = m_hostImpl->rootLayer(); | 310 LayerImpl* root = m_hostImpl->rootLayer(); |
311 | 311 |
312 expectClearedScrollDeltasRecursive(root); | 312 expectClearedScrollDeltasRecursive(root); |
313 | 313 |
314 scoped_ptr<ScrollAndScaleSet> scrollInfo; | 314 scoped_ptr<ScrollAndScaleSet> scrollInfo; |
315 | 315 |
316 scrollInfo = m_hostImpl->processScrollDeltas(); | 316 scrollInfo = m_hostImpl->processScrollDeltas(); |
317 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); | 317 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); |
318 expectClearedScrollDeltasRecursive(root); | 318 expectClearedScrollDeltasRecursive(root); |
319 | 319 |
320 scrollInfo = m_hostImpl->processScrollDeltas(); | 320 scrollInfo = m_hostImpl->processScrollDeltas(); |
321 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); | 321 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); |
322 expectClearedScrollDeltasRecursive(root); | 322 expectClearedScrollDeltasRecursive(root); |
323 } | 323 } |
324 | 324 |
325 TEST_P(LayerTreeHostImplTest, scrollDeltaRepeatedScrolls) | 325 TEST_P(LayerTreeHostImplTest, scrollDeltaRepeatedScrolls) |
326 { | 326 { |
327 gfx::Vector2d scrollOffset(20, 30); | 327 gfx::Vector2d scrollOffset(20, 30); |
328 gfx::Vector2d scrollDelta(11, -15); | 328 gfx::Vector2d scrollDelta(11, -15); |
329 { | 329 { |
330 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(),
1); | 330 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(),
1); |
331 root->setScrollOffset(scrollOffset); | 331 root->setScrollOffset(scrollOffset); |
332 root->setScrollable(true); | 332 root->setScrollable(true); |
333 root->setMaxScrollOffset(gfx::Vector2d(100, 100)); | 333 root->setMaxScrollOffset(gfx::Vector2d(100, 100)); |
334 root->scrollBy(scrollDelta); | 334 root->scrollBy(scrollDelta); |
335 m_hostImpl->setRootLayer(root.Pass()); | 335 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
336 } | 336 } |
337 LayerImpl* root = m_hostImpl->rootLayer(); | 337 LayerImpl* root = m_hostImpl->rootLayer(); |
338 | 338 |
339 scoped_ptr<ScrollAndScaleSet> scrollInfo; | 339 scoped_ptr<ScrollAndScaleSet> scrollInfo; |
340 | 340 |
341 scrollInfo = m_hostImpl->processScrollDeltas(); | 341 scrollInfo = m_hostImpl->processScrollDeltas(); |
342 ASSERT_EQ(scrollInfo->scrolls.size(), 1u); | 342 ASSERT_EQ(scrollInfo->scrolls.size(), 1u); |
343 EXPECT_VECTOR_EQ(root->sentScrollDelta(), scrollDelta); | 343 EXPECT_VECTOR_EQ(root->sentScrollDelta(), scrollDelta); |
344 expectContains(*scrollInfo, root->id(), scrollDelta); | 344 expectContains(*scrollInfo, root->id(), scrollDelta); |
345 | 345 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 TEST_P(LayerTreeHostImplTest, replaceTreeWhileScrolling) | 392 TEST_P(LayerTreeHostImplTest, replaceTreeWhileScrolling) |
393 { | 393 { |
394 const int scrollLayerId = 1; | 394 const int scrollLayerId = 1; |
395 | 395 |
396 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 396 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
397 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); | 397 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); |
398 initializeRendererAndDrawFrame(); | 398 initializeRendererAndDrawFrame(); |
399 | 399 |
400 // We should not crash if the tree is replaced while we are scrolling. | 400 // We should not crash if the tree is replaced while we are scrolling. |
401 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 401 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
402 m_hostImpl->detachLayerTree(); | 402 m_hostImpl->activeTree()->DetachLayerTree(); |
403 | 403 |
404 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 404 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
405 | 405 |
406 // We should still be scrolling, because the scrolled layer also exists in t
he new tree. | 406 // We should still be scrolling, because the scrolled layer also exists in t
he new tree. |
407 gfx::Vector2d scrollDelta(0, 10); | 407 gfx::Vector2d scrollDelta(0, 10); |
408 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 408 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
409 m_hostImpl->scrollEnd(); | 409 m_hostImpl->scrollEnd(); |
410 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; | 410 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; |
411 expectContains(*scrollInfo, scrollLayerId, scrollDelta); | 411 expectContains(*scrollInfo, scrollLayerId, scrollDelta); |
412 } | 412 } |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
925 | 925 |
926 private: | 926 private: |
927 bool m_didDrawCalled; | 927 bool m_didDrawCalled; |
928 bool m_willDrawCalled; | 928 bool m_willDrawCalled; |
929 }; | 929 }; |
930 | 930 |
931 TEST_P(LayerTreeHostImplTest, didDrawNotCalledOnHiddenLayer) | 931 TEST_P(LayerTreeHostImplTest, didDrawNotCalledOnHiddenLayer) |
932 { | 932 { |
933 // The root layer is always drawn, so run this test on a child layer that | 933 // The root layer is always drawn, so run this test on a child layer that |
934 // will be masked out by the root layer's bounds. | 934 // will be masked out by the root layer's bounds. |
935 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(m_hostImpl->activeTree(),
1)); | 935 m_hostImpl->activeTree()->SetRootLayer(DidDrawCheckLayer::create(m_hostImpl-
>activeTree(), 1)); |
936 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); | 936 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); |
937 root->setMasksToBounds(true); | 937 root->setMasksToBounds(true); |
938 | 938 |
939 root->addChild(DidDrawCheckLayer::create(m_hostImpl->activeTree(), 2)); | 939 root->addChild(DidDrawCheckLayer::create(m_hostImpl->activeTree(), 2)); |
940 DidDrawCheckLayer* layer = static_cast<DidDrawCheckLayer*>(root->children()[
0]); | 940 DidDrawCheckLayer* layer = static_cast<DidDrawCheckLayer*>(root->children()[
0]); |
941 // Ensure visibleContentRect for layer is empty | 941 // Ensure visibleContentRect for layer is empty |
942 layer->setPosition(gfx::PointF(100, 100)); | 942 layer->setPosition(gfx::PointF(100, 100)); |
943 layer->setBounds(gfx::Size(10, 10)); | 943 layer->setBounds(gfx::Size(10, 10)); |
944 layer->setContentBounds(gfx::Size(10, 10)); | 944 layer->setContentBounds(gfx::Size(10, 10)); |
945 | 945 |
(...skipping 25 matching lines...) Expand all Loading... |
971 EXPECT_TRUE(layer->didDrawCalled()); | 971 EXPECT_TRUE(layer->didDrawCalled()); |
972 | 972 |
973 EXPECT_FALSE(layer->visibleContentRect().IsEmpty()); | 973 EXPECT_FALSE(layer->visibleContentRect().IsEmpty()); |
974 } | 974 } |
975 | 975 |
976 TEST_P(LayerTreeHostImplTest, willDrawNotCalledOnOccludedLayer) | 976 TEST_P(LayerTreeHostImplTest, willDrawNotCalledOnOccludedLayer) |
977 { | 977 { |
978 gfx::Size bigSize(1000, 1000); | 978 gfx::Size bigSize(1000, 1000); |
979 m_hostImpl->setViewportSize(bigSize, bigSize); | 979 m_hostImpl->setViewportSize(bigSize, bigSize); |
980 | 980 |
981 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(m_hostImpl->activeTree(),
1)); | 981 m_hostImpl->activeTree()->SetRootLayer(DidDrawCheckLayer::create(m_hostImpl-
>activeTree(), 1)); |
982 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); | 982 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); |
983 | 983 |
984 root->addChild(DidDrawCheckLayer::create(m_hostImpl->activeTree(), 2)); | 984 root->addChild(DidDrawCheckLayer::create(m_hostImpl->activeTree(), 2)); |
985 DidDrawCheckLayer* occludedLayer = static_cast<DidDrawCheckLayer*>(root->chi
ldren()[0]); | 985 DidDrawCheckLayer* occludedLayer = static_cast<DidDrawCheckLayer*>(root->chi
ldren()[0]); |
986 | 986 |
987 root->addChild(DidDrawCheckLayer::create(m_hostImpl->activeTree(), 3)); | 987 root->addChild(DidDrawCheckLayer::create(m_hostImpl->activeTree(), 3)); |
988 DidDrawCheckLayer* topLayer = static_cast<DidDrawCheckLayer*>(root->children
()[1]); | 988 DidDrawCheckLayer* topLayer = static_cast<DidDrawCheckLayer*>(root->children
()[1]); |
989 // This layer covers the occludedLayer above. Make this layer large so it ca
n occlude. | 989 // This layer covers the occludedLayer above. Make this layer large so it ca
n occlude. |
990 topLayer->setBounds(bigSize); | 990 topLayer->setBounds(bigSize); |
991 topLayer->setContentBounds(bigSize); | 991 topLayer->setContentBounds(bigSize); |
(...skipping 11 matching lines...) Expand all Loading... |
1003 m_hostImpl->didDrawAllLayers(frame); | 1003 m_hostImpl->didDrawAllLayers(frame); |
1004 | 1004 |
1005 EXPECT_FALSE(occludedLayer->willDrawCalled()); | 1005 EXPECT_FALSE(occludedLayer->willDrawCalled()); |
1006 EXPECT_FALSE(occludedLayer->didDrawCalled()); | 1006 EXPECT_FALSE(occludedLayer->didDrawCalled()); |
1007 EXPECT_TRUE(topLayer->willDrawCalled()); | 1007 EXPECT_TRUE(topLayer->willDrawCalled()); |
1008 EXPECT_TRUE(topLayer->didDrawCalled()); | 1008 EXPECT_TRUE(topLayer->didDrawCalled()); |
1009 } | 1009 } |
1010 | 1010 |
1011 TEST_P(LayerTreeHostImplTest, didDrawCalledOnAllLayers) | 1011 TEST_P(LayerTreeHostImplTest, didDrawCalledOnAllLayers) |
1012 { | 1012 { |
1013 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(m_hostImpl->activeTree(),
1)); | 1013 m_hostImpl->activeTree()->SetRootLayer(DidDrawCheckLayer::create(m_hostImpl-
>activeTree(), 1)); |
1014 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); | 1014 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); |
1015 | 1015 |
1016 root->addChild(DidDrawCheckLayer::create(m_hostImpl->activeTree(), 2)); | 1016 root->addChild(DidDrawCheckLayer::create(m_hostImpl->activeTree(), 2)); |
1017 DidDrawCheckLayer* layer1 = static_cast<DidDrawCheckLayer*>(root->children()
[0]); | 1017 DidDrawCheckLayer* layer1 = static_cast<DidDrawCheckLayer*>(root->children()
[0]); |
1018 | 1018 |
1019 layer1->addChild(DidDrawCheckLayer::create(m_hostImpl->activeTree(), 3)); | 1019 layer1->addChild(DidDrawCheckLayer::create(m_hostImpl->activeTree(), 3)); |
1020 DidDrawCheckLayer* layer2 = static_cast<DidDrawCheckLayer*>(layer1->children
()[0]); | 1020 DidDrawCheckLayer* layer2 = static_cast<DidDrawCheckLayer*>(layer1->children
()[0]); |
1021 | 1021 |
1022 layer1->setOpacity(0.3f); | 1022 layer1->setOpacity(0.3f); |
1023 layer1->setPreserves3D(false); | 1023 layer1->setPreserves3D(false); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1059 pushTileProperties(0, 0, resource, gfx::Rect(), false); | 1059 pushTileProperties(0, 0, resource, gfx::Rect(), false); |
1060 } | 1060 } |
1061 if (animating) | 1061 if (animating) |
1062 addAnimatedTransformToLayer(*this, 10, 3, 0); | 1062 addAnimatedTransformToLayer(*this, 10, 3, 0); |
1063 } | 1063 } |
1064 }; | 1064 }; |
1065 | 1065 |
1066 TEST_P(LayerTreeHostImplTest, prepareToDrawFailsWhenAnimationUsesCheckerboard) | 1066 TEST_P(LayerTreeHostImplTest, prepareToDrawFailsWhenAnimationUsesCheckerboard) |
1067 { | 1067 { |
1068 // When the texture is not missing, we draw as usual. | 1068 // When the texture is not missing, we draw as usual. |
1069 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(m_hostImpl->activeTree(),
1)); | 1069 m_hostImpl->activeTree()->SetRootLayer(DidDrawCheckLayer::create(m_hostImpl-
>activeTree(), 1)); |
1070 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); | 1070 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa
yer()); |
1071 root->addChild(MissingTextureAnimatingLayer::create(m_hostImpl->activeTree()
, 2, false, false, true, m_hostImpl->resourceProvider())); | 1071 root->addChild(MissingTextureAnimatingLayer::create(m_hostImpl->activeTree()
, 2, false, false, true, m_hostImpl->resourceProvider())); |
1072 | 1072 |
1073 LayerTreeHostImpl::FrameData frame; | 1073 LayerTreeHostImpl::FrameData frame; |
1074 | 1074 |
1075 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1075 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
1076 m_hostImpl->drawLayers(frame); | 1076 m_hostImpl->drawLayers(frame); |
1077 m_hostImpl->didDrawAllLayers(frame); | 1077 m_hostImpl->didDrawAllLayers(frame); |
1078 | 1078 |
1079 // When a texture is missing and we're not animating, we draw as usual with
checkerboarding. | 1079 // When a texture is missing and we're not animating, we draw as usual with
checkerboarding. |
1080 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(m_hostImpl->activeTree(),
3)); | 1080 m_hostImpl->activeTree()->SetRootLayer(DidDrawCheckLayer::create(m_hostImpl-
>activeTree(), 3)); |
1081 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); | 1081 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); |
1082 root->addChild(MissingTextureAnimatingLayer::create(m_hostImpl->activeTree()
, 4, true, false, false, m_hostImpl->resourceProvider())); | 1082 root->addChild(MissingTextureAnimatingLayer::create(m_hostImpl->activeTree()
, 4, true, false, false, m_hostImpl->resourceProvider())); |
1083 | 1083 |
1084 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1084 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
1085 m_hostImpl->drawLayers(frame); | 1085 m_hostImpl->drawLayers(frame); |
1086 m_hostImpl->didDrawAllLayers(frame); | 1086 m_hostImpl->didDrawAllLayers(frame); |
1087 | 1087 |
1088 // When a texture is missing and we're animating, we don't want to draw anyt
hing. | 1088 // When a texture is missing and we're animating, we don't want to draw anyt
hing. |
1089 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(m_hostImpl->activeTree(),
5)); | 1089 m_hostImpl->activeTree()->SetRootLayer(DidDrawCheckLayer::create(m_hostImpl-
>activeTree(), 5)); |
1090 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); | 1090 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); |
1091 root->addChild(MissingTextureAnimatingLayer::create(m_hostImpl->activeTree()
, 6, true, false, true, m_hostImpl->resourceProvider())); | 1091 root->addChild(MissingTextureAnimatingLayer::create(m_hostImpl->activeTree()
, 6, true, false, true, m_hostImpl->resourceProvider())); |
1092 | 1092 |
1093 EXPECT_FALSE(m_hostImpl->prepareToDraw(frame)); | 1093 EXPECT_FALSE(m_hostImpl->prepareToDraw(frame)); |
1094 m_hostImpl->drawLayers(frame); | 1094 m_hostImpl->drawLayers(frame); |
1095 m_hostImpl->didDrawAllLayers(frame); | 1095 m_hostImpl->didDrawAllLayers(frame); |
1096 | 1096 |
1097 // When the layer skips draw and we're animating, we still draw the frame. | 1097 // When the layer skips draw and we're animating, we still draw the frame. |
1098 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(m_hostImpl->activeTree(),
7)); | 1098 m_hostImpl->activeTree()->SetRootLayer(DidDrawCheckLayer::create(m_hostImpl-
>activeTree(), 7)); |
1099 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); | 1099 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); |
1100 root->addChild(MissingTextureAnimatingLayer::create(m_hostImpl->activeTree()
, 8, false, true, true, m_hostImpl->resourceProvider())); | 1100 root->addChild(MissingTextureAnimatingLayer::create(m_hostImpl->activeTree()
, 8, false, true, true, m_hostImpl->resourceProvider())); |
1101 | 1101 |
1102 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1102 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
1103 m_hostImpl->drawLayers(frame); | 1103 m_hostImpl->drawLayers(frame); |
1104 m_hostImpl->didDrawAllLayers(frame); | 1104 m_hostImpl->didDrawAllLayers(frame); |
1105 } | 1105 } |
1106 | 1106 |
1107 TEST_P(LayerTreeHostImplTest, scrollRootIgnored) | 1107 TEST_P(LayerTreeHostImplTest, scrollRootIgnored) |
1108 { | 1108 { |
1109 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1); | 1109 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1); |
1110 root->setScrollable(false); | 1110 root->setScrollable(false); |
1111 m_hostImpl->setRootLayer(root.Pass()); | 1111 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
1112 initializeRendererAndDrawFrame(); | 1112 initializeRendererAndDrawFrame(); |
1113 | 1113 |
1114 // Scroll event is ignored because layer is not scrollable. | 1114 // Scroll event is ignored because layer is not scrollable. |
1115 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollIgnored); | 1115 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollIgnored); |
1116 EXPECT_FALSE(m_didRequestRedraw); | 1116 EXPECT_FALSE(m_didRequestRedraw); |
1117 EXPECT_FALSE(m_didRequestCommit); | 1117 EXPECT_FALSE(m_didRequestCommit); |
1118 } | 1118 } |
1119 | 1119 |
1120 TEST_P(LayerTreeHostImplTest, scrollNonCompositedRoot) | 1120 TEST_P(LayerTreeHostImplTest, scrollNonCompositedRoot) |
1121 { | 1121 { |
(...skipping 11 matching lines...) Expand all Loading... |
1133 | 1133 |
1134 scoped_ptr<LayerImpl> scrollLayer = LayerImpl::create(m_hostImpl->activeTree
(), 2); | 1134 scoped_ptr<LayerImpl> scrollLayer = LayerImpl::create(m_hostImpl->activeTree
(), 2); |
1135 scrollLayer->setScrollable(true); | 1135 scrollLayer->setScrollable(true); |
1136 scrollLayer->setMaxScrollOffset(gfx::Vector2d(surfaceSize.width(), surfaceSi
ze.height())); | 1136 scrollLayer->setMaxScrollOffset(gfx::Vector2d(surfaceSize.width(), surfaceSi
ze.height())); |
1137 scrollLayer->setBounds(surfaceSize); | 1137 scrollLayer->setBounds(surfaceSize); |
1138 scrollLayer->setContentBounds(surfaceSize); | 1138 scrollLayer->setContentBounds(surfaceSize); |
1139 scrollLayer->setPosition(gfx::PointF(0, 0)); | 1139 scrollLayer->setPosition(gfx::PointF(0, 0)); |
1140 scrollLayer->setAnchorPoint(gfx::PointF(0, 0)); | 1140 scrollLayer->setAnchorPoint(gfx::PointF(0, 0)); |
1141 scrollLayer->addChild(contentLayer.Pass()); | 1141 scrollLayer->addChild(contentLayer.Pass()); |
1142 | 1142 |
1143 m_hostImpl->setRootLayer(scrollLayer.Pass()); | 1143 m_hostImpl->activeTree()->SetRootLayer(scrollLayer.Pass()); |
1144 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1144 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1145 initializeRendererAndDrawFrame(); | 1145 initializeRendererAndDrawFrame(); |
1146 | 1146 |
1147 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 1147 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
1148 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 1148 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
1149 m_hostImpl->scrollEnd(); | 1149 m_hostImpl->scrollEnd(); |
1150 EXPECT_TRUE(m_didRequestRedraw); | 1150 EXPECT_TRUE(m_didRequestRedraw); |
1151 EXPECT_TRUE(m_didRequestCommit); | 1151 EXPECT_TRUE(m_didRequestCommit); |
1152 } | 1152 } |
1153 | 1153 |
1154 TEST_P(LayerTreeHostImplTest, scrollChildCallsCommitAndRedraw) | 1154 TEST_P(LayerTreeHostImplTest, scrollChildCallsCommitAndRedraw) |
1155 { | 1155 { |
1156 gfx::Size surfaceSize(10, 10); | 1156 gfx::Size surfaceSize(10, 10); |
1157 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1); | 1157 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1); |
1158 root->setBounds(surfaceSize); | 1158 root->setBounds(surfaceSize); |
1159 root->setContentBounds(surfaceSize); | 1159 root->setContentBounds(surfaceSize); |
1160 root->addChild(createScrollableLayer(2, surfaceSize)); | 1160 root->addChild(createScrollableLayer(2, surfaceSize)); |
1161 m_hostImpl->setRootLayer(root.Pass()); | 1161 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
1162 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1162 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1163 initializeRendererAndDrawFrame(); | 1163 initializeRendererAndDrawFrame(); |
1164 | 1164 |
1165 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 1165 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
1166 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 1166 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
1167 m_hostImpl->scrollEnd(); | 1167 m_hostImpl->scrollEnd(); |
1168 EXPECT_TRUE(m_didRequestRedraw); | 1168 EXPECT_TRUE(m_didRequestRedraw); |
1169 EXPECT_TRUE(m_didRequestCommit); | 1169 EXPECT_TRUE(m_didRequestCommit); |
1170 } | 1170 } |
1171 | 1171 |
1172 TEST_P(LayerTreeHostImplTest, scrollMissesChild) | 1172 TEST_P(LayerTreeHostImplTest, scrollMissesChild) |
1173 { | 1173 { |
1174 gfx::Size surfaceSize(10, 10); | 1174 gfx::Size surfaceSize(10, 10); |
1175 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1); | 1175 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1); |
1176 root->addChild(createScrollableLayer(2, surfaceSize)); | 1176 root->addChild(createScrollableLayer(2, surfaceSize)); |
1177 m_hostImpl->setRootLayer(root.Pass()); | 1177 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
1178 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1178 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1179 initializeRendererAndDrawFrame(); | 1179 initializeRendererAndDrawFrame(); |
1180 | 1180 |
1181 // Scroll event is ignored because the input coordinate is outside the layer
boundaries. | 1181 // Scroll event is ignored because the input coordinate is outside the layer
boundaries. |
1182 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(15, 5), InputHandlerClient::Whe
el), InputHandlerClient::ScrollIgnored); | 1182 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(15, 5), InputHandlerClient::Whe
el), InputHandlerClient::ScrollIgnored); |
1183 EXPECT_FALSE(m_didRequestRedraw); | 1183 EXPECT_FALSE(m_didRequestRedraw); |
1184 EXPECT_FALSE(m_didRequestCommit); | 1184 EXPECT_FALSE(m_didRequestCommit); |
1185 } | 1185 } |
1186 | 1186 |
1187 TEST_P(LayerTreeHostImplTest, scrollMissesBackfacingChild) | 1187 TEST_P(LayerTreeHostImplTest, scrollMissesBackfacingChild) |
1188 { | 1188 { |
1189 gfx::Size surfaceSize(10, 10); | 1189 gfx::Size surfaceSize(10, 10); |
1190 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1); | 1190 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1); |
1191 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize); | 1191 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize); |
1192 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1192 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1193 | 1193 |
1194 gfx::Transform matrix; | 1194 gfx::Transform matrix; |
1195 MathUtil::rotateEulerAngles(&matrix, 180, 0, 0); | 1195 MathUtil::rotateEulerAngles(&matrix, 180, 0, 0); |
1196 child->setTransform(matrix); | 1196 child->setTransform(matrix); |
1197 child->setDoubleSided(false); | 1197 child->setDoubleSided(false); |
1198 | 1198 |
1199 root->addChild(child.Pass()); | 1199 root->addChild(child.Pass()); |
1200 m_hostImpl->setRootLayer(root.Pass()); | 1200 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
1201 initializeRendererAndDrawFrame(); | 1201 initializeRendererAndDrawFrame(); |
1202 | 1202 |
1203 // Scroll event is ignored because the scrollable layer is not facing the vi
ewer and there is | 1203 // Scroll event is ignored because the scrollable layer is not facing the vi
ewer and there is |
1204 // nothing scrollable behind it. | 1204 // nothing scrollable behind it. |
1205 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollIgnored); | 1205 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollIgnored); |
1206 EXPECT_FALSE(m_didRequestRedraw); | 1206 EXPECT_FALSE(m_didRequestRedraw); |
1207 EXPECT_FALSE(m_didRequestCommit); | 1207 EXPECT_FALSE(m_didRequestCommit); |
1208 } | 1208 } |
1209 | 1209 |
1210 TEST_P(LayerTreeHostImplTest, scrollBlockedByContentLayer) | 1210 TEST_P(LayerTreeHostImplTest, scrollBlockedByContentLayer) |
1211 { | 1211 { |
1212 gfx::Size surfaceSize(10, 10); | 1212 gfx::Size surfaceSize(10, 10); |
1213 scoped_ptr<LayerImpl> contentLayer = createScrollableLayer(1, surfaceSize); | 1213 scoped_ptr<LayerImpl> contentLayer = createScrollableLayer(1, surfaceSize); |
1214 contentLayer->setShouldScrollOnMainThread(true); | 1214 contentLayer->setShouldScrollOnMainThread(true); |
1215 contentLayer->setScrollable(false); | 1215 contentLayer->setScrollable(false); |
1216 | 1216 |
1217 scoped_ptr<LayerImpl> scrollLayer = createScrollableLayer(2, surfaceSize); | 1217 scoped_ptr<LayerImpl> scrollLayer = createScrollableLayer(2, surfaceSize); |
1218 scrollLayer->addChild(contentLayer.Pass()); | 1218 scrollLayer->addChild(contentLayer.Pass()); |
1219 | 1219 |
1220 m_hostImpl->setRootLayer(scrollLayer.Pass()); | 1220 m_hostImpl->activeTree()->SetRootLayer(scrollLayer.Pass()); |
1221 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1221 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1222 initializeRendererAndDrawFrame(); | 1222 initializeRendererAndDrawFrame(); |
1223 | 1223 |
1224 // Scrolling fails because the content layer is asking to be scrolled on the
main thread. | 1224 // Scrolling fails because the content layer is asking to be scrolled on the
main thread. |
1225 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollOnMainThread); | 1225 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollOnMainThread); |
1226 } | 1226 } |
1227 | 1227 |
1228 TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnMainThread) | 1228 TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnMainThread) |
1229 { | 1229 { |
1230 gfx::Size surfaceSize(10, 10); | 1230 gfx::Size surfaceSize(10, 10); |
1231 float pageScale = 2; | 1231 float pageScale = 2; |
1232 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); | 1232 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); |
1233 m_hostImpl->setRootLayer(root.Pass()); | 1233 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
1234 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1234 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1235 initializeRendererAndDrawFrame(); | 1235 initializeRendererAndDrawFrame(); |
1236 | 1236 |
1237 gfx::Vector2d scrollDelta(0, 10); | 1237 gfx::Vector2d scrollDelta(0, 10); |
1238 gfx::Vector2d expectedScrollDelta(scrollDelta); | 1238 gfx::Vector2d expectedScrollDelta(scrollDelta); |
1239 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); | 1239 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); |
1240 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 1240 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
1241 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 1241 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
1242 m_hostImpl->scrollEnd(); | 1242 m_hostImpl->scrollEnd(); |
1243 | 1243 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1275 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(3
, 1)); | 1275 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(3
, 1)); |
1276 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(3
, 2)); | 1276 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(3
, 2)); |
1277 EXPECT_EQ(1.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(3
, 3)); | 1277 EXPECT_EQ(1.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(3
, 3)); |
1278 } | 1278 } |
1279 | 1279 |
1280 TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread) | 1280 TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread) |
1281 { | 1281 { |
1282 gfx::Size surfaceSize(10, 10); | 1282 gfx::Size surfaceSize(10, 10); |
1283 float pageScale = 2; | 1283 float pageScale = 2; |
1284 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); | 1284 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); |
1285 m_hostImpl->setRootLayer(root.Pass()); | 1285 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
1286 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1286 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1287 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); | 1287 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); |
1288 initializeRendererAndDrawFrame(); | 1288 initializeRendererAndDrawFrame(); |
1289 | 1289 |
1290 gfx::Vector2d scrollDelta(0, 10); | 1290 gfx::Vector2d scrollDelta(0, 10); |
1291 gfx::Vector2d expectedScrollDelta(scrollDelta); | 1291 gfx::Vector2d expectedScrollDelta(scrollDelta); |
1292 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); | 1292 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); |
1293 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 1293 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
1294 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 1294 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
1295 m_hostImpl->scrollEnd(); | 1295 m_hostImpl->scrollEnd(); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1361 TEST_P(LayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread) | 1361 TEST_P(LayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread) |
1362 { | 1362 { |
1363 gfx::Size surfaceSize(10, 10); | 1363 gfx::Size surfaceSize(10, 10); |
1364 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1); | 1364 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1); |
1365 root->setBounds(surfaceSize); | 1365 root->setBounds(surfaceSize); |
1366 root->setContentBounds(surfaceSize); | 1366 root->setContentBounds(surfaceSize); |
1367 // Also mark the root scrollable so it becomes the root scroll layer. | 1367 // Also mark the root scrollable so it becomes the root scroll layer. |
1368 root->setScrollable(true); | 1368 root->setScrollable(true); |
1369 int scrollLayerId = 2; | 1369 int scrollLayerId = 2; |
1370 root->addChild(createScrollableLayer(scrollLayerId, surfaceSize)); | 1370 root->addChild(createScrollableLayer(scrollLayerId, surfaceSize)); |
1371 m_hostImpl->setRootLayer(root.Pass()); | 1371 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
1372 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1372 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1373 initializeRendererAndDrawFrame(); | 1373 initializeRendererAndDrawFrame(); |
1374 | 1374 |
1375 LayerImpl* child = m_hostImpl->rootLayer()->children()[0]; | 1375 LayerImpl* child = m_hostImpl->rootLayer()->children()[0]; |
1376 | 1376 |
1377 gfx::Vector2d scrollDelta(0, 10); | 1377 gfx::Vector2d scrollDelta(0, 10); |
1378 gfx::Vector2d expectedScrollDelta(scrollDelta); | 1378 gfx::Vector2d expectedScrollDelta(scrollDelta); |
1379 gfx::Vector2d expectedMaxScroll(child->maxScrollOffset()); | 1379 gfx::Vector2d expectedMaxScroll(child->maxScrollOffset()); |
1380 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 1380 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
1381 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 1381 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
(...skipping 28 matching lines...) Expand all Loading... |
1410 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); | 1410 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); |
1411 | 1411 |
1412 scoped_ptr<LayerImpl> grandChild = createScrollableLayer(3, surfaceSize); | 1412 scoped_ptr<LayerImpl> grandChild = createScrollableLayer(3, surfaceSize); |
1413 grandChild->setScrollOffset(gfx::Vector2d(0, 5)); | 1413 grandChild->setScrollOffset(gfx::Vector2d(0, 5)); |
1414 | 1414 |
1415 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize); | 1415 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize); |
1416 child->setScrollOffset(gfx::Vector2d(3, 0)); | 1416 child->setScrollOffset(gfx::Vector2d(3, 0)); |
1417 child->addChild(grandChild.Pass()); | 1417 child->addChild(grandChild.Pass()); |
1418 | 1418 |
1419 root->addChild(child.Pass()); | 1419 root->addChild(child.Pass()); |
1420 m_hostImpl->setRootLayer(root.Pass()); | 1420 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
1421 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1421 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1422 initializeRendererAndDrawFrame(); | 1422 initializeRendererAndDrawFrame(); |
1423 { | 1423 { |
1424 gfx::Vector2d scrollDelta(-8, -7); | 1424 gfx::Vector2d scrollDelta(-8, -7); |
1425 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::
Wheel), InputHandlerClient::ScrollStarted); | 1425 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::
Wheel), InputHandlerClient::ScrollStarted); |
1426 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 1426 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
1427 m_hostImpl->scrollEnd(); | 1427 m_hostImpl->scrollEnd(); |
1428 | 1428 |
1429 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 1429 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
1430 | 1430 |
(...skipping 11 matching lines...) Expand all Loading... |
1442 { | 1442 { |
1443 // When we try to scroll a non-scrollable child layer, the scroll delta | 1443 // When we try to scroll a non-scrollable child layer, the scroll delta |
1444 // should be applied to one of its ancestors if possible. | 1444 // should be applied to one of its ancestors if possible. |
1445 gfx::Size surfaceSize(10, 10); | 1445 gfx::Size surfaceSize(10, 10); |
1446 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); | 1446 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); |
1447 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize); | 1447 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize); |
1448 | 1448 |
1449 child->setScrollable(false); | 1449 child->setScrollable(false); |
1450 root->addChild(child.Pass()); | 1450 root->addChild(child.Pass()); |
1451 | 1451 |
1452 m_hostImpl->setRootLayer(root.Pass()); | 1452 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
1453 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1453 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1454 initializeRendererAndDrawFrame(); | 1454 initializeRendererAndDrawFrame(); |
1455 { | 1455 { |
1456 gfx::Vector2d scrollDelta(0, 4); | 1456 gfx::Vector2d scrollDelta(0, 4); |
1457 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::
Wheel), InputHandlerClient::ScrollStarted); | 1457 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::
Wheel), InputHandlerClient::ScrollStarted); |
1458 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 1458 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
1459 m_hostImpl->scrollEnd(); | 1459 m_hostImpl->scrollEnd(); |
1460 | 1460 |
1461 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 1461 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
1462 | 1462 |
1463 // Only the root should have scrolled. | 1463 // Only the root should have scrolled. |
1464 ASSERT_EQ(scrollInfo->scrolls.size(), 1u); | 1464 ASSERT_EQ(scrollInfo->scrolls.size(), 1u); |
1465 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD
elta); | 1465 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD
elta); |
1466 } | 1466 } |
1467 } | 1467 } |
1468 | 1468 |
1469 TEST_P(LayerTreeHostImplTest, scrollBeforeRedraw) | 1469 TEST_P(LayerTreeHostImplTest, scrollBeforeRedraw) |
1470 { | 1470 { |
1471 gfx::Size surfaceSize(10, 10); | 1471 gfx::Size surfaceSize(10, 10); |
1472 m_hostImpl->setRootLayer(createScrollableLayer(1, surfaceSize)); | 1472 m_hostImpl->activeTree()->SetRootLayer(createScrollableLayer(1, surfaceSize)
); |
1473 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1473 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1474 | 1474 |
1475 // Draw one frame and then immediately rebuild the layer tree to mimic a tre
e synchronization. | 1475 // Draw one frame and then immediately rebuild the layer tree to mimic a tre
e synchronization. |
1476 initializeRendererAndDrawFrame(); | 1476 initializeRendererAndDrawFrame(); |
1477 m_hostImpl->detachLayerTree(); | 1477 m_hostImpl->activeTree()->DetachLayerTree(); |
1478 m_hostImpl->setRootLayer(createScrollableLayer(2, surfaceSize)); | 1478 m_hostImpl->activeTree()->SetRootLayer(createScrollableLayer(2, surfaceSize)
); |
1479 | 1479 |
1480 // Scrolling should still work even though we did not draw yet. | 1480 // Scrolling should still work even though we did not draw yet. |
1481 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 1481 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
1482 } | 1482 } |
1483 | 1483 |
1484 TEST_P(LayerTreeHostImplTest, scrollAxisAlignedRotatedLayer) | 1484 TEST_P(LayerTreeHostImplTest, scrollAxisAlignedRotatedLayer) |
1485 { | 1485 { |
1486 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 1486 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
1487 | 1487 |
1488 // Rotate the root layer 90 degrees counter-clockwise about its center. | 1488 // Rotate the root layer 90 degrees counter-clockwise about its center. |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1697 }; | 1697 }; |
1698 | 1698 |
1699 TEST_P(LayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers) | 1699 TEST_P(LayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers) |
1700 { | 1700 { |
1701 { | 1701 { |
1702 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(),
1); | 1702 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(),
1); |
1703 root->setAnchorPoint(gfx::PointF(0, 0)); | 1703 root->setAnchorPoint(gfx::PointF(0, 0)); |
1704 root->setBounds(gfx::Size(10, 10)); | 1704 root->setBounds(gfx::Size(10, 10)); |
1705 root->setContentBounds(root->bounds()); | 1705 root->setContentBounds(root->bounds()); |
1706 root->setDrawsContent(false); | 1706 root->setDrawsContent(false); |
1707 m_hostImpl->setRootLayer(root.Pass()); | 1707 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
1708 } | 1708 } |
1709 LayerImpl* root = m_hostImpl->rootLayer(); | 1709 LayerImpl* root = m_hostImpl->rootLayer(); |
1710 | 1710 |
1711 root->addChild(BlendStateCheckLayer::create(m_hostImpl->activeTree(), 2, m_h
ostImpl->resourceProvider())); | 1711 root->addChild(BlendStateCheckLayer::create(m_hostImpl->activeTree(), 2, m_h
ostImpl->resourceProvider())); |
1712 BlendStateCheckLayer* layer1 = static_cast<BlendStateCheckLayer*>(root->chil
dren()[0]); | 1712 BlendStateCheckLayer* layer1 = static_cast<BlendStateCheckLayer*>(root->chil
dren()[0]); |
1713 layer1->setPosition(gfx::PointF(2, 2)); | 1713 layer1->setPosition(gfx::PointF(2, 2)); |
1714 | 1714 |
1715 LayerTreeHostImpl::FrameData frame; | 1715 LayerTreeHostImpl::FrameData frame; |
1716 | 1716 |
1717 // Opaque layer, drawn without blending. | 1717 // Opaque layer, drawn without blending. |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1884 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1884 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
1885 m_hostImpl->drawLayers(frame); | 1885 m_hostImpl->drawLayers(frame); |
1886 EXPECT_TRUE(layer1->quadsAppended()); | 1886 EXPECT_TRUE(layer1->quadsAppended()); |
1887 m_hostImpl->didDrawAllLayers(frame); | 1887 m_hostImpl->didDrawAllLayers(frame); |
1888 | 1888 |
1889 } | 1889 } |
1890 | 1890 |
1891 TEST_P(LayerTreeHostImplTest, viewportCovered) | 1891 TEST_P(LayerTreeHostImplTest, viewportCovered) |
1892 { | 1892 { |
1893 m_hostImpl->initializeRenderer(createOutputSurface()); | 1893 m_hostImpl->initializeRenderer(createOutputSurface()); |
1894 m_hostImpl->setBackgroundColor(SK_ColorGRAY); | 1894 m_hostImpl->activeTree()->set_background_color(SK_ColorGRAY); |
1895 | 1895 |
1896 gfx::Size viewportSize(1000, 1000); | 1896 gfx::Size viewportSize(1000, 1000); |
1897 m_hostImpl->setViewportSize(viewportSize, viewportSize); | 1897 m_hostImpl->setViewportSize(viewportSize, viewportSize); |
1898 | 1898 |
1899 m_hostImpl->setRootLayer(LayerImpl::create(m_hostImpl->activeTree(), 1)); | 1899 m_hostImpl->activeTree()->SetRootLayer(LayerImpl::create(m_hostImpl->activeT
ree(), 1)); |
1900 m_hostImpl->rootLayer()->addChild(BlendStateCheckLayer::create(m_hostImpl->a
ctiveTree(), 2, m_hostImpl->resourceProvider())); | 1900 m_hostImpl->rootLayer()->addChild(BlendStateCheckLayer::create(m_hostImpl->a
ctiveTree(), 2, m_hostImpl->resourceProvider())); |
1901 BlendStateCheckLayer* child = static_cast<BlendStateCheckLayer*>(m_hostImpl-
>rootLayer()->children()[0]); | 1901 BlendStateCheckLayer* child = static_cast<BlendStateCheckLayer*>(m_hostImpl-
>rootLayer()->children()[0]); |
1902 child->setExpectation(false, false); | 1902 child->setExpectation(false, false); |
1903 child->setContentsOpaque(true); | 1903 child->setContentsOpaque(true); |
1904 | 1904 |
1905 // No gutter rects | 1905 // No gutter rects |
1906 { | 1906 { |
1907 gfx::Rect layerRect(0, 0, 1000, 1000); | 1907 gfx::Rect layerRect(0, 0, 1000, 1000); |
1908 child->setPosition(layerRect.origin()); | 1908 child->setPosition(layerRect.origin()); |
1909 child->setBounds(layerRect.size()); | 1909 child->setBounds(layerRect.size()); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2002 TEST_P(LayerTreeHostImplTest, reshapeNotCalledUntilDraw) | 2002 TEST_P(LayerTreeHostImplTest, reshapeNotCalledUntilDraw) |
2003 { | 2003 { |
2004 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new ReshapeTrackerContext)).PassAs<OutputSurf
ace>(); | 2004 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new ReshapeTrackerContext)).PassAs<OutputSurf
ace>(); |
2005 ReshapeTrackerContext* reshapeTracker = static_cast<ReshapeTrackerContext*>(
outputSurface->Context3D()); | 2005 ReshapeTrackerContext* reshapeTracker = static_cast<ReshapeTrackerContext*>(
outputSurface->Context3D()); |
2006 m_hostImpl->initializeRenderer(outputSurface.Pass()); | 2006 m_hostImpl->initializeRenderer(outputSurface.Pass()); |
2007 | 2007 |
2008 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(m_hostImpl->activ
eTree(), 1); | 2008 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(m_hostImpl->activ
eTree(), 1); |
2009 root->setAnchorPoint(gfx::PointF(0, 0)); | 2009 root->setAnchorPoint(gfx::PointF(0, 0)); |
2010 root->setBounds(gfx::Size(10, 10)); | 2010 root->setBounds(gfx::Size(10, 10)); |
2011 root->setDrawsContent(true); | 2011 root->setDrawsContent(true); |
2012 m_hostImpl->setRootLayer(root.Pass()); | 2012 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
2013 EXPECT_FALSE(reshapeTracker->reshapeCalled()); | 2013 EXPECT_FALSE(reshapeTracker->reshapeCalled()); |
2014 | 2014 |
2015 LayerTreeHostImpl::FrameData frame; | 2015 LayerTreeHostImpl::FrameData frame; |
2016 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2016 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
2017 m_hostImpl->drawLayers(frame); | 2017 m_hostImpl->drawLayers(frame); |
2018 EXPECT_TRUE(reshapeTracker->reshapeCalled()); | 2018 EXPECT_TRUE(reshapeTracker->reshapeCalled()); |
2019 m_hostImpl->didDrawAllLayers(frame); | 2019 m_hostImpl->didDrawAllLayers(frame); |
2020 } | 2020 } |
2021 | 2021 |
2022 class PartialSwapTrackerContext : public FakeWebGraphicsContext3D { | 2022 class PartialSwapTrackerContext : public FakeWebGraphicsContext3D { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2060 child->setPosition(gfx::PointF(12, 13)); | 2060 child->setPosition(gfx::PointF(12, 13)); |
2061 child->setAnchorPoint(gfx::PointF(0, 0)); | 2061 child->setAnchorPoint(gfx::PointF(0, 0)); |
2062 child->setBounds(gfx::Size(14, 15)); | 2062 child->setBounds(gfx::Size(14, 15)); |
2063 child->setContentBounds(gfx::Size(14, 15)); | 2063 child->setContentBounds(gfx::Size(14, 15)); |
2064 child->setDrawsContent(true); | 2064 child->setDrawsContent(true); |
2065 root->setAnchorPoint(gfx::PointF(0, 0)); | 2065 root->setAnchorPoint(gfx::PointF(0, 0)); |
2066 root->setBounds(gfx::Size(500, 500)); | 2066 root->setBounds(gfx::Size(500, 500)); |
2067 root->setContentBounds(gfx::Size(500, 500)); | 2067 root->setContentBounds(gfx::Size(500, 500)); |
2068 root->setDrawsContent(true); | 2068 root->setDrawsContent(true); |
2069 root->addChild(child.Pass()); | 2069 root->addChild(child.Pass()); |
2070 layerTreeHostImpl->setRootLayer(root.Pass()); | 2070 layerTreeHostImpl->activeTree()->SetRootLayer(root.Pass()); |
2071 | 2071 |
2072 LayerTreeHostImpl::FrameData frame; | 2072 LayerTreeHostImpl::FrameData frame; |
2073 | 2073 |
2074 // First frame, the entire screen should get swapped. | 2074 // First frame, the entire screen should get swapped. |
2075 EXPECT_TRUE(layerTreeHostImpl->prepareToDraw(frame)); | 2075 EXPECT_TRUE(layerTreeHostImpl->prepareToDraw(frame)); |
2076 layerTreeHostImpl->drawLayers(frame); | 2076 layerTreeHostImpl->drawLayers(frame); |
2077 layerTreeHostImpl->didDrawAllLayers(frame); | 2077 layerTreeHostImpl->didDrawAllLayers(frame); |
2078 layerTreeHostImpl->swapBuffers(); | 2078 layerTreeHostImpl->swapBuffers(); |
2079 gfx::Rect actualSwapRect = partialSwapTracker->partialSwapRect(); | 2079 gfx::Rect actualSwapRect = partialSwapTracker->partialSwapRect(); |
2080 gfx::Rect expectedSwapRect = gfx::Rect(gfx::Point(), gfx::Size(500, 500)); | 2080 gfx::Rect expectedSwapRect = gfx::Rect(gfx::Point(), gfx::Size(500, 500)); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2124 child->setBounds(gfx::Size(10, 10)); | 2124 child->setBounds(gfx::Size(10, 10)); |
2125 child->setContentBounds(gfx::Size(10, 10)); | 2125 child->setContentBounds(gfx::Size(10, 10)); |
2126 child->setDrawsContent(true); | 2126 child->setDrawsContent(true); |
2127 root->setAnchorPoint(gfx::PointF(0, 0)); | 2127 root->setAnchorPoint(gfx::PointF(0, 0)); |
2128 root->setBounds(gfx::Size(10, 10)); | 2128 root->setBounds(gfx::Size(10, 10)); |
2129 root->setContentBounds(gfx::Size(10, 10)); | 2129 root->setContentBounds(gfx::Size(10, 10)); |
2130 root->setDrawsContent(true); | 2130 root->setDrawsContent(true); |
2131 root->setOpacity(0.7f); | 2131 root->setOpacity(0.7f); |
2132 root->addChild(child.Pass()); | 2132 root->addChild(child.Pass()); |
2133 | 2133 |
2134 m_hostImpl->setRootLayer(root.Pass()); | 2134 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
2135 | 2135 |
2136 LayerTreeHostImpl::FrameData frame; | 2136 LayerTreeHostImpl::FrameData frame; |
2137 | 2137 |
2138 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2138 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
2139 EXPECT_EQ(1u, frame.renderSurfaceLayerList->size()); | 2139 EXPECT_EQ(1u, frame.renderSurfaceLayerList->size()); |
2140 EXPECT_EQ(1u, frame.renderPasses.size()); | 2140 EXPECT_EQ(1u, frame.renderPasses.size()); |
2141 m_hostImpl->didDrawAllLayers(frame); | 2141 m_hostImpl->didDrawAllLayers(frame); |
2142 } | 2142 } |
2143 | 2143 |
2144 class FakeLayerWithQuads : public LayerImpl { | 2144 class FakeLayerWithQuads : public LayerImpl { |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2400 grandChild->setAnchorPoint(gfx::PointF(0, 0)); | 2400 grandChild->setAnchorPoint(gfx::PointF(0, 0)); |
2401 grandChild->setPosition(gfx::Point(grandChildRect.x(), grandChildRect.y())); | 2401 grandChild->setPosition(gfx::Point(grandChildRect.x(), grandChildRect.y())); |
2402 grandChild->setBounds(gfx::Size(grandChildRect.width(), grandChildRect.heigh
t())); | 2402 grandChild->setBounds(gfx::Size(grandChildRect.width(), grandChildRect.heigh
t())); |
2403 grandChild->setContentBounds(grandChild->bounds()); | 2403 grandChild->setContentBounds(grandChild->bounds()); |
2404 grandChild->drawProperties().visible_content_rect = grandChildRect; | 2404 grandChild->drawProperties().visible_content_rect = grandChildRect; |
2405 grandChild->setDrawsContent(true); | 2405 grandChild->setDrawsContent(true); |
2406 | 2406 |
2407 child->addChild(grandChild.Pass()); | 2407 child->addChild(grandChild.Pass()); |
2408 root->addChild(child.Pass()); | 2408 root->addChild(child.Pass()); |
2409 | 2409 |
2410 myHostImpl->setRootLayer(root.Pass()); | 2410 myHostImpl->activeTree()->SetRootLayer(root.Pass()); |
2411 return myHostImpl.Pass(); | 2411 return myHostImpl.Pass(); |
2412 } | 2412 } |
2413 | 2413 |
2414 TEST_P(LayerTreeHostImplTest, contributingLayerEmptyScissorPartialSwap) | 2414 TEST_P(LayerTreeHostImplTest, contributingLayerEmptyScissorPartialSwap) |
2415 { | 2415 { |
2416 scoped_ptr<LayerTreeHostImpl> myHostImpl = setupLayersForOpacity(true, this,
&m_proxy); | 2416 scoped_ptr<LayerTreeHostImpl> myHostImpl = setupLayersForOpacity(true, this,
&m_proxy); |
2417 | 2417 |
2418 { | 2418 { |
2419 LayerTreeHostImpl::FrameData frame; | 2419 LayerTreeHostImpl::FrameData frame; |
2420 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 2420 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2533 rootLayer->addChild(videoLayer.PassAs<LayerImpl>()); | 2533 rootLayer->addChild(videoLayer.PassAs<LayerImpl>()); |
2534 | 2534 |
2535 scoped_ptr<IOSurfaceLayerImpl> ioSurfaceLayer = IOSurfaceLayerImpl::create(m
_hostImpl->activeTree(), 5); | 2535 scoped_ptr<IOSurfaceLayerImpl> ioSurfaceLayer = IOSurfaceLayerImpl::create(m
_hostImpl->activeTree(), 5); |
2536 ioSurfaceLayer->setBounds(gfx::Size(10, 10)); | 2536 ioSurfaceLayer->setBounds(gfx::Size(10, 10)); |
2537 ioSurfaceLayer->setAnchorPoint(gfx::PointF(0, 0)); | 2537 ioSurfaceLayer->setAnchorPoint(gfx::PointF(0, 0)); |
2538 ioSurfaceLayer->setContentBounds(gfx::Size(10, 10)); | 2538 ioSurfaceLayer->setContentBounds(gfx::Size(10, 10)); |
2539 ioSurfaceLayer->setDrawsContent(true); | 2539 ioSurfaceLayer->setDrawsContent(true); |
2540 ioSurfaceLayer->setIOSurfaceProperties(1, gfx::Size(10, 10)); | 2540 ioSurfaceLayer->setIOSurfaceProperties(1, gfx::Size(10, 10)); |
2541 rootLayer->addChild(ioSurfaceLayer.PassAs<LayerImpl>()); | 2541 rootLayer->addChild(ioSurfaceLayer.PassAs<LayerImpl>()); |
2542 | 2542 |
2543 m_hostImpl->setRootLayer(rootLayer.Pass()); | 2543 m_hostImpl->activeTree()->SetRootLayer(rootLayer.Pass()); |
2544 | 2544 |
2545 EXPECT_EQ(0u, context3d->NumTextures()); | 2545 EXPECT_EQ(0u, context3d->NumTextures()); |
2546 | 2546 |
2547 LayerTreeHostImpl::FrameData frame; | 2547 LayerTreeHostImpl::FrameData frame; |
2548 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2548 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
2549 m_hostImpl->drawLayers(frame); | 2549 m_hostImpl->drawLayers(frame); |
2550 m_hostImpl->didDrawAllLayers(frame); | 2550 m_hostImpl->didDrawAllLayers(frame); |
2551 m_hostImpl->swapBuffers(); | 2551 m_hostImpl->swapBuffers(); |
2552 | 2552 |
2553 EXPECT_GT(context3d->NumTextures(), 0u); | 2553 EXPECT_GT(context3d->NumTextures(), 0u); |
2554 | 2554 |
2555 // Kill the layer tree. | 2555 // Kill the layer tree. |
2556 m_hostImpl->setRootLayer(LayerImpl::create(m_hostImpl->activeTree(), 100)); | 2556 m_hostImpl->activeTree()->SetRootLayer(LayerImpl::create(m_hostImpl->activeT
ree(), 100)); |
2557 // There should be no textures left in use after. | 2557 // There should be no textures left in use after. |
2558 EXPECT_EQ(0u, context3d->NumTextures()); | 2558 EXPECT_EQ(0u, context3d->NumTextures()); |
2559 } | 2559 } |
2560 | 2560 |
2561 class MockDrawQuadsToFillScreenContext : public FakeWebGraphicsContext3D { | 2561 class MockDrawQuadsToFillScreenContext : public FakeWebGraphicsContext3D { |
2562 public: | 2562 public: |
2563 MOCK_METHOD1(useProgram, void(WebKit::WebGLId program)); | 2563 MOCK_METHOD1(useProgram, void(WebKit::WebGLId program)); |
2564 MOCK_METHOD4(drawElements, void(WebKit::WGC3Denum mode, WebKit::WGC3Dsizei c
ount, WebKit::WGC3Denum type, WebKit::WGC3Dintptr offset)); | 2564 MOCK_METHOD4(drawElements, void(WebKit::WGC3Denum mode, WebKit::WGC3Dsizei c
ount, WebKit::WGC3Denum type, WebKit::WGC3Dintptr offset)); |
2565 }; | 2565 }; |
2566 | 2566 |
2567 TEST_P(LayerTreeHostImplTest, hasTransparentBackground) | 2567 TEST_P(LayerTreeHostImplTest, hasTransparentBackground) |
2568 { | 2568 { |
2569 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new MockDrawQuadsToFillScreenContext)).PassAs
<OutputSurface>(); | 2569 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new MockDrawQuadsToFillScreenContext)).PassAs
<OutputSurface>(); |
2570 MockDrawQuadsToFillScreenContext* mockContext = static_cast<MockDrawQuadsToF
illScreenContext*>(outputSurface->Context3D()); | 2570 MockDrawQuadsToFillScreenContext* mockContext = static_cast<MockDrawQuadsToF
illScreenContext*>(outputSurface->Context3D()); |
2571 | 2571 |
2572 // Run test case | 2572 // Run test case |
2573 createLayerTreeHost(false, outputSurface.Pass()); | 2573 createLayerTreeHost(false, outputSurface.Pass()); |
2574 setupRootLayerImpl(LayerImpl::create(m_hostImpl->activeTree(), 1)); | 2574 setupRootLayerImpl(LayerImpl::create(m_hostImpl->activeTree(), 1)); |
2575 m_hostImpl->setBackgroundColor(SK_ColorWHITE); | 2575 m_hostImpl->activeTree()->set_background_color(SK_ColorWHITE); |
2576 | 2576 |
2577 // Verify one quad is drawn when transparent background set is not set. | 2577 // Verify one quad is drawn when transparent background set is not set. |
2578 m_hostImpl->setHasTransparentBackground(false); | 2578 m_hostImpl->activeTree()->set_has_transparent_background(false); |
2579 EXPECT_CALL(*mockContext, useProgram(_)) | 2579 EXPECT_CALL(*mockContext, useProgram(_)) |
2580 .Times(1); | 2580 .Times(1); |
2581 EXPECT_CALL(*mockContext, drawElements(_, _, _, _)) | 2581 EXPECT_CALL(*mockContext, drawElements(_, _, _, _)) |
2582 .Times(1); | 2582 .Times(1); |
2583 LayerTreeHostImpl::FrameData frame; | 2583 LayerTreeHostImpl::FrameData frame; |
2584 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2584 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
2585 m_hostImpl->drawLayers(frame); | 2585 m_hostImpl->drawLayers(frame); |
2586 m_hostImpl->didDrawAllLayers(frame); | 2586 m_hostImpl->didDrawAllLayers(frame); |
2587 Mock::VerifyAndClearExpectations(&mockContext); | 2587 Mock::VerifyAndClearExpectations(&mockContext); |
2588 | 2588 |
2589 // Verify no quads are drawn when transparent background is set. | 2589 // Verify no quads are drawn when transparent background is set. |
2590 m_hostImpl->setHasTransparentBackground(true); | 2590 m_hostImpl->activeTree()->set_has_transparent_background(true); |
2591 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2591 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
2592 m_hostImpl->drawLayers(frame); | 2592 m_hostImpl->drawLayers(frame); |
2593 m_hostImpl->didDrawAllLayers(frame); | 2593 m_hostImpl->didDrawAllLayers(frame); |
2594 Mock::VerifyAndClearExpectations(&mockContext); | 2594 Mock::VerifyAndClearExpectations(&mockContext); |
2595 } | 2595 } |
2596 | 2596 |
2597 static void addDrawingLayerTo(LayerImpl* parent, int id, const gfx::Rect& layerR
ect, LayerImpl** result) | 2597 static void addDrawingLayerTo(LayerImpl* parent, int id, const gfx::Rect& layerR
ect, LayerImpl** result) |
2598 { | 2598 { |
2599 scoped_ptr<LayerImpl> layer = FakeLayerWithQuads::create(parent->layerTreeIm
pl(), id); | 2599 scoped_ptr<LayerImpl> layer = FakeLayerWithQuads::create(parent->layerTreeIm
pl(), id); |
2600 LayerImpl* layerPtr = layer.get(); | 2600 LayerImpl* layerPtr = layer.get(); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2678 | 2678 |
2679 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl->activeTree(), 1); | 2679 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl->activeTree(), 1); |
2680 rootPtr = root.get(); | 2680 rootPtr = root.get(); |
2681 | 2681 |
2682 root->setAnchorPoint(gfx::PointF(0, 0)); | 2682 root->setAnchorPoint(gfx::PointF(0, 0)); |
2683 root->setPosition(gfx::PointF(0, 0)); | 2683 root->setPosition(gfx::PointF(0, 0)); |
2684 root->setBounds(rootSize); | 2684 root->setBounds(rootSize); |
2685 root->setContentBounds(rootSize); | 2685 root->setContentBounds(rootSize); |
2686 root->setDrawsContent(true); | 2686 root->setDrawsContent(true); |
2687 root->setMasksToBounds(true); | 2687 root->setMasksToBounds(true); |
2688 myHostImpl->setRootLayer(root.Pass()); | 2688 myHostImpl->activeTree()->SetRootLayer(root.Pass()); |
2689 | 2689 |
2690 addDrawingLayerTo(rootPtr, 2, gfx::Rect(300, 300, 300, 300), &layerS1Ptr); | 2690 addDrawingLayerTo(rootPtr, 2, gfx::Rect(300, 300, 300, 300), &layerS1Ptr); |
2691 layerS1Ptr->setForceRenderSurface(true); | 2691 layerS1Ptr->setForceRenderSurface(true); |
2692 | 2692 |
2693 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(10, 10, 10, 10), 0); // L11 | 2693 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(10, 10, 10, 10), 0); // L11 |
2694 addDrawingLayerTo(layerS1Ptr, 4, gfx::Rect(0, 0, 30, 30), 0); // L12 | 2694 addDrawingLayerTo(layerS1Ptr, 4, gfx::Rect(0, 0, 30, 30), 0); // L12 |
2695 | 2695 |
2696 addDrawingLayerTo(rootPtr, 5, gfx::Rect(550, 250, 300, 400), &layerS2Ptr); | 2696 addDrawingLayerTo(rootPtr, 5, gfx::Rect(550, 250, 300, 400), &layerS2Ptr); |
2697 layerS2Ptr->setForceRenderSurface(true); | 2697 layerS2Ptr->setForceRenderSurface(true); |
2698 | 2698 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2789 | 2789 |
2790 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl->activeTree(), 1); | 2790 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl->activeTree(), 1); |
2791 rootPtr = root.get(); | 2791 rootPtr = root.get(); |
2792 | 2792 |
2793 root->setAnchorPoint(gfx::PointF(0, 0)); | 2793 root->setAnchorPoint(gfx::PointF(0, 0)); |
2794 root->setPosition(gfx::PointF(0, 0)); | 2794 root->setPosition(gfx::PointF(0, 0)); |
2795 root->setBounds(rootSize); | 2795 root->setBounds(rootSize); |
2796 root->setContentBounds(rootSize); | 2796 root->setContentBounds(rootSize); |
2797 root->setDrawsContent(true); | 2797 root->setDrawsContent(true); |
2798 root->setMasksToBounds(true); | 2798 root->setMasksToBounds(true); |
2799 myHostImpl->setRootLayer(root.Pass()); | 2799 myHostImpl->activeTree()->SetRootLayer(root.Pass()); |
2800 | 2800 |
2801 addDrawingLayerTo(rootPtr, 2, gfx::Rect(0, 0, 800, 800), &layerS1Ptr); | 2801 addDrawingLayerTo(rootPtr, 2, gfx::Rect(0, 0, 800, 800), &layerS1Ptr); |
2802 layerS1Ptr->setForceRenderSurface(true); | 2802 layerS1Ptr->setForceRenderSurface(true); |
2803 layerS1Ptr->setDrawsContent(false); | 2803 layerS1Ptr->setDrawsContent(false); |
2804 | 2804 |
2805 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(0, 0, 300, 300), 0); // L11 | 2805 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(0, 0, 300, 300), 0); // L11 |
2806 addDrawingLayerTo(layerS1Ptr, 4, gfx::Rect(0, 500, 300, 300), 0); // L12 | 2806 addDrawingLayerTo(layerS1Ptr, 4, gfx::Rect(0, 500, 300, 300), 0); // L12 |
2807 addDrawingLayerTo(layerS1Ptr, 5, gfx::Rect(500, 0, 300, 300), 0); // L13 | 2807 addDrawingLayerTo(layerS1Ptr, 5, gfx::Rect(500, 0, 300, 300), 0); // L13 |
2808 addDrawingLayerTo(layerS1Ptr, 6, gfx::Rect(500, 500, 300, 300), 0); // L14 | 2808 addDrawingLayerTo(layerS1Ptr, 6, gfx::Rect(500, 500, 300, 300), 0); // L14 |
2809 addDrawingLayerTo(layerS1Ptr, 9, gfx::Rect(500, 500, 300, 300), 0); // L14 | 2809 addDrawingLayerTo(layerS1Ptr, 9, gfx::Rect(500, 500, 300, 300), 0); // L14 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2901 | 2901 |
2902 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl->activeTree(), 1); | 2902 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl->activeTree(), 1); |
2903 rootPtr = root.get(); | 2903 rootPtr = root.get(); |
2904 | 2904 |
2905 root->setAnchorPoint(gfx::PointF(0, 0)); | 2905 root->setAnchorPoint(gfx::PointF(0, 0)); |
2906 root->setPosition(gfx::PointF(0, 0)); | 2906 root->setPosition(gfx::PointF(0, 0)); |
2907 root->setBounds(rootSize); | 2907 root->setBounds(rootSize); |
2908 root->setContentBounds(rootSize); | 2908 root->setContentBounds(rootSize); |
2909 root->setDrawsContent(true); | 2909 root->setDrawsContent(true); |
2910 root->setMasksToBounds(true); | 2910 root->setMasksToBounds(true); |
2911 myHostImpl->setRootLayer(root.Pass()); | 2911 myHostImpl->activeTree()->SetRootLayer(root.Pass()); |
2912 | 2912 |
2913 addDrawingLayerTo(rootPtr, 2, gfx::Rect(0, 0, 400, 400), &layerS1Ptr); | 2913 addDrawingLayerTo(rootPtr, 2, gfx::Rect(0, 0, 400, 400), &layerS1Ptr); |
2914 layerS1Ptr->setForceRenderSurface(true); | 2914 layerS1Ptr->setForceRenderSurface(true); |
2915 | 2915 |
2916 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(0, 0, 300, 300), 0); // L11 | 2916 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(0, 0, 300, 300), 0); // L11 |
2917 addDrawingLayerTo(layerS1Ptr, 4, gfx::Rect(100, 0, 300, 300), 0); // L12 | 2917 addDrawingLayerTo(layerS1Ptr, 4, gfx::Rect(100, 0, 300, 300), 0); // L12 |
2918 | 2918 |
2919 addDrawingLayerTo(rootPtr, 7, gfx::Rect(200, 0, 300, 300), &layerS2Ptr); | 2919 addDrawingLayerTo(rootPtr, 7, gfx::Rect(200, 0, 300, 300), &layerS2Ptr); |
2920 layerS2Ptr->setForceRenderSurface(true); | 2920 layerS2Ptr->setForceRenderSurface(true); |
2921 | 2921 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2982 | 2982 |
2983 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl->activeTree(), 1); | 2983 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl->activeTree(), 1); |
2984 rootPtr = root.get(); | 2984 rootPtr = root.get(); |
2985 | 2985 |
2986 root->setAnchorPoint(gfx::PointF(0, 0)); | 2986 root->setAnchorPoint(gfx::PointF(0, 0)); |
2987 root->setPosition(gfx::PointF(0, 0)); | 2987 root->setPosition(gfx::PointF(0, 0)); |
2988 root->setBounds(rootSize); | 2988 root->setBounds(rootSize); |
2989 root->setContentBounds(rootSize); | 2989 root->setContentBounds(rootSize); |
2990 root->setDrawsContent(true); | 2990 root->setDrawsContent(true); |
2991 root->setMasksToBounds(true); | 2991 root->setMasksToBounds(true); |
2992 myHostImpl->setRootLayer(root.Pass()); | 2992 myHostImpl->activeTree()->SetRootLayer(root.Pass()); |
2993 | 2993 |
2994 addDrawingLayerTo(rootPtr, 2, gfx::Rect(0, 0, 400, 400), &layerS1Ptr); | 2994 addDrawingLayerTo(rootPtr, 2, gfx::Rect(0, 0, 400, 400), &layerS1Ptr); |
2995 layerS1Ptr->setForceRenderSurface(true); | 2995 layerS1Ptr->setForceRenderSurface(true); |
2996 gfx::Transform transform = layerS1Ptr->transform(); | 2996 gfx::Transform transform = layerS1Ptr->transform(); |
2997 transform.Translate(200, 200); | 2997 transform.Translate(200, 200); |
2998 transform.Rotate(45); | 2998 transform.Rotate(45); |
2999 transform.Translate(-200, -200); | 2999 transform.Translate(-200, -200); |
3000 layerS1Ptr->setTransform(transform); | 3000 layerS1Ptr->setTransform(transform); |
3001 | 3001 |
3002 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(200, 0, 200, 400), 0); // L11 | 3002 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(200, 0, 200, 400), 0); // L11 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3066 | 3066 |
3067 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl->activeTree(), 1); | 3067 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl->activeTree(), 1); |
3068 rootPtr = root.get(); | 3068 rootPtr = root.get(); |
3069 | 3069 |
3070 root->setAnchorPoint(gfx::PointF(0, 0)); | 3070 root->setAnchorPoint(gfx::PointF(0, 0)); |
3071 root->setPosition(gfx::PointF(0, 0)); | 3071 root->setPosition(gfx::PointF(0, 0)); |
3072 root->setBounds(rootSize); | 3072 root->setBounds(rootSize); |
3073 root->setContentBounds(rootSize); | 3073 root->setContentBounds(rootSize); |
3074 root->setDrawsContent(true); | 3074 root->setDrawsContent(true); |
3075 root->setMasksToBounds(true); | 3075 root->setMasksToBounds(true); |
3076 myHostImpl->setRootLayer(root.Pass()); | 3076 myHostImpl->activeTree()->SetRootLayer(root.Pass()); |
3077 | 3077 |
3078 addDrawingLayerTo(rootPtr, 2, gfx::Rect(300, 300, 300, 300), &layerS1Ptr); | 3078 addDrawingLayerTo(rootPtr, 2, gfx::Rect(300, 300, 300, 300), &layerS1Ptr); |
3079 layerS1Ptr->setForceRenderSurface(true); | 3079 layerS1Ptr->setForceRenderSurface(true); |
3080 | 3080 |
3081 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(10, 10, 10, 10), 0); // L11 | 3081 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(10, 10, 10, 10), 0); // L11 |
3082 addDrawingLayerTo(layerS1Ptr, 4, gfx::Rect(0, 0, 30, 30), 0); // L12 | 3082 addDrawingLayerTo(layerS1Ptr, 4, gfx::Rect(0, 0, 30, 30), 0); // L12 |
3083 | 3083 |
3084 addDrawingLayerTo(rootPtr, 5, gfx::Rect(550, 250, 300, 400), &layerS2Ptr); | 3084 addDrawingLayerTo(rootPtr, 5, gfx::Rect(550, 250, 300, 400), &layerS2Ptr); |
3085 layerS2Ptr->setForceRenderSurface(true); | 3085 layerS2Ptr->setForceRenderSurface(true); |
3086 | 3086 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3203 grandChild->setPosition(gfx::Point(grandChildRect.x(), grandChildRect.y())); | 3203 grandChild->setPosition(gfx::Point(grandChildRect.x(), grandChildRect.y())); |
3204 grandChild->setBounds(gfx::Size(grandChildRect.width(), grandChildRect.heigh
t())); | 3204 grandChild->setBounds(gfx::Size(grandChildRect.width(), grandChildRect.heigh
t())); |
3205 grandChild->setContentBounds(grandChild->bounds()); | 3205 grandChild->setContentBounds(grandChild->bounds()); |
3206 grandChild->setDrawsContent(true); | 3206 grandChild->setDrawsContent(true); |
3207 | 3207 |
3208 TiledLayerImpl* childPtr = child.get(); | 3208 TiledLayerImpl* childPtr = child.get(); |
3209 RenderPass::Id childPassId(childPtr->id(), 0); | 3209 RenderPass::Id childPassId(childPtr->id(), 0); |
3210 | 3210 |
3211 child->addChild(grandChild.Pass()); | 3211 child->addChild(grandChild.Pass()); |
3212 root->addChild(child.PassAs<LayerImpl>()); | 3212 root->addChild(child.PassAs<LayerImpl>()); |
3213 myHostImpl->setRootLayer(root.Pass()); | 3213 myHostImpl->activeTree()->SetRootLayer(root.Pass()); |
3214 myHostImpl->setViewportSize(rootRect.size(), rootRect.size()); | 3214 myHostImpl->setViewportSize(rootRect.size(), rootRect.size()); |
3215 | 3215 |
3216 EXPECT_FALSE(myHostImpl->renderer()->haveCachedResourcesForRenderPassId(chil
dPassId)); | 3216 EXPECT_FALSE(myHostImpl->renderer()->haveCachedResourcesForRenderPassId(chil
dPassId)); |
3217 | 3217 |
3218 { | 3218 { |
3219 LayerTreeHostImpl::FrameData frame; | 3219 LayerTreeHostImpl::FrameData frame; |
3220 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 3220 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
3221 myHostImpl->drawLayers(frame); | 3221 myHostImpl->drawLayers(frame); |
3222 myHostImpl->didDrawAllLayers(frame); | 3222 myHostImpl->didDrawAllLayers(frame); |
3223 } | 3223 } |
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3942 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor); | 3942 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor); |
3943 | 3943 |
3944 gfx::Size layoutSurfaceSize(10, 20); | 3944 gfx::Size layoutSurfaceSize(10, 20); |
3945 gfx::Size deviceSurfaceSize(layoutSurfaceSize.width() * static_cast<int>(dev
iceScaleFactor), | 3945 gfx::Size deviceSurfaceSize(layoutSurfaceSize.width() * static_cast<int>(dev
iceScaleFactor), |
3946 layoutSurfaceSize.height() * static_cast<int>(de
viceScaleFactor)); | 3946 layoutSurfaceSize.height() * static_cast<int>(de
viceScaleFactor)); |
3947 float pageScale = 2; | 3947 float pageScale = 2; |
3948 scoped_ptr<LayerImpl> root = createScrollableLayer(1, layoutSurfaceSize); | 3948 scoped_ptr<LayerImpl> root = createScrollableLayer(1, layoutSurfaceSize); |
3949 // For this test we want to force scrolls to only pan the pinchZoomViewport | 3949 // For this test we want to force scrolls to only pan the pinchZoomViewport |
3950 // and not the document, we can verify commit/redraw are requested. | 3950 // and not the document, we can verify commit/redraw are requested. |
3951 root->setMaxScrollOffset(gfx::Vector2d()); | 3951 root->setMaxScrollOffset(gfx::Vector2d()); |
3952 m_hostImpl->setRootLayer(root.Pass()); | 3952 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
3953 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); | 3953 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); |
3954 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); | 3954 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); |
3955 initializeRendererAndDrawFrame(); | 3955 initializeRendererAndDrawFrame(); |
3956 | 3956 |
3957 // Set new page scale on impl thread by pinching. | 3957 // Set new page scale on impl thread by pinching. |
3958 m_hostImpl->pinchGestureBegin(); | 3958 m_hostImpl->pinchGestureBegin(); |
3959 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); | 3959 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); |
3960 m_hostImpl->pinchGestureEnd(); | 3960 m_hostImpl->pinchGestureEnd(); |
3961 drawOneFrame(); | 3961 drawOneFrame(); |
3962 | 3962 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4014 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor); | 4014 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor); |
4015 | 4015 |
4016 gfx::Size layoutSurfaceSize(10, 20); | 4016 gfx::Size layoutSurfaceSize(10, 20); |
4017 gfx::Size deviceSurfaceSize(layoutSurfaceSize.width() * static_cast<int>(dev
iceScaleFactor), | 4017 gfx::Size deviceSurfaceSize(layoutSurfaceSize.width() * static_cast<int>(dev
iceScaleFactor), |
4018 layoutSurfaceSize.height() * static_cast<int>(de
viceScaleFactor)); | 4018 layoutSurfaceSize.height() * static_cast<int>(de
viceScaleFactor)); |
4019 float pageScale = 2; | 4019 float pageScale = 2; |
4020 scoped_ptr<LayerImpl> root = createScrollableLayer(1, layoutSurfaceSize); | 4020 scoped_ptr<LayerImpl> root = createScrollableLayer(1, layoutSurfaceSize); |
4021 // For this test we want to force scrolls to move the pinchZoomViewport so | 4021 // For this test we want to force scrolls to move the pinchZoomViewport so |
4022 // we can see the scroll component on the implTransform. | 4022 // we can see the scroll component on the implTransform. |
4023 root->setMaxScrollOffset(gfx::Vector2d()); | 4023 root->setMaxScrollOffset(gfx::Vector2d()); |
4024 m_hostImpl->setRootLayer(root.Pass()); | 4024 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
4025 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); | 4025 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); |
4026 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); | 4026 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); |
4027 initializeRendererAndDrawFrame(); | 4027 initializeRendererAndDrawFrame(); |
4028 | 4028 |
4029 // Set new page scale on impl thread by pinching. | 4029 // Set new page scale on impl thread by pinching. |
4030 m_hostImpl->pinchGestureBegin(); | 4030 m_hostImpl->pinchGestureBegin(); |
4031 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); | 4031 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); |
4032 m_hostImpl->pinchGestureEnd(); | 4032 m_hostImpl->pinchGestureEnd(); |
4033 drawOneFrame(); | 4033 drawOneFrame(); |
4034 | 4034 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4098 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor); | 4098 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor); |
4099 | 4099 |
4100 gfx::Size layoutSurfaceSize(10, 20); | 4100 gfx::Size layoutSurfaceSize(10, 20); |
4101 gfx::Size deviceSurfaceSize(layoutSurfaceSize.width() * static_cast<int>(dev
iceScaleFactor), | 4101 gfx::Size deviceSurfaceSize(layoutSurfaceSize.width() * static_cast<int>(dev
iceScaleFactor), |
4102 layoutSurfaceSize.height() * static_cast<int>(de
viceScaleFactor)); | 4102 layoutSurfaceSize.height() * static_cast<int>(de
viceScaleFactor)); |
4103 float pageScale = 2; | 4103 float pageScale = 2; |
4104 scoped_ptr<LayerImpl> root = createScrollableLayer(1, layoutSurfaceSize); | 4104 scoped_ptr<LayerImpl> root = createScrollableLayer(1, layoutSurfaceSize); |
4105 // For this test we want to scrolls to move both the document and the | 4105 // For this test we want to scrolls to move both the document and the |
4106 // pinchZoomViewport so we can see some scroll component on the implTransfor
m. | 4106 // pinchZoomViewport so we can see some scroll component on the implTransfor
m. |
4107 root->setMaxScrollOffset(gfx::Vector2d(3, 4)); | 4107 root->setMaxScrollOffset(gfx::Vector2d(3, 4)); |
4108 m_hostImpl->setRootLayer(root.Pass()); | 4108 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
4109 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); | 4109 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); |
4110 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); | 4110 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); |
4111 initializeRendererAndDrawFrame(); | 4111 initializeRendererAndDrawFrame(); |
4112 | 4112 |
4113 // Set new page scale on impl thread by pinching. | 4113 // Set new page scale on impl thread by pinching. |
4114 m_hostImpl->pinchGestureBegin(); | 4114 m_hostImpl->pinchGestureBegin(); |
4115 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); | 4115 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); |
4116 m_hostImpl->pinchGestureEnd(); | 4116 m_hostImpl->pinchGestureEnd(); |
4117 drawOneFrame(); | 4117 drawOneFrame(); |
4118 | 4118 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4221 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor); | 4221 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor); |
4222 | 4222 |
4223 gfx::Size layoutSurfaceSize(10, 20); | 4223 gfx::Size layoutSurfaceSize(10, 20); |
4224 gfx::Size deviceSurfaceSize(layoutSurfaceSize.width() * static_cast<int>(dev
iceScaleFactor), | 4224 gfx::Size deviceSurfaceSize(layoutSurfaceSize.width() * static_cast<int>(dev
iceScaleFactor), |
4225 layoutSurfaceSize.height() * static_cast<int>(de
viceScaleFactor)); | 4225 layoutSurfaceSize.height() * static_cast<int>(de
viceScaleFactor)); |
4226 float pageScale = 2; | 4226 float pageScale = 2; |
4227 scoped_ptr<LayerImpl> root = createScrollableLayer(1, layoutSurfaceSize); | 4227 scoped_ptr<LayerImpl> root = createScrollableLayer(1, layoutSurfaceSize); |
4228 // For this test we want to scrolls to move both the document and the | 4228 // For this test we want to scrolls to move both the document and the |
4229 // pinchZoomViewport so we can see some scroll component on the implTransfor
m. | 4229 // pinchZoomViewport so we can see some scroll component on the implTransfor
m. |
4230 root->setMaxScrollOffset(gfx::Vector2d(3, 4)); | 4230 root->setMaxScrollOffset(gfx::Vector2d(3, 4)); |
4231 m_hostImpl->setRootLayer(root.Pass()); | 4231 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
4232 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); | 4232 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); |
4233 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); | 4233 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); |
4234 initializeRendererAndDrawFrame(); | 4234 initializeRendererAndDrawFrame(); |
4235 | 4235 |
4236 // Set new page scale on impl thread by pinching. | 4236 // Set new page scale on impl thread by pinching. |
4237 m_hostImpl->pinchGestureBegin(); | 4237 m_hostImpl->pinchGestureBegin(); |
4238 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); | 4238 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); |
4239 m_hostImpl->pinchGestureEnd(); | 4239 m_hostImpl->pinchGestureEnd(); |
4240 drawOneFrame(); | 4240 drawOneFrame(); |
4241 | 4241 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4340 gfx::Rect noDamage = gfx::Rect(m_hostImpl->deviceViewportSize()); | 4340 gfx::Rect noDamage = gfx::Rect(m_hostImpl->deviceViewportSize()); |
4341 drawFrameAndTestDamage(noDamage); | 4341 drawFrameAndTestDamage(noDamage); |
4342 } | 4342 } |
4343 | 4343 |
4344 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, | 4344 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, |
4345 LayerTreeHostImplTest, | 4345 LayerTreeHostImplTest, |
4346 ::testing::Values(false, true)); | 4346 ::testing::Values(false, true)); |
4347 | 4347 |
4348 } // namespace | 4348 } // namespace |
4349 } // namespace cc | 4349 } // namespace cc |
OLD | NEW |