OLD | NEW |
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" | |
13 #include "base/macros.h" | 12 #include "base/macros.h" |
14 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
15 #include "ui/display/display.h" | 14 #include "ui/display/display.h" |
16 | 15 |
17 namespace display { | 16 namespace display { |
18 class DisplayLayout; | 17 class DisplayLayout; |
19 class DisplayManager; | 18 class DisplayManager; |
20 } | 19 } |
21 | 20 |
22 namespace ash { | 21 namespace ash { |
23 | 22 |
24 namespace test { | 23 namespace test { |
25 class DisplayConfigurationControllerTestApi; | 24 class DisplayConfigurationControllerTestApi; |
26 } // namespace test | 25 } // namespace test |
27 | 26 |
28 class DisplayAnimator; | 27 class DisplayAnimator; |
29 class ScreenRotationAnimator; | 28 class ScreenRotationAnimator; |
30 | 29 |
31 // This class controls Display related configuration. Specifically it: | 30 // This class controls Display related configuration. Specifically it: |
32 // * Handles animated transitions where appropriate. | 31 // * Handles animated transitions where appropriate. |
33 // * Limits the frequency of certain operations. | 32 // * Limits the frequency of certain operations. |
34 // * Provides a single interface for UI and API classes. | 33 // * Provides a single interface for UI and API classes. |
35 // * TODO: Forwards display configuration changed events to UI and API classes. | 34 // * TODO: Forwards display configuration changed events to UI and API classes. |
36 class ASH_EXPORT DisplayConfigurationController | 35 class ASH_EXPORT DisplayConfigurationController |
37 : public WindowTreeHostManager::Observer, | 36 : public WindowTreeHostManager::Observer { |
38 public ScreenRotationAnimatorObserver { | |
39 public: | 37 public: |
40 DisplayConfigurationController( | 38 DisplayConfigurationController( |
41 display::DisplayManager* display_manager, | 39 display::DisplayManager* display_manager, |
42 WindowTreeHostManager* window_tree_host_manager); | 40 WindowTreeHostManager* window_tree_host_manager); |
43 ~DisplayConfigurationController() override; | 41 ~DisplayConfigurationController() override; |
44 | 42 |
45 // Sets the layout for the current displays with a fade in/out | 43 // Sets the layout for the current displays with a fade in/out |
46 // animation. Currently |display_id| is assumed to be the secondary | 44 // animation. Currently |display_id| is assumed to be the secondary |
47 // display. TODO(oshima/stevenjb): Support 3+ displays. | 45 // display. TODO(oshima/stevenjb): Support 3+ displays. |
48 void SetDisplayLayout(std::unique_ptr<display::DisplayLayout> layout); | 46 void SetDisplayLayout(std::unique_ptr<display::DisplayLayout> layout); |
49 | 47 |
50 // Sets the mirror mode with a fade-in/fade-out animation. Affects all | 48 // Sets the mirror mode with a fade-in/fade-out animation. Affects all |
51 // displays. | 49 // displays. |
52 void SetMirrorMode(bool mirror); | 50 void SetMirrorMode(bool mirror); |
53 | 51 |
54 // Sets the display's rotation with animation if available. | 52 // Sets the display's rotation with animation if available. |
55 void SetDisplayRotation(int64_t display_id, | 53 void SetDisplayRotation(int64_t display_id, |
56 display::Display::Rotation rotation, | 54 display::Display::Rotation rotation, |
57 display::Display::RotationSource source); | 55 display::Display::RotationSource source); |
58 | 56 |
59 // Sets the primary display id. | 57 // Sets the primary display id. |
60 void SetPrimaryDisplayId(int64_t display_id); | 58 void SetPrimaryDisplayId(int64_t display_id); |
61 | 59 |
62 // WindowTreeHostManager::Observer | 60 // WindowTreeHostManager::Observer |
63 void OnDisplayConfigurationChanged() override; | 61 void OnDisplayConfigurationChanged() override; |
64 | 62 |
65 // ScreenRotationAnimatorObserver | |
66 // This will be called when the animation is ended or aborted. | |
67 void OnScreenRotationAnimationFinished( | |
68 ScreenRotationAnimator* animator) override; | |
69 | |
70 protected: | 63 protected: |
71 friend class ash::test::DisplayConfigurationControllerTestApi; | 64 friend class ash::test::DisplayConfigurationControllerTestApi; |
72 | 65 |
73 // Allow tests to skip animations. | 66 // Allow tests to skip animations. |
74 void ResetAnimatorForTest(); | 67 void ResetAnimatorForTest(); |
75 | 68 |
76 private: | 69 private: |
77 class DisplayChangeLimiter; | 70 class DisplayChangeLimiter; |
78 | 71 |
79 // Sets the timeout for the DisplayChangeLimiter if it exists. Call this | 72 // Sets the timeout for the DisplayChangeLimiter if it exists. Call this |
(...skipping 24 matching lines...) Expand all Loading... |
104 rotation_animator_map_; | 97 rotation_animator_map_; |
105 | 98 |
106 base::WeakPtrFactory<DisplayConfigurationController> weak_ptr_factory_; | 99 base::WeakPtrFactory<DisplayConfigurationController> weak_ptr_factory_; |
107 | 100 |
108 DISALLOW_COPY_AND_ASSIGN(DisplayConfigurationController); | 101 DISALLOW_COPY_AND_ASSIGN(DisplayConfigurationController); |
109 }; | 102 }; |
110 | 103 |
111 } // namespace ash | 104 } // namespace ash |
112 | 105 |
113 #endif // ASH_DISPLAY_DISPLAY_CONFIGURATION_CONTROLLER_H_ | 106 #endif // ASH_DISPLAY_DISPLAY_CONFIGURATION_CONTROLLER_H_ |
OLD | NEW |