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

Side by Side Diff: ash/display/display_configuration_controller.h

Issue 2728803002: Handles users rotating screen too early (Closed)
Patch Set: Rebased to commit. 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 | « ash/BUILD.gn ('k') | ash/display/display_configuration_controller.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_DISPLAY_DISPLAY_CONFIGURATION_CONTROLLER_H_ 5 #ifndef ASH_DISPLAY_DISPLAY_CONFIGURATION_CONTROLLER_H_
6 #define ASH_DISPLAY_DISPLAY_CONFIGURATION_CONTROLLER_H_ 6 #define ASH_DISPLAY_DISPLAY_CONFIGURATION_CONTROLLER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "ash/ash_export.h" 10 #include "ash/ash_export.h"
11 #include "ash/display/window_tree_host_manager.h" 11 #include "ash/display/window_tree_host_manager.h"
12 #include "ash/rotator/screen_rotation_animator_observer.h"
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
14 #include "ui/display/display.h" 15 #include "ui/display/display.h"
15 16
16 namespace display { 17 namespace display {
17 class DisplayLayout; 18 class DisplayLayout;
18 class DisplayManager; 19 class DisplayManager;
19 } 20 }
20 21
21 namespace ash { 22 namespace ash {
22 23
23 namespace test { 24 namespace test {
24 class ShellTestApi; 25 class DisplayConfigurationControllerTestApi;
25 } // namespace test 26 } // namespace test
26 27
27 class DisplayAnimator; 28 class DisplayAnimator;
29 class ScreenRotationAnimator;
28 30
29 // This class controls Display related configuration. Specifically it: 31 // This class controls Display related configuration. Specifically it:
30 // * Handles animated transitions where appropriate. 32 // * Handles animated transitions where appropriate.
31 // * Limits the frequency of certain operations. 33 // * Limits the frequency of certain operations.
32 // * Provides a single interface for UI and API classes. 34 // * Provides a single interface for UI and API classes.
33 // * TODO: Forwards display configuration changed events to UI and API classes. 35 // * TODO: Forwards display configuration changed events to UI and API classes.
34 class ASH_EXPORT DisplayConfigurationController 36 class ASH_EXPORT DisplayConfigurationController
35 : public WindowTreeHostManager::Observer { 37 : public WindowTreeHostManager::Observer,
38 public ScreenRotationAnimatorObserver {
36 public: 39 public:
37 DisplayConfigurationController( 40 DisplayConfigurationController(
38 display::DisplayManager* display_manager, 41 display::DisplayManager* display_manager,
39 WindowTreeHostManager* window_tree_host_manager); 42 WindowTreeHostManager* window_tree_host_manager);
40 ~DisplayConfigurationController() override; 43 ~DisplayConfigurationController() override;
41 44
42 // Sets the layout for the current displays with a fade in/out 45 // Sets the layout for the current displays with a fade in/out
43 // animation. Currently |display_id| is assumed to be the secondary 46 // animation. Currently |display_id| is assumed to be the secondary
44 // display. TODO(oshima/stevenjb): Support 3+ displays. 47 // display. TODO(oshima/stevenjb): Support 3+ displays.
45 void SetDisplayLayout(std::unique_ptr<display::DisplayLayout> layout); 48 void SetDisplayLayout(std::unique_ptr<display::DisplayLayout> layout);
46 49
47 // Sets the mirror mode with a fade-in/fade-out animation. Affects all 50 // Sets the mirror mode with a fade-in/fade-out animation. Affects all
48 // displays. 51 // displays.
49 void SetMirrorMode(bool mirror); 52 void SetMirrorMode(bool mirror);
50 53
51 // Sets the display's rotation with animation if available. 54 // Sets the display's rotation with animation if available.
52 void SetDisplayRotation(int64_t display_id, 55 void SetDisplayRotation(int64_t display_id,
53 display::Display::Rotation rotation, 56 display::Display::Rotation rotation,
54 display::Display::RotationSource source); 57 display::Display::RotationSource source);
55 58
56 // Sets the primary display id. 59 // Sets the primary display id.
57 void SetPrimaryDisplayId(int64_t display_id); 60 void SetPrimaryDisplayId(int64_t display_id);
58 61
59 // WindowTreeHostManager::Observer 62 // WindowTreeHostManager::Observer
60 void OnDisplayConfigurationChanged() override; 63 void OnDisplayConfigurationChanged() override;
61 64
65 // ScreenRotationAnimatorObserver
66 // This will be called when the animation is ended or aborted.
67 void OnScreenRotationAnimationFinished(
68 ScreenRotationAnimator* animator) override;
69
62 protected: 70 protected:
63 friend class ash::test::ShellTestApi; 71 friend class ash::test::DisplayConfigurationControllerTestApi;
64 72
65 // Allow tests to skip animations. 73 // Allow tests to skip animations.
66 void ResetAnimatorForTest(); 74 void ResetAnimatorForTest();
67 75
68 private: 76 private:
69 class DisplayChangeLimiter; 77 class DisplayChangeLimiter;
70 78
71 // Sets the timeout for the DisplayChangeLimiter if it exists. Call this 79 // Sets the timeout for the DisplayChangeLimiter if it exists. Call this
72 // *before* starting any animations. 80 // *before* starting any animations.
73 void SetThrottleTimeout(int64_t throttle_ms); 81 void SetThrottleTimeout(int64_t throttle_ms);
74 bool IsLimited(); 82 bool IsLimited();
75 void SetDisplayLayoutImpl(std::unique_ptr<display::DisplayLayout> layout); 83 void SetDisplayLayoutImpl(std::unique_ptr<display::DisplayLayout> layout);
76 void SetMirrorModeImpl(bool mirror); 84 void SetMirrorModeImpl(bool mirror);
77 void SetPrimaryDisplayIdImpl(int64_t display_id); 85 void SetPrimaryDisplayIdImpl(int64_t display_id);
78 86
87 // Returns the ScreenRotationAnimator associated with the |display_id|. If
88 // there is no existing ScreenRotationAnimator for |display_id|, it will make
89 // one and store the pair in the |rotation_animator_map_|.
90 ScreenRotationAnimator* GetScreenRotationAnimatorForDisplay(
91 int64_t display_id);
92
79 display::DisplayManager* display_manager_; // weak ptr 93 display::DisplayManager* display_manager_; // weak ptr
80 WindowTreeHostManager* window_tree_host_manager_; // weak ptr 94 WindowTreeHostManager* window_tree_host_manager_; // weak ptr
81 std::unique_ptr<DisplayAnimator> display_animator_; 95 std::unique_ptr<DisplayAnimator> display_animator_;
82 std::unique_ptr<DisplayChangeLimiter> limiter_; 96 std::unique_ptr<DisplayChangeLimiter> limiter_;
83 97
98 // Tracks |display_id| to ScreenRotationAnimator mappings. The
99 // |rotation_animator_map_| is populated on demand the first time a
100 // ScreenRotationAnimator is needed for a given |display_id|.
101 // On animation ended or aborted, the animator may be deleted if there is no
102 // more pending rotation request.
103 std::unordered_map<int64_t, std::unique_ptr<ScreenRotationAnimator>>
104 rotation_animator_map_;
105
84 base::WeakPtrFactory<DisplayConfigurationController> weak_ptr_factory_; 106 base::WeakPtrFactory<DisplayConfigurationController> weak_ptr_factory_;
85 107
86 DISALLOW_COPY_AND_ASSIGN(DisplayConfigurationController); 108 DISALLOW_COPY_AND_ASSIGN(DisplayConfigurationController);
87 }; 109 };
88 110
89 } // namespace ash 111 } // namespace ash
90 112
91 #endif // ASH_DISPLAY_DISPLAY_CONFIGURATION_CONTROLLER_H_ 113 #endif // ASH_DISPLAY_DISPLAY_CONFIGURATION_CONTROLLER_H_
OLDNEW
« no previous file with comments | « ash/BUILD.gn ('k') | ash/display/display_configuration_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698