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

Side by Side Diff: ash/rotator/screen_rotation_animator.h

Issue 2771713004: Adds UMA for screen rotation animation smoothness. (Closed)
Patch Set: Merged and Moves the ScreenRotationAnimationMetricsReporter to .cc. Created 3 years, 9 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 | ash/rotator/screen_rotation_animator.cc » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #ifndef ASH_ROTATOR_SCREEN_ROTATION_ANIMATOR_H_ 5 #ifndef ASH_ROTATOR_SCREEN_ROTATION_ANIMATOR_H_
6 #define ASH_ROTATOR_SCREEN_ROTATION_ANIMATOR_H_ 6 #define ASH_ROTATOR_SCREEN_ROTATION_ANIMATOR_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "ash/ash_export.h" 10 #include "ash/ash_export.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/observer_list.h" 13 #include "base/observer_list.h"
14 #include "ui/display/display.h" 14 #include "ui/display/display.h"
15 15
16 namespace ui { 16 namespace ui {
17 class AnimationMetricsReporter;
17 class Layer; 18 class Layer;
18 class LayerTreeOwner; 19 class LayerTreeOwner;
19 } // namespace ui 20 } // namespace ui
20 21
21 namespace ash { 22 namespace ash {
22 namespace test { 23 namespace test {
23 class ScreenRotationAnimatorTestApi; 24 class ScreenRotationAnimatorTestApi;
24 } // namespace test 25 } // namespace test
25 26
26 class ScreenRotationAnimatorObserver; 27 class ScreenRotationAnimatorObserver;
(...skipping 15 matching lines...) Expand all
42 void Rotate(display::Display::Rotation new_rotation, 43 void Rotate(display::Display::Rotation new_rotation,
43 display::Display::RotationSource source); 44 display::Display::RotationSource source);
44 45
45 int64_t display_id() const { return display_id_; } 46 int64_t display_id() const { return display_id_; }
46 47
47 void AddScreenRotationAnimatorObserver( 48 void AddScreenRotationAnimatorObserver(
48 ScreenRotationAnimatorObserver* observer); 49 ScreenRotationAnimatorObserver* observer);
49 void RemoveScreenRotationAnimatorObserver( 50 void RemoveScreenRotationAnimatorObserver(
50 ScreenRotationAnimatorObserver* observer); 51 ScreenRotationAnimatorObserver* observer);
51 52
52 void OnLayerAnimationEnded(); 53 // When screen rotation animation is ended or aborted, calls |Rotate()| with
53 54 // the pending rotation request if the request queue is not empty. Otherwise
54 void OnLayerAnimationAborted(); 55 // notifies |screen_rotation_animator_observer_|.
56 void ProcessAnimationQueue();
55 57
56 private: 58 private:
57 friend class ash::test::ScreenRotationAnimatorTestApi; 59 friend class ash::test::ScreenRotationAnimatorTestApi;
58 struct ScreenRotationRequest; 60 struct ScreenRotationRequest;
59 61
60 // Set the screen orientation to |new_rotation| and animate the change. The 62 // Set the screen orientation to |new_rotation| and animate the change. The
61 // animation will rotate the initial orientation's layer towards the new 63 // animation will rotate the initial orientation's layer towards the new
62 // orientation through |rotation_degrees| while fading out, and the new 64 // orientation through |rotation_degrees| while fading out, and the new
63 // orientation's layer will be rotated in to the |new_orientation| through 65 // orientation's layer will be rotated in to the |new_orientation| through
64 // |rotation_degrees| arc. 66 // |rotation_degrees| arc.
65 void AnimateRotation(std::unique_ptr<ScreenRotationRequest> rotation_request); 67 void AnimateRotation(std::unique_ptr<ScreenRotationRequest> rotation_request);
66 68
67 // When screen rotation animation is ended or aborted, if the request queue is
68 // not empty, it will call |Rotate()| with the pending rotation request.
69 // Otherwise it will notify |screen_rotation_animator_observer_|.
70 void ProcessAnimationQueue();
71
72 void set_disable_animation_timers_for_test(bool disable_timers); 69 void set_disable_animation_timers_for_test(bool disable_timers);
73 70
74 void StopAnimating(); 71 void StopAnimating();
75 72
76 // The id of the display to rotate. 73 // The id of the display to rotate.
77 int64_t display_id_; 74 int64_t display_id_;
78 bool is_rotating_; 75 bool is_rotating_;
76 std::unique_ptr<ui::AnimationMetricsReporter> metrics_reporter_;
79 // Only set in unittest to disable animation timers. 77 // Only set in unittest to disable animation timers.
80 bool disable_animation_timers_for_test_; 78 bool disable_animation_timers_for_test_;
81 base::ObserverList<ScreenRotationAnimatorObserver> 79 base::ObserverList<ScreenRotationAnimatorObserver>
82 screen_rotation_animator_observers_; 80 screen_rotation_animator_observers_;
83 std::unique_ptr<ui::LayerTreeOwner> old_layer_tree_owner_; 81 std::unique_ptr<ui::LayerTreeOwner> old_layer_tree_owner_;
84 std::unique_ptr<ScreenRotationRequest> last_pending_request_; 82 std::unique_ptr<ScreenRotationRequest> last_pending_request_;
85 base::WeakPtrFactory<ScreenRotationAnimator> weak_factory_; 83 base::WeakPtrFactory<ScreenRotationAnimator> weak_factory_;
86 84
87 DISALLOW_COPY_AND_ASSIGN(ScreenRotationAnimator); 85 DISALLOW_COPY_AND_ASSIGN(ScreenRotationAnimator);
88 }; 86 };
89 87
90 } // namespace ash 88 } // namespace ash
91 89
92 #endif // ASH_ROTATOR_SCREEN_ROTATION_ANIMATOR_H_ 90 #endif // ASH_ROTATOR_SCREEN_ROTATION_ANIMATOR_H_
OLDNEW
« no previous file with comments | « no previous file | ash/rotator/screen_rotation_animator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698