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

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

Issue 2907053004: GSB uses delta_hints to calculate scrolling chain. (Closed)
Patch Set: debug version Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 histogram_tester.ExpectTotalCount("Event.Scroll.ScrollerSize.OnScroll_Wheel", 823 histogram_tester.ExpectTotalCount("Event.Scroll.ScrollerSize.OnScroll_Wheel",
824 1); 824 1);
825 } 825 }
826 826
827 TEST_F(LayerTreeHostImplTest, ScrollRootCallsCommitAndRedraw) { 827 TEST_F(LayerTreeHostImplTest, ScrollRootCallsCommitAndRedraw) {
828 SetupScrollAndContentsLayers(gfx::Size(100, 100)); 828 SetupScrollAndContentsLayers(gfx::Size(100, 100));
829 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 829 host_impl_->active_tree()->BuildPropertyTreesForTesting();
830 830
831 host_impl_->SetViewportSize(gfx::Size(50, 50)); 831 host_impl_->SetViewportSize(gfx::Size(50, 50));
832 DrawFrame(); 832 DrawFrame();
833 833 LOG(ERROR) << "Scroll begin";
834 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( 834 InputHandler::ScrollStatus status = host_impl_->ScrollBegin(
835 BeginState(gfx::Point()).get(), InputHandler::WHEEL); 835 BeginState(gfx::Point()).get(), InputHandler::WHEEL);
836 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 836 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
837 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, 837 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
838 status.main_thread_scrolling_reasons); 838 status.main_thread_scrolling_reasons);
839 839
840 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), 840 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(),
841 InputHandler::WHEEL)); 841 InputHandler::WHEEL));
842 LOG(ERROR) << "SCroll By";
842 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); 843 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get());
843 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, 10), 844 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, 10),
844 InputHandler::WHEEL)); 845 InputHandler::WHEEL));
846 LOG(ERROR) << "scroll end";
845 host_impl_->ScrollEnd(EndState().get()); 847 host_impl_->ScrollEnd(EndState().get());
846 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), 848 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(),
847 InputHandler::WHEEL)); 849 InputHandler::WHEEL));
848 EXPECT_TRUE(did_request_redraw_); 850 EXPECT_TRUE(did_request_redraw_);
849 EXPECT_TRUE(did_request_commit_); 851 EXPECT_TRUE(did_request_commit_);
850 } 852 }
851 853
852 TEST_F(LayerTreeHostImplTest, ScrollActiveOnlyAfterScrollMovement) { 854 TEST_F(LayerTreeHostImplTest, ScrollActiveOnlyAfterScrollMovement) {
853 SetupScrollAndContentsLayers(gfx::Size(100, 100)); 855 SetupScrollAndContentsLayers(gfx::Size(100, 100));
854 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 856 host_impl_->active_tree()->BuildPropertyTreesForTesting();
(...skipping 5187 matching lines...) Expand 10 before | Expand all | Expand 10 after
6042 expected_scroll_delta)); 6044 expected_scroll_delta));
6043 6045
6044 // The root scroll layer should not have scrolled, because the input delta 6046 // The root scroll layer should not have scrolled, because the input delta
6045 // was close to the layer's axis of movement. 6047 // was close to the layer's axis of movement.
6046 EXPECT_EQ(scroll_info->scrolls.size(), 1u); 6048 EXPECT_EQ(scroll_info->scrolls.size(), 1u);
6047 } 6049 }
6048 { 6050 {
6049 // Now reset and scroll the same amount horizontally. 6051 // Now reset and scroll the same amount horizontally.
6050 SetScrollOffsetDelta(child_ptr, gfx::Vector2dF()); 6052 SetScrollOffsetDelta(child_ptr, gfx::Vector2dF());
6051 gfx::Vector2d gesture_scroll_delta(10, 0); 6053 gfx::Vector2d gesture_scroll_delta(10, 0);
6054 LOG(ERROR) << "scroll begin:\n";
6052 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 6055 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
6053 host_impl_ 6056 host_impl_
6054 ->ScrollBegin(BeginState(gfx::Point(1, 1)).get(), 6057 ->ScrollBegin(BeginState(gfx::Point()).get(),
6055 InputHandler::TOUCHSCREEN) 6058 InputHandler::TOUCHSCREEN)
6056 .thread); 6059 .thread);
6060 LOG(ERROR) << "\nscroll by:\n";
6057 host_impl_->ScrollBy(UpdateState(gfx::Point(), gesture_scroll_delta).get()); 6061 host_impl_->ScrollBy(UpdateState(gfx::Point(), gesture_scroll_delta).get());
6062 LOG(ERROR) << "\nscroll begin:\n";
6058 host_impl_->ScrollEnd(EndState().get()); 6063 host_impl_->ScrollEnd(EndState().get());
6059 6064
6060 // The child layer shouldn't have scrolled. 6065 // The child layer shouldn't have scrolled.
6061 gfx::Vector2d expected_scroll_delta( 6066 gfx::Vector2d expected_scroll_delta(
6062 0, -gesture_scroll_delta.x() * 6067 0, -gesture_scroll_delta.x() *
6063 std::sin(MathUtil::Deg2Rad(child_layer_angle))); 6068 std::sin(MathUtil::Deg2Rad(child_layer_angle)));
6064 std::unique_ptr<ScrollAndScaleSet> scroll_info = 6069 std::unique_ptr<ScrollAndScaleSet> scroll_info =
6065 host_impl_->ProcessScrollDeltas(); 6070 host_impl_->ProcessScrollDeltas();
6066 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child_layer_id, 6071 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child_layer_id,
6067 expected_scroll_delta)); 6072 expected_scroll_delta));
(...skipping 3685 matching lines...) Expand 10 before | Expand all | Expand 10 after
9753 // Verifies that the overscroll delta should not have accumulated in 9758 // Verifies that the overscroll delta should not have accumulated in
9754 // the browser controls if we do a hide and show without releasing finger. 9759 // the browser controls if we do a hide and show without releasing finger.
9755 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); 9760 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200));
9756 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 9761 host_impl_->active_tree()->BuildPropertyTreesForTesting();
9757 9762
9758 host_impl_->SetViewportSize(gfx::Size(100, 100)); 9763 host_impl_->SetViewportSize(gfx::Size(100, 100));
9759 host_impl_->browser_controls_manager()->UpdateBrowserControlsState( 9764 host_impl_->browser_controls_manager()->UpdateBrowserControlsState(
9760 BOTH, SHOWN, false); 9765 BOTH, SHOWN, false);
9761 DrawFrame(); 9766 DrawFrame();
9762 9767
9768 LOG(ERROR) << "\nscroll begin:\n";
9763 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 9769 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
9764 host_impl_ 9770 host_impl_
9765 ->ScrollBegin(BeginState(gfx::Point()).get(), 9771 ->ScrollBegin(BeginState(gfx::Point()).get(),
9766 InputHandler::TOUCHSCREEN) 9772 InputHandler::TOUCHSCREEN)
9767 .thread); 9773 .thread);
9768 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset()); 9774 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset());
9769 9775
9770 float offset = 50; 9776 float offset = 50;
9777 LOG(ERROR) << "\nscroll by 1:\n";
9771 EXPECT_TRUE( 9778 EXPECT_TRUE(
9772 host_impl_ 9779 host_impl_
9773 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) 9780 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get())
9774 .did_scroll); 9781 .did_scroll);
9775 EXPECT_EQ(-offset, 9782 EXPECT_EQ(-offset,
9776 host_impl_->browser_controls_manager()->ControlsTopOffset()); 9783 host_impl_->browser_controls_manager()->ControlsTopOffset());
9777 EXPECT_EQ(gfx::Vector2dF().ToString(), 9784 EXPECT_EQ(gfx::Vector2dF().ToString(),
9778 scroll_layer->CurrentScrollOffset().ToString()); 9785 scroll_layer->CurrentScrollOffset().ToString());
9779 9786 LOG(ERROR) << "\nscroll by 2:\n";
9780 EXPECT_TRUE( 9787 EXPECT_TRUE(
9781 host_impl_ 9788 host_impl_
9782 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) 9789 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get())
9783 .did_scroll); 9790 .did_scroll);
9784 EXPECT_EQ(gfx::Vector2dF(0, offset).ToString(), 9791 EXPECT_EQ(gfx::Vector2dF(0, offset).ToString(),
9785 scroll_layer->CurrentScrollOffset().ToString()); 9792 scroll_layer->CurrentScrollOffset().ToString());
9786 9793 LOG(ERROR) << "\nscroll by 3:\n";
9787 EXPECT_TRUE( 9794 EXPECT_TRUE(
9788 host_impl_ 9795 host_impl_
9789 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) 9796 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get())
9790 .did_scroll); 9797 .did_scroll);
9791 9798
9792 // Should have fully scrolled 9799 // Should have fully scrolled
9793 EXPECT_EQ(gfx::Vector2dF(0, scroll_layer->MaxScrollOffset().y()).ToString(), 9800 EXPECT_EQ(gfx::Vector2dF(0, scroll_layer->MaxScrollOffset().y()).ToString(),
9794 scroll_layer->CurrentScrollOffset().ToString()); 9801 scroll_layer->CurrentScrollOffset().ToString());
9795 9802
9796 float overscrollamount = 10; 9803 float overscrollamount = 10;
9797 9804 LOG(ERROR) << "\nscroll by 4:\n";
9798 // Overscroll the content 9805 // Overscroll the content
9799 EXPECT_FALSE(host_impl_ 9806 EXPECT_FALSE(host_impl_
9800 ->ScrollBy(UpdateState(gfx::Point(), 9807 ->ScrollBy(UpdateState(gfx::Point(),
9801 gfx::Vector2d(0, overscrollamount)) 9808 gfx::Vector2d(0, overscrollamount))
9802 .get()) 9809 .get())
9803 .did_scroll); 9810 .did_scroll);
9804 EXPECT_EQ(gfx::Vector2dF(0, 2 * offset).ToString(), 9811 EXPECT_EQ(gfx::Vector2dF(0, 2 * offset).ToString(),
9805 scroll_layer->CurrentScrollOffset().ToString()); 9812 scroll_layer->CurrentScrollOffset().ToString());
9806 EXPECT_EQ(gfx::Vector2dF(0, overscrollamount).ToString(), 9813 EXPECT_EQ(gfx::Vector2dF(0, overscrollamount).ToString(),
9807 host_impl_->accumulated_root_overscroll().ToString()); 9814 host_impl_->accumulated_root_overscroll().ToString());
9808 9815 LOG(ERROR) << "\nscroll by 5:\n";
9809 EXPECT_TRUE( 9816 EXPECT_TRUE(
9810 host_impl_ 9817 host_impl_
9811 ->ScrollBy( 9818 ->ScrollBy(
9812 UpdateState(gfx::Point(), gfx::Vector2d(0, -2 * offset)).get()) 9819 UpdateState(gfx::Point(), gfx::Vector2d(0, -2 * offset)).get())
9813 .did_scroll); 9820 .did_scroll);
9814 EXPECT_EQ(gfx::Vector2dF(0, 0).ToString(), 9821 EXPECT_EQ(gfx::Vector2dF(0, 0).ToString(),
9815 scroll_layer->CurrentScrollOffset().ToString()); 9822 scroll_layer->CurrentScrollOffset().ToString());
9816 EXPECT_EQ(-offset, 9823 EXPECT_EQ(-offset,
9817 host_impl_->browser_controls_manager()->ControlsTopOffset()); 9824 host_impl_->browser_controls_manager()->ControlsTopOffset());
9818 9825 LOG(ERROR) << "\nscroll by 6:\n";
9819 EXPECT_TRUE( 9826 EXPECT_TRUE(
9820 host_impl_ 9827 host_impl_
9821 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, -offset)).get()) 9828 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, -offset)).get())
9822 .did_scroll); 9829 .did_scroll);
9823 EXPECT_EQ(gfx::Vector2dF(0, 0).ToString(), 9830 EXPECT_EQ(gfx::Vector2dF(0, 0).ToString(),
9824 scroll_layer->CurrentScrollOffset().ToString()); 9831 scroll_layer->CurrentScrollOffset().ToString());
9825 9832
9826 // Browser controls should be fully visible 9833 // Browser controls should be fully visible
9827 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset()); 9834 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset());
9828 9835 LOG(ERROR) << "\nscroll end:\n";
9829 host_impl_->ScrollEnd(EndState().get()); 9836 host_impl_->ScrollEnd(EndState().get());
9830 } 9837 }
9831 9838
9832 // Tests that when we set a child scroller (e.g. a scrolling div) as the outer 9839 // Tests that when we set a child scroller (e.g. a scrolling div) as the outer
9833 // viewport, scrolling it controls the browser controls. 9840 // viewport, scrolling it controls the browser controls.
9834 TEST_F(LayerTreeHostImplBrowserControlsTest, 9841 TEST_F(LayerTreeHostImplBrowserControlsTest,
9835 ReplacedOuterViewportScrollsBrowserControls) { 9842 ReplacedOuterViewportScrollsBrowserControls) {
9836 const gfx::Size scroll_content_size(400, 400); 9843 const gfx::Size scroll_content_size(400, 400);
9837 const gfx::Size root_layer_size(200, 200); 9844 const gfx::Size root_layer_size(200, 200);
9838 const gfx::Size viewport_size(100, 100); 9845 const gfx::Size viewport_size(100, 100);
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after
10819 scrolling_layer->CurrentScrollOffset()); 10826 scrolling_layer->CurrentScrollOffset());
10820 EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingNode()); 10827 EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingNode());
10821 host_impl_->DidFinishImplFrame(); 10828 host_impl_->DidFinishImplFrame();
10822 } 10829 }
10823 10830
10824 TEST_F(LayerTreeHostImplTest, SecondScrollAnimatedBeginNotIgnored) { 10831 TEST_F(LayerTreeHostImplTest, SecondScrollAnimatedBeginNotIgnored) {
10825 const gfx::Size content_size(1000, 1000); 10832 const gfx::Size content_size(1000, 1000);
10826 const gfx::Size viewport_size(50, 100); 10833 const gfx::Size viewport_size(50, 100);
10827 CreateBasicVirtualViewportLayers(viewport_size, content_size); 10834 CreateBasicVirtualViewportLayers(viewport_size, content_size);
10828 10835
10829 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 10836 EXPECT_EQ(
10830 host_impl_->ScrollAnimatedBegin(gfx::Point()).thread); 10837 InputHandler::SCROLL_ON_IMPL_THREAD,
10838 host_impl_->ScrollAnimatedBegin(BeginState(gfx::Point()).get()).thread);
10831 10839
10832 // The second ScrollAnimatedBegin should not get ignored. 10840 // The second ScrollAnimatedBegin should not get ignored.
10833 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 10841 EXPECT_EQ(
10834 host_impl_->ScrollAnimatedBegin(gfx::Point()).thread); 10842 InputHandler::SCROLL_ON_IMPL_THREAD,
10843 host_impl_->ScrollAnimatedBegin(BeginState(gfx::Point()).get()).thread);
10835 } 10844 }
10836 10845
10837 // Verfify that a smooth scroll animation doesn't jump when UpdateTarget gets 10846 // Verfify that a smooth scroll animation doesn't jump when UpdateTarget gets
10838 // called before the animation is started. 10847 // called before the animation is started.
10839 TEST_F(LayerTreeHostImplTest, AnimatedScrollUpdateTargetBeforeStarting) { 10848 TEST_F(LayerTreeHostImplTest, AnimatedScrollUpdateTargetBeforeStarting) {
10840 const gfx::Size content_size(1000, 1000); 10849 const gfx::Size content_size(1000, 1000);
10841 const gfx::Size viewport_size(50, 100); 10850 const gfx::Size viewport_size(50, 100);
10842 CreateBasicVirtualViewportLayers(viewport_size, content_size); 10851 CreateBasicVirtualViewportLayers(viewport_size, content_size);
10843 10852
10844 DrawFrame(); 10853 DrawFrame();
(...skipping 1695 matching lines...) Expand 10 before | Expand all | Expand 10 after
12540 // layer should be prioritized over the hidden layer. 12549 // layer should be prioritized over the hidden layer.
12541 hidden_layer->set_contributes_to_drawn_render_surface(false); 12550 hidden_layer->set_contributes_to_drawn_render_surface(false);
12542 hidden_layer->set_raster_even_if_not_drawn(true); 12551 hidden_layer->set_raster_even_if_not_drawn(true);
12543 queue = host_impl_->BuildRasterQueue(TreePriority::SMOOTHNESS_TAKES_PRIORITY, 12552 queue = host_impl_->BuildRasterQueue(TreePriority::SMOOTHNESS_TAKES_PRIORITY,
12544 RasterTilePriorityQueue::Type::ALL); 12553 RasterTilePriorityQueue::Type::ALL);
12545 EXPECT_EQ(queue->Top().tile()->layer_id(), 3); 12554 EXPECT_EQ(queue->Top().tile()->layer_id(), 3);
12546 } 12555 }
12547 12556
12548 } // namespace 12557 } // namespace
12549 } // namespace cc 12558 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698