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

wm: Use AnimationThroughputReporter for hide metric

Bug: 1021774
Change-Id: I8b0d4044403df50de63471aa38872f46f2225053
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2271014Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Commit-Queue: Xiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#784157}
parent d6f415d6
...@@ -9,10 +9,10 @@ ...@@ -9,10 +9,10 @@
#include <algorithm> #include <algorithm>
#include <memory> #include <memory>
#include "base/bind.h"
#include "base/check_op.h" #include "base/check_op.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/lazy_instance.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/notreached.h" #include "base/notreached.h"
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include "ui/aura/window_delegate.h" #include "ui/aura/window_delegate.h"
#include "ui/aura/window_observer.h" #include "ui/aura/window_observer.h"
#include "ui/base/class_property.h" #include "ui/base/class_property.h"
#include "ui/compositor/animation_metrics_reporter.h" #include "ui/compositor/animation_throughput_reporter.h"
#include "ui/compositor/compositor_observer.h" #include "ui/compositor/compositor_observer.h"
#include "ui/compositor/layer.h" #include "ui/compositor/layer.h"
#include "ui/compositor/layer_animation_observer.h" #include "ui/compositor/layer_animation_observer.h"
...@@ -139,21 +139,24 @@ class HidingWindowAnimationObserverBase : public aura::WindowObserver { ...@@ -139,21 +139,24 @@ class HidingWindowAnimationObserverBase : public aura::WindowObserver {
DISALLOW_COPY_AND_ASSIGN(HidingWindowAnimationObserverBase); DISALLOW_COPY_AND_ASSIGN(HidingWindowAnimationObserverBase);
}; };
class HidingWindowMetricsReporter : public ui::AnimationMetricsReporter { // TODO(crbug.com/1021774): Find a better home and merge with
public: // ash::metris_util::ForSmoothness.
HidingWindowMetricsReporter() = default; using SmoothnessCallback = base::RepeatingCallback<void(int smoothness)>;
~HidingWindowMetricsReporter() override = default; ui::AnimationThroughputReporter::ReportCallback ForSmoothness(
SmoothnessCallback callback) {
void Report(int value) override { return base::BindRepeating(
UMA_HISTOGRAM_PERCENTAGE("Ash.Window.AnimationSmoothness.Hide", value); [](SmoothnessCallback callback,
} cc::FrameSequenceMetrics::ThroughputData throughput) {
const int smoothness = std::floor(100.0f * throughput.frames_produced /
private: throughput.frames_expected);
DISALLOW_COPY_AND_ASSIGN(HidingWindowMetricsReporter); callback.Run(smoothness);
}; },
std::move(callback));
}
base::LazyInstance<HidingWindowMetricsReporter>::Leaky g_reporter_hide = void ReportHideSmoothness(int smoothness) {
LAZY_INSTANCE_INITIALIZER; UMA_HISTOGRAM_PERCENTAGE("Ash.Window.AnimationSmoothness.Hide", smoothness);
}
} // namespace } // namespace
...@@ -300,8 +303,12 @@ void AnimateHideWindowCommon(aura::Window* window, ...@@ -300,8 +303,12 @@ void AnimateHideWindowCommon(aura::Window* window,
// Property sets within this scope will be implicitly animated. // Property sets within this scope will be implicitly animated.
ScopedHidingAnimationSettings hiding_settings(window); ScopedHidingAnimationSettings hiding_settings(window);
hiding_settings.layer_animation_settings()->SetAnimationMetricsReporter(
g_reporter_hide.Pointer()); // Report animation smoothness for animations created within this scope.
ui::AnimationThroughputReporter reporter(
hiding_settings.layer_animation_settings()->GetAnimator(),
ForSmoothness(base::BindRepeating(&ReportHideSmoothness)));
// Render surface caching may not provide a benefit when animating the opacity // Render surface caching may not provide a benefit when animating the opacity
// of a single layer. // of a single layer.
if (!window->layer()->children().empty()) if (!window->layer()->children().empty())
......
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