Commit ef48283b authored by Xiyuan Xia's avatar Xiyuan Xia Committed by Commit Bot

ash: Use AnimationThroughputReporter for screen rotation metric

Bug: 1021774
Change-Id: I3e725eba1e129980470b1d361791d4eee099b682
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2266902Reviewed-by: default avatarSammie Quon <sammiequon@chromium.org>
Commit-Queue: Xiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#782864}
parent f47d8f05
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <utility> #include <utility>
#include "ash/public/cpp/ash_switches.h" #include "ash/public/cpp/ash_switches.h"
#include "ash/public/cpp/metrics_util.h"
#include "ash/public/cpp/shell_window_ids.h" #include "ash/public/cpp/shell_window_ids.h"
#include "ash/rotator/screen_rotation_animation.h" #include "ash/rotator/screen_rotation_animation.h"
#include "ash/rotator/screen_rotation_animator_observer.h" #include "ash/rotator/screen_rotation_animator_observer.h"
...@@ -23,6 +24,7 @@ ...@@ -23,6 +24,7 @@
#include "third_party/khronos/GLES2/gl2.h" #include "third_party/khronos/GLES2/gl2.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/base/class_property.h" #include "ui/base/class_property.h"
#include "ui/compositor/animation_throughput_reporter.h"
#include "ui/compositor/callback_layer_animation_observer.h" #include "ui/compositor/callback_layer_animation_observer.h"
#include "ui/compositor/layer.h" #include "ui/compositor/layer.h"
#include "ui/compositor/layer_animation_element.h" #include "ui/compositor/layer_animation_element.h"
...@@ -183,20 +185,12 @@ ScreenRotationAnimator::ScreenRotationAnimator(aura::Window* root_window) ...@@ -183,20 +185,12 @@ ScreenRotationAnimator::ScreenRotationAnimator(aura::Window* root_window)
: root_window_(root_window), : root_window_(root_window),
screen_rotation_state_(IDLE), screen_rotation_state_(IDLE),
rotation_request_id_(0), rotation_request_id_(0),
metrics_reporter_(std::make_unique<ui::HistogramPercentageMetricsReporter<
kRotationAnimationSmoothness>>()),
disable_animation_timers_for_test_(false) {} disable_animation_timers_for_test_(false) {}
ScreenRotationAnimator::~ScreenRotationAnimator() { ScreenRotationAnimator::~ScreenRotationAnimator() {
// To prevent a call to |AnimationEndedCallback()| from calling a method on // To prevent a call to |AnimationEndedCallback()| from calling a method on
// the |animator_|. // the |animator_|.
weak_factory_.InvalidateWeakPtrs(); weak_factory_.InvalidateWeakPtrs();
// Explicitly reset the |old_layer_tree_owner_| and |metrics_reporter_| in
// order to make sure |metrics_reporter_| outlives the attached animation
// sequence.
old_layer_tree_owner_.reset();
metrics_reporter_.reset();
} }
void ScreenRotationAnimator::StartRotationAnimation( void ScreenRotationAnimator::StartRotationAnimation(
...@@ -462,8 +456,11 @@ void ScreenRotationAnimator::AnimateRotation( ...@@ -462,8 +456,11 @@ void ScreenRotationAnimator::AnimateRotation(
new_layer_animator->set_disable_timer_for_test(true); new_layer_animator->set_disable_timer_for_test(true);
old_layer_animator->set_disable_timer_for_test(true); old_layer_animator->set_disable_timer_for_test(true);
} }
old_layer_animation_sequence->SetAnimationMetricsReporter( ui::AnimationThroughputReporter reporter(
metrics_reporter_.get()); old_layer_animator,
metrics_util::ForSmoothness(base::BindRepeating([](int smoothness) {
UMA_HISTOGRAM_PERCENTAGE(kRotationAnimationSmoothness, smoothness);
})));
// Add an observer so that the cloned/copied layers can be cleaned up with the // Add an observer so that the cloned/copied layers can be cleaned up with the
// animation completes/aborts. // animation completes/aborts.
......
...@@ -27,7 +27,6 @@ class CopyOutputResult; ...@@ -27,7 +27,6 @@ class CopyOutputResult;
} // namespace cc } // namespace cc
namespace ui { namespace ui {
class AnimationMetricsReporter;
class LayerTreeOwner; class LayerTreeOwner;
class ScopedAnimationDurationScaleMode; class ScopedAnimationDurationScaleMode;
} // namespace ui } // namespace ui
...@@ -185,7 +184,6 @@ class ASH_EXPORT ScreenRotationAnimator { ...@@ -185,7 +184,6 @@ class ASH_EXPORT ScreenRotationAnimator {
// cancel the previous rotation request. // cancel the previous rotation request.
int64_t rotation_request_id_; int64_t rotation_request_id_;
std::unique_ptr<ui::AnimationMetricsReporter> metrics_reporter_;
// Only set in unittest to disable animation timers. // Only set in unittest to disable animation timers.
bool disable_animation_timers_for_test_; bool disable_animation_timers_for_test_;
base::ObserverList<ScreenRotationAnimatorObserver>::Unchecked base::ObserverList<ScreenRotationAnimatorObserver>::Unchecked
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment