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> |
11 #include <utility> | 11 #include <utility> |
12 | 12 |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/location.h" | 15 #include "base/location.h" |
16 #include "base/memory/ptr_util.h" | 16 #include "base/memory/ptr_util.h" |
17 #include "base/run_loop.h" | 17 #include "base/run_loop.h" |
| 18 #include "base/test/histogram_tester.h" |
18 #include "base/threading/thread_task_runner_handle.h" | 19 #include "base/threading/thread_task_runner_handle.h" |
19 #include "cc/animation/animation_host.h" | 20 #include "cc/animation/animation_host.h" |
20 #include "cc/animation/animation_id_provider.h" | 21 #include "cc/animation/animation_id_provider.h" |
21 #include "cc/animation/transform_operations.h" | 22 #include "cc/animation/transform_operations.h" |
22 #include "cc/base/math_util.h" | 23 #include "cc/base/math_util.h" |
23 #include "cc/input/browser_controls_offset_manager.h" | 24 #include "cc/input/browser_controls_offset_manager.h" |
24 #include "cc/input/main_thread_scrolling_reason.h" | 25 #include "cc/input/main_thread_scrolling_reason.h" |
25 #include "cc/input/page_scale_animation.h" | 26 #include "cc/input/page_scale_animation.h" |
26 #include "cc/layers/append_quads_data.h" | 27 #include "cc/layers/append_quads_data.h" |
27 #include "cc/layers/heads_up_display_layer_impl.h" | 28 #include "cc/layers/heads_up_display_layer_impl.h" |
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 ASSERT_EQ(scroll_info->scrolls.size(), 1u); | 748 ASSERT_EQ(scroll_info->scrolls.size(), 1u); |
748 EXPECT_TRUE(ScrollInfoContains(*scroll_info, root->id(), | 749 EXPECT_TRUE(ScrollInfoContains(*scroll_info, root->id(), |
749 scroll_delta + scroll_delta2)); | 750 scroll_delta + scroll_delta2)); |
750 | 751 |
751 root->ScrollBy(gfx::Vector2d()); | 752 root->ScrollBy(gfx::Vector2d()); |
752 scroll_info = host_impl_->ProcessScrollDeltas(); | 753 scroll_info = host_impl_->ProcessScrollDeltas(); |
753 EXPECT_TRUE(ScrollInfoContains(*scroll_info, root->id(), | 754 EXPECT_TRUE(ScrollInfoContains(*scroll_info, root->id(), |
754 scroll_delta + scroll_delta2)); | 755 scroll_delta + scroll_delta2)); |
755 } | 756 } |
756 | 757 |
| 758 TEST_F(LayerTreeHostImplTest, ScrollerSizeOfCCScrollingHistogramRecordingTest) { |
| 759 const gfx::Size content_size(800, 600); |
| 760 const gfx::Size viewport_size(500, 500); |
| 761 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
| 762 |
| 763 LayerImpl* outer_viewport_scroll_layer = |
| 764 host_impl_->active_tree()->OuterViewportScrollLayer(); |
| 765 int id = outer_viewport_scroll_layer->id(); |
| 766 std::unique_ptr<LayerImpl> child = |
| 767 LayerImpl::Create(host_impl_->active_tree(), id + 2); |
| 768 std::unique_ptr<LayerImpl> child_clip = |
| 769 LayerImpl::Create(host_impl_->active_tree(), id + 3); |
| 770 |
| 771 child_clip->SetBounds(gfx::Size(100, 100)); |
| 772 |
| 773 child->SetScrollClipLayer(child_clip->id()); |
| 774 child->SetElementId(LayerIdToElementIdForTesting(child->id())); |
| 775 child->SetBounds(gfx::Size(100, 400)); |
| 776 child->SetPosition(gfx::PointF()); |
| 777 child->SetDrawsContent(true); |
| 778 |
| 779 child_clip->test_properties()->AddChild(std::move(child)); |
| 780 outer_viewport_scroll_layer->test_properties()->AddChild( |
| 781 std::move(child_clip)); |
| 782 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 783 |
| 784 base::HistogramTester histogram_tester; |
| 785 |
| 786 // Test touch scroll. |
| 787 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
| 788 BeginState(gfx::Point()).get(), InputHandler::TOUCHSCREEN); |
| 789 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
| 790 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
| 791 status.main_thread_scrolling_reasons); |
| 792 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
| 793 host_impl_->ScrollEnd(EndState().get()); |
| 794 |
| 795 histogram_tester.ExpectBucketCount("Event.Scroll.ScrollerSize.OnScroll_Touch", |
| 796 10000, 1); |
| 797 histogram_tester.ExpectTotalCount("Event.Scroll.ScrollerSize.OnScroll_Touch", |
| 798 1); |
| 799 |
| 800 // Scrolling root layer doesn't add to count. |
| 801 host_impl_->ScrollBegin(BeginState(gfx::Point(450, 450)).get(), |
| 802 InputHandler::TOUCHSCREEN); |
| 803 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
| 804 host_impl_->ScrollEnd(EndState().get()); |
| 805 histogram_tester.ExpectTotalCount("Event.Scroll.ScrollerSize.OnScroll_Touch", |
| 806 1); |
| 807 |
| 808 // Test wheel scroll. |
| 809 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), InputHandler::WHEEL); |
| 810 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
| 811 host_impl_->ScrollEnd(EndState().get()); |
| 812 histogram_tester.ExpectBucketCount("Event.Scroll.ScrollerSize.OnScroll_Wheel", |
| 813 10000, 1); |
| 814 histogram_tester.ExpectTotalCount("Event.Scroll.ScrollerSize.OnScroll_Wheel", |
| 815 1); |
| 816 } |
| 817 |
757 TEST_F(LayerTreeHostImplTest, ScrollRootCallsCommitAndRedraw) { | 818 TEST_F(LayerTreeHostImplTest, ScrollRootCallsCommitAndRedraw) { |
758 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 819 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
759 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 820 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
760 | 821 |
761 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 822 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
762 DrawFrame(); | 823 DrawFrame(); |
763 | 824 |
764 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 825 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
765 BeginState(gfx::Point()).get(), InputHandler::WHEEL); | 826 BeginState(gfx::Point()).get(), InputHandler::WHEEL); |
766 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 827 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
(...skipping 11550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12317 else | 12378 else |
12318 EXPECT_FALSE(tile->HasRasterTask()); | 12379 EXPECT_FALSE(tile->HasRasterTask()); |
12319 } | 12380 } |
12320 Region expected_invalidation( | 12381 Region expected_invalidation( |
12321 raster_source->GetRectForImage(checkerable_image->uniqueID())); | 12382 raster_source->GetRectForImage(checkerable_image->uniqueID())); |
12322 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); | 12383 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); |
12323 } | 12384 } |
12324 | 12385 |
12325 } // namespace | 12386 } // namespace |
12326 } // namespace cc | 12387 } // namespace cc |
OLD | NEW |