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

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

Issue 2251933002: Fix smooth scroll animation flake on janky pages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix UpdateTarget while animation is not started Created 4 years, 4 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 9791 matching lines...) Expand 10 before | Expand all | Expand 10 after
9802 host_impl_->WillBeginImplFrame(begin_frame_args); 9802 host_impl_->WillBeginImplFrame(begin_frame_args);
9803 host_impl_->Animate(); 9803 host_impl_->Animate();
9804 host_impl_->UpdateAnimationState(true); 9804 host_impl_->UpdateAnimationState(true);
9805 9805
9806 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), 9806 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100),
9807 scrolling_layer->CurrentScrollOffset()); 9807 scrolling_layer->CurrentScrollOffset());
9808 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); 9808 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer());
9809 host_impl_->DidFinishImplFrame(); 9809 host_impl_->DidFinishImplFrame();
9810 } 9810 }
9811 9811
9812 // Verfify that a smooth scroll animation doesn't jump when UpdateTarget gets
9813 // called before the animation is started.
9814 TEST_F(LayerTreeHostImplTest, AnimatedScrollUpdateTargetBeforeStarting) {
9815 const gfx::Size content_size(1000, 1000);
9816 const gfx::Size viewport_size(50, 100);
9817 CreateBasicVirtualViewportLayers(viewport_size, content_size);
9818
9819 DrawFrame();
9820
9821 base::TimeTicks start_time =
9822 base::TimeTicks() + base::TimeDelta::FromMilliseconds(200);
9823
9824 BeginFrameArgs begin_frame_args =
9825 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
9826 begin_frame_args.frame_time = start_time;
9827 host_impl_->WillBeginImplFrame(begin_frame_args);
9828 host_impl_->UpdateAnimationState(true);
9829 host_impl_->DidFinishImplFrame();
9830
9831 EXPECT_EQ(
9832 InputHandler::SCROLL_ON_IMPL_THREAD,
9833 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread);
9834 // This will call ScrollOffsetAnimationCurve::UpdateTarget while the animation
9835 // created above is in state ANIMATION::WAITING_FOR_TARGET_AVAILABILITY and
9836 // doesn't have a start time.
9837 EXPECT_EQ(
9838 InputHandler::SCROLL_ON_IMPL_THREAD,
9839 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100)).thread);
9840
9841 begin_frame_args.frame_time =
9842 start_time + base::TimeDelta::FromMilliseconds(250);
9843 // This is when the animation above gets promoted to STARTING.
9844 host_impl_->WillBeginImplFrame(begin_frame_args);
9845 host_impl_->UpdateAnimationState(true);
9846 host_impl_->DidFinishImplFrame();
9847
9848 begin_frame_args.frame_time =
9849 start_time + base::TimeDelta::FromMilliseconds(300);
9850 // This is when the animation above gets ticked.
9851 host_impl_->WillBeginImplFrame(begin_frame_args);
9852 host_impl_->UpdateAnimationState(true);
9853 host_impl_->DidFinishImplFrame();
9854
9855 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer();
9856 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), scrolling_layer);
9857
9858 // Verify no jump.
9859 float y = scrolling_layer->CurrentScrollOffset().y();
9860 EXPECT_TRUE(y > 1 && y < 49);
9861 }
9862
9812 // Test that a smooth scroll offset animation is aborted when followed by a 9863 // Test that a smooth scroll offset animation is aborted when followed by a
9813 // non-smooth scroll offset animation. 9864 // non-smooth scroll offset animation.
9814 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedAborted) { 9865 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedAborted) {
9815 const gfx::Size content_size(1000, 1000); 9866 const gfx::Size content_size(1000, 1000);
9816 const gfx::Size viewport_size(500, 500); 9867 const gfx::Size viewport_size(500, 500);
9817 CreateBasicVirtualViewportLayers(viewport_size, content_size); 9868 CreateBasicVirtualViewportLayers(viewport_size, content_size);
9818 9869
9819 DrawFrame(); 9870 DrawFrame();
9820 9871
9821 base::TimeTicks start_time = 9872 base::TimeTicks start_time =
(...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after
10894 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); 10945 EXPECT_TRUE(host_impl_->use_gpu_rasterization());
10895 10946
10896 // Re-initialize with a software output surface. 10947 // Re-initialize with a software output surface.
10897 output_surface_ = FakeOutputSurface::CreateDelegatingSoftware(); 10948 output_surface_ = FakeOutputSurface::CreateDelegatingSoftware();
10898 host_impl_->InitializeRenderer(output_surface_.get()); 10949 host_impl_->InitializeRenderer(output_surface_.get());
10899 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); 10950 EXPECT_FALSE(host_impl_->use_gpu_rasterization());
10900 } 10951 }
10901 10952
10902 } // namespace 10953 } // namespace
10903 } // namespace cc 10954 } // namespace cc
OLDNEW
« cc/animation/scroll_offset_animations_impl.cc ('K') | « cc/test/animation_test_common.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698