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

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 (extern constexpr) 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
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"
7 #include "base/time/time.h" 8 #include "base/time/time.h"
8 #include "ui/aura/window.h" 9 #include "ui/aura/window.h"
10 #include "ui/compositor/animation_metrics_reporter_template.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 {
17 19
18 // The time duration for transformation animations. 20 // The time duration for transformation animations.
(...skipping 25 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 extern constexpr char kMetricCloseName[] =
57 "Ash.WindowSelector.AnimationSmoothness.Close";
58 extern constexpr char kMetricEnterName[] =
59 "Ash.WindowSelector.AnimationSmoothness.Enter";
60 extern constexpr char kMetricExitName[] =
61 "Ash.WindowSelector.AnimationSmoothness.Exit";
62
63 base::LazyInstance<ui::AnimationMetricsReporterTemplate<kMetricCloseName>>::
64 Leaky g_reporter_close = LAZY_INSTANCE_INITIALIZER;
65 base::LazyInstance<ui::AnimationMetricsReporterTemplate<kMetricEnterName>>::
66 Leaky g_reporter_enter = LAZY_INSTANCE_INITIALIZER;
67 base::LazyInstance<ui::AnimationMetricsReporterTemplate<kMetricExitName>>::Leaky
68 g_reporter_exit = LAZY_INSTANCE_INITIALIZER;
69
70 ui::AnimationMetricsReporter* GetMetricsReporter(
71 OverviewAnimationType animation_type) {
72 switch (animation_type) {
73 case OVERVIEW_ANIMATION_NONE:
74 return nullptr;
75 case OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN:
76 case OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS:
77 return g_reporter_enter.Pointer();
78 case OVERVIEW_ANIMATION_EXIT_OVERVIEW_MODE_FADE_OUT:
79 case OVERVIEW_ANIMATION_RESTORE_WINDOW:
80 return g_reporter_exit.Pointer();
81 case OVERVIEW_ANIMATION_CLOSING_SELECTOR_ITEM:
82 case OVERVIEW_ANIMATION_CLOSE_SELECTOR_ITEM:
83 return g_reporter_close.Pointer();
84 }
85 NOTREACHED();
86 return nullptr;
87 }
88
54 } // namespace 89 } // namespace
55 90
56 ScopedOverviewAnimationSettingsAura::ScopedOverviewAnimationSettingsAura( 91 ScopedOverviewAnimationSettingsAura::ScopedOverviewAnimationSettingsAura(
57 OverviewAnimationType animation_type, 92 OverviewAnimationType animation_type,
58 aura::Window* window) 93 aura::Window* window)
59 : animation_settings_(new ui::ScopedLayerAnimationSettings( 94 : animation_settings_(new ui::ScopedLayerAnimationSettings(
60 window->layer()->GetAnimator())) { 95 window->layer()->GetAnimator())) {
61 switch (animation_type) { 96 switch (animation_type) {
62 case OVERVIEW_ANIMATION_NONE: 97 case OVERVIEW_ANIMATION_NONE:
63 animation_settings_->SetPreemptionStrategy( 98 animation_settings_->SetPreemptionStrategy(
(...skipping 20 matching lines...) Expand all
84 break; 119 break;
85 case OVERVIEW_ANIMATION_CLOSING_SELECTOR_ITEM: 120 case OVERVIEW_ANIMATION_CLOSING_SELECTOR_ITEM:
86 case OVERVIEW_ANIMATION_CLOSE_SELECTOR_ITEM: 121 case OVERVIEW_ANIMATION_CLOSE_SELECTOR_ITEM:
87 animation_settings_->SetPreemptionStrategy( 122 animation_settings_->SetPreemptionStrategy(
88 ui::LayerAnimator::ENQUEUE_NEW_ANIMATION); 123 ui::LayerAnimator::ENQUEUE_NEW_ANIMATION);
89 animation_settings_->SetTweenType(gfx::Tween::EASE_OUT); 124 animation_settings_->SetTweenType(gfx::Tween::EASE_OUT);
90 break; 125 break;
91 } 126 }
92 animation_settings_->SetTransitionDuration( 127 animation_settings_->SetTransitionDuration(
93 GetAnimationDuration(animation_type)); 128 GetAnimationDuration(animation_type));
129 animation_settings_->SetAnimationMetricsReporter(
130 GetMetricsReporter(animation_type));
94 } 131 }
95 132
96 ScopedOverviewAnimationSettingsAura::~ScopedOverviewAnimationSettingsAura() {} 133 ScopedOverviewAnimationSettingsAura::~ScopedOverviewAnimationSettingsAura() {}
97 134
98 void ScopedOverviewAnimationSettingsAura::AddObserver( 135 void ScopedOverviewAnimationSettingsAura::AddObserver(
99 ui::ImplicitAnimationObserver* observer) { 136 ui::ImplicitAnimationObserver* observer) {
100 animation_settings_->AddObserver(observer); 137 animation_settings_->AddObserver(observer);
101 } 138 }
102 139
103 } // namespace ash 140 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | ui/compositor/animation_metrics_reporter_template.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698