Commit 36ad87f0 authored by Xiyuan Xia's avatar Xiyuan Xia Committed by Commit Bot

ash: Use AnimationThroughputReporter for ScrollableShelf

Replace AnimationMetricsReporter with AnimationThroughputReporter
to use new code path for smoothness metrics.

Bug: 1021774
Change-Id: I1d15a836b43bacb80cc244a840cbe01de6f34ec6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2250502Reviewed-by: default avatarAndrew Xu <andrewxu@chromium.org>
Commit-Queue: Xiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#779830}
parent ee5cdf7a
......@@ -20,7 +20,7 @@
#include "base/numerics/ranges.h"
#include "chromeos/constants/chromeos_switches.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/compositor/animation_metrics_reporter.h"
#include "ui/compositor/animation_throughput_reporter.h"
#include "ui/compositor/paint_recorder.h"
#include "ui/compositor/scoped_layer_animation_settings.h"
#include "ui/gfx/geometry/insets.h"
......@@ -105,6 +105,27 @@ int64_t GetDisplayIdForView(const views::View* view) {
return display::Screen::GetScreen()->GetDisplayNearestWindow(window).id();
}
void ReportSmoothness(bool tablet_mode, bool launcher_visible, int smoothness) {
base::UmaHistogramPercentage(kAnimationSmoothnessHistogram, smoothness);
if (tablet_mode) {
if (launcher_visible) {
base::UmaHistogramPercentage(
kAnimationSmoothnessTabletLauncherVisibleHistogram, smoothness);
} else {
base::UmaHistogramPercentage(
kAnimationSmoothnessTabletLauncherHiddenHistogram, smoothness);
}
} else {
if (launcher_visible) {
base::UmaHistogramPercentage(
kAnimationSmoothnessClamshellLauncherVisibleHistogram, smoothness);
} else {
base::UmaHistogramPercentage(
kAnimationSmoothnessClamshellLauncherHiddenHistogram, smoothness);
}
}
}
} // namespace
////////////////////////////////////////////////////////////////////////////////
......@@ -340,45 +361,6 @@ class ScrollableShelfView::ScopedActiveInkDropCountImpl
ScrollableShelfView* owner_ = nullptr;
};
////////////////////////////////////////////////////////////////////////////////
// ScrollableShelfAnimationMetricsReporter
class ScrollableShelfAnimationMetricsReporter
: public ui::AnimationMetricsReporter {
public:
ScrollableShelfAnimationMetricsReporter() {}
~ScrollableShelfAnimationMetricsReporter() override = default;
void set_display_id(int64_t display_id) { display_id_ = display_id; }
// ui::AnimationMetricsReporter:
void Report(int value) override {
base::UmaHistogramPercentage(kAnimationSmoothnessHistogram, value);
if (Shell::Get()->IsInTabletMode()) {
if (Shell::Get()->app_list_controller()->IsVisible(display_id_)) {
base::UmaHistogramPercentage(
kAnimationSmoothnessTabletLauncherVisibleHistogram, value);
} else {
base::UmaHistogramPercentage(
kAnimationSmoothnessTabletLauncherHiddenHistogram, value);
}
} else {
if (Shell::Get()->app_list_controller()->IsVisible(display_id_)) {
base::UmaHistogramPercentage(
kAnimationSmoothnessClamshellLauncherVisibleHistogram, value);
} else {
base::UmaHistogramPercentage(
kAnimationSmoothnessClamshellLauncherHiddenHistogram, value);
}
}
}
private:
int64_t display_id_ = display::kInvalidDisplayId;
DISALLOW_COPY_AND_ASSIGN(ScrollableShelfAnimationMetricsReporter);
};
////////////////////////////////////////////////////////////////////////////////
// ScrollableShelfContainerView
......@@ -514,9 +496,7 @@ ScrollableShelfView::ScrollableShelfView(ShelfModel* model, Shelf* shelf)
shelf,
/*drag_and_drop_host=*/this,
/*shelf_button_delegate=*/this)),
page_flip_time_threshold_(kShelfPageFlipDelay),
animation_metrics_reporter_(
std::make_unique<ScrollableShelfAnimationMetricsReporter>()) {
page_flip_time_threshold_(kShelfPageFlipDelay) {
Shell::Get()->AddShellObserver(this);
ShelfConfig::Get()->AddObserver(this);
set_allow_deactivate_on_esc(true);
......@@ -829,10 +809,15 @@ void ScrollableShelfView::StartShelfScrollAnimation(float scroll_distance) {
animation_settings.SetTweenType(gfx::Tween::EASE_OUT);
animation_settings.SetPreemptionStrategy(
ui::LayerAnimator::IMMEDIATELY_SET_NEW_TARGET);
animation_settings.SetAnimationMetricsReporter(
animation_metrics_reporter_.get());
animation_settings.AddObserver(this);
animation_metrics_reporter_->set_display_id(GetDisplayIdForView(this));
ui::AnimationThroughputReporter reporter(
animation_settings.GetAnimator(),
metrics_util::ForSmoothness(
base::BindRepeating(&ReportSmoothness, Shell::Get()->IsInTabletMode(),
Shell::Get()->app_list_controller()->IsVisible(
GetDisplayIdForView(this)))));
shelf_container_view_->TranslateShelfView(scroll_offset_);
}
......
......@@ -32,7 +32,6 @@ class FocusSearch;
namespace ash {
class PresentationTimeRecorder;
class ScrollableShelfAnimationMetricsReporter;
class ASH_EXPORT ScrollableShelfView : public views::AccessiblePaneView,
public ShellObserver,
......@@ -572,10 +571,6 @@ class ASH_EXPORT ScrollableShelfView : public views::AccessiblePaneView,
// |shelf_container_view_| in non-overflow mode.
bool layer_clip_in_non_overflow_ = false;
// Metric reporter for scrolling animations.
const std::unique_ptr<ScrollableShelfAnimationMetricsReporter>
animation_metrics_reporter_;
// Records the presentation time for the scrollable shelf dragging.
std::unique_ptr<PresentationTimeRecorder> presentation_time_recorder_;
......
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