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

Side by Side Diff: cc/layer_tree_host_impl_unittest.cc

Issue 11704003: cc: Move more functionality from host to LayerTreeImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 } 116 }
117 117
118 void setupRootLayerImpl(scoped_ptr<LayerImpl> root) 118 void setupRootLayerImpl(scoped_ptr<LayerImpl> root)
119 { 119 {
120 root->setAnchorPoint(gfx::PointF(0, 0)); 120 root->setAnchorPoint(gfx::PointF(0, 0));
121 root->setPosition(gfx::PointF(0, 0)); 121 root->setPosition(gfx::PointF(0, 0));
122 root->setBounds(gfx::Size(10, 10)); 122 root->setBounds(gfx::Size(10, 10));
123 root->setContentBounds(gfx::Size(10, 10)); 123 root->setContentBounds(gfx::Size(10, 10));
124 root->setDrawsContent(true); 124 root->setDrawsContent(true);
125 root->drawProperties().visible_content_rect = gfx::Rect(0, 0, 10, 10); 125 root->drawProperties().visible_content_rect = gfx::Rect(0, 0, 10, 10);
126 m_hostImpl->setRootLayer(root.Pass()); 126 m_hostImpl->activeTree()->SetRootLayer(root.Pass());
127 } 127 }
128 128
129 static void expectClearedScrollDeltasRecursive(LayerImpl* layer) 129 static void expectClearedScrollDeltasRecursive(LayerImpl* layer)
130 { 130 {
131 ASSERT_EQ(layer->scrollDelta(), gfx::Vector2d()); 131 ASSERT_EQ(layer->scrollDelta(), gfx::Vector2d());
132 for (size_t i = 0; i < layer->children().size(); ++i) 132 for (size_t i = 0; i < layer->children().size(); ++i)
133 expectClearedScrollDeltasRecursive(layer->children()[i]); 133 expectClearedScrollDeltasRecursive(layer->children()[i]);
134 } 134 }
135 135
136 static void expectContains(const ScrollAndScaleSet& scrollInfo, int id, cons t gfx::Vector2d& scrollDelta) 136 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
171 root->setPosition(gfx::PointF(0, 0)); 171 root->setPosition(gfx::PointF(0, 0));
172 root->setAnchorPoint(gfx::PointF(0, 0)); 172 root->setAnchorPoint(gfx::PointF(0, 0));
173 173
174 scoped_ptr<LayerImpl> contents = LayerImpl::create(m_hostImpl->activeTre e(), 2); 174 scoped_ptr<LayerImpl> contents = LayerImpl::create(m_hostImpl->activeTre e(), 2);
175 contents->setDrawsContent(true); 175 contents->setDrawsContent(true);
176 contents->setBounds(contentSize); 176 contents->setBounds(contentSize);
177 contents->setContentBounds(contentSize); 177 contents->setContentBounds(contentSize);
178 contents->setPosition(gfx::PointF(0, 0)); 178 contents->setPosition(gfx::PointF(0, 0));
179 contents->setAnchorPoint(gfx::PointF(0, 0)); 179 contents->setAnchorPoint(gfx::PointF(0, 0));
180 root->addChild(contents.Pass()); 180 root->addChild(contents.Pass());
181 m_hostImpl->setRootLayer(root.Pass()); 181 m_hostImpl->activeTree()->SetRootLayer(root.Pass());
182 } 182 }
183 183
184 scoped_ptr<LayerImpl> createScrollableLayer(int id, const gfx::Size& size) 184 scoped_ptr<LayerImpl> createScrollableLayer(int id, const gfx::Size& size)
185 { 185 {
186 scoped_ptr<LayerImpl> layer = LayerImpl::create(m_hostImpl->activeTree() , id); 186 scoped_ptr<LayerImpl> layer = LayerImpl::create(m_hostImpl->activeTree() , id);
187 layer->setScrollable(true); 187 layer->setScrollable(true);
188 layer->setDrawsContent(true); 188 layer->setDrawsContent(true);
189 layer->setBounds(size); 189 layer->setBounds(size);
190 layer->setContentBounds(size); 190 layer->setContentBounds(size);
191 layer->setMaxScrollOffset(gfx::Vector2d(size.width() * 2, size.height() * 2)); 191 layer->setMaxScrollOffset(gfx::Vector2d(size.width() * 2, size.height() * 2));
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 // that canDraw changed. 239 // that canDraw changed.
240 EXPECT_FALSE(m_hostImpl->canDraw()); 240 EXPECT_FALSE(m_hostImpl->canDraw());
241 m_onCanDrawStateChangedCalled = false; 241 m_onCanDrawStateChangedCalled = false;
242 242
243 setupScrollAndContentsLayers(gfx::Size(100, 100)); 243 setupScrollAndContentsLayers(gfx::Size(100, 100));
244 EXPECT_TRUE(m_hostImpl->canDraw()); 244 EXPECT_TRUE(m_hostImpl->canDraw());
245 EXPECT_TRUE(m_onCanDrawStateChangedCalled); 245 EXPECT_TRUE(m_onCanDrawStateChangedCalled);
246 m_onCanDrawStateChangedCalled = false; 246 m_onCanDrawStateChangedCalled = false;
247 247
248 // Toggle the root layer to make sure it toggles canDraw 248 // Toggle the root layer to make sure it toggles canDraw
249 m_hostImpl->setRootLayer(scoped_ptr<LayerImpl>()); 249 m_hostImpl->activeTree()->SetRootLayer(scoped_ptr<LayerImpl>());
250 EXPECT_FALSE(m_hostImpl->canDraw()); 250 EXPECT_FALSE(m_hostImpl->canDraw());
251 EXPECT_TRUE(m_onCanDrawStateChangedCalled); 251 EXPECT_TRUE(m_onCanDrawStateChangedCalled);
252 m_onCanDrawStateChangedCalled = false; 252 m_onCanDrawStateChangedCalled = false;
253 253
254 setupScrollAndContentsLayers(gfx::Size(100, 100)); 254 setupScrollAndContentsLayers(gfx::Size(100, 100));
255 EXPECT_TRUE(m_hostImpl->canDraw()); 255 EXPECT_TRUE(m_hostImpl->canDraw());
256 EXPECT_TRUE(m_onCanDrawStateChangedCalled); 256 EXPECT_TRUE(m_onCanDrawStateChangedCalled);
257 m_onCanDrawStateChangedCalled = false; 257 m_onCanDrawStateChangedCalled = false;
258 258
259 // Toggle the device viewport size to make sure it toggles canDraw. 259 // Toggle the device viewport size to make sure it toggles canDraw.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 300
301 TEST_P(LayerTreeHostImplTest, scrollDeltaTreeButNoChanges) 301 TEST_P(LayerTreeHostImplTest, scrollDeltaTreeButNoChanges)
302 { 302 {
303 { 303 {
304 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1); 304 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1);
305 root->addChild(LayerImpl::create(m_hostImpl->activeTree(), 2)); 305 root->addChild(LayerImpl::create(m_hostImpl->activeTree(), 2));
306 root->addChild(LayerImpl::create(m_hostImpl->activeTree(), 3)); 306 root->addChild(LayerImpl::create(m_hostImpl->activeTree(), 3));
307 root->children()[1]->addChild(LayerImpl::create(m_hostImpl->activeTree() , 4)); 307 root->children()[1]->addChild(LayerImpl::create(m_hostImpl->activeTree() , 4));
308 root->children()[1]->addChild(LayerImpl::create(m_hostImpl->activeTree() , 5)); 308 root->children()[1]->addChild(LayerImpl::create(m_hostImpl->activeTree() , 5));
309 root->children()[1]->children()[0]->addChild(LayerImpl::create(m_hostImp l->activeTree(), 6)); 309 root->children()[1]->children()[0]->addChild(LayerImpl::create(m_hostImp l->activeTree(), 6));
310 m_hostImpl->setRootLayer(root.Pass()); 310 m_hostImpl->activeTree()->SetRootLayer(root.Pass());
311 } 311 }
312 LayerImpl* root = m_hostImpl->rootLayer(); 312 LayerImpl* root = m_hostImpl->rootLayer();
313 313
314 expectClearedScrollDeltasRecursive(root); 314 expectClearedScrollDeltasRecursive(root);
315 315
316 scoped_ptr<ScrollAndScaleSet> scrollInfo; 316 scoped_ptr<ScrollAndScaleSet> scrollInfo;
317 317
318 scrollInfo = m_hostImpl->processScrollDeltas(); 318 scrollInfo = m_hostImpl->processScrollDeltas();
319 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); 319 ASSERT_EQ(scrollInfo->scrolls.size(), 0u);
320 expectClearedScrollDeltasRecursive(root); 320 expectClearedScrollDeltasRecursive(root);
321 321
322 scrollInfo = m_hostImpl->processScrollDeltas(); 322 scrollInfo = m_hostImpl->processScrollDeltas();
323 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); 323 ASSERT_EQ(scrollInfo->scrolls.size(), 0u);
324 expectClearedScrollDeltasRecursive(root); 324 expectClearedScrollDeltasRecursive(root);
325 } 325 }
326 326
327 TEST_P(LayerTreeHostImplTest, scrollDeltaRepeatedScrolls) 327 TEST_P(LayerTreeHostImplTest, scrollDeltaRepeatedScrolls)
328 { 328 {
329 gfx::Vector2d scrollOffset(20, 30); 329 gfx::Vector2d scrollOffset(20, 30);
330 gfx::Vector2d scrollDelta(11, -15); 330 gfx::Vector2d scrollDelta(11, -15);
331 { 331 {
332 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1); 332 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1);
333 root->setScrollOffset(scrollOffset); 333 root->setScrollOffset(scrollOffset);
334 root->setScrollable(true); 334 root->setScrollable(true);
335 root->setMaxScrollOffset(gfx::Vector2d(100, 100)); 335 root->setMaxScrollOffset(gfx::Vector2d(100, 100));
336 root->scrollBy(scrollDelta); 336 root->scrollBy(scrollDelta);
337 m_hostImpl->setRootLayer(root.Pass()); 337 m_hostImpl->activeTree()->SetRootLayer(root.Pass());
338 } 338 }
339 LayerImpl* root = m_hostImpl->rootLayer(); 339 LayerImpl* root = m_hostImpl->rootLayer();
340 340
341 scoped_ptr<ScrollAndScaleSet> scrollInfo; 341 scoped_ptr<ScrollAndScaleSet> scrollInfo;
342 342
343 scrollInfo = m_hostImpl->processScrollDeltas(); 343 scrollInfo = m_hostImpl->processScrollDeltas();
344 ASSERT_EQ(scrollInfo->scrolls.size(), 1u); 344 ASSERT_EQ(scrollInfo->scrolls.size(), 1u);
345 EXPECT_VECTOR_EQ(root->sentScrollDelta(), scrollDelta); 345 EXPECT_VECTOR_EQ(root->sentScrollDelta(), scrollDelta);
346 expectContains(*scrollInfo, root->id(), scrollDelta); 346 expectContains(*scrollInfo, root->id(), scrollDelta);
347 347
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 TEST_P(LayerTreeHostImplTest, replaceTreeWhileScrolling) 394 TEST_P(LayerTreeHostImplTest, replaceTreeWhileScrolling)
395 { 395 {
396 const int scrollLayerId = 1; 396 const int scrollLayerId = 1;
397 397
398 setupScrollAndContentsLayers(gfx::Size(100, 100)); 398 setupScrollAndContentsLayers(gfx::Size(100, 100));
399 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); 399 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50));
400 initializeRendererAndDrawFrame(); 400 initializeRendererAndDrawFrame();
401 401
402 // We should not crash if the tree is replaced while we are scrolling. 402 // We should not crash if the tree is replaced while we are scrolling.
403 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted); 403 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
404 m_hostImpl->detachLayerTree(); 404 m_hostImpl->activeTree()->DetachLayerTree();
405 405
406 setupScrollAndContentsLayers(gfx::Size(100, 100)); 406 setupScrollAndContentsLayers(gfx::Size(100, 100));
407 407
408 // We should still be scrolling, because the scrolled layer also exists in t he new tree. 408 // We should still be scrolling, because the scrolled layer also exists in t he new tree.
409 gfx::Vector2d scrollDelta(0, 10); 409 gfx::Vector2d scrollDelta(0, 10);
410 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 410 m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
411 m_hostImpl->scrollEnd(); 411 m_hostImpl->scrollEnd();
412 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; 412 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ;
413 expectContains(*scrollInfo, scrollLayerId, scrollDelta); 413 expectContains(*scrollInfo, scrollLayerId, scrollDelta);
414 } 414 }
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 927
928 private: 928 private:
929 bool m_didDrawCalled; 929 bool m_didDrawCalled;
930 bool m_willDrawCalled; 930 bool m_willDrawCalled;
931 }; 931 };
932 932
933 TEST_P(LayerTreeHostImplTest, didDrawNotCalledOnHiddenLayer) 933 TEST_P(LayerTreeHostImplTest, didDrawNotCalledOnHiddenLayer)
934 { 934 {
935 // The root layer is always drawn, so run this test on a child layer that 935 // The root layer is always drawn, so run this test on a child layer that
936 // will be masked out by the root layer's bounds. 936 // will be masked out by the root layer's bounds.
937 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(m_hostImpl->activeTree(), 1)); 937 m_hostImpl->activeTree()->SetRootLayer(DidDrawCheckLayer::create(m_hostImpl- >activeTree(), 1));
938 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa yer()); 938 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa yer());
939 root->setMasksToBounds(true); 939 root->setMasksToBounds(true);
940 940
941 root->addChild(DidDrawCheckLayer::create(m_hostImpl->activeTree(), 2)); 941 root->addChild(DidDrawCheckLayer::create(m_hostImpl->activeTree(), 2));
942 DidDrawCheckLayer* layer = static_cast<DidDrawCheckLayer*>(root->children()[ 0]); 942 DidDrawCheckLayer* layer = static_cast<DidDrawCheckLayer*>(root->children()[ 0]);
943 // Ensure visibleContentRect for layer is empty 943 // Ensure visibleContentRect for layer is empty
944 layer->setPosition(gfx::PointF(100, 100)); 944 layer->setPosition(gfx::PointF(100, 100));
945 layer->setBounds(gfx::Size(10, 10)); 945 layer->setBounds(gfx::Size(10, 10));
946 layer->setContentBounds(gfx::Size(10, 10)); 946 layer->setContentBounds(gfx::Size(10, 10));
947 947
(...skipping 25 matching lines...) Expand all
973 EXPECT_TRUE(layer->didDrawCalled()); 973 EXPECT_TRUE(layer->didDrawCalled());
974 974
975 EXPECT_FALSE(layer->visibleContentRect().IsEmpty()); 975 EXPECT_FALSE(layer->visibleContentRect().IsEmpty());
976 } 976 }
977 977
978 TEST_P(LayerTreeHostImplTest, willDrawNotCalledOnOccludedLayer) 978 TEST_P(LayerTreeHostImplTest, willDrawNotCalledOnOccludedLayer)
979 { 979 {
980 gfx::Size bigSize(1000, 1000); 980 gfx::Size bigSize(1000, 1000);
981 m_hostImpl->setViewportSize(bigSize, bigSize); 981 m_hostImpl->setViewportSize(bigSize, bigSize);
982 982
983 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(m_hostImpl->activeTree(), 1)); 983 m_hostImpl->activeTree()->SetRootLayer(DidDrawCheckLayer::create(m_hostImpl- >activeTree(), 1));
984 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa yer()); 984 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa yer());
985 985
986 root->addChild(DidDrawCheckLayer::create(m_hostImpl->activeTree(), 2)); 986 root->addChild(DidDrawCheckLayer::create(m_hostImpl->activeTree(), 2));
987 DidDrawCheckLayer* occludedLayer = static_cast<DidDrawCheckLayer*>(root->chi ldren()[0]); 987 DidDrawCheckLayer* occludedLayer = static_cast<DidDrawCheckLayer*>(root->chi ldren()[0]);
988 988
989 root->addChild(DidDrawCheckLayer::create(m_hostImpl->activeTree(), 3)); 989 root->addChild(DidDrawCheckLayer::create(m_hostImpl->activeTree(), 3));
990 DidDrawCheckLayer* topLayer = static_cast<DidDrawCheckLayer*>(root->children ()[1]); 990 DidDrawCheckLayer* topLayer = static_cast<DidDrawCheckLayer*>(root->children ()[1]);
991 // This layer covers the occludedLayer above. Make this layer large so it ca n occlude. 991 // This layer covers the occludedLayer above. Make this layer large so it ca n occlude.
992 topLayer->setBounds(bigSize); 992 topLayer->setBounds(bigSize);
993 topLayer->setContentBounds(bigSize); 993 topLayer->setContentBounds(bigSize);
(...skipping 11 matching lines...) Expand all
1005 m_hostImpl->didDrawAllLayers(frame); 1005 m_hostImpl->didDrawAllLayers(frame);
1006 1006
1007 EXPECT_FALSE(occludedLayer->willDrawCalled()); 1007 EXPECT_FALSE(occludedLayer->willDrawCalled());
1008 EXPECT_FALSE(occludedLayer->didDrawCalled()); 1008 EXPECT_FALSE(occludedLayer->didDrawCalled());
1009 EXPECT_TRUE(topLayer->willDrawCalled()); 1009 EXPECT_TRUE(topLayer->willDrawCalled());
1010 EXPECT_TRUE(topLayer->didDrawCalled()); 1010 EXPECT_TRUE(topLayer->didDrawCalled());
1011 } 1011 }
1012 1012
1013 TEST_P(LayerTreeHostImplTest, didDrawCalledOnAllLayers) 1013 TEST_P(LayerTreeHostImplTest, didDrawCalledOnAllLayers)
1014 { 1014 {
1015 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(m_hostImpl->activeTree(), 1)); 1015 m_hostImpl->activeTree()->SetRootLayer(DidDrawCheckLayer::create(m_hostImpl- >activeTree(), 1));
1016 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa yer()); 1016 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa yer());
1017 1017
1018 root->addChild(DidDrawCheckLayer::create(m_hostImpl->activeTree(), 2)); 1018 root->addChild(DidDrawCheckLayer::create(m_hostImpl->activeTree(), 2));
1019 DidDrawCheckLayer* layer1 = static_cast<DidDrawCheckLayer*>(root->children() [0]); 1019 DidDrawCheckLayer* layer1 = static_cast<DidDrawCheckLayer*>(root->children() [0]);
1020 1020
1021 layer1->addChild(DidDrawCheckLayer::create(m_hostImpl->activeTree(), 3)); 1021 layer1->addChild(DidDrawCheckLayer::create(m_hostImpl->activeTree(), 3));
1022 DidDrawCheckLayer* layer2 = static_cast<DidDrawCheckLayer*>(layer1->children ()[0]); 1022 DidDrawCheckLayer* layer2 = static_cast<DidDrawCheckLayer*>(layer1->children ()[0]);
1023 1023
1024 layer1->setOpacity(0.3f); 1024 layer1->setOpacity(0.3f);
1025 layer1->setPreserves3D(false); 1025 layer1->setPreserves3D(false);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 pushTileProperties(0, 0, resource, gfx::Rect(), false); 1061 pushTileProperties(0, 0, resource, gfx::Rect(), false);
1062 } 1062 }
1063 if (animating) 1063 if (animating)
1064 addAnimatedTransformToLayer(*this, 10, 3, 0); 1064 addAnimatedTransformToLayer(*this, 10, 3, 0);
1065 } 1065 }
1066 }; 1066 };
1067 1067
1068 TEST_P(LayerTreeHostImplTest, prepareToDrawFailsWhenAnimationUsesCheckerboard) 1068 TEST_P(LayerTreeHostImplTest, prepareToDrawFailsWhenAnimationUsesCheckerboard)
1069 { 1069 {
1070 // When the texture is not missing, we draw as usual. 1070 // When the texture is not missing, we draw as usual.
1071 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(m_hostImpl->activeTree(), 1)); 1071 m_hostImpl->activeTree()->SetRootLayer(DidDrawCheckLayer::create(m_hostImpl- >activeTree(), 1));
1072 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa yer()); 1072 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLa yer());
1073 root->addChild(MissingTextureAnimatingLayer::create(m_hostImpl->activeTree() , 2, false, false, true, m_hostImpl->resourceProvider())); 1073 root->addChild(MissingTextureAnimatingLayer::create(m_hostImpl->activeTree() , 2, false, false, true, m_hostImpl->resourceProvider()));
1074 1074
1075 LayerTreeHostImpl::FrameData frame; 1075 LayerTreeHostImpl::FrameData frame;
1076 1076
1077 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 1077 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
1078 m_hostImpl->drawLayers(frame); 1078 m_hostImpl->drawLayers(frame);
1079 m_hostImpl->didDrawAllLayers(frame); 1079 m_hostImpl->didDrawAllLayers(frame);
1080 1080
1081 // When a texture is missing and we're not animating, we draw as usual with checkerboarding. 1081 // When a texture is missing and we're not animating, we draw as usual with checkerboarding.
1082 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(m_hostImpl->activeTree(), 3)); 1082 m_hostImpl->activeTree()->SetRootLayer(DidDrawCheckLayer::create(m_hostImpl- >activeTree(), 3));
1083 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); 1083 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer());
1084 root->addChild(MissingTextureAnimatingLayer::create(m_hostImpl->activeTree() , 4, true, false, false, m_hostImpl->resourceProvider())); 1084 root->addChild(MissingTextureAnimatingLayer::create(m_hostImpl->activeTree() , 4, true, false, false, m_hostImpl->resourceProvider()));
1085 1085
1086 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 1086 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
1087 m_hostImpl->drawLayers(frame); 1087 m_hostImpl->drawLayers(frame);
1088 m_hostImpl->didDrawAllLayers(frame); 1088 m_hostImpl->didDrawAllLayers(frame);
1089 1089
1090 // When a texture is missing and we're animating, we don't want to draw anyt hing. 1090 // When a texture is missing and we're animating, we don't want to draw anyt hing.
1091 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(m_hostImpl->activeTree(), 5)); 1091 m_hostImpl->activeTree()->SetRootLayer(DidDrawCheckLayer::create(m_hostImpl- >activeTree(), 5));
1092 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); 1092 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer());
1093 root->addChild(MissingTextureAnimatingLayer::create(m_hostImpl->activeTree() , 6, true, false, true, m_hostImpl->resourceProvider())); 1093 root->addChild(MissingTextureAnimatingLayer::create(m_hostImpl->activeTree() , 6, true, false, true, m_hostImpl->resourceProvider()));
1094 1094
1095 EXPECT_FALSE(m_hostImpl->prepareToDraw(frame)); 1095 EXPECT_FALSE(m_hostImpl->prepareToDraw(frame));
1096 m_hostImpl->drawLayers(frame); 1096 m_hostImpl->drawLayers(frame);
1097 m_hostImpl->didDrawAllLayers(frame); 1097 m_hostImpl->didDrawAllLayers(frame);
1098 1098
1099 // When the layer skips draw and we're animating, we still draw the frame. 1099 // When the layer skips draw and we're animating, we still draw the frame.
1100 m_hostImpl->setRootLayer(DidDrawCheckLayer::create(m_hostImpl->activeTree(), 7)); 1100 m_hostImpl->activeTree()->SetRootLayer(DidDrawCheckLayer::create(m_hostImpl- >activeTree(), 7));
1101 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer()); 1101 root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer());
1102 root->addChild(MissingTextureAnimatingLayer::create(m_hostImpl->activeTree() , 8, false, true, true, m_hostImpl->resourceProvider())); 1102 root->addChild(MissingTextureAnimatingLayer::create(m_hostImpl->activeTree() , 8, false, true, true, m_hostImpl->resourceProvider()));
1103 1103
1104 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 1104 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
1105 m_hostImpl->drawLayers(frame); 1105 m_hostImpl->drawLayers(frame);
1106 m_hostImpl->didDrawAllLayers(frame); 1106 m_hostImpl->didDrawAllLayers(frame);
1107 } 1107 }
1108 1108
1109 TEST_P(LayerTreeHostImplTest, scrollRootIgnored) 1109 TEST_P(LayerTreeHostImplTest, scrollRootIgnored)
1110 { 1110 {
1111 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1); 1111 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1);
1112 root->setScrollable(false); 1112 root->setScrollable(false);
1113 m_hostImpl->setRootLayer(root.Pass()); 1113 m_hostImpl->activeTree()->SetRootLayer(root.Pass());
1114 initializeRendererAndDrawFrame(); 1114 initializeRendererAndDrawFrame();
1115 1115
1116 // Scroll event is ignored because layer is not scrollable. 1116 // Scroll event is ignored because layer is not scrollable.
1117 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee l), InputHandlerClient::ScrollIgnored); 1117 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee l), InputHandlerClient::ScrollIgnored);
1118 EXPECT_FALSE(m_didRequestRedraw); 1118 EXPECT_FALSE(m_didRequestRedraw);
1119 EXPECT_FALSE(m_didRequestCommit); 1119 EXPECT_FALSE(m_didRequestCommit);
1120 } 1120 }
1121 1121
1122 TEST_P(LayerTreeHostImplTest, scrollNonCompositedRoot) 1122 TEST_P(LayerTreeHostImplTest, scrollNonCompositedRoot)
1123 { 1123 {
(...skipping 11 matching lines...) Expand all
1135 1135
1136 scoped_ptr<LayerImpl> scrollLayer = LayerImpl::create(m_hostImpl->activeTree (), 2); 1136 scoped_ptr<LayerImpl> scrollLayer = LayerImpl::create(m_hostImpl->activeTree (), 2);
1137 scrollLayer->setScrollable(true); 1137 scrollLayer->setScrollable(true);
1138 scrollLayer->setMaxScrollOffset(gfx::Vector2d(surfaceSize.width(), surfaceSi ze.height())); 1138 scrollLayer->setMaxScrollOffset(gfx::Vector2d(surfaceSize.width(), surfaceSi ze.height()));
1139 scrollLayer->setBounds(surfaceSize); 1139 scrollLayer->setBounds(surfaceSize);
1140 scrollLayer->setContentBounds(surfaceSize); 1140 scrollLayer->setContentBounds(surfaceSize);
1141 scrollLayer->setPosition(gfx::PointF(0, 0)); 1141 scrollLayer->setPosition(gfx::PointF(0, 0));
1142 scrollLayer->setAnchorPoint(gfx::PointF(0, 0)); 1142 scrollLayer->setAnchorPoint(gfx::PointF(0, 0));
1143 scrollLayer->addChild(contentLayer.Pass()); 1143 scrollLayer->addChild(contentLayer.Pass());
1144 1144
1145 m_hostImpl->setRootLayer(scrollLayer.Pass()); 1145 m_hostImpl->activeTree()->SetRootLayer(scrollLayer.Pass());
1146 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1146 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1147 initializeRendererAndDrawFrame(); 1147 initializeRendererAndDrawFrame();
1148 1148
1149 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted); 1149 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
1150 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10)); 1150 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10));
1151 m_hostImpl->scrollEnd(); 1151 m_hostImpl->scrollEnd();
1152 EXPECT_TRUE(m_didRequestRedraw); 1152 EXPECT_TRUE(m_didRequestRedraw);
1153 EXPECT_TRUE(m_didRequestCommit); 1153 EXPECT_TRUE(m_didRequestCommit);
1154 } 1154 }
1155 1155
1156 TEST_P(LayerTreeHostImplTest, scrollChildCallsCommitAndRedraw) 1156 TEST_P(LayerTreeHostImplTest, scrollChildCallsCommitAndRedraw)
1157 { 1157 {
1158 gfx::Size surfaceSize(10, 10); 1158 gfx::Size surfaceSize(10, 10);
1159 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1); 1159 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1);
1160 root->setBounds(surfaceSize); 1160 root->setBounds(surfaceSize);
1161 root->setContentBounds(surfaceSize); 1161 root->setContentBounds(surfaceSize);
1162 root->addChild(createScrollableLayer(2, surfaceSize)); 1162 root->addChild(createScrollableLayer(2, surfaceSize));
1163 m_hostImpl->setRootLayer(root.Pass()); 1163 m_hostImpl->activeTree()->SetRootLayer(root.Pass());
1164 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1164 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1165 initializeRendererAndDrawFrame(); 1165 initializeRendererAndDrawFrame();
1166 1166
1167 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted); 1167 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
1168 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10)); 1168 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10));
1169 m_hostImpl->scrollEnd(); 1169 m_hostImpl->scrollEnd();
1170 EXPECT_TRUE(m_didRequestRedraw); 1170 EXPECT_TRUE(m_didRequestRedraw);
1171 EXPECT_TRUE(m_didRequestCommit); 1171 EXPECT_TRUE(m_didRequestCommit);
1172 } 1172 }
1173 1173
1174 TEST_P(LayerTreeHostImplTest, scrollMissesChild) 1174 TEST_P(LayerTreeHostImplTest, scrollMissesChild)
1175 { 1175 {
1176 gfx::Size surfaceSize(10, 10); 1176 gfx::Size surfaceSize(10, 10);
1177 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1); 1177 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1);
1178 root->addChild(createScrollableLayer(2, surfaceSize)); 1178 root->addChild(createScrollableLayer(2, surfaceSize));
1179 m_hostImpl->setRootLayer(root.Pass()); 1179 m_hostImpl->activeTree()->SetRootLayer(root.Pass());
1180 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1180 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1181 initializeRendererAndDrawFrame(); 1181 initializeRendererAndDrawFrame();
1182 1182
1183 // Scroll event is ignored because the input coordinate is outside the layer boundaries. 1183 // Scroll event is ignored because the input coordinate is outside the layer boundaries.
1184 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(15, 5), InputHandlerClient::Whe el), InputHandlerClient::ScrollIgnored); 1184 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(15, 5), InputHandlerClient::Whe el), InputHandlerClient::ScrollIgnored);
1185 EXPECT_FALSE(m_didRequestRedraw); 1185 EXPECT_FALSE(m_didRequestRedraw);
1186 EXPECT_FALSE(m_didRequestCommit); 1186 EXPECT_FALSE(m_didRequestCommit);
1187 } 1187 }
1188 1188
1189 TEST_P(LayerTreeHostImplTest, scrollMissesBackfacingChild) 1189 TEST_P(LayerTreeHostImplTest, scrollMissesBackfacingChild)
1190 { 1190 {
1191 gfx::Size surfaceSize(10, 10); 1191 gfx::Size surfaceSize(10, 10);
1192 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1); 1192 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1);
1193 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize); 1193 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize);
1194 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1194 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1195 1195
1196 gfx::Transform matrix; 1196 gfx::Transform matrix;
1197 MathUtil::rotateEulerAngles(&matrix, 180, 0, 0); 1197 MathUtil::rotateEulerAngles(&matrix, 180, 0, 0);
1198 child->setTransform(matrix); 1198 child->setTransform(matrix);
1199 child->setDoubleSided(false); 1199 child->setDoubleSided(false);
1200 1200
1201 root->addChild(child.Pass()); 1201 root->addChild(child.Pass());
1202 m_hostImpl->setRootLayer(root.Pass()); 1202 m_hostImpl->activeTree()->SetRootLayer(root.Pass());
1203 initializeRendererAndDrawFrame(); 1203 initializeRendererAndDrawFrame();
1204 1204
1205 // Scroll event is ignored because the scrollable layer is not facing the vi ewer and there is 1205 // Scroll event is ignored because the scrollable layer is not facing the vi ewer and there is
1206 // nothing scrollable behind it. 1206 // nothing scrollable behind it.
1207 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollIgnored); 1207 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollIgnored);
1208 EXPECT_FALSE(m_didRequestRedraw); 1208 EXPECT_FALSE(m_didRequestRedraw);
1209 EXPECT_FALSE(m_didRequestCommit); 1209 EXPECT_FALSE(m_didRequestCommit);
1210 } 1210 }
1211 1211
1212 TEST_P(LayerTreeHostImplTest, scrollBlockedByContentLayer) 1212 TEST_P(LayerTreeHostImplTest, scrollBlockedByContentLayer)
1213 { 1213 {
1214 gfx::Size surfaceSize(10, 10); 1214 gfx::Size surfaceSize(10, 10);
1215 scoped_ptr<LayerImpl> contentLayer = createScrollableLayer(1, surfaceSize); 1215 scoped_ptr<LayerImpl> contentLayer = createScrollableLayer(1, surfaceSize);
1216 contentLayer->setShouldScrollOnMainThread(true); 1216 contentLayer->setShouldScrollOnMainThread(true);
1217 contentLayer->setScrollable(false); 1217 contentLayer->setScrollable(false);
1218 1218
1219 scoped_ptr<LayerImpl> scrollLayer = createScrollableLayer(2, surfaceSize); 1219 scoped_ptr<LayerImpl> scrollLayer = createScrollableLayer(2, surfaceSize);
1220 scrollLayer->addChild(contentLayer.Pass()); 1220 scrollLayer->addChild(contentLayer.Pass());
1221 1221
1222 m_hostImpl->setRootLayer(scrollLayer.Pass()); 1222 m_hostImpl->activeTree()->SetRootLayer(scrollLayer.Pass());
1223 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1223 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1224 initializeRendererAndDrawFrame(); 1224 initializeRendererAndDrawFrame();
1225 1225
1226 // Scrolling fails because the content layer is asking to be scrolled on the main thread. 1226 // Scrolling fails because the content layer is asking to be scrolled on the main thread.
1227 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollOnMainThread); 1227 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollOnMainThread);
1228 } 1228 }
1229 1229
1230 TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnMainThread) 1230 TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnMainThread)
1231 { 1231 {
1232 gfx::Size surfaceSize(10, 10); 1232 gfx::Size surfaceSize(10, 10);
1233 float pageScale = 2; 1233 float pageScale = 2;
1234 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); 1234 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize);
1235 m_hostImpl->setRootLayer(root.Pass()); 1235 m_hostImpl->activeTree()->SetRootLayer(root.Pass());
1236 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1236 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1237 initializeRendererAndDrawFrame(); 1237 initializeRendererAndDrawFrame();
1238 1238
1239 gfx::Vector2d scrollDelta(0, 10); 1239 gfx::Vector2d scrollDelta(0, 10);
1240 gfx::Vector2d expectedScrollDelta(scrollDelta); 1240 gfx::Vector2d expectedScrollDelta(scrollDelta);
1241 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); 1241 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset());
1242 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted); 1242 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
1243 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 1243 m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
1244 m_hostImpl->scrollEnd(); 1244 m_hostImpl->scrollEnd();
1245 1245
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1277 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(3 , 1)); 1277 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(3 , 1));
1278 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(3 , 2)); 1278 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(3 , 2));
1279 EXPECT_EQ(1.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(3 , 3)); 1279 EXPECT_EQ(1.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(3 , 3));
1280 } 1280 }
1281 1281
1282 TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread) 1282 TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread)
1283 { 1283 {
1284 gfx::Size surfaceSize(10, 10); 1284 gfx::Size surfaceSize(10, 10);
1285 float pageScale = 2; 1285 float pageScale = 2;
1286 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); 1286 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize);
1287 m_hostImpl->setRootLayer(root.Pass()); 1287 m_hostImpl->activeTree()->SetRootLayer(root.Pass());
1288 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1288 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1289 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); 1289 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
1290 initializeRendererAndDrawFrame(); 1290 initializeRendererAndDrawFrame();
1291 1291
1292 gfx::Vector2d scrollDelta(0, 10); 1292 gfx::Vector2d scrollDelta(0, 10);
1293 gfx::Vector2d expectedScrollDelta(scrollDelta); 1293 gfx::Vector2d expectedScrollDelta(scrollDelta);
1294 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); 1294 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset());
1295 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted); 1295 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
1296 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 1296 m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
1297 m_hostImpl->scrollEnd(); 1297 m_hostImpl->scrollEnd();
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1363 TEST_P(LayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread) 1363 TEST_P(LayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread)
1364 { 1364 {
1365 gfx::Size surfaceSize(10, 10); 1365 gfx::Size surfaceSize(10, 10);
1366 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1); 1366 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1);
1367 root->setBounds(surfaceSize); 1367 root->setBounds(surfaceSize);
1368 root->setContentBounds(surfaceSize); 1368 root->setContentBounds(surfaceSize);
1369 // Also mark the root scrollable so it becomes the root scroll layer. 1369 // Also mark the root scrollable so it becomes the root scroll layer.
1370 root->setScrollable(true); 1370 root->setScrollable(true);
1371 int scrollLayerId = 2; 1371 int scrollLayerId = 2;
1372 root->addChild(createScrollableLayer(scrollLayerId, surfaceSize)); 1372 root->addChild(createScrollableLayer(scrollLayerId, surfaceSize));
1373 m_hostImpl->setRootLayer(root.Pass()); 1373 m_hostImpl->activeTree()->SetRootLayer(root.Pass());
1374 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1374 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1375 initializeRendererAndDrawFrame(); 1375 initializeRendererAndDrawFrame();
1376 1376
1377 LayerImpl* child = m_hostImpl->rootLayer()->children()[0]; 1377 LayerImpl* child = m_hostImpl->rootLayer()->children()[0];
1378 1378
1379 gfx::Vector2d scrollDelta(0, 10); 1379 gfx::Vector2d scrollDelta(0, 10);
1380 gfx::Vector2d expectedScrollDelta(scrollDelta); 1380 gfx::Vector2d expectedScrollDelta(scrollDelta);
1381 gfx::Vector2d expectedMaxScroll(child->maxScrollOffset()); 1381 gfx::Vector2d expectedMaxScroll(child->maxScrollOffset());
1382 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted); 1382 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
1383 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 1383 m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
(...skipping 28 matching lines...) Expand all
1412 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); 1412 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize);
1413 1413
1414 scoped_ptr<LayerImpl> grandChild = createScrollableLayer(3, surfaceSize); 1414 scoped_ptr<LayerImpl> grandChild = createScrollableLayer(3, surfaceSize);
1415 grandChild->setScrollOffset(gfx::Vector2d(0, 5)); 1415 grandChild->setScrollOffset(gfx::Vector2d(0, 5));
1416 1416
1417 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize); 1417 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize);
1418 child->setScrollOffset(gfx::Vector2d(3, 0)); 1418 child->setScrollOffset(gfx::Vector2d(3, 0));
1419 child->addChild(grandChild.Pass()); 1419 child->addChild(grandChild.Pass());
1420 1420
1421 root->addChild(child.Pass()); 1421 root->addChild(child.Pass());
1422 m_hostImpl->setRootLayer(root.Pass()); 1422 m_hostImpl->activeTree()->SetRootLayer(root.Pass());
1423 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1423 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1424 initializeRendererAndDrawFrame(); 1424 initializeRendererAndDrawFrame();
1425 { 1425 {
1426 gfx::Vector2d scrollDelta(-8, -7); 1426 gfx::Vector2d scrollDelta(-8, -7);
1427 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient:: Wheel), InputHandlerClient::ScrollStarted); 1427 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient:: Wheel), InputHandlerClient::ScrollStarted);
1428 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 1428 m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
1429 m_hostImpl->scrollEnd(); 1429 m_hostImpl->scrollEnd();
1430 1430
1431 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as(); 1431 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as();
1432 1432
(...skipping 11 matching lines...) Expand all
1444 { 1444 {
1445 // When we try to scroll a non-scrollable child layer, the scroll delta 1445 // When we try to scroll a non-scrollable child layer, the scroll delta
1446 // should be applied to one of its ancestors if possible. 1446 // should be applied to one of its ancestors if possible.
1447 gfx::Size surfaceSize(10, 10); 1447 gfx::Size surfaceSize(10, 10);
1448 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); 1448 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize);
1449 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize); 1449 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize);
1450 1450
1451 child->setScrollable(false); 1451 child->setScrollable(false);
1452 root->addChild(child.Pass()); 1452 root->addChild(child.Pass());
1453 1453
1454 m_hostImpl->setRootLayer(root.Pass()); 1454 m_hostImpl->activeTree()->SetRootLayer(root.Pass());
1455 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1455 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1456 initializeRendererAndDrawFrame(); 1456 initializeRendererAndDrawFrame();
1457 { 1457 {
1458 gfx::Vector2d scrollDelta(0, 4); 1458 gfx::Vector2d scrollDelta(0, 4);
1459 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient:: Wheel), InputHandlerClient::ScrollStarted); 1459 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient:: Wheel), InputHandlerClient::ScrollStarted);
1460 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 1460 m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
1461 m_hostImpl->scrollEnd(); 1461 m_hostImpl->scrollEnd();
1462 1462
1463 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as(); 1463 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as();
1464 1464
1465 // Only the root should have scrolled. 1465 // Only the root should have scrolled.
1466 ASSERT_EQ(scrollInfo->scrolls.size(), 1u); 1466 ASSERT_EQ(scrollInfo->scrolls.size(), 1u);
1467 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD elta); 1467 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD elta);
1468 } 1468 }
1469 } 1469 }
1470 1470
1471 TEST_P(LayerTreeHostImplTest, scrollBeforeRedraw) 1471 TEST_P(LayerTreeHostImplTest, scrollBeforeRedraw)
1472 { 1472 {
1473 gfx::Size surfaceSize(10, 10); 1473 gfx::Size surfaceSize(10, 10);
1474 m_hostImpl->setRootLayer(createScrollableLayer(1, surfaceSize)); 1474 m_hostImpl->activeTree()->SetRootLayer(createScrollableLayer(1, surfaceSize) );
1475 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1475 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1476 1476
1477 // Draw one frame and then immediately rebuild the layer tree to mimic a tre e synchronization. 1477 // Draw one frame and then immediately rebuild the layer tree to mimic a tre e synchronization.
1478 initializeRendererAndDrawFrame(); 1478 initializeRendererAndDrawFrame();
1479 m_hostImpl->detachLayerTree(); 1479 m_hostImpl->activeTree()->DetachLayerTree();
1480 m_hostImpl->setRootLayer(createScrollableLayer(2, surfaceSize)); 1480 m_hostImpl->activeTree()->SetRootLayer(createScrollableLayer(2, surfaceSize) );
1481 1481
1482 // Scrolling should still work even though we did not draw yet. 1482 // Scrolling should still work even though we did not draw yet.
1483 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted); 1483 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
1484 } 1484 }
1485 1485
1486 TEST_P(LayerTreeHostImplTest, scrollAxisAlignedRotatedLayer) 1486 TEST_P(LayerTreeHostImplTest, scrollAxisAlignedRotatedLayer)
1487 { 1487 {
1488 setupScrollAndContentsLayers(gfx::Size(100, 100)); 1488 setupScrollAndContentsLayers(gfx::Size(100, 100));
1489 1489
1490 // Rotate the root layer 90 degrees counter-clockwise about its center. 1490 // Rotate the root layer 90 degrees counter-clockwise about its center.
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
1699 }; 1699 };
1700 1700
1701 TEST_P(LayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers) 1701 TEST_P(LayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers)
1702 { 1702 {
1703 { 1703 {
1704 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1); 1704 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1);
1705 root->setAnchorPoint(gfx::PointF(0, 0)); 1705 root->setAnchorPoint(gfx::PointF(0, 0));
1706 root->setBounds(gfx::Size(10, 10)); 1706 root->setBounds(gfx::Size(10, 10));
1707 root->setContentBounds(root->bounds()); 1707 root->setContentBounds(root->bounds());
1708 root->setDrawsContent(false); 1708 root->setDrawsContent(false);
1709 m_hostImpl->setRootLayer(root.Pass()); 1709 m_hostImpl->activeTree()->SetRootLayer(root.Pass());
1710 } 1710 }
1711 LayerImpl* root = m_hostImpl->rootLayer(); 1711 LayerImpl* root = m_hostImpl->rootLayer();
1712 1712
1713 root->addChild(BlendStateCheckLayer::create(m_hostImpl->activeTree(), 2, m_h ostImpl->resourceProvider())); 1713 root->addChild(BlendStateCheckLayer::create(m_hostImpl->activeTree(), 2, m_h ostImpl->resourceProvider()));
1714 BlendStateCheckLayer* layer1 = static_cast<BlendStateCheckLayer*>(root->chil dren()[0]); 1714 BlendStateCheckLayer* layer1 = static_cast<BlendStateCheckLayer*>(root->chil dren()[0]);
1715 layer1->setPosition(gfx::PointF(2, 2)); 1715 layer1->setPosition(gfx::PointF(2, 2));
1716 1716
1717 LayerTreeHostImpl::FrameData frame; 1717 LayerTreeHostImpl::FrameData frame;
1718 1718
1719 // Opaque layer, drawn without blending. 1719 // Opaque layer, drawn without blending.
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1886 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 1886 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
1887 m_hostImpl->drawLayers(frame); 1887 m_hostImpl->drawLayers(frame);
1888 EXPECT_TRUE(layer1->quadsAppended()); 1888 EXPECT_TRUE(layer1->quadsAppended());
1889 m_hostImpl->didDrawAllLayers(frame); 1889 m_hostImpl->didDrawAllLayers(frame);
1890 1890
1891 } 1891 }
1892 1892
1893 TEST_P(LayerTreeHostImplTest, viewportCovered) 1893 TEST_P(LayerTreeHostImplTest, viewportCovered)
1894 { 1894 {
1895 m_hostImpl->initializeRenderer(createOutputSurface()); 1895 m_hostImpl->initializeRenderer(createOutputSurface());
1896 m_hostImpl->setBackgroundColor(SK_ColorGRAY); 1896 m_hostImpl->activeTree()->set_background_color(SK_ColorGRAY);
1897 1897
1898 gfx::Size viewportSize(1000, 1000); 1898 gfx::Size viewportSize(1000, 1000);
1899 m_hostImpl->setViewportSize(viewportSize, viewportSize); 1899 m_hostImpl->setViewportSize(viewportSize, viewportSize);
1900 1900
1901 m_hostImpl->setRootLayer(LayerImpl::create(m_hostImpl->activeTree(), 1)); 1901 m_hostImpl->activeTree()->SetRootLayer(LayerImpl::create(m_hostImpl->activeT ree(), 1));
1902 m_hostImpl->rootLayer()->addChild(BlendStateCheckLayer::create(m_hostImpl->a ctiveTree(), 2, m_hostImpl->resourceProvider())); 1902 m_hostImpl->rootLayer()->addChild(BlendStateCheckLayer::create(m_hostImpl->a ctiveTree(), 2, m_hostImpl->resourceProvider()));
1903 BlendStateCheckLayer* child = static_cast<BlendStateCheckLayer*>(m_hostImpl- >rootLayer()->children()[0]); 1903 BlendStateCheckLayer* child = static_cast<BlendStateCheckLayer*>(m_hostImpl- >rootLayer()->children()[0]);
1904 child->setExpectation(false, false); 1904 child->setExpectation(false, false);
1905 child->setContentsOpaque(true); 1905 child->setContentsOpaque(true);
1906 1906
1907 // No gutter rects 1907 // No gutter rects
1908 { 1908 {
1909 gfx::Rect layerRect(0, 0, 1000, 1000); 1909 gfx::Rect layerRect(0, 0, 1000, 1000);
1910 child->setPosition(layerRect.origin()); 1910 child->setPosition(layerRect.origin());
1911 child->setBounds(layerRect.size()); 1911 child->setBounds(layerRect.size());
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
2004 TEST_P(LayerTreeHostImplTest, reshapeNotCalledUntilDraw) 2004 TEST_P(LayerTreeHostImplTest, reshapeNotCalledUntilDraw)
2005 { 2005 {
2006 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped _ptr<WebKit::WebGraphicsContext3D>(new ReshapeTrackerContext)).PassAs<OutputSurf ace>(); 2006 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped _ptr<WebKit::WebGraphicsContext3D>(new ReshapeTrackerContext)).PassAs<OutputSurf ace>();
2007 ReshapeTrackerContext* reshapeTracker = static_cast<ReshapeTrackerContext*>( outputSurface->Context3D()); 2007 ReshapeTrackerContext* reshapeTracker = static_cast<ReshapeTrackerContext*>( outputSurface->Context3D());
2008 m_hostImpl->initializeRenderer(outputSurface.Pass()); 2008 m_hostImpl->initializeRenderer(outputSurface.Pass());
2009 2009
2010 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(m_hostImpl->activ eTree(), 1); 2010 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(m_hostImpl->activ eTree(), 1);
2011 root->setAnchorPoint(gfx::PointF(0, 0)); 2011 root->setAnchorPoint(gfx::PointF(0, 0));
2012 root->setBounds(gfx::Size(10, 10)); 2012 root->setBounds(gfx::Size(10, 10));
2013 root->setDrawsContent(true); 2013 root->setDrawsContent(true);
2014 m_hostImpl->setRootLayer(root.Pass()); 2014 m_hostImpl->activeTree()->SetRootLayer(root.Pass());
2015 EXPECT_FALSE(reshapeTracker->reshapeCalled()); 2015 EXPECT_FALSE(reshapeTracker->reshapeCalled());
2016 2016
2017 LayerTreeHostImpl::FrameData frame; 2017 LayerTreeHostImpl::FrameData frame;
2018 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 2018 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
2019 m_hostImpl->drawLayers(frame); 2019 m_hostImpl->drawLayers(frame);
2020 EXPECT_TRUE(reshapeTracker->reshapeCalled()); 2020 EXPECT_TRUE(reshapeTracker->reshapeCalled());
2021 m_hostImpl->didDrawAllLayers(frame); 2021 m_hostImpl->didDrawAllLayers(frame);
2022 } 2022 }
2023 2023
2024 class PartialSwapTrackerContext : public FakeWebGraphicsContext3D { 2024 class PartialSwapTrackerContext : public FakeWebGraphicsContext3D {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2062 child->setPosition(gfx::PointF(12, 13)); 2062 child->setPosition(gfx::PointF(12, 13));
2063 child->setAnchorPoint(gfx::PointF(0, 0)); 2063 child->setAnchorPoint(gfx::PointF(0, 0));
2064 child->setBounds(gfx::Size(14, 15)); 2064 child->setBounds(gfx::Size(14, 15));
2065 child->setContentBounds(gfx::Size(14, 15)); 2065 child->setContentBounds(gfx::Size(14, 15));
2066 child->setDrawsContent(true); 2066 child->setDrawsContent(true);
2067 root->setAnchorPoint(gfx::PointF(0, 0)); 2067 root->setAnchorPoint(gfx::PointF(0, 0));
2068 root->setBounds(gfx::Size(500, 500)); 2068 root->setBounds(gfx::Size(500, 500));
2069 root->setContentBounds(gfx::Size(500, 500)); 2069 root->setContentBounds(gfx::Size(500, 500));
2070 root->setDrawsContent(true); 2070 root->setDrawsContent(true);
2071 root->addChild(child.Pass()); 2071 root->addChild(child.Pass());
2072 layerTreeHostImpl->setRootLayer(root.Pass()); 2072 layerTreeHostImpl->activeTree()->SetRootLayer(root.Pass());
2073 2073
2074 LayerTreeHostImpl::FrameData frame; 2074 LayerTreeHostImpl::FrameData frame;
2075 2075
2076 // First frame, the entire screen should get swapped. 2076 // First frame, the entire screen should get swapped.
2077 EXPECT_TRUE(layerTreeHostImpl->prepareToDraw(frame)); 2077 EXPECT_TRUE(layerTreeHostImpl->prepareToDraw(frame));
2078 layerTreeHostImpl->drawLayers(frame); 2078 layerTreeHostImpl->drawLayers(frame);
2079 layerTreeHostImpl->didDrawAllLayers(frame); 2079 layerTreeHostImpl->didDrawAllLayers(frame);
2080 layerTreeHostImpl->swapBuffers(); 2080 layerTreeHostImpl->swapBuffers();
2081 gfx::Rect actualSwapRect = partialSwapTracker->partialSwapRect(); 2081 gfx::Rect actualSwapRect = partialSwapTracker->partialSwapRect();
2082 gfx::Rect expectedSwapRect = gfx::Rect(gfx::Point(), gfx::Size(500, 500)); 2082 gfx::Rect expectedSwapRect = gfx::Rect(gfx::Point(), gfx::Size(500, 500));
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
2126 child->setBounds(gfx::Size(10, 10)); 2126 child->setBounds(gfx::Size(10, 10));
2127 child->setContentBounds(gfx::Size(10, 10)); 2127 child->setContentBounds(gfx::Size(10, 10));
2128 child->setDrawsContent(true); 2128 child->setDrawsContent(true);
2129 root->setAnchorPoint(gfx::PointF(0, 0)); 2129 root->setAnchorPoint(gfx::PointF(0, 0));
2130 root->setBounds(gfx::Size(10, 10)); 2130 root->setBounds(gfx::Size(10, 10));
2131 root->setContentBounds(gfx::Size(10, 10)); 2131 root->setContentBounds(gfx::Size(10, 10));
2132 root->setDrawsContent(true); 2132 root->setDrawsContent(true);
2133 root->setOpacity(0.7f); 2133 root->setOpacity(0.7f);
2134 root->addChild(child.Pass()); 2134 root->addChild(child.Pass());
2135 2135
2136 m_hostImpl->setRootLayer(root.Pass()); 2136 m_hostImpl->activeTree()->SetRootLayer(root.Pass());
2137 2137
2138 LayerTreeHostImpl::FrameData frame; 2138 LayerTreeHostImpl::FrameData frame;
2139 2139
2140 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 2140 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
2141 EXPECT_EQ(1u, frame.renderSurfaceLayerList->size()); 2141 EXPECT_EQ(1u, frame.renderSurfaceLayerList->size());
2142 EXPECT_EQ(1u, frame.renderPasses.size()); 2142 EXPECT_EQ(1u, frame.renderPasses.size());
2143 m_hostImpl->didDrawAllLayers(frame); 2143 m_hostImpl->didDrawAllLayers(frame);
2144 } 2144 }
2145 2145
2146 class FakeLayerWithQuads : public LayerImpl { 2146 class FakeLayerWithQuads : public LayerImpl {
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
2403 grandChild->setAnchorPoint(gfx::PointF(0, 0)); 2403 grandChild->setAnchorPoint(gfx::PointF(0, 0));
2404 grandChild->setPosition(gfx::Point(grandChildRect.x(), grandChildRect.y())); 2404 grandChild->setPosition(gfx::Point(grandChildRect.x(), grandChildRect.y()));
2405 grandChild->setBounds(gfx::Size(grandChildRect.width(), grandChildRect.heigh t())); 2405 grandChild->setBounds(gfx::Size(grandChildRect.width(), grandChildRect.heigh t()));
2406 grandChild->setContentBounds(grandChild->bounds()); 2406 grandChild->setContentBounds(grandChild->bounds());
2407 grandChild->drawProperties().visible_content_rect = grandChildRect; 2407 grandChild->drawProperties().visible_content_rect = grandChildRect;
2408 grandChild->setDrawsContent(true); 2408 grandChild->setDrawsContent(true);
2409 2409
2410 child->addChild(grandChild.Pass()); 2410 child->addChild(grandChild.Pass());
2411 root->addChild(child.Pass()); 2411 root->addChild(child.Pass());
2412 2412
2413 myHostImpl->setRootLayer(root.Pass()); 2413 myHostImpl->activeTree()->SetRootLayer(root.Pass());
2414 return myHostImpl.Pass(); 2414 return myHostImpl.Pass();
2415 } 2415 }
2416 2416
2417 TEST_P(LayerTreeHostImplTest, contributingLayerEmptyScissorPartialSwap) 2417 TEST_P(LayerTreeHostImplTest, contributingLayerEmptyScissorPartialSwap)
2418 { 2418 {
2419 scoped_ptr<LayerTreeHostImpl> myHostImpl = setupLayersForOpacity(true, this, &m_proxy); 2419 scoped_ptr<LayerTreeHostImpl> myHostImpl = setupLayersForOpacity(true, this, &m_proxy);
2420 2420
2421 { 2421 {
2422 LayerTreeHostImpl::FrameData frame; 2422 LayerTreeHostImpl::FrameData frame;
2423 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 2423 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2471 : LayerImpl(treeImpl, id) 2471 : LayerImpl(treeImpl, id)
2472 , m_didLoseOutputSurfaceCalled(false) 2472 , m_didLoseOutputSurfaceCalled(false)
2473 { 2473 {
2474 } 2474 }
2475 2475
2476 bool m_didLoseOutputSurfaceCalled; 2476 bool m_didLoseOutputSurfaceCalled;
2477 }; 2477 };
2478 2478
2479 TEST_P(LayerTreeHostImplTest, outputSurfaceLostAndRestoredNotificationSentToAllL ayers) 2479 TEST_P(LayerTreeHostImplTest, outputSurfaceLostAndRestoredNotificationSentToAllL ayers)
2480 { 2480 {
2481 m_hostImpl->setRootLayer(OutputSurfaceLostNotificationCheckLayer::create(m_h ostImpl->activeTree(), 1)); 2481 m_hostImpl->activeTree()->SetRootLayer(OutputSurfaceLostNotificationCheckLay er::create(m_hostImpl->activeTree(), 1));
2482 OutputSurfaceLostNotificationCheckLayer* root = static_cast<OutputSurfaceLos tNotificationCheckLayer*>(m_hostImpl->rootLayer()); 2482 OutputSurfaceLostNotificationCheckLayer* root = static_cast<OutputSurfaceLos tNotificationCheckLayer*>(m_hostImpl->rootLayer());
2483 2483
2484 root->addChild(OutputSurfaceLostNotificationCheckLayer::create(m_hostImpl->a ctiveTree(), 2)); 2484 root->addChild(OutputSurfaceLostNotificationCheckLayer::create(m_hostImpl->a ctiveTree(), 2));
2485 OutputSurfaceLostNotificationCheckLayer* layer1 = static_cast<OutputSurfaceL ostNotificationCheckLayer*>(root->children()[0]); 2485 OutputSurfaceLostNotificationCheckLayer* layer1 = static_cast<OutputSurfaceL ostNotificationCheckLayer*>(root->children()[0]);
2486 2486
2487 layer1->addChild(OutputSurfaceLostNotificationCheckLayer::create(m_hostImpl- >activeTree(), 3)); 2487 layer1->addChild(OutputSurfaceLostNotificationCheckLayer::create(m_hostImpl- >activeTree(), 3));
2488 OutputSurfaceLostNotificationCheckLayer* layer2 = static_cast<OutputSurfaceL ostNotificationCheckLayer*>(layer1->children()[0]); 2488 OutputSurfaceLostNotificationCheckLayer* layer2 = static_cast<OutputSurfaceL ostNotificationCheckLayer*>(layer1->children()[0]);
2489 2489
2490 EXPECT_FALSE(root->didLoseOutputSurfaceCalled()); 2490 EXPECT_FALSE(root->didLoseOutputSurfaceCalled());
2491 EXPECT_FALSE(layer1->didLoseOutputSurfaceCalled()); 2491 EXPECT_FALSE(layer1->didLoseOutputSurfaceCalled());
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
2907 hwProvider.setFrame(&hwVideoFrame); 2907 hwProvider.setFrame(&hwVideoFrame);
2908 2908
2909 FakeVideoFrame videoFrameScaled( 2909 FakeVideoFrame videoFrameScaled(
2910 VideoFrame::WrapNativeTexture( 2910 VideoFrame::WrapNativeTexture(
2911 m_hostImpl->resourceProvider()->graphicsContext3D()->createTexture() , 2911 m_hostImpl->resourceProvider()->graphicsContext3D()->createTexture() ,
2912 GL_TEXTURE_2D, 2912 GL_TEXTURE_2D,
2913 gfx::Size(4, 4), gfx::Rect(0, 0, 3, 2), gfx::Size(4, 4), base::TimeD elta(), 2913 gfx::Size(4, 4), gfx::Rect(0, 0, 3, 2), gfx::Size(4, 4), base::TimeD elta(),
2914 VideoFrame::ReadPixelsCB(), base::Closure())); 2914 VideoFrame::ReadPixelsCB(), base::Closure()));
2915 providerScaled.setFrame(&videoFrameScaled); 2915 providerScaled.setFrame(&videoFrameScaled);
2916 2916
2917 m_hostImpl->setRootLayer(rootLayer.Pass()); 2917 m_hostImpl->activeTree()->SetRootLayer(rootLayer.Pass());
2918 2918
2919 LayerTreeHostImpl::FrameData frame; 2919 LayerTreeHostImpl::FrameData frame;
2920 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 2920 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
2921 m_hostImpl->drawLayers(frame); 2921 m_hostImpl->drawLayers(frame);
2922 m_hostImpl->didDrawAllLayers(frame); 2922 m_hostImpl->didDrawAllLayers(frame);
2923 m_hostImpl->swapBuffers(); 2923 m_hostImpl->swapBuffers();
2924 2924
2925 unsigned numResources = m_hostImpl->resourceProvider()->numResources(); 2925 unsigned numResources = m_hostImpl->resourceProvider()->numResources();
2926 2926
2927 // Lose the WebKit::WebGraphicsContext3D, replacing it with a StrictWebGraph icsContext3DWithIOSurface, 2927 // Lose the WebKit::WebGraphicsContext3D, replacing it with a StrictWebGraph icsContext3DWithIOSurface,
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
3040 ioSurfaceLayer->setContentBounds(gfx::Size(10, 10)); 3040 ioSurfaceLayer->setContentBounds(gfx::Size(10, 10));
3041 ioSurfaceLayer->setDrawsContent(true); 3041 ioSurfaceLayer->setDrawsContent(true);
3042 ioSurfaceLayer->setIOSurfaceProperties(1, gfx::Size(10, 10)); 3042 ioSurfaceLayer->setIOSurfaceProperties(1, gfx::Size(10, 10));
3043 rootLayer->addChild(ioSurfaceLayer.PassAs<LayerImpl>()); 3043 rootLayer->addChild(ioSurfaceLayer.PassAs<LayerImpl>());
3044 3044
3045 // Lose the WebGraphicsContext3D, replacing it with a TrackingWebGraphicsCon text3D (which the LayerTreeHostImpl takes ownership of). 3045 // Lose the WebGraphicsContext3D, replacing it with a TrackingWebGraphicsCon text3D (which the LayerTreeHostImpl takes ownership of).
3046 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p tr<WebKit::WebGraphicsContext3D>(new TrackingWebGraphicsContext3D))); 3046 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p tr<WebKit::WebGraphicsContext3D>(new TrackingWebGraphicsContext3D)));
3047 TrackingWebGraphicsContext3D* trackingWebGraphicsContext3D = static_cast<Tra ckingWebGraphicsContext3D*>(outputSurface->Context3D()); 3047 TrackingWebGraphicsContext3D* trackingWebGraphicsContext3D = static_cast<Tra ckingWebGraphicsContext3D*>(outputSurface->Context3D());
3048 m_hostImpl->initializeRenderer(outputSurface.Pass()); 3048 m_hostImpl->initializeRenderer(outputSurface.Pass());
3049 3049
3050 m_hostImpl->setRootLayer(rootLayer.Pass()); 3050 m_hostImpl->activeTree()->SetRootLayer(rootLayer.Pass());
3051 3051
3052 LayerTreeHostImpl::FrameData frame; 3052 LayerTreeHostImpl::FrameData frame;
3053 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 3053 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
3054 m_hostImpl->drawLayers(frame); 3054 m_hostImpl->drawLayers(frame);
3055 m_hostImpl->didDrawAllLayers(frame); 3055 m_hostImpl->didDrawAllLayers(frame);
3056 m_hostImpl->swapBuffers(); 3056 m_hostImpl->swapBuffers();
3057 3057
3058 EXPECT_GT(trackingWebGraphicsContext3D->numTextures(), 0u); 3058 EXPECT_GT(trackingWebGraphicsContext3D->numTextures(), 0u);
3059 3059
3060 // Kill the layer tree. 3060 // Kill the layer tree.
3061 m_hostImpl->setRootLayer(LayerImpl::create(m_hostImpl->activeTree(), 100)); 3061 m_hostImpl->activeTree()->SetRootLayer(LayerImpl::create(m_hostImpl->activeT ree(), 100));
3062 // There should be no textures left in use after. 3062 // There should be no textures left in use after.
3063 EXPECT_EQ(0u, trackingWebGraphicsContext3D->numTextures()); 3063 EXPECT_EQ(0u, trackingWebGraphicsContext3D->numTextures());
3064 } 3064 }
3065 3065
3066 class MockDrawQuadsToFillScreenContext : public FakeWebGraphicsContext3D { 3066 class MockDrawQuadsToFillScreenContext : public FakeWebGraphicsContext3D {
3067 public: 3067 public:
3068 MOCK_METHOD1(useProgram, void(WebKit::WebGLId program)); 3068 MOCK_METHOD1(useProgram, void(WebKit::WebGLId program));
3069 MOCK_METHOD4(drawElements, void(WebKit::WGC3Denum mode, WebKit::WGC3Dsizei c ount, WebKit::WGC3Denum type, WebKit::WGC3Dintptr offset)); 3069 MOCK_METHOD4(drawElements, void(WebKit::WGC3Denum mode, WebKit::WGC3Dsizei c ount, WebKit::WGC3Denum type, WebKit::WGC3Dintptr offset));
3070 }; 3070 };
3071 3071
3072 TEST_P(LayerTreeHostImplTest, hasTransparentBackground) 3072 TEST_P(LayerTreeHostImplTest, hasTransparentBackground)
3073 { 3073 {
3074 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped _ptr<WebKit::WebGraphicsContext3D>(new MockDrawQuadsToFillScreenContext)).PassAs <OutputSurface>(); 3074 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped _ptr<WebKit::WebGraphicsContext3D>(new MockDrawQuadsToFillScreenContext)).PassAs <OutputSurface>();
3075 MockDrawQuadsToFillScreenContext* mockContext = static_cast<MockDrawQuadsToF illScreenContext*>(outputSurface->Context3D()); 3075 MockDrawQuadsToFillScreenContext* mockContext = static_cast<MockDrawQuadsToF illScreenContext*>(outputSurface->Context3D());
3076 3076
3077 // Run test case 3077 // Run test case
3078 createLayerTreeHost(false, outputSurface.Pass()); 3078 createLayerTreeHost(false, outputSurface.Pass());
3079 setupRootLayerImpl(LayerImpl::create(m_hostImpl->activeTree(), 1)); 3079 setupRootLayerImpl(LayerImpl::create(m_hostImpl->activeTree(), 1));
3080 m_hostImpl->setBackgroundColor(SK_ColorWHITE); 3080 m_hostImpl->activeTree()->set_background_color(SK_ColorWHITE);
3081 3081
3082 // Verify one quad is drawn when transparent background set is not set. 3082 // Verify one quad is drawn when transparent background set is not set.
3083 m_hostImpl->setHasTransparentBackground(false); 3083 m_hostImpl->activeTree()->set_has_transparent_background(false);
3084 EXPECT_CALL(*mockContext, useProgram(_)) 3084 EXPECT_CALL(*mockContext, useProgram(_))
3085 .Times(1); 3085 .Times(1);
3086 EXPECT_CALL(*mockContext, drawElements(_, _, _, _)) 3086 EXPECT_CALL(*mockContext, drawElements(_, _, _, _))
3087 .Times(1); 3087 .Times(1);
3088 LayerTreeHostImpl::FrameData frame; 3088 LayerTreeHostImpl::FrameData frame;
3089 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 3089 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
3090 m_hostImpl->drawLayers(frame); 3090 m_hostImpl->drawLayers(frame);
3091 m_hostImpl->didDrawAllLayers(frame); 3091 m_hostImpl->didDrawAllLayers(frame);
3092 Mock::VerifyAndClearExpectations(&mockContext); 3092 Mock::VerifyAndClearExpectations(&mockContext);
3093 3093
3094 // Verify no quads are drawn when transparent background is set. 3094 // Verify no quads are drawn when transparent background is set.
3095 m_hostImpl->setHasTransparentBackground(true); 3095 m_hostImpl->activeTree()->set_has_transparent_background(true);
3096 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 3096 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
3097 m_hostImpl->drawLayers(frame); 3097 m_hostImpl->drawLayers(frame);
3098 m_hostImpl->didDrawAllLayers(frame); 3098 m_hostImpl->didDrawAllLayers(frame);
3099 Mock::VerifyAndClearExpectations(&mockContext); 3099 Mock::VerifyAndClearExpectations(&mockContext);
3100 } 3100 }
3101 3101
3102 static void addDrawingLayerTo(LayerImpl* parent, int id, const gfx::Rect& layerR ect, LayerImpl** result) 3102 static void addDrawingLayerTo(LayerImpl* parent, int id, const gfx::Rect& layerR ect, LayerImpl** result)
3103 { 3103 {
3104 scoped_ptr<LayerImpl> layer = FakeLayerWithQuads::create(parent->layerTreeIm pl(), id); 3104 scoped_ptr<LayerImpl> layer = FakeLayerWithQuads::create(parent->layerTreeIm pl(), id);
3105 LayerImpl* layerPtr = layer.get(); 3105 LayerImpl* layerPtr = layer.get();
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
3183 3183
3184 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl->activeTree(), 1); 3184 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl->activeTree(), 1);
3185 rootPtr = root.get(); 3185 rootPtr = root.get();
3186 3186
3187 root->setAnchorPoint(gfx::PointF(0, 0)); 3187 root->setAnchorPoint(gfx::PointF(0, 0));
3188 root->setPosition(gfx::PointF(0, 0)); 3188 root->setPosition(gfx::PointF(0, 0));
3189 root->setBounds(rootSize); 3189 root->setBounds(rootSize);
3190 root->setContentBounds(rootSize); 3190 root->setContentBounds(rootSize);
3191 root->setDrawsContent(true); 3191 root->setDrawsContent(true);
3192 root->setMasksToBounds(true); 3192 root->setMasksToBounds(true);
3193 myHostImpl->setRootLayer(root.Pass()); 3193 myHostImpl->activeTree()->SetRootLayer(root.Pass());
3194 3194
3195 addDrawingLayerTo(rootPtr, 2, gfx::Rect(300, 300, 300, 300), &layerS1Ptr); 3195 addDrawingLayerTo(rootPtr, 2, gfx::Rect(300, 300, 300, 300), &layerS1Ptr);
3196 layerS1Ptr->setForceRenderSurface(true); 3196 layerS1Ptr->setForceRenderSurface(true);
3197 3197
3198 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(10, 10, 10, 10), 0); // L11 3198 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(10, 10, 10, 10), 0); // L11
3199 addDrawingLayerTo(layerS1Ptr, 4, gfx::Rect(0, 0, 30, 30), 0); // L12 3199 addDrawingLayerTo(layerS1Ptr, 4, gfx::Rect(0, 0, 30, 30), 0); // L12
3200 3200
3201 addDrawingLayerTo(rootPtr, 5, gfx::Rect(550, 250, 300, 400), &layerS2Ptr); 3201 addDrawingLayerTo(rootPtr, 5, gfx::Rect(550, 250, 300, 400), &layerS2Ptr);
3202 layerS2Ptr->setForceRenderSurface(true); 3202 layerS2Ptr->setForceRenderSurface(true);
3203 3203
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
3294 3294
3295 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl->activeTree(), 1); 3295 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl->activeTree(), 1);
3296 rootPtr = root.get(); 3296 rootPtr = root.get();
3297 3297
3298 root->setAnchorPoint(gfx::PointF(0, 0)); 3298 root->setAnchorPoint(gfx::PointF(0, 0));
3299 root->setPosition(gfx::PointF(0, 0)); 3299 root->setPosition(gfx::PointF(0, 0));
3300 root->setBounds(rootSize); 3300 root->setBounds(rootSize);
3301 root->setContentBounds(rootSize); 3301 root->setContentBounds(rootSize);
3302 root->setDrawsContent(true); 3302 root->setDrawsContent(true);
3303 root->setMasksToBounds(true); 3303 root->setMasksToBounds(true);
3304 myHostImpl->setRootLayer(root.Pass()); 3304 myHostImpl->activeTree()->SetRootLayer(root.Pass());
3305 3305
3306 addDrawingLayerTo(rootPtr, 2, gfx::Rect(0, 0, 800, 800), &layerS1Ptr); 3306 addDrawingLayerTo(rootPtr, 2, gfx::Rect(0, 0, 800, 800), &layerS1Ptr);
3307 layerS1Ptr->setForceRenderSurface(true); 3307 layerS1Ptr->setForceRenderSurface(true);
3308 layerS1Ptr->setDrawsContent(false); 3308 layerS1Ptr->setDrawsContent(false);
3309 3309
3310 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(0, 0, 300, 300), 0); // L11 3310 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(0, 0, 300, 300), 0); // L11
3311 addDrawingLayerTo(layerS1Ptr, 4, gfx::Rect(0, 500, 300, 300), 0); // L12 3311 addDrawingLayerTo(layerS1Ptr, 4, gfx::Rect(0, 500, 300, 300), 0); // L12
3312 addDrawingLayerTo(layerS1Ptr, 5, gfx::Rect(500, 0, 300, 300), 0); // L13 3312 addDrawingLayerTo(layerS1Ptr, 5, gfx::Rect(500, 0, 300, 300), 0); // L13
3313 addDrawingLayerTo(layerS1Ptr, 6, gfx::Rect(500, 500, 300, 300), 0); // L14 3313 addDrawingLayerTo(layerS1Ptr, 6, gfx::Rect(500, 500, 300, 300), 0); // L14
3314 addDrawingLayerTo(layerS1Ptr, 9, gfx::Rect(500, 500, 300, 300), 0); // L14 3314 addDrawingLayerTo(layerS1Ptr, 9, gfx::Rect(500, 500, 300, 300), 0); // L14
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
3406 3406
3407 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl->activeTree(), 1); 3407 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl->activeTree(), 1);
3408 rootPtr = root.get(); 3408 rootPtr = root.get();
3409 3409
3410 root->setAnchorPoint(gfx::PointF(0, 0)); 3410 root->setAnchorPoint(gfx::PointF(0, 0));
3411 root->setPosition(gfx::PointF(0, 0)); 3411 root->setPosition(gfx::PointF(0, 0));
3412 root->setBounds(rootSize); 3412 root->setBounds(rootSize);
3413 root->setContentBounds(rootSize); 3413 root->setContentBounds(rootSize);
3414 root->setDrawsContent(true); 3414 root->setDrawsContent(true);
3415 root->setMasksToBounds(true); 3415 root->setMasksToBounds(true);
3416 myHostImpl->setRootLayer(root.Pass()); 3416 myHostImpl->activeTree()->SetRootLayer(root.Pass());
3417 3417
3418 addDrawingLayerTo(rootPtr, 2, gfx::Rect(0, 0, 400, 400), &layerS1Ptr); 3418 addDrawingLayerTo(rootPtr, 2, gfx::Rect(0, 0, 400, 400), &layerS1Ptr);
3419 layerS1Ptr->setForceRenderSurface(true); 3419 layerS1Ptr->setForceRenderSurface(true);
3420 3420
3421 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(0, 0, 300, 300), 0); // L11 3421 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(0, 0, 300, 300), 0); // L11
3422 addDrawingLayerTo(layerS1Ptr, 4, gfx::Rect(100, 0, 300, 300), 0); // L12 3422 addDrawingLayerTo(layerS1Ptr, 4, gfx::Rect(100, 0, 300, 300), 0); // L12
3423 3423
3424 addDrawingLayerTo(rootPtr, 7, gfx::Rect(200, 0, 300, 300), &layerS2Ptr); 3424 addDrawingLayerTo(rootPtr, 7, gfx::Rect(200, 0, 300, 300), &layerS2Ptr);
3425 layerS2Ptr->setForceRenderSurface(true); 3425 layerS2Ptr->setForceRenderSurface(true);
3426 3426
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
3487 3487
3488 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl->activeTree(), 1); 3488 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl->activeTree(), 1);
3489 rootPtr = root.get(); 3489 rootPtr = root.get();
3490 3490
3491 root->setAnchorPoint(gfx::PointF(0, 0)); 3491 root->setAnchorPoint(gfx::PointF(0, 0));
3492 root->setPosition(gfx::PointF(0, 0)); 3492 root->setPosition(gfx::PointF(0, 0));
3493 root->setBounds(rootSize); 3493 root->setBounds(rootSize);
3494 root->setContentBounds(rootSize); 3494 root->setContentBounds(rootSize);
3495 root->setDrawsContent(true); 3495 root->setDrawsContent(true);
3496 root->setMasksToBounds(true); 3496 root->setMasksToBounds(true);
3497 myHostImpl->setRootLayer(root.Pass()); 3497 myHostImpl->activeTree()->SetRootLayer(root.Pass());
3498 3498
3499 addDrawingLayerTo(rootPtr, 2, gfx::Rect(0, 0, 400, 400), &layerS1Ptr); 3499 addDrawingLayerTo(rootPtr, 2, gfx::Rect(0, 0, 400, 400), &layerS1Ptr);
3500 layerS1Ptr->setForceRenderSurface(true); 3500 layerS1Ptr->setForceRenderSurface(true);
3501 gfx::Transform transform = layerS1Ptr->transform(); 3501 gfx::Transform transform = layerS1Ptr->transform();
3502 transform.Translate(200, 200); 3502 transform.Translate(200, 200);
3503 transform.Rotate(45); 3503 transform.Rotate(45);
3504 transform.Translate(-200, -200); 3504 transform.Translate(-200, -200);
3505 layerS1Ptr->setTransform(transform); 3505 layerS1Ptr->setTransform(transform);
3506 3506
3507 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(200, 0, 200, 400), 0); // L11 3507 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(200, 0, 200, 400), 0); // L11
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
3571 3571
3572 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl->activeTree(), 1); 3572 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl->activeTree(), 1);
3573 rootPtr = root.get(); 3573 rootPtr = root.get();
3574 3574
3575 root->setAnchorPoint(gfx::PointF(0, 0)); 3575 root->setAnchorPoint(gfx::PointF(0, 0));
3576 root->setPosition(gfx::PointF(0, 0)); 3576 root->setPosition(gfx::PointF(0, 0));
3577 root->setBounds(rootSize); 3577 root->setBounds(rootSize);
3578 root->setContentBounds(rootSize); 3578 root->setContentBounds(rootSize);
3579 root->setDrawsContent(true); 3579 root->setDrawsContent(true);
3580 root->setMasksToBounds(true); 3580 root->setMasksToBounds(true);
3581 myHostImpl->setRootLayer(root.Pass()); 3581 myHostImpl->activeTree()->SetRootLayer(root.Pass());
3582 3582
3583 addDrawingLayerTo(rootPtr, 2, gfx::Rect(300, 300, 300, 300), &layerS1Ptr); 3583 addDrawingLayerTo(rootPtr, 2, gfx::Rect(300, 300, 300, 300), &layerS1Ptr);
3584 layerS1Ptr->setForceRenderSurface(true); 3584 layerS1Ptr->setForceRenderSurface(true);
3585 3585
3586 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(10, 10, 10, 10), 0); // L11 3586 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(10, 10, 10, 10), 0); // L11
3587 addDrawingLayerTo(layerS1Ptr, 4, gfx::Rect(0, 0, 30, 30), 0); // L12 3587 addDrawingLayerTo(layerS1Ptr, 4, gfx::Rect(0, 0, 30, 30), 0); // L12
3588 3588
3589 addDrawingLayerTo(rootPtr, 5, gfx::Rect(550, 250, 300, 400), &layerS2Ptr); 3589 addDrawingLayerTo(rootPtr, 5, gfx::Rect(550, 250, 300, 400), &layerS2Ptr);
3590 layerS2Ptr->setForceRenderSurface(true); 3590 layerS2Ptr->setForceRenderSurface(true);
3591 3591
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
3708 grandChild->setPosition(gfx::Point(grandChildRect.x(), grandChildRect.y())); 3708 grandChild->setPosition(gfx::Point(grandChildRect.x(), grandChildRect.y()));
3709 grandChild->setBounds(gfx::Size(grandChildRect.width(), grandChildRect.heigh t())); 3709 grandChild->setBounds(gfx::Size(grandChildRect.width(), grandChildRect.heigh t()));
3710 grandChild->setContentBounds(grandChild->bounds()); 3710 grandChild->setContentBounds(grandChild->bounds());
3711 grandChild->setDrawsContent(true); 3711 grandChild->setDrawsContent(true);
3712 3712
3713 TiledLayerImpl* childPtr = child.get(); 3713 TiledLayerImpl* childPtr = child.get();
3714 RenderPass::Id childPassId(childPtr->id(), 0); 3714 RenderPass::Id childPassId(childPtr->id(), 0);
3715 3715
3716 child->addChild(grandChild.Pass()); 3716 child->addChild(grandChild.Pass());
3717 root->addChild(child.PassAs<LayerImpl>()); 3717 root->addChild(child.PassAs<LayerImpl>());
3718 myHostImpl->setRootLayer(root.Pass()); 3718 myHostImpl->activeTree()->SetRootLayer(root.Pass());
3719 myHostImpl->setViewportSize(rootRect.size(), rootRect.size()); 3719 myHostImpl->setViewportSize(rootRect.size(), rootRect.size());
3720 3720
3721 EXPECT_FALSE(myHostImpl->renderer()->haveCachedResourcesForRenderPassId(chil dPassId)); 3721 EXPECT_FALSE(myHostImpl->renderer()->haveCachedResourcesForRenderPassId(chil dPassId));
3722 3722
3723 { 3723 {
3724 LayerTreeHostImpl::FrameData frame; 3724 LayerTreeHostImpl::FrameData frame;
3725 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3725 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3726 myHostImpl->drawLayers(frame); 3726 myHostImpl->drawLayers(frame);
3727 myHostImpl->didDrawAllLayers(frame); 3727 myHostImpl->didDrawAllLayers(frame);
3728 } 3728 }
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after
4447 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor); 4447 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor);
4448 4448
4449 gfx::Size layoutSurfaceSize(10, 20); 4449 gfx::Size layoutSurfaceSize(10, 20);
4450 gfx::Size deviceSurfaceSize(layoutSurfaceSize.width() * static_cast<int>(dev iceScaleFactor), 4450 gfx::Size deviceSurfaceSize(layoutSurfaceSize.width() * static_cast<int>(dev iceScaleFactor),
4451 layoutSurfaceSize.height() * static_cast<int>(de viceScaleFactor)); 4451 layoutSurfaceSize.height() * static_cast<int>(de viceScaleFactor));
4452 float pageScale = 2; 4452 float pageScale = 2;
4453 scoped_ptr<LayerImpl> root = createScrollableLayer(1, layoutSurfaceSize); 4453 scoped_ptr<LayerImpl> root = createScrollableLayer(1, layoutSurfaceSize);
4454 // For this test we want to force scrolls to only pan the pinchZoomViewport 4454 // For this test we want to force scrolls to only pan the pinchZoomViewport
4455 // and not the document, we can verify commit/redraw are requested. 4455 // and not the document, we can verify commit/redraw are requested.
4456 root->setMaxScrollOffset(gfx::Vector2d()); 4456 root->setMaxScrollOffset(gfx::Vector2d());
4457 m_hostImpl->setRootLayer(root.Pass()); 4457 m_hostImpl->activeTree()->SetRootLayer(root.Pass());
4458 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); 4458 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize);
4459 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); 4459 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
4460 initializeRendererAndDrawFrame(); 4460 initializeRendererAndDrawFrame();
4461 4461
4462 // Set new page scale on impl thread by pinching. 4462 // Set new page scale on impl thread by pinching.
4463 m_hostImpl->pinchGestureBegin(); 4463 m_hostImpl->pinchGestureBegin();
4464 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); 4464 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point());
4465 m_hostImpl->pinchGestureEnd(); 4465 m_hostImpl->pinchGestureEnd();
4466 drawOneFrame(); 4466 drawOneFrame();
4467 4467
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
4519 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor); 4519 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor);
4520 4520
4521 gfx::Size layoutSurfaceSize(10, 20); 4521 gfx::Size layoutSurfaceSize(10, 20);
4522 gfx::Size deviceSurfaceSize(layoutSurfaceSize.width() * static_cast<int>(dev iceScaleFactor), 4522 gfx::Size deviceSurfaceSize(layoutSurfaceSize.width() * static_cast<int>(dev iceScaleFactor),
4523 layoutSurfaceSize.height() * static_cast<int>(de viceScaleFactor)); 4523 layoutSurfaceSize.height() * static_cast<int>(de viceScaleFactor));
4524 float pageScale = 2; 4524 float pageScale = 2;
4525 scoped_ptr<LayerImpl> root = createScrollableLayer(1, layoutSurfaceSize); 4525 scoped_ptr<LayerImpl> root = createScrollableLayer(1, layoutSurfaceSize);
4526 // For this test we want to force scrolls to move the pinchZoomViewport so 4526 // For this test we want to force scrolls to move the pinchZoomViewport so
4527 // we can see the scroll component on the implTransform. 4527 // we can see the scroll component on the implTransform.
4528 root->setMaxScrollOffset(gfx::Vector2d()); 4528 root->setMaxScrollOffset(gfx::Vector2d());
4529 m_hostImpl->setRootLayer(root.Pass()); 4529 m_hostImpl->activeTree()->SetRootLayer(root.Pass());
4530 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); 4530 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize);
4531 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); 4531 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
4532 initializeRendererAndDrawFrame(); 4532 initializeRendererAndDrawFrame();
4533 4533
4534 // Set new page scale on impl thread by pinching. 4534 // Set new page scale on impl thread by pinching.
4535 m_hostImpl->pinchGestureBegin(); 4535 m_hostImpl->pinchGestureBegin();
4536 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); 4536 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point());
4537 m_hostImpl->pinchGestureEnd(); 4537 m_hostImpl->pinchGestureEnd();
4538 drawOneFrame(); 4538 drawOneFrame();
4539 4539
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
4603 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor); 4603 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor);
4604 4604
4605 gfx::Size layoutSurfaceSize(10, 20); 4605 gfx::Size layoutSurfaceSize(10, 20);
4606 gfx::Size deviceSurfaceSize(layoutSurfaceSize.width() * static_cast<int>(dev iceScaleFactor), 4606 gfx::Size deviceSurfaceSize(layoutSurfaceSize.width() * static_cast<int>(dev iceScaleFactor),
4607 layoutSurfaceSize.height() * static_cast<int>(de viceScaleFactor)); 4607 layoutSurfaceSize.height() * static_cast<int>(de viceScaleFactor));
4608 float pageScale = 2; 4608 float pageScale = 2;
4609 scoped_ptr<LayerImpl> root = createScrollableLayer(1, layoutSurfaceSize); 4609 scoped_ptr<LayerImpl> root = createScrollableLayer(1, layoutSurfaceSize);
4610 // For this test we want to scrolls to move both the document and the 4610 // For this test we want to scrolls to move both the document and the
4611 // pinchZoomViewport so we can see some scroll component on the implTransfor m. 4611 // pinchZoomViewport so we can see some scroll component on the implTransfor m.
4612 root->setMaxScrollOffset(gfx::Vector2d(3, 4)); 4612 root->setMaxScrollOffset(gfx::Vector2d(3, 4));
4613 m_hostImpl->setRootLayer(root.Pass()); 4613 m_hostImpl->activeTree()->SetRootLayer(root.Pass());
4614 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); 4614 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize);
4615 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); 4615 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
4616 initializeRendererAndDrawFrame(); 4616 initializeRendererAndDrawFrame();
4617 4617
4618 // Set new page scale on impl thread by pinching. 4618 // Set new page scale on impl thread by pinching.
4619 m_hostImpl->pinchGestureBegin(); 4619 m_hostImpl->pinchGestureBegin();
4620 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); 4620 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point());
4621 m_hostImpl->pinchGestureEnd(); 4621 m_hostImpl->pinchGestureEnd();
4622 drawOneFrame(); 4622 drawOneFrame();
4623 4623
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
4726 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor); 4726 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor);
4727 4727
4728 gfx::Size layoutSurfaceSize(10, 20); 4728 gfx::Size layoutSurfaceSize(10, 20);
4729 gfx::Size deviceSurfaceSize(layoutSurfaceSize.width() * static_cast<int>(dev iceScaleFactor), 4729 gfx::Size deviceSurfaceSize(layoutSurfaceSize.width() * static_cast<int>(dev iceScaleFactor),
4730 layoutSurfaceSize.height() * static_cast<int>(de viceScaleFactor)); 4730 layoutSurfaceSize.height() * static_cast<int>(de viceScaleFactor));
4731 float pageScale = 2; 4731 float pageScale = 2;
4732 scoped_ptr<LayerImpl> root = createScrollableLayer(1, layoutSurfaceSize); 4732 scoped_ptr<LayerImpl> root = createScrollableLayer(1, layoutSurfaceSize);
4733 // For this test we want to scrolls to move both the document and the 4733 // For this test we want to scrolls to move both the document and the
4734 // pinchZoomViewport so we can see some scroll component on the implTransfor m. 4734 // pinchZoomViewport so we can see some scroll component on the implTransfor m.
4735 root->setMaxScrollOffset(gfx::Vector2d(3, 4)); 4735 root->setMaxScrollOffset(gfx::Vector2d(3, 4));
4736 m_hostImpl->setRootLayer(root.Pass()); 4736 m_hostImpl->activeTree()->SetRootLayer(root.Pass());
4737 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); 4737 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize);
4738 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); 4738 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
4739 initializeRendererAndDrawFrame(); 4739 initializeRendererAndDrawFrame();
4740 4740
4741 // Set new page scale on impl thread by pinching. 4741 // Set new page scale on impl thread by pinching.
4742 m_hostImpl->pinchGestureBegin(); 4742 m_hostImpl->pinchGestureBegin();
4743 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); 4743 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point());
4744 m_hostImpl->pinchGestureEnd(); 4744 m_hostImpl->pinchGestureEnd();
4745 drawOneFrame(); 4745 drawOneFrame();
4746 4746
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
4845 gfx::Rect noDamage = gfx::Rect(m_hostImpl->deviceViewportSize()); 4845 gfx::Rect noDamage = gfx::Rect(m_hostImpl->deviceViewportSize());
4846 drawFrameAndTestDamage(noDamage); 4846 drawFrameAndTestDamage(noDamage);
4847 } 4847 }
4848 4848
4849 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, 4849 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests,
4850 LayerTreeHostImplTest, 4850 LayerTreeHostImplTest,
4851 ::testing::Values(false, true)); 4851 ::testing::Values(false, true));
4852 4852
4853 } // namespace 4853 } // namespace
4854 } // namespace cc 4854 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698