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

Side by Side Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 1801853002: Transfer LayerImpl ownership to LayerTreeImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more asan. Created 4 years, 9 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
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 gfx::ScrollOffset delta = 228 gfx::ScrollOffset delta =
229 layer_impl->layer_tree_impl() 229 layer_impl->layer_tree_impl()
230 ->property_trees() 230 ->property_trees()
231 ->scroll_tree.GetScrollOffsetDeltaForTesting(layer_impl->id()); 231 ->scroll_tree.GetScrollOffsetDeltaForTesting(layer_impl->id());
232 return gfx::Vector2dF(delta.x(), delta.y()); 232 return gfx::Vector2dF(delta.x(), delta.y());
233 } 233 }
234 234
235 static void ExpectClearedScrollDeltasRecursive(LayerImpl* layer) { 235 static void ExpectClearedScrollDeltasRecursive(LayerImpl* layer) {
236 ASSERT_EQ(ScrollDelta(layer), gfx::Vector2d()); 236 ASSERT_EQ(ScrollDelta(layer), gfx::Vector2d());
237 for (size_t i = 0; i < layer->children().size(); ++i) 237 for (size_t i = 0; i < layer->children().size(); ++i)
238 ExpectClearedScrollDeltasRecursive(layer->children()[i].get()); 238 ExpectClearedScrollDeltasRecursive(layer->children()[i]);
239 } 239 }
240 240
241 static ::testing::AssertionResult ScrollInfoContains( 241 static ::testing::AssertionResult ScrollInfoContains(
242 const ScrollAndScaleSet& scroll_info, 242 const ScrollAndScaleSet& scroll_info,
243 int id, 243 int id,
244 const gfx::Vector2d& scroll_delta) { 244 const gfx::Vector2d& scroll_delta) {
245 int times_encountered = 0; 245 int times_encountered = 0;
246 246
247 for (size_t i = 0; i < scroll_info.scrolls.size(); ++i) { 247 for (size_t i = 0; i < scroll_info.scrolls.size(); ++i) {
248 if (scroll_info.scrolls[i].layer_id != id) 248 if (scroll_info.scrolls[i].layer_id != id)
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 // Sets up a typical virtual viewport setup with one child content layer. 360 // Sets up a typical virtual viewport setup with one child content layer.
361 // Returns a pointer to the content layer. 361 // Returns a pointer to the content layer.
362 LayerImpl* CreateBasicVirtualViewportLayers(const gfx::Size& viewport_size, 362 LayerImpl* CreateBasicVirtualViewportLayers(const gfx::Size& viewport_size,
363 const gfx::Size& content_size) { 363 const gfx::Size& content_size) {
364 // CreateScrollAndContentsLayers makes the outer viewport unscrollable and 364 // CreateScrollAndContentsLayers makes the outer viewport unscrollable and
365 // the inner a different size from the outer. We'll reuse its layer 365 // the inner a different size from the outer. We'll reuse its layer
366 // hierarchy but adjust the sizing to our needs. 366 // hierarchy but adjust the sizing to our needs.
367 CreateScrollAndContentsLayers(host_impl_->active_tree(), content_size); 367 CreateScrollAndContentsLayers(host_impl_->active_tree(), content_size);
368 368
369 LayerImpl* content_layer = 369 LayerImpl* content_layer =
370 host_impl_->OuterViewportScrollLayer()->children().back().get(); 370 host_impl_->OuterViewportScrollLayer()->children().back();
371 content_layer->SetBounds(content_size); 371 content_layer->SetBounds(content_size);
372 host_impl_->OuterViewportScrollLayer()->SetBounds(content_size); 372 host_impl_->OuterViewportScrollLayer()->SetBounds(content_size);
373 373
374 LayerImpl* outer_clip = host_impl_->OuterViewportScrollLayer()->parent(); 374 LayerImpl* outer_clip = host_impl_->OuterViewportScrollLayer()->parent();
375 outer_clip->SetBounds(viewport_size); 375 outer_clip->SetBounds(viewport_size);
376 376
377 LayerImpl* inner_clip_layer = 377 LayerImpl* inner_clip_layer =
378 host_impl_->InnerViewportScrollLayer()->parent()->parent(); 378 host_impl_->InnerViewportScrollLayer()->parent()->parent();
379 inner_clip_layer->SetBounds(viewport_size); 379 inner_clip_layer->SetBounds(viewport_size);
380 host_impl_->InnerViewportScrollLayer()->SetBounds(viewport_size); 380 host_impl_->InnerViewportScrollLayer()->SetBounds(viewport_size);
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 root_layer->SetScrollClipLayer(root_clip->id()); 621 root_layer->SetScrollClipLayer(root_clip->id());
622 root_layer->layer_tree_impl() 622 root_layer->layer_tree_impl()
623 ->property_trees() 623 ->property_trees()
624 ->scroll_tree.UpdateScrollOffsetBaseForTesting(root_layer->id(), 624 ->scroll_tree.UpdateScrollOffsetBaseForTesting(root_layer->id(),
625 scroll_offset); 625 scroll_offset);
626 host_impl_->active_tree()->SetRootLayer(std::move(root_clip)); 626 host_impl_->active_tree()->SetRootLayer(std::move(root_clip));
627 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 627 host_impl_->active_tree()->BuildPropertyTreesForTesting();
628 root_layer->ScrollBy(scroll_delta); 628 root_layer->ScrollBy(scroll_delta);
629 } 629 }
630 630
631 LayerImpl* root = 631 LayerImpl* root = host_impl_->active_tree()->root_layer()->children()[0];
632 host_impl_->active_tree()->root_layer()->children()[0].get();
633 632
634 scoped_ptr<ScrollAndScaleSet> scroll_info; 633 scoped_ptr<ScrollAndScaleSet> scroll_info;
635 634
636 scroll_info = host_impl_->ProcessScrollDeltas(); 635 scroll_info = host_impl_->ProcessScrollDeltas();
637 ASSERT_EQ(scroll_info->scrolls.size(), 1u); 636 ASSERT_EQ(scroll_info->scrolls.size(), 1u);
638 EXPECT_TRUE(ScrollInfoContains(*scroll_info, root->id(), scroll_delta)); 637 EXPECT_TRUE(ScrollInfoContains(*scroll_info, root->id(), scroll_delta));
639 638
640 gfx::Vector2d scroll_delta2(-5, 27); 639 gfx::Vector2d scroll_delta2(-5, 27);
641 root->ScrollBy(scroll_delta2); 640 root->ScrollBy(scroll_delta2);
642 scroll_info = host_impl_->ProcessScrollDeltas(); 641 scroll_info = host_impl_->ProcessScrollDeltas();
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 TEST_F(LayerTreeHostImplTest, ReplaceTreeWhileScrolling) { 723 TEST_F(LayerTreeHostImplTest, ReplaceTreeWhileScrolling) {
725 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); 724 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100));
726 host_impl_->SetViewportSize(gfx::Size(50, 50)); 725 host_impl_->SetViewportSize(gfx::Size(50, 50));
727 DrawFrame(); 726 DrawFrame();
728 727
729 // We should not crash if the tree is replaced while we are scrolling. 728 // We should not crash if the tree is replaced while we are scrolling.
730 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 729 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
731 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 730 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
732 InputHandler::WHEEL) 731 InputHandler::WHEEL)
733 .thread); 732 .thread);
734 host_impl_->active_tree()->DetachLayerTree(); 733 host_impl_->active_tree()->ClearLayers();
735 734
736 scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); 735 scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100));
737 736
738 // We should still be scrolling, because the scrolled layer also exists in the 737 // We should still be scrolling, because the scrolled layer also exists in the
739 // new tree. 738 // new tree.
740 gfx::Vector2d scroll_delta(0, 10); 739 gfx::Vector2d scroll_delta(0, 10);
741 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); 740 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get());
742 host_impl_->ScrollEnd(EndState().get()); 741 host_impl_->ScrollEnd(EndState().get());
743 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); 742 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas();
744 EXPECT_TRUE( 743 EXPECT_TRUE(
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 EXPECT_TRUE(host_impl_->ScrollVerticallyByPage( 1147 EXPECT_TRUE(host_impl_->ScrollVerticallyByPage(
1149 gfx::Point(), SCROLL_BACKWARD)); 1148 gfx::Point(), SCROLL_BACKWARD));
1150 } 1149 }
1151 1150
1152 TEST_F(LayerTreeHostImplTest, ScrollWithUserUnscrollableLayers) { 1151 TEST_F(LayerTreeHostImplTest, ScrollWithUserUnscrollableLayers) {
1153 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); 1152 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200));
1154 host_impl_->SetViewportSize(gfx::Size(100, 100)); 1153 host_impl_->SetViewportSize(gfx::Size(100, 100));
1155 1154
1156 gfx::Size overflow_size(400, 400); 1155 gfx::Size overflow_size(400, 400);
1157 ASSERT_EQ(1u, scroll_layer->children().size()); 1156 ASSERT_EQ(1u, scroll_layer->children().size());
1158 LayerImpl* overflow = scroll_layer->children()[0].get(); 1157 LayerImpl* overflow = scroll_layer->children()[0];
1159 overflow->SetBounds(overflow_size); 1158 overflow->SetBounds(overflow_size);
1160 overflow->SetScrollClipLayer(scroll_layer->parent()->parent()->id()); 1159 overflow->SetScrollClipLayer(scroll_layer->parent()->parent()->id());
1161 overflow->layer_tree_impl() 1160 overflow->layer_tree_impl()
1162 ->property_trees() 1161 ->property_trees()
1163 ->scroll_tree.UpdateScrollOffsetBaseForTesting(overflow->id(), 1162 ->scroll_tree.UpdateScrollOffsetBaseForTesting(overflow->id(),
1164 gfx::ScrollOffset()); 1163 gfx::ScrollOffset());
1165 overflow->SetPosition(gfx::PointF()); 1164 overflow->SetPosition(gfx::PointF());
1166 1165
1167 SetNeedsRebuildPropertyTrees(); 1166 SetNeedsRebuildPropertyTrees();
1168 DrawFrame(); 1167 DrawFrame();
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1220 host_impl_->SetViewportSize(gfx::Size(50, 50)); 1219 host_impl_->SetViewportSize(gfx::Size(50, 50));
1221 1220
1222 host_impl_->CreatePendingTree(); 1221 host_impl_->CreatePendingTree();
1223 host_impl_->pending_tree()->SetRootLayer( 1222 host_impl_->pending_tree()->SetRootLayer(
1224 LayerImpl::Create(host_impl_->pending_tree(), 1)); 1223 LayerImpl::Create(host_impl_->pending_tree(), 1));
1225 LayerImpl* root = host_impl_->pending_tree()->root_layer(); 1224 LayerImpl* root = host_impl_->pending_tree()->root_layer();
1226 root->SetBounds(gfx::Size(50, 50)); 1225 root->SetBounds(gfx::Size(50, 50));
1227 root->SetForceRenderSurface(true); 1226 root->SetForceRenderSurface(true);
1228 1227
1229 root->AddChild(LayerImpl::Create(host_impl_->pending_tree(), 2)); 1228 root->AddChild(LayerImpl::Create(host_impl_->pending_tree(), 2));
1230 LayerImpl* child = root->children()[0].get(); 1229 LayerImpl* child = root->children()[0];
1231 child->SetBounds(gfx::Size(10, 10)); 1230 child->SetBounds(gfx::Size(10, 10));
1232 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); 1231 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10);
1233 child->SetDrawsContent(true); 1232 child->SetDrawsContent(true);
1234 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 10.0, 3, 0); 1233 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 10.0, 3, 0);
1235 1234
1236 EXPECT_FALSE(did_request_next_frame_); 1235 EXPECT_FALSE(did_request_next_frame_);
1237 EXPECT_FALSE(did_request_redraw_); 1236 EXPECT_FALSE(did_request_redraw_);
1238 EXPECT_FALSE(did_request_commit_); 1237 EXPECT_FALSE(did_request_commit_);
1239 1238
1240 host_impl_->AnimatePendingTreeAfterCommit(); 1239 host_impl_->AnimatePendingTreeAfterCommit();
(...skipping 29 matching lines...) Expand all
1270 1269
1271 host_impl_->SetViewportSize(gfx::Size(50, 50)); 1270 host_impl_->SetViewportSize(gfx::Size(50, 50));
1272 1271
1273 host_impl_->active_tree()->SetRootLayer( 1272 host_impl_->active_tree()->SetRootLayer(
1274 LayerImpl::Create(host_impl_->active_tree(), 1)); 1273 LayerImpl::Create(host_impl_->active_tree(), 1));
1275 LayerImpl* root = host_impl_->active_tree()->root_layer(); 1274 LayerImpl* root = host_impl_->active_tree()->root_layer();
1276 root->SetBounds(gfx::Size(50, 50)); 1275 root->SetBounds(gfx::Size(50, 50));
1277 root->SetForceRenderSurface(true); 1276 root->SetForceRenderSurface(true);
1278 1277
1279 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); 1278 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2));
1280 LayerImpl* child = root->children()[0].get(); 1279 LayerImpl* child = root->children()[0];
1281 child->SetBounds(gfx::Size(10, 10)); 1280 child->SetBounds(gfx::Size(10, 10));
1282 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); 1281 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10);
1283 child->SetDrawsContent(true); 1282 child->SetDrawsContent(true);
1284 1283
1285 // Add a translate from 6,7 to 8,9. 1284 // Add a translate from 6,7 to 8,9.
1286 TransformOperations start; 1285 TransformOperations start;
1287 start.AppendTranslate(6.f, 7.f, 0.f); 1286 start.AppendTranslate(6.f, 7.f, 0.f);
1288 TransformOperations end; 1287 TransformOperations end;
1289 end.AppendTranslate(8.f, 9.f, 0.f); 1288 end.AppendTranslate(8.f, 9.f, 0.f);
1290 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 4.0, start, 1289 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 4.0, start,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1334 1333
1335 host_impl_->SetViewportSize(gfx::Size(50, 50)); 1334 host_impl_->SetViewportSize(gfx::Size(50, 50));
1336 1335
1337 host_impl_->active_tree()->SetRootLayer( 1336 host_impl_->active_tree()->SetRootLayer(
1338 LayerImpl::Create(host_impl_->active_tree(), 1)); 1337 LayerImpl::Create(host_impl_->active_tree(), 1));
1339 LayerImpl* root = host_impl_->active_tree()->root_layer(); 1338 LayerImpl* root = host_impl_->active_tree()->root_layer();
1340 root->SetBounds(gfx::Size(50, 50)); 1339 root->SetBounds(gfx::Size(50, 50));
1341 root->SetHasRenderSurface(true); 1340 root->SetHasRenderSurface(true);
1342 1341
1343 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); 1342 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2));
1344 LayerImpl* child = root->children()[0].get(); 1343 LayerImpl* child = root->children()[0];
1345 child->SetBounds(gfx::Size(10, 10)); 1344 child->SetBounds(gfx::Size(10, 10));
1346 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); 1345 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10);
1347 child->SetDrawsContent(true); 1346 child->SetDrawsContent(true);
1348 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 10.0, 3, 0); 1347 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 10.0, 3, 0);
1349 1348
1350 // Set up the property trees so that UpdateDrawProperties will work in 1349 // Set up the property trees so that UpdateDrawProperties will work in
1351 // CommitComplete below. 1350 // CommitComplete below.
1352 LayerImplList list; 1351 LayerImplList list;
1353 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1352 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1354 root, gfx::Size(50, 50), &list, 0); 1353 root, gfx::Size(50, 50), &list, 0);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1393 1392
1394 host_impl_->active_tree()->SetRootLayer( 1393 host_impl_->active_tree()->SetRootLayer(
1395 LayerImpl::Create(host_impl_->active_tree(), 1)); 1394 LayerImpl::Create(host_impl_->active_tree(), 1));
1396 LayerImpl* root = host_impl_->active_tree()->root_layer(); 1395 LayerImpl* root = host_impl_->active_tree()->root_layer();
1397 root->SetBounds(gfx::Size(50, 50)); 1396 root->SetBounds(gfx::Size(50, 50));
1398 root->SetHasRenderSurface(true); 1397 root->SetHasRenderSurface(true);
1399 1398
1400 root->AddChild(scoped_ptr<MissingTilesLayer>( 1399 root->AddChild(scoped_ptr<MissingTilesLayer>(
1401 new MissingTilesLayer(host_impl_->active_tree(), 2))); 1400 new MissingTilesLayer(host_impl_->active_tree(), 2)));
1402 MissingTilesLayer* child = 1401 MissingTilesLayer* child =
1403 static_cast<MissingTilesLayer*>(root->children()[0].get()); 1402 static_cast<MissingTilesLayer*>(root->children()[0]);
1404 child->SetBounds(gfx::Size(10, 10)); 1403 child->SetBounds(gfx::Size(10, 10));
1405 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); 1404 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10);
1406 child->SetDrawsContent(true); 1405 child->SetDrawsContent(true);
1407 1406
1408 EXPECT_TRUE(child->was_ever_ready_since_last_transform_animation()); 1407 EXPECT_TRUE(child->was_ever_ready_since_last_transform_animation());
1409 1408
1410 // Add a translate from 6,7 to 8,9. 1409 // Add a translate from 6,7 to 8,9.
1411 TransformOperations start; 1410 TransformOperations start;
1412 start.AppendTranslate(6.f, 7.f, 0.f); 1411 start.AppendTranslate(6.f, 7.f, 0.f);
1413 TransformOperations end; 1412 TransformOperations end;
(...skipping 1840 matching lines...) Expand 10 before | Expand all | Expand 10 after
3254 // The root layer is always drawn, so run this test on a child layer that 3253 // The root layer is always drawn, so run this test on a child layer that
3255 // will be masked out by the root layer's bounds. 3254 // will be masked out by the root layer's bounds.
3256 host_impl_->active_tree()->SetRootLayer( 3255 host_impl_->active_tree()->SetRootLayer(
3257 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); 3256 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1));
3258 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( 3257 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(
3259 host_impl_->active_tree()->root_layer()); 3258 host_impl_->active_tree()->root_layer());
3260 3259
3261 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); 3260 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2));
3262 root->SetForceRenderSurface(true); 3261 root->SetForceRenderSurface(true);
3263 DidDrawCheckLayer* layer = 3262 DidDrawCheckLayer* layer =
3264 static_cast<DidDrawCheckLayer*>(root->children()[0].get()); 3263 static_cast<DidDrawCheckLayer*>(root->children()[0]);
3265 3264
3266 { 3265 {
3267 LayerTreeHostImpl::FrameData frame; 3266 LayerTreeHostImpl::FrameData frame;
3268 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); 3267 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame));
3269 host_impl_->DrawLayers(&frame); 3268 host_impl_->DrawLayers(&frame);
3270 host_impl_->DidDrawAllLayers(frame); 3269 host_impl_->DidDrawAllLayers(frame);
3271 3270
3272 EXPECT_TRUE(layer->will_draw_called()); 3271 EXPECT_TRUE(layer->will_draw_called());
3273 EXPECT_TRUE(layer->append_quads_called()); 3272 EXPECT_TRUE(layer->append_quads_called());
3274 EXPECT_TRUE(layer->did_draw_called()); 3273 EXPECT_TRUE(layer->did_draw_called());
(...skipping 21 matching lines...) Expand all
3296 // The root layer is always drawn, so run this test on a child layer that 3295 // The root layer is always drawn, so run this test on a child layer that
3297 // will be masked out by the root layer's bounds. 3296 // will be masked out by the root layer's bounds.
3298 host_impl_->active_tree()->SetRootLayer( 3297 host_impl_->active_tree()->SetRootLayer(
3299 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); 3298 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1));
3300 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( 3299 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(
3301 host_impl_->active_tree()->root_layer()); 3300 host_impl_->active_tree()->root_layer());
3302 root->SetMasksToBounds(true); 3301 root->SetMasksToBounds(true);
3303 root->SetForceRenderSurface(true); 3302 root->SetForceRenderSurface(true);
3304 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); 3303 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2));
3305 DidDrawCheckLayer* layer = 3304 DidDrawCheckLayer* layer =
3306 static_cast<DidDrawCheckLayer*>(root->children()[0].get()); 3305 static_cast<DidDrawCheckLayer*>(root->children()[0]);
3307 // Ensure visible_layer_rect for layer is empty. 3306 // Ensure visible_layer_rect for layer is empty.
3308 layer->SetPosition(gfx::PointF(100.f, 100.f)); 3307 layer->SetPosition(gfx::PointF(100.f, 100.f));
3309 layer->SetBounds(gfx::Size(10, 10)); 3308 layer->SetBounds(gfx::Size(10, 10));
3310 3309
3311 LayerTreeHostImpl::FrameData frame; 3310 LayerTreeHostImpl::FrameData frame;
3312 3311
3313 EXPECT_FALSE(layer->will_draw_called()); 3312 EXPECT_FALSE(layer->will_draw_called());
3314 EXPECT_FALSE(layer->did_draw_called()); 3313 EXPECT_FALSE(layer->did_draw_called());
3315 3314
3316 SetNeedsRebuildPropertyTrees(); 3315 SetNeedsRebuildPropertyTrees();
(...skipping 28 matching lines...) Expand all
3345 gfx::Size big_size(1000, 1000); 3344 gfx::Size big_size(1000, 1000);
3346 host_impl_->SetViewportSize(big_size); 3345 host_impl_->SetViewportSize(big_size);
3347 3346
3348 host_impl_->active_tree()->SetRootLayer( 3347 host_impl_->active_tree()->SetRootLayer(
3349 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); 3348 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1));
3350 DidDrawCheckLayer* root = 3349 DidDrawCheckLayer* root =
3351 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 3350 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
3352 3351
3353 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); 3352 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2));
3354 DidDrawCheckLayer* occluded_layer = 3353 DidDrawCheckLayer* occluded_layer =
3355 static_cast<DidDrawCheckLayer*>(root->children()[0].get()); 3354 static_cast<DidDrawCheckLayer*>(root->children()[0]);
3356 3355
3357 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); 3356 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3));
3358 root->SetForceRenderSurface(true); 3357 root->SetForceRenderSurface(true);
3359 DidDrawCheckLayer* top_layer = 3358 DidDrawCheckLayer* top_layer =
3360 static_cast<DidDrawCheckLayer*>(root->children()[1].get()); 3359 static_cast<DidDrawCheckLayer*>(root->children()[1]);
3361 // This layer covers the occluded_layer above. Make this layer large so it can 3360 // This layer covers the occluded_layer above. Make this layer large so it can
3362 // occlude. 3361 // occlude.
3363 top_layer->SetBounds(big_size); 3362 top_layer->SetBounds(big_size);
3364 top_layer->SetContentsOpaque(true); 3363 top_layer->SetContentsOpaque(true);
3365 3364
3366 LayerTreeHostImpl::FrameData frame; 3365 LayerTreeHostImpl::FrameData frame;
3367 3366
3368 EXPECT_FALSE(occluded_layer->will_draw_called()); 3367 EXPECT_FALSE(occluded_layer->will_draw_called());
3369 EXPECT_FALSE(occluded_layer->did_draw_called()); 3368 EXPECT_FALSE(occluded_layer->did_draw_called());
3370 EXPECT_FALSE(top_layer->will_draw_called()); 3369 EXPECT_FALSE(top_layer->will_draw_called());
(...skipping 11 matching lines...) Expand all
3382 3381
3383 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { 3382 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) {
3384 host_impl_->active_tree()->SetRootLayer( 3383 host_impl_->active_tree()->SetRootLayer(
3385 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); 3384 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1));
3386 DidDrawCheckLayer* root = 3385 DidDrawCheckLayer* root =
3387 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 3386 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
3388 3387
3389 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); 3388 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2));
3390 root->SetForceRenderSurface(true); 3389 root->SetForceRenderSurface(true);
3391 DidDrawCheckLayer* layer1 = 3390 DidDrawCheckLayer* layer1 =
3392 static_cast<DidDrawCheckLayer*>(root->children()[0].get()); 3391 static_cast<DidDrawCheckLayer*>(root->children()[0]);
3393 3392
3394 layer1->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); 3393 layer1->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3));
3395 DidDrawCheckLayer* layer2 = 3394 DidDrawCheckLayer* layer2 =
3396 static_cast<DidDrawCheckLayer*>(layer1->children()[0].get()); 3395 static_cast<DidDrawCheckLayer*>(layer1->children()[0]);
3397 3396
3398 layer1->SetForceRenderSurface(true); 3397 layer1->SetForceRenderSurface(true);
3399 layer1->SetShouldFlattenTransform(true); 3398 layer1->SetShouldFlattenTransform(true);
3400 3399
3401 EXPECT_FALSE(root->did_draw_called()); 3400 EXPECT_FALSE(root->did_draw_called());
3402 EXPECT_FALSE(layer1->did_draw_called()); 3401 EXPECT_FALSE(layer1->did_draw_called());
3403 EXPECT_FALSE(layer2->did_draw_called()); 3402 EXPECT_FALSE(layer2->did_draw_called());
3404 3403
3405 LayerTreeHostImpl::FrameData frame; 3404 LayerTreeHostImpl::FrameData frame;
3406 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( 3405 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
3559 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); 3558 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame));
3560 host_impl_->DrawLayers(&frame); 3559 host_impl_->DrawLayers(&frame);
3561 host_impl_->DidDrawAllLayers(frame); 3560 host_impl_->DidDrawAllLayers(frame);
3562 host_impl_->SwapBuffers(frame); 3561 host_impl_->SwapBuffers(frame);
3563 3562
3564 for (size_t i = 0; i < cases.size(); ++i) { 3563 for (size_t i = 0; i < cases.size(); ++i) {
3565 // Clean up host_impl_ state. 3564 // Clean up host_impl_ state.
3566 const auto& testcase = cases[i]; 3565 const auto& testcase = cases[i];
3567 std::vector<LayerImpl*> to_remove; 3566 std::vector<LayerImpl*> to_remove;
3568 for (const auto& child : root->children()) 3567 for (const auto& child : root->children())
3569 to_remove.push_back(child.get()); 3568 to_remove.push_back(child);
3570 for (auto* child : to_remove) 3569 for (auto* child : to_remove)
3571 root->RemoveChild(child); 3570 root->RemoveChild(child);
3572 timeline()->ClearPlayers(); 3571 timeline()->ClearPlayers();
3573 3572
3574 std::ostringstream scope; 3573 std::ostringstream scope;
3575 scope << "Test case: " << i; 3574 scope << "Test case: " << i;
3576 SCOPED_TRACE(scope.str()); 3575 SCOPED_TRACE(scope.str());
3577 3576
3578 root->AddChild(MissingTextureAnimatingLayer::Create( 3577 root->AddChild(MissingTextureAnimatingLayer::Create(
3579 host_impl_->active_tree(), 2, testcase.layer_before.has_missing_tile, 3578 host_impl_->active_tree(), 2, testcase.layer_before.has_missing_tile,
3580 testcase.layer_before.has_incomplete_tile, 3579 testcase.layer_before.has_incomplete_tile,
3581 testcase.layer_before.is_animating, host_impl_->resource_provider(), 3580 testcase.layer_before.is_animating, host_impl_->resource_provider(),
3582 timeline())); 3581 timeline()));
3583 DidDrawCheckLayer* before = 3582 DidDrawCheckLayer* before =
3584 static_cast<DidDrawCheckLayer*>(root->children().back().get()); 3583 static_cast<DidDrawCheckLayer*>(root->children().back());
3585 if (testcase.layer_before.has_copy_request) 3584 if (testcase.layer_before.has_copy_request)
3586 before->AddCopyRequest(); 3585 before->AddCopyRequest();
3587 3586
3588 root->AddChild(MissingTextureAnimatingLayer::Create( 3587 root->AddChild(MissingTextureAnimatingLayer::Create(
3589 host_impl_->active_tree(), 3, testcase.layer_between.has_missing_tile, 3588 host_impl_->active_tree(), 3, testcase.layer_between.has_missing_tile,
3590 testcase.layer_between.has_incomplete_tile, 3589 testcase.layer_between.has_incomplete_tile,
3591 testcase.layer_between.is_animating, host_impl_->resource_provider(), 3590 testcase.layer_between.is_animating, host_impl_->resource_provider(),
3592 timeline())); 3591 timeline()));
3593 DidDrawCheckLayer* between = 3592 DidDrawCheckLayer* between =
3594 static_cast<DidDrawCheckLayer*>(root->children().back().get()); 3593 static_cast<DidDrawCheckLayer*>(root->children().back());
3595 if (testcase.layer_between.has_copy_request) 3594 if (testcase.layer_between.has_copy_request)
3596 between->AddCopyRequest(); 3595 between->AddCopyRequest();
3597 3596
3598 root->AddChild(MissingTextureAnimatingLayer::Create( 3597 root->AddChild(MissingTextureAnimatingLayer::Create(
3599 host_impl_->active_tree(), 4, testcase.layer_after.has_missing_tile, 3598 host_impl_->active_tree(), 4, testcase.layer_after.has_missing_tile,
3600 testcase.layer_after.has_incomplete_tile, 3599 testcase.layer_after.has_incomplete_tile,
3601 testcase.layer_after.is_animating, host_impl_->resource_provider(), 3600 testcase.layer_after.is_animating, host_impl_->resource_provider(),
3602 timeline())); 3601 timeline()));
3603 DidDrawCheckLayer* after = 3602 DidDrawCheckLayer* after =
3604 static_cast<DidDrawCheckLayer*>(root->children().back().get()); 3603 static_cast<DidDrawCheckLayer*>(root->children().back());
3605 if (testcase.layer_after.has_copy_request) 3604 if (testcase.layer_after.has_copy_request)
3606 after->AddCopyRequest(); 3605 after->AddCopyRequest();
3607 3606
3608 if (testcase.high_res_required) 3607 if (testcase.high_res_required)
3609 host_impl_->SetRequiresHighResToDraw(); 3608 host_impl_->SetRequiresHighResToDraw();
3610 3609
3611 LayerTreeHostImpl::FrameData frame; 3610 LayerTreeHostImpl::FrameData frame;
3612 SetNeedsRebuildPropertyTrees(); 3611 SetNeedsRebuildPropertyTrees();
3613 EXPECT_EQ(testcase.expected_result, PrepareToDrawFrame(&frame)); 3612 EXPECT_EQ(testcase.expected_result, PrepareToDrawFrame(&frame));
3614 host_impl_->DrawLayers(&frame); 3613 host_impl_->DrawLayers(&frame);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
3654 root->SetForceRenderSurface(true); 3653 root->SetForceRenderSurface(true);
3655 3654
3656 SetNeedsRebuildPropertyTrees(); 3655 SetNeedsRebuildPropertyTrees();
3657 host_impl_->OnDraw(external_transform, external_viewport, external_clip, 3656 host_impl_->OnDraw(external_transform, external_viewport, external_clip,
3658 resourceless_software_draw); 3657 resourceless_software_draw);
3659 3658
3660 for (size_t i = 0; i < cases.size(); ++i) { 3659 for (size_t i = 0; i < cases.size(); ++i) {
3661 const auto& testcase = cases[i]; 3660 const auto& testcase = cases[i];
3662 std::vector<LayerImpl*> to_remove; 3661 std::vector<LayerImpl*> to_remove;
3663 for (const auto& child : root->children()) 3662 for (const auto& child : root->children())
3664 to_remove.push_back(child.get()); 3663 to_remove.push_back(child);
3665 for (auto* child : to_remove) 3664 for (auto* child : to_remove)
3666 root->RemoveChild(child); 3665 root->RemoveChild(child);
3667 3666
3668 std::ostringstream scope; 3667 std::ostringstream scope;
3669 scope << "Test case: " << i; 3668 scope << "Test case: " << i;
3670 SCOPED_TRACE(scope.str()); 3669 SCOPED_TRACE(scope.str());
3671 3670
3672 root->AddChild(MissingTextureAnimatingLayer::Create( 3671 root->AddChild(MissingTextureAnimatingLayer::Create(
3673 host_impl_->active_tree(), 2, testcase.layer_before.has_missing_tile, 3672 host_impl_->active_tree(), 2, testcase.layer_before.has_missing_tile,
3674 testcase.layer_before.has_incomplete_tile, 3673 testcase.layer_before.has_incomplete_tile,
3675 testcase.layer_before.is_animating, host_impl_->resource_provider(), 3674 testcase.layer_before.is_animating, host_impl_->resource_provider(),
3676 timeline())); 3675 timeline()));
3677 DidDrawCheckLayer* before = 3676 DidDrawCheckLayer* before =
3678 static_cast<DidDrawCheckLayer*>(root->children().back().get()); 3677 static_cast<DidDrawCheckLayer*>(root->children().back());
3679 if (testcase.layer_before.has_copy_request) 3678 if (testcase.layer_before.has_copy_request)
3680 before->AddCopyRequest(); 3679 before->AddCopyRequest();
3681 3680
3682 root->AddChild(MissingTextureAnimatingLayer::Create( 3681 root->AddChild(MissingTextureAnimatingLayer::Create(
3683 host_impl_->active_tree(), 3, testcase.layer_between.has_missing_tile, 3682 host_impl_->active_tree(), 3, testcase.layer_between.has_missing_tile,
3684 testcase.layer_between.has_incomplete_tile, 3683 testcase.layer_between.has_incomplete_tile,
3685 testcase.layer_between.is_animating, host_impl_->resource_provider(), 3684 testcase.layer_between.is_animating, host_impl_->resource_provider(),
3686 timeline())); 3685 timeline()));
3687 DidDrawCheckLayer* between = 3686 DidDrawCheckLayer* between =
3688 static_cast<DidDrawCheckLayer*>(root->children().back().get()); 3687 static_cast<DidDrawCheckLayer*>(root->children().back());
3689 if (testcase.layer_between.has_copy_request) 3688 if (testcase.layer_between.has_copy_request)
3690 between->AddCopyRequest(); 3689 between->AddCopyRequest();
3691 3690
3692 root->AddChild(MissingTextureAnimatingLayer::Create( 3691 root->AddChild(MissingTextureAnimatingLayer::Create(
3693 host_impl_->active_tree(), 4, testcase.layer_after.has_missing_tile, 3692 host_impl_->active_tree(), 4, testcase.layer_after.has_missing_tile,
3694 testcase.layer_after.has_incomplete_tile, 3693 testcase.layer_after.has_incomplete_tile,
3695 testcase.layer_after.is_animating, host_impl_->resource_provider(), 3694 testcase.layer_after.is_animating, host_impl_->resource_provider(),
3696 timeline())); 3695 timeline()));
3697 DidDrawCheckLayer* after = 3696 DidDrawCheckLayer* after =
3698 static_cast<DidDrawCheckLayer*>(root->children().back().get()); 3697 static_cast<DidDrawCheckLayer*>(root->children().back());
3699 if (testcase.layer_after.has_copy_request) 3698 if (testcase.layer_after.has_copy_request)
3700 after->AddCopyRequest(); 3699 after->AddCopyRequest();
3701 3700
3702 if (testcase.high_res_required) 3701 if (testcase.high_res_required)
3703 host_impl_->SetRequiresHighResToDraw(); 3702 host_impl_->SetRequiresHighResToDraw();
3704 3703
3705 SetNeedsRebuildPropertyTrees(); 3704 SetNeedsRebuildPropertyTrees();
3706 host_impl_->OnDraw(external_transform, external_viewport, external_clip, 3705 host_impl_->OnDraw(external_transform, external_viewport, external_clip,
3707 resourceless_software_draw); 3706 resourceless_software_draw);
3708 } 3707 }
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
3848 HidingTopControlsExpandsScrollableSize) { 3847 HidingTopControlsExpandsScrollableSize) {
3849 SetupTopControlsAndScrollLayerWithVirtualViewport( 3848 SetupTopControlsAndScrollLayerWithVirtualViewport(
3850 gfx::Size(50, 50), gfx::Size(50, 50), gfx::Size(50, 50)); 3849 gfx::Size(50, 50), gfx::Size(50, 50), gfx::Size(50, 50));
3851 3850
3852 LayerTreeImpl* active_tree = host_impl_->active_tree(); 3851 LayerTreeImpl* active_tree = host_impl_->active_tree();
3853 3852
3854 // Create a content layer beneath the outer viewport scroll layer. 3853 // Create a content layer beneath the outer viewport scroll layer.
3855 int id = host_impl_->OuterViewportScrollLayer()->id(); 3854 int id = host_impl_->OuterViewportScrollLayer()->id();
3856 host_impl_->OuterViewportScrollLayer()->AddChild( 3855 host_impl_->OuterViewportScrollLayer()->AddChild(
3857 LayerImpl::Create(host_impl_->active_tree(), id + 2)); 3856 LayerImpl::Create(host_impl_->active_tree(), id + 2));
3858 LayerImpl* content = 3857 LayerImpl* content = active_tree->OuterViewportScrollLayer()->children()[0];
3859 active_tree->OuterViewportScrollLayer()->children()[0].get();
3860 content->SetBounds(gfx::Size(50, 50)); 3858 content->SetBounds(gfx::Size(50, 50));
3861 3859
3862 SetNeedsRebuildPropertyTrees(); 3860 SetNeedsRebuildPropertyTrees();
3863 DrawFrame(); 3861 DrawFrame();
3864 3862
3865 LayerImpl* inner_container = active_tree->InnerViewportContainerLayer(); 3863 LayerImpl* inner_container = active_tree->InnerViewportContainerLayer();
3866 LayerImpl* outer_container = active_tree->OuterViewportContainerLayer(); 3864 LayerImpl* outer_container = active_tree->OuterViewportContainerLayer();
3867 3865
3868 // The top controls should start off showing so the viewport should be shrunk. 3866 // The top controls should start off showing so the viewport should be shrunk.
3869 ASSERT_EQ(gfx::Size(50, 50), inner_container->bounds()); 3867 ASSERT_EQ(gfx::Size(50, 50), inner_container->bounds());
(...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after
4770 default_page_scale_matrix.Scale(default_page_scale, default_page_scale); 4768 default_page_scale_matrix.Scale(default_page_scale, default_page_scale);
4771 4769
4772 float new_page_scale = 2.f; 4770 float new_page_scale = 2.f;
4773 gfx::Transform new_page_scale_matrix; 4771 gfx::Transform new_page_scale_matrix;
4774 new_page_scale_matrix.Scale(new_page_scale, new_page_scale); 4772 new_page_scale_matrix.Scale(new_page_scale, new_page_scale);
4775 4773
4776 // Create a normal scrollable root layer and another scrollable child layer. 4774 // Create a normal scrollable root layer and another scrollable child layer.
4777 LayerImpl* scroll = SetupScrollAndContentsLayers(surface_size); 4775 LayerImpl* scroll = SetupScrollAndContentsLayers(surface_size);
4778 scroll->SetDrawsContent(true); 4776 scroll->SetDrawsContent(true);
4779 LayerImpl* root = host_impl_->active_tree()->root_layer(); 4777 LayerImpl* root = host_impl_->active_tree()->root_layer();
4780 LayerImpl* child = scroll->children()[0].get(); 4778 LayerImpl* child = scroll->children()[0];
4781 child->SetDrawsContent(true); 4779 child->SetDrawsContent(true);
4782 4780
4783 scoped_ptr<LayerImpl> scrollable_child_clip = 4781 scoped_ptr<LayerImpl> scrollable_child_clip =
4784 LayerImpl::Create(host_impl_->active_tree(), 6); 4782 LayerImpl::Create(host_impl_->active_tree(), 6);
4785 scoped_ptr<LayerImpl> scrollable_child = 4783 scoped_ptr<LayerImpl> scrollable_child =
4786 CreateScrollableLayer(7, surface_size, scrollable_child_clip.get()); 4784 CreateScrollableLayer(7, surface_size, scrollable_child_clip.get());
4787 scrollable_child_clip->AddChild(std::move(scrollable_child)); 4785 scrollable_child_clip->AddChild(std::move(scrollable_child));
4788 child->AddChild(std::move(scrollable_child_clip)); 4786 child->AddChild(std::move(scrollable_child_clip));
4789 LayerImpl* grand_child = child->children()[0].get(); 4787 LayerImpl* grand_child = child->children()[0];
4790 grand_child->SetDrawsContent(true); 4788 grand_child->SetDrawsContent(true);
4791 4789
4792 // Set new page scale on impl thread by pinching. 4790 // Set new page scale on impl thread by pinching.
4793 SetNeedsRebuildPropertyTrees(); 4791 SetNeedsRebuildPropertyTrees();
4794 RebuildPropertyTrees(); 4792 RebuildPropertyTrees();
4795 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 4793 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
4796 InputHandler::TOUCHSCREEN); 4794 InputHandler::TOUCHSCREEN);
4797 host_impl_->PinchGestureBegin(); 4795 host_impl_->PinchGestureBegin();
4798 host_impl_->PinchGestureUpdate(new_page_scale, gfx::Point()); 4796 host_impl_->PinchGestureUpdate(new_page_scale, gfx::Point());
4799 host_impl_->PinchGestureEnd(); 4797 host_impl_->PinchGestureEnd();
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
4896 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 4894 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
4897 InputHandler::WHEEL) 4895 InputHandler::WHEEL)
4898 .thread); 4896 .thread);
4899 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); 4897 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get());
4900 host_impl_->ScrollEnd(EndState().get()); 4898 host_impl_->ScrollEnd(EndState().get());
4901 4899
4902 scoped_ptr<ScrollAndScaleSet> scroll_info = 4900 scoped_ptr<ScrollAndScaleSet> scroll_info =
4903 host_impl_->ProcessScrollDeltas(); 4901 host_impl_->ProcessScrollDeltas();
4904 4902
4905 // The grand child should have scrolled up to its limit. 4903 // The grand child should have scrolled up to its limit.
4906 LayerImpl* child = 4904 LayerImpl* child = host_impl_->active_tree()->root_layer()->children()[0];
4907 host_impl_->active_tree()->root_layer()->children()[0].get(); 4905 LayerImpl* grand_child = child->children()[0];
4908 LayerImpl* grand_child = child->children()[0].get();
4909 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), 4906 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(),
4910 gfx::Vector2d(0, -5))); 4907 gfx::Vector2d(0, -5)));
4911 4908
4912 // The child should not have scrolled. 4909 // The child should not have scrolled.
4913 ExpectNone(*scroll_info.get(), child->id()); 4910 ExpectNone(*scroll_info.get(), child->id());
4914 } 4911 }
4915 } 4912 }
4916 4913
4917 TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) { 4914 TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) {
4918 // Scroll a child layer beyond its maximum scroll range and make sure the 4915 // Scroll a child layer beyond its maximum scroll range and make sure the
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
4968 host_impl_->ScrollEnd(EndState().get()); 4965 host_impl_->ScrollEnd(EndState().get());
4969 4966
4970 scoped_ptr<ScrollAndScaleSet> scroll_info = 4967 scoped_ptr<ScrollAndScaleSet> scroll_info =
4971 host_impl_->ProcessScrollDeltas(); 4968 host_impl_->ProcessScrollDeltas();
4972 4969
4973 // The grand child should have scrolled up to its limit. 4970 // The grand child should have scrolled up to its limit.
4974 LayerImpl* child = host_impl_->active_tree() 4971 LayerImpl* child = host_impl_->active_tree()
4975 ->root_layer() 4972 ->root_layer()
4976 ->children()[0] 4973 ->children()[0]
4977 ->children()[0] 4974 ->children()[0]
4978 ->children()[0] 4975 ->children()[0];
4979 .get(); 4976 LayerImpl* grand_child = child->children()[0];
4980 LayerImpl* grand_child = child->children()[0].get();
4981 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), 4977 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(),
4982 gfx::Vector2d(0, -2))); 4978 gfx::Vector2d(0, -2)));
4983 4979
4984 // The child should not have scrolled. 4980 // The child should not have scrolled.
4985 ExpectNone(*scroll_info.get(), child->id()); 4981 ExpectNone(*scroll_info.get(), child->id());
4986 4982
4987 // The next time we scroll we should only scroll the parent. 4983 // The next time we scroll we should only scroll the parent.
4988 scroll_delta = gfx::Vector2d(0, -3); 4984 scroll_delta = gfx::Vector2d(0, -3);
4989 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 4985 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
4990 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), 4986 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(),
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
5112 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr)); 5108 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr));
5113 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, 5109 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3,
5114 Layer::INVALID_ID); 5110 Layer::INVALID_ID);
5115 host_impl_->active_tree()->DidBecomeActive(); 5111 host_impl_->active_tree()->DidBecomeActive();
5116 host_impl_->SetViewportSize(surface_size); 5112 host_impl_->SetViewportSize(surface_size);
5117 5113
5118 // Draw one frame and then immediately rebuild the layer tree to mimic a tree 5114 // Draw one frame and then immediately rebuild the layer tree to mimic a tree
5119 // synchronization. 5115 // synchronization.
5120 SetNeedsRebuildPropertyTrees(); 5116 SetNeedsRebuildPropertyTrees();
5121 DrawFrame(); 5117 DrawFrame();
5122 host_impl_->active_tree()->DetachLayerTree(); 5118 host_impl_->active_tree()->ClearLayers();
5123 scoped_ptr<LayerImpl> root_ptr2 = 5119 scoped_ptr<LayerImpl> root_ptr2 =
5124 LayerImpl::Create(host_impl_->active_tree(), 4); 5120 LayerImpl::Create(host_impl_->active_tree(), 4);
5125 scoped_ptr<LayerImpl> root_clip2 = 5121 scoped_ptr<LayerImpl> root_clip2 =
5126 LayerImpl::Create(host_impl_->active_tree(), 5); 5122 LayerImpl::Create(host_impl_->active_tree(), 5);
5127 scoped_ptr<LayerImpl> root_scroll2 = 5123 scoped_ptr<LayerImpl> root_scroll2 =
5128 CreateScrollableLayer(6, surface_size, root_clip2.get()); 5124 CreateScrollableLayer(6, surface_size, root_clip2.get());
5129 root_scroll2->SetIsContainerForFixedPositionLayers(true); 5125 root_scroll2->SetIsContainerForFixedPositionLayers(true);
5130 root_clip2->AddChild(std::move(root_scroll2)); 5126 root_clip2->AddChild(std::move(root_scroll2));
5131 root_clip2->SetForceRenderSurface(true); 5127 root_clip2->SetForceRenderSurface(true);
5132 root_ptr2->AddChild(std::move(root_clip2)); 5128 root_ptr2->AddChild(std::move(root_clip2));
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after
6044 root->SetForceRenderSurface(true); 6040 root->SetForceRenderSurface(true);
6045 host_impl_->active_tree()->SetRootLayer(std::move(root)); 6041 host_impl_->active_tree()->SetRootLayer(std::move(root));
6046 } 6042 }
6047 LayerImpl* root = host_impl_->active_tree()->root_layer(); 6043 LayerImpl* root = host_impl_->active_tree()->root_layer();
6048 6044
6049 root->AddChild( 6045 root->AddChild(
6050 BlendStateCheckLayer::Create(host_impl_->active_tree(), 6046 BlendStateCheckLayer::Create(host_impl_->active_tree(),
6051 2, 6047 2,
6052 host_impl_->resource_provider())); 6048 host_impl_->resource_provider()));
6053 BlendStateCheckLayer* layer1 = 6049 BlendStateCheckLayer* layer1 =
6054 static_cast<BlendStateCheckLayer*>(root->children()[0].get()); 6050 static_cast<BlendStateCheckLayer*>(root->children()[0]);
6055 layer1->SetPosition(gfx::PointF(2.f, 2.f)); 6051 layer1->SetPosition(gfx::PointF(2.f, 2.f));
6056 6052
6057 LayerTreeHostImpl::FrameData frame; 6053 LayerTreeHostImpl::FrameData frame;
6058 6054
6059 // Opaque layer, drawn without blending. 6055 // Opaque layer, drawn without blending.
6060 layer1->SetContentsOpaque(true); 6056 layer1->SetContentsOpaque(true);
6061 layer1->SetExpectation(false, false); 6057 layer1->SetExpectation(false, false);
6062 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 6058 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
6063 SetNeedsRebuildPropertyTrees(); 6059 SetNeedsRebuildPropertyTrees();
6064 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); 6060 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame));
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
6098 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); 6094 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame));
6099 host_impl_->DrawLayers(&frame); 6095 host_impl_->DrawLayers(&frame);
6100 EXPECT_TRUE(layer1->quads_appended()); 6096 EXPECT_TRUE(layer1->quads_appended());
6101 host_impl_->DidDrawAllLayers(frame); 6097 host_impl_->DidDrawAllLayers(frame);
6102 6098
6103 layer1->AddChild( 6099 layer1->AddChild(
6104 BlendStateCheckLayer::Create(host_impl_->active_tree(), 6100 BlendStateCheckLayer::Create(host_impl_->active_tree(),
6105 3, 6101 3,
6106 host_impl_->resource_provider())); 6102 host_impl_->resource_provider()));
6107 BlendStateCheckLayer* layer2 = 6103 BlendStateCheckLayer* layer2 =
6108 static_cast<BlendStateCheckLayer*>(layer1->children()[0].get()); 6104 static_cast<BlendStateCheckLayer*>(layer1->children()[0]);
6109 layer2->SetPosition(gfx::PointF(4.f, 4.f)); 6105 layer2->SetPosition(gfx::PointF(4.f, 4.f));
6110 6106
6111 // 2 opaque layers, drawn without blending. 6107 // 2 opaque layers, drawn without blending.
6112 layer1->SetContentsOpaque(true); 6108 layer1->SetContentsOpaque(true);
6113 layer1->SetOpacity(1.f); 6109 layer1->SetOpacity(1.f);
6114 layer1->NoteLayerPropertyChanged(); 6110 layer1->NoteLayerPropertyChanged();
6115 layer1->SetExpectation(false, false); 6111 layer1->SetExpectation(false, false);
6116 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 6112 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
6117 layer2->SetContentsOpaque(true); 6113 layer2->SetContentsOpaque(true);
6118 layer2->SetOpacity(1.f); 6114 layer2->SetOpacity(1.f);
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
6306 void SetupActiveTreeLayers() { 6302 void SetupActiveTreeLayers() {
6307 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); 6303 host_impl_->active_tree()->set_background_color(SK_ColorGRAY);
6308 host_impl_->active_tree()->SetRootLayer( 6304 host_impl_->active_tree()->SetRootLayer(
6309 LayerImpl::Create(host_impl_->active_tree(), 1)); 6305 LayerImpl::Create(host_impl_->active_tree(), 1));
6310 host_impl_->active_tree()->root_layer()->SetForceRenderSurface(true); 6306 host_impl_->active_tree()->root_layer()->SetForceRenderSurface(true);
6311 host_impl_->active_tree()->root_layer()->AddChild( 6307 host_impl_->active_tree()->root_layer()->AddChild(
6312 BlendStateCheckLayer::Create(host_impl_->active_tree(), 6308 BlendStateCheckLayer::Create(host_impl_->active_tree(),
6313 2, 6309 2,
6314 host_impl_->resource_provider())); 6310 host_impl_->resource_provider()));
6315 child_ = static_cast<BlendStateCheckLayer*>( 6311 child_ = static_cast<BlendStateCheckLayer*>(
6316 host_impl_->active_tree()->root_layer()->children()[0].get()); 6312 host_impl_->active_tree()->root_layer()->children()[0]);
6317 child_->SetExpectation(false, false); 6313 child_->SetExpectation(false, false);
6318 child_->SetContentsOpaque(true); 6314 child_->SetContentsOpaque(true);
6319 } 6315 }
6320 6316
6321 // Expect no gutter rects. 6317 // Expect no gutter rects.
6322 void TestLayerCoversFullViewport() { 6318 void TestLayerCoversFullViewport() {
6323 gfx::Rect layer_rect(viewport_size_); 6319 gfx::Rect layer_rect(viewport_size_);
6324 child_->SetPosition(gfx::PointF(layer_rect.origin())); 6320 child_->SetPosition(gfx::PointF(layer_rect.origin()));
6325 child_->SetBounds(layer_rect.size()); 6321 child_->SetBounds(layer_rect.size());
6326 child_->SetQuadRect(gfx::Rect(layer_rect.size())); 6322 child_->SetQuadRect(gfx::Rect(layer_rect.size()));
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after
7197 ASSERT_EQ(1u, frame.render_passes.size()); 7193 ASSERT_EQ(1u, frame.render_passes.size());
7198 7194
7199 // Verify the damage rect for the root render pass. 7195 // Verify the damage rect for the root render pass.
7200 const RenderPass* root_render_pass = frame.render_passes.back().get(); 7196 const RenderPass* root_render_pass = frame.render_passes.back().get();
7201 EXPECT_EQ(expected_damage, root_render_pass->damage_rect); 7197 EXPECT_EQ(expected_damage, root_render_pass->damage_rect);
7202 7198
7203 // Verify the root and child layers' quads are generated and not being 7199 // Verify the root and child layers' quads are generated and not being
7204 // culled. 7200 // culled.
7205 ASSERT_EQ(2u, root_render_pass->quad_list.size()); 7201 ASSERT_EQ(2u, root_render_pass->quad_list.size());
7206 7202
7207 LayerImpl* child = 7203 LayerImpl* child = host_impl_->active_tree()->root_layer()->children()[0];
7208 host_impl_->active_tree()->root_layer()->children()[0].get();
7209 gfx::Rect expected_child_visible_rect(child->bounds()); 7204 gfx::Rect expected_child_visible_rect(child->bounds());
7210 EXPECT_EQ(expected_child_visible_rect, 7205 EXPECT_EQ(expected_child_visible_rect,
7211 root_render_pass->quad_list.front()->visible_rect); 7206 root_render_pass->quad_list.front()->visible_rect);
7212 7207
7213 LayerImpl* root = host_impl_->active_tree()->root_layer(); 7208 LayerImpl* root = host_impl_->active_tree()->root_layer();
7214 gfx::Rect expected_root_visible_rect(root->bounds()); 7209 gfx::Rect expected_root_visible_rect(root->bounds());
7215 EXPECT_EQ(expected_root_visible_rect, 7210 EXPECT_EQ(expected_root_visible_rect,
7216 root_render_pass->quad_list.ElementAt(1)->visible_rect); 7211 root_render_pass->quad_list.ElementAt(1)->visible_rect);
7217 } 7212 }
7218 7213
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
7731 root_scrolling->AddChild(std::move(child)); 7726 root_scrolling->AddChild(std::move(child));
7732 root->AddChild(std::move(root_scrolling)); 7727 root->AddChild(std::move(root_scrolling));
7733 host_impl_->active_tree()->SetRootLayer(std::move(root)); 7728 host_impl_->active_tree()->SetRootLayer(std::move(root));
7734 host_impl_->active_tree()->DidBecomeActive(); 7729 host_impl_->active_tree()->DidBecomeActive();
7735 host_impl_->SetViewportSize(surface_size); 7730 host_impl_->SetViewportSize(surface_size);
7736 SetNeedsRebuildPropertyTrees(); 7731 SetNeedsRebuildPropertyTrees();
7737 DrawFrame(); 7732 DrawFrame();
7738 { 7733 {
7739 scoped_ptr<ScrollAndScaleSet> scroll_info; 7734 scoped_ptr<ScrollAndScaleSet> scroll_info;
7740 LayerImpl* child = 7735 LayerImpl* child =
7741 host_impl_->active_tree()->root_layer()->children()[0]->children() 7736 host_impl_->active_tree()->root_layer()->children()[0]->children()[0];
7742 [0].get(); 7737 LayerImpl* grand_child = child->children()[0];
7743 LayerImpl* grand_child = child->children()[0].get();
7744 7738
7745 gfx::Vector2d scroll_delta(0, -2); 7739 gfx::Vector2d scroll_delta(0, -2);
7746 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 7740 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
7747 host_impl_ 7741 host_impl_
7748 ->ScrollBegin(BeginState(gfx::Point()).get(), 7742 ->ScrollBegin(BeginState(gfx::Point()).get(),
7749 InputHandler::TOUCHSCREEN) 7743 InputHandler::TOUCHSCREEN)
7750 .thread); 7744 .thread);
7751 EXPECT_TRUE( 7745 EXPECT_TRUE(
7752 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()) 7746 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get())
7753 .did_scroll); 7747 .did_scroll);
(...skipping 1563 matching lines...) Expand 10 before | Expand all | Expand 10 after
9317 gfx::Rect external_viewport(10, 20); 9311 gfx::Rect external_viewport(10, 20);
9318 host_impl_->SetExternalTilePriorityConstraints(external_viewport, 9312 host_impl_->SetExternalTilePriorityConstraints(external_viewport,
9319 external_transform); 9313 external_transform);
9320 EXPECT_TRUE(host_impl_->pending_tree()->needs_update_draw_properties()); 9314 EXPECT_TRUE(host_impl_->pending_tree()->needs_update_draw_properties());
9321 EXPECT_TRUE(host_impl_->active_tree()->needs_update_draw_properties()); 9315 EXPECT_TRUE(host_impl_->active_tree()->needs_update_draw_properties());
9322 } 9316 }
9323 9317
9324 TEST_F(LayerTreeHostImplTest, ExternalViewportAffectsVisibleRects) { 9318 TEST_F(LayerTreeHostImplTest, ExternalViewportAffectsVisibleRects) {
9325 const gfx::Size layer_size(100, 100); 9319 const gfx::Size layer_size(100, 100);
9326 SetupScrollAndContentsLayers(layer_size); 9320 SetupScrollAndContentsLayers(layer_size);
9327 LayerImpl* content_layer = host_impl_->active_tree() 9321 LayerImpl* content_layer =
9328 ->OuterViewportScrollLayer() 9322 host_impl_->active_tree()->OuterViewportScrollLayer()->children()[0];
9329 ->children()[0]
9330 .get();
9331 SetNeedsRebuildPropertyTrees(); 9323 SetNeedsRebuildPropertyTrees();
9332 RebuildPropertyTrees(); 9324 RebuildPropertyTrees();
9333 9325
9334 bool update_lcd_text = false; 9326 bool update_lcd_text = false;
9335 9327
9336 host_impl_->SetViewportSize(gfx::Size(90, 90)); 9328 host_impl_->SetViewportSize(gfx::Size(90, 90));
9337 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); 9329 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text);
9338 EXPECT_EQ(gfx::Rect(90, 90), content_layer->visible_layer_rect()); 9330 EXPECT_EQ(gfx::Rect(90, 90), content_layer->visible_layer_rect());
9339 9331
9340 gfx::Transform external_transform; 9332 gfx::Transform external_transform;
(...skipping 12 matching lines...) Expand all
9353 external_transform); 9345 external_transform);
9354 9346
9355 host_impl_->OnDraw(external_transform, external_viewport, external_clip, 9347 host_impl_->OnDraw(external_transform, external_viewport, external_clip,
9356 resourceless_software_draw); 9348 resourceless_software_draw);
9357 EXPECT_EQ(gfx::Rect(90, 90), content_layer->visible_layer_rect()); 9349 EXPECT_EQ(gfx::Rect(90, 90), content_layer->visible_layer_rect());
9358 } 9350 }
9359 9351
9360 TEST_F(LayerTreeHostImplTest, ExternalTransformAffectsVisibleRects) { 9352 TEST_F(LayerTreeHostImplTest, ExternalTransformAffectsVisibleRects) {
9361 const gfx::Size layer_size(100, 100); 9353 const gfx::Size layer_size(100, 100);
9362 SetupScrollAndContentsLayers(layer_size); 9354 SetupScrollAndContentsLayers(layer_size);
9363 LayerImpl* content_layer = host_impl_->active_tree() 9355 LayerImpl* content_layer =
9364 ->OuterViewportScrollLayer() 9356 host_impl_->active_tree()->OuterViewportScrollLayer()->children()[0];
9365 ->children()[0]
9366 .get();
9367 SetNeedsRebuildPropertyTrees(); 9357 SetNeedsRebuildPropertyTrees();
9368 RebuildPropertyTrees(); 9358 RebuildPropertyTrees();
9369 9359
9370 bool update_lcd_text = false; 9360 bool update_lcd_text = false;
9371 9361
9372 host_impl_->SetViewportSize(gfx::Size(50, 50)); 9362 host_impl_->SetViewportSize(gfx::Size(50, 50));
9373 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); 9363 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text);
9374 EXPECT_EQ(gfx::Rect(50, 50), content_layer->visible_layer_rect()); 9364 EXPECT_EQ(gfx::Rect(50, 50), content_layer->visible_layer_rect());
9375 9365
9376 gfx::Transform external_transform; 9366 gfx::Transform external_transform;
(...skipping 17 matching lines...) Expand all
9394 external_transform); 9384 external_transform);
9395 9385
9396 host_impl_->OnDraw(external_transform, external_viewport, external_clip, 9386 host_impl_->OnDraw(external_transform, external_viewport, external_clip,
9397 resourceless_software_draw); 9387 resourceless_software_draw);
9398 EXPECT_EQ(gfx::Rect(50, 50), content_layer->visible_layer_rect()); 9388 EXPECT_EQ(gfx::Rect(50, 50), content_layer->visible_layer_rect());
9399 } 9389 }
9400 9390
9401 TEST_F(LayerTreeHostImplTest, ExternalTransformAffectsSublayerScaleFactor) { 9391 TEST_F(LayerTreeHostImplTest, ExternalTransformAffectsSublayerScaleFactor) {
9402 const gfx::Size layer_size(100, 100); 9392 const gfx::Size layer_size(100, 100);
9403 SetupScrollAndContentsLayers(layer_size); 9393 SetupScrollAndContentsLayers(layer_size);
9404 LayerImpl* content_layer = host_impl_->active_tree() 9394 LayerImpl* content_layer =
9405 ->OuterViewportScrollLayer() 9395 host_impl_->active_tree()->OuterViewportScrollLayer()->children()[0];
9406 ->children()[0]
9407 .get();
9408 content_layer->AddChild(LayerImpl::Create(host_impl_->active_tree(), 100)); 9396 content_layer->AddChild(LayerImpl::Create(host_impl_->active_tree(), 100));
9409 LayerImpl* test_layer = host_impl_->active_tree()->LayerById(100); 9397 LayerImpl* test_layer = host_impl_->active_tree()->LayerById(100);
9410 test_layer->SetForceRenderSurface(true); 9398 test_layer->SetForceRenderSurface(true);
9411 test_layer->SetDrawsContent(true); 9399 test_layer->SetDrawsContent(true);
9412 test_layer->SetBounds(layer_size); 9400 test_layer->SetBounds(layer_size);
9413 gfx::Transform perspective_transform; 9401 gfx::Transform perspective_transform;
9414 perspective_transform.ApplyPerspectiveDepth(2); 9402 perspective_transform.ApplyPerspectiveDepth(2);
9415 test_layer->SetTransform(perspective_transform); 9403 test_layer->SetTransform(perspective_transform);
9416 9404
9417 SetNeedsRebuildPropertyTrees(); 9405 SetNeedsRebuildPropertyTrees();
(...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after
10346 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), 10334 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(),
10347 InputHandler::TOUCHSCREEN); 10335 InputHandler::TOUCHSCREEN);
10348 host_impl_->ScrollBy( 10336 host_impl_->ScrollBy(
10349 UpdateState(gfx::Point(), gfx::Vector2dF(0, scroll)).get()); 10337 UpdateState(gfx::Point(), gfx::Vector2dF(0, scroll)).get());
10350 accumulated_scroll += scroll; 10338 accumulated_scroll += scroll;
10351 host_impl_->ScrollEnd(EndState().get()); 10339 host_impl_->ScrollEnd(EndState().get());
10352 host_impl_->active_tree()->UpdateDrawProperties(false); 10340 host_impl_->active_tree()->UpdateDrawProperties(false);
10353 10341
10354 host_impl_->CreatePendingTree(); 10342 host_impl_->CreatePendingTree();
10355 host_impl_->pending_tree()->set_source_frame_number(i + 1); 10343 host_impl_->pending_tree()->set_source_frame_number(i + 1);
10356 LayerImpl* content_layer = host_impl_->pending_tree() 10344 LayerImpl* content_layer =
10357 ->OuterViewportScrollLayer() 10345 host_impl_->pending_tree()->OuterViewportScrollLayer()->children()[0];
10358 ->children()[0]
10359 .get();
10360 // The scroll done on the active tree is undone on the pending tree. 10346 // The scroll done on the active tree is undone on the pending tree.
10361 gfx::Transform translate; 10347 gfx::Transform translate;
10362 translate.Translate(0, accumulated_scroll); 10348 translate.Translate(0, accumulated_scroll);
10363 content_layer->SetTransform(translate); 10349 content_layer->SetTransform(translate);
10364 10350
10365 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); 10351 LayerTreeImpl* pending_tree = host_impl_->pending_tree();
10366 pending_tree->PushPageScaleFromMainThread(1.f, 1.f, 1.f); 10352 pending_tree->PushPageScaleFromMainThread(1.f, 1.f, 1.f);
10367 LayerImpl* last_scrolled_layer = pending_tree->LayerById( 10353 LayerImpl* last_scrolled_layer = pending_tree->LayerById(
10368 host_impl_->active_tree()->LastScrolledLayerId()); 10354 host_impl_->active_tree()->LastScrolledLayerId());
10369 10355
(...skipping 23 matching lines...) Expand all
10393 // There should not be any jitter measured till we hit the fixed point hits 10379 // There should not be any jitter measured till we hit the fixed point hits
10394 // threshold. 10380 // threshold.
10395 float expected_jitter = 10381 float expected_jitter =
10396 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0; 10382 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0;
10397 EXPECT_EQ(jitter, expected_jitter); 10383 EXPECT_EQ(jitter, expected_jitter);
10398 } 10384 }
10399 } 10385 }
10400 10386
10401 } // namespace 10387 } // namespace
10402 } // namespace cc 10388 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698