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

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

Issue 2084233002: cc: Move LayerImpl::AddChild and RemoveChild to LayerImplTestProperties (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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_common_unittest.cc ('k') | cc/trees/layer_tree_impl_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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 gfx::ScrollOffset()); 324 gfx::ScrollOffset());
325 outer_scroll->SetBounds(content_size); 325 outer_scroll->SetBounds(content_size);
326 outer_scroll->SetPosition(gfx::PointF()); 326 outer_scroll->SetPosition(gfx::PointF());
327 327
328 std::unique_ptr<LayerImpl> contents = 328 std::unique_ptr<LayerImpl> contents =
329 LayerImpl::Create(layer_tree_impl, kContentLayerId); 329 LayerImpl::Create(layer_tree_impl, kContentLayerId);
330 contents->SetDrawsContent(true); 330 contents->SetDrawsContent(true);
331 contents->SetBounds(content_size); 331 contents->SetBounds(content_size);
332 contents->SetPosition(gfx::PointF()); 332 contents->SetPosition(gfx::PointF());
333 333
334 outer_scroll->AddChild(std::move(contents)); 334 outer_scroll->test_properties()->AddChild(std::move(contents));
335 outer_clip->AddChild(std::move(outer_scroll)); 335 outer_clip->test_properties()->AddChild(std::move(outer_scroll));
336 inner_scroll->AddChild(std::move(outer_clip)); 336 inner_scroll->test_properties()->AddChild(std::move(outer_clip));
337 page_scale->AddChild(std::move(inner_scroll)); 337 page_scale->test_properties()->AddChild(std::move(inner_scroll));
338 inner_clip->AddChild(std::move(page_scale)); 338 inner_clip->test_properties()->AddChild(std::move(page_scale));
339 root->AddChild(std::move(inner_clip)); 339 root->test_properties()->AddChild(std::move(inner_clip));
340 340
341 layer_tree_impl->SetRootLayer(std::move(root)); 341 layer_tree_impl->SetRootLayer(std::move(root));
342 layer_tree_impl->SetViewportLayersFromIds( 342 layer_tree_impl->SetViewportLayersFromIds(
343 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportScrollLayerId, 343 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportScrollLayerId,
344 kOuterViewportScrollLayerId); 344 kOuterViewportScrollLayerId);
345 345
346 layer_tree_impl->DidBecomeActive(); 346 layer_tree_impl->DidBecomeActive();
347 return layer_tree_impl->InnerViewportScrollLayer(); 347 return layer_tree_impl->InnerViewportScrollLayer();
348 } 348 }
349 349
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 591
592 std::unique_ptr<ScrollAndScaleSet> scroll_info = 592 std::unique_ptr<ScrollAndScaleSet> scroll_info =
593 host_impl_->ProcessScrollDeltas(); 593 host_impl_->ProcessScrollDeltas();
594 ASSERT_EQ(scroll_info->scrolls.size(), 0u); 594 ASSERT_EQ(scroll_info->scrolls.size(), 0u);
595 } 595 }
596 596
597 TEST_F(LayerTreeHostImplTest, ScrollDeltaTreeButNoChanges) { 597 TEST_F(LayerTreeHostImplTest, ScrollDeltaTreeButNoChanges) {
598 { 598 {
599 std::unique_ptr<LayerImpl> root = 599 std::unique_ptr<LayerImpl> root =
600 LayerImpl::Create(host_impl_->active_tree(), 1); 600 LayerImpl::Create(host_impl_->active_tree(), 1);
601 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); 601 root->test_properties()->AddChild(
602 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 3)); 602 LayerImpl::Create(host_impl_->active_tree(), 2));
603 root->test_properties()->children[1]->AddChild( 603 root->test_properties()->AddChild(
604 LayerImpl::Create(host_impl_->active_tree(), 3));
605 root->test_properties()->children[1]->test_properties()->AddChild(
604 LayerImpl::Create(host_impl_->active_tree(), 4)); 606 LayerImpl::Create(host_impl_->active_tree(), 4));
605 root->test_properties()->children[1]->AddChild( 607 root->test_properties()->children[1]->test_properties()->AddChild(
606 LayerImpl::Create(host_impl_->active_tree(), 5)); 608 LayerImpl::Create(host_impl_->active_tree(), 5));
607 root->test_properties() 609 root->test_properties()
608 ->children[1] 610 ->children[1]
609 ->test_properties() 611 ->test_properties()
610 ->children[0] 612 ->children[0]
613 ->test_properties()
611 ->AddChild(LayerImpl::Create(host_impl_->active_tree(), 6)); 614 ->AddChild(LayerImpl::Create(host_impl_->active_tree(), 6));
612 host_impl_->active_tree()->SetRootLayer(std::move(root)); 615 host_impl_->active_tree()->SetRootLayer(std::move(root));
613 } 616 }
614 LayerImpl* root = host_impl_->active_tree()->root_layer(); 617 LayerImpl* root = host_impl_->active_tree()->root_layer();
615 618
616 ExpectClearedScrollDeltasRecursive(root); 619 ExpectClearedScrollDeltasRecursive(root);
617 620
618 std::unique_ptr<ScrollAndScaleSet> scroll_info; 621 std::unique_ptr<ScrollAndScaleSet> scroll_info;
619 622
620 scroll_info = host_impl_->ProcessScrollDeltas(); 623 scroll_info = host_impl_->ProcessScrollDeltas();
621 ASSERT_EQ(scroll_info->scrolls.size(), 0u); 624 ASSERT_EQ(scroll_info->scrolls.size(), 0u);
622 ExpectClearedScrollDeltasRecursive(root); 625 ExpectClearedScrollDeltasRecursive(root);
623 626
624 scroll_info = host_impl_->ProcessScrollDeltas(); 627 scroll_info = host_impl_->ProcessScrollDeltas();
625 ASSERT_EQ(scroll_info->scrolls.size(), 0u); 628 ASSERT_EQ(scroll_info->scrolls.size(), 0u);
626 ExpectClearedScrollDeltasRecursive(root); 629 ExpectClearedScrollDeltasRecursive(root);
627 } 630 }
628 631
629 TEST_F(LayerTreeHostImplTest, ScrollDeltaRepeatedScrolls) { 632 TEST_F(LayerTreeHostImplTest, ScrollDeltaRepeatedScrolls) {
630 gfx::ScrollOffset scroll_offset(20, 30); 633 gfx::ScrollOffset scroll_offset(20, 30);
631 gfx::Vector2d scroll_delta(11, -15); 634 gfx::Vector2d scroll_delta(11, -15);
632 { 635 {
633 std::unique_ptr<LayerImpl> root_clip = 636 std::unique_ptr<LayerImpl> root_clip =
634 LayerImpl::Create(host_impl_->active_tree(), 2); 637 LayerImpl::Create(host_impl_->active_tree(), 2);
635 std::unique_ptr<LayerImpl> root = 638 std::unique_ptr<LayerImpl> root =
636 LayerImpl::Create(host_impl_->active_tree(), 1); 639 LayerImpl::Create(host_impl_->active_tree(), 1);
637 root_clip->SetBounds(gfx::Size(10, 10)); 640 root_clip->SetBounds(gfx::Size(10, 10));
638 LayerImpl* root_layer = root.get(); 641 LayerImpl* root_layer = root.get();
639 root_clip->AddChild(std::move(root)); 642 root_clip->test_properties()->AddChild(std::move(root));
640 root_layer->SetBounds(gfx::Size(110, 110)); 643 root_layer->SetBounds(gfx::Size(110, 110));
641 root_layer->SetScrollClipLayer(root_clip->id()); 644 root_layer->SetScrollClipLayer(root_clip->id());
642 root_layer->layer_tree_impl() 645 root_layer->layer_tree_impl()
643 ->property_trees() 646 ->property_trees()
644 ->scroll_tree.UpdateScrollOffsetBaseForTesting(root_layer->id(), 647 ->scroll_tree.UpdateScrollOffsetBaseForTesting(root_layer->id(),
645 scroll_offset); 648 scroll_offset);
646 host_impl_->active_tree()->SetRootLayer(std::move(root_clip)); 649 host_impl_->active_tree()->SetRootLayer(std::move(root_clip));
647 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); 650 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting();
648 root_layer->ScrollBy(scroll_delta); 651 root_layer->ScrollBy(scroll_delta);
649 } 652 }
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 LayerImpl* root = host_impl_->active_tree()->root_layer(); 798 LayerImpl* root = host_impl_->active_tree()->root_layer();
796 799
797 LayerImpl* child = 0; 800 LayerImpl* child = 0;
798 { 801 {
799 std::unique_ptr<LayerImpl> child_layer = 802 std::unique_ptr<LayerImpl> child_layer =
800 LayerImpl::Create(host_impl_->active_tree(), 6); 803 LayerImpl::Create(host_impl_->active_tree(), 6);
801 child = child_layer.get(); 804 child = child_layer.get();
802 child_layer->SetDrawsContent(true); 805 child_layer->SetDrawsContent(true);
803 child_layer->SetPosition(gfx::PointF(0, 20)); 806 child_layer->SetPosition(gfx::PointF(0, 20));
804 child_layer->SetBounds(gfx::Size(50, 50)); 807 child_layer->SetBounds(gfx::Size(50, 50));
805 scroll->AddChild(std::move(child_layer)); 808 scroll->test_properties()->AddChild(std::move(child_layer));
806 SetNeedsRebuildPropertyTrees(); 809 SetNeedsRebuildPropertyTrees();
807 RebuildPropertyTrees(); 810 RebuildPropertyTrees();
808 } 811 }
809 812
810 // Touch handler regions determine whether touch events block scroll. 813 // Touch handler regions determine whether touch events block scroll.
811 root->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100)); 814 root->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100));
812 EXPECT_TRUE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 10))); 815 EXPECT_TRUE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 10)));
813 816
814 // But they don't influence the actual handling of the scroll gestures. 817 // But they don't influence the actual handling of the scroll gestures.
815 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( 818 InputHandler::ScrollStatus status = host_impl_->ScrollBegin(
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 std::unique_ptr<LayerImpl> squash1 = LayerImpl::Create(layer_tree_impl, 5); 959 std::unique_ptr<LayerImpl> squash1 = LayerImpl::Create(layer_tree_impl, 5);
957 squash1->SetBounds(gfx::Size(140, 300)); 960 squash1->SetBounds(gfx::Size(140, 300));
958 squash1->SetPosition(gfx::PointF(220, 0)); 961 squash1->SetPosition(gfx::PointF(220, 0));
959 squash1->SetDrawsContent(true); 962 squash1->SetDrawsContent(true);
960 963
961 std::unique_ptr<LayerImpl> squash2 = LayerImpl::Create(layer_tree_impl, 6); 964 std::unique_ptr<LayerImpl> squash2 = LayerImpl::Create(layer_tree_impl, 6);
962 squash2->SetBounds(gfx::Size(140, 300)); 965 squash2->SetBounds(gfx::Size(140, 300));
963 squash2->SetPosition(gfx::PointF(220, 300)); 966 squash2->SetPosition(gfx::PointF(220, 300));
964 squash2->SetDrawsContent(true); 967 squash2->SetDrawsContent(true);
965 968
966 scroll->AddChild(std::move(squash2)); 969 scroll->test_properties()->AddChild(std::move(squash2));
967 clip->AddChild(std::move(scroll)); 970 clip->test_properties()->AddChild(std::move(scroll));
968 clip->AddChild(std::move(scrollbar)); 971 clip->test_properties()->AddChild(std::move(scrollbar));
969 clip->AddChild(std::move(squash1)); 972 clip->test_properties()->AddChild(std::move(squash1));
970 root->AddChild(std::move(clip)); 973 root->test_properties()->AddChild(std::move(clip));
971 974
972 layer_tree_impl->SetRootLayer(std::move(root)); 975 layer_tree_impl->SetRootLayer(std::move(root));
973 SetNeedsRebuildPropertyTrees(); 976 SetNeedsRebuildPropertyTrees();
974 RebuildPropertyTrees(); 977 RebuildPropertyTrees();
975 layer_tree_impl->DidBecomeActive(); 978 layer_tree_impl->DidBecomeActive();
976 979
977 // The point hits squash1 layer and also scroll layer, because scroll layer is 980 // The point hits squash1 layer and also scroll layer, because scroll layer is
978 // not an ancestor of squash1 layer, we cannot scroll on impl thread. 981 // not an ancestor of squash1 layer, we cannot scroll on impl thread.
979 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( 982 InputHandler::ScrollStatus status = host_impl_->ScrollBegin(
980 BeginState(gfx::Point(230, 150)).get(), InputHandler::WHEEL); 983 BeginState(gfx::Point(230, 150)).get(), InputHandler::WHEEL);
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
1290 1293
1291 host_impl_->SetViewportSize(gfx::Size(50, 50)); 1294 host_impl_->SetViewportSize(gfx::Size(50, 50));
1292 1295
1293 host_impl_->CreatePendingTree(); 1296 host_impl_->CreatePendingTree();
1294 host_impl_->pending_tree()->SetRootLayer( 1297 host_impl_->pending_tree()->SetRootLayer(
1295 LayerImpl::Create(host_impl_->pending_tree(), 1)); 1298 LayerImpl::Create(host_impl_->pending_tree(), 1));
1296 LayerImpl* root = host_impl_->pending_tree()->root_layer(); 1299 LayerImpl* root = host_impl_->pending_tree()->root_layer();
1297 root->SetBounds(gfx::Size(50, 50)); 1300 root->SetBounds(gfx::Size(50, 50));
1298 root->test_properties()->force_render_surface = true; 1301 root->test_properties()->force_render_surface = true;
1299 1302
1300 root->AddChild(LayerImpl::Create(host_impl_->pending_tree(), 2)); 1303 root->test_properties()->AddChild(
1304 LayerImpl::Create(host_impl_->pending_tree(), 2));
1301 host_impl_->pending_tree()->BuildLayerListForTesting(); 1305 host_impl_->pending_tree()->BuildLayerListForTesting();
1302 LayerImpl* child = root->test_properties()->children[0]; 1306 LayerImpl* child = root->test_properties()->children[0];
1303 child->SetBounds(gfx::Size(10, 10)); 1307 child->SetBounds(gfx::Size(10, 10));
1304 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); 1308 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10);
1305 child->SetDrawsContent(true); 1309 child->SetDrawsContent(true);
1306 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 10.0, 3, 0); 1310 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 10.0, 3, 0);
1307 1311
1308 EXPECT_FALSE(did_request_next_frame_); 1312 EXPECT_FALSE(did_request_next_frame_);
1309 EXPECT_FALSE(did_request_redraw_); 1313 EXPECT_FALSE(did_request_redraw_);
1310 EXPECT_FALSE(did_request_commit_); 1314 EXPECT_FALSE(did_request_commit_);
(...skipping 30 matching lines...) Expand all
1341 EXPECT_FALSE(host_impl_->CommitToActiveTree()); 1345 EXPECT_FALSE(host_impl_->CommitToActiveTree());
1342 1346
1343 host_impl_->SetViewportSize(gfx::Size(50, 50)); 1347 host_impl_->SetViewportSize(gfx::Size(50, 50));
1344 1348
1345 host_impl_->active_tree()->SetRootLayer( 1349 host_impl_->active_tree()->SetRootLayer(
1346 LayerImpl::Create(host_impl_->active_tree(), 1)); 1350 LayerImpl::Create(host_impl_->active_tree(), 1));
1347 LayerImpl* root = host_impl_->active_tree()->root_layer(); 1351 LayerImpl* root = host_impl_->active_tree()->root_layer();
1348 root->SetBounds(gfx::Size(50, 50)); 1352 root->SetBounds(gfx::Size(50, 50));
1349 root->test_properties()->force_render_surface = true; 1353 root->test_properties()->force_render_surface = true;
1350 1354
1351 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); 1355 root->test_properties()->AddChild(
1356 LayerImpl::Create(host_impl_->active_tree(), 2));
1352 LayerImpl* child = root->test_properties()->children[0]; 1357 LayerImpl* child = root->test_properties()->children[0];
1353 child->SetBounds(gfx::Size(10, 10)); 1358 child->SetBounds(gfx::Size(10, 10));
1354 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); 1359 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10);
1355 child->SetDrawsContent(true); 1360 child->SetDrawsContent(true);
1356 1361
1357 // Add a translate from 6,7 to 8,9. 1362 // Add a translate from 6,7 to 8,9.
1358 TransformOperations start; 1363 TransformOperations start;
1359 start.AppendTranslate(6.f, 7.f, 0.f); 1364 start.AppendTranslate(6.f, 7.f, 0.f);
1360 TransformOperations end; 1365 TransformOperations end;
1361 end.AppendTranslate(8.f, 9.f, 0.f); 1366 end.AppendTranslate(8.f, 9.f, 0.f);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1405 EXPECT_TRUE(host_impl_->CommitToActiveTree()); 1410 EXPECT_TRUE(host_impl_->CommitToActiveTree());
1406 1411
1407 host_impl_->SetViewportSize(gfx::Size(50, 50)); 1412 host_impl_->SetViewportSize(gfx::Size(50, 50));
1408 1413
1409 host_impl_->active_tree()->SetRootLayer( 1414 host_impl_->active_tree()->SetRootLayer(
1410 LayerImpl::Create(host_impl_->active_tree(), 1)); 1415 LayerImpl::Create(host_impl_->active_tree(), 1));
1411 LayerImpl* root = host_impl_->active_tree()->root_layer(); 1416 LayerImpl* root = host_impl_->active_tree()->root_layer();
1412 root->SetBounds(gfx::Size(50, 50)); 1417 root->SetBounds(gfx::Size(50, 50));
1413 root->SetHasRenderSurface(true); 1418 root->SetHasRenderSurface(true);
1414 1419
1415 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); 1420 root->test_properties()->AddChild(
1421 LayerImpl::Create(host_impl_->active_tree(), 2));
1416 LayerImpl* child = root->test_properties()->children[0]; 1422 LayerImpl* child = root->test_properties()->children[0];
1417 child->SetBounds(gfx::Size(10, 10)); 1423 child->SetBounds(gfx::Size(10, 10));
1418 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); 1424 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10);
1419 child->SetDrawsContent(true); 1425 child->SetDrawsContent(true);
1420 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 10.0, 3, 0); 1426 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 10.0, 3, 0);
1421 1427
1422 // Set up the property trees so that UpdateDrawProperties will work in 1428 // Set up the property trees so that UpdateDrawProperties will work in
1423 // CommitComplete below. 1429 // CommitComplete below.
1424 LayerImplList list; 1430 LayerImplList list;
1425 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1431 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
(...skipping 17 matching lines...) Expand all
1443 } 1449 }
1444 1450
1445 TEST_F(LayerTreeHostImplTest, AnimationSchedulingOnLayerDestruction) { 1451 TEST_F(LayerTreeHostImplTest, AnimationSchedulingOnLayerDestruction) {
1446 host_impl_->SetViewportSize(gfx::Size(50, 50)); 1452 host_impl_->SetViewportSize(gfx::Size(50, 50));
1447 1453
1448 host_impl_->active_tree()->SetRootLayer( 1454 host_impl_->active_tree()->SetRootLayer(
1449 LayerImpl::Create(host_impl_->active_tree(), 1)); 1455 LayerImpl::Create(host_impl_->active_tree(), 1));
1450 LayerImpl* root = host_impl_->active_tree()->root_layer(); 1456 LayerImpl* root = host_impl_->active_tree()->root_layer();
1451 root->SetBounds(gfx::Size(50, 50)); 1457 root->SetBounds(gfx::Size(50, 50));
1452 1458
1453 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); 1459 root->test_properties()->AddChild(
1460 LayerImpl::Create(host_impl_->active_tree(), 2));
1454 LayerImpl* child = root->test_properties()->children[0]; 1461 LayerImpl* child = root->test_properties()->children[0];
1455 child->SetBounds(gfx::Size(10, 10)); 1462 child->SetBounds(gfx::Size(10, 10));
1456 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); 1463 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10);
1457 child->SetDrawsContent(true); 1464 child->SetDrawsContent(true);
1458 1465
1459 // Add a translate animation. 1466 // Add a translate animation.
1460 TransformOperations start; 1467 TransformOperations start;
1461 start.AppendTranslate(6.f, 7.f, 0.f); 1468 start.AppendTranslate(6.f, 7.f, 0.f);
1462 TransformOperations end; 1469 TransformOperations end;
1463 end.AppendTranslate(8.f, 9.f, 0.f); 1470 end.AppendTranslate(8.f, 9.f, 0.f);
(...skipping 14 matching lines...) Expand all
1478 1485
1479 // The next frame after activating, we'll tick the animation again. 1486 // The next frame after activating, we'll tick the animation again.
1480 host_impl_->Animate(); 1487 host_impl_->Animate();
1481 // An animation exists on the active layer. Doing Animate() requests another 1488 // An animation exists on the active layer. Doing Animate() requests another
1482 // frame after the current one. 1489 // frame after the current one.
1483 EXPECT_TRUE(did_request_next_frame_); 1490 EXPECT_TRUE(did_request_next_frame_);
1484 did_request_next_frame_ = false; 1491 did_request_next_frame_ = false;
1485 1492
1486 // Destroy layer, unregister animation target (element). 1493 // Destroy layer, unregister animation target (element).
1487 child->test_properties()->parent = nullptr; 1494 child->test_properties()->parent = nullptr;
1488 root->RemoveChildForTesting(child); 1495 root->test_properties()->RemoveChild(child);
1489 child = nullptr; 1496 child = nullptr;
1490 1497
1491 // Doing Animate() doesn't request another frame after the current one. 1498 // Doing Animate() doesn't request another frame after the current one.
1492 host_impl_->Animate(); 1499 host_impl_->Animate();
1493 EXPECT_FALSE(did_request_next_frame_); 1500 EXPECT_FALSE(did_request_next_frame_);
1494 1501
1495 host_impl_->Animate(); 1502 host_impl_->Animate();
1496 EXPECT_FALSE(did_request_next_frame_); 1503 EXPECT_FALSE(did_request_next_frame_);
1497 } 1504 }
1498 1505
(...skipping 17 matching lines...) Expand all
1516 1523
1517 TEST_F(LayerTreeHostImplTest, AnimationMarksLayerNotReady) { 1524 TEST_F(LayerTreeHostImplTest, AnimationMarksLayerNotReady) {
1518 host_impl_->SetViewportSize(gfx::Size(50, 50)); 1525 host_impl_->SetViewportSize(gfx::Size(50, 50));
1519 1526
1520 host_impl_->active_tree()->SetRootLayer( 1527 host_impl_->active_tree()->SetRootLayer(
1521 LayerImpl::Create(host_impl_->active_tree(), 1)); 1528 LayerImpl::Create(host_impl_->active_tree(), 1));
1522 LayerImpl* root = host_impl_->active_tree()->root_layer(); 1529 LayerImpl* root = host_impl_->active_tree()->root_layer();
1523 root->SetBounds(gfx::Size(50, 50)); 1530 root->SetBounds(gfx::Size(50, 50));
1524 root->SetHasRenderSurface(true); 1531 root->SetHasRenderSurface(true);
1525 1532
1526 root->AddChild(std::unique_ptr<MissingTilesLayer>( 1533 root->test_properties()->AddChild(std::unique_ptr<MissingTilesLayer>(
1527 new MissingTilesLayer(host_impl_->active_tree(), 2))); 1534 new MissingTilesLayer(host_impl_->active_tree(), 2)));
1528 MissingTilesLayer* child = 1535 MissingTilesLayer* child =
1529 static_cast<MissingTilesLayer*>(root->test_properties()->children[0]); 1536 static_cast<MissingTilesLayer*>(root->test_properties()->children[0]);
1530 child->SetBounds(gfx::Size(10, 10)); 1537 child->SetBounds(gfx::Size(10, 10));
1531 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); 1538 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10);
1532 child->SetDrawsContent(true); 1539 child->SetDrawsContent(true);
1533 1540
1534 EXPECT_TRUE(child->was_ever_ready_since_last_transform_animation()); 1541 EXPECT_TRUE(child->was_ever_ready_since_last_transform_animation());
1535 1542
1536 // Add a translate from 6,7 to 8,9. 1543 // Add a translate from 6,7 to 8,9.
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
2035 // to the other. Scrolls shouldn't bubbling from the child. 2042 // to the other. Scrolls shouldn't bubbling from the child.
2036 LayerImpl *parent; 2043 LayerImpl *parent;
2037 LayerImpl *child; 2044 LayerImpl *child;
2038 LayerImpl *child_clip; 2045 LayerImpl *child_clip;
2039 2046
2040 std::unique_ptr<LayerImpl> scroll_parent_clip = 2047 std::unique_ptr<LayerImpl> scroll_parent_clip =
2041 LayerImpl::Create(host_impl_->active_tree(), 6); 2048 LayerImpl::Create(host_impl_->active_tree(), 6);
2042 std::unique_ptr<LayerImpl> scroll_parent = 2049 std::unique_ptr<LayerImpl> scroll_parent =
2043 CreateScrollableLayer(7, gfx::Size(10, 10), scroll_parent_clip.get()); 2050 CreateScrollableLayer(7, gfx::Size(10, 10), scroll_parent_clip.get());
2044 parent = scroll_parent.get(); 2051 parent = scroll_parent.get();
2045 scroll_parent_clip->AddChild(std::move(scroll_parent)); 2052 scroll_parent_clip->test_properties()->AddChild(std::move(scroll_parent));
2046 2053
2047 viewport_scroll->AddChild(std::move(scroll_parent_clip)); 2054 viewport_scroll->test_properties()->AddChild(std::move(scroll_parent_clip));
2048 2055
2049 std::unique_ptr<LayerImpl> scroll_child_clip = 2056 std::unique_ptr<LayerImpl> scroll_child_clip =
2050 LayerImpl::Create(host_impl_->active_tree(), 8); 2057 LayerImpl::Create(host_impl_->active_tree(), 8);
2051 std::unique_ptr<LayerImpl> scroll_child = 2058 std::unique_ptr<LayerImpl> scroll_child =
2052 CreateScrollableLayer(9, gfx::Size(10, 10), scroll_child_clip.get()); 2059 CreateScrollableLayer(9, gfx::Size(10, 10), scroll_child_clip.get());
2053 child = scroll_child.get(); 2060 child = scroll_child.get();
2054 scroll_child->SetPosition(gfx::PointF(20.f, 20.f)); 2061 scroll_child->SetPosition(gfx::PointF(20.f, 20.f));
2055 scroll_child_clip->AddChild(std::move(scroll_child)); 2062 scroll_child_clip->test_properties()->AddChild(std::move(scroll_child));
2056 2063
2057 child_clip = scroll_child_clip.get(); 2064 child_clip = scroll_child_clip.get();
2058 viewport_scroll->AddChild(std::move(scroll_child_clip)); 2065 viewport_scroll->test_properties()->AddChild(std::move(scroll_child_clip));
2059 2066
2060 child_clip->test_properties()->scroll_parent = parent; 2067 child_clip->test_properties()->scroll_parent = parent;
2061 std::unique_ptr<std::set<LayerImpl*>> scroll_children( 2068 std::unique_ptr<std::set<LayerImpl*>> scroll_children(
2062 new std::set<LayerImpl*>); 2069 new std::set<LayerImpl*>);
2063 scroll_children->insert(child_clip); 2070 scroll_children->insert(child_clip);
2064 parent->test_properties()->scroll_children.reset(scroll_children.release()); 2071 parent->test_properties()->scroll_children.reset(scroll_children.release());
2065 2072
2066 SetNeedsRebuildPropertyTrees(); 2073 SetNeedsRebuildPropertyTrees();
2067 DrawFrame(); 2074 DrawFrame();
2068 2075
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
2721 2728
2722 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = 2729 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar =
2723 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 400, 2730 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 400,
2724 VERTICAL, 10, 0, false, true); 2731 VERTICAL, 10, 0, false, true);
2725 scrollbar->test_properties()->opacity = 0.f; 2732 scrollbar->test_properties()->opacity = 0.f;
2726 EXPECT_FLOAT_EQ(0.f, scrollbar->test_properties()->opacity); 2733 EXPECT_FLOAT_EQ(0.f, scrollbar->test_properties()->opacity);
2727 2734
2728 LayerImpl* scroll = host_impl_->active_tree()->OuterViewportScrollLayer(); 2735 LayerImpl* scroll = host_impl_->active_tree()->OuterViewportScrollLayer();
2729 LayerImpl* root = host_impl_->active_tree()->InnerViewportContainerLayer(); 2736 LayerImpl* root = host_impl_->active_tree()->InnerViewportContainerLayer();
2730 scrollbar->SetScrollLayerId(scroll->id()); 2737 scrollbar->SetScrollLayerId(scroll->id());
2731 root->AddChild(std::move(scrollbar)); 2738 root->test_properties()->AddChild(std::move(scrollbar));
2732 2739
2733 host_impl_->active_tree()->DidBecomeActive(); 2740 host_impl_->active_tree()->DidBecomeActive();
2734 SetNeedsRebuildPropertyTrees(); 2741 SetNeedsRebuildPropertyTrees();
2735 DrawFrame(); 2742 DrawFrame();
2736 } 2743 }
2737 2744
2738 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) { 2745 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) {
2739 LayerTreeSettings settings = DefaultSettings(); 2746 LayerTreeSettings settings = DefaultSettings();
2740 settings.scrollbar_animator = animator; 2747 settings.scrollbar_animator = animator;
2741 settings.scrollbar_fade_delay_ms = 20; 2748 settings.scrollbar_fade_delay_ms = 20;
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
2905 host_impl_->CreatePendingTree(); 2912 host_impl_->CreatePendingTree();
2906 CreateScrollAndContentsLayers(host_impl_->pending_tree(), content_size); 2913 CreateScrollAndContentsLayers(host_impl_->pending_tree(), content_size);
2907 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = 2914 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar =
2908 SolidColorScrollbarLayerImpl::Create(host_impl_->pending_tree(), 400, 2915 SolidColorScrollbarLayerImpl::Create(host_impl_->pending_tree(), 400,
2909 VERTICAL, 10, 0, false, true); 2916 VERTICAL, 10, 0, false, true);
2910 scrollbar->test_properties()->opacity = 0.f; 2917 scrollbar->test_properties()->opacity = 0.f;
2911 LayerImpl* scroll = host_impl_->pending_tree()->OuterViewportScrollLayer(); 2918 LayerImpl* scroll = host_impl_->pending_tree()->OuterViewportScrollLayer();
2912 LayerImpl* container = 2919 LayerImpl* container =
2913 host_impl_->pending_tree()->InnerViewportContainerLayer(); 2920 host_impl_->pending_tree()->InnerViewportContainerLayer();
2914 scrollbar->SetScrollLayerId(scroll->id()); 2921 scrollbar->SetScrollLayerId(scroll->id());
2915 container->AddChild(std::move(scrollbar)); 2922 container->test_properties()->AddChild(std::move(scrollbar));
2916 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); 2923 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f);
2917 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting(); 2924 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting();
2918 host_impl_->ActivateSyncTree(); 2925 host_impl_->ActivateSyncTree();
2919 2926
2920 LayerImpl* active_scrollbar_layer = 2927 LayerImpl* active_scrollbar_layer =
2921 host_impl_->active_tree()->LayerById(400); 2928 host_impl_->active_tree()->LayerById(400);
2922 2929
2923 EffectNode* active_tree_node = 2930 EffectNode* active_tree_node =
2924 host_impl_->active_tree()->property_trees()->effect_tree.Node( 2931 host_impl_->active_tree()->property_trees()->effect_tree.Node(
2925 active_scrollbar_layer->effect_tree_index()); 2932 active_scrollbar_layer->effect_tree_index());
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
3068 gfx::ScrollOffset(10, 10)); 3075 gfx::ScrollOffset(10, 10));
3069 EXPECT_FALSE(animation_task_.Equals(base::Closure())); 3076 EXPECT_FALSE(animation_task_.Equals(base::Closure()));
3070 animation_task_ = base::Closure(); 3077 animation_task_ = base::Closure();
3071 host_impl_->active_tree()->InnerViewportScrollLayer()->SetCurrentScrollOffset( 3078 host_impl_->active_tree()->InnerViewportScrollLayer()->SetCurrentScrollOffset(
3072 gfx::ScrollOffset(10, 10)); 3079 gfx::ScrollOffset(10, 10));
3073 EXPECT_FALSE(animation_task_.Equals(base::Closure())); 3080 EXPECT_FALSE(animation_task_.Equals(base::Closure()));
3074 animation_task_ = base::Closure(); 3081 animation_task_ = base::Closure();
3075 3082
3076 // Check scrollbar registration on a sublayer. 3083 // Check scrollbar registration on a sublayer.
3077 child->SetScrollClipLayer(child_clip->id()); 3084 child->SetScrollClipLayer(child_clip->id());
3078 child_clip->AddChild(std::move(child)); 3085 child_clip->test_properties()->AddChild(std::move(child));
3079 root_scroll->AddChild(std::move(child_clip)); 3086 root_scroll->test_properties()->AddChild(std::move(child_clip));
3080 EXPECT_EQ(0ul, host_impl_->ScrollbarsFor(child_scroll_id).size()); 3087 EXPECT_EQ(0ul, host_impl_->ScrollbarsFor(child_scroll_id).size());
3081 EXPECT_EQ(nullptr, 3088 EXPECT_EQ(nullptr,
3082 host_impl_->ScrollbarAnimationControllerForId(child_scroll_id)); 3089 host_impl_->ScrollbarAnimationControllerForId(child_scroll_id));
3083 vert_2_scrollbar->SetScrollLayerId(child_scroll_id); 3090 vert_2_scrollbar->SetScrollLayerId(child_scroll_id);
3084 EXPECT_EQ(1ul, host_impl_->ScrollbarsFor(child_scroll_id).size()); 3091 EXPECT_EQ(1ul, host_impl_->ScrollbarsFor(child_scroll_id).size());
3085 EXPECT_TRUE(host_impl_->ScrollbarAnimationControllerForId(child_scroll_id)); 3092 EXPECT_TRUE(host_impl_->ScrollbarAnimationControllerForId(child_scroll_id));
3086 horiz_2_scrollbar->SetScrollLayerId(child_scroll_id); 3093 horiz_2_scrollbar->SetScrollLayerId(child_scroll_id);
3087 EXPECT_EQ(2ul, host_impl_->ScrollbarsFor(child_scroll_id).size()); 3094 EXPECT_EQ(2ul, host_impl_->ScrollbarsFor(child_scroll_id).size());
3088 EXPECT_TRUE(host_impl_->ScrollbarAnimationControllerForId(child_scroll_id)); 3095 EXPECT_TRUE(host_impl_->ScrollbarAnimationControllerForId(child_scroll_id));
3089 3096
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
3146 LayerImpl* root_scroll = 3153 LayerImpl* root_scroll =
3147 host_impl_->active_tree()->OuterViewportScrollLayer(); 3154 host_impl_->active_tree()->OuterViewportScrollLayer();
3148 // The scrollbar is on the left side. 3155 // The scrollbar is on the left side.
3149 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = 3156 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar =
3150 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 6, 3157 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 6,
3151 VERTICAL, 5, 5, true, true); 3158 VERTICAL, 5, 5, true, true);
3152 scrollbar->SetScrollLayerId(root_scroll->id()); 3159 scrollbar->SetScrollLayerId(root_scroll->id());
3153 scrollbar->SetDrawsContent(true); 3160 scrollbar->SetDrawsContent(true);
3154 scrollbar->SetBounds(scrollbar_size); 3161 scrollbar->SetBounds(scrollbar_size);
3155 scrollbar->SetTouchEventHandlerRegion(gfx::Rect(scrollbar_size)); 3162 scrollbar->SetTouchEventHandlerRegion(gfx::Rect(scrollbar_size));
3156 host_impl_->active_tree()->InnerViewportContainerLayer()->AddChild( 3163 host_impl_->active_tree()
3157 std::move(scrollbar)); 3164 ->InnerViewportContainerLayer()
3165 ->test_properties()
3166 ->AddChild(std::move(scrollbar));
3158 host_impl_->active_tree()->DidBecomeActive(); 3167 host_impl_->active_tree()->DidBecomeActive();
3159 3168
3160 DrawFrame(); 3169 DrawFrame();
3161 host_impl_->active_tree()->UpdateDrawProperties(false); 3170 host_impl_->active_tree()->UpdateDrawProperties(false);
3162 3171
3163 ScrollbarAnimationControllerThinning* scrollbar_animation_controller = 3172 ScrollbarAnimationControllerThinning* scrollbar_animation_controller =
3164 static_cast<ScrollbarAnimationControllerThinning*>( 3173 static_cast<ScrollbarAnimationControllerThinning*>(
3165 host_impl_->ScrollbarAnimationControllerForId(root_scroll->id())); 3174 host_impl_->ScrollbarAnimationControllerForId(root_scroll->id()));
3166 scrollbar_animation_controller->set_mouse_move_distance_for_test(100.f); 3175 scrollbar_animation_controller->set_mouse_move_distance_for_test(100.f);
3167 3176
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
3383 }; 3392 };
3384 3393
3385 TEST_F(LayerTreeHostImplTest, WillDrawReturningFalseDoesNotCall) { 3394 TEST_F(LayerTreeHostImplTest, WillDrawReturningFalseDoesNotCall) {
3386 // The root layer is always drawn, so run this test on a child layer that 3395 // The root layer is always drawn, so run this test on a child layer that
3387 // will be masked out by the root layer's bounds. 3396 // will be masked out by the root layer's bounds.
3388 host_impl_->active_tree()->SetRootLayer( 3397 host_impl_->active_tree()->SetRootLayer(
3389 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); 3398 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1));
3390 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( 3399 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(
3391 host_impl_->active_tree()->root_layer()); 3400 host_impl_->active_tree()->root_layer());
3392 3401
3393 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); 3402 root->test_properties()->AddChild(
3403 DidDrawCheckLayer::Create(host_impl_->active_tree(), 2));
3394 root->test_properties()->force_render_surface = true; 3404 root->test_properties()->force_render_surface = true;
3395 DidDrawCheckLayer* layer = 3405 DidDrawCheckLayer* layer =
3396 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]); 3406 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]);
3397 3407
3398 { 3408 {
3399 LayerTreeHostImpl::FrameData frame; 3409 LayerTreeHostImpl::FrameData frame;
3400 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); 3410 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame));
3401 host_impl_->DrawLayers(&frame); 3411 host_impl_->DrawLayers(&frame);
3402 host_impl_->DidDrawAllLayers(frame); 3412 host_impl_->DidDrawAllLayers(frame);
3403 3413
(...skipping 22 matching lines...) Expand all
3426 3436
3427 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) { 3437 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) {
3428 // The root layer is always drawn, so run this test on a child layer that 3438 // The root layer is always drawn, so run this test on a child layer that
3429 // will be masked out by the root layer's bounds. 3439 // will be masked out by the root layer's bounds.
3430 host_impl_->active_tree()->SetRootLayer( 3440 host_impl_->active_tree()->SetRootLayer(
3431 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); 3441 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1));
3432 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( 3442 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(
3433 host_impl_->active_tree()->root_layer()); 3443 host_impl_->active_tree()->root_layer());
3434 root->SetMasksToBounds(true); 3444 root->SetMasksToBounds(true);
3435 root->test_properties()->force_render_surface = true; 3445 root->test_properties()->force_render_surface = true;
3436 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); 3446 root->test_properties()->AddChild(
3447 DidDrawCheckLayer::Create(host_impl_->active_tree(), 2));
3437 DidDrawCheckLayer* layer = 3448 DidDrawCheckLayer* layer =
3438 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]); 3449 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]);
3439 // Ensure visible_layer_rect for layer is empty. 3450 // Ensure visible_layer_rect for layer is empty.
3440 layer->SetPosition(gfx::PointF(100.f, 100.f)); 3451 layer->SetPosition(gfx::PointF(100.f, 100.f));
3441 layer->SetBounds(gfx::Size(10, 10)); 3452 layer->SetBounds(gfx::Size(10, 10));
3442 3453
3443 LayerTreeHostImpl::FrameData frame; 3454 LayerTreeHostImpl::FrameData frame;
3444 3455
3445 EXPECT_FALSE(layer->will_draw_called()); 3456 EXPECT_FALSE(layer->will_draw_called());
3446 EXPECT_FALSE(layer->did_draw_called()); 3457 EXPECT_FALSE(layer->did_draw_called());
(...skipping 28 matching lines...) Expand all
3475 3486
3476 TEST_F(LayerTreeHostImplTest, WillDrawNotCalledOnOccludedLayer) { 3487 TEST_F(LayerTreeHostImplTest, WillDrawNotCalledOnOccludedLayer) {
3477 gfx::Size big_size(1000, 1000); 3488 gfx::Size big_size(1000, 1000);
3478 host_impl_->SetViewportSize(big_size); 3489 host_impl_->SetViewportSize(big_size);
3479 3490
3480 host_impl_->active_tree()->SetRootLayer( 3491 host_impl_->active_tree()->SetRootLayer(
3481 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); 3492 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1));
3482 DidDrawCheckLayer* root = 3493 DidDrawCheckLayer* root =
3483 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 3494 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
3484 3495
3485 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); 3496 root->test_properties()->AddChild(
3497 DidDrawCheckLayer::Create(host_impl_->active_tree(), 2));
3486 DidDrawCheckLayer* occluded_layer = 3498 DidDrawCheckLayer* occluded_layer =
3487 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]); 3499 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]);
3488 3500
3489 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); 3501 root->test_properties()->AddChild(
3502 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3));
3490 root->test_properties()->force_render_surface = true; 3503 root->test_properties()->force_render_surface = true;
3491 DidDrawCheckLayer* top_layer = 3504 DidDrawCheckLayer* top_layer =
3492 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[1]); 3505 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[1]);
3493 // This layer covers the occluded_layer above. Make this layer large so it can 3506 // This layer covers the occluded_layer above. Make this layer large so it can
3494 // occlude. 3507 // occlude.
3495 top_layer->SetBounds(big_size); 3508 top_layer->SetBounds(big_size);
3496 top_layer->SetContentsOpaque(true); 3509 top_layer->SetContentsOpaque(true);
3497 3510
3498 LayerTreeHostImpl::FrameData frame; 3511 LayerTreeHostImpl::FrameData frame;
3499 3512
(...skipping 11 matching lines...) Expand all
3511 EXPECT_TRUE(top_layer->will_draw_called()); 3524 EXPECT_TRUE(top_layer->will_draw_called());
3512 EXPECT_TRUE(top_layer->did_draw_called()); 3525 EXPECT_TRUE(top_layer->did_draw_called());
3513 } 3526 }
3514 3527
3515 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { 3528 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) {
3516 host_impl_->active_tree()->SetRootLayer( 3529 host_impl_->active_tree()->SetRootLayer(
3517 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); 3530 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1));
3518 DidDrawCheckLayer* root = 3531 DidDrawCheckLayer* root =
3519 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 3532 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
3520 3533
3521 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); 3534 root->test_properties()->AddChild(
3535 DidDrawCheckLayer::Create(host_impl_->active_tree(), 2));
3522 root->test_properties()->force_render_surface = true; 3536 root->test_properties()->force_render_surface = true;
3523 DidDrawCheckLayer* layer1 = 3537 DidDrawCheckLayer* layer1 =
3524 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]); 3538 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]);
3525 3539
3526 layer1->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); 3540 layer1->test_properties()->AddChild(
3541 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3));
3527 DidDrawCheckLayer* layer2 = 3542 DidDrawCheckLayer* layer2 =
3528 static_cast<DidDrawCheckLayer*>(layer1->test_properties()->children[0]); 3543 static_cast<DidDrawCheckLayer*>(layer1->test_properties()->children[0]);
3529 3544
3530 layer1->test_properties()->force_render_surface = true; 3545 layer1->test_properties()->force_render_surface = true;
3531 layer1->test_properties()->should_flatten_transform = true; 3546 layer1->test_properties()->should_flatten_transform = true;
3532 3547
3533 EXPECT_FALSE(root->did_draw_called()); 3548 EXPECT_FALSE(root->did_draw_called());
3534 EXPECT_FALSE(layer1->did_draw_called()); 3549 EXPECT_FALSE(layer1->did_draw_called());
3535 EXPECT_FALSE(layer2->did_draw_called()); 3550 EXPECT_FALSE(layer2->did_draw_called());
3536 3551
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
3693 host_impl_->DidDrawAllLayers(frame); 3708 host_impl_->DidDrawAllLayers(frame);
3694 host_impl_->SwapBuffers(frame); 3709 host_impl_->SwapBuffers(frame);
3695 3710
3696 for (size_t i = 0; i < cases.size(); ++i) { 3711 for (size_t i = 0; i < cases.size(); ++i) {
3697 // Clean up host_impl_ state. 3712 // Clean up host_impl_ state.
3698 const auto& testcase = cases[i]; 3713 const auto& testcase = cases[i];
3699 std::vector<LayerImpl*> to_remove; 3714 std::vector<LayerImpl*> to_remove;
3700 for (const auto& child : root->test_properties()->children) 3715 for (const auto& child : root->test_properties()->children)
3701 to_remove.push_back(child); 3716 to_remove.push_back(child);
3702 for (auto* child : to_remove) 3717 for (auto* child : to_remove)
3703 root->RemoveChildForTesting(child); 3718 root->test_properties()->RemoveChild(child);
3704 timeline()->ClearPlayers(); 3719 timeline()->ClearPlayers();
3705 3720
3706 std::ostringstream scope; 3721 std::ostringstream scope;
3707 scope << "Test case: " << i; 3722 scope << "Test case: " << i;
3708 SCOPED_TRACE(scope.str()); 3723 SCOPED_TRACE(scope.str());
3709 3724
3710 root->AddChild(MissingTextureAnimatingLayer::Create( 3725 root->test_properties()->AddChild(MissingTextureAnimatingLayer::Create(
3711 host_impl_->active_tree(), 2, testcase.layer_before.has_missing_tile, 3726 host_impl_->active_tree(), 2, testcase.layer_before.has_missing_tile,
3712 testcase.layer_before.has_incomplete_tile, 3727 testcase.layer_before.has_incomplete_tile,
3713 testcase.layer_before.is_animating, host_impl_->resource_provider(), 3728 testcase.layer_before.is_animating, host_impl_->resource_provider(),
3714 timeline())); 3729 timeline()));
3715 DidDrawCheckLayer* before = static_cast<DidDrawCheckLayer*>( 3730 DidDrawCheckLayer* before = static_cast<DidDrawCheckLayer*>(
3716 root->test_properties()->children.back()); 3731 root->test_properties()->children.back());
3717 if (testcase.layer_before.has_copy_request) 3732 if (testcase.layer_before.has_copy_request)
3718 before->AddCopyRequest(); 3733 before->AddCopyRequest();
3719 3734
3720 root->AddChild(MissingTextureAnimatingLayer::Create( 3735 root->test_properties()->AddChild(MissingTextureAnimatingLayer::Create(
3721 host_impl_->active_tree(), 3, testcase.layer_between.has_missing_tile, 3736 host_impl_->active_tree(), 3, testcase.layer_between.has_missing_tile,
3722 testcase.layer_between.has_incomplete_tile, 3737 testcase.layer_between.has_incomplete_tile,
3723 testcase.layer_between.is_animating, host_impl_->resource_provider(), 3738 testcase.layer_between.is_animating, host_impl_->resource_provider(),
3724 timeline())); 3739 timeline()));
3725 DidDrawCheckLayer* between = static_cast<DidDrawCheckLayer*>( 3740 DidDrawCheckLayer* between = static_cast<DidDrawCheckLayer*>(
3726 root->test_properties()->children.back()); 3741 root->test_properties()->children.back());
3727 if (testcase.layer_between.has_copy_request) 3742 if (testcase.layer_between.has_copy_request)
3728 between->AddCopyRequest(); 3743 between->AddCopyRequest();
3729 3744
3730 root->AddChild(MissingTextureAnimatingLayer::Create( 3745 root->test_properties()->AddChild(MissingTextureAnimatingLayer::Create(
3731 host_impl_->active_tree(), 4, testcase.layer_after.has_missing_tile, 3746 host_impl_->active_tree(), 4, testcase.layer_after.has_missing_tile,
3732 testcase.layer_after.has_incomplete_tile, 3747 testcase.layer_after.has_incomplete_tile,
3733 testcase.layer_after.is_animating, host_impl_->resource_provider(), 3748 testcase.layer_after.is_animating, host_impl_->resource_provider(),
3734 timeline())); 3749 timeline()));
3735 DidDrawCheckLayer* after = static_cast<DidDrawCheckLayer*>( 3750 DidDrawCheckLayer* after = static_cast<DidDrawCheckLayer*>(
3736 root->test_properties()->children.back()); 3751 root->test_properties()->children.back());
3737 if (testcase.layer_after.has_copy_request) 3752 if (testcase.layer_after.has_copy_request)
3738 after->AddCopyRequest(); 3753 after->AddCopyRequest();
3739 3754
3740 if (testcase.high_res_required) 3755 if (testcase.high_res_required)
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
3788 SetNeedsRebuildPropertyTrees(); 3803 SetNeedsRebuildPropertyTrees();
3789 host_impl_->OnDraw(external_transform, external_viewport, external_clip, 3804 host_impl_->OnDraw(external_transform, external_viewport, external_clip,
3790 resourceless_software_draw); 3805 resourceless_software_draw);
3791 3806
3792 for (size_t i = 0; i < cases.size(); ++i) { 3807 for (size_t i = 0; i < cases.size(); ++i) {
3793 const auto& testcase = cases[i]; 3808 const auto& testcase = cases[i];
3794 std::vector<LayerImpl*> to_remove; 3809 std::vector<LayerImpl*> to_remove;
3795 for (const auto& child : root->test_properties()->children) 3810 for (const auto& child : root->test_properties()->children)
3796 to_remove.push_back(child); 3811 to_remove.push_back(child);
3797 for (auto* child : to_remove) 3812 for (auto* child : to_remove)
3798 root->RemoveChildForTesting(child); 3813 root->test_properties()->RemoveChild(child);
3799 3814
3800 std::ostringstream scope; 3815 std::ostringstream scope;
3801 scope << "Test case: " << i; 3816 scope << "Test case: " << i;
3802 SCOPED_TRACE(scope.str()); 3817 SCOPED_TRACE(scope.str());
3803 3818
3804 root->AddChild(MissingTextureAnimatingLayer::Create( 3819 root->test_properties()->AddChild(MissingTextureAnimatingLayer::Create(
3805 host_impl_->active_tree(), 2, testcase.layer_before.has_missing_tile, 3820 host_impl_->active_tree(), 2, testcase.layer_before.has_missing_tile,
3806 testcase.layer_before.has_incomplete_tile, 3821 testcase.layer_before.has_incomplete_tile,
3807 testcase.layer_before.is_animating, host_impl_->resource_provider(), 3822 testcase.layer_before.is_animating, host_impl_->resource_provider(),
3808 timeline())); 3823 timeline()));
3809 DidDrawCheckLayer* before = static_cast<DidDrawCheckLayer*>( 3824 DidDrawCheckLayer* before = static_cast<DidDrawCheckLayer*>(
3810 root->test_properties()->children.back()); 3825 root->test_properties()->children.back());
3811 if (testcase.layer_before.has_copy_request) 3826 if (testcase.layer_before.has_copy_request)
3812 before->AddCopyRequest(); 3827 before->AddCopyRequest();
3813 3828
3814 root->AddChild(MissingTextureAnimatingLayer::Create( 3829 root->test_properties()->AddChild(MissingTextureAnimatingLayer::Create(
3815 host_impl_->active_tree(), 3, testcase.layer_between.has_missing_tile, 3830 host_impl_->active_tree(), 3, testcase.layer_between.has_missing_tile,
3816 testcase.layer_between.has_incomplete_tile, 3831 testcase.layer_between.has_incomplete_tile,
3817 testcase.layer_between.is_animating, host_impl_->resource_provider(), 3832 testcase.layer_between.is_animating, host_impl_->resource_provider(),
3818 timeline())); 3833 timeline()));
3819 DidDrawCheckLayer* between = static_cast<DidDrawCheckLayer*>( 3834 DidDrawCheckLayer* between = static_cast<DidDrawCheckLayer*>(
3820 root->test_properties()->children.back()); 3835 root->test_properties()->children.back());
3821 if (testcase.layer_between.has_copy_request) 3836 if (testcase.layer_between.has_copy_request)
3822 between->AddCopyRequest(); 3837 between->AddCopyRequest();
3823 3838
3824 root->AddChild(MissingTextureAnimatingLayer::Create( 3839 root->test_properties()->AddChild(MissingTextureAnimatingLayer::Create(
3825 host_impl_->active_tree(), 4, testcase.layer_after.has_missing_tile, 3840 host_impl_->active_tree(), 4, testcase.layer_after.has_missing_tile,
3826 testcase.layer_after.has_incomplete_tile, 3841 testcase.layer_after.has_incomplete_tile,
3827 testcase.layer_after.is_animating, host_impl_->resource_provider(), 3842 testcase.layer_after.is_animating, host_impl_->resource_provider(),
3828 timeline())); 3843 timeline()));
3829 DidDrawCheckLayer* after = static_cast<DidDrawCheckLayer*>( 3844 DidDrawCheckLayer* after = static_cast<DidDrawCheckLayer*>(
3830 root->test_properties()->children.back()); 3845 root->test_properties()->children.back());
3831 if (testcase.layer_after.has_copy_request) 3846 if (testcase.layer_after.has_copy_request)
3832 after->AddCopyRequest(); 3847 after->AddCopyRequest();
3833 3848
3834 if (testcase.high_res_required) 3849 if (testcase.high_res_required)
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
3948 outer_scroll->SetBounds(scroll_layer_size); 3963 outer_scroll->SetBounds(scroll_layer_size);
3949 outer_scroll->SetPosition(gfx::PointF()); 3964 outer_scroll->SetPosition(gfx::PointF());
3950 outer_scroll->SetDrawsContent(false); 3965 outer_scroll->SetDrawsContent(false);
3951 outer_scroll->test_properties()->is_container_for_fixed_position_layers = 3966 outer_scroll->test_properties()->is_container_for_fixed_position_layers =
3952 true; 3967 true;
3953 3968
3954 int inner_viewport_scroll_layer_id = root->id(); 3969 int inner_viewport_scroll_layer_id = root->id();
3955 int outer_viewport_scroll_layer_id = outer_scroll->id(); 3970 int outer_viewport_scroll_layer_id = outer_scroll->id();
3956 int page_scale_layer_id = page_scale->id(); 3971 int page_scale_layer_id = page_scale->id();
3957 3972
3958 outer_clip->AddChild(std::move(outer_scroll)); 3973 outer_clip->test_properties()->AddChild(std::move(outer_scroll));
3959 root->AddChild(std::move(outer_clip)); 3974 root->test_properties()->AddChild(std::move(outer_clip));
3960 page_scale->AddChild(std::move(root)); 3975 page_scale->test_properties()->AddChild(std::move(root));
3961 root_clip->AddChild(std::move(page_scale)); 3976 root_clip->test_properties()->AddChild(std::move(page_scale));
3962 3977
3963 tree_impl->SetRootLayer(std::move(root_clip)); 3978 tree_impl->SetRootLayer(std::move(root_clip));
3964 tree_impl->SetViewportLayersFromIds(Layer::INVALID_ID, page_scale_layer_id, 3979 tree_impl->SetViewportLayersFromIds(Layer::INVALID_ID, page_scale_layer_id,
3965 inner_viewport_scroll_layer_id, 3980 inner_viewport_scroll_layer_id,
3966 outer_viewport_scroll_layer_id); 3981 outer_viewport_scroll_layer_id);
3967 tree_impl->BuildLayerListAndPropertyTreesForTesting(); 3982 tree_impl->BuildLayerListAndPropertyTreesForTesting();
3968 3983
3969 host_impl_->SetViewportSize(inner_viewport_size); 3984 host_impl_->SetViewportSize(inner_viewport_size);
3970 LayerImpl* root_clip_ptr = tree_impl->root_layer(); 3985 LayerImpl* root_clip_ptr = tree_impl->root_layer();
3971 EXPECT_EQ(inner_viewport_size, root_clip_ptr->bounds()); 3986 EXPECT_EQ(inner_viewport_size, root_clip_ptr->bounds());
(...skipping 15 matching lines...) Expand all
3987 // place. 4002 // place.
3988 TEST_F(LayerTreeHostImplTopControlsTest, 4003 TEST_F(LayerTreeHostImplTopControlsTest,
3989 HidingTopControlsExpandsScrollableSize) { 4004 HidingTopControlsExpandsScrollableSize) {
3990 SetupTopControlsAndScrollLayerWithVirtualViewport( 4005 SetupTopControlsAndScrollLayerWithVirtualViewport(
3991 gfx::Size(50, 50), gfx::Size(50, 50), gfx::Size(50, 50)); 4006 gfx::Size(50, 50), gfx::Size(50, 50), gfx::Size(50, 50));
3992 4007
3993 LayerTreeImpl* active_tree = host_impl_->active_tree(); 4008 LayerTreeImpl* active_tree = host_impl_->active_tree();
3994 4009
3995 // Create a content layer beneath the outer viewport scroll layer. 4010 // Create a content layer beneath the outer viewport scroll layer.
3996 int id = host_impl_->OuterViewportScrollLayer()->id(); 4011 int id = host_impl_->OuterViewportScrollLayer()->id();
3997 host_impl_->OuterViewportScrollLayer()->AddChild( 4012 host_impl_->OuterViewportScrollLayer()->test_properties()->AddChild(
3998 LayerImpl::Create(host_impl_->active_tree(), id + 2)); 4013 LayerImpl::Create(host_impl_->active_tree(), id + 2));
3999 LayerImpl* content = 4014 LayerImpl* content =
4000 active_tree->OuterViewportScrollLayer()->test_properties()->children[0]; 4015 active_tree->OuterViewportScrollLayer()->test_properties()->children[0];
4001 content->SetBounds(gfx::Size(50, 50)); 4016 content->SetBounds(gfx::Size(50, 50));
4002 4017
4003 SetNeedsRebuildPropertyTrees(); 4018 SetNeedsRebuildPropertyTrees();
4004 DrawFrame(); 4019 DrawFrame();
4005 4020
4006 LayerImpl* inner_container = active_tree->InnerViewportContainerLayer(); 4021 LayerImpl* inner_container = active_tree->InnerViewportContainerLayer();
4007 LayerImpl* outer_container = active_tree->OuterViewportContainerLayer(); 4022 LayerImpl* outer_container = active_tree->OuterViewportContainerLayer();
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
4265 4280
4266 child_clip->SetBounds(sub_content_layer_size); 4281 child_clip->SetBounds(sub_content_layer_size);
4267 child->SetScrollClipLayer(child_clip->id()); 4282 child->SetScrollClipLayer(child_clip->id());
4268 child->SetBounds(sub_content_size); 4283 child->SetBounds(sub_content_size);
4269 child->SetPosition(gfx::PointF()); 4284 child->SetPosition(gfx::PointF());
4270 child->SetDrawsContent(true); 4285 child->SetDrawsContent(true);
4271 child->test_properties()->is_container_for_fixed_position_layers = true; 4286 child->test_properties()->is_container_for_fixed_position_layers = true;
4272 4287
4273 // scroll child to limit 4288 // scroll child to limit
4274 SetScrollOffsetDelta(child.get(), gfx::Vector2dF(0, 100.f)); 4289 SetScrollOffsetDelta(child.get(), gfx::Vector2dF(0, 100.f));
4275 child_clip->AddChild(std::move(child)); 4290 child_clip->test_properties()->AddChild(std::move(child));
4276 outer_viewport_scroll_layer->AddChild(std::move(child_clip)); 4291 outer_viewport_scroll_layer->test_properties()->AddChild(
4292 std::move(child_clip));
4277 4293
4278 // Scroll 25px to hide top controls 4294 // Scroll 25px to hide top controls
4279 gfx::Vector2dF scroll_delta(0.f, 25.f); 4295 gfx::Vector2dF scroll_delta(0.f, 25.f);
4280 host_impl_->active_tree()->property_trees()->needs_rebuild = true; 4296 host_impl_->active_tree()->property_trees()->needs_rebuild = true;
4281 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); 4297 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting();
4282 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 4298 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
4283 host_impl_ 4299 host_impl_
4284 ->ScrollBegin(BeginState(gfx::Point()).get(), 4300 ->ScrollBegin(BeginState(gfx::Point()).get(),
4285 InputHandler::TOUCHSCREEN) 4301 InputHandler::TOUCHSCREEN)
4286 .thread); 4302 .thread);
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
4757 4773
4758 std::unique_ptr<LayerImpl> scroll_clip_layer = 4774 std::unique_ptr<LayerImpl> scroll_clip_layer =
4759 LayerImpl::Create(host_impl_->active_tree(), 3); 4775 LayerImpl::Create(host_impl_->active_tree(), 3);
4760 scroll_clip_layer->SetBounds(surface_size); 4776 scroll_clip_layer->SetBounds(surface_size);
4761 4777
4762 std::unique_ptr<LayerImpl> scroll_layer = 4778 std::unique_ptr<LayerImpl> scroll_layer =
4763 LayerImpl::Create(host_impl_->active_tree(), 2); 4779 LayerImpl::Create(host_impl_->active_tree(), 2);
4764 scroll_layer->SetScrollClipLayer(3); 4780 scroll_layer->SetScrollClipLayer(3);
4765 scroll_layer->SetBounds(contents_size); 4781 scroll_layer->SetBounds(contents_size);
4766 scroll_layer->SetPosition(gfx::PointF()); 4782 scroll_layer->SetPosition(gfx::PointF());
4767 scroll_layer->AddChild(std::move(content_layer)); 4783 scroll_layer->test_properties()->AddChild(std::move(content_layer));
4768 scroll_clip_layer->AddChild(std::move(scroll_layer)); 4784 scroll_clip_layer->test_properties()->AddChild(std::move(scroll_layer));
4769 4785
4770 scroll_clip_layer->test_properties()->force_render_surface = true; 4786 scroll_clip_layer->test_properties()->force_render_surface = true;
4771 host_impl_->active_tree()->SetRootLayer(std::move(scroll_clip_layer)); 4787 host_impl_->active_tree()->SetRootLayer(std::move(scroll_clip_layer));
4772 host_impl_->SetViewportSize(surface_size); 4788 host_impl_->SetViewportSize(surface_size);
4773 SetNeedsRebuildPropertyTrees(); 4789 SetNeedsRebuildPropertyTrees();
4774 DrawFrame(); 4790 DrawFrame();
4775 4791
4776 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 4792 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
4777 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), 4793 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(),
4778 InputHandler::WHEEL) 4794 InputHandler::WHEEL)
4779 .thread); 4795 .thread);
4780 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); 4796 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get());
4781 host_impl_->ScrollEnd(EndState().get()); 4797 host_impl_->ScrollEnd(EndState().get());
4782 EXPECT_TRUE(did_request_redraw_); 4798 EXPECT_TRUE(did_request_redraw_);
4783 EXPECT_TRUE(did_request_commit_); 4799 EXPECT_TRUE(did_request_commit_);
4784 } 4800 }
4785 4801
4786 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { 4802 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) {
4787 gfx::Size surface_size(10, 10); 4803 gfx::Size surface_size(10, 10);
4788 gfx::Size contents_size(20, 20); 4804 gfx::Size contents_size(20, 20);
4789 std::unique_ptr<LayerImpl> root = 4805 std::unique_ptr<LayerImpl> root =
4790 LayerImpl::Create(host_impl_->active_tree(), 1); 4806 LayerImpl::Create(host_impl_->active_tree(), 1);
4791 root->SetBounds(surface_size); 4807 root->SetBounds(surface_size);
4792 root->AddChild(CreateScrollableLayer(2, contents_size, root.get())); 4808 root->test_properties()->AddChild(
4809 CreateScrollableLayer(2, contents_size, root.get()));
4793 root->test_properties()->force_render_surface = true; 4810 root->test_properties()->force_render_surface = true;
4794 host_impl_->active_tree()->SetRootLayer(std::move(root)); 4811 host_impl_->active_tree()->SetRootLayer(std::move(root));
4795 host_impl_->SetViewportSize(surface_size); 4812 host_impl_->SetViewportSize(surface_size);
4796 SetNeedsRebuildPropertyTrees(); 4813 SetNeedsRebuildPropertyTrees();
4797 DrawFrame(); 4814 DrawFrame();
4798 4815
4799 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 4816 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
4800 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), 4817 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(),
4801 InputHandler::WHEEL) 4818 InputHandler::WHEEL)
4802 .thread); 4819 .thread);
4803 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); 4820 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get());
4804 host_impl_->ScrollEnd(EndState().get()); 4821 host_impl_->ScrollEnd(EndState().get());
4805 EXPECT_TRUE(did_request_redraw_); 4822 EXPECT_TRUE(did_request_redraw_);
4806 EXPECT_TRUE(did_request_commit_); 4823 EXPECT_TRUE(did_request_commit_);
4807 } 4824 }
4808 4825
4809 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { 4826 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) {
4810 gfx::Size surface_size(10, 10); 4827 gfx::Size surface_size(10, 10);
4811 std::unique_ptr<LayerImpl> root = 4828 std::unique_ptr<LayerImpl> root =
4812 LayerImpl::Create(host_impl_->active_tree(), 1); 4829 LayerImpl::Create(host_impl_->active_tree(), 1);
4813 root->AddChild(CreateScrollableLayer(2, surface_size, root.get())); 4830 root->test_properties()->AddChild(
4831 CreateScrollableLayer(2, surface_size, root.get()));
4814 root->test_properties()->force_render_surface = true; 4832 root->test_properties()->force_render_surface = true;
4815 host_impl_->active_tree()->SetRootLayer(std::move(root)); 4833 host_impl_->active_tree()->SetRootLayer(std::move(root));
4816 host_impl_->SetViewportSize(surface_size); 4834 host_impl_->SetViewportSize(surface_size);
4817 SetNeedsRebuildPropertyTrees(); 4835 SetNeedsRebuildPropertyTrees();
4818 DrawFrame(); 4836 DrawFrame();
4819 4837
4820 // Scroll event is ignored because the input coordinate is outside the layer 4838 // Scroll event is ignored because the input coordinate is outside the layer
4821 // boundaries. 4839 // boundaries.
4822 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( 4840 InputHandler::ScrollStatus status = host_impl_->ScrollBegin(
4823 BeginState(gfx::Point(15, 5)).get(), InputHandler::WHEEL); 4841 BeginState(gfx::Point(15, 5)).get(), InputHandler::WHEEL);
(...skipping 12 matching lines...) Expand all
4836 root->test_properties()->force_render_surface = true; 4854 root->test_properties()->force_render_surface = true;
4837 std::unique_ptr<LayerImpl> child = 4855 std::unique_ptr<LayerImpl> child =
4838 CreateScrollableLayer(2, surface_size, root.get()); 4856 CreateScrollableLayer(2, surface_size, root.get());
4839 host_impl_->SetViewportSize(surface_size); 4857 host_impl_->SetViewportSize(surface_size);
4840 4858
4841 gfx::Transform matrix; 4859 gfx::Transform matrix;
4842 matrix.RotateAboutXAxis(180.0); 4860 matrix.RotateAboutXAxis(180.0);
4843 child->SetTransform(matrix); 4861 child->SetTransform(matrix);
4844 child->test_properties()->double_sided = false; 4862 child->test_properties()->double_sided = false;
4845 4863
4846 root->AddChild(std::move(child)); 4864 root->test_properties()->AddChild(std::move(child));
4847 host_impl_->active_tree()->SetRootLayer(std::move(root)); 4865 host_impl_->active_tree()->SetRootLayer(std::move(root));
4848 SetNeedsRebuildPropertyTrees(); 4866 SetNeedsRebuildPropertyTrees();
4849 DrawFrame(); 4867 DrawFrame();
4850 4868
4851 // Scroll event is ignored because the scrollable layer is not facing the 4869 // Scroll event is ignored because the scrollable layer is not facing the
4852 // viewer and there is nothing scrollable behind it. 4870 // viewer and there is nothing scrollable behind it.
4853 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( 4871 InputHandler::ScrollStatus status = host_impl_->ScrollBegin(
4854 BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL); 4872 BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL);
4855 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); 4873 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread);
4856 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, 4874 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer,
(...skipping 10 matching lines...) Expand all
4867 std::unique_ptr<LayerImpl> content_layer = 4885 std::unique_ptr<LayerImpl> content_layer =
4868 CreateScrollableLayer(1, surface_size, clip_layer.get()); 4886 CreateScrollableLayer(1, surface_size, clip_layer.get());
4869 content_layer->set_main_thread_scrolling_reasons( 4887 content_layer->set_main_thread_scrolling_reasons(
4870 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); 4888 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects);
4871 content_layer->SetScrollClipLayer(Layer::INVALID_ID); 4889 content_layer->SetScrollClipLayer(Layer::INVALID_ID);
4872 4890
4873 // Note: we can use the same clip layer for both since both calls to 4891 // Note: we can use the same clip layer for both since both calls to
4874 // CreateScrollableLayer() use the same surface size. 4892 // CreateScrollableLayer() use the same surface size.
4875 std::unique_ptr<LayerImpl> scroll_layer = 4893 std::unique_ptr<LayerImpl> scroll_layer =
4876 CreateScrollableLayer(2, surface_size, clip_layer.get()); 4894 CreateScrollableLayer(2, surface_size, clip_layer.get());
4877 scroll_layer->AddChild(std::move(content_layer)); 4895 scroll_layer->test_properties()->AddChild(std::move(content_layer));
4878 clip_layer->AddChild(std::move(scroll_layer)); 4896 clip_layer->test_properties()->AddChild(std::move(scroll_layer));
4879 clip_layer->test_properties()->force_render_surface = true; 4897 clip_layer->test_properties()->force_render_surface = true;
4880 4898
4881 host_impl_->active_tree()->SetRootLayer(std::move(clip_layer)); 4899 host_impl_->active_tree()->SetRootLayer(std::move(clip_layer));
4882 host_impl_->SetViewportSize(surface_size); 4900 host_impl_->SetViewportSize(surface_size);
4883 SetNeedsRebuildPropertyTrees(); 4901 SetNeedsRebuildPropertyTrees();
4884 DrawFrame(); 4902 DrawFrame();
4885 4903
4886 // Scrolling fails because the content layer is asking to be scrolled on the 4904 // Scrolling fails because the content layer is asking to be scrolled on the
4887 // main thread. 4905 // main thread.
4888 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( 4906 InputHandler::ScrollStatus status = host_impl_->ScrollBegin(
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
5009 LayerImpl* scroll = SetupScrollAndContentsLayers(surface_size); 5027 LayerImpl* scroll = SetupScrollAndContentsLayers(surface_size);
5010 scroll->SetDrawsContent(true); 5028 scroll->SetDrawsContent(true);
5011 LayerImpl* root = host_impl_->active_tree()->root_layer(); 5029 LayerImpl* root = host_impl_->active_tree()->root_layer();
5012 LayerImpl* child = scroll->test_properties()->children[0]; 5030 LayerImpl* child = scroll->test_properties()->children[0];
5013 child->SetDrawsContent(true); 5031 child->SetDrawsContent(true);
5014 5032
5015 std::unique_ptr<LayerImpl> scrollable_child_clip = 5033 std::unique_ptr<LayerImpl> scrollable_child_clip =
5016 LayerImpl::Create(host_impl_->active_tree(), 6); 5034 LayerImpl::Create(host_impl_->active_tree(), 6);
5017 std::unique_ptr<LayerImpl> scrollable_child = 5035 std::unique_ptr<LayerImpl> scrollable_child =
5018 CreateScrollableLayer(7, surface_size, scrollable_child_clip.get()); 5036 CreateScrollableLayer(7, surface_size, scrollable_child_clip.get());
5019 scrollable_child_clip->AddChild(std::move(scrollable_child)); 5037 scrollable_child_clip->test_properties()->AddChild(
5020 child->AddChild(std::move(scrollable_child_clip)); 5038 std::move(scrollable_child));
5039 child->test_properties()->AddChild(std::move(scrollable_child_clip));
5021 LayerImpl* grand_child = child->test_properties()->children[0]; 5040 LayerImpl* grand_child = child->test_properties()->children[0];
5022 grand_child->SetDrawsContent(true); 5041 grand_child->SetDrawsContent(true);
5023 5042
5024 // Set new page scale on impl thread by pinching. 5043 // Set new page scale on impl thread by pinching.
5025 SetNeedsRebuildPropertyTrees(); 5044 SetNeedsRebuildPropertyTrees();
5026 RebuildPropertyTrees(); 5045 RebuildPropertyTrees();
5027 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 5046 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
5028 InputHandler::TOUCHSCREEN); 5047 InputHandler::TOUCHSCREEN);
5029 host_impl_->PinchGestureBegin(); 5048 host_impl_->PinchGestureBegin();
5030 host_impl_->PinchGestureUpdate(new_page_scale, gfx::Point()); 5049 host_impl_->PinchGestureUpdate(new_page_scale, gfx::Point());
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
5099 std::unique_ptr<LayerImpl> root = 5118 std::unique_ptr<LayerImpl> root =
5100 LayerImpl::Create(host_impl_->active_tree(), 1); 5119 LayerImpl::Create(host_impl_->active_tree(), 1);
5101 root->SetBounds(surface_size); 5120 root->SetBounds(surface_size);
5102 root->test_properties()->force_render_surface = true; 5121 root->test_properties()->force_render_surface = true;
5103 std::unique_ptr<LayerImpl> grand_child = 5122 std::unique_ptr<LayerImpl> grand_child =
5104 CreateScrollableLayer(3, content_size, root.get()); 5123 CreateScrollableLayer(3, content_size, root.get());
5105 5124
5106 std::unique_ptr<LayerImpl> child = 5125 std::unique_ptr<LayerImpl> child =
5107 CreateScrollableLayer(2, content_size, root.get()); 5126 CreateScrollableLayer(2, content_size, root.get());
5108 LayerImpl* grand_child_layer = grand_child.get(); 5127 LayerImpl* grand_child_layer = grand_child.get();
5109 child->AddChild(std::move(grand_child)); 5128 child->test_properties()->AddChild(std::move(grand_child));
5110 5129
5111 LayerImpl* child_layer = child.get(); 5130 LayerImpl* child_layer = child.get();
5112 root->AddChild(std::move(child)); 5131 root->test_properties()->AddChild(std::move(child));
5113 host_impl_->active_tree()->SetRootLayer(std::move(root)); 5132 host_impl_->active_tree()->SetRootLayer(std::move(root));
5114 host_impl_->active_tree()->DidBecomeActive(); 5133 host_impl_->active_tree()->DidBecomeActive();
5115 host_impl_->SetViewportSize(surface_size); 5134 host_impl_->SetViewportSize(surface_size);
5116 grand_child_layer->layer_tree_impl() 5135 grand_child_layer->layer_tree_impl()
5117 ->property_trees() 5136 ->property_trees()
5118 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(), 5137 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(),
5119 gfx::ScrollOffset(0, 5)); 5138 gfx::ScrollOffset(0, 5));
5120 child_layer->layer_tree_impl() 5139 child_layer->layer_tree_impl()
5121 ->property_trees() 5140 ->property_trees()
5122 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(), 5141 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(),
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
5162 CreateScrollableLayer(3, surface_size, root_clip.get()); 5181 CreateScrollableLayer(3, surface_size, root_clip.get());
5163 root_scrolling->test_properties()->is_container_for_fixed_position_layers = 5182 root_scrolling->test_properties()->is_container_for_fixed_position_layers =
5164 true; 5183 true;
5165 5184
5166 std::unique_ptr<LayerImpl> grand_child = 5185 std::unique_ptr<LayerImpl> grand_child =
5167 CreateScrollableLayer(5, surface_size, root_clip.get()); 5186 CreateScrollableLayer(5, surface_size, root_clip.get());
5168 5187
5169 std::unique_ptr<LayerImpl> child = 5188 std::unique_ptr<LayerImpl> child =
5170 CreateScrollableLayer(4, surface_size, root_clip.get()); 5189 CreateScrollableLayer(4, surface_size, root_clip.get());
5171 LayerImpl* grand_child_layer = grand_child.get(); 5190 LayerImpl* grand_child_layer = grand_child.get();
5172 child->AddChild(std::move(grand_child)); 5191 child->test_properties()->AddChild(std::move(grand_child));
5173 5192
5174 LayerImpl* child_layer = child.get(); 5193 LayerImpl* child_layer = child.get();
5175 root_scrolling->AddChild(std::move(child)); 5194 root_scrolling->test_properties()->AddChild(std::move(child));
5176 root_clip->AddChild(std::move(root_scrolling)); 5195 root_clip->test_properties()->AddChild(std::move(root_scrolling));
5177 EXPECT_EQ(viewport_size, root_clip->bounds()); 5196 EXPECT_EQ(viewport_size, root_clip->bounds());
5178 root_ptr->AddChild(std::move(root_clip)); 5197 root_ptr->test_properties()->AddChild(std::move(root_clip));
5179 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr)); 5198 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr));
5180 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, 5199 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3,
5181 Layer::INVALID_ID); 5200 Layer::INVALID_ID);
5182 host_impl_->active_tree()->DidBecomeActive(); 5201 host_impl_->active_tree()->DidBecomeActive();
5183 host_impl_->SetViewportSize(viewport_size); 5202 host_impl_->SetViewportSize(viewport_size);
5184 5203
5185 grand_child_layer->layer_tree_impl() 5204 grand_child_layer->layer_tree_impl()
5186 ->property_trees() 5205 ->property_trees()
5187 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(), 5206 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(),
5188 gfx::ScrollOffset(0, 2)); 5207 gfx::ScrollOffset(0, 2));
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
5297 std::unique_ptr<LayerImpl> root_scroll = 5316 std::unique_ptr<LayerImpl> root_scroll =
5298 CreateScrollableLayer(1, content_size, root_clip.get()); 5317 CreateScrollableLayer(1, content_size, root_clip.get());
5299 // Make 'root' the clip layer for child: since they have the same sizes the 5318 // Make 'root' the clip layer for child: since they have the same sizes the
5300 // child will have zero max_scroll_offset and scrolls will bubble. 5319 // child will have zero max_scroll_offset and scrolls will bubble.
5301 std::unique_ptr<LayerImpl> child = 5320 std::unique_ptr<LayerImpl> child =
5302 CreateScrollableLayer(2, content_size, root_scroll.get()); 5321 CreateScrollableLayer(2, content_size, root_scroll.get());
5303 child->test_properties()->is_container_for_fixed_position_layers = true; 5322 child->test_properties()->is_container_for_fixed_position_layers = true;
5304 root_scroll->SetBounds(content_size); 5323 root_scroll->SetBounds(content_size);
5305 5324
5306 int root_scroll_id = root_scroll->id(); 5325 int root_scroll_id = root_scroll->id();
5307 root_scroll->AddChild(std::move(child)); 5326 root_scroll->test_properties()->AddChild(std::move(child));
5308 root_clip->AddChild(std::move(root_scroll)); 5327 root_clip->test_properties()->AddChild(std::move(root_scroll));
5309 root_ptr->AddChild(std::move(root_clip)); 5328 root_ptr->test_properties()->AddChild(std::move(root_clip));
5310 5329
5311 host_impl_->SetViewportSize(surface_size); 5330 host_impl_->SetViewportSize(surface_size);
5312 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr)); 5331 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr));
5313 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 2, 5332 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 2,
5314 Layer::INVALID_ID); 5333 Layer::INVALID_ID);
5315 host_impl_->active_tree()->DidBecomeActive(); 5334 host_impl_->active_tree()->DidBecomeActive();
5316 SetNeedsRebuildPropertyTrees(); 5335 SetNeedsRebuildPropertyTrees();
5317 DrawFrame(); 5336 DrawFrame();
5318 { 5337 {
5319 gfx::Vector2d scroll_delta(0, 4); 5338 gfx::Vector2d scroll_delta(0, 4);
(...skipping 17 matching lines...) Expand all
5337 TEST_F(LayerTreeHostImplTest, ScrollBeforeRedraw) { 5356 TEST_F(LayerTreeHostImplTest, ScrollBeforeRedraw) {
5338 gfx::Size surface_size(10, 10); 5357 gfx::Size surface_size(10, 10);
5339 std::unique_ptr<LayerImpl> root_ptr = 5358 std::unique_ptr<LayerImpl> root_ptr =
5340 LayerImpl::Create(host_impl_->active_tree(), 1); 5359 LayerImpl::Create(host_impl_->active_tree(), 1);
5341 std::unique_ptr<LayerImpl> root_clip = 5360 std::unique_ptr<LayerImpl> root_clip =
5342 LayerImpl::Create(host_impl_->active_tree(), 2); 5361 LayerImpl::Create(host_impl_->active_tree(), 2);
5343 std::unique_ptr<LayerImpl> root_scroll = 5362 std::unique_ptr<LayerImpl> root_scroll =
5344 CreateScrollableLayer(3, surface_size, root_clip.get()); 5363 CreateScrollableLayer(3, surface_size, root_clip.get());
5345 root_clip->test_properties()->force_render_surface = true; 5364 root_clip->test_properties()->force_render_surface = true;
5346 root_scroll->test_properties()->is_container_for_fixed_position_layers = true; 5365 root_scroll->test_properties()->is_container_for_fixed_position_layers = true;
5347 root_clip->AddChild(std::move(root_scroll)); 5366 root_clip->test_properties()->AddChild(std::move(root_scroll));
5348 root_ptr->AddChild(std::move(root_clip)); 5367 root_ptr->test_properties()->AddChild(std::move(root_clip));
5349 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr)); 5368 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr));
5350 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, 5369 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3,
5351 Layer::INVALID_ID); 5370 Layer::INVALID_ID);
5352 host_impl_->active_tree()->DidBecomeActive(); 5371 host_impl_->active_tree()->DidBecomeActive();
5353 host_impl_->SetViewportSize(surface_size); 5372 host_impl_->SetViewportSize(surface_size);
5354 5373
5355 // Draw one frame and then immediately rebuild the layer tree to mimic a tree 5374 // Draw one frame and then immediately rebuild the layer tree to mimic a tree
5356 // synchronization. 5375 // synchronization.
5357 SetNeedsRebuildPropertyTrees(); 5376 SetNeedsRebuildPropertyTrees();
5358 DrawFrame(); 5377 DrawFrame();
5359 host_impl_->active_tree()->DetachLayers(); 5378 host_impl_->active_tree()->DetachLayers();
5360 std::unique_ptr<LayerImpl> root_ptr2 = 5379 std::unique_ptr<LayerImpl> root_ptr2 =
5361 LayerImpl::Create(host_impl_->active_tree(), 4); 5380 LayerImpl::Create(host_impl_->active_tree(), 4);
5362 std::unique_ptr<LayerImpl> root_clip2 = 5381 std::unique_ptr<LayerImpl> root_clip2 =
5363 LayerImpl::Create(host_impl_->active_tree(), 5); 5382 LayerImpl::Create(host_impl_->active_tree(), 5);
5364 std::unique_ptr<LayerImpl> root_scroll2 = 5383 std::unique_ptr<LayerImpl> root_scroll2 =
5365 CreateScrollableLayer(6, surface_size, root_clip2.get()); 5384 CreateScrollableLayer(6, surface_size, root_clip2.get());
5366 root_scroll2->test_properties()->is_container_for_fixed_position_layers = 5385 root_scroll2->test_properties()->is_container_for_fixed_position_layers =
5367 true; 5386 true;
5368 root_clip2->AddChild(std::move(root_scroll2)); 5387 root_clip2->test_properties()->AddChild(std::move(root_scroll2));
5369 root_clip2->test_properties()->force_render_surface = true; 5388 root_clip2->test_properties()->force_render_surface = true;
5370 root_ptr2->AddChild(std::move(root_clip2)); 5389 root_ptr2->test_properties()->AddChild(std::move(root_clip2));
5371 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr2)); 5390 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr2));
5372 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 6, 5391 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 6,
5373 Layer::INVALID_ID); 5392 Layer::INVALID_ID);
5374 host_impl_->active_tree()->DidBecomeActive(); 5393 host_impl_->active_tree()->DidBecomeActive();
5375 5394
5376 // Scrolling should still work even though we did not draw yet. 5395 // Scrolling should still work even though we did not draw yet.
5377 SetNeedsRebuildPropertyTrees(); 5396 SetNeedsRebuildPropertyTrees();
5378 RebuildPropertyTrees(); 5397 RebuildPropertyTrees();
5379 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 5398 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
5380 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), 5399 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(),
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
5447 5466
5448 // Only allow vertical scrolling. 5467 // Only allow vertical scrolling.
5449 clip_layer->SetBounds( 5468 clip_layer->SetBounds(
5450 gfx::Size(child->bounds().width(), child->bounds().height() / 2)); 5469 gfx::Size(child->bounds().width(), child->bounds().height() / 2));
5451 // The rotation depends on the layer's transform origin, and the child layer 5470 // The rotation depends on the layer's transform origin, and the child layer
5452 // is a different size than the clip, so make sure the clip layer's origin 5471 // is a different size than the clip, so make sure the clip layer's origin
5453 // lines up over the child. 5472 // lines up over the child.
5454 clip_layer->test_properties()->transform_origin = gfx::Point3F( 5473 clip_layer->test_properties()->transform_origin = gfx::Point3F(
5455 clip_layer->bounds().width() * 0.5f, clip_layer->bounds().height(), 0.f); 5474 clip_layer->bounds().width() * 0.5f, clip_layer->bounds().height(), 0.f);
5456 LayerImpl* child_ptr = child.get(); 5475 LayerImpl* child_ptr = child.get();
5457 clip_layer->AddChild(std::move(child)); 5476 clip_layer->test_properties()->AddChild(std::move(child));
5458 scroll_layer->AddChild(std::move(clip_layer)); 5477 scroll_layer->test_properties()->AddChild(std::move(clip_layer));
5459 5478
5460 gfx::Size surface_size(50, 50); 5479 gfx::Size surface_size(50, 50);
5461 host_impl_->SetViewportSize(surface_size); 5480 host_impl_->SetViewportSize(surface_size);
5462 SetNeedsRebuildPropertyTrees(); 5481 SetNeedsRebuildPropertyTrees();
5463 DrawFrame(); 5482 DrawFrame();
5464 { 5483 {
5465 // Scroll down in screen coordinates with a gesture. 5484 // Scroll down in screen coordinates with a gesture.
5466 gfx::Vector2d gesture_scroll_delta(0, 10); 5485 gfx::Vector2d gesture_scroll_delta(0, 10);
5467 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 5486 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
5468 host_impl_ 5487 host_impl_
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
5532 perspective_transform.Translate(50.0, 50.0); 5551 perspective_transform.Translate(50.0, 50.0);
5533 clip_layer->SetTransform(perspective_transform); 5552 clip_layer->SetTransform(perspective_transform);
5534 5553
5535 clip_layer->SetBounds(gfx::Size(child_ptr->bounds().width() / 2, 5554 clip_layer->SetBounds(gfx::Size(child_ptr->bounds().width() / 2,
5536 child_ptr->bounds().height() / 2)); 5555 child_ptr->bounds().height() / 2));
5537 // The transform depends on the layer's transform origin, and the child layer 5556 // The transform depends on the layer's transform origin, and the child layer
5538 // is a different size than the clip, so make sure the clip layer's origin 5557 // is a different size than the clip, so make sure the clip layer's origin
5539 // lines up over the child. 5558 // lines up over the child.
5540 clip_layer->test_properties()->transform_origin = gfx::Point3F( 5559 clip_layer->test_properties()->transform_origin = gfx::Point3F(
5541 clip_layer->bounds().width(), clip_layer->bounds().height(), 0.f); 5560 clip_layer->bounds().width(), clip_layer->bounds().height(), 0.f);
5542 clip_layer->AddChild(std::move(child)); 5561 clip_layer->test_properties()->AddChild(std::move(child));
5543 scroll_layer->AddChild(std::move(clip_layer)); 5562 scroll_layer->test_properties()->AddChild(std::move(clip_layer));
5544 5563
5545 gfx::Size surface_size(50, 50); 5564 gfx::Size surface_size(50, 50);
5546 host_impl_->SetViewportSize(surface_size); 5565 host_impl_->SetViewportSize(surface_size);
5547 5566
5548 std::unique_ptr<ScrollAndScaleSet> scroll_info; 5567 std::unique_ptr<ScrollAndScaleSet> scroll_info;
5549 5568
5550 gfx::Vector2d gesture_scroll_deltas[4]; 5569 gfx::Vector2d gesture_scroll_deltas[4];
5551 gesture_scroll_deltas[0] = gfx::Vector2d(4, 10); 5570 gesture_scroll_deltas[0] = gfx::Vector2d(4, 10);
5552 gesture_scroll_deltas[1] = gfx::Vector2d(4, 10); 5571 gesture_scroll_deltas[1] = gfx::Vector2d(4, 10);
5553 gesture_scroll_deltas[2] = gfx::Vector2d(10, 0); 5572 gesture_scroll_deltas[2] = gfx::Vector2d(10, 0);
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
5999 6018
6000 std::unique_ptr<LayerImpl> root = 6019 std::unique_ptr<LayerImpl> root =
6001 CreateScrollableLayer(1, surface_size, root_clip.get()); 6020 CreateScrollableLayer(1, surface_size, root_clip.get());
6002 6021
6003 std::unique_ptr<LayerImpl> grand_child = 6022 std::unique_ptr<LayerImpl> grand_child =
6004 CreateScrollableLayer(3, surface_size, root_clip.get()); 6023 CreateScrollableLayer(3, surface_size, root_clip.get());
6005 6024
6006 std::unique_ptr<LayerImpl> child = 6025 std::unique_ptr<LayerImpl> child =
6007 CreateScrollableLayer(2, surface_size, root_clip.get()); 6026 CreateScrollableLayer(2, surface_size, root_clip.get());
6008 LayerImpl* grand_child_layer = grand_child.get(); 6027 LayerImpl* grand_child_layer = grand_child.get();
6009 child->AddChild(std::move(grand_child)); 6028 child->test_properties()->AddChild(std::move(grand_child));
6010 6029
6011 LayerImpl* child_layer = child.get(); 6030 LayerImpl* child_layer = child.get();
6012 root->AddChild(std::move(child)); 6031 root->test_properties()->AddChild(std::move(child));
6013 root_clip->AddChild(std::move(root)); 6032 root_clip->test_properties()->AddChild(std::move(root));
6014 child_layer->layer_tree_impl() 6033 child_layer->layer_tree_impl()
6015 ->property_trees() 6034 ->property_trees()
6016 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(), 6035 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(),
6017 gfx::ScrollOffset(0, 3)); 6036 gfx::ScrollOffset(0, 3));
6018 grand_child_layer->layer_tree_impl() 6037 grand_child_layer->layer_tree_impl()
6019 ->property_trees() 6038 ->property_trees()
6020 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(), 6039 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(),
6021 gfx::ScrollOffset(0, 2)); 6040 gfx::ScrollOffset(0, 2));
6022 host_impl_->active_tree()->SetRootLayer(std::move(root_clip)); 6041 host_impl_->active_tree()->SetRootLayer(std::move(root_clip));
6023 host_impl_->active_tree()->DidBecomeActive(); 6042 host_impl_->active_tree()->DidBecomeActive();
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
6283 { 6302 {
6284 std::unique_ptr<LayerImpl> root = 6303 std::unique_ptr<LayerImpl> root =
6285 LayerImpl::Create(host_impl_->active_tree(), 1); 6304 LayerImpl::Create(host_impl_->active_tree(), 1);
6286 root->SetBounds(gfx::Size(10, 10)); 6305 root->SetBounds(gfx::Size(10, 10));
6287 root->SetDrawsContent(false); 6306 root->SetDrawsContent(false);
6288 root->test_properties()->force_render_surface = true; 6307 root->test_properties()->force_render_surface = true;
6289 host_impl_->active_tree()->SetRootLayer(std::move(root)); 6308 host_impl_->active_tree()->SetRootLayer(std::move(root));
6290 } 6309 }
6291 LayerImpl* root = host_impl_->active_tree()->root_layer(); 6310 LayerImpl* root = host_impl_->active_tree()->root_layer();
6292 6311
6293 root->AddChild( 6312 root->test_properties()->AddChild(BlendStateCheckLayer::Create(
6294 BlendStateCheckLayer::Create(host_impl_->active_tree(), 6313 host_impl_->active_tree(), 2, host_impl_->resource_provider()));
6295 2,
6296 host_impl_->resource_provider()));
6297 BlendStateCheckLayer* layer1 = 6314 BlendStateCheckLayer* layer1 =
6298 static_cast<BlendStateCheckLayer*>(root->test_properties()->children[0]); 6315 static_cast<BlendStateCheckLayer*>(root->test_properties()->children[0]);
6299 layer1->SetPosition(gfx::PointF(2.f, 2.f)); 6316 layer1->SetPosition(gfx::PointF(2.f, 2.f));
6300 6317
6301 LayerTreeHostImpl::FrameData frame; 6318 LayerTreeHostImpl::FrameData frame;
6302 6319
6303 // Opaque layer, drawn without blending. 6320 // Opaque layer, drawn without blending.
6304 layer1->SetContentsOpaque(true); 6321 layer1->SetContentsOpaque(true);
6305 layer1->SetExpectation(false, false); 6322 layer1->SetExpectation(false, false);
6306 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 6323 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
(...skipping 30 matching lines...) Expand all
6337 layer1->test_properties()->opacity = 0.5f; 6354 layer1->test_properties()->opacity = 0.5f;
6338 layer1->NoteLayerPropertyChanged(); 6355 layer1->NoteLayerPropertyChanged();
6339 layer1->SetExpectation(true, false); 6356 layer1->SetExpectation(true, false);
6340 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 6357 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
6341 SetNeedsRebuildPropertyTrees(); 6358 SetNeedsRebuildPropertyTrees();
6342 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); 6359 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame));
6343 host_impl_->DrawLayers(&frame); 6360 host_impl_->DrawLayers(&frame);
6344 EXPECT_TRUE(layer1->quads_appended()); 6361 EXPECT_TRUE(layer1->quads_appended());
6345 host_impl_->DidDrawAllLayers(frame); 6362 host_impl_->DidDrawAllLayers(frame);
6346 6363
6347 layer1->AddChild( 6364 layer1->test_properties()->AddChild(BlendStateCheckLayer::Create(
6348 BlendStateCheckLayer::Create(host_impl_->active_tree(), 6365 host_impl_->active_tree(), 3, host_impl_->resource_provider()));
6349 3,
6350 host_impl_->resource_provider()));
6351 BlendStateCheckLayer* layer2 = static_cast<BlendStateCheckLayer*>( 6366 BlendStateCheckLayer* layer2 = static_cast<BlendStateCheckLayer*>(
6352 layer1->test_properties()->children[0]); 6367 layer1->test_properties()->children[0]);
6353 layer2->SetPosition(gfx::PointF(4.f, 4.f)); 6368 layer2->SetPosition(gfx::PointF(4.f, 4.f));
6354 6369
6355 // 2 opaque layers, drawn without blending. 6370 // 2 opaque layers, drawn without blending.
6356 layer1->SetContentsOpaque(true); 6371 layer1->SetContentsOpaque(true);
6357 layer1->test_properties()->opacity = 1.f; 6372 layer1->test_properties()->opacity = 1.f;
6358 layer1->NoteLayerPropertyChanged(); 6373 layer1->NoteLayerPropertyChanged();
6359 layer1->SetExpectation(false, false); 6374 layer1->SetExpectation(false, false);
6360 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 6375 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
6548 } 6563 }
6549 6564
6550 void SetupActiveTreeLayers() { 6565 void SetupActiveTreeLayers() {
6551 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); 6566 host_impl_->active_tree()->set_background_color(SK_ColorGRAY);
6552 host_impl_->active_tree()->SetRootLayer( 6567 host_impl_->active_tree()->SetRootLayer(
6553 LayerImpl::Create(host_impl_->active_tree(), 1)); 6568 LayerImpl::Create(host_impl_->active_tree(), 1));
6554 host_impl_->active_tree() 6569 host_impl_->active_tree()
6555 ->root_layer() 6570 ->root_layer()
6556 ->test_properties() 6571 ->test_properties()
6557 ->force_render_surface = true; 6572 ->force_render_surface = true;
6558 host_impl_->active_tree()->root_layer()->AddChild( 6573 host_impl_->active_tree()->root_layer()->test_properties()->AddChild(
6559 BlendStateCheckLayer::Create(host_impl_->active_tree(), 6574 BlendStateCheckLayer::Create(host_impl_->active_tree(), 2,
6560 2,
6561 host_impl_->resource_provider())); 6575 host_impl_->resource_provider()));
6562 child_ = static_cast<BlendStateCheckLayer*>(host_impl_->active_tree() 6576 child_ = static_cast<BlendStateCheckLayer*>(host_impl_->active_tree()
6563 ->root_layer() 6577 ->root_layer()
6564 ->test_properties() 6578 ->test_properties()
6565 ->children[0]); 6579 ->children[0]);
6566 child_->SetExpectation(false, false); 6580 child_->SetExpectation(false, false);
6567 child_->SetContentsOpaque(true); 6581 child_->SetContentsOpaque(true);
6568 } 6582 }
6569 6583
6570 // Expect no gutter rects. 6584 // Expect no gutter rects.
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
6927 std::unique_ptr<LayerImpl> root = 6941 std::unique_ptr<LayerImpl> root =
6928 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); 6942 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1);
6929 root->test_properties()->force_render_surface = true; 6943 root->test_properties()->force_render_surface = true;
6930 std::unique_ptr<LayerImpl> child = 6944 std::unique_ptr<LayerImpl> child =
6931 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); 6945 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2);
6932 child->SetPosition(gfx::PointF(12.f, 13.f)); 6946 child->SetPosition(gfx::PointF(12.f, 13.f));
6933 child->SetBounds(gfx::Size(14, 15)); 6947 child->SetBounds(gfx::Size(14, 15));
6934 child->SetDrawsContent(true); 6948 child->SetDrawsContent(true);
6935 root->SetBounds(gfx::Size(500, 500)); 6949 root->SetBounds(gfx::Size(500, 500));
6936 root->SetDrawsContent(true); 6950 root->SetDrawsContent(true);
6937 root->AddChild(std::move(child)); 6951 root->test_properties()->AddChild(std::move(child));
6938 layer_tree_host_impl->active_tree()->SetRootLayer(std::move(root)); 6952 layer_tree_host_impl->active_tree()->SetRootLayer(std::move(root));
6939 6953
6940 LayerTreeHostImpl::FrameData frame; 6954 LayerTreeHostImpl::FrameData frame;
6941 6955
6942 // First frame, the entire screen should get swapped. 6956 // First frame, the entire screen should get swapped.
6943 layer_tree_host_impl->active_tree() 6957 layer_tree_host_impl->active_tree()
6944 ->BuildLayerListAndPropertyTreesForTesting(); 6958 ->BuildLayerListAndPropertyTreesForTesting();
6945 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); 6959 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame));
6946 layer_tree_host_impl->DrawLayers(&frame); 6960 layer_tree_host_impl->DrawLayers(&frame);
6947 layer_tree_host_impl->DidDrawAllLayers(frame); 6961 layer_tree_host_impl->DidDrawAllLayers(frame);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
6996 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) { 7010 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) {
6997 std::unique_ptr<LayerImpl> root = 7011 std::unique_ptr<LayerImpl> root =
6998 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); 7012 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1);
6999 std::unique_ptr<LayerImpl> child = 7013 std::unique_ptr<LayerImpl> child =
7000 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); 7014 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2);
7001 child->SetBounds(gfx::Size(10, 10)); 7015 child->SetBounds(gfx::Size(10, 10));
7002 child->SetDrawsContent(true); 7016 child->SetDrawsContent(true);
7003 root->SetBounds(gfx::Size(10, 10)); 7017 root->SetBounds(gfx::Size(10, 10));
7004 root->SetDrawsContent(true); 7018 root->SetDrawsContent(true);
7005 root->test_properties()->force_render_surface = true; 7019 root->test_properties()->force_render_surface = true;
7006 root->AddChild(std::move(child)); 7020 root->test_properties()->AddChild(std::move(child));
7007 7021
7008 host_impl_->active_tree()->SetRootLayer(std::move(root)); 7022 host_impl_->active_tree()->SetRootLayer(std::move(root));
7009 7023
7010 LayerTreeHostImpl::FrameData frame; 7024 LayerTreeHostImpl::FrameData frame;
7011 7025
7012 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); 7026 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame));
7013 EXPECT_EQ(1u, frame.render_surface_layer_list->size()); 7027 EXPECT_EQ(1u, frame.render_surface_layer_list->size());
7014 EXPECT_EQ(1u, frame.render_passes.size()); 7028 EXPECT_EQ(1u, frame.render_passes.size());
7015 host_impl_->DidDrawAllLayers(frame); 7029 host_impl_->DidDrawAllLayers(frame);
7016 } 7030 }
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
7266 child->SetBounds(gfx::Size(child_rect.width(), child_rect.height())); 7280 child->SetBounds(gfx::Size(child_rect.width(), child_rect.height()));
7267 child->draw_properties().visible_layer_rect = child_rect; 7281 child->draw_properties().visible_layer_rect = child_rect;
7268 child->SetDrawsContent(false); 7282 child->SetDrawsContent(false);
7269 child->test_properties()->force_render_surface = true; 7283 child->test_properties()->force_render_surface = true;
7270 7284
7271 grand_child->SetPosition(gfx::PointF(grand_child_rect.origin())); 7285 grand_child->SetPosition(gfx::PointF(grand_child_rect.origin()));
7272 grand_child->SetBounds(grand_child_rect.size()); 7286 grand_child->SetBounds(grand_child_rect.size());
7273 grand_child->draw_properties().visible_layer_rect = grand_child_rect; 7287 grand_child->draw_properties().visible_layer_rect = grand_child_rect;
7274 grand_child->SetDrawsContent(true); 7288 grand_child->SetDrawsContent(true);
7275 7289
7276 child->AddChild(std::move(grand_child)); 7290 child->test_properties()->AddChild(std::move(grand_child));
7277 root->AddChild(std::move(child)); 7291 root->test_properties()->AddChild(std::move(child));
7278 7292
7279 my_host_impl->active_tree()->SetRootLayer(std::move(root)); 7293 my_host_impl->active_tree()->SetRootLayer(std::move(root));
7280 my_host_impl->active_tree()->BuildLayerListAndPropertyTreesForTesting(); 7294 my_host_impl->active_tree()->BuildLayerListAndPropertyTreesForTesting();
7281 return my_host_impl; 7295 return my_host_impl;
7282 } 7296 }
7283 7297
7284 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorPartialSwap) { 7298 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorPartialSwap) {
7285 TestSharedBitmapManager shared_bitmap_manager; 7299 TestSharedBitmapManager shared_bitmap_manager;
7286 TestTaskGraphRunner task_graph_runner; 7300 TestTaskGraphRunner task_graph_runner;
7287 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); 7301 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create());
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
7356 7370
7357 scoped_refptr<VideoFrame> softwareFrame = 7371 scoped_refptr<VideoFrame> softwareFrame =
7358 media::VideoFrame::CreateColorFrame( 7372 media::VideoFrame::CreateColorFrame(
7359 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); 7373 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta());
7360 FakeVideoFrameProvider provider; 7374 FakeVideoFrameProvider provider;
7361 provider.set_frame(softwareFrame); 7375 provider.set_frame(softwareFrame);
7362 std::unique_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( 7376 std::unique_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create(
7363 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0); 7377 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0);
7364 video_layer->SetBounds(gfx::Size(10, 10)); 7378 video_layer->SetBounds(gfx::Size(10, 10));
7365 video_layer->SetDrawsContent(true); 7379 video_layer->SetDrawsContent(true);
7366 root_layer->AddChild(std::move(video_layer)); 7380 root_layer->test_properties()->AddChild(std::move(video_layer));
7367 7381
7368 host_impl_->active_tree()->SetRootLayer(std::move(root_layer)); 7382 host_impl_->active_tree()->SetRootLayer(std::move(root_layer));
7369 7383
7370 EXPECT_EQ(0u, context3d->NumTextures()); 7384 EXPECT_EQ(0u, context3d->NumTextures());
7371 7385
7372 LayerTreeHostImpl::FrameData frame; 7386 LayerTreeHostImpl::FrameData frame;
7373 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); 7387 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame));
7374 host_impl_->DrawLayers(&frame); 7388 host_impl_->DrawLayers(&frame);
7375 host_impl_->DidDrawAllLayers(frame); 7389 host_impl_->DidDrawAllLayers(frame);
7376 host_impl_->SwapBuffers(frame); 7390 host_impl_->SwapBuffers(frame);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
7480 root->SetBounds(gfx::Size(10, 10)); 7494 root->SetBounds(gfx::Size(10, 10));
7481 root->SetDrawsContent(true); 7495 root->SetDrawsContent(true);
7482 root->test_properties()->force_render_surface = true; 7496 root->test_properties()->force_render_surface = true;
7483 7497
7484 // Child layer is in the bottom right corner. 7498 // Child layer is in the bottom right corner.
7485 std::unique_ptr<SolidColorLayerImpl> child = 7499 std::unique_ptr<SolidColorLayerImpl> child =
7486 SolidColorLayerImpl::Create(host_impl_->active_tree(), 2); 7500 SolidColorLayerImpl::Create(host_impl_->active_tree(), 2);
7487 child->SetPosition(gfx::PointF(9.f, 9.f)); 7501 child->SetPosition(gfx::PointF(9.f, 9.f));
7488 child->SetBounds(gfx::Size(1, 1)); 7502 child->SetBounds(gfx::Size(1, 1));
7489 child->SetDrawsContent(true); 7503 child->SetDrawsContent(true);
7490 root->AddChild(std::move(child)); 7504 root->test_properties()->AddChild(std::move(child));
7491 7505
7492 host_impl_->active_tree()->SetRootLayer(std::move(root)); 7506 host_impl_->active_tree()->SetRootLayer(std::move(root));
7493 7507
7494 // Draw a frame. In the first frame, the entire viewport should be damaged. 7508 // Draw a frame. In the first frame, the entire viewport should be damaged.
7495 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); 7509 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize());
7496 DrawFrameAndTestDamage(full_frame_damage); 7510 DrawFrameAndTestDamage(full_frame_damage);
7497 7511
7498 // The second frame has damage that doesn't touch the child layer. Its quads 7512 // The second frame has damage that doesn't touch the child layer. Its quads
7499 // should still be generated. 7513 // should still be generated.
7500 gfx::Rect small_damage = gfx::Rect(0, 0, 1, 1); 7514 gfx::Rect small_damage = gfx::Rect(0, 0, 1, 1);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
7536 std::unique_ptr<LayerImpl> scoped_root = 7550 std::unique_ptr<LayerImpl> scoped_root =
7537 LayerImpl::Create(host_impl_->pending_tree(), 1); 7551 LayerImpl::Create(host_impl_->pending_tree(), 1);
7538 LayerImpl* root = scoped_root.get(); 7552 LayerImpl* root = scoped_root.get();
7539 root->test_properties()->force_render_surface = true; 7553 root->test_properties()->force_render_surface = true;
7540 7554
7541 host_impl_->pending_tree()->SetRootLayer(std::move(scoped_root)); 7555 host_impl_->pending_tree()->SetRootLayer(std::move(scoped_root));
7542 7556
7543 std::unique_ptr<LayerImpl> scoped_scrolling_layer = 7557 std::unique_ptr<LayerImpl> scoped_scrolling_layer =
7544 LayerImpl::Create(host_impl_->pending_tree(), 2); 7558 LayerImpl::Create(host_impl_->pending_tree(), 2);
7545 LayerImpl* scrolling_layer = scoped_scrolling_layer.get(); 7559 LayerImpl* scrolling_layer = scoped_scrolling_layer.get();
7546 root->AddChild(std::move(scoped_scrolling_layer)); 7560 root->test_properties()->AddChild(std::move(scoped_scrolling_layer));
7547 7561
7548 gfx::Size content_layer_bounds(100000, 100); 7562 gfx::Size content_layer_bounds(100000, 100);
7549 scoped_refptr<FakeRasterSource> raster_source( 7563 scoped_refptr<FakeRasterSource> raster_source(
7550 FakeRasterSource::CreateFilled(content_layer_bounds)); 7564 FakeRasterSource::CreateFilled(content_layer_bounds));
7551 7565
7552 std::unique_ptr<FakePictureLayerImpl> scoped_content_layer = 7566 std::unique_ptr<FakePictureLayerImpl> scoped_content_layer =
7553 FakePictureLayerImpl::CreateWithRasterSource(host_impl_->pending_tree(), 7567 FakePictureLayerImpl::CreateWithRasterSource(host_impl_->pending_tree(),
7554 3, raster_source); 7568 3, raster_source);
7555 LayerImpl* content_layer = scoped_content_layer.get(); 7569 LayerImpl* content_layer = scoped_content_layer.get();
7556 scrolling_layer->AddChild(std::move(scoped_content_layer)); 7570 scrolling_layer->test_properties()->AddChild(std::move(scoped_content_layer));
7557 content_layer->SetBounds(content_layer_bounds); 7571 content_layer->SetBounds(content_layer_bounds);
7558 content_layer->SetDrawsContent(true); 7572 content_layer->SetDrawsContent(true);
7559 7573
7560 root->SetBounds(root_size); 7574 root->SetBounds(root_size);
7561 7575
7562 gfx::ScrollOffset scroll_offset(100000, 0); 7576 gfx::ScrollOffset scroll_offset(100000, 0);
7563 scrolling_layer->SetScrollClipLayer(root->id()); 7577 scrolling_layer->SetScrollClipLayer(root->id());
7564 scrolling_layer->layer_tree_impl() 7578 scrolling_layer->layer_tree_impl()
7565 ->property_trees() 7579 ->property_trees()
7566 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scrolling_layer->id(), 7580 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scrolling_layer->id(),
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
7688 // SolidColorLayerImpl will be drawn. 7702 // SolidColorLayerImpl will be drawn.
7689 std::unique_ptr<SolidColorLayerImpl> root_layer = 7703 std::unique_ptr<SolidColorLayerImpl> root_layer =
7690 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); 7704 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1);
7691 7705
7692 // VideoLayerImpl will not be drawn. 7706 // VideoLayerImpl will not be drawn.
7693 FakeVideoFrameProvider provider; 7707 FakeVideoFrameProvider provider;
7694 std::unique_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( 7708 std::unique_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create(
7695 host_impl_->active_tree(), 2, &provider, media::VIDEO_ROTATION_0); 7709 host_impl_->active_tree(), 2, &provider, media::VIDEO_ROTATION_0);
7696 video_layer->SetBounds(gfx::Size(10, 10)); 7710 video_layer->SetBounds(gfx::Size(10, 10));
7697 video_layer->SetDrawsContent(true); 7711 video_layer->SetDrawsContent(true);
7698 root_layer->AddChild(std::move(video_layer)); 7712 root_layer->test_properties()->AddChild(std::move(video_layer));
7699 SetupRootLayerImpl(std::move(root_layer)); 7713 SetupRootLayerImpl(std::move(root_layer));
7700 7714
7701 host_impl_->OnDraw(external_transform, external_viewport, external_clip, 7715 host_impl_->OnDraw(external_transform, external_viewport, external_clip,
7702 resourceless_software_draw); 7716 resourceless_software_draw);
7703 7717
7704 EXPECT_EQ(1u, last_on_draw_frame_->will_draw_layers.size()); 7718 EXPECT_EQ(1u, last_on_draw_frame_->will_draw_layers.size());
7705 EXPECT_EQ(host_impl_->active_tree()->root_layer(), 7719 EXPECT_EQ(host_impl_->active_tree()->root_layer(),
7706 last_on_draw_frame_->will_draw_layers[0]); 7720 last_on_draw_frame_->will_draw_layers[0]);
7707 } 7721 }
7708 7722
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
7909 std::unique_ptr<LayerImpl> root_clip = 7923 std::unique_ptr<LayerImpl> root_clip =
7910 LayerImpl::Create(host_impl_->active_tree(), 3); 7924 LayerImpl::Create(host_impl_->active_tree(), 3);
7911 root_clip->test_properties()->force_render_surface = true; 7925 root_clip->test_properties()->force_render_surface = true;
7912 7926
7913 std::unique_ptr<LayerImpl> root_scroll = 7927 std::unique_ptr<LayerImpl> root_scroll =
7914 CreateScrollableLayer(1, content_size, root_clip.get()); 7928 CreateScrollableLayer(1, content_size, root_clip.get());
7915 root_scroll->test_properties()->is_container_for_fixed_position_layers = true; 7929 root_scroll->test_properties()->is_container_for_fixed_position_layers = true;
7916 std::unique_ptr<LayerImpl> child = 7930 std::unique_ptr<LayerImpl> child =
7917 CreateScrollableLayer(2, content_size, root_clip.get()); 7931 CreateScrollableLayer(2, content_size, root_clip.get());
7918 7932
7919 root_scroll->AddChild(std::move(child)); 7933 root_scroll->test_properties()->AddChild(std::move(child));
7920 int root_id = root_scroll->id(); 7934 int root_id = root_scroll->id();
7921 root_clip->AddChild(std::move(root_scroll)); 7935 root_clip->test_properties()->AddChild(std::move(root_scroll));
7922 root_ptr->AddChild(std::move(root_clip)); 7936 root_ptr->test_properties()->AddChild(std::move(root_clip));
7923 7937
7924 host_impl_->SetViewportSize(surface_size); 7938 host_impl_->SetViewportSize(surface_size);
7925 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr)); 7939 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr));
7926 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 1, 7940 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 1,
7927 Layer::INVALID_ID); 7941 Layer::INVALID_ID);
7928 host_impl_->active_tree()->DidBecomeActive(); 7942 host_impl_->active_tree()->DidBecomeActive();
7929 SetNeedsRebuildPropertyTrees(); 7943 SetNeedsRebuildPropertyTrees();
7930 DrawFrame(); 7944 DrawFrame();
7931 { 7945 {
7932 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 7946 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
7969 ->property_trees() 7983 ->property_trees()
7970 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child->id(), 7984 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child->id(),
7971 gfx::ScrollOffset(0, 2)); 7985 gfx::ScrollOffset(0, 2));
7972 7986
7973 std::unique_ptr<LayerImpl> child = 7987 std::unique_ptr<LayerImpl> child =
7974 CreateScrollableLayer(3, surface_size, root.get()); 7988 CreateScrollableLayer(3, surface_size, root.get());
7975 child->layer_tree_impl() 7989 child->layer_tree_impl()
7976 ->property_trees() 7990 ->property_trees()
7977 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child->id(), 7991 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child->id(),
7978 gfx::ScrollOffset(0, 4)); 7992 gfx::ScrollOffset(0, 4));
7979 child->AddChild(std::move(grand_child)); 7993 child->test_properties()->AddChild(std::move(grand_child));
7980 7994
7981 root_scrolling->AddChild(std::move(child)); 7995 root_scrolling->test_properties()->AddChild(std::move(child));
7982 root->AddChild(std::move(root_scrolling)); 7996 root->test_properties()->AddChild(std::move(root_scrolling));
7983 host_impl_->active_tree()->SetRootLayer(std::move(root)); 7997 host_impl_->active_tree()->SetRootLayer(std::move(root));
7984 host_impl_->active_tree()->DidBecomeActive(); 7998 host_impl_->active_tree()->DidBecomeActive();
7985 host_impl_->SetViewportSize(surface_size); 7999 host_impl_->SetViewportSize(surface_size);
7986 SetNeedsRebuildPropertyTrees(); 8000 SetNeedsRebuildPropertyTrees();
7987 DrawFrame(); 8001 DrawFrame();
7988 { 8002 {
7989 std::unique_ptr<ScrollAndScaleSet> scroll_info; 8003 std::unique_ptr<ScrollAndScaleSet> scroll_info;
7990 LayerImpl* child = host_impl_->active_tree() 8004 LayerImpl* child = host_impl_->active_tree()
7991 ->root_layer() 8005 ->root_layer()
7992 ->test_properties() 8006 ->test_properties()
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
8052 gfx::Size content_size(20, 20); 8066 gfx::Size content_size(20, 20);
8053 std::unique_ptr<LayerImpl> root_clip = 8067 std::unique_ptr<LayerImpl> root_clip =
8054 LayerImpl::Create(host_impl_->active_tree(), 3); 8068 LayerImpl::Create(host_impl_->active_tree(), 3);
8055 root_clip->test_properties()->force_render_surface = true; 8069 root_clip->test_properties()->force_render_surface = true;
8056 std::unique_ptr<LayerImpl> root_scroll = 8070 std::unique_ptr<LayerImpl> root_scroll =
8057 CreateScrollableLayer(1, content_size, root_clip.get()); 8071 CreateScrollableLayer(1, content_size, root_clip.get());
8058 int root_scroll_id = root_scroll->id(); 8072 int root_scroll_id = root_scroll->id();
8059 std::unique_ptr<LayerImpl> child = 8073 std::unique_ptr<LayerImpl> child =
8060 CreateScrollableLayer(2, content_size, root_clip.get()); 8074 CreateScrollableLayer(2, content_size, root_clip.get());
8061 8075
8062 root_scroll->AddChild(std::move(child)); 8076 root_scroll->test_properties()->AddChild(std::move(child));
8063 root_clip->AddChild(std::move(root_scroll)); 8077 root_clip->test_properties()->AddChild(std::move(root_scroll));
8064 8078
8065 host_impl_->SetViewportSize(surface_size); 8079 host_impl_->SetViewportSize(surface_size);
8066 host_impl_->active_tree()->SetRootLayer(std::move(root_clip)); 8080 host_impl_->active_tree()->SetRootLayer(std::move(root_clip));
8067 host_impl_->active_tree()->DidBecomeActive(); 8081 host_impl_->active_tree()->DidBecomeActive();
8068 SetNeedsRebuildPropertyTrees(); 8082 SetNeedsRebuildPropertyTrees();
8069 DrawFrame(); 8083 DrawFrame();
8070 { 8084 {
8071 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 8085 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
8072 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 8086 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
8073 InputHandler::WHEEL) 8087 InputHandler::WHEEL)
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
8107 host_impl_->active_tree()->LayerById(page_scale_layer_id); 8121 host_impl_->active_tree()->LayerById(page_scale_layer_id);
8108 8122
8109 int occluder_layer_id = 6; 8123 int occluder_layer_id = 6;
8110 std::unique_ptr<LayerImpl> occluder_layer = 8124 std::unique_ptr<LayerImpl> occluder_layer =
8111 LayerImpl::Create(host_impl_->active_tree(), occluder_layer_id); 8125 LayerImpl::Create(host_impl_->active_tree(), occluder_layer_id);
8112 occluder_layer->SetDrawsContent(true); 8126 occluder_layer->SetDrawsContent(true);
8113 occluder_layer->SetBounds(content_size); 8127 occluder_layer->SetBounds(content_size);
8114 occluder_layer->SetPosition(gfx::PointF()); 8128 occluder_layer->SetPosition(gfx::PointF());
8115 8129
8116 // The parent of the occluder is *above* the scroller. 8130 // The parent of the occluder is *above* the scroller.
8117 page_scale_layer->AddChild(std::move(occluder_layer)); 8131 page_scale_layer->test_properties()->AddChild(std::move(occluder_layer));
8118 8132
8119 SetNeedsRebuildPropertyTrees(); 8133 SetNeedsRebuildPropertyTrees();
8120 DrawFrame(); 8134 DrawFrame();
8121 8135
8122 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( 8136 InputHandler::ScrollStatus status = host_impl_->ScrollBegin(
8123 BeginState(gfx::Point()).get(), InputHandler::WHEEL); 8137 BeginState(gfx::Point()).get(), InputHandler::WHEEL);
8124 EXPECT_EQ(InputHandler::SCROLL_UNKNOWN, status.thread); 8138 EXPECT_EQ(InputHandler::SCROLL_UNKNOWN, status.thread);
8125 EXPECT_EQ(MainThreadScrollingReason::kFailedHitTest, 8139 EXPECT_EQ(MainThreadScrollingReason::kFailedHitTest,
8126 status.main_thread_scrolling_reasons); 8140 status.main_thread_scrolling_reasons);
8127 } 8141 }
(...skipping 20 matching lines...) Expand all
8148 int child_scroll_clip_layer_id = 7; 8162 int child_scroll_clip_layer_id = 7;
8149 std::unique_ptr<LayerImpl> child_scroll_clip = 8163 std::unique_ptr<LayerImpl> child_scroll_clip =
8150 LayerImpl::Create(host_impl_->active_tree(), child_scroll_clip_layer_id); 8164 LayerImpl::Create(host_impl_->active_tree(), child_scroll_clip_layer_id);
8151 8165
8152 int child_scroll_layer_id = 8; 8166 int child_scroll_layer_id = 8;
8153 std::unique_ptr<LayerImpl> child_scroll = CreateScrollableLayer( 8167 std::unique_ptr<LayerImpl> child_scroll = CreateScrollableLayer(
8154 child_scroll_layer_id, content_size, child_scroll_clip.get()); 8168 child_scroll_layer_id, content_size, child_scroll_clip.get());
8155 8169
8156 child_scroll->SetPosition(gfx::PointF(10.f, 10.f)); 8170 child_scroll->SetPosition(gfx::PointF(10.f, 10.f));
8157 8171
8158 child_scroll->AddChild(std::move(occluder_layer)); 8172 child_scroll->test_properties()->AddChild(std::move(occluder_layer));
8159 child_scroll_clip->AddChild(std::move(child_scroll)); 8173 child_scroll_clip->test_properties()->AddChild(std::move(child_scroll));
8160 scroll_layer->AddChild(std::move(child_scroll_clip)); 8174 scroll_layer->test_properties()->AddChild(std::move(child_scroll_clip));
8161 8175
8162 SetNeedsRebuildPropertyTrees(); 8176 SetNeedsRebuildPropertyTrees();
8163 DrawFrame(); 8177 DrawFrame();
8164 8178
8165 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( 8179 InputHandler::ScrollStatus status = host_impl_->ScrollBegin(
8166 BeginState(gfx::Point()).get(), InputHandler::WHEEL); 8180 BeginState(gfx::Point()).get(), InputHandler::WHEEL);
8167 EXPECT_EQ(InputHandler::SCROLL_UNKNOWN, status.thread); 8181 EXPECT_EQ(InputHandler::SCROLL_UNKNOWN, status.thread);
8168 EXPECT_EQ(MainThreadScrollingReason::kFailedHitTest, 8182 EXPECT_EQ(MainThreadScrollingReason::kFailedHitTest,
8169 status.main_thread_scrolling_reasons); 8183 status.main_thread_scrolling_reasons);
8170 } 8184 }
8171 8185
8172 TEST_F(LayerTreeHostImplTest, NotScrollInvisibleScroller) { 8186 TEST_F(LayerTreeHostImplTest, NotScrollInvisibleScroller) {
8173 gfx::Size content_size(100, 100); 8187 gfx::Size content_size(100, 100);
8174 SetupScrollAndContentsLayers(content_size); 8188 SetupScrollAndContentsLayers(content_size);
8175 8189
8176 LayerImpl* root = host_impl_->active_tree()->LayerById(1); 8190 LayerImpl* root = host_impl_->active_tree()->LayerById(1);
8177 8191
8178 int scroll_layer_id = 2; 8192 int scroll_layer_id = 2;
8179 LayerImpl* scroll_layer = 8193 LayerImpl* scroll_layer =
8180 host_impl_->active_tree()->LayerById(scroll_layer_id); 8194 host_impl_->active_tree()->LayerById(scroll_layer_id);
8181 8195
8182 int child_scroll_layer_id = 7; 8196 int child_scroll_layer_id = 7;
8183 std::unique_ptr<LayerImpl> child_scroll = 8197 std::unique_ptr<LayerImpl> child_scroll =
8184 CreateScrollableLayer(child_scroll_layer_id, content_size, root); 8198 CreateScrollableLayer(child_scroll_layer_id, content_size, root);
8185 child_scroll->SetDrawsContent(false); 8199 child_scroll->SetDrawsContent(false);
8186 8200
8187 scroll_layer->AddChild(std::move(child_scroll)); 8201 scroll_layer->test_properties()->AddChild(std::move(child_scroll));
8188 8202
8189 SetNeedsRebuildPropertyTrees(); 8203 SetNeedsRebuildPropertyTrees();
8190 DrawFrame(); 8204 DrawFrame();
8191 8205
8192 // We should not have scrolled |child_scroll| even though we technically "hit" 8206 // We should not have scrolled |child_scroll| even though we technically "hit"
8193 // it. The reason for this is that if the scrolling the scroll would not move 8207 // it. The reason for this is that if the scrolling the scroll would not move
8194 // any layer that is a drawn RSLL member, then we can ignore the hit. 8208 // any layer that is a drawn RSLL member, then we can ignore the hit.
8195 // 8209 //
8196 // Why SCROLL_STARTED? In this case, it's because we've bubbled out and 8210 // Why SCROLL_STARTED? In this case, it's because we've bubbled out and
8197 // started scrolling the inner viewport. 8211 // started scrolling the inner viewport.
(...skipping 20 matching lines...) Expand all
8218 LayerImpl::Create(host_impl_->active_tree(), 8); 8232 LayerImpl::Create(host_impl_->active_tree(), 8);
8219 child_layer->SetDrawsContent(false); 8233 child_layer->SetDrawsContent(false);
8220 8234
8221 std::unique_ptr<LayerImpl> grand_child_layer = 8235 std::unique_ptr<LayerImpl> grand_child_layer =
8222 LayerImpl::Create(host_impl_->active_tree(), 9); 8236 LayerImpl::Create(host_impl_->active_tree(), 9);
8223 grand_child_layer->SetDrawsContent(true); 8237 grand_child_layer->SetDrawsContent(true);
8224 grand_child_layer->SetBounds(content_size); 8238 grand_child_layer->SetBounds(content_size);
8225 // Move the grand child so it's not hit by our test point. 8239 // Move the grand child so it's not hit by our test point.
8226 grand_child_layer->SetPosition(gfx::PointF(10.f, 10.f)); 8240 grand_child_layer->SetPosition(gfx::PointF(10.f, 10.f));
8227 8241
8228 child_layer->AddChild(std::move(grand_child_layer)); 8242 child_layer->test_properties()->AddChild(std::move(grand_child_layer));
8229 invisible_scroll_layer->AddChild(std::move(child_layer)); 8243 invisible_scroll_layer->test_properties()->AddChild(std::move(child_layer));
8230 root_scroll_layer->AddChild(std::move(invisible_scroll_layer)); 8244 root_scroll_layer->test_properties()->AddChild(
8245 std::move(invisible_scroll_layer));
8231 8246
8232 SetNeedsRebuildPropertyTrees(); 8247 SetNeedsRebuildPropertyTrees();
8233 DrawFrame(); 8248 DrawFrame();
8234 8249
8235 // We should have scrolled |invisible_scroll_layer| as it was hit and it has 8250 // We should have scrolled |invisible_scroll_layer| as it was hit and it has
8236 // a descendant which is a drawn RSLL member. 8251 // a descendant which is a drawn RSLL member.
8237 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 8252 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
8238 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 8253 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
8239 InputHandler::WHEEL) 8254 InputHandler::WHEEL)
8240 .thread); 8255 .thread);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
8274 LayerImpl::Create(host_impl_->active_tree(), container_id); 8289 LayerImpl::Create(host_impl_->active_tree(), container_id);
8275 8290
8276 std::unique_ptr<std::set<LayerImpl*>> scroll_children( 8291 std::unique_ptr<std::set<LayerImpl*>> scroll_children(
8277 new std::set<LayerImpl*>); 8292 new std::set<LayerImpl*>);
8278 scroll_children->insert(scroll_child.get()); 8293 scroll_children->insert(scroll_child.get());
8279 invisible_scroll->test_properties()->scroll_children.reset( 8294 invisible_scroll->test_properties()->scroll_children.reset(
8280 scroll_children.release()); 8295 scroll_children.release());
8281 8296
8282 scroll_child->test_properties()->scroll_parent = invisible_scroll.get(); 8297 scroll_child->test_properties()->scroll_parent = invisible_scroll.get();
8283 8298
8284 container->AddChild(std::move(invisible_scroll)); 8299 container->test_properties()->AddChild(std::move(invisible_scroll));
8285 container->AddChild(std::move(scroll_child)); 8300 container->test_properties()->AddChild(std::move(scroll_child));
8286 8301
8287 scroll_layer->AddChild(std::move(container)); 8302 scroll_layer->test_properties()->AddChild(std::move(container));
8288 8303
8289 SetNeedsRebuildPropertyTrees(); 8304 SetNeedsRebuildPropertyTrees();
8290 DrawFrame(); 8305 DrawFrame();
8291 8306
8292 // We should have scrolled |child_scroll| even though it is invisible. 8307 // We should have scrolled |child_scroll| even though it is invisible.
8293 // The reason for this is that if the scrolling the scroll would move a layer 8308 // The reason for this is that if the scrolling the scroll would move a layer
8294 // that is a drawn RSLL member, then we should accept this hit. 8309 // that is a drawn RSLL member, then we should accept this hit.
8295 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 8310 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
8296 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 8311 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
8297 InputHandler::WHEEL) 8312 InputHandler::WHEEL)
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
9033 ->scroll_tree.UpdateScrollOffsetBaseForTesting(outer_scroll->id(), 9048 ->scroll_tree.UpdateScrollOffsetBaseForTesting(outer_scroll->id(),
9034 gfx::ScrollOffset()); 9049 gfx::ScrollOffset());
9035 outer_scroll->SetBounds(content_size); 9050 outer_scroll->SetBounds(content_size);
9036 outer_scroll->SetPosition(gfx::PointF()); 9051 outer_scroll->SetPosition(gfx::PointF());
9037 9052
9038 std::unique_ptr<LayerImpl> contents = LayerImpl::Create(layer_tree_impl, 8); 9053 std::unique_ptr<LayerImpl> contents = LayerImpl::Create(layer_tree_impl, 8);
9039 contents->SetDrawsContent(true); 9054 contents->SetDrawsContent(true);
9040 contents->SetBounds(content_size); 9055 contents->SetBounds(content_size);
9041 contents->SetPosition(gfx::PointF()); 9056 contents->SetPosition(gfx::PointF());
9042 9057
9043 outer_scroll->AddChild(std::move(contents)); 9058 outer_scroll->test_properties()->AddChild(std::move(contents));
9044 outer_clip->AddChild(std::move(outer_scroll)); 9059 outer_clip->test_properties()->AddChild(std::move(outer_scroll));
9045 inner_scroll->AddChild(std::move(outer_clip)); 9060 inner_scroll->test_properties()->AddChild(std::move(outer_clip));
9046 page_scale->AddChild(std::move(inner_scroll)); 9061 page_scale->test_properties()->AddChild(std::move(inner_scroll));
9047 inner_clip->AddChild(std::move(page_scale)); 9062 inner_clip->test_properties()->AddChild(std::move(page_scale));
9048 9063
9049 inner_clip->test_properties()->force_render_surface = true; 9064 inner_clip->test_properties()->force_render_surface = true;
9050 layer_tree_impl->SetRootLayer(std::move(inner_clip)); 9065 layer_tree_impl->SetRootLayer(std::move(inner_clip));
9051 layer_tree_impl->SetViewportLayersFromIds( 9066 layer_tree_impl->SetViewportLayersFromIds(
9052 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportScrollLayerId, 9067 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportScrollLayerId,
9053 kOuterViewportScrollLayerId); 9068 kOuterViewportScrollLayerId);
9054 9069
9055 host_impl_->active_tree()->DidBecomeActive(); 9070 host_impl_->active_tree()->DidBecomeActive();
9056 } 9071 }
9057 }; 9072 };
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
9221 gfx::Size inner_viewport = gfx::Size(25, 40); 9236 gfx::Size inner_viewport = gfx::Size(25, 40);
9222 9237
9223 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); 9238 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport);
9224 9239
9225 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); 9240 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer();
9226 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); 9241 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer();
9227 9242
9228 std::unique_ptr<LayerImpl> child = 9243 std::unique_ptr<LayerImpl> child =
9229 CreateScrollableLayer(10, outer_viewport, outer_scroll); 9244 CreateScrollableLayer(10, outer_viewport, outer_scroll);
9230 LayerImpl* child_scroll = child.get(); 9245 LayerImpl* child_scroll = child.get();
9231 outer_scroll->test_properties()->children[0]->AddChild(std::move(child)); 9246 outer_scroll->test_properties()->children[0]->test_properties()->AddChild(
9247 std::move(child));
9232 9248
9233 SetNeedsRebuildPropertyTrees(); 9249 SetNeedsRebuildPropertyTrees();
9234 DrawFrame(); 9250 DrawFrame();
9235 { 9251 {
9236 std::unique_ptr<ScrollAndScaleSet> scroll_info; 9252 std::unique_ptr<ScrollAndScaleSet> scroll_info;
9237 9253
9238 gfx::Vector2d scroll_delta(0, inner_viewport.height()); 9254 gfx::Vector2d scroll_delta(0, inner_viewport.height());
9239 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 9255 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
9240 host_impl_ 9256 host_impl_
9241 ->ScrollBegin(BeginState(gfx::Point()).get(), 9257 ->ScrollBegin(BeginState(gfx::Point()).get(),
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
9289 gfx::Size inner_viewport = gfx::Size(25, 40); 9305 gfx::Size inner_viewport = gfx::Size(25, 40);
9290 9306
9291 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); 9307 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport);
9292 9308
9293 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); 9309 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer();
9294 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); 9310 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer();
9295 9311
9296 std::unique_ptr<LayerImpl> child = 9312 std::unique_ptr<LayerImpl> child =
9297 CreateScrollableLayer(10, outer_viewport, outer_scroll); 9313 CreateScrollableLayer(10, outer_viewport, outer_scroll);
9298 LayerImpl* child_scroll = child.get(); 9314 LayerImpl* child_scroll = child.get();
9299 outer_scroll->test_properties()->children[0]->AddChild(std::move(child)); 9315 outer_scroll->test_properties()->children[0]->test_properties()->AddChild(
9316 std::move(child));
9300 9317
9301 SetNeedsRebuildPropertyTrees(); 9318 SetNeedsRebuildPropertyTrees();
9302 DrawFrame(); 9319 DrawFrame();
9303 9320
9304 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 9321 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
9305 host_impl_ 9322 host_impl_
9306 ->RootScrollBegin(BeginState(gfx::Point()).get(), 9323 ->RootScrollBegin(BeginState(gfx::Point()).get(),
9307 InputHandler::TOUCHSCREEN) 9324 InputHandler::TOUCHSCREEN)
9308 .thread); 9325 .thread);
9309 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), inner_scroll); 9326 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), inner_scroll);
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
9646 EXPECT_EQ(gfx::Rect(50, 50), content_layer->visible_layer_rect()); 9663 EXPECT_EQ(gfx::Rect(50, 50), content_layer->visible_layer_rect());
9647 } 9664 }
9648 9665
9649 TEST_F(LayerTreeHostImplTest, ExternalTransformAffectsSublayerScaleFactor) { 9666 TEST_F(LayerTreeHostImplTest, ExternalTransformAffectsSublayerScaleFactor) {
9650 const gfx::Size layer_size(100, 100); 9667 const gfx::Size layer_size(100, 100);
9651 SetupScrollAndContentsLayers(layer_size); 9668 SetupScrollAndContentsLayers(layer_size);
9652 LayerImpl* content_layer = host_impl_->active_tree() 9669 LayerImpl* content_layer = host_impl_->active_tree()
9653 ->OuterViewportScrollLayer() 9670 ->OuterViewportScrollLayer()
9654 ->test_properties() 9671 ->test_properties()
9655 ->children[0]; 9672 ->children[0];
9656 content_layer->AddChild(LayerImpl::Create(host_impl_->active_tree(), 100)); 9673 content_layer->test_properties()->AddChild(
9674 LayerImpl::Create(host_impl_->active_tree(), 100));
9657 LayerImpl* test_layer = host_impl_->active_tree()->LayerById(100); 9675 LayerImpl* test_layer = host_impl_->active_tree()->LayerById(100);
9658 test_layer->test_properties()->force_render_surface = true; 9676 test_layer->test_properties()->force_render_surface = true;
9659 test_layer->SetDrawsContent(true); 9677 test_layer->SetDrawsContent(true);
9660 test_layer->SetBounds(layer_size); 9678 test_layer->SetBounds(layer_size);
9661 gfx::Transform perspective_transform; 9679 gfx::Transform perspective_transform;
9662 perspective_transform.ApplyPerspectiveDepth(2); 9680 perspective_transform.ApplyPerspectiveDepth(2);
9663 test_layer->SetTransform(perspective_transform); 9681 test_layer->SetTransform(perspective_transform);
9664 9682
9665 SetNeedsRebuildPropertyTrees(); 9683 SetNeedsRebuildPropertyTrees();
9666 RebuildPropertyTrees(); 9684 RebuildPropertyTrees();
(...skipping 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after
10740 page_scale_layer->transform_tree_index()); 10758 page_scale_layer->transform_tree_index());
10741 EXPECT_EQ(active_tree_node->data.post_local_scale_factor, 2.f); 10759 EXPECT_EQ(active_tree_node->data.post_local_scale_factor, 2.f);
10742 } 10760 }
10743 10761
10744 TEST_F(LayerTreeHostImplTest, SubLayerScaleForNodeInSubtreeOfPageScaleLayer) { 10762 TEST_F(LayerTreeHostImplTest, SubLayerScaleForNodeInSubtreeOfPageScaleLayer) {
10745 // Checks that the sublayer scale of a transform node in the subtree of the 10763 // Checks that the sublayer scale of a transform node in the subtree of the
10746 // page scale layer is updated without a property tree rebuild. 10764 // page scale layer is updated without a property tree rebuild.
10747 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 3.f); 10765 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 3.f);
10748 CreateScrollAndContentsLayers(host_impl_->active_tree(), gfx::Size(100, 100)); 10766 CreateScrollAndContentsLayers(host_impl_->active_tree(), gfx::Size(100, 100));
10749 LayerImpl* page_scale_layer = host_impl_->active_tree()->PageScaleLayer(); 10767 LayerImpl* page_scale_layer = host_impl_->active_tree()->PageScaleLayer();
10750 page_scale_layer->AddChild(LayerImpl::Create(host_impl_->active_tree(), 100)); 10768 page_scale_layer->test_properties()->AddChild(
10769 LayerImpl::Create(host_impl_->active_tree(), 100));
10751 10770
10752 LayerImpl* in_subtree_of_page_scale_layer = 10771 LayerImpl* in_subtree_of_page_scale_layer =
10753 host_impl_->active_tree()->LayerById(100); 10772 host_impl_->active_tree()->LayerById(100);
10754 in_subtree_of_page_scale_layer->test_properties()->force_render_surface = 10773 in_subtree_of_page_scale_layer->test_properties()->force_render_surface =
10755 true; 10774 true;
10756 SetNeedsRebuildPropertyTrees(); 10775 SetNeedsRebuildPropertyTrees();
10757 RebuildPropertyTrees(); 10776 RebuildPropertyTrees();
10758 DrawFrame(); 10777 DrawFrame();
10759 TransformNode* node = 10778 TransformNode* node =
10760 host_impl_->active_tree()->property_trees()->transform_tree.Node( 10779 host_impl_->active_tree()->property_trees()->transform_tree.Node(
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
10858 10877
10859 // Re-initialize with a software output surface. 10878 // Re-initialize with a software output surface.
10860 output_surface_ = FakeOutputSurface::CreateSoftware( 10879 output_surface_ = FakeOutputSurface::CreateSoftware(
10861 base::WrapUnique(new SoftwareOutputDevice)); 10880 base::WrapUnique(new SoftwareOutputDevice));
10862 host_impl_->InitializeRenderer(output_surface_.get()); 10881 host_impl_->InitializeRenderer(output_surface_.get());
10863 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); 10882 EXPECT_FALSE(host_impl_->use_gpu_rasterization());
10864 } 10883 }
10865 10884
10866 } // namespace 10885 } // namespace
10867 } // namespace cc 10886 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common_unittest.cc ('k') | cc/trees/layer_tree_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698