Chromium Code Reviews| Index: ui/compositor/layer_animation_element.cc |
| diff --git a/ui/compositor/layer_animation_element.cc b/ui/compositor/layer_animation_element.cc |
| index b446b7ad9d8248256f2f88e8b3ea5c7156fd6dbe..5b83b7883fd0d5c1be0dfc18ee0a025a5ce27e0e 100644 |
| --- a/ui/compositor/layer_animation_element.cc |
| +++ b/ui/compositor/layer_animation_element.cc |
| @@ -447,8 +447,8 @@ LayerAnimationElement::TargetValue::TargetValue( |
| // LayerAnimationElement ------------------------------------------------------- |
| -LayerAnimationElement::LayerAnimationElement( |
| - AnimatableProperties properties, base::TimeDelta duration) |
| +LayerAnimationElement::LayerAnimationElement(AnimatableProperties properties, |
| + base::TimeDelta duration) |
| : first_frame_(true), |
| properties_(properties), |
| duration_(GetEffectiveDuration(duration)), |
| @@ -456,11 +456,12 @@ LayerAnimationElement::LayerAnimationElement( |
| animation_id_(cc::AnimationIdProvider::NextAnimationId()), |
| animation_group_id_(0), |
| last_progressed_fraction_(0.0), |
| - weak_ptr_factory_(this) { |
| -} |
| + animation_metrics_reporter_(nullptr), |
| + start_frame_number_(0), |
| + weak_ptr_factory_(this) {} |
| LayerAnimationElement::LayerAnimationElement( |
| - const LayerAnimationElement &element) |
| + const LayerAnimationElement& element) |
| : first_frame_(element.first_frame_), |
| properties_(element.properties_), |
| duration_(element.duration_), |
| @@ -468,8 +469,9 @@ LayerAnimationElement::LayerAnimationElement( |
| animation_id_(cc::AnimationIdProvider::NextAnimationId()), |
| animation_group_id_(element.animation_group_id_), |
| last_progressed_fraction_(element.last_progressed_fraction_), |
| - weak_ptr_factory_(this) { |
| -} |
| + animation_metrics_reporter_(nullptr), |
| + start_frame_number_(0), |
| + weak_ptr_factory_(this) {} |
| LayerAnimationElement::~LayerAnimationElement() { |
| } |
| @@ -481,6 +483,8 @@ void LayerAnimationElement::Start(LayerAnimationDelegate* delegate, |
| animation_group_id_ = animation_group_id; |
| last_progressed_fraction_ = 0.0; |
| OnStart(delegate); |
| + if (delegate) |
| + start_frame_number_ = delegate->GetFrameNumber(); |
| RequestEffectiveStart(delegate); |
| first_frame_ = false; |
| } |
| @@ -534,10 +538,28 @@ bool LayerAnimationElement::IsFinished(base::TimeTicks time, |
| } |
| bool LayerAnimationElement::ProgressToEnd(LayerAnimationDelegate* delegate) { |
| - if (first_frame_) |
| + const int frame_number = delegate ? delegate->GetFrameNumber() : 0; |
| + if (first_frame_) { |
| OnStart(delegate); |
| + start_frame_number_ = frame_number; |
| + } |
| base::WeakPtr<LayerAnimationElement> alive(weak_ptr_factory_.GetWeakPtr()); |
| bool need_draw = OnProgress(1.0, delegate); |
| + |
| + int end_frame_number = frame_number; |
| + if (animation_metrics_reporter_ && end_frame_number > start_frame_number_ && |
| + !duration_.is_zero()) { |
| + base::TimeDelta elapsed = base::TimeTicks::Now() - effective_start_time_; |
| + if (elapsed >= duration_) { |
| + int smoothness = 100; |
| + const double kFrameInterval = 1000.f / 60.f; |
|
reveman
2017/01/21 15:27:39
Should we get the actual vsync interval here inste
varkha
2017/01/24 00:18:57
Is there an easy place to get it from in composito
reveman
2017/01/24 17:21:45
VSync manager observer interface provides this: ht
varkha
2017/01/24 20:18:29
Looks like it is the Compositor that always sets t
varkha
2017/01/24 23:56:20
Please see if this works.
|
| + const double actual_duration = |
| + (end_frame_number - start_frame_number_) * kFrameInterval; |
| + if (duration_.InMillisecondsF() - actual_duration >= kFrameInterval) |
| + smoothness = 100 * (actual_duration / duration_.InMillisecondsF()); |
|
reveman
2017/01/21 15:27:39
Did you consider just reporting dropped frames ins
varkha
2017/01/24 00:18:57
one dropped frame could indeed ruin user experienc
|
| + animation_metrics_reporter_->Report(smoothness); |
| + } |
| + } |
| if (!alive) |
| return need_draw; |
| last_progressed_fraction_ = 1.0; |