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

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

Issue 2040543002: Take MT jank into account when animating the scroll offset on CC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unused plumbing 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 10027 matching lines...) Expand 10 before | Expand all | Expand 10 after
10038 host_impl_->DidFinishImplFrame(); 10038 host_impl_->DidFinishImplFrame();
10039 10039
10040 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); 10040 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer();
10041 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), scrolling_layer); 10041 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), scrolling_layer);
10042 10042
10043 // Verify no jump. 10043 // Verify no jump.
10044 float y = scrolling_layer->CurrentScrollOffset().y(); 10044 float y = scrolling_layer->CurrentScrollOffset().y();
10045 EXPECT_TRUE(y > 1 && y < 49); 10045 EXPECT_TRUE(y > 1 && y < 49);
10046 } 10046 }
10047 10047
10048 TEST_F(LayerTreeHostImplTest, ScrollAnimatedWithDelay) {
10049 const gfx::Size content_size(1000, 1000);
10050 const gfx::Size viewport_size(50, 100);
10051 CreateBasicVirtualViewportLayers(viewport_size, content_size);
10052
10053 DrawFrame();
10054
10055 base::TimeTicks start_time =
10056 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100);
10057 BeginFrameArgs begin_frame_args =
10058 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
10059
10060 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
10061 host_impl_
10062 ->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100),
10063 base::TimeDelta::FromMilliseconds(100))
tdresser 2016/08/25 15:55:54 Comment on added delay.
ymalik 2016/08/29 14:52:05 Done.
10064 .thread);
10065 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer();
10066 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), scrolling_layer);
10067
10068 // First tick, animation is started.
10069 begin_frame_args.frame_time = start_time;
10070 host_impl_->WillBeginImplFrame(begin_frame_args);
10071 host_impl_->UpdateAnimationState(true);
10072 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset());
10073 host_impl_->DidFinishImplFrame();
10074
10075 // Second tick after 50ms, animation should be half way done since
10076 // the duration due to delay is 100ms.
10077 begin_frame_args.frame_time =
10078 start_time + base::TimeDelta::FromMilliseconds(50);
10079 host_impl_->WillBeginImplFrame(begin_frame_args);
10080 host_impl_->UpdateAnimationState(true);
10081 EXPECT_EQ(50, scrolling_layer->CurrentScrollOffset().y());
10082 host_impl_->DidFinishImplFrame();
10083
10084 // Update target.
10085 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
10086 host_impl_
10087 ->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100),
10088 base::TimeDelta::FromMilliseconds(150))
10089 .thread);
10090
10091 // Third tick after 100ms, should be at the target position since update
10092 // target was called with a large value of jank.
10093 begin_frame_args.frame_time =
10094 start_time + base::TimeDelta::FromMilliseconds(100);
10095 host_impl_->WillBeginImplFrame(begin_frame_args);
10096 host_impl_->UpdateAnimationState(true);
10097 EXPECT_EQ(200, scrolling_layer->CurrentScrollOffset().y());
10098 }
10099
10048 // Test that a smooth scroll offset animation is aborted when followed by a 10100 // Test that a smooth scroll offset animation is aborted when followed by a
10049 // non-smooth scroll offset animation. 10101 // non-smooth scroll offset animation.
10050 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedAborted) { 10102 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedAborted) {
10051 const gfx::Size content_size(1000, 1000); 10103 const gfx::Size content_size(1000, 1000);
10052 const gfx::Size viewport_size(500, 500); 10104 const gfx::Size viewport_size(500, 500);
10053 CreateBasicVirtualViewportLayers(viewport_size, content_size); 10105 CreateBasicVirtualViewportLayers(viewport_size, content_size);
10054 10106
10055 DrawFrame(); 10107 DrawFrame();
10056 10108
10057 base::TimeTicks start_time = 10109 base::TimeTicks start_time =
(...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after
11138 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); 11190 EXPECT_TRUE(host_impl_->use_gpu_rasterization());
11139 11191
11140 // Re-initialize with a software output surface. 11192 // Re-initialize with a software output surface.
11141 output_surface_ = FakeOutputSurface::CreateDelegatingSoftware(); 11193 output_surface_ = FakeOutputSurface::CreateDelegatingSoftware();
11142 host_impl_->InitializeRenderer(output_surface_.get()); 11194 host_impl_->InitializeRenderer(output_surface_.get());
11143 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); 11195 EXPECT_FALSE(host_impl_->use_gpu_rasterization());
11144 } 11196 }
11145 11197
11146 } // namespace 11198 } // namespace
11147 } // namespace cc 11199 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698