OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 | 213 |
214 return init; | 214 return init; |
215 } | 215 } |
216 | 216 |
217 void SetupRootLayerImpl(std::unique_ptr<LayerImpl> root) { | 217 void SetupRootLayerImpl(std::unique_ptr<LayerImpl> root) { |
218 root->SetPosition(gfx::PointF()); | 218 root->SetPosition(gfx::PointF()); |
219 root->SetBounds(gfx::Size(10, 10)); | 219 root->SetBounds(gfx::Size(10, 10)); |
220 root->SetDrawsContent(true); | 220 root->SetDrawsContent(true); |
221 root->draw_properties().visible_layer_rect = gfx::Rect(0, 0, 10, 10); | 221 root->draw_properties().visible_layer_rect = gfx::Rect(0, 0, 10, 10); |
222 root->test_properties()->force_render_surface = true; | 222 root->test_properties()->force_render_surface = true; |
223 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 223 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
224 } | 224 } |
225 | 225 |
226 static gfx::Vector2dF ScrollDelta(LayerImpl* layer_impl) { | 226 static gfx::Vector2dF ScrollDelta(LayerImpl* layer_impl) { |
227 gfx::ScrollOffset delta = | 227 gfx::ScrollOffset delta = |
228 layer_impl->layer_tree_impl() | 228 layer_impl->layer_tree_impl() |
229 ->property_trees() | 229 ->property_trees() |
230 ->scroll_tree.GetScrollOffsetDeltaForTesting(layer_impl->id()); | 230 ->scroll_tree.GetScrollOffsetDeltaForTesting(layer_impl->id()); |
231 return gfx::Vector2dF(delta.x(), delta.y()); | 231 return gfx::Vector2dF(delta.x(), delta.y()); |
232 } | 232 } |
233 | 233 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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->test_properties()->AddChild(std::move(contents)); | 334 outer_scroll->test_properties()->AddChild(std::move(contents)); |
335 outer_clip->test_properties()->AddChild(std::move(outer_scroll)); | 335 outer_clip->test_properties()->AddChild(std::move(outer_scroll)); |
336 inner_scroll->test_properties()->AddChild(std::move(outer_clip)); | 336 inner_scroll->test_properties()->AddChild(std::move(outer_clip)); |
337 page_scale->test_properties()->AddChild(std::move(inner_scroll)); | 337 page_scale->test_properties()->AddChild(std::move(inner_scroll)); |
338 inner_clip->test_properties()->AddChild(std::move(page_scale)); | 338 inner_clip->test_properties()->AddChild(std::move(page_scale)); |
339 root->test_properties()->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->SetRootLayerForTesting(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 |
350 LayerImpl* SetupScrollAndContentsLayers(const gfx::Size& content_size) { | 350 LayerImpl* SetupScrollAndContentsLayers(const gfx::Size& content_size) { |
351 LayerImpl* scroll_layer = CreateScrollAndContentsLayers( | 351 LayerImpl* scroll_layer = CreateScrollAndContentsLayers( |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 EXPECT_FALSE(host_impl_->CanDraw()); | 535 EXPECT_FALSE(host_impl_->CanDraw()); |
536 on_can_draw_state_changed_called_ = false; | 536 on_can_draw_state_changed_called_ = false; |
537 | 537 |
538 // Set up the root layer, which allows us to draw. | 538 // Set up the root layer, which allows us to draw. |
539 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 539 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
540 EXPECT_TRUE(host_impl_->CanDraw()); | 540 EXPECT_TRUE(host_impl_->CanDraw()); |
541 EXPECT_TRUE(on_can_draw_state_changed_called_); | 541 EXPECT_TRUE(on_can_draw_state_changed_called_); |
542 on_can_draw_state_changed_called_ = false; | 542 on_can_draw_state_changed_called_ = false; |
543 | 543 |
544 // Toggle the root layer to make sure it toggles can_draw | 544 // Toggle the root layer to make sure it toggles can_draw |
545 host_impl_->active_tree()->SetRootLayer(nullptr); | 545 host_impl_->active_tree()->SetRootLayerForTesting(nullptr); |
546 host_impl_->active_tree()->DetachLayers(); | 546 host_impl_->active_tree()->DetachLayers(); |
547 EXPECT_FALSE(host_impl_->CanDraw()); | 547 EXPECT_FALSE(host_impl_->CanDraw()); |
548 EXPECT_TRUE(on_can_draw_state_changed_called_); | 548 EXPECT_TRUE(on_can_draw_state_changed_called_); |
549 on_can_draw_state_changed_called_ = false; | 549 on_can_draw_state_changed_called_ = false; |
550 | 550 |
551 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 551 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
552 EXPECT_TRUE(host_impl_->CanDraw()); | 552 EXPECT_TRUE(host_impl_->CanDraw()); |
553 EXPECT_TRUE(on_can_draw_state_changed_called_); | 553 EXPECT_TRUE(on_can_draw_state_changed_called_); |
554 on_can_draw_state_changed_called_ = false; | 554 on_can_draw_state_changed_called_ = false; |
555 | 555 |
(...skipping 24 matching lines...) Expand all Loading... |
580 gfx::Transform identity; | 580 gfx::Transform identity; |
581 gfx::Rect viewport(100, 100); | 581 gfx::Rect viewport(100, 100); |
582 const bool resourceless_software_draw = true; | 582 const bool resourceless_software_draw = true; |
583 host_impl_->OnDraw(identity, viewport, viewport, resourceless_software_draw); | 583 host_impl_->OnDraw(identity, viewport, viewport, resourceless_software_draw); |
584 ASSERT_EQ(fake_output_surface->num_sent_frames(), 1u); | 584 ASSERT_EQ(fake_output_surface->num_sent_frames(), 1u); |
585 EXPECT_EQ(gfx::SizeF(100.f, 100.f), | 585 EXPECT_EQ(gfx::SizeF(100.f, 100.f), |
586 fake_output_surface->last_sent_frame()->metadata.root_layer_size); | 586 fake_output_surface->last_sent_frame()->metadata.root_layer_size); |
587 } | 587 } |
588 | 588 |
589 TEST_F(LayerTreeHostImplTest, ScrollDeltaNoLayers) { | 589 TEST_F(LayerTreeHostImplTest, ScrollDeltaNoLayers) { |
590 ASSERT_FALSE(host_impl_->active_tree()->root_layer()); | 590 ASSERT_FALSE(host_impl_->active_tree()->root_layer_for_testing()); |
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->test_properties()->AddChild( | 601 root->test_properties()->AddChild( |
602 LayerImpl::Create(host_impl_->active_tree(), 2)); | 602 LayerImpl::Create(host_impl_->active_tree(), 2)); |
603 root->test_properties()->AddChild( | 603 root->test_properties()->AddChild( |
604 LayerImpl::Create(host_impl_->active_tree(), 3)); | 604 LayerImpl::Create(host_impl_->active_tree(), 3)); |
605 root->test_properties()->children[1]->test_properties()->AddChild( | 605 root->test_properties()->children[1]->test_properties()->AddChild( |
606 LayerImpl::Create(host_impl_->active_tree(), 4)); | 606 LayerImpl::Create(host_impl_->active_tree(), 4)); |
607 root->test_properties()->children[1]->test_properties()->AddChild( | 607 root->test_properties()->children[1]->test_properties()->AddChild( |
608 LayerImpl::Create(host_impl_->active_tree(), 5)); | 608 LayerImpl::Create(host_impl_->active_tree(), 5)); |
609 root->test_properties() | 609 root->test_properties() |
610 ->children[1] | 610 ->children[1] |
611 ->test_properties() | 611 ->test_properties() |
612 ->children[0] | 612 ->children[0] |
613 ->test_properties() | 613 ->test_properties() |
614 ->AddChild(LayerImpl::Create(host_impl_->active_tree(), 6)); | 614 ->AddChild(LayerImpl::Create(host_impl_->active_tree(), 6)); |
615 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 615 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
616 } | 616 } |
617 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 617 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); |
618 | 618 |
619 ExpectClearedScrollDeltasRecursive(root); | 619 ExpectClearedScrollDeltasRecursive(root); |
620 | 620 |
621 std::unique_ptr<ScrollAndScaleSet> scroll_info; | 621 std::unique_ptr<ScrollAndScaleSet> scroll_info; |
622 | 622 |
623 scroll_info = host_impl_->ProcessScrollDeltas(); | 623 scroll_info = host_impl_->ProcessScrollDeltas(); |
624 ASSERT_EQ(scroll_info->scrolls.size(), 0u); | 624 ASSERT_EQ(scroll_info->scrolls.size(), 0u); |
625 ExpectClearedScrollDeltasRecursive(root); | 625 ExpectClearedScrollDeltasRecursive(root); |
626 | 626 |
627 scroll_info = host_impl_->ProcessScrollDeltas(); | 627 scroll_info = host_impl_->ProcessScrollDeltas(); |
(...skipping 11 matching lines...) Expand all Loading... |
639 LayerImpl::Create(host_impl_->active_tree(), 1); | 639 LayerImpl::Create(host_impl_->active_tree(), 1); |
640 root_clip->SetBounds(gfx::Size(10, 10)); | 640 root_clip->SetBounds(gfx::Size(10, 10)); |
641 LayerImpl* root_layer = root.get(); | 641 LayerImpl* root_layer = root.get(); |
642 root_clip->test_properties()->AddChild(std::move(root)); | 642 root_clip->test_properties()->AddChild(std::move(root)); |
643 root_layer->SetBounds(gfx::Size(110, 110)); | 643 root_layer->SetBounds(gfx::Size(110, 110)); |
644 root_layer->SetScrollClipLayer(root_clip->id()); | 644 root_layer->SetScrollClipLayer(root_clip->id()); |
645 root_layer->layer_tree_impl() | 645 root_layer->layer_tree_impl() |
646 ->property_trees() | 646 ->property_trees() |
647 ->scroll_tree.UpdateScrollOffsetBaseForTesting(root_layer->id(), | 647 ->scroll_tree.UpdateScrollOffsetBaseForTesting(root_layer->id(), |
648 scroll_offset); | 648 scroll_offset); |
649 host_impl_->active_tree()->SetRootLayer(std::move(root_clip)); | 649 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_clip)); |
650 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 650 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
651 root_layer->ScrollBy(scroll_delta); | 651 root_layer->ScrollBy(scroll_delta); |
652 } | 652 } |
653 | 653 |
654 LayerImpl* root = | 654 LayerImpl* root = host_impl_->active_tree() |
655 host_impl_->active_tree()->root_layer()->test_properties()->children[0]; | 655 ->root_layer_for_testing() |
| 656 ->test_properties() |
| 657 ->children[0]; |
656 | 658 |
657 std::unique_ptr<ScrollAndScaleSet> scroll_info; | 659 std::unique_ptr<ScrollAndScaleSet> scroll_info; |
658 | 660 |
659 scroll_info = host_impl_->ProcessScrollDeltas(); | 661 scroll_info = host_impl_->ProcessScrollDeltas(); |
660 ASSERT_EQ(scroll_info->scrolls.size(), 1u); | 662 ASSERT_EQ(scroll_info->scrolls.size(), 1u); |
661 EXPECT_TRUE(ScrollInfoContains(*scroll_info, root->id(), scroll_delta)); | 663 EXPECT_TRUE(ScrollInfoContains(*scroll_info, root->id(), scroll_delta)); |
662 | 664 |
663 gfx::Vector2d scroll_delta2(-5, 27); | 665 gfx::Vector2d scroll_delta2(-5, 27); |
664 root->ScrollBy(scroll_delta2); | 666 root->ScrollBy(scroll_delta2); |
665 scroll_info = host_impl_->ProcessScrollDeltas(); | 667 scroll_info = host_impl_->ProcessScrollDeltas(); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 790 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
789 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 791 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
790 status.main_thread_scrolling_reasons); | 792 status.main_thread_scrolling_reasons); |
791 host_impl_->ScrollEnd(EndState().get()); | 793 host_impl_->ScrollEnd(EndState().get()); |
792 } | 794 } |
793 | 795 |
794 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnTouchEventHandlers) { | 796 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnTouchEventHandlers) { |
795 LayerImpl* scroll = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 797 LayerImpl* scroll = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
796 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 798 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
797 DrawFrame(); | 799 DrawFrame(); |
798 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 800 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); |
799 | 801 |
800 LayerImpl* child = 0; | 802 LayerImpl* child = 0; |
801 { | 803 { |
802 std::unique_ptr<LayerImpl> child_layer = | 804 std::unique_ptr<LayerImpl> child_layer = |
803 LayerImpl::Create(host_impl_->active_tree(), 6); | 805 LayerImpl::Create(host_impl_->active_tree(), 6); |
804 child = child_layer.get(); | 806 child = child_layer.get(); |
805 child_layer->SetDrawsContent(true); | 807 child_layer->SetDrawsContent(true); |
806 child_layer->SetPosition(gfx::PointF(0, 20)); | 808 child_layer->SetPosition(gfx::PointF(0, 20)); |
807 child_layer->SetBounds(gfx::Size(50, 50)); | 809 child_layer->SetBounds(gfx::Size(50, 50)); |
808 scroll->test_properties()->AddChild(std::move(child_layer)); | 810 scroll->test_properties()->AddChild(std::move(child_layer)); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 // Now the fling should go ahead since we've started scrolling a layer | 877 // Now the fling should go ahead since we've started scrolling a layer |
876 status = host_impl_->FlingScrollBegin(); | 878 status = host_impl_->FlingScrollBegin(); |
877 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 879 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
878 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 880 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
879 status.main_thread_scrolling_reasons); | 881 status.main_thread_scrolling_reasons); |
880 } | 882 } |
881 | 883 |
882 TEST_F(LayerTreeHostImplTest, NoFlingWhenScrollingOnMain) { | 884 TEST_F(LayerTreeHostImplTest, NoFlingWhenScrollingOnMain) { |
883 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 885 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
884 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 886 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
885 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 887 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); |
886 | 888 |
887 root->set_main_thread_scrolling_reasons( | 889 root->set_main_thread_scrolling_reasons( |
888 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); | 890 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); |
889 | 891 |
890 SetNeedsRebuildPropertyTrees(); | 892 SetNeedsRebuildPropertyTrees(); |
891 DrawFrame(); | 893 DrawFrame(); |
892 | 894 |
893 // Start scrolling a layer | 895 // Start scrolling a layer |
894 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 896 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
895 BeginState(gfx::Point()).get(), InputHandler::TOUCHSCREEN); | 897 BeginState(gfx::Point()).get(), InputHandler::TOUCHSCREEN); |
896 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); | 898 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); |
897 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, | 899 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, |
898 status.main_thread_scrolling_reasons); | 900 status.main_thread_scrolling_reasons); |
899 | 901 |
900 // The fling should be ignored since there's no layer being scrolled impl-side | 902 // The fling should be ignored since there's no layer being scrolled impl-side |
901 status = host_impl_->FlingScrollBegin(); | 903 status = host_impl_->FlingScrollBegin(); |
902 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); | 904 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); |
903 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, | 905 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, |
904 status.main_thread_scrolling_reasons); | 906 status.main_thread_scrolling_reasons); |
905 } | 907 } |
906 | 908 |
907 TEST_F(LayerTreeHostImplTest, ShouldScrollOnMainThread) { | 909 TEST_F(LayerTreeHostImplTest, ShouldScrollOnMainThread) { |
908 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 910 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
909 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 911 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
910 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 912 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); |
911 | 913 |
912 root->set_main_thread_scrolling_reasons( | 914 root->set_main_thread_scrolling_reasons( |
913 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); | 915 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); |
914 SetNeedsRebuildPropertyTrees(); | 916 SetNeedsRebuildPropertyTrees(); |
915 DrawFrame(); | 917 DrawFrame(); |
916 | 918 |
917 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 919 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
918 BeginState(gfx::Point()).get(), InputHandler::WHEEL); | 920 BeginState(gfx::Point()).get(), InputHandler::WHEEL); |
919 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); | 921 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); |
920 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, | 922 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
965 squash2->SetBounds(gfx::Size(140, 300)); | 967 squash2->SetBounds(gfx::Size(140, 300)); |
966 squash2->SetPosition(gfx::PointF(220, 300)); | 968 squash2->SetPosition(gfx::PointF(220, 300)); |
967 squash2->SetDrawsContent(true); | 969 squash2->SetDrawsContent(true); |
968 | 970 |
969 scroll->test_properties()->AddChild(std::move(squash2)); | 971 scroll->test_properties()->AddChild(std::move(squash2)); |
970 clip->test_properties()->AddChild(std::move(scroll)); | 972 clip->test_properties()->AddChild(std::move(scroll)); |
971 clip->test_properties()->AddChild(std::move(scrollbar)); | 973 clip->test_properties()->AddChild(std::move(scrollbar)); |
972 clip->test_properties()->AddChild(std::move(squash1)); | 974 clip->test_properties()->AddChild(std::move(squash1)); |
973 root->test_properties()->AddChild(std::move(clip)); | 975 root->test_properties()->AddChild(std::move(clip)); |
974 | 976 |
975 layer_tree_impl->SetRootLayer(std::move(root)); | 977 layer_tree_impl->SetRootLayerForTesting(std::move(root)); |
976 SetNeedsRebuildPropertyTrees(); | 978 SetNeedsRebuildPropertyTrees(); |
977 RebuildPropertyTrees(); | 979 RebuildPropertyTrees(); |
978 layer_tree_impl->DidBecomeActive(); | 980 layer_tree_impl->DidBecomeActive(); |
979 | 981 |
980 // The point hits squash1 layer and also scroll layer, because scroll layer is | 982 // The point hits squash1 layer and also scroll layer, because scroll layer is |
981 // not an ancestor of squash1 layer, we cannot scroll on impl thread. | 983 // not an ancestor of squash1 layer, we cannot scroll on impl thread. |
982 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 984 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
983 BeginState(gfx::Point(230, 150)).get(), InputHandler::WHEEL); | 985 BeginState(gfx::Point(230, 150)).get(), InputHandler::WHEEL); |
984 EXPECT_EQ(InputHandler::SCROLL_UNKNOWN, status.thread); | 986 EXPECT_EQ(InputHandler::SCROLL_UNKNOWN, status.thread); |
985 EXPECT_EQ(MainThreadScrollingReason::kFailedHitTest, | 987 EXPECT_EQ(MainThreadScrollingReason::kFailedHitTest, |
(...skipping 10 matching lines...) Expand all Loading... |
996 // an ancestor of squash2 layer, we should scroll on impl. | 998 // an ancestor of squash2 layer, we should scroll on impl. |
997 status = host_impl_->ScrollBegin(BeginState(gfx::Point(230, 450)).get(), | 999 status = host_impl_->ScrollBegin(BeginState(gfx::Point(230, 450)).get(), |
998 InputHandler::WHEEL); | 1000 InputHandler::WHEEL); |
999 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 1001 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
1000 } | 1002 } |
1001 | 1003 |
1002 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionBasic) { | 1004 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionBasic) { |
1003 SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 1005 SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
1004 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 1006 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
1005 | 1007 |
1006 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 1008 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); |
1007 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); | 1009 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); |
1008 | 1010 |
1009 SetNeedsRebuildPropertyTrees(); | 1011 SetNeedsRebuildPropertyTrees(); |
1010 DrawFrame(); | 1012 DrawFrame(); |
1011 | 1013 |
1012 // All scroll types inside the non-fast scrollable region should fail. | 1014 // All scroll types inside the non-fast scrollable region should fail. |
1013 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 1015 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
1014 BeginState(gfx::Point(25, 25)).get(), InputHandler::WHEEL); | 1016 BeginState(gfx::Point(25, 25)).get(), InputHandler::WHEEL); |
1015 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); | 1017 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); |
1016 EXPECT_EQ(MainThreadScrollingReason::kNonFastScrollableRegion, | 1018 EXPECT_EQ(MainThreadScrollingReason::kNonFastScrollableRegion, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1052 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); | 1054 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
1053 host_impl_->ScrollEnd(EndState().get()); | 1055 host_impl_->ScrollEnd(EndState().get()); |
1054 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( | 1056 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( |
1055 gfx::Point(75, 75), InputHandler::TOUCHSCREEN)); | 1057 gfx::Point(75, 75), InputHandler::TOUCHSCREEN)); |
1056 } | 1058 } |
1057 | 1059 |
1058 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionWithOffset) { | 1060 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionWithOffset) { |
1059 SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 1061 SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
1060 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 1062 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
1061 | 1063 |
1062 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 1064 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); |
1063 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); | 1065 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); |
1064 root->SetPosition(gfx::PointF(-25.f, 0.f)); | 1066 root->SetPosition(gfx::PointF(-25.f, 0.f)); |
1065 root->SetDrawsContent(true); | 1067 root->SetDrawsContent(true); |
1066 | 1068 |
1067 SetNeedsRebuildPropertyTrees(); | 1069 SetNeedsRebuildPropertyTrees(); |
1068 DrawFrame(); | 1070 DrawFrame(); |
1069 | 1071 |
1070 // This point would fall into the non-fast scrollable region except that we've | 1072 // This point would fall into the non-fast scrollable region except that we've |
1071 // moved the layer down by 25 pixels. | 1073 // moved the layer down by 25 pixels. |
1072 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 1074 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1287 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), scroll_layer->CurrentScrollOffset()); | 1289 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), scroll_layer->CurrentScrollOffset()); |
1288 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); | 1290 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); |
1289 } | 1291 } |
1290 | 1292 |
1291 TEST_F(LayerTreeHostImplTest, AnimationSchedulingPendingTree) { | 1293 TEST_F(LayerTreeHostImplTest, AnimationSchedulingPendingTree) { |
1292 EXPECT_FALSE(host_impl_->CommitToActiveTree()); | 1294 EXPECT_FALSE(host_impl_->CommitToActiveTree()); |
1293 | 1295 |
1294 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1296 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
1295 | 1297 |
1296 host_impl_->CreatePendingTree(); | 1298 host_impl_->CreatePendingTree(); |
1297 host_impl_->pending_tree()->SetRootLayer( | 1299 host_impl_->pending_tree()->SetRootLayerForTesting( |
1298 LayerImpl::Create(host_impl_->pending_tree(), 1)); | 1300 LayerImpl::Create(host_impl_->pending_tree(), 1)); |
1299 LayerImpl* root = host_impl_->pending_tree()->root_layer(); | 1301 LayerImpl* root = host_impl_->pending_tree()->root_layer_for_testing(); |
1300 root->SetBounds(gfx::Size(50, 50)); | 1302 root->SetBounds(gfx::Size(50, 50)); |
1301 root->test_properties()->force_render_surface = true; | 1303 root->test_properties()->force_render_surface = true; |
1302 | 1304 |
1303 root->test_properties()->AddChild( | 1305 root->test_properties()->AddChild( |
1304 LayerImpl::Create(host_impl_->pending_tree(), 2)); | 1306 LayerImpl::Create(host_impl_->pending_tree(), 2)); |
1305 host_impl_->pending_tree()->BuildLayerListForTesting(); | 1307 host_impl_->pending_tree()->BuildLayerListForTesting(); |
1306 LayerImpl* child = root->test_properties()->children[0]; | 1308 LayerImpl* child = root->test_properties()->children[0]; |
1307 child->SetBounds(gfx::Size(10, 10)); | 1309 child->SetBounds(gfx::Size(10, 10)); |
1308 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); | 1310 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); |
1309 child->SetDrawsContent(true); | 1311 child->SetDrawsContent(true); |
(...skipping 29 matching lines...) Expand all Loading... |
1339 // activating will draw on its own when it's ready. | 1341 // activating will draw on its own when it's ready. |
1340 EXPECT_FALSE(did_request_redraw_); | 1342 EXPECT_FALSE(did_request_redraw_); |
1341 EXPECT_FALSE(did_request_commit_); | 1343 EXPECT_FALSE(did_request_commit_); |
1342 } | 1344 } |
1343 | 1345 |
1344 TEST_F(LayerTreeHostImplTest, AnimationSchedulingActiveTree) { | 1346 TEST_F(LayerTreeHostImplTest, AnimationSchedulingActiveTree) { |
1345 EXPECT_FALSE(host_impl_->CommitToActiveTree()); | 1347 EXPECT_FALSE(host_impl_->CommitToActiveTree()); |
1346 | 1348 |
1347 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1349 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
1348 | 1350 |
1349 host_impl_->active_tree()->SetRootLayer( | 1351 host_impl_->active_tree()->SetRootLayerForTesting( |
1350 LayerImpl::Create(host_impl_->active_tree(), 1)); | 1352 LayerImpl::Create(host_impl_->active_tree(), 1)); |
1351 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 1353 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); |
1352 root->SetBounds(gfx::Size(50, 50)); | 1354 root->SetBounds(gfx::Size(50, 50)); |
1353 root->test_properties()->force_render_surface = true; | 1355 root->test_properties()->force_render_surface = true; |
1354 | 1356 |
1355 root->test_properties()->AddChild( | 1357 root->test_properties()->AddChild( |
1356 LayerImpl::Create(host_impl_->active_tree(), 2)); | 1358 LayerImpl::Create(host_impl_->active_tree(), 2)); |
1357 LayerImpl* child = root->test_properties()->children[0]; | 1359 LayerImpl* child = root->test_properties()->children[0]; |
1358 child->SetBounds(gfx::Size(10, 10)); | 1360 child->SetBounds(gfx::Size(10, 10)); |
1359 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); | 1361 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); |
1360 child->SetDrawsContent(true); | 1362 child->SetDrawsContent(true); |
1361 | 1363 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1404 } | 1406 } |
1405 | 1407 |
1406 TEST_F(LayerTreeHostImplTest, AnimationSchedulingCommitToActiveTree) { | 1408 TEST_F(LayerTreeHostImplTest, AnimationSchedulingCommitToActiveTree) { |
1407 FakeImplTaskRunnerProvider provider(nullptr); | 1409 FakeImplTaskRunnerProvider provider(nullptr); |
1408 CreateHostImplWithTaskRunnerProvider(DefaultSettings(), CreateOutputSurface(), | 1410 CreateHostImplWithTaskRunnerProvider(DefaultSettings(), CreateOutputSurface(), |
1409 &provider); | 1411 &provider); |
1410 EXPECT_TRUE(host_impl_->CommitToActiveTree()); | 1412 EXPECT_TRUE(host_impl_->CommitToActiveTree()); |
1411 | 1413 |
1412 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1414 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
1413 | 1415 |
1414 host_impl_->active_tree()->SetRootLayer( | 1416 host_impl_->active_tree()->SetRootLayerForTesting( |
1415 LayerImpl::Create(host_impl_->active_tree(), 1)); | 1417 LayerImpl::Create(host_impl_->active_tree(), 1)); |
1416 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 1418 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); |
1417 root->SetBounds(gfx::Size(50, 50)); | 1419 root->SetBounds(gfx::Size(50, 50)); |
1418 root->SetHasRenderSurface(true); | 1420 root->SetHasRenderSurface(true); |
1419 | 1421 |
1420 root->test_properties()->AddChild( | 1422 root->test_properties()->AddChild( |
1421 LayerImpl::Create(host_impl_->active_tree(), 2)); | 1423 LayerImpl::Create(host_impl_->active_tree(), 2)); |
1422 LayerImpl* child = root->test_properties()->children[0]; | 1424 LayerImpl* child = root->test_properties()->children[0]; |
1423 child->SetBounds(gfx::Size(10, 10)); | 1425 child->SetBounds(gfx::Size(10, 10)); |
1424 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); | 1426 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); |
1425 child->SetDrawsContent(true); | 1427 child->SetDrawsContent(true); |
1426 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 10.0, 3, 0); | 1428 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 10.0, 3, 0); |
(...skipping 17 matching lines...) Expand all Loading... |
1444 EXPECT_TRUE(did_request_redraw_); | 1446 EXPECT_TRUE(did_request_redraw_); |
1445 EXPECT_FALSE(did_request_commit_); | 1447 EXPECT_FALSE(did_request_commit_); |
1446 | 1448 |
1447 // Delete the LayerTreeHostImpl before the TaskRunnerProvider goes away. | 1449 // Delete the LayerTreeHostImpl before the TaskRunnerProvider goes away. |
1448 host_impl_ = nullptr; | 1450 host_impl_ = nullptr; |
1449 } | 1451 } |
1450 | 1452 |
1451 TEST_F(LayerTreeHostImplTest, AnimationSchedulingOnLayerDestruction) { | 1453 TEST_F(LayerTreeHostImplTest, AnimationSchedulingOnLayerDestruction) { |
1452 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1454 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
1453 | 1455 |
1454 host_impl_->active_tree()->SetRootLayer( | 1456 host_impl_->active_tree()->SetRootLayerForTesting( |
1455 LayerImpl::Create(host_impl_->active_tree(), 1)); | 1457 LayerImpl::Create(host_impl_->active_tree(), 1)); |
1456 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 1458 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); |
1457 root->SetBounds(gfx::Size(50, 50)); | 1459 root->SetBounds(gfx::Size(50, 50)); |
1458 | 1460 |
1459 root->test_properties()->AddChild( | 1461 root->test_properties()->AddChild( |
1460 LayerImpl::Create(host_impl_->active_tree(), 2)); | 1462 LayerImpl::Create(host_impl_->active_tree(), 2)); |
1461 LayerImpl* child = root->test_properties()->children[0]; | 1463 LayerImpl* child = root->test_properties()->children[0]; |
1462 child->SetBounds(gfx::Size(10, 10)); | 1464 child->SetBounds(gfx::Size(10, 10)); |
1463 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); | 1465 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); |
1464 child->SetDrawsContent(true); | 1466 child->SetDrawsContent(true); |
1465 | 1467 |
1466 // Add a translate animation. | 1468 // Add a translate animation. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1517 append_quads_data->num_missing_tiles += has_missing_tiles_; | 1519 append_quads_data->num_missing_tiles += has_missing_tiles_; |
1518 } | 1520 } |
1519 | 1521 |
1520 private: | 1522 private: |
1521 bool has_missing_tiles_; | 1523 bool has_missing_tiles_; |
1522 }; | 1524 }; |
1523 | 1525 |
1524 TEST_F(LayerTreeHostImplTest, AnimationMarksLayerNotReady) { | 1526 TEST_F(LayerTreeHostImplTest, AnimationMarksLayerNotReady) { |
1525 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1527 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
1526 | 1528 |
1527 host_impl_->active_tree()->SetRootLayer( | 1529 host_impl_->active_tree()->SetRootLayerForTesting( |
1528 LayerImpl::Create(host_impl_->active_tree(), 1)); | 1530 LayerImpl::Create(host_impl_->active_tree(), 1)); |
1529 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 1531 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); |
1530 root->SetBounds(gfx::Size(50, 50)); | 1532 root->SetBounds(gfx::Size(50, 50)); |
1531 root->SetHasRenderSurface(true); | 1533 root->SetHasRenderSurface(true); |
1532 | 1534 |
1533 root->test_properties()->AddChild(std::unique_ptr<MissingTilesLayer>( | 1535 root->test_properties()->AddChild(std::unique_ptr<MissingTilesLayer>( |
1534 new MissingTilesLayer(host_impl_->active_tree(), 2))); | 1536 new MissingTilesLayer(host_impl_->active_tree(), 2))); |
1535 MissingTilesLayer* child = | 1537 MissingTilesLayer* child = |
1536 static_cast<MissingTilesLayer*>(root->test_properties()->children[0]); | 1538 static_cast<MissingTilesLayer*>(root->test_properties()->children[0]); |
1537 child->SetBounds(gfx::Size(10, 10)); | 1539 child->SetBounds(gfx::Size(10, 10)); |
1538 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); | 1540 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); |
1539 child->SetDrawsContent(true); | 1541 child->SetDrawsContent(true); |
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2481 } | 2483 } |
2482 | 2484 |
2483 TEST_F(LayerTreeHostImplTest, PageScaleAnimationTransferedOnSyncTreeActivate) { | 2485 TEST_F(LayerTreeHostImplTest, PageScaleAnimationTransferedOnSyncTreeActivate) { |
2484 host_impl_->CreatePendingTree(); | 2486 host_impl_->CreatePendingTree(); |
2485 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); | 2487 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); |
2486 CreateScrollAndContentsLayers( | 2488 CreateScrollAndContentsLayers( |
2487 host_impl_->pending_tree(), | 2489 host_impl_->pending_tree(), |
2488 gfx::Size(100, 100)); | 2490 gfx::Size(100, 100)); |
2489 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting(); | 2491 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting(); |
2490 host_impl_->ActivateSyncTree(); | 2492 host_impl_->ActivateSyncTree(); |
| 2493 host_impl_->active_tree()->SetRootLayerFromLayerListForTesting(); |
2491 DrawFrame(); | 2494 DrawFrame(); |
2492 | 2495 |
2493 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); | 2496 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); |
2494 DCHECK(scroll_layer); | 2497 DCHECK(scroll_layer); |
2495 | 2498 |
2496 float min_page_scale = 0.5f; | 2499 float min_page_scale = 0.5f; |
2497 float max_page_scale = 4.f; | 2500 float max_page_scale = 4.f; |
2498 host_impl_->sync_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, | 2501 host_impl_->sync_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, |
2499 max_page_scale); | 2502 max_page_scale); |
2500 host_impl_->ActivateSyncTree(); | 2503 host_impl_->ActivateSyncTree(); |
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3387 private: | 3390 private: |
3388 bool will_draw_returns_false_; | 3391 bool will_draw_returns_false_; |
3389 bool will_draw_called_; | 3392 bool will_draw_called_; |
3390 bool append_quads_called_; | 3393 bool append_quads_called_; |
3391 bool did_draw_called_; | 3394 bool did_draw_called_; |
3392 }; | 3395 }; |
3393 | 3396 |
3394 TEST_F(LayerTreeHostImplTest, WillDrawReturningFalseDoesNotCall) { | 3397 TEST_F(LayerTreeHostImplTest, WillDrawReturningFalseDoesNotCall) { |
3395 // The root layer is always drawn, so run this test on a child layer that | 3398 // The root layer is always drawn, so run this test on a child layer that |
3396 // will be masked out by the root layer's bounds. | 3399 // will be masked out by the root layer's bounds. |
3397 host_impl_->active_tree()->SetRootLayer( | 3400 host_impl_->active_tree()->SetRootLayerForTesting( |
3398 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 3401 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
3399 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( | 3402 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( |
3400 host_impl_->active_tree()->root_layer()); | 3403 host_impl_->active_tree()->root_layer_for_testing()); |
3401 | 3404 |
3402 root->test_properties()->AddChild( | 3405 root->test_properties()->AddChild( |
3403 DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 3406 DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
3404 root->test_properties()->force_render_surface = true; | 3407 root->test_properties()->force_render_surface = true; |
3405 DidDrawCheckLayer* layer = | 3408 DidDrawCheckLayer* layer = |
3406 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]); | 3409 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]); |
3407 | 3410 |
3408 { | 3411 { |
3409 LayerTreeHostImpl::FrameData frame; | 3412 LayerTreeHostImpl::FrameData frame; |
3410 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 3413 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
(...skipping 19 matching lines...) Expand all Loading... |
3430 | 3433 |
3431 EXPECT_TRUE(layer->will_draw_called()); | 3434 EXPECT_TRUE(layer->will_draw_called()); |
3432 EXPECT_FALSE(layer->append_quads_called()); | 3435 EXPECT_FALSE(layer->append_quads_called()); |
3433 EXPECT_FALSE(layer->did_draw_called()); | 3436 EXPECT_FALSE(layer->did_draw_called()); |
3434 } | 3437 } |
3435 } | 3438 } |
3436 | 3439 |
3437 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) { | 3440 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) { |
3438 // The root layer is always drawn, so run this test on a child layer that | 3441 // The root layer is always drawn, so run this test on a child layer that |
3439 // will be masked out by the root layer's bounds. | 3442 // will be masked out by the root layer's bounds. |
3440 host_impl_->active_tree()->SetRootLayer( | 3443 host_impl_->active_tree()->SetRootLayerForTesting( |
3441 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 3444 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
3442 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( | 3445 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( |
3443 host_impl_->active_tree()->root_layer()); | 3446 host_impl_->active_tree()->root_layer_for_testing()); |
3444 root->SetMasksToBounds(true); | 3447 root->SetMasksToBounds(true); |
3445 root->test_properties()->force_render_surface = true; | 3448 root->test_properties()->force_render_surface = true; |
3446 root->test_properties()->AddChild( | 3449 root->test_properties()->AddChild( |
3447 DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 3450 DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
3448 DidDrawCheckLayer* layer = | 3451 DidDrawCheckLayer* layer = |
3449 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]); | 3452 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]); |
3450 // Ensure visible_layer_rect for layer is empty. | 3453 // Ensure visible_layer_rect for layer is empty. |
3451 layer->SetPosition(gfx::PointF(100.f, 100.f)); | 3454 layer->SetPosition(gfx::PointF(100.f, 100.f)); |
3452 layer->SetBounds(gfx::Size(10, 10)); | 3455 layer->SetBounds(gfx::Size(10, 10)); |
3453 | 3456 |
(...skipping 27 matching lines...) Expand all Loading... |
3481 EXPECT_TRUE(layer->will_draw_called()); | 3484 EXPECT_TRUE(layer->will_draw_called()); |
3482 EXPECT_TRUE(layer->did_draw_called()); | 3485 EXPECT_TRUE(layer->did_draw_called()); |
3483 | 3486 |
3484 EXPECT_FALSE(layer->visible_layer_rect().IsEmpty()); | 3487 EXPECT_FALSE(layer->visible_layer_rect().IsEmpty()); |
3485 } | 3488 } |
3486 | 3489 |
3487 TEST_F(LayerTreeHostImplTest, WillDrawNotCalledOnOccludedLayer) { | 3490 TEST_F(LayerTreeHostImplTest, WillDrawNotCalledOnOccludedLayer) { |
3488 gfx::Size big_size(1000, 1000); | 3491 gfx::Size big_size(1000, 1000); |
3489 host_impl_->SetViewportSize(big_size); | 3492 host_impl_->SetViewportSize(big_size); |
3490 | 3493 |
3491 host_impl_->active_tree()->SetRootLayer( | 3494 host_impl_->active_tree()->SetRootLayerForTesting( |
3492 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 3495 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
3493 DidDrawCheckLayer* root = | 3496 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( |
3494 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 3497 host_impl_->active_tree()->root_layer_for_testing()); |
3495 | 3498 |
3496 root->test_properties()->AddChild( | 3499 root->test_properties()->AddChild( |
3497 DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 3500 DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
3498 DidDrawCheckLayer* occluded_layer = | 3501 DidDrawCheckLayer* occluded_layer = |
3499 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]); | 3502 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]); |
3500 | 3503 |
3501 root->test_properties()->AddChild( | 3504 root->test_properties()->AddChild( |
3502 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | 3505 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
3503 root->test_properties()->force_render_surface = true; | 3506 root->test_properties()->force_render_surface = true; |
3504 DidDrawCheckLayer* top_layer = | 3507 DidDrawCheckLayer* top_layer = |
(...skipping 14 matching lines...) Expand all Loading... |
3519 host_impl_->DrawLayers(&frame); | 3522 host_impl_->DrawLayers(&frame); |
3520 host_impl_->DidDrawAllLayers(frame); | 3523 host_impl_->DidDrawAllLayers(frame); |
3521 | 3524 |
3522 EXPECT_FALSE(occluded_layer->will_draw_called()); | 3525 EXPECT_FALSE(occluded_layer->will_draw_called()); |
3523 EXPECT_FALSE(occluded_layer->did_draw_called()); | 3526 EXPECT_FALSE(occluded_layer->did_draw_called()); |
3524 EXPECT_TRUE(top_layer->will_draw_called()); | 3527 EXPECT_TRUE(top_layer->will_draw_called()); |
3525 EXPECT_TRUE(top_layer->did_draw_called()); | 3528 EXPECT_TRUE(top_layer->did_draw_called()); |
3526 } | 3529 } |
3527 | 3530 |
3528 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { | 3531 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { |
3529 host_impl_->active_tree()->SetRootLayer( | 3532 host_impl_->active_tree()->SetRootLayerForTesting( |
3530 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 3533 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
3531 DidDrawCheckLayer* root = | 3534 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( |
3532 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 3535 host_impl_->active_tree()->root_layer_for_testing()); |
3533 | 3536 |
3534 root->test_properties()->AddChild( | 3537 root->test_properties()->AddChild( |
3535 DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 3538 DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
3536 root->test_properties()->force_render_surface = true; | 3539 root->test_properties()->force_render_surface = true; |
3537 DidDrawCheckLayer* layer1 = | 3540 DidDrawCheckLayer* layer1 = |
3538 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]); | 3541 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]); |
3539 | 3542 |
3540 layer1->test_properties()->AddChild( | 3543 layer1->test_properties()->AddChild( |
3541 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | 3544 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
3542 DidDrawCheckLayer* layer2 = | 3545 DidDrawCheckLayer* layer2 = |
3543 static_cast<DidDrawCheckLayer*>(layer1->test_properties()->children[0]); | 3546 static_cast<DidDrawCheckLayer*>(layer1->test_properties()->children[0]); |
3544 | 3547 |
3545 layer1->test_properties()->force_render_surface = true; | 3548 layer1->test_properties()->force_render_surface = true; |
3546 layer1->test_properties()->should_flatten_transform = true; | 3549 layer1->test_properties()->should_flatten_transform = true; |
3547 | 3550 |
3548 EXPECT_FALSE(root->did_draw_called()); | 3551 EXPECT_FALSE(root->did_draw_called()); |
3549 EXPECT_FALSE(layer1->did_draw_called()); | 3552 EXPECT_FALSE(layer1->did_draw_called()); |
3550 EXPECT_FALSE(layer2->did_draw_called()); | 3553 EXPECT_FALSE(layer2->did_draw_called()); |
3551 | 3554 |
3552 LayerTreeHostImpl::FrameData frame; | 3555 LayerTreeHostImpl::FrameData frame; |
3553 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( | 3556 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( |
3554 host_impl_->active_tree()->root_layer()); | 3557 host_impl_->active_tree()->root_layer_for_testing()); |
3555 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 3558 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
3556 host_impl_->DrawLayers(&frame); | 3559 host_impl_->DrawLayers(&frame); |
3557 host_impl_->DidDrawAllLayers(frame); | 3560 host_impl_->DidDrawAllLayers(frame); |
3558 | 3561 |
3559 EXPECT_TRUE(root->did_draw_called()); | 3562 EXPECT_TRUE(root->did_draw_called()); |
3560 EXPECT_TRUE(layer1->did_draw_called()); | 3563 EXPECT_TRUE(layer1->did_draw_called()); |
3561 EXPECT_TRUE(layer2->did_draw_called()); | 3564 EXPECT_TRUE(layer2->did_draw_called()); |
3562 | 3565 |
3563 EXPECT_NE(root->render_surface(), layer1->render_surface()); | 3566 EXPECT_NE(root->render_surface(), layer1->render_surface()); |
3564 EXPECT_TRUE(layer1->render_surface()); | 3567 EXPECT_TRUE(layer1->render_surface()); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3688 cases.back().layer_after.has_missing_tile = true; | 3691 cases.back().layer_after.has_missing_tile = true; |
3689 cases.back().layer_after.is_animating = true; | 3692 cases.back().layer_after.is_animating = true; |
3690 // 16. High res required is higher priority than animating missing tiles. | 3693 // 16. High res required is higher priority than animating missing tiles. |
3691 cases.push_back( | 3694 cases.push_back( |
3692 PrepareToDrawSuccessTestCase(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT)); | 3695 PrepareToDrawSuccessTestCase(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT)); |
3693 cases.back().high_res_required = true; | 3696 cases.back().high_res_required = true; |
3694 cases.back().layer_between.has_missing_tile = true; | 3697 cases.back().layer_between.has_missing_tile = true; |
3695 cases.back().layer_before.has_missing_tile = true; | 3698 cases.back().layer_before.has_missing_tile = true; |
3696 cases.back().layer_before.is_animating = true; | 3699 cases.back().layer_before.is_animating = true; |
3697 | 3700 |
3698 host_impl_->active_tree()->SetRootLayer( | 3701 host_impl_->active_tree()->SetRootLayerForTesting( |
3699 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 3702 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
3700 DidDrawCheckLayer* root = | 3703 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( |
3701 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 3704 host_impl_->active_tree()->root_layer_for_testing()); |
3702 root->test_properties()->force_render_surface = true; | 3705 root->test_properties()->force_render_surface = true; |
3703 | 3706 |
3704 LayerTreeHostImpl::FrameData frame; | 3707 LayerTreeHostImpl::FrameData frame; |
3705 SetNeedsRebuildPropertyTrees(); | 3708 SetNeedsRebuildPropertyTrees(); |
3706 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 3709 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
3707 host_impl_->DrawLayers(&frame); | 3710 host_impl_->DrawLayers(&frame); |
3708 host_impl_->DidDrawAllLayers(frame); | 3711 host_impl_->DidDrawAllLayers(frame); |
3709 host_impl_->SwapBuffers(frame); | 3712 host_impl_->SwapBuffers(frame); |
3710 | 3713 |
3711 for (size_t i = 0; i < cases.size(); ++i) { | 3714 for (size_t i = 0; i < cases.size(); ++i) { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3787 cases.back().layer_between.is_animating = true; | 3790 cases.back().layer_between.is_animating = true; |
3788 // 2. High res required with incomplete tile. | 3791 // 2. High res required with incomplete tile. |
3789 cases.push_back(PrepareToDrawSuccessTestCase(DRAW_SUCCESS)); | 3792 cases.push_back(PrepareToDrawSuccessTestCase(DRAW_SUCCESS)); |
3790 cases.back().high_res_required = true; | 3793 cases.back().high_res_required = true; |
3791 cases.back().layer_between.has_incomplete_tile = true; | 3794 cases.back().layer_between.has_incomplete_tile = true; |
3792 // 3. High res required with missing tile. | 3795 // 3. High res required with missing tile. |
3793 cases.push_back(PrepareToDrawSuccessTestCase(DRAW_SUCCESS)); | 3796 cases.push_back(PrepareToDrawSuccessTestCase(DRAW_SUCCESS)); |
3794 cases.back().high_res_required = true; | 3797 cases.back().high_res_required = true; |
3795 cases.back().layer_between.has_missing_tile = true; | 3798 cases.back().layer_between.has_missing_tile = true; |
3796 | 3799 |
3797 host_impl_->active_tree()->SetRootLayer( | 3800 host_impl_->active_tree()->SetRootLayerForTesting( |
3798 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 3801 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
3799 DidDrawCheckLayer* root = | 3802 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( |
3800 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 3803 host_impl_->active_tree()->root_layer_for_testing()); |
3801 root->test_properties()->force_render_surface = true; | 3804 root->test_properties()->force_render_surface = true; |
3802 | 3805 |
3803 SetNeedsRebuildPropertyTrees(); | 3806 SetNeedsRebuildPropertyTrees(); |
3804 host_impl_->OnDraw(external_transform, external_viewport, external_clip, | 3807 host_impl_->OnDraw(external_transform, external_viewport, external_clip, |
3805 resourceless_software_draw); | 3808 resourceless_software_draw); |
3806 | 3809 |
3807 for (size_t i = 0; i < cases.size(); ++i) { | 3810 for (size_t i = 0; i < cases.size(); ++i) { |
3808 const auto& testcase = cases[i]; | 3811 const auto& testcase = cases[i]; |
3809 std::vector<LayerImpl*> to_remove; | 3812 std::vector<LayerImpl*> to_remove; |
3810 for (const auto& child : root->test_properties()->children) | 3813 for (const auto& child : root->test_properties()->children) |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3853 host_impl_->OnDraw(external_transform, external_viewport, external_clip, | 3856 host_impl_->OnDraw(external_transform, external_viewport, external_clip, |
3854 resourceless_software_draw); | 3857 resourceless_software_draw); |
3855 } | 3858 } |
3856 } | 3859 } |
3857 | 3860 |
3858 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { | 3861 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { |
3859 std::unique_ptr<LayerImpl> root = | 3862 std::unique_ptr<LayerImpl> root = |
3860 LayerImpl::Create(host_impl_->active_tree(), 1); | 3863 LayerImpl::Create(host_impl_->active_tree(), 1); |
3861 root->SetScrollClipLayer(Layer::INVALID_ID); | 3864 root->SetScrollClipLayer(Layer::INVALID_ID); |
3862 root->test_properties()->force_render_surface = true; | 3865 root->test_properties()->force_render_surface = true; |
3863 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 3866 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
3864 SetNeedsRebuildPropertyTrees(); | 3867 SetNeedsRebuildPropertyTrees(); |
3865 DrawFrame(); | 3868 DrawFrame(); |
3866 | 3869 |
3867 // Scroll event is ignored because layer is not scrollable. | 3870 // Scroll event is ignored because layer is not scrollable. |
3868 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 3871 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
3869 BeginState(gfx::Point()).get(), InputHandler::WHEEL); | 3872 BeginState(gfx::Point()).get(), InputHandler::WHEEL); |
3870 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); | 3873 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); |
3871 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, | 3874 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, |
3872 status.main_thread_scrolling_reasons); | 3875 status.main_thread_scrolling_reasons); |
3873 EXPECT_FALSE(did_request_redraw_); | 3876 EXPECT_FALSE(did_request_redraw_); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3968 | 3971 |
3969 int inner_viewport_scroll_layer_id = root->id(); | 3972 int inner_viewport_scroll_layer_id = root->id(); |
3970 int outer_viewport_scroll_layer_id = outer_scroll->id(); | 3973 int outer_viewport_scroll_layer_id = outer_scroll->id(); |
3971 int page_scale_layer_id = page_scale->id(); | 3974 int page_scale_layer_id = page_scale->id(); |
3972 | 3975 |
3973 outer_clip->test_properties()->AddChild(std::move(outer_scroll)); | 3976 outer_clip->test_properties()->AddChild(std::move(outer_scroll)); |
3974 root->test_properties()->AddChild(std::move(outer_clip)); | 3977 root->test_properties()->AddChild(std::move(outer_clip)); |
3975 page_scale->test_properties()->AddChild(std::move(root)); | 3978 page_scale->test_properties()->AddChild(std::move(root)); |
3976 root_clip->test_properties()->AddChild(std::move(page_scale)); | 3979 root_clip->test_properties()->AddChild(std::move(page_scale)); |
3977 | 3980 |
3978 tree_impl->SetRootLayer(std::move(root_clip)); | 3981 tree_impl->SetRootLayerForTesting(std::move(root_clip)); |
3979 tree_impl->SetViewportLayersFromIds(Layer::INVALID_ID, page_scale_layer_id, | 3982 tree_impl->SetViewportLayersFromIds(Layer::INVALID_ID, page_scale_layer_id, |
3980 inner_viewport_scroll_layer_id, | 3983 inner_viewport_scroll_layer_id, |
3981 outer_viewport_scroll_layer_id); | 3984 outer_viewport_scroll_layer_id); |
3982 tree_impl->BuildLayerListAndPropertyTreesForTesting(); | 3985 tree_impl->BuildLayerListAndPropertyTreesForTesting(); |
3983 | 3986 |
3984 host_impl_->SetViewportSize(inner_viewport_size); | 3987 host_impl_->SetViewportSize(inner_viewport_size); |
3985 LayerImpl* root_clip_ptr = tree_impl->root_layer(); | 3988 LayerImpl* root_clip_ptr = tree_impl->root_layer_for_testing(); |
3986 EXPECT_EQ(inner_viewport_size, root_clip_ptr->bounds()); | 3989 EXPECT_EQ(inner_viewport_size, root_clip_ptr->bounds()); |
3987 } | 3990 } |
3988 | 3991 |
3989 protected: | 3992 protected: |
3990 gfx::Size layer_size_; | 3993 gfx::Size layer_size_; |
3991 gfx::Size clip_size_; | 3994 gfx::Size clip_size_; |
3992 gfx::Size viewport_size_; | 3995 gfx::Size viewport_size_; |
3993 float top_controls_height_; | 3996 float top_controls_height_; |
3994 | 3997 |
3995 LayerTreeSettings settings_; | 3998 LayerTreeSettings settings_; |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4435 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(0.f); | 4438 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(0.f); |
4436 | 4439 |
4437 host_impl_->DidChangeTopControlsPosition(); | 4440 host_impl_->DidChangeTopControlsPosition(); |
4438 LayerImpl* inner_clip_ptr = host_impl_->InnerViewportScrollLayer() | 4441 LayerImpl* inner_clip_ptr = host_impl_->InnerViewportScrollLayer() |
4439 ->test_properties() | 4442 ->test_properties() |
4440 ->parent->test_properties() | 4443 ->parent->test_properties() |
4441 ->parent; | 4444 ->parent; |
4442 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); | 4445 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); |
4443 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); | 4446 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); |
4444 | 4447 |
4445 host_impl_->sync_tree()->root_layer()->SetBounds( | 4448 host_impl_->sync_tree()->root_layer_for_testing()->SetBounds( |
4446 gfx::Size(inner_clip_ptr->bounds().width(), | 4449 gfx::Size(inner_clip_ptr->bounds().width(), |
4447 inner_clip_ptr->bounds().height() - 50.f)); | 4450 inner_clip_ptr->bounds().height() - 50.f)); |
4448 | 4451 |
4449 host_impl_->ActivateSyncTree(); | 4452 host_impl_->ActivateSyncTree(); |
4450 | 4453 |
4451 inner_clip_ptr = host_impl_->InnerViewportScrollLayer() | 4454 inner_clip_ptr = host_impl_->InnerViewportScrollLayer() |
4452 ->test_properties() | 4455 ->test_properties() |
4453 ->parent->test_properties() | 4456 ->parent->test_properties() |
4454 ->parent; | 4457 ->parent; |
4455 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); | 4458 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4803 | 4806 |
4804 std::unique_ptr<LayerImpl> scroll_layer = | 4807 std::unique_ptr<LayerImpl> scroll_layer = |
4805 LayerImpl::Create(host_impl_->active_tree(), 2); | 4808 LayerImpl::Create(host_impl_->active_tree(), 2); |
4806 scroll_layer->SetScrollClipLayer(3); | 4809 scroll_layer->SetScrollClipLayer(3); |
4807 scroll_layer->SetBounds(contents_size); | 4810 scroll_layer->SetBounds(contents_size); |
4808 scroll_layer->SetPosition(gfx::PointF()); | 4811 scroll_layer->SetPosition(gfx::PointF()); |
4809 scroll_layer->test_properties()->AddChild(std::move(content_layer)); | 4812 scroll_layer->test_properties()->AddChild(std::move(content_layer)); |
4810 scroll_clip_layer->test_properties()->AddChild(std::move(scroll_layer)); | 4813 scroll_clip_layer->test_properties()->AddChild(std::move(scroll_layer)); |
4811 | 4814 |
4812 scroll_clip_layer->test_properties()->force_render_surface = true; | 4815 scroll_clip_layer->test_properties()->force_render_surface = true; |
4813 host_impl_->active_tree()->SetRootLayer(std::move(scroll_clip_layer)); | 4816 host_impl_->active_tree()->SetRootLayerForTesting( |
| 4817 std::move(scroll_clip_layer)); |
4814 host_impl_->SetViewportSize(surface_size); | 4818 host_impl_->SetViewportSize(surface_size); |
4815 SetNeedsRebuildPropertyTrees(); | 4819 SetNeedsRebuildPropertyTrees(); |
4816 DrawFrame(); | 4820 DrawFrame(); |
4817 | 4821 |
4818 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4822 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
4819 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 4823 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
4820 InputHandler::WHEEL) | 4824 InputHandler::WHEEL) |
4821 .thread); | 4825 .thread); |
4822 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); | 4826 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
4823 host_impl_->ScrollEnd(EndState().get()); | 4827 host_impl_->ScrollEnd(EndState().get()); |
4824 EXPECT_TRUE(did_request_redraw_); | 4828 EXPECT_TRUE(did_request_redraw_); |
4825 EXPECT_TRUE(did_request_commit_); | 4829 EXPECT_TRUE(did_request_commit_); |
4826 } | 4830 } |
4827 | 4831 |
4828 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { | 4832 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { |
4829 gfx::Size surface_size(10, 10); | 4833 gfx::Size surface_size(10, 10); |
4830 gfx::Size contents_size(20, 20); | 4834 gfx::Size contents_size(20, 20); |
4831 std::unique_ptr<LayerImpl> root = | 4835 std::unique_ptr<LayerImpl> root = |
4832 LayerImpl::Create(host_impl_->active_tree(), 1); | 4836 LayerImpl::Create(host_impl_->active_tree(), 1); |
4833 root->SetBounds(surface_size); | 4837 root->SetBounds(surface_size); |
4834 root->test_properties()->AddChild( | 4838 root->test_properties()->AddChild( |
4835 CreateScrollableLayer(2, contents_size, root.get())); | 4839 CreateScrollableLayer(2, contents_size, root.get())); |
4836 root->test_properties()->force_render_surface = true; | 4840 root->test_properties()->force_render_surface = true; |
4837 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 4841 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
4838 host_impl_->SetViewportSize(surface_size); | 4842 host_impl_->SetViewportSize(surface_size); |
4839 SetNeedsRebuildPropertyTrees(); | 4843 SetNeedsRebuildPropertyTrees(); |
4840 DrawFrame(); | 4844 DrawFrame(); |
4841 | 4845 |
4842 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4846 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
4843 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 4847 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
4844 InputHandler::WHEEL) | 4848 InputHandler::WHEEL) |
4845 .thread); | 4849 .thread); |
4846 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); | 4850 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
4847 host_impl_->ScrollEnd(EndState().get()); | 4851 host_impl_->ScrollEnd(EndState().get()); |
4848 EXPECT_TRUE(did_request_redraw_); | 4852 EXPECT_TRUE(did_request_redraw_); |
4849 EXPECT_TRUE(did_request_commit_); | 4853 EXPECT_TRUE(did_request_commit_); |
4850 } | 4854 } |
4851 | 4855 |
4852 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { | 4856 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { |
4853 gfx::Size surface_size(10, 10); | 4857 gfx::Size surface_size(10, 10); |
4854 std::unique_ptr<LayerImpl> root = | 4858 std::unique_ptr<LayerImpl> root = |
4855 LayerImpl::Create(host_impl_->active_tree(), 1); | 4859 LayerImpl::Create(host_impl_->active_tree(), 1); |
4856 root->test_properties()->AddChild( | 4860 root->test_properties()->AddChild( |
4857 CreateScrollableLayer(2, surface_size, root.get())); | 4861 CreateScrollableLayer(2, surface_size, root.get())); |
4858 root->test_properties()->force_render_surface = true; | 4862 root->test_properties()->force_render_surface = true; |
4859 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 4863 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
4860 host_impl_->SetViewportSize(surface_size); | 4864 host_impl_->SetViewportSize(surface_size); |
4861 SetNeedsRebuildPropertyTrees(); | 4865 SetNeedsRebuildPropertyTrees(); |
4862 DrawFrame(); | 4866 DrawFrame(); |
4863 | 4867 |
4864 // Scroll event is ignored because the input coordinate is outside the layer | 4868 // Scroll event is ignored because the input coordinate is outside the layer |
4865 // boundaries. | 4869 // boundaries. |
4866 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 4870 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
4867 BeginState(gfx::Point(15, 5)).get(), InputHandler::WHEEL); | 4871 BeginState(gfx::Point(15, 5)).get(), InputHandler::WHEEL); |
4868 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); | 4872 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); |
4869 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, | 4873 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, |
(...skipping 11 matching lines...) Expand all Loading... |
4881 std::unique_ptr<LayerImpl> child = | 4885 std::unique_ptr<LayerImpl> child = |
4882 CreateScrollableLayer(2, surface_size, root.get()); | 4886 CreateScrollableLayer(2, surface_size, root.get()); |
4883 host_impl_->SetViewportSize(surface_size); | 4887 host_impl_->SetViewportSize(surface_size); |
4884 | 4888 |
4885 gfx::Transform matrix; | 4889 gfx::Transform matrix; |
4886 matrix.RotateAboutXAxis(180.0); | 4890 matrix.RotateAboutXAxis(180.0); |
4887 child->SetTransform(matrix); | 4891 child->SetTransform(matrix); |
4888 child->test_properties()->double_sided = false; | 4892 child->test_properties()->double_sided = false; |
4889 | 4893 |
4890 root->test_properties()->AddChild(std::move(child)); | 4894 root->test_properties()->AddChild(std::move(child)); |
4891 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 4895 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
4892 SetNeedsRebuildPropertyTrees(); | 4896 SetNeedsRebuildPropertyTrees(); |
4893 DrawFrame(); | 4897 DrawFrame(); |
4894 | 4898 |
4895 // Scroll event is ignored because the scrollable layer is not facing the | 4899 // Scroll event is ignored because the scrollable layer is not facing the |
4896 // viewer and there is nothing scrollable behind it. | 4900 // viewer and there is nothing scrollable behind it. |
4897 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 4901 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
4898 BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL); | 4902 BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL); |
4899 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); | 4903 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); |
4900 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, | 4904 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, |
4901 status.main_thread_scrolling_reasons); | 4905 status.main_thread_scrolling_reasons); |
(...skipping 13 matching lines...) Expand all Loading... |
4915 content_layer->SetScrollClipLayer(Layer::INVALID_ID); | 4919 content_layer->SetScrollClipLayer(Layer::INVALID_ID); |
4916 | 4920 |
4917 // Note: we can use the same clip layer for both since both calls to | 4921 // Note: we can use the same clip layer for both since both calls to |
4918 // CreateScrollableLayer() use the same surface size. | 4922 // CreateScrollableLayer() use the same surface size. |
4919 std::unique_ptr<LayerImpl> scroll_layer = | 4923 std::unique_ptr<LayerImpl> scroll_layer = |
4920 CreateScrollableLayer(2, surface_size, clip_layer.get()); | 4924 CreateScrollableLayer(2, surface_size, clip_layer.get()); |
4921 scroll_layer->test_properties()->AddChild(std::move(content_layer)); | 4925 scroll_layer->test_properties()->AddChild(std::move(content_layer)); |
4922 clip_layer->test_properties()->AddChild(std::move(scroll_layer)); | 4926 clip_layer->test_properties()->AddChild(std::move(scroll_layer)); |
4923 clip_layer->test_properties()->force_render_surface = true; | 4927 clip_layer->test_properties()->force_render_surface = true; |
4924 | 4928 |
4925 host_impl_->active_tree()->SetRootLayer(std::move(clip_layer)); | 4929 host_impl_->active_tree()->SetRootLayerForTesting(std::move(clip_layer)); |
4926 host_impl_->SetViewportSize(surface_size); | 4930 host_impl_->SetViewportSize(surface_size); |
4927 SetNeedsRebuildPropertyTrees(); | 4931 SetNeedsRebuildPropertyTrees(); |
4928 DrawFrame(); | 4932 DrawFrame(); |
4929 | 4933 |
4930 // Scrolling fails because the content layer is asking to be scrolled on the | 4934 // Scrolling fails because the content layer is asking to be scrolled on the |
4931 // main thread. | 4935 // main thread. |
4932 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 4936 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
4933 BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL); | 4937 BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL); |
4934 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); | 4938 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); |
4935 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, | 4939 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5045 gfx::Transform default_page_scale_matrix; | 5049 gfx::Transform default_page_scale_matrix; |
5046 default_page_scale_matrix.Scale(default_page_scale, default_page_scale); | 5050 default_page_scale_matrix.Scale(default_page_scale, default_page_scale); |
5047 | 5051 |
5048 float new_page_scale = 2.f; | 5052 float new_page_scale = 2.f; |
5049 gfx::Transform new_page_scale_matrix; | 5053 gfx::Transform new_page_scale_matrix; |
5050 new_page_scale_matrix.Scale(new_page_scale, new_page_scale); | 5054 new_page_scale_matrix.Scale(new_page_scale, new_page_scale); |
5051 | 5055 |
5052 // Create a normal scrollable root layer and another scrollable child layer. | 5056 // Create a normal scrollable root layer and another scrollable child layer. |
5053 LayerImpl* scroll = SetupScrollAndContentsLayers(surface_size); | 5057 LayerImpl* scroll = SetupScrollAndContentsLayers(surface_size); |
5054 scroll->SetDrawsContent(true); | 5058 scroll->SetDrawsContent(true); |
5055 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 5059 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); |
5056 LayerImpl* child = scroll->test_properties()->children[0]; | 5060 LayerImpl* child = scroll->test_properties()->children[0]; |
5057 child->SetDrawsContent(true); | 5061 child->SetDrawsContent(true); |
5058 | 5062 |
5059 std::unique_ptr<LayerImpl> scrollable_child_clip = | 5063 std::unique_ptr<LayerImpl> scrollable_child_clip = |
5060 LayerImpl::Create(host_impl_->active_tree(), 6); | 5064 LayerImpl::Create(host_impl_->active_tree(), 6); |
5061 std::unique_ptr<LayerImpl> scrollable_child = | 5065 std::unique_ptr<LayerImpl> scrollable_child = |
5062 CreateScrollableLayer(7, surface_size, scrollable_child_clip.get()); | 5066 CreateScrollableLayer(7, surface_size, scrollable_child_clip.get()); |
5063 scrollable_child_clip->test_properties()->AddChild( | 5067 scrollable_child_clip->test_properties()->AddChild( |
5064 std::move(scrollable_child)); | 5068 std::move(scrollable_child)); |
5065 child->test_properties()->AddChild(std::move(scrollable_child_clip)); | 5069 child->test_properties()->AddChild(std::move(scrollable_child_clip)); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5148 std::unique_ptr<LayerImpl> grand_child = | 5152 std::unique_ptr<LayerImpl> grand_child = |
5149 CreateScrollableLayer(3, content_size, root.get()); | 5153 CreateScrollableLayer(3, content_size, root.get()); |
5150 | 5154 |
5151 std::unique_ptr<LayerImpl> child = | 5155 std::unique_ptr<LayerImpl> child = |
5152 CreateScrollableLayer(2, content_size, root.get()); | 5156 CreateScrollableLayer(2, content_size, root.get()); |
5153 LayerImpl* grand_child_layer = grand_child.get(); | 5157 LayerImpl* grand_child_layer = grand_child.get(); |
5154 child->test_properties()->AddChild(std::move(grand_child)); | 5158 child->test_properties()->AddChild(std::move(grand_child)); |
5155 | 5159 |
5156 LayerImpl* child_layer = child.get(); | 5160 LayerImpl* child_layer = child.get(); |
5157 root->test_properties()->AddChild(std::move(child)); | 5161 root->test_properties()->AddChild(std::move(child)); |
5158 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 5162 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
5159 host_impl_->active_tree()->DidBecomeActive(); | 5163 host_impl_->active_tree()->DidBecomeActive(); |
5160 host_impl_->SetViewportSize(surface_size); | 5164 host_impl_->SetViewportSize(surface_size); |
5161 grand_child_layer->layer_tree_impl() | 5165 grand_child_layer->layer_tree_impl() |
5162 ->property_trees() | 5166 ->property_trees() |
5163 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(), | 5167 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(), |
5164 gfx::ScrollOffset(0, 5)); | 5168 gfx::ScrollOffset(0, 5)); |
5165 child_layer->layer_tree_impl() | 5169 child_layer->layer_tree_impl() |
5166 ->property_trees() | 5170 ->property_trees() |
5167 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(), | 5171 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(), |
5168 gfx::ScrollOffset(3, 0)); | 5172 gfx::ScrollOffset(3, 0)); |
5169 | 5173 |
5170 SetNeedsRebuildPropertyTrees(); | 5174 SetNeedsRebuildPropertyTrees(); |
5171 DrawFrame(); | 5175 DrawFrame(); |
5172 { | 5176 { |
5173 gfx::Vector2d scroll_delta(-8, -7); | 5177 gfx::Vector2d scroll_delta(-8, -7); |
5174 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5178 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
5175 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 5179 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
5176 InputHandler::WHEEL) | 5180 InputHandler::WHEEL) |
5177 .thread); | 5181 .thread); |
5178 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5182 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
5179 host_impl_->ScrollEnd(EndState().get()); | 5183 host_impl_->ScrollEnd(EndState().get()); |
5180 | 5184 |
5181 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 5185 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
5182 host_impl_->ProcessScrollDeltas(); | 5186 host_impl_->ProcessScrollDeltas(); |
5183 | 5187 |
5184 // The grand child should have scrolled up to its limit. | 5188 // The grand child should have scrolled up to its limit. |
5185 LayerImpl* child = | 5189 LayerImpl* child = host_impl_->active_tree() |
5186 host_impl_->active_tree()->root_layer()->test_properties()->children[0]; | 5190 ->root_layer_for_testing() |
| 5191 ->test_properties() |
| 5192 ->children[0]; |
5187 LayerImpl* grand_child = child->test_properties()->children[0]; | 5193 LayerImpl* grand_child = child->test_properties()->children[0]; |
5188 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), | 5194 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), |
5189 gfx::Vector2d(0, -5))); | 5195 gfx::Vector2d(0, -5))); |
5190 | 5196 |
5191 // The child should not have scrolled. | 5197 // The child should not have scrolled. |
5192 ExpectNone(*scroll_info.get(), child->id()); | 5198 ExpectNone(*scroll_info.get(), child->id()); |
5193 } | 5199 } |
5194 } | 5200 } |
5195 | 5201 |
5196 TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) { | 5202 TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) { |
(...skipping 17 matching lines...) Expand all Loading... |
5214 std::unique_ptr<LayerImpl> child = | 5220 std::unique_ptr<LayerImpl> child = |
5215 CreateScrollableLayer(4, surface_size, root_clip.get()); | 5221 CreateScrollableLayer(4, surface_size, root_clip.get()); |
5216 LayerImpl* grand_child_layer = grand_child.get(); | 5222 LayerImpl* grand_child_layer = grand_child.get(); |
5217 child->test_properties()->AddChild(std::move(grand_child)); | 5223 child->test_properties()->AddChild(std::move(grand_child)); |
5218 | 5224 |
5219 LayerImpl* child_layer = child.get(); | 5225 LayerImpl* child_layer = child.get(); |
5220 root_scrolling->test_properties()->AddChild(std::move(child)); | 5226 root_scrolling->test_properties()->AddChild(std::move(child)); |
5221 root_clip->test_properties()->AddChild(std::move(root_scrolling)); | 5227 root_clip->test_properties()->AddChild(std::move(root_scrolling)); |
5222 EXPECT_EQ(viewport_size, root_clip->bounds()); | 5228 EXPECT_EQ(viewport_size, root_clip->bounds()); |
5223 root_ptr->test_properties()->AddChild(std::move(root_clip)); | 5229 root_ptr->test_properties()->AddChild(std::move(root_clip)); |
5224 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr)); | 5230 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr)); |
5225 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, | 5231 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, |
5226 Layer::INVALID_ID); | 5232 Layer::INVALID_ID); |
5227 host_impl_->active_tree()->DidBecomeActive(); | 5233 host_impl_->active_tree()->DidBecomeActive(); |
5228 host_impl_->SetViewportSize(viewport_size); | 5234 host_impl_->SetViewportSize(viewport_size); |
5229 | 5235 |
5230 grand_child_layer->layer_tree_impl() | 5236 grand_child_layer->layer_tree_impl() |
5231 ->property_trees() | 5237 ->property_trees() |
5232 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(), | 5238 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(), |
5233 gfx::ScrollOffset(0, 2)); | 5239 gfx::ScrollOffset(0, 2)); |
5234 child_layer->layer_tree_impl() | 5240 child_layer->layer_tree_impl() |
(...skipping 10 matching lines...) Expand all Loading... |
5245 InputHandler::NON_BUBBLING_GESTURE) | 5251 InputHandler::NON_BUBBLING_GESTURE) |
5246 .thread); | 5252 .thread); |
5247 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5253 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
5248 host_impl_->ScrollEnd(EndState().get()); | 5254 host_impl_->ScrollEnd(EndState().get()); |
5249 | 5255 |
5250 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 5256 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
5251 host_impl_->ProcessScrollDeltas(); | 5257 host_impl_->ProcessScrollDeltas(); |
5252 | 5258 |
5253 // The grand child should have scrolled up to its limit. | 5259 // The grand child should have scrolled up to its limit. |
5254 LayerImpl* child = host_impl_->active_tree() | 5260 LayerImpl* child = host_impl_->active_tree() |
5255 ->root_layer() | 5261 ->root_layer_for_testing() |
5256 ->test_properties() | 5262 ->test_properties() |
5257 ->children[0] | 5263 ->children[0] |
5258 ->test_properties() | 5264 ->test_properties() |
5259 ->children[0] | 5265 ->children[0] |
5260 ->test_properties() | 5266 ->test_properties() |
5261 ->children[0]; | 5267 ->children[0]; |
5262 LayerImpl* grand_child = child->test_properties()->children[0]; | 5268 LayerImpl* grand_child = child->test_properties()->children[0]; |
5263 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), | 5269 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), |
5264 gfx::Vector2d(0, -2))); | 5270 gfx::Vector2d(0, -2))); |
5265 | 5271 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5347 CreateScrollableLayer(2, content_size, root_scroll.get()); | 5353 CreateScrollableLayer(2, content_size, root_scroll.get()); |
5348 child->test_properties()->is_container_for_fixed_position_layers = true; | 5354 child->test_properties()->is_container_for_fixed_position_layers = true; |
5349 root_scroll->SetBounds(content_size); | 5355 root_scroll->SetBounds(content_size); |
5350 | 5356 |
5351 int root_scroll_id = root_scroll->id(); | 5357 int root_scroll_id = root_scroll->id(); |
5352 root_scroll->test_properties()->AddChild(std::move(child)); | 5358 root_scroll->test_properties()->AddChild(std::move(child)); |
5353 root_clip->test_properties()->AddChild(std::move(root_scroll)); | 5359 root_clip->test_properties()->AddChild(std::move(root_scroll)); |
5354 root_ptr->test_properties()->AddChild(std::move(root_clip)); | 5360 root_ptr->test_properties()->AddChild(std::move(root_clip)); |
5355 | 5361 |
5356 host_impl_->SetViewportSize(surface_size); | 5362 host_impl_->SetViewportSize(surface_size); |
5357 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr)); | 5363 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr)); |
5358 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 2, | 5364 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 2, |
5359 Layer::INVALID_ID); | 5365 Layer::INVALID_ID); |
5360 host_impl_->active_tree()->DidBecomeActive(); | 5366 host_impl_->active_tree()->DidBecomeActive(); |
5361 SetNeedsRebuildPropertyTrees(); | 5367 SetNeedsRebuildPropertyTrees(); |
5362 DrawFrame(); | 5368 DrawFrame(); |
5363 { | 5369 { |
5364 gfx::Vector2d scroll_delta(0, 4); | 5370 gfx::Vector2d scroll_delta(0, 4); |
5365 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5371 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
5366 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 5372 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
5367 InputHandler::WHEEL) | 5373 InputHandler::WHEEL) |
(...skipping 16 matching lines...) Expand all Loading... |
5384 std::unique_ptr<LayerImpl> root_ptr = | 5390 std::unique_ptr<LayerImpl> root_ptr = |
5385 LayerImpl::Create(host_impl_->active_tree(), 1); | 5391 LayerImpl::Create(host_impl_->active_tree(), 1); |
5386 std::unique_ptr<LayerImpl> root_clip = | 5392 std::unique_ptr<LayerImpl> root_clip = |
5387 LayerImpl::Create(host_impl_->active_tree(), 2); | 5393 LayerImpl::Create(host_impl_->active_tree(), 2); |
5388 std::unique_ptr<LayerImpl> root_scroll = | 5394 std::unique_ptr<LayerImpl> root_scroll = |
5389 CreateScrollableLayer(3, surface_size, root_clip.get()); | 5395 CreateScrollableLayer(3, surface_size, root_clip.get()); |
5390 root_clip->test_properties()->force_render_surface = true; | 5396 root_clip->test_properties()->force_render_surface = true; |
5391 root_scroll->test_properties()->is_container_for_fixed_position_layers = true; | 5397 root_scroll->test_properties()->is_container_for_fixed_position_layers = true; |
5392 root_clip->test_properties()->AddChild(std::move(root_scroll)); | 5398 root_clip->test_properties()->AddChild(std::move(root_scroll)); |
5393 root_ptr->test_properties()->AddChild(std::move(root_clip)); | 5399 root_ptr->test_properties()->AddChild(std::move(root_clip)); |
5394 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr)); | 5400 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr)); |
5395 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, | 5401 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 3, |
5396 Layer::INVALID_ID); | 5402 Layer::INVALID_ID); |
5397 host_impl_->active_tree()->DidBecomeActive(); | 5403 host_impl_->active_tree()->DidBecomeActive(); |
5398 host_impl_->SetViewportSize(surface_size); | 5404 host_impl_->SetViewportSize(surface_size); |
5399 | 5405 |
5400 // Draw one frame and then immediately rebuild the layer tree to mimic a tree | 5406 // Draw one frame and then immediately rebuild the layer tree to mimic a tree |
5401 // synchronization. | 5407 // synchronization. |
5402 SetNeedsRebuildPropertyTrees(); | 5408 SetNeedsRebuildPropertyTrees(); |
5403 DrawFrame(); | 5409 DrawFrame(); |
5404 host_impl_->active_tree()->DetachLayers(); | 5410 host_impl_->active_tree()->DetachLayers(); |
5405 std::unique_ptr<LayerImpl> root_ptr2 = | 5411 std::unique_ptr<LayerImpl> root_ptr2 = |
5406 LayerImpl::Create(host_impl_->active_tree(), 4); | 5412 LayerImpl::Create(host_impl_->active_tree(), 4); |
5407 std::unique_ptr<LayerImpl> root_clip2 = | 5413 std::unique_ptr<LayerImpl> root_clip2 = |
5408 LayerImpl::Create(host_impl_->active_tree(), 5); | 5414 LayerImpl::Create(host_impl_->active_tree(), 5); |
5409 std::unique_ptr<LayerImpl> root_scroll2 = | 5415 std::unique_ptr<LayerImpl> root_scroll2 = |
5410 CreateScrollableLayer(6, surface_size, root_clip2.get()); | 5416 CreateScrollableLayer(6, surface_size, root_clip2.get()); |
5411 root_scroll2->test_properties()->is_container_for_fixed_position_layers = | 5417 root_scroll2->test_properties()->is_container_for_fixed_position_layers = |
5412 true; | 5418 true; |
5413 root_clip2->test_properties()->AddChild(std::move(root_scroll2)); | 5419 root_clip2->test_properties()->AddChild(std::move(root_scroll2)); |
5414 root_clip2->test_properties()->force_render_surface = true; | 5420 root_clip2->test_properties()->force_render_surface = true; |
5415 root_ptr2->test_properties()->AddChild(std::move(root_clip2)); | 5421 root_ptr2->test_properties()->AddChild(std::move(root_clip2)); |
5416 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr2)); | 5422 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr2)); |
5417 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 6, | 5423 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 6, |
5418 Layer::INVALID_ID); | 5424 Layer::INVALID_ID); |
5419 host_impl_->active_tree()->DidBecomeActive(); | 5425 host_impl_->active_tree()->DidBecomeActive(); |
5420 | 5426 |
5421 // Scrolling should still work even though we did not draw yet. | 5427 // Scrolling should still work even though we did not draw yet. |
5422 SetNeedsRebuildPropertyTrees(); | 5428 SetNeedsRebuildPropertyTrees(); |
5423 RebuildPropertyTrees(); | 5429 RebuildPropertyTrees(); |
5424 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5430 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
5425 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 5431 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
5426 InputHandler::WHEEL) | 5432 InputHandler::WHEEL) |
5427 .thread); | 5433 .thread); |
5428 } | 5434 } |
5429 | 5435 |
5430 TEST_F(LayerTreeHostImplTest, ScrollAxisAlignedRotatedLayer) { | 5436 TEST_F(LayerTreeHostImplTest, ScrollAxisAlignedRotatedLayer) { |
5431 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 5437 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
5432 scroll_layer->SetDrawsContent(true); | 5438 scroll_layer->SetDrawsContent(true); |
5433 | 5439 |
5434 // Rotate the root layer 90 degrees counter-clockwise about its center. | 5440 // Rotate the root layer 90 degrees counter-clockwise about its center. |
5435 gfx::Transform rotate_transform; | 5441 gfx::Transform rotate_transform; |
5436 rotate_transform.Rotate(-90.0); | 5442 rotate_transform.Rotate(-90.0); |
5437 host_impl_->active_tree()->root_layer()->SetTransform(rotate_transform); | 5443 host_impl_->active_tree()->root_layer_for_testing()->SetTransform( |
| 5444 rotate_transform); |
5438 | 5445 |
5439 gfx::Size surface_size(50, 50); | 5446 gfx::Size surface_size(50, 50); |
5440 host_impl_->SetViewportSize(surface_size); | 5447 host_impl_->SetViewportSize(surface_size); |
5441 SetNeedsRebuildPropertyTrees(); | 5448 SetNeedsRebuildPropertyTrees(); |
5442 DrawFrame(); | 5449 DrawFrame(); |
5443 | 5450 |
5444 // Scroll to the right in screen coordinates with a gesture. | 5451 // Scroll to the right in screen coordinates with a gesture. |
5445 gfx::Vector2d gesture_scroll_delta(10, 0); | 5452 gfx::Vector2d gesture_scroll_delta(10, 0); |
5446 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5453 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
5447 host_impl_ | 5454 host_impl_ |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6057 root->test_properties()->AddChild(std::move(child)); | 6064 root->test_properties()->AddChild(std::move(child)); |
6058 root_clip->test_properties()->AddChild(std::move(root)); | 6065 root_clip->test_properties()->AddChild(std::move(root)); |
6059 child_layer->layer_tree_impl() | 6066 child_layer->layer_tree_impl() |
6060 ->property_trees() | 6067 ->property_trees() |
6061 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(), | 6068 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(), |
6062 gfx::ScrollOffset(0, 3)); | 6069 gfx::ScrollOffset(0, 3)); |
6063 grand_child_layer->layer_tree_impl() | 6070 grand_child_layer->layer_tree_impl() |
6064 ->property_trees() | 6071 ->property_trees() |
6065 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(), | 6072 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(), |
6066 gfx::ScrollOffset(0, 2)); | 6073 gfx::ScrollOffset(0, 2)); |
6067 host_impl_->active_tree()->SetRootLayer(std::move(root_clip)); | 6074 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_clip)); |
6068 host_impl_->active_tree()->DidBecomeActive(); | 6075 host_impl_->active_tree()->DidBecomeActive(); |
6069 host_impl_->SetViewportSize(surface_size); | 6076 host_impl_->SetViewportSize(surface_size); |
6070 SetNeedsRebuildPropertyTrees(); | 6077 SetNeedsRebuildPropertyTrees(); |
6071 DrawFrame(); | 6078 DrawFrame(); |
6072 { | 6079 { |
6073 gfx::Vector2d scroll_delta(0, -10); | 6080 gfx::Vector2d scroll_delta(0, -10); |
6074 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 6081 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
6075 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 6082 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
6076 InputHandler::NON_BUBBLING_GESTURE) | 6083 InputHandler::NON_BUBBLING_GESTURE) |
6077 .thread); | 6084 .thread); |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6324 ResourceId resource_id_; | 6331 ResourceId resource_id_; |
6325 }; | 6332 }; |
6326 | 6333 |
6327 TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { | 6334 TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { |
6328 { | 6335 { |
6329 std::unique_ptr<LayerImpl> root = | 6336 std::unique_ptr<LayerImpl> root = |
6330 LayerImpl::Create(host_impl_->active_tree(), 1); | 6337 LayerImpl::Create(host_impl_->active_tree(), 1); |
6331 root->SetBounds(gfx::Size(10, 10)); | 6338 root->SetBounds(gfx::Size(10, 10)); |
6332 root->SetDrawsContent(false); | 6339 root->SetDrawsContent(false); |
6333 root->test_properties()->force_render_surface = true; | 6340 root->test_properties()->force_render_surface = true; |
6334 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 6341 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
6335 } | 6342 } |
6336 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 6343 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); |
6337 | 6344 |
6338 root->test_properties()->AddChild(BlendStateCheckLayer::Create( | 6345 root->test_properties()->AddChild(BlendStateCheckLayer::Create( |
6339 host_impl_->active_tree(), 2, host_impl_->resource_provider())); | 6346 host_impl_->active_tree(), 2, host_impl_->resource_provider())); |
6340 BlendStateCheckLayer* layer1 = | 6347 BlendStateCheckLayer* layer1 = |
6341 static_cast<BlendStateCheckLayer*>(root->test_properties()->children[0]); | 6348 static_cast<BlendStateCheckLayer*>(root->test_properties()->children[0]); |
6342 layer1->SetPosition(gfx::PointF(2.f, 2.f)); | 6349 layer1->SetPosition(gfx::PointF(2.f, 2.f)); |
6343 | 6350 |
6344 LayerTreeHostImpl::FrameData frame; | 6351 LayerTreeHostImpl::FrameData frame; |
6345 | 6352 |
6346 // Opaque layer, drawn without blending. | 6353 // Opaque layer, drawn without blending. |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6447 // carries the inherited opacity). | 6454 // carries the inherited opacity). |
6448 layer1->SetContentsOpaque(true); | 6455 layer1->SetContentsOpaque(true); |
6449 layer1->test_properties()->opacity = 0.5f; | 6456 layer1->test_properties()->opacity = 0.5f; |
6450 layer1->NoteLayerPropertyChanged(); | 6457 layer1->NoteLayerPropertyChanged(); |
6451 layer1->test_properties()->force_render_surface = true; | 6458 layer1->test_properties()->force_render_surface = true; |
6452 layer1->SetExpectation(false, true); | 6459 layer1->SetExpectation(false, true); |
6453 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6460 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6454 layer2->SetExpectation(false, false); | 6461 layer2->SetExpectation(false, false); |
6455 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6462 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6456 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( | 6463 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( |
6457 host_impl_->active_tree()->root_layer()); | 6464 host_impl_->active_tree()->root_layer_for_testing()); |
6458 SetNeedsRebuildPropertyTrees(); | 6465 SetNeedsRebuildPropertyTrees(); |
6459 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6466 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
6460 host_impl_->DrawLayers(&frame); | 6467 host_impl_->DrawLayers(&frame); |
6461 EXPECT_TRUE(layer1->quads_appended()); | 6468 EXPECT_TRUE(layer1->quads_appended()); |
6462 EXPECT_TRUE(layer2->quads_appended()); | 6469 EXPECT_TRUE(layer2->quads_appended()); |
6463 host_impl_->DidDrawAllLayers(frame); | 6470 host_impl_->DidDrawAllLayers(frame); |
6464 layer1->test_properties()->force_render_surface = false; | 6471 layer1->test_properties()->force_render_surface = false; |
6465 | 6472 |
6466 // Draw again, but with child non-opaque, to make sure | 6473 // Draw again, but with child non-opaque, to make sure |
6467 // layer1 not culled. | 6474 // layer1 not culled. |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6583 std::unique_ptr<OutputSurface> CreateFakeOutputSurface(bool software) { | 6590 std::unique_ptr<OutputSurface> CreateFakeOutputSurface(bool software) { |
6584 if (software) { | 6591 if (software) { |
6585 return FakeOutputSurface::CreateSoftware( | 6592 return FakeOutputSurface::CreateSoftware( |
6586 base::WrapUnique(new SoftwareOutputDevice())); | 6593 base::WrapUnique(new SoftwareOutputDevice())); |
6587 } | 6594 } |
6588 return FakeOutputSurface::Create3d(); | 6595 return FakeOutputSurface::Create3d(); |
6589 } | 6596 } |
6590 | 6597 |
6591 void SetupActiveTreeLayers() { | 6598 void SetupActiveTreeLayers() { |
6592 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); | 6599 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); |
6593 host_impl_->active_tree()->SetRootLayer( | 6600 host_impl_->active_tree()->SetRootLayerForTesting( |
6594 LayerImpl::Create(host_impl_->active_tree(), 1)); | 6601 LayerImpl::Create(host_impl_->active_tree(), 1)); |
6595 host_impl_->active_tree() | 6602 host_impl_->active_tree() |
6596 ->root_layer() | 6603 ->root_layer_for_testing() |
6597 ->test_properties() | 6604 ->test_properties() |
6598 ->force_render_surface = true; | 6605 ->force_render_surface = true; |
6599 host_impl_->active_tree()->root_layer()->test_properties()->AddChild( | 6606 host_impl_->active_tree() |
6600 BlendStateCheckLayer::Create(host_impl_->active_tree(), 2, | 6607 ->root_layer_for_testing() |
6601 host_impl_->resource_provider())); | 6608 ->test_properties() |
| 6609 ->AddChild(BlendStateCheckLayer::Create( |
| 6610 host_impl_->active_tree(), 2, host_impl_->resource_provider())); |
6602 child_ = static_cast<BlendStateCheckLayer*>(host_impl_->active_tree() | 6611 child_ = static_cast<BlendStateCheckLayer*>(host_impl_->active_tree() |
6603 ->root_layer() | 6612 ->root_layer_for_testing() |
6604 ->test_properties() | 6613 ->test_properties() |
6605 ->children[0]); | 6614 ->children[0]); |
6606 child_->SetExpectation(false, false); | 6615 child_->SetExpectation(false, false); |
6607 child_->SetContentsOpaque(true); | 6616 child_->SetContentsOpaque(true); |
6608 } | 6617 } |
6609 | 6618 |
6610 // Expect no gutter rects. | 6619 // Expect no gutter rects. |
6611 void TestLayerCoversFullViewport() { | 6620 void TestLayerCoversFullViewport() { |
6612 gfx::Rect layer_rect(viewport_size_); | 6621 gfx::Rect layer_rect(viewport_size_); |
6613 child_->SetPosition(gfx::PointF(layer_rect.origin())); | 6622 child_->SetPosition(gfx::PointF(layer_rect.origin())); |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6893 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); | 6902 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); |
6894 std::unique_ptr<OutputSurface> output_surface( | 6903 std::unique_ptr<OutputSurface> output_surface( |
6895 FakeOutputSurface::Create3d(provider)); | 6904 FakeOutputSurface::Create3d(provider)); |
6896 CreateHostImpl(DefaultSettings(), std::move(output_surface)); | 6905 CreateHostImpl(DefaultSettings(), std::move(output_surface)); |
6897 | 6906 |
6898 std::unique_ptr<LayerImpl> root = | 6907 std::unique_ptr<LayerImpl> root = |
6899 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); | 6908 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); |
6900 root->SetBounds(gfx::Size(10, 10)); | 6909 root->SetBounds(gfx::Size(10, 10)); |
6901 root->SetDrawsContent(true); | 6910 root->SetDrawsContent(true); |
6902 root->test_properties()->force_render_surface = true; | 6911 root->test_properties()->force_render_surface = true; |
6903 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 6912 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
6904 EXPECT_FALSE(provider->TestContext3d()->reshape_called()); | 6913 EXPECT_FALSE(provider->TestContext3d()->reshape_called()); |
6905 provider->TestContext3d()->clear_reshape_called(); | 6914 provider->TestContext3d()->clear_reshape_called(); |
6906 | 6915 |
6907 LayerTreeHostImpl::FrameData frame; | 6916 LayerTreeHostImpl::FrameData frame; |
6908 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 6917 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
6909 host_impl_->active_tree()->SetDeviceScaleFactor(1.f); | 6918 host_impl_->active_tree()->SetDeviceScaleFactor(1.f); |
6910 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6919 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
6911 host_impl_->DrawLayers(&frame); | 6920 host_impl_->DrawLayers(&frame); |
6912 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); | 6921 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); |
6913 EXPECT_EQ(provider->TestContext3d()->width(), 10); | 6922 EXPECT_EQ(provider->TestContext3d()->width(), 10); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6968 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); | 6977 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); |
6969 root->test_properties()->force_render_surface = true; | 6978 root->test_properties()->force_render_surface = true; |
6970 std::unique_ptr<LayerImpl> child = | 6979 std::unique_ptr<LayerImpl> child = |
6971 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); | 6980 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); |
6972 child->SetPosition(gfx::PointF(12.f, 13.f)); | 6981 child->SetPosition(gfx::PointF(12.f, 13.f)); |
6973 child->SetBounds(gfx::Size(14, 15)); | 6982 child->SetBounds(gfx::Size(14, 15)); |
6974 child->SetDrawsContent(true); | 6983 child->SetDrawsContent(true); |
6975 root->SetBounds(gfx::Size(500, 500)); | 6984 root->SetBounds(gfx::Size(500, 500)); |
6976 root->SetDrawsContent(true); | 6985 root->SetDrawsContent(true); |
6977 root->test_properties()->AddChild(std::move(child)); | 6986 root->test_properties()->AddChild(std::move(child)); |
6978 layer_tree_host_impl->active_tree()->SetRootLayer(std::move(root)); | 6987 layer_tree_host_impl->active_tree()->SetRootLayerForTesting(std::move(root)); |
6979 | 6988 |
6980 LayerTreeHostImpl::FrameData frame; | 6989 LayerTreeHostImpl::FrameData frame; |
6981 | 6990 |
6982 // First frame, the entire screen should get swapped. | 6991 // First frame, the entire screen should get swapped. |
6983 layer_tree_host_impl->active_tree() | 6992 layer_tree_host_impl->active_tree() |
6984 ->BuildLayerListAndPropertyTreesForTesting(); | 6993 ->BuildLayerListAndPropertyTreesForTesting(); |
6985 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); | 6994 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); |
6986 layer_tree_host_impl->DrawLayers(&frame); | 6995 layer_tree_host_impl->DrawLayers(&frame); |
6987 layer_tree_host_impl->DidDrawAllLayers(frame); | 6996 layer_tree_host_impl->DidDrawAllLayers(frame); |
6988 layer_tree_host_impl->SwapBuffers(frame); | 6997 layer_tree_host_impl->SwapBuffers(frame); |
6989 gfx::Rect expected_swap_rect(0, 0, 500, 500); | 6998 gfx::Rect expected_swap_rect(0, 0, 500, 500); |
6990 EXPECT_EQ(expected_swap_rect.ToString(), | 6999 EXPECT_EQ(expected_swap_rect.ToString(), |
6991 fake_output_surface->last_swap_rect().ToString()); | 7000 fake_output_surface->last_swap_rect().ToString()); |
6992 | 7001 |
6993 // Second frame, only the damaged area should get swapped. Damage should be | 7002 // Second frame, only the damaged area should get swapped. Damage should be |
6994 // the union of old and new child rects. | 7003 // the union of old and new child rects. |
6995 // expected damage rect: gfx::Rect(26, 28); | 7004 // expected damage rect: gfx::Rect(26, 28); |
6996 // expected swap rect: vertically flipped, with origin at bottom left corner. | 7005 // expected swap rect: vertically flipped, with origin at bottom left corner. |
6997 layer_tree_host_impl->active_tree() | 7006 layer_tree_host_impl->active_tree() |
6998 ->root_layer() | 7007 ->root_layer_for_testing() |
6999 ->test_properties() | 7008 ->test_properties() |
7000 ->children[0] | 7009 ->children[0] |
7001 ->SetPosition(gfx::PointF()); | 7010 ->SetPosition(gfx::PointF()); |
7002 layer_tree_host_impl->active_tree() | 7011 layer_tree_host_impl->active_tree() |
7003 ->root_layer() | 7012 ->root_layer_for_testing() |
7004 ->test_properties() | 7013 ->test_properties() |
7005 ->children[0] | 7014 ->children[0] |
7006 ->NoteLayerPropertyChanged(); | 7015 ->NoteLayerPropertyChanged(); |
7007 layer_tree_host_impl->active_tree()->property_trees()->needs_rebuild = true; | 7016 layer_tree_host_impl->active_tree()->property_trees()->needs_rebuild = true; |
7008 layer_tree_host_impl->active_tree() | 7017 layer_tree_host_impl->active_tree() |
7009 ->BuildLayerListAndPropertyTreesForTesting(); | 7018 ->BuildLayerListAndPropertyTreesForTesting(); |
7010 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); | 7019 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); |
7011 layer_tree_host_impl->DrawLayers(&frame); | 7020 layer_tree_host_impl->DrawLayers(&frame); |
7012 host_impl_->DidDrawAllLayers(frame); | 7021 host_impl_->DidDrawAllLayers(frame); |
7013 layer_tree_host_impl->SwapBuffers(frame); | 7022 layer_tree_host_impl->SwapBuffers(frame); |
7014 | 7023 |
7015 // Make sure that partial swap is constrained to the viewport dimensions | 7024 // Make sure that partial swap is constrained to the viewport dimensions |
7016 // expected damage rect: gfx::Rect(500, 500); | 7025 // expected damage rect: gfx::Rect(500, 500); |
7017 // expected swap rect: flipped damage rect, but also clamped to viewport | 7026 // expected swap rect: flipped damage rect, but also clamped to viewport |
7018 expected_swap_rect = gfx::Rect(0, 500-28, 26, 28); | 7027 expected_swap_rect = gfx::Rect(0, 500-28, 26, 28); |
7019 EXPECT_EQ(expected_swap_rect.ToString(), | 7028 EXPECT_EQ(expected_swap_rect.ToString(), |
7020 fake_output_surface->last_swap_rect().ToString()); | 7029 fake_output_surface->last_swap_rect().ToString()); |
7021 | 7030 |
7022 layer_tree_host_impl->SetViewportSize(gfx::Size(10, 10)); | 7031 layer_tree_host_impl->SetViewportSize(gfx::Size(10, 10)); |
7023 // This will damage everything. | 7032 // This will damage everything. |
7024 layer_tree_host_impl->active_tree()->root_layer()->SetBackgroundColor( | 7033 layer_tree_host_impl->active_tree() |
7025 SK_ColorBLACK); | 7034 ->root_layer_for_testing() |
| 7035 ->SetBackgroundColor(SK_ColorBLACK); |
7026 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); | 7036 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); |
7027 layer_tree_host_impl->DrawLayers(&frame); | 7037 layer_tree_host_impl->DrawLayers(&frame); |
7028 host_impl_->DidDrawAllLayers(frame); | 7038 host_impl_->DidDrawAllLayers(frame); |
7029 layer_tree_host_impl->SwapBuffers(frame); | 7039 layer_tree_host_impl->SwapBuffers(frame); |
7030 | 7040 |
7031 expected_swap_rect = gfx::Rect(0, 0, 10, 10); | 7041 expected_swap_rect = gfx::Rect(0, 0, 10, 10); |
7032 EXPECT_EQ(expected_swap_rect.ToString(), | 7042 EXPECT_EQ(expected_swap_rect.ToString(), |
7033 fake_output_surface->last_swap_rect().ToString()); | 7043 fake_output_surface->last_swap_rect().ToString()); |
7034 } | 7044 } |
7035 | 7045 |
7036 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) { | 7046 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) { |
7037 std::unique_ptr<LayerImpl> root = | 7047 std::unique_ptr<LayerImpl> root = |
7038 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); | 7048 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); |
7039 std::unique_ptr<LayerImpl> child = | 7049 std::unique_ptr<LayerImpl> child = |
7040 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); | 7050 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); |
7041 child->SetBounds(gfx::Size(10, 10)); | 7051 child->SetBounds(gfx::Size(10, 10)); |
7042 child->SetDrawsContent(true); | 7052 child->SetDrawsContent(true); |
7043 root->SetBounds(gfx::Size(10, 10)); | 7053 root->SetBounds(gfx::Size(10, 10)); |
7044 root->SetDrawsContent(true); | 7054 root->SetDrawsContent(true); |
7045 root->test_properties()->force_render_surface = true; | 7055 root->test_properties()->force_render_surface = true; |
7046 root->test_properties()->AddChild(std::move(child)); | 7056 root->test_properties()->AddChild(std::move(child)); |
7047 | 7057 |
7048 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 7058 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
7049 | 7059 |
7050 LayerTreeHostImpl::FrameData frame; | 7060 LayerTreeHostImpl::FrameData frame; |
7051 | 7061 |
7052 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 7062 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
7053 EXPECT_EQ(1u, frame.render_surface_layer_list->size()); | 7063 EXPECT_EQ(1u, frame.render_surface_layer_list->size()); |
7054 EXPECT_EQ(1u, frame.render_passes.size()); | 7064 EXPECT_EQ(1u, frame.render_passes.size()); |
7055 host_impl_->DidDrawAllLayers(frame); | 7065 host_impl_->DidDrawAllLayers(frame); |
7056 } | 7066 } |
7057 | 7067 |
7058 class FakeLayerWithQuads : public LayerImpl { | 7068 class FakeLayerWithQuads : public LayerImpl { |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7187 LayerTreeHostImpl::FrameData frame; | 7197 LayerTreeHostImpl::FrameData frame; |
7188 SetNeedsRebuildPropertyTrees(); | 7198 SetNeedsRebuildPropertyTrees(); |
7189 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 7199 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
7190 host_impl_->DrawLayers(&frame); | 7200 host_impl_->DrawLayers(&frame); |
7191 host_impl_->DidDrawAllLayers(frame); | 7201 host_impl_->DidDrawAllLayers(frame); |
7192 } | 7202 } |
7193 Mock::VerifyAndClearExpectations(&mock_context); | 7203 Mock::VerifyAndClearExpectations(&mock_context); |
7194 | 7204 |
7195 // Without partial swap, but a layer does clip its subtree, one scissor is | 7205 // Without partial swap, but a layer does clip its subtree, one scissor is |
7196 // set. | 7206 // set. |
7197 host_impl_->active_tree()->root_layer()->SetMasksToBounds(true); | 7207 host_impl_->active_tree()->root_layer_for_testing()->SetMasksToBounds(true); |
7198 host_impl_->active_tree()->root_layer()->NoteLayerPropertyChanged(); | 7208 host_impl_->active_tree() |
| 7209 ->root_layer_for_testing() |
| 7210 ->NoteLayerPropertyChanged(); |
7199 harness.MustDrawSolidQuad(); | 7211 harness.MustDrawSolidQuad(); |
7200 harness.MustSetScissor(0, 0, 10, 10); | 7212 harness.MustSetScissor(0, 0, 10, 10); |
7201 { | 7213 { |
7202 LayerTreeHostImpl::FrameData frame; | 7214 LayerTreeHostImpl::FrameData frame; |
7203 SetNeedsRebuildPropertyTrees(); | 7215 SetNeedsRebuildPropertyTrees(); |
7204 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 7216 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
7205 host_impl_->DrawLayers(&frame); | 7217 host_impl_->DrawLayers(&frame); |
7206 host_impl_->DidDrawAllLayers(frame); | 7218 host_impl_->DidDrawAllLayers(frame); |
7207 } | 7219 } |
7208 Mock::VerifyAndClearExpectations(&mock_context); | 7220 Mock::VerifyAndClearExpectations(&mock_context); |
(...skipping 15 matching lines...) Expand all Loading... |
7224 harness.MustDrawSolidQuad(); | 7236 harness.MustDrawSolidQuad(); |
7225 { | 7237 { |
7226 LayerTreeHostImpl::FrameData frame; | 7238 LayerTreeHostImpl::FrameData frame; |
7227 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 7239 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
7228 host_impl_->DrawLayers(&frame); | 7240 host_impl_->DrawLayers(&frame); |
7229 host_impl_->DidDrawAllLayers(frame); | 7241 host_impl_->DidDrawAllLayers(frame); |
7230 } | 7242 } |
7231 Mock::VerifyAndClearExpectations(&mock_context); | 7243 Mock::VerifyAndClearExpectations(&mock_context); |
7232 | 7244 |
7233 // Damage a portion of the frame. | 7245 // Damage a portion of the frame. |
7234 host_impl_->active_tree()->root_layer()->SetUpdateRect( | 7246 host_impl_->active_tree()->root_layer_for_testing()->SetUpdateRect( |
7235 gfx::Rect(0, 0, 2, 3)); | 7247 gfx::Rect(0, 0, 2, 3)); |
7236 | 7248 |
7237 // The second frame will be partially-swapped (the y coordinates are flipped). | 7249 // The second frame will be partially-swapped (the y coordinates are flipped). |
7238 harness.MustSetScissor(0, 7, 2, 3); | 7250 harness.MustSetScissor(0, 7, 2, 3); |
7239 harness.MustDrawSolidQuad(); | 7251 harness.MustDrawSolidQuad(); |
7240 { | 7252 { |
7241 LayerTreeHostImpl::FrameData frame; | 7253 LayerTreeHostImpl::FrameData frame; |
7242 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 7254 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
7243 host_impl_->DrawLayers(&frame); | 7255 host_impl_->DrawLayers(&frame); |
7244 host_impl_->DidDrawAllLayers(frame); | 7256 host_impl_->DidDrawAllLayers(frame); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7309 child->test_properties()->force_render_surface = true; | 7321 child->test_properties()->force_render_surface = true; |
7310 | 7322 |
7311 grand_child->SetPosition(gfx::PointF(grand_child_rect.origin())); | 7323 grand_child->SetPosition(gfx::PointF(grand_child_rect.origin())); |
7312 grand_child->SetBounds(grand_child_rect.size()); | 7324 grand_child->SetBounds(grand_child_rect.size()); |
7313 grand_child->draw_properties().visible_layer_rect = grand_child_rect; | 7325 grand_child->draw_properties().visible_layer_rect = grand_child_rect; |
7314 grand_child->SetDrawsContent(true); | 7326 grand_child->SetDrawsContent(true); |
7315 | 7327 |
7316 child->test_properties()->AddChild(std::move(grand_child)); | 7328 child->test_properties()->AddChild(std::move(grand_child)); |
7317 root->test_properties()->AddChild(std::move(child)); | 7329 root->test_properties()->AddChild(std::move(child)); |
7318 | 7330 |
7319 my_host_impl->active_tree()->SetRootLayer(std::move(root)); | 7331 my_host_impl->active_tree()->SetRootLayerForTesting(std::move(root)); |
7320 my_host_impl->active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 7332 my_host_impl->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
7321 return my_host_impl; | 7333 return my_host_impl; |
7322 } | 7334 } |
7323 | 7335 |
7324 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorPartialSwap) { | 7336 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorPartialSwap) { |
7325 TestSharedBitmapManager shared_bitmap_manager; | 7337 TestSharedBitmapManager shared_bitmap_manager; |
7326 TestTaskGraphRunner task_graph_runner; | 7338 TestTaskGraphRunner task_graph_runner; |
7327 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); | 7339 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); |
7328 provider->BindToCurrentThread(); | 7340 provider->BindToCurrentThread(); |
7329 provider->TestContext3d()->set_have_post_sub_buffer(true); | 7341 provider->TestContext3d()->set_have_post_sub_buffer(true); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7398 media::VideoFrame::CreateColorFrame( | 7410 media::VideoFrame::CreateColorFrame( |
7399 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); | 7411 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); |
7400 FakeVideoFrameProvider provider; | 7412 FakeVideoFrameProvider provider; |
7401 provider.set_frame(softwareFrame); | 7413 provider.set_frame(softwareFrame); |
7402 std::unique_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( | 7414 std::unique_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( |
7403 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0); | 7415 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0); |
7404 video_layer->SetBounds(gfx::Size(10, 10)); | 7416 video_layer->SetBounds(gfx::Size(10, 10)); |
7405 video_layer->SetDrawsContent(true); | 7417 video_layer->SetDrawsContent(true); |
7406 root_layer->test_properties()->AddChild(std::move(video_layer)); | 7418 root_layer->test_properties()->AddChild(std::move(video_layer)); |
7407 | 7419 |
7408 host_impl_->active_tree()->SetRootLayer(std::move(root_layer)); | 7420 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_layer)); |
7409 | 7421 |
7410 EXPECT_EQ(0u, context3d->NumTextures()); | 7422 EXPECT_EQ(0u, context3d->NumTextures()); |
7411 | 7423 |
7412 LayerTreeHostImpl::FrameData frame; | 7424 LayerTreeHostImpl::FrameData frame; |
7413 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 7425 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
7414 host_impl_->DrawLayers(&frame); | 7426 host_impl_->DrawLayers(&frame); |
7415 host_impl_->DidDrawAllLayers(frame); | 7427 host_impl_->DidDrawAllLayers(frame); |
7416 host_impl_->SwapBuffers(frame); | 7428 host_impl_->SwapBuffers(frame); |
7417 | 7429 |
7418 EXPECT_GT(context3d->NumTextures(), 0u); | 7430 EXPECT_GT(context3d->NumTextures(), 0u); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7487 | 7499 |
7488 // Verify the damage rect for the root render pass. | 7500 // Verify the damage rect for the root render pass. |
7489 const RenderPass* root_render_pass = frame.render_passes.back().get(); | 7501 const RenderPass* root_render_pass = frame.render_passes.back().get(); |
7490 EXPECT_EQ(expected_damage, root_render_pass->damage_rect); | 7502 EXPECT_EQ(expected_damage, root_render_pass->damage_rect); |
7491 | 7503 |
7492 // Verify the root and child layers' quads are generated and not being | 7504 // Verify the root and child layers' quads are generated and not being |
7493 // culled. | 7505 // culled. |
7494 ASSERT_EQ(2u, root_render_pass->quad_list.size()); | 7506 ASSERT_EQ(2u, root_render_pass->quad_list.size()); |
7495 | 7507 |
7496 LayerImpl* child = host_impl_->active_tree() | 7508 LayerImpl* child = host_impl_->active_tree() |
7497 ->root_layer() | 7509 ->root_layer_for_testing() |
7498 ->test_properties() | 7510 ->test_properties() |
7499 ->children[0]; | 7511 ->children[0]; |
7500 gfx::Rect expected_child_visible_rect(child->bounds()); | 7512 gfx::Rect expected_child_visible_rect(child->bounds()); |
7501 EXPECT_EQ(expected_child_visible_rect, | 7513 EXPECT_EQ(expected_child_visible_rect, |
7502 root_render_pass->quad_list.front()->visible_rect); | 7514 root_render_pass->quad_list.front()->visible_rect); |
7503 | 7515 |
7504 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 7516 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); |
7505 gfx::Rect expected_root_visible_rect(root->bounds()); | 7517 gfx::Rect expected_root_visible_rect(root->bounds()); |
7506 EXPECT_EQ(expected_root_visible_rect, | 7518 EXPECT_EQ(expected_root_visible_rect, |
7507 root_render_pass->quad_list.ElementAt(1)->visible_rect); | 7519 root_render_pass->quad_list.ElementAt(1)->visible_rect); |
7508 } | 7520 } |
7509 | 7521 |
7510 host_impl_->DrawLayers(&frame); | 7522 host_impl_->DrawLayers(&frame); |
7511 host_impl_->DidDrawAllLayers(frame); | 7523 host_impl_->DidDrawAllLayers(frame); |
7512 EXPECT_EQ(expect_to_draw, host_impl_->SwapBuffers(frame)); | 7524 EXPECT_EQ(expect_to_draw, host_impl_->SwapBuffers(frame)); |
7513 } | 7525 } |
7514 }; | 7526 }; |
7515 | 7527 |
7516 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) { | 7528 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) { |
7517 std::unique_ptr<SolidColorLayerImpl> root = | 7529 std::unique_ptr<SolidColorLayerImpl> root = |
7518 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 7530 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
7519 root->SetPosition(gfx::PointF()); | 7531 root->SetPosition(gfx::PointF()); |
7520 root->SetBounds(gfx::Size(10, 10)); | 7532 root->SetBounds(gfx::Size(10, 10)); |
7521 root->SetDrawsContent(true); | 7533 root->SetDrawsContent(true); |
7522 root->test_properties()->force_render_surface = true; | 7534 root->test_properties()->force_render_surface = true; |
7523 | 7535 |
7524 // Child layer is in the bottom right corner. | 7536 // Child layer is in the bottom right corner. |
7525 std::unique_ptr<SolidColorLayerImpl> child = | 7537 std::unique_ptr<SolidColorLayerImpl> child = |
7526 SolidColorLayerImpl::Create(host_impl_->active_tree(), 2); | 7538 SolidColorLayerImpl::Create(host_impl_->active_tree(), 2); |
7527 child->SetPosition(gfx::PointF(9.f, 9.f)); | 7539 child->SetPosition(gfx::PointF(9.f, 9.f)); |
7528 child->SetBounds(gfx::Size(1, 1)); | 7540 child->SetBounds(gfx::Size(1, 1)); |
7529 child->SetDrawsContent(true); | 7541 child->SetDrawsContent(true); |
7530 root->test_properties()->AddChild(std::move(child)); | 7542 root->test_properties()->AddChild(std::move(child)); |
7531 | 7543 |
7532 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 7544 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
7533 | 7545 |
7534 // Draw a frame. In the first frame, the entire viewport should be damaged. | 7546 // Draw a frame. In the first frame, the entire viewport should be damaged. |
7535 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); | 7547 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); |
7536 DrawFrameAndTestDamage(full_frame_damage); | 7548 DrawFrameAndTestDamage(full_frame_damage); |
7537 | 7549 |
7538 // The second frame has damage that doesn't touch the child layer. Its quads | 7550 // The second frame has damage that doesn't touch the child layer. Its quads |
7539 // should still be generated. | 7551 // should still be generated. |
7540 gfx::Rect small_damage = gfx::Rect(0, 0, 1, 1); | 7552 gfx::Rect small_damage = gfx::Rect(0, 0, 1, 1); |
7541 host_impl_->active_tree()->root_layer()->SetUpdateRect(small_damage); | 7553 host_impl_->active_tree()->root_layer_for_testing()->SetUpdateRect( |
| 7554 small_damage); |
7542 DrawFrameAndTestDamage(small_damage); | 7555 DrawFrameAndTestDamage(small_damage); |
7543 | 7556 |
7544 // The third frame should have no damage, so no quads should be generated. | 7557 // The third frame should have no damage, so no quads should be generated. |
7545 gfx::Rect no_damage; | 7558 gfx::Rect no_damage; |
7546 DrawFrameAndTestDamage(no_damage); | 7559 DrawFrameAndTestDamage(no_damage); |
7547 } | 7560 } |
7548 | 7561 |
7549 // TODO(reveman): Remove this test and the ability to prevent on demand raster | 7562 // TODO(reveman): Remove this test and the ability to prevent on demand raster |
7550 // when delegating renderer supports PictureDrawQuads. crbug.com/342121 | 7563 // when delegating renderer supports PictureDrawQuads. crbug.com/342121 |
7551 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, PreventRasterizeOnDemand) { | 7564 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, PreventRasterizeOnDemand) { |
(...skipping 19 matching lines...) Expand all Loading... |
7571 host_impl_->CreatePendingTree(); | 7584 host_impl_->CreatePendingTree(); |
7572 host_impl_->pending_tree()->SetDeviceScaleFactor(device_scale_factor); | 7585 host_impl_->pending_tree()->SetDeviceScaleFactor(device_scale_factor); |
7573 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f / 16.f, | 7586 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f / 16.f, |
7574 16.f); | 7587 16.f); |
7575 | 7588 |
7576 std::unique_ptr<LayerImpl> scoped_root = | 7589 std::unique_ptr<LayerImpl> scoped_root = |
7577 LayerImpl::Create(host_impl_->pending_tree(), 1); | 7590 LayerImpl::Create(host_impl_->pending_tree(), 1); |
7578 LayerImpl* root = scoped_root.get(); | 7591 LayerImpl* root = scoped_root.get(); |
7579 root->test_properties()->force_render_surface = true; | 7592 root->test_properties()->force_render_surface = true; |
7580 | 7593 |
7581 host_impl_->pending_tree()->SetRootLayer(std::move(scoped_root)); | 7594 host_impl_->pending_tree()->SetRootLayerForTesting(std::move(scoped_root)); |
7582 | 7595 |
7583 std::unique_ptr<LayerImpl> scoped_scrolling_layer = | 7596 std::unique_ptr<LayerImpl> scoped_scrolling_layer = |
7584 LayerImpl::Create(host_impl_->pending_tree(), 2); | 7597 LayerImpl::Create(host_impl_->pending_tree(), 2); |
7585 LayerImpl* scrolling_layer = scoped_scrolling_layer.get(); | 7598 LayerImpl* scrolling_layer = scoped_scrolling_layer.get(); |
7586 root->test_properties()->AddChild(std::move(scoped_scrolling_layer)); | 7599 root->test_properties()->AddChild(std::move(scoped_scrolling_layer)); |
7587 | 7600 |
7588 gfx::Size content_layer_bounds(100000, 100); | 7601 gfx::Size content_layer_bounds(100000, 100); |
7589 scoped_refptr<FakeRasterSource> raster_source( | 7602 scoped_refptr<FakeRasterSource> raster_source( |
7590 FakeRasterSource::CreateFilled(content_layer_bounds)); | 7603 FakeRasterSource::CreateFilled(content_layer_bounds)); |
7591 | 7604 |
7592 std::unique_ptr<FakePictureLayerImpl> scoped_content_layer = | 7605 std::unique_ptr<FakePictureLayerImpl> scoped_content_layer = |
7593 FakePictureLayerImpl::CreateWithRasterSource(host_impl_->pending_tree(), | 7606 FakePictureLayerImpl::CreateWithRasterSource(host_impl_->pending_tree(), |
7594 3, raster_source); | 7607 3, raster_source); |
7595 LayerImpl* content_layer = scoped_content_layer.get(); | 7608 LayerImpl* content_layer = scoped_content_layer.get(); |
7596 scrolling_layer->test_properties()->AddChild(std::move(scoped_content_layer)); | 7609 scrolling_layer->test_properties()->AddChild(std::move(scoped_content_layer)); |
7597 content_layer->SetBounds(content_layer_bounds); | 7610 content_layer->SetBounds(content_layer_bounds); |
7598 content_layer->SetDrawsContent(true); | 7611 content_layer->SetDrawsContent(true); |
7599 | 7612 |
7600 root->SetBounds(root_size); | 7613 root->SetBounds(root_size); |
7601 | 7614 |
7602 gfx::ScrollOffset scroll_offset(100000, 0); | 7615 gfx::ScrollOffset scroll_offset(100000, 0); |
7603 scrolling_layer->SetScrollClipLayer(root->id()); | 7616 scrolling_layer->SetScrollClipLayer(root->id()); |
7604 scrolling_layer->layer_tree_impl() | 7617 scrolling_layer->layer_tree_impl() |
7605 ->property_trees() | 7618 ->property_trees() |
7606 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scrolling_layer->id(), | 7619 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scrolling_layer->id(), |
7607 scroll_offset); | 7620 scroll_offset); |
7608 | 7621 |
7609 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting(); | 7622 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting(); |
7610 host_impl_->ActivateSyncTree(); | 7623 host_impl_->ActivateSyncTree(); |
| 7624 host_impl_->active_tree()->SetRootLayerFromLayerListForTesting(); |
7611 | 7625 |
7612 bool update_lcd_text = false; | 7626 bool update_lcd_text = false; |
7613 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); | 7627 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); |
7614 ASSERT_EQ(1u, host_impl_->active_tree()->RenderSurfaceLayerList().size()); | 7628 ASSERT_EQ(1u, host_impl_->active_tree()->RenderSurfaceLayerList().size()); |
7615 | 7629 |
7616 LayerTreeHostImpl::FrameData frame; | 7630 LayerTreeHostImpl::FrameData frame; |
7617 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 7631 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
7618 | 7632 |
7619 ASSERT_EQ(1u, frame.render_passes.size()); | 7633 ASSERT_EQ(1u, frame.render_passes.size()); |
7620 ASSERT_LE(1u, frame.render_passes[0]->quad_list.size()); | 7634 ASSERT_LE(1u, frame.render_passes[0]->quad_list.size()); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7735 host_impl_->active_tree(), 2, &provider, media::VIDEO_ROTATION_0); | 7749 host_impl_->active_tree(), 2, &provider, media::VIDEO_ROTATION_0); |
7736 video_layer->SetBounds(gfx::Size(10, 10)); | 7750 video_layer->SetBounds(gfx::Size(10, 10)); |
7737 video_layer->SetDrawsContent(true); | 7751 video_layer->SetDrawsContent(true); |
7738 root_layer->test_properties()->AddChild(std::move(video_layer)); | 7752 root_layer->test_properties()->AddChild(std::move(video_layer)); |
7739 SetupRootLayerImpl(std::move(root_layer)); | 7753 SetupRootLayerImpl(std::move(root_layer)); |
7740 | 7754 |
7741 host_impl_->OnDraw(external_transform, external_viewport, external_clip, | 7755 host_impl_->OnDraw(external_transform, external_viewport, external_clip, |
7742 resourceless_software_draw); | 7756 resourceless_software_draw); |
7743 | 7757 |
7744 EXPECT_EQ(1u, last_on_draw_frame_->will_draw_layers.size()); | 7758 EXPECT_EQ(1u, last_on_draw_frame_->will_draw_layers.size()); |
7745 EXPECT_EQ(host_impl_->active_tree()->root_layer(), | 7759 EXPECT_EQ(host_impl_->active_tree()->root_layer_for_testing(), |
7746 last_on_draw_frame_->will_draw_layers[0]); | 7760 last_on_draw_frame_->will_draw_layers[0]); |
7747 } | 7761 } |
7748 | 7762 |
7749 // Checks that we have a non-0 default allocation if we pass a context that | 7763 // Checks that we have a non-0 default allocation if we pass a context that |
7750 // doesn't support memory management extensions. | 7764 // doesn't support memory management extensions. |
7751 TEST_F(LayerTreeHostImplTest, DefaultMemoryAllocation) { | 7765 TEST_F(LayerTreeHostImplTest, DefaultMemoryAllocation) { |
7752 LayerTreeSettings settings = DefaultSettings(); | 7766 LayerTreeSettings settings = DefaultSettings(); |
7753 host_impl_ = LayerTreeHostImpl::Create( | 7767 host_impl_ = LayerTreeHostImpl::Create( |
7754 settings, this, &task_runner_provider_, &stats_instrumentation_, | 7768 settings, this, &task_runner_provider_, &stats_instrumentation_, |
7755 &shared_bitmap_manager_, &gpu_memory_buffer_manager_, &task_graph_runner_, | 7769 &shared_bitmap_manager_, &gpu_memory_buffer_manager_, &task_graph_runner_, |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7909 | 7923 |
7910 TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) { | 7924 TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) { |
7911 scoped_refptr<TestContextProvider> context_provider = | 7925 scoped_refptr<TestContextProvider> context_provider = |
7912 TestContextProvider::Create(); | 7926 TestContextProvider::Create(); |
7913 | 7927 |
7914 CreateHostImpl(DefaultSettings(), | 7928 CreateHostImpl(DefaultSettings(), |
7915 FakeOutputSurface::Create3d(context_provider)); | 7929 FakeOutputSurface::Create3d(context_provider)); |
7916 | 7930 |
7917 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 7931 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); |
7918 | 7932 |
7919 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 7933 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); |
7920 root->test_properties()->copy_requests.push_back( | 7934 root->test_properties()->copy_requests.push_back( |
7921 CopyOutputRequest::CreateRequest( | 7935 CopyOutputRequest::CreateRequest( |
7922 base::Bind(&ShutdownReleasesContext_Callback))); | 7936 base::Bind(&ShutdownReleasesContext_Callback))); |
7923 | 7937 |
7924 LayerTreeHostImpl::FrameData frame; | 7938 LayerTreeHostImpl::FrameData frame; |
7925 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 7939 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
7926 host_impl_->DrawLayers(&frame); | 7940 host_impl_->DrawLayers(&frame); |
7927 host_impl_->DidDrawAllLayers(frame); | 7941 host_impl_->DidDrawAllLayers(frame); |
7928 | 7942 |
7929 // The CopyOutputResult's callback has a ref on the ContextProvider and a | 7943 // The CopyOutputResult's callback has a ref on the ContextProvider and a |
(...skipping 25 matching lines...) Expand all Loading... |
7955 root_scroll->test_properties()->is_container_for_fixed_position_layers = true; | 7969 root_scroll->test_properties()->is_container_for_fixed_position_layers = true; |
7956 std::unique_ptr<LayerImpl> child = | 7970 std::unique_ptr<LayerImpl> child = |
7957 CreateScrollableLayer(2, content_size, root_clip.get()); | 7971 CreateScrollableLayer(2, content_size, root_clip.get()); |
7958 | 7972 |
7959 root_scroll->test_properties()->AddChild(std::move(child)); | 7973 root_scroll->test_properties()->AddChild(std::move(child)); |
7960 int root_id = root_scroll->id(); | 7974 int root_id = root_scroll->id(); |
7961 root_clip->test_properties()->AddChild(std::move(root_scroll)); | 7975 root_clip->test_properties()->AddChild(std::move(root_scroll)); |
7962 root_ptr->test_properties()->AddChild(std::move(root_clip)); | 7976 root_ptr->test_properties()->AddChild(std::move(root_clip)); |
7963 | 7977 |
7964 host_impl_->SetViewportSize(surface_size); | 7978 host_impl_->SetViewportSize(surface_size); |
7965 host_impl_->active_tree()->SetRootLayer(std::move(root_ptr)); | 7979 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr)); |
7966 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 1, | 7980 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 1, |
7967 Layer::INVALID_ID); | 7981 Layer::INVALID_ID); |
7968 host_impl_->active_tree()->DidBecomeActive(); | 7982 host_impl_->active_tree()->DidBecomeActive(); |
7969 SetNeedsRebuildPropertyTrees(); | 7983 SetNeedsRebuildPropertyTrees(); |
7970 DrawFrame(); | 7984 DrawFrame(); |
7971 { | 7985 { |
7972 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 7986 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
7973 host_impl_ | 7987 host_impl_ |
7974 ->ScrollBegin(BeginState(gfx::Point()).get(), | 7988 ->ScrollBegin(BeginState(gfx::Point()).get(), |
7975 InputHandler::TOUCHSCREEN) | 7989 InputHandler::TOUCHSCREEN) |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8013 std::unique_ptr<LayerImpl> child = | 8027 std::unique_ptr<LayerImpl> child = |
8014 CreateScrollableLayer(3, surface_size, root.get()); | 8028 CreateScrollableLayer(3, surface_size, root.get()); |
8015 child->layer_tree_impl() | 8029 child->layer_tree_impl() |
8016 ->property_trees() | 8030 ->property_trees() |
8017 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child->id(), | 8031 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child->id(), |
8018 gfx::ScrollOffset(0, 4)); | 8032 gfx::ScrollOffset(0, 4)); |
8019 child->test_properties()->AddChild(std::move(grand_child)); | 8033 child->test_properties()->AddChild(std::move(grand_child)); |
8020 | 8034 |
8021 root_scrolling->test_properties()->AddChild(std::move(child)); | 8035 root_scrolling->test_properties()->AddChild(std::move(child)); |
8022 root->test_properties()->AddChild(std::move(root_scrolling)); | 8036 root->test_properties()->AddChild(std::move(root_scrolling)); |
8023 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 8037 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
8024 host_impl_->active_tree()->DidBecomeActive(); | 8038 host_impl_->active_tree()->DidBecomeActive(); |
8025 host_impl_->SetViewportSize(surface_size); | 8039 host_impl_->SetViewportSize(surface_size); |
8026 SetNeedsRebuildPropertyTrees(); | 8040 SetNeedsRebuildPropertyTrees(); |
8027 DrawFrame(); | 8041 DrawFrame(); |
8028 { | 8042 { |
8029 std::unique_ptr<ScrollAndScaleSet> scroll_info; | 8043 std::unique_ptr<ScrollAndScaleSet> scroll_info; |
8030 LayerImpl* child = host_impl_->active_tree() | 8044 LayerImpl* child = host_impl_->active_tree() |
8031 ->root_layer() | 8045 ->root_layer_for_testing() |
8032 ->test_properties() | 8046 ->test_properties() |
8033 ->children[0] | 8047 ->children[0] |
8034 ->test_properties() | 8048 ->test_properties() |
8035 ->children[0]; | 8049 ->children[0]; |
8036 LayerImpl* grand_child = child->test_properties()->children[0]; | 8050 LayerImpl* grand_child = child->test_properties()->children[0]; |
8037 | 8051 |
8038 gfx::Vector2d scroll_delta(0, -2); | 8052 gfx::Vector2d scroll_delta(0, -2); |
8039 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8053 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
8040 host_impl_ | 8054 host_impl_ |
8041 ->ScrollBegin(BeginState(gfx::Point()).get(), | 8055 ->ScrollBegin(BeginState(gfx::Point()).get(), |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8096 std::unique_ptr<LayerImpl> root_scroll = | 8110 std::unique_ptr<LayerImpl> root_scroll = |
8097 CreateScrollableLayer(1, content_size, root_clip.get()); | 8111 CreateScrollableLayer(1, content_size, root_clip.get()); |
8098 int root_scroll_id = root_scroll->id(); | 8112 int root_scroll_id = root_scroll->id(); |
8099 std::unique_ptr<LayerImpl> child = | 8113 std::unique_ptr<LayerImpl> child = |
8100 CreateScrollableLayer(2, content_size, root_clip.get()); | 8114 CreateScrollableLayer(2, content_size, root_clip.get()); |
8101 | 8115 |
8102 root_scroll->test_properties()->AddChild(std::move(child)); | 8116 root_scroll->test_properties()->AddChild(std::move(child)); |
8103 root_clip->test_properties()->AddChild(std::move(root_scroll)); | 8117 root_clip->test_properties()->AddChild(std::move(root_scroll)); |
8104 | 8118 |
8105 host_impl_->SetViewportSize(surface_size); | 8119 host_impl_->SetViewportSize(surface_size); |
8106 host_impl_->active_tree()->SetRootLayer(std::move(root_clip)); | 8120 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_clip)); |
8107 host_impl_->active_tree()->DidBecomeActive(); | 8121 host_impl_->active_tree()->DidBecomeActive(); |
8108 SetNeedsRebuildPropertyTrees(); | 8122 SetNeedsRebuildPropertyTrees(); |
8109 DrawFrame(); | 8123 DrawFrame(); |
8110 { | 8124 { |
8111 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8125 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
8112 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 8126 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
8113 InputHandler::WHEEL) | 8127 InputHandler::WHEEL) |
8114 .thread); | 8128 .thread); |
8115 | 8129 |
8116 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8130 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8344 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed | 8358 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed |
8345 // to CompositorFrameMetadata after SwapBuffers(); | 8359 // to CompositorFrameMetadata after SwapBuffers(); |
8346 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { | 8360 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { |
8347 std::unique_ptr<SolidColorLayerImpl> root = | 8361 std::unique_ptr<SolidColorLayerImpl> root = |
8348 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 8362 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
8349 root->SetPosition(gfx::PointF()); | 8363 root->SetPosition(gfx::PointF()); |
8350 root->SetBounds(gfx::Size(10, 10)); | 8364 root->SetBounds(gfx::Size(10, 10)); |
8351 root->SetDrawsContent(true); | 8365 root->SetDrawsContent(true); |
8352 root->test_properties()->force_render_surface = true; | 8366 root->test_properties()->force_render_surface = true; |
8353 | 8367 |
8354 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 8368 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
8355 | 8369 |
8356 FakeOutputSurface* fake_output_surface = | 8370 FakeOutputSurface* fake_output_surface = |
8357 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); | 8371 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); |
8358 | 8372 |
8359 ui::LatencyInfo latency_info; | 8373 ui::LatencyInfo latency_info; |
8360 latency_info.AddLatencyNumber( | 8374 latency_info.AddLatencyNumber( |
8361 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, 0); | 8375 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, 0); |
8362 std::unique_ptr<SwapPromise> swap_promise( | 8376 std::unique_ptr<SwapPromise> swap_promise( |
8363 new LatencyInfoSwapPromise(latency_info)); | 8377 new LatencyInfoSwapPromise(latency_info)); |
8364 host_impl_->active_tree()->QueuePinnedSwapPromise(std::move(swap_promise)); | 8378 host_impl_->active_tree()->QueuePinnedSwapPromise(std::move(swap_promise)); |
(...skipping 15 matching lines...) Expand all Loading... |
8380 | 8394 |
8381 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) { | 8395 TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) { |
8382 int root_layer_id = 1; | 8396 int root_layer_id = 1; |
8383 std::unique_ptr<SolidColorLayerImpl> root = | 8397 std::unique_ptr<SolidColorLayerImpl> root = |
8384 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id); | 8398 SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id); |
8385 root->SetPosition(gfx::PointF()); | 8399 root->SetPosition(gfx::PointF()); |
8386 root->SetBounds(gfx::Size(10, 10)); | 8400 root->SetBounds(gfx::Size(10, 10)); |
8387 root->SetDrawsContent(true); | 8401 root->SetDrawsContent(true); |
8388 root->test_properties()->force_render_surface = true; | 8402 root->test_properties()->force_render_surface = true; |
8389 | 8403 |
8390 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 8404 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
8391 | 8405 |
8392 // Ensure the default frame selection bounds are empty. | 8406 // Ensure the default frame selection bounds are empty. |
8393 FakeOutputSurface* fake_output_surface = | 8407 FakeOutputSurface* fake_output_surface = |
8394 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); | 8408 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); |
8395 | 8409 |
8396 // Plumb the layer-local selection bounds. | 8410 // Plumb the layer-local selection bounds. |
8397 gfx::Point selection_top(5, 0); | 8411 gfx::Point selection_top(5, 0); |
8398 gfx::Point selection_bottom(5, 5); | 8412 gfx::Point selection_bottom(5, 5); |
8399 LayerSelection selection; | 8413 LayerSelection selection; |
8400 selection.start.type = gfx::SelectionBound::CENTER; | 8414 selection.start.type = gfx::SelectionBound::CENTER; |
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9073 contents->SetBounds(content_size); | 9087 contents->SetBounds(content_size); |
9074 contents->SetPosition(gfx::PointF()); | 9088 contents->SetPosition(gfx::PointF()); |
9075 | 9089 |
9076 outer_scroll->test_properties()->AddChild(std::move(contents)); | 9090 outer_scroll->test_properties()->AddChild(std::move(contents)); |
9077 outer_clip->test_properties()->AddChild(std::move(outer_scroll)); | 9091 outer_clip->test_properties()->AddChild(std::move(outer_scroll)); |
9078 inner_scroll->test_properties()->AddChild(std::move(outer_clip)); | 9092 inner_scroll->test_properties()->AddChild(std::move(outer_clip)); |
9079 page_scale->test_properties()->AddChild(std::move(inner_scroll)); | 9093 page_scale->test_properties()->AddChild(std::move(inner_scroll)); |
9080 inner_clip->test_properties()->AddChild(std::move(page_scale)); | 9094 inner_clip->test_properties()->AddChild(std::move(page_scale)); |
9081 | 9095 |
9082 inner_clip->test_properties()->force_render_surface = true; | 9096 inner_clip->test_properties()->force_render_surface = true; |
9083 layer_tree_impl->SetRootLayer(std::move(inner_clip)); | 9097 layer_tree_impl->SetRootLayerForTesting(std::move(inner_clip)); |
9084 layer_tree_impl->SetViewportLayersFromIds( | 9098 layer_tree_impl->SetViewportLayersFromIds( |
9085 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportScrollLayerId, | 9099 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportScrollLayerId, |
9086 kOuterViewportScrollLayerId); | 9100 kOuterViewportScrollLayerId); |
9087 | 9101 |
9088 host_impl_->active_tree()->DidBecomeActive(); | 9102 host_impl_->active_tree()->DidBecomeActive(); |
9089 } | 9103 } |
9090 }; | 9104 }; |
9091 | 9105 |
9092 TEST_F(LayerTreeHostImplVirtualViewportTest, ScrollBothInnerAndOuterLayer) { | 9106 TEST_F(LayerTreeHostImplVirtualViewportTest, ScrollBothInnerAndOuterLayer) { |
9093 gfx::Size content_size = gfx::Size(100, 160); | 9107 gfx::Size content_size = gfx::Size(100, 160); |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9537 host_impl_->SetViewportSize(viewport_size); | 9551 host_impl_->SetViewportSize(viewport_size); |
9538 | 9552 |
9539 host_impl_->CreatePendingTree(); | 9553 host_impl_->CreatePendingTree(); |
9540 scoped_refptr<FakeRasterSource> raster_source( | 9554 scoped_refptr<FakeRasterSource> raster_source( |
9541 FakeRasterSource::CreateFilled(viewport_size)); | 9555 FakeRasterSource::CreateFilled(viewport_size)); |
9542 std::unique_ptr<FakePictureLayerImpl> layer( | 9556 std::unique_ptr<FakePictureLayerImpl> layer( |
9543 FakePictureLayerImpl::CreateWithRasterSource(host_impl_->pending_tree(), | 9557 FakePictureLayerImpl::CreateWithRasterSource(host_impl_->pending_tree(), |
9544 11, raster_source)); | 9558 11, raster_source)); |
9545 layer->SetBounds(viewport_size); | 9559 layer->SetBounds(viewport_size); |
9546 layer->SetDrawsContent(true); | 9560 layer->SetDrawsContent(true); |
9547 host_impl_->pending_tree()->SetRootLayer(std::move(layer)); | 9561 host_impl_->pending_tree()->SetRootLayerForTesting(std::move(layer)); |
9548 | 9562 |
9549 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting(); | 9563 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting(); |
9550 host_impl_->ActivateSyncTree(); | 9564 host_impl_->ActivateSyncTree(); |
| 9565 host_impl_->active_tree()->SetRootLayerFromLayerListForTesting(); |
9551 | 9566 |
9552 const gfx::Transform draw_transform; | 9567 const gfx::Transform draw_transform; |
9553 const gfx::Rect draw_viewport(viewport_size); | 9568 const gfx::Rect draw_viewport(viewport_size); |
9554 const gfx::Rect clip(viewport_size); | 9569 const gfx::Rect clip(viewport_size); |
9555 bool resourceless_software_draw = false; | 9570 bool resourceless_software_draw = false; |
9556 | 9571 |
9557 // Regular draw causes UpdateTiles. | 9572 // Regular draw causes UpdateTiles. |
9558 did_request_prepare_tiles_ = false; | 9573 did_request_prepare_tiles_ = false; |
9559 host_impl_->OnDraw(draw_transform, draw_viewport, clip, | 9574 host_impl_->OnDraw(draw_transform, draw_viewport, clip, |
9560 resourceless_software_draw); | 9575 resourceless_software_draw); |
(...skipping 10 matching lines...) Expand all Loading... |
9571 } | 9586 } |
9572 | 9587 |
9573 TEST_F(LayerTreeHostImplTest, ExternalTileConstraintReflectedInPendingTree) { | 9588 TEST_F(LayerTreeHostImplTest, ExternalTileConstraintReflectedInPendingTree) { |
9574 EXPECT_FALSE(host_impl_->CommitToActiveTree()); | 9589 EXPECT_FALSE(host_impl_->CommitToActiveTree()); |
9575 const gfx::Size layer_size(100, 100); | 9590 const gfx::Size layer_size(100, 100); |
9576 host_impl_->SetViewportSize(layer_size); | 9591 host_impl_->SetViewportSize(layer_size); |
9577 bool update_lcd_text = false; | 9592 bool update_lcd_text = false; |
9578 | 9593 |
9579 // Set up active and pending tree. | 9594 // Set up active and pending tree. |
9580 host_impl_->CreatePendingTree(); | 9595 host_impl_->CreatePendingTree(); |
9581 host_impl_->pending_tree()->SetRootLayer( | 9596 host_impl_->pending_tree()->SetRootLayerForTesting( |
9582 LayerImpl::Create(host_impl_->pending_tree(), 1)); | 9597 LayerImpl::Create(host_impl_->pending_tree(), 1)); |
9583 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting(); | 9598 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting(); |
9584 host_impl_->pending_tree()->UpdateDrawProperties(update_lcd_text); | 9599 host_impl_->pending_tree()->UpdateDrawProperties(update_lcd_text); |
9585 | 9600 |
9586 host_impl_->ActivateSyncTree(); | 9601 host_impl_->ActivateSyncTree(); |
| 9602 host_impl_->active_tree()->SetRootLayerFromLayerListForTesting(); |
9587 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 9603 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
9588 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); | 9604 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); |
9589 | 9605 |
9590 host_impl_->CreatePendingTree(); | 9606 host_impl_->CreatePendingTree(); |
9591 host_impl_->pending_tree()->UpdateDrawProperties(update_lcd_text); | 9607 host_impl_->pending_tree()->UpdateDrawProperties(update_lcd_text); |
9592 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); | 9608 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); |
9593 | 9609 |
9594 EXPECT_FALSE(host_impl_->pending_tree()->needs_update_draw_properties()); | 9610 EXPECT_FALSE(host_impl_->pending_tree()->needs_update_draw_properties()); |
9595 EXPECT_FALSE(host_impl_->active_tree()->needs_update_draw_properties()); | 9611 EXPECT_FALSE(host_impl_->active_tree()->needs_update_draw_properties()); |
9596 | 9612 |
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10269 layer->set_gpu_raster_max_texture_size(host_impl_->device_viewport_size()); | 10285 layer->set_gpu_raster_max_texture_size(host_impl_->device_viewport_size()); |
10270 layer->SetDrawsContent(true); | 10286 layer->SetDrawsContent(true); |
10271 layer->tilings()->AddTiling(1.0f, raster_source_with_tiles); | 10287 layer->tilings()->AddTiling(1.0f, raster_source_with_tiles); |
10272 layer->UpdateRasterSource(raster_source_with_tiles, &empty_invalidation, | 10288 layer->UpdateRasterSource(raster_source_with_tiles, &empty_invalidation, |
10273 nullptr); | 10289 nullptr); |
10274 layer->tilings()->tiling_at(0)->set_resolution( | 10290 layer->tilings()->tiling_at(0)->set_resolution( |
10275 TileResolution::HIGH_RESOLUTION); | 10291 TileResolution::HIGH_RESOLUTION); |
10276 layer->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 10292 layer->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
10277 layer->tilings()->UpdateTilePriorities(gfx::Rect(gfx::Size(10, 10)), 1.f, 1.0, | 10293 layer->tilings()->UpdateTilePriorities(gfx::Rect(gfx::Size(10, 10)), 1.f, 1.0, |
10278 Occlusion(), true); | 10294 Occlusion(), true); |
10279 host_impl_->pending_tree()->SetRootLayer(std::move(layer)); | 10295 host_impl_->pending_tree()->SetRootLayerForTesting(std::move(layer)); |
10280 | 10296 |
10281 FakePictureLayerImpl* root_layer = static_cast<FakePictureLayerImpl*>( | 10297 FakePictureLayerImpl* root_layer = static_cast<FakePictureLayerImpl*>( |
10282 host_impl_->pending_tree()->root_layer()); | 10298 host_impl_->pending_tree()->root_layer_for_testing()); |
10283 | 10299 |
10284 root_layer->set_has_valid_tile_priorities(true); | 10300 root_layer->set_has_valid_tile_priorities(true); |
10285 std::unique_ptr<RasterTilePriorityQueue> non_empty_raster_priority_queue_all = | 10301 std::unique_ptr<RasterTilePriorityQueue> non_empty_raster_priority_queue_all = |
10286 host_impl_->BuildRasterQueue(TreePriority::SAME_PRIORITY_FOR_BOTH_TREES, | 10302 host_impl_->BuildRasterQueue(TreePriority::SAME_PRIORITY_FOR_BOTH_TREES, |
10287 RasterTilePriorityQueue::Type::ALL); | 10303 RasterTilePriorityQueue::Type::ALL); |
10288 EXPECT_FALSE(non_empty_raster_priority_queue_all->IsEmpty()); | 10304 EXPECT_FALSE(non_empty_raster_priority_queue_all->IsEmpty()); |
10289 | 10305 |
10290 root_layer->set_has_valid_tile_priorities(false); | 10306 root_layer->set_has_valid_tile_priorities(false); |
10291 std::unique_ptr<RasterTilePriorityQueue> empty_raster_priority_queue_all = | 10307 std::unique_ptr<RasterTilePriorityQueue> empty_raster_priority_queue_all = |
10292 host_impl_->BuildRasterQueue(TreePriority::SAME_PRIORITY_FOR_BOTH_TREES, | 10308 host_impl_->BuildRasterQueue(TreePriority::SAME_PRIORITY_FOR_BOTH_TREES, |
10293 RasterTilePriorityQueue::Type::ALL); | 10309 RasterTilePriorityQueue::Type::ALL); |
10294 EXPECT_TRUE(empty_raster_priority_queue_all->IsEmpty()); | 10310 EXPECT_TRUE(empty_raster_priority_queue_all->IsEmpty()); |
10295 } | 10311 } |
10296 | 10312 |
10297 TEST_F(LayerTreeHostImplTest, DidBecomeActive) { | 10313 TEST_F(LayerTreeHostImplTest, DidBecomeActive) { |
10298 host_impl_->CreatePendingTree(); | 10314 host_impl_->CreatePendingTree(); |
10299 host_impl_->ActivateSyncTree(); | 10315 host_impl_->ActivateSyncTree(); |
10300 host_impl_->CreatePendingTree(); | 10316 host_impl_->CreatePendingTree(); |
10301 | 10317 |
10302 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); | 10318 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); |
10303 | 10319 |
10304 std::unique_ptr<FakePictureLayerImpl> pending_layer = | 10320 std::unique_ptr<FakePictureLayerImpl> pending_layer = |
10305 FakePictureLayerImpl::Create(pending_tree, 10); | 10321 FakePictureLayerImpl::Create(pending_tree, 10); |
10306 FakePictureLayerImpl* raw_pending_layer = pending_layer.get(); | 10322 FakePictureLayerImpl* raw_pending_layer = pending_layer.get(); |
10307 pending_tree->SetRootLayer(std::move(pending_layer)); | 10323 pending_tree->SetRootLayerForTesting(std::move(pending_layer)); |
10308 pending_tree->BuildLayerListForTesting(); | 10324 pending_tree->BuildLayerListForTesting(); |
10309 ASSERT_EQ(raw_pending_layer, pending_tree->root_layer()); | 10325 ASSERT_EQ(raw_pending_layer, pending_tree->root_layer_for_testing()); |
10310 | 10326 |
10311 EXPECT_EQ(0u, raw_pending_layer->did_become_active_call_count()); | 10327 EXPECT_EQ(0u, raw_pending_layer->did_become_active_call_count()); |
10312 pending_tree->DidBecomeActive(); | 10328 pending_tree->DidBecomeActive(); |
10313 EXPECT_EQ(1u, raw_pending_layer->did_become_active_call_count()); | 10329 EXPECT_EQ(1u, raw_pending_layer->did_become_active_call_count()); |
10314 | 10330 |
10315 std::unique_ptr<FakePictureLayerImpl> mask_layer = | 10331 std::unique_ptr<FakePictureLayerImpl> mask_layer = |
10316 FakePictureLayerImpl::Create(pending_tree, 11); | 10332 FakePictureLayerImpl::Create(pending_tree, 11); |
10317 FakePictureLayerImpl* raw_mask_layer = mask_layer.get(); | 10333 FakePictureLayerImpl* raw_mask_layer = mask_layer.get(); |
10318 raw_pending_layer->test_properties()->SetMaskLayer(std::move(mask_layer)); | 10334 raw_pending_layer->test_properties()->SetMaskLayer(std::move(mask_layer)); |
10319 ASSERT_EQ(raw_mask_layer, raw_pending_layer->test_properties()->mask_layer); | 10335 ASSERT_EQ(raw_mask_layer, raw_pending_layer->test_properties()->mask_layer); |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10737 | 10753 |
10738 TEST_F(LayerTreeHostImplTest, UpdatePageScaleFactorOnActiveTree) { | 10754 TEST_F(LayerTreeHostImplTest, UpdatePageScaleFactorOnActiveTree) { |
10739 // Check page scale factor update in property trees when an update is made | 10755 // Check page scale factor update in property trees when an update is made |
10740 // on the active tree. | 10756 // on the active tree. |
10741 host_impl_->CreatePendingTree(); | 10757 host_impl_->CreatePendingTree(); |
10742 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 3.f); | 10758 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 3.f); |
10743 CreateScrollAndContentsLayers(host_impl_->pending_tree(), | 10759 CreateScrollAndContentsLayers(host_impl_->pending_tree(), |
10744 gfx::Size(100, 100)); | 10760 gfx::Size(100, 100)); |
10745 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting(); | 10761 host_impl_->pending_tree()->BuildLayerListAndPropertyTreesForTesting(); |
10746 host_impl_->ActivateSyncTree(); | 10762 host_impl_->ActivateSyncTree(); |
| 10763 host_impl_->active_tree()->SetRootLayerFromLayerListForTesting(); |
10747 DrawFrame(); | 10764 DrawFrame(); |
10748 | 10765 |
10749 host_impl_->CreatePendingTree(); | 10766 host_impl_->CreatePendingTree(); |
10750 host_impl_->active_tree()->SetPageScaleOnActiveTree(2.f); | 10767 host_impl_->active_tree()->SetPageScaleOnActiveTree(2.f); |
10751 LayerImpl* page_scale_layer = host_impl_->active_tree()->PageScaleLayer(); | 10768 LayerImpl* page_scale_layer = host_impl_->active_tree()->PageScaleLayer(); |
10752 | 10769 |
10753 TransformNode* active_tree_node = | 10770 TransformNode* active_tree_node = |
10754 host_impl_->active_tree()->property_trees()->transform_tree.Node( | 10771 host_impl_->active_tree()->property_trees()->transform_tree.Node( |
10755 page_scale_layer->transform_tree_index()); | 10772 page_scale_layer->transform_tree_index()); |
10756 // SetPageScaleOnActiveTree also updates the factors in property trees. | 10773 // SetPageScaleOnActiveTree also updates the factors in property trees. |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10896 | 10913 |
10897 // Re-initialize with a software output surface. | 10914 // Re-initialize with a software output surface. |
10898 output_surface_ = FakeOutputSurface::CreateSoftware( | 10915 output_surface_ = FakeOutputSurface::CreateSoftware( |
10899 base::WrapUnique(new SoftwareOutputDevice)); | 10916 base::WrapUnique(new SoftwareOutputDevice)); |
10900 host_impl_->InitializeRenderer(output_surface_.get()); | 10917 host_impl_->InitializeRenderer(output_surface_.get()); |
10901 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 10918 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
10902 } | 10919 } |
10903 | 10920 |
10904 } // namespace | 10921 } // namespace |
10905 } // namespace cc | 10922 } // namespace cc |
OLD | NEW |