Commit 3b6d9a0a authored by Sammie Quon's avatar Sammie Quon Committed by Commit Bot

splitview: Add animation smoothness metrics for Divider snap animation.

This is a heavy animation as it basically calls into UpdateResize which
resizes both windows (or one window and overview). Also, changes the
animation to use a runner which is synced with the compositor.

Test: none, will update tast-tests
Bug: 1047495
Change-Id: Ic29eb0dd831e7bbc5115268f8c09718b6fc82796
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2254820Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarBrian White <bcwhite@chromium.org>
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#782707}
parent 4694d411
......@@ -10,6 +10,7 @@
#include "ash/accessibility/accessibility_controller_impl.h"
#include "ash/display/screen_orientation_controller.h"
#include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/metrics_util.h"
#include "ash/public/cpp/presentation_time_recorder.h"
#include "ash/public/cpp/window_properties.h"
#include "ash/root_window_controller.h"
......@@ -47,9 +48,11 @@
#include "ui/base/class_property.h"
#include "ui/base/hit_test.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/throughput_tracker.h"
#include "ui/gfx/animation/slide_animation.h"
#include "ui/gfx/animation/tween.h"
#include "ui/gfx/transform_util.h"
#include "ui/views/animation/compositor_animation_runner.h"
#include "ui/views/widget/widget.h"
#include "ui/wm/core/coordinate_conversion.h"
#include "ui/wm/core/shadow_controller.h"
......@@ -77,6 +80,11 @@ constexpr float kTwoThirdPositionRatio = 0.67f;
constexpr float kBlackScrimFadeInRatio = 0.1f;
constexpr float kBlackScrimOpacity = 0.4f;
// Records the animation smoothness when the divider is released during a resize
// and animated to a fixed position ratio.
constexpr char kDividerAnimationSmoothness[] =
"Ash.SplitViewResize.AnimationSmoothness.DividerAnimation";
// Histogram names that record presentation time of resize operation with
// following conditions, a) clamshell split view, empty overview grid,
// b) clamshell split view, nonempty overview grid, c) tablet split view, one
......@@ -281,8 +289,31 @@ class SplitViewController::DividerSnapAnimation
// in tablet_mode_window_drag_delegate.cc.
SetSlideDuration(base::TimeDelta::FromMilliseconds(300));
SetTweenType(gfx::Tween::EASE_IN);
}
aura::Window* window = split_view_controller->left_window()
? split_view_controller->left_window()
: split_view_controller->right_window();
DCHECK(window);
// |widget| may be null in tests. It will use the default animation
// container in this case.
views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window);
if (!widget)
return;
gfx::AnimationContainer* container = new gfx::AnimationContainer();
container->SetAnimationRunner(
std::make_unique<views::CompositorAnimationRunner>(widget));
SetContainer(container);
tracker_.emplace(widget->GetCompositor()->RequestNewThroughputTracker());
tracker_->Start(
metrics_util::ForSmoothness(base::BindRepeating([](int smoothness) {
UMA_HISTOGRAM_PERCENTAGE(kDividerAnimationSmoothness, smoothness);
})));
}
DividerSnapAnimation(const DividerSnapAnimation&) = delete;
DividerSnapAnimation& operator=(const DividerSnapAnimation&) = delete;
~DividerSnapAnimation() override = default;
int ending_position() const { return ending_position_; }
......@@ -296,6 +327,9 @@ class SplitViewController::DividerSnapAnimation
split_view_controller_->EndResizeImpl();
split_view_controller_->EndTabletSplitViewAfterResizingIfAppropriate();
if (tracker_)
tracker_->Stop();
}
void AnimationProgressed(const gfx::Animation* animation) override {
......@@ -311,9 +345,15 @@ class SplitViewController::DividerSnapAnimation
split_view_controller_->SetWindowsTransformDuringResizing();
}
void AnimationCanceled(const gfx::Animation* animation) override {
if (tracker_)
tracker_->Cancel();
}
SplitViewController* split_view_controller_;
int starting_position_;
int ending_position_;
base::Optional<ui::ThroughputTracker> tracker_;
};
// static
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_WM_SPLITSVIEW_SPLIT_VIEW_CONTROLLER_H_
#define ASH_WM_SPLITSVIEW_SPLIT_VIEW_CONTROLLER_H_
#ifndef ASH_WM_SPLITVIEW_SPLIT_VIEW_CONTROLLER_H_
#define ASH_WM_SPLITVIEW_SPLIT_VIEW_CONTROLLER_H_
#include <limits>
#include <memory>
......@@ -512,4 +512,4 @@ class ASH_EXPORT SplitViewController : public aura::WindowObserver,
} // namespace ash
#endif // ASH_WM_SPLITSVIEW_SPLIT_VIEW_CONTROLLER_H_
#endif // ASH_WM_SPLITVIEW_SPLIT_VIEW_CONTROLLER_H_
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_WM_SPLITSVIEW_SPLIT_VIEW_DIVIDER_H_
#define ASH_WM_SPLITSVIEW_SPLIT_VIEW_DIVIDER_H_
#ifndef ASH_WM_SPLITVIEW_SPLIT_VIEW_DIVIDER_H_
#define ASH_WM_SPLITVIEW_SPLIT_VIEW_DIVIDER_H_
#include <memory>
......@@ -125,4 +125,4 @@ class ASH_EXPORT SplitViewDivider : public aura::WindowObserver,
} // namespace ash
#endif // ASH_WM_SPLITSVIEW_SPLIT_VIEW_DIVIDER_H_
#endif // ASH_WM_SPLITVIEW_SPLIT_VIEW_DIVIDER_H_
......@@ -10636,6 +10636,17 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</summary>
</histogram>
<histogram name="Ash.SplitViewResize.AnimationSmoothness.DividerAnimation"
units="%" expires_after="2021-06-15">
<owner>sammiequon@chromium.org</owner>
<owner>xdai@chromium.org</owner>
<summary>
Relative smoothness of animation when releasing the split view divider,
recorded when the animation completes. 100% represents ideally smooth 60
frames per second.
</summary>
</histogram>
<histogram base="true" name="Ash.SplitViewResize.PresentationTime" units="ms"
expires_after="2020-12-12">
<!-- Name completed by histogram_suffixes name="SplitViewResizeModes" -->
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