Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(564)

Side by Side Diff: ash/wm/overview/scoped_overview_animation_settings_aura.cc

Issue 2631333002: [animations] Adds metrics for jank on selected layer animations (Closed)
Patch Set: Adds UMA reporting for ripples and overview mode (query refresh rate) Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/wm/overview/scoped_overview_animation_settings_aura.h" 5 #include "ash/wm/overview/scoped_overview_animation_settings_aura.h"
6 6
7 #include "base/lazy_instance.h"
8 #include "base/metrics/histogram_macros.h"
7 #include "base/time/time.h" 9 #include "base/time/time.h"
8 #include "ui/aura/window.h" 10 #include "ui/aura/window.h"
9 #include "ui/compositor/layer.h" 11 #include "ui/compositor/layer.h"
10 #include "ui/compositor/layer_animation_observer.h" 12 #include "ui/compositor/layer_animation_observer.h"
11 #include "ui/compositor/scoped_layer_animation_settings.h" 13 #include "ui/compositor/scoped_layer_animation_settings.h"
12 #include "ui/gfx/animation/tween.h" 14 #include "ui/gfx/animation/tween.h"
13 15
14 namespace ash { 16 namespace ash {
15 17
16 namespace { 18 namespace {
(...skipping 27 matching lines...) Expand all
44 return base::TimeDelta::FromMilliseconds(kTransitionMilliseconds); 46 return base::TimeDelta::FromMilliseconds(kTransitionMilliseconds);
45 case OVERVIEW_ANIMATION_CLOSING_SELECTOR_ITEM: 47 case OVERVIEW_ANIMATION_CLOSING_SELECTOR_ITEM:
46 return base::TimeDelta::FromMilliseconds(kCloseScaleMilliseconds); 48 return base::TimeDelta::FromMilliseconds(kCloseScaleMilliseconds);
47 case OVERVIEW_ANIMATION_CLOSE_SELECTOR_ITEM: 49 case OVERVIEW_ANIMATION_CLOSE_SELECTOR_ITEM:
48 return base::TimeDelta::FromMilliseconds(kCloseFadeOutMilliseconds); 50 return base::TimeDelta::FromMilliseconds(kCloseFadeOutMilliseconds);
49 } 51 }
50 NOTREACHED(); 52 NOTREACHED();
51 return base::TimeDelta(); 53 return base::TimeDelta();
52 } 54 }
53 55
56 class OverviewEnterMetricsReporter : public ui::AnimationMetricsReporter {
57 void Report(int value) override {
58 UMA_HISTOGRAM_PERCENTAGE("Ash.WindowSelector.AnimationSmoothness.Enter",
59 value);
60 }
61 };
62
63 class OverviewExitMetricsReporter : public ui::AnimationMetricsReporter {
64 void Report(int value) override {
65 UMA_HISTOGRAM_PERCENTAGE("Ash.WindowSelector.AnimationSmoothness.Exit",
66 value);
67 }
68 };
69
70 class OverviewCloseMetricsReporter : public ui::AnimationMetricsReporter {
71 void Report(int value) override {
72 UMA_HISTOGRAM_PERCENTAGE("Ash.WindowSelector.AnimationSmoothness.Close",
73 value);
74 }
75 };
76
77 base::LazyInstance<OverviewEnterMetricsReporter>::Leaky g_reporter_enter =
78 LAZY_INSTANCE_INITIALIZER;
79 base::LazyInstance<OverviewExitMetricsReporter>::Leaky g_reporter_exit =
80 LAZY_INSTANCE_INITIALIZER;
81 base::LazyInstance<OverviewCloseMetricsReporter>::Leaky g_reporter_close =
82 LAZY_INSTANCE_INITIALIZER;
83
84 ui::AnimationMetricsReporter* GetMetricsReporter(
85 OverviewAnimationType animation_type) {
86 switch (animation_type) {
87 case OVERVIEW_ANIMATION_NONE:
88 return nullptr;
89 case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN:
90 case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS:
91 return g_reporter_enter.Pointer();
92 case OVERVIEW_ANIMATION_EXIT_OVERVIEW_MODE_FADE_OUT:
93 case OVERVIEW_ANIMATION_RESTORE_WINDOW:
94 return g_reporter_exit.Pointer();
95 case OVERVIEW_ANIMATION_CLOSING_SELECTOR_ITEM:
96 case OVERVIEW_ANIMATION_CLOSE_SELECTOR_ITEM:
97 return g_reporter_close.Pointer();
98 }
99 NOTREACHED();
100 return nullptr;
101 }
102
54 } // namespace 103 } // namespace
55 104
56 ScopedOverviewAnimationSettingsAura::ScopedOverviewAnimationSettingsAura( 105 ScopedOverviewAnimationSettingsAura::ScopedOverviewAnimationSettingsAura(
57 OverviewAnimationType animation_type, 106 OverviewAnimationType animation_type,
58 aura::Window* window) 107 aura::Window* window)
59 : animation_settings_(new ui::ScopedLayerAnimationSettings( 108 : animation_settings_(new ui::ScopedLayerAnimationSettings(
60 window->layer()->GetAnimator())) { 109 window->layer()->GetAnimator())) {
61 switch (animation_type) { 110 switch (animation_type) {
62 case OVERVIEW_ANIMATION_NONE: 111 case OVERVIEW_ANIMATION_NONE:
63 animation_settings_->SetPreemptionStrategy( 112 animation_settings_->SetPreemptionStrategy(
(...skipping 20 matching lines...) Expand all
84 break; 133 break;
85 case OVERVIEW_ANIMATION_CLOSING_SELECTOR_ITEM: 134 case OVERVIEW_ANIMATION_CLOSING_SELECTOR_ITEM:
86 case OVERVIEW_ANIMATION_CLOSE_SELECTOR_ITEM: 135 case OVERVIEW_ANIMATION_CLOSE_SELECTOR_ITEM:
87 animation_settings_->SetPreemptionStrategy( 136 animation_settings_->SetPreemptionStrategy(
88 ui::LayerAnimator::ENQUEUE_NEW_ANIMATION); 137 ui::LayerAnimator::ENQUEUE_NEW_ANIMATION);
89 animation_settings_->SetTweenType(gfx::Tween::EASE_OUT); 138 animation_settings_->SetTweenType(gfx::Tween::EASE_OUT);
90 break; 139 break;
91 } 140 }
92 animation_settings_->SetTransitionDuration( 141 animation_settings_->SetTransitionDuration(
93 GetAnimationDuration(animation_type)); 142 GetAnimationDuration(animation_type));
143 animation_settings_->SetAnimationMetricsReporter(
144 GetMetricsReporter(animation_type));
94 } 145 }
95 146
96 ScopedOverviewAnimationSettingsAura::~ScopedOverviewAnimationSettingsAura() {} 147 ScopedOverviewAnimationSettingsAura::~ScopedOverviewAnimationSettingsAura() {}
97 148
98 void ScopedOverviewAnimationSettingsAura::AddObserver( 149 void ScopedOverviewAnimationSettingsAura::AddObserver(
99 ui::ImplicitAnimationObserver* observer) { 150 ui::ImplicitAnimationObserver* observer) {
100 animation_settings_->AddObserver(observer); 151 animation_settings_->AddObserver(observer);
101 } 152 }
102 153
103 } // namespace ash 154 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698