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

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

Issue 2863103002: Reduce composited smooth scroll latency by a frame (also fixes latency UMAs). (Closed)
Patch Set: Cleanup. Created 3 years, 7 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
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest_animation.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 5623 matching lines...) Expand 10 before | Expand all | Expand 10 after
5634 EXPECT_EQ( 5634 EXPECT_EQ(
5635 InputHandler::SCROLL_ON_IMPL_THREAD, 5635 InputHandler::SCROLL_ON_IMPL_THREAD,
5636 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, -100)).thread); 5636 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, -100)).thread);
5637 5637
5638 begin_frame_args.frame_time = start_time; 5638 begin_frame_args.frame_time = start_time;
5639 begin_frame_args.sequence_number++; 5639 begin_frame_args.sequence_number++;
5640 host_impl_->WillBeginImplFrame(begin_frame_args); 5640 host_impl_->WillBeginImplFrame(begin_frame_args);
5641 host_impl_->Animate(); 5641 host_impl_->Animate();
5642 host_impl_->UpdateAnimationState(true); 5642 host_impl_->UpdateAnimationState(true);
5643 5643
5644 EXPECT_EQ(gfx::ScrollOffset(0, 30), grand_child_layer->CurrentScrollOffset()); 5644 // Should have started scrolling.
5645 EXPECT_NE(gfx::ScrollOffset(0, 30), grand_child_layer->CurrentScrollOffset());
5645 host_impl_->DidFinishImplFrame(); 5646 host_impl_->DidFinishImplFrame();
5646 5647
5647 begin_frame_args.frame_time = 5648 begin_frame_args.frame_time =
5648 start_time + base::TimeDelta::FromMilliseconds(200); 5649 start_time + base::TimeDelta::FromMilliseconds(200);
5649 begin_frame_args.sequence_number++; 5650 begin_frame_args.sequence_number++;
5650 host_impl_->WillBeginImplFrame(begin_frame_args); 5651 host_impl_->WillBeginImplFrame(begin_frame_args);
5651 host_impl_->Animate(); 5652 host_impl_->Animate();
5652 host_impl_->UpdateAnimationState(true); 5653 host_impl_->UpdateAnimationState(true);
5653 5654
5654 EXPECT_EQ(gfx::ScrollOffset(0, 0), grand_child_layer->CurrentScrollOffset()); 5655 EXPECT_EQ(gfx::ScrollOffset(0, 0), grand_child_layer->CurrentScrollOffset());
(...skipping 5097 matching lines...) Expand 10 before | Expand all | Expand 10 after
10752 LayerImpl* scrolling_layer = host_impl_->OuterViewportScrollLayer(); 10753 LayerImpl* scrolling_layer = host_impl_->OuterViewportScrollLayer();
10753 EXPECT_EQ(scrolling_layer->scroll_tree_index(), 10754 EXPECT_EQ(scrolling_layer->scroll_tree_index(),
10754 host_impl_->CurrentlyScrollingNode()->id); 10755 host_impl_->CurrentlyScrollingNode()->id);
10755 10756
10756 begin_frame_args.frame_time = start_time; 10757 begin_frame_args.frame_time = start_time;
10757 begin_frame_args.sequence_number++; 10758 begin_frame_args.sequence_number++;
10758 host_impl_->WillBeginImplFrame(begin_frame_args); 10759 host_impl_->WillBeginImplFrame(begin_frame_args);
10759 host_impl_->Animate(); 10760 host_impl_->Animate();
10760 host_impl_->UpdateAnimationState(true); 10761 host_impl_->UpdateAnimationState(true);
10761 10762
10762 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); 10763 EXPECT_NE(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset());
10763 host_impl_->DidFinishImplFrame(); 10764 host_impl_->DidFinishImplFrame();
10764 10765
10765 begin_frame_args.frame_time = 10766 begin_frame_args.frame_time =
10766 start_time + base::TimeDelta::FromMilliseconds(50); 10767 start_time + base::TimeDelta::FromMilliseconds(50);
10767 begin_frame_args.sequence_number++; 10768 begin_frame_args.sequence_number++;
10768 host_impl_->WillBeginImplFrame(begin_frame_args); 10769 host_impl_->WillBeginImplFrame(begin_frame_args);
10769 host_impl_->Animate(); 10770 host_impl_->Animate();
10770 host_impl_->UpdateAnimationState(true); 10771 host_impl_->UpdateAnimationState(true);
10771 10772
10772 float y = scrolling_layer->CurrentScrollOffset().y(); 10773 float y = scrolling_layer->CurrentScrollOffset().y();
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
10893 10894
10894 LayerImpl* scrolling_layer = host_impl_->OuterViewportScrollLayer(); 10895 LayerImpl* scrolling_layer = host_impl_->OuterViewportScrollLayer();
10895 EXPECT_EQ(scrolling_layer->scroll_tree_index(), 10896 EXPECT_EQ(scrolling_layer->scroll_tree_index(),
10896 host_impl_->CurrentlyScrollingNode()->id); 10897 host_impl_->CurrentlyScrollingNode()->id);
10897 10898
10898 // First tick, animation is started. 10899 // First tick, animation is started.
10899 begin_frame_args.frame_time = start_time; 10900 begin_frame_args.frame_time = start_time;
10900 begin_frame_args.sequence_number++; 10901 begin_frame_args.sequence_number++;
10901 host_impl_->WillBeginImplFrame(begin_frame_args); 10902 host_impl_->WillBeginImplFrame(begin_frame_args);
10902 host_impl_->UpdateAnimationState(true); 10903 host_impl_->UpdateAnimationState(true);
10903 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); 10904 EXPECT_NE(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset());
10904 host_impl_->DidFinishImplFrame(); 10905 host_impl_->DidFinishImplFrame();
10905 10906
10906 // Second tick after 50ms, animation should be half way done since 10907 // Second tick after 50ms, animation should be half way done since the
10907 // the duration due to delay is 100ms. 10908 // duration due to delay is 100ms. Subtract off the frame interval since we
10908 begin_frame_args.frame_time = 10909 // progress a full frame on the first tick.
10909 start_time + base::TimeDelta::FromMilliseconds(50); 10910 base::TimeTicks half_way_time = start_time - begin_frame_args.interval +
10911 base::TimeDelta::FromMilliseconds(50);
10912 begin_frame_args.frame_time = half_way_time;
10910 begin_frame_args.sequence_number++; 10913 begin_frame_args.sequence_number++;
10911 host_impl_->WillBeginImplFrame(begin_frame_args); 10914 host_impl_->WillBeginImplFrame(begin_frame_args);
10912 host_impl_->UpdateAnimationState(true); 10915 host_impl_->UpdateAnimationState(true);
10913 EXPECT_EQ(50, scrolling_layer->CurrentScrollOffset().y()); 10916 EXPECT_EQ(50, scrolling_layer->CurrentScrollOffset().y());
10914 host_impl_->DidFinishImplFrame(); 10917 host_impl_->DidFinishImplFrame();
10915 10918
10916 // Update target. 10919 // Update target.
10917 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 10920 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
10918 host_impl_ 10921 host_impl_
10919 ->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100), 10922 ->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100),
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
10956 10959
10957 begin_frame_args.frame_time = start_time; 10960 begin_frame_args.frame_time = start_time;
10958 begin_frame_args.sequence_number++; 10961 begin_frame_args.sequence_number++;
10959 host_impl_->WillBeginImplFrame(begin_frame_args); 10962 host_impl_->WillBeginImplFrame(begin_frame_args);
10960 host_impl_->Animate(); 10963 host_impl_->Animate();
10961 host_impl_->UpdateAnimationState(true); 10964 host_impl_->UpdateAnimationState(true);
10962 10965
10963 EXPECT_TRUE(GetImplAnimationHost()->HasAnyAnimationTargetingProperty( 10966 EXPECT_TRUE(GetImplAnimationHost()->HasAnyAnimationTargetingProperty(
10964 scrolling_layer->element_id(), TargetProperty::SCROLL_OFFSET)); 10967 scrolling_layer->element_id(), TargetProperty::SCROLL_OFFSET));
10965 10968
10966 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); 10969 EXPECT_NE(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset());
10967 host_impl_->DidFinishImplFrame(); 10970 host_impl_->DidFinishImplFrame();
10968 10971
10969 begin_frame_args.frame_time = 10972 begin_frame_args.frame_time =
10970 start_time + base::TimeDelta::FromMilliseconds(50); 10973 start_time + base::TimeDelta::FromMilliseconds(50);
10971 begin_frame_args.sequence_number++; 10974 begin_frame_args.sequence_number++;
10972 host_impl_->WillBeginImplFrame(begin_frame_args); 10975 host_impl_->WillBeginImplFrame(begin_frame_args);
10973 host_impl_->Animate(); 10976 host_impl_->Animate();
10974 host_impl_->UpdateAnimationState(true); 10977 host_impl_->UpdateAnimationState(true);
10975 10978
10976 float y = scrolling_layer->CurrentScrollOffset().y(); 10979 float y = scrolling_layer->CurrentScrollOffset().y();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
11025 LayerImpl* scrolling_layer = host_impl_->OuterViewportScrollLayer(); 11028 LayerImpl* scrolling_layer = host_impl_->OuterViewportScrollLayer();
11026 EXPECT_EQ(scrolling_layer->scroll_tree_index(), 11029 EXPECT_EQ(scrolling_layer->scroll_tree_index(),
11027 host_impl_->CurrentlyScrollingNode()->id); 11030 host_impl_->CurrentlyScrollingNode()->id);
11028 11031
11029 begin_frame_args.frame_time = start_time; 11032 begin_frame_args.frame_time = start_time;
11030 begin_frame_args.sequence_number++; 11033 begin_frame_args.sequence_number++;
11031 host_impl_->WillBeginImplFrame(begin_frame_args); 11034 host_impl_->WillBeginImplFrame(begin_frame_args);
11032 host_impl_->Animate(); 11035 host_impl_->Animate();
11033 host_impl_->UpdateAnimationState(true); 11036 host_impl_->UpdateAnimationState(true);
11034 11037
11035 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); 11038 EXPECT_NE(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset());
11036 host_impl_->DidFinishImplFrame(); 11039 host_impl_->DidFinishImplFrame();
11037 11040
11038 begin_frame_args.frame_time = 11041 begin_frame_args.frame_time =
11039 start_time + base::TimeDelta::FromMilliseconds(50); 11042 start_time + base::TimeDelta::FromMilliseconds(50);
11040 begin_frame_args.sequence_number++; 11043 begin_frame_args.sequence_number++;
11041 host_impl_->WillBeginImplFrame(begin_frame_args); 11044 host_impl_->WillBeginImplFrame(begin_frame_args);
11042 host_impl_->Animate(); 11045 host_impl_->Animate();
11043 host_impl_->UpdateAnimationState(true); 11046 host_impl_->UpdateAnimationState(true);
11044 11047
11045 float y = scrolling_layer->CurrentScrollOffset().y(); 11048 float y = scrolling_layer->CurrentScrollOffset().y();
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
11261 LayerImpl* scrolling_layer = host_impl_->OuterViewportScrollLayer(); 11264 LayerImpl* scrolling_layer = host_impl_->OuterViewportScrollLayer();
11262 EXPECT_EQ(scrolling_layer->scroll_tree_index(), 11265 EXPECT_EQ(scrolling_layer->scroll_tree_index(),
11263 host_impl_->CurrentlyScrollingNode()->id); 11266 host_impl_->CurrentlyScrollingNode()->id);
11264 11267
11265 begin_frame_args.frame_time = start_time; 11268 begin_frame_args.frame_time = start_time;
11266 begin_frame_args.sequence_number++; 11269 begin_frame_args.sequence_number++;
11267 host_impl_->WillBeginImplFrame(begin_frame_args); 11270 host_impl_->WillBeginImplFrame(begin_frame_args);
11268 host_impl_->Animate(); 11271 host_impl_->Animate();
11269 host_impl_->UpdateAnimationState(true); 11272 host_impl_->UpdateAnimationState(true);
11270 11273
11271 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); 11274 EXPECT_NE(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset());
11272 host_impl_->DidFinishImplFrame(); 11275 host_impl_->DidFinishImplFrame();
11273 11276
11274 begin_frame_args.frame_time = 11277 begin_frame_args.frame_time =
11275 start_time + base::TimeDelta::FromMilliseconds(50); 11278 start_time + base::TimeDelta::FromMilliseconds(50);
11276 begin_frame_args.sequence_number++; 11279 begin_frame_args.sequence_number++;
11277 host_impl_->WillBeginImplFrame(begin_frame_args); 11280 host_impl_->WillBeginImplFrame(begin_frame_args);
11278 host_impl_->Animate(); 11281 host_impl_->Animate();
11279 host_impl_->UpdateAnimationState(true); 11282 host_impl_->UpdateAnimationState(true);
11280 11283
11281 // Should not have scrolled horizontally. 11284 // Should not have scrolled horizontally.
(...skipping 1095 matching lines...) Expand 10 before | Expand all | Expand 10 after
12377 else 12380 else
12378 EXPECT_FALSE(tile->HasRasterTask()); 12381 EXPECT_FALSE(tile->HasRasterTask());
12379 } 12382 }
12380 Region expected_invalidation( 12383 Region expected_invalidation(
12381 raster_source->GetRectForImage(checkerable_image->uniqueID())); 12384 raster_source->GetRectForImage(checkerable_image->uniqueID()));
12382 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); 12385 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation()));
12383 } 12386 }
12384 12387
12385 } // namespace 12388 } // namespace
12386 } // namespace cc 12389 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest_animation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698