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 // This class controls Display related configuration. Specifically it: | 8 #include <memory> |
9 // * Handles animated transitions where appropriate. | |
10 // * Limits the frequency of certain operations. | |
11 // * Provides a single interface for UI and API classes. | |
12 // * TODO: Forwards display configuration changed events to UI and API classes. | |
13 | 9 |
14 #include "ash/ash_export.h" | 10 #include "ash/ash_export.h" |
15 #include "ash/display/window_tree_host_manager.h" | 11 #include "ash/display/window_tree_host_manager.h" |
16 #include "base/macros.h" | 12 #include "base/macros.h" |
17 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
18 #include "ui/gfx/display.h" | 14 #include "ui/gfx/display.h" |
19 | 15 |
20 namespace display { | 16 namespace display { |
21 class DisplayLayout; | 17 class DisplayLayout; |
22 } | 18 } |
23 | 19 |
24 namespace ash { | 20 namespace ash { |
25 | 21 |
26 namespace test { | 22 namespace test { |
27 class ShellTestApi; | 23 class ShellTestApi; |
28 } // namespace test | 24 } // namespace test |
29 | 25 |
30 class DisplayAnimator; | 26 class DisplayAnimator; |
31 class DisplayManager; | 27 class DisplayManager; |
32 | 28 |
| 29 // This class controls Display related configuration. Specifically it: |
| 30 // * Handles animated transitions where appropriate. |
| 31 // * Limits the frequency of certain operations. |
| 32 // * Provides a single interface for UI and API classes. |
| 33 // * TODO: Forwards display configuration changed events to UI and API classes. |
33 class ASH_EXPORT DisplayConfigurationController | 34 class ASH_EXPORT DisplayConfigurationController |
34 : public WindowTreeHostManager::Observer { | 35 : public WindowTreeHostManager::Observer { |
35 public: | 36 public: |
36 DisplayConfigurationController( | 37 DisplayConfigurationController( |
37 DisplayManager* display_manager, | 38 DisplayManager* display_manager, |
38 WindowTreeHostManager* window_tree_host_manager); | 39 WindowTreeHostManager* window_tree_host_manager); |
39 ~DisplayConfigurationController() override; | 40 ~DisplayConfigurationController() override; |
40 | 41 |
41 // Sets the layout for the current displays with a fade in/out | 42 // Sets the layout for the current displays with a fade in/out |
42 // animation. Currently |display_id| is assumed to be the secondary | 43 // animation. Currently |display_id| is assumed to be the secondary |
43 // display. TODO(oshima/stevenjb): Support 3+ displays. | 44 // display. TODO(oshima/stevenjb): Support 3+ displays. |
44 void SetDisplayLayout(scoped_ptr<display::DisplayLayout> layout, | 45 void SetDisplayLayout(std::unique_ptr<display::DisplayLayout> layout, |
45 bool user_action); | 46 bool user_action); |
46 | 47 |
47 // 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 |
48 // displays. | 49 // displays. |
49 void SetMirrorMode(bool mirror, bool user_action); | 50 void SetMirrorMode(bool mirror, bool user_action); |
50 | 51 |
51 // Sets the display's rotation with animation if available. | 52 // Sets the display's rotation with animation if available. |
52 void SetDisplayRotation(int64_t display_id, | 53 void SetDisplayRotation(int64_t display_id, |
53 gfx::Display::Rotation rotation, | 54 gfx::Display::Rotation rotation, |
54 gfx::Display::RotationSource source, | 55 gfx::Display::RotationSource source, |
(...skipping 11 matching lines...) Expand all Loading... |
66 // Allow tests to skip animations. | 67 // Allow tests to skip animations. |
67 void ResetAnimatorForTest(); | 68 void ResetAnimatorForTest(); |
68 | 69 |
69 private: | 70 private: |
70 class DisplayChangeLimiter; | 71 class DisplayChangeLimiter; |
71 | 72 |
72 // Sets the timeout for the DisplayChangeLimiter if it exists. Call this | 73 // Sets the timeout for the DisplayChangeLimiter if it exists. Call this |
73 // *before* starting any animations. | 74 // *before* starting any animations. |
74 void SetThrottleTimeout(int64_t throttle_ms); | 75 void SetThrottleTimeout(int64_t throttle_ms); |
75 bool IsLimited(); | 76 bool IsLimited(); |
76 void SetDisplayLayoutImpl(scoped_ptr<display::DisplayLayout> layout); | 77 void SetDisplayLayoutImpl(std::unique_ptr<display::DisplayLayout> layout); |
77 void SetMirrorModeImpl(bool mirror); | 78 void SetMirrorModeImpl(bool mirror); |
78 void SetPrimaryDisplayIdImpl(int64_t display_id); | 79 void SetPrimaryDisplayIdImpl(int64_t display_id); |
79 | 80 |
80 DisplayManager* display_manager_; // weak ptr | 81 DisplayManager* display_manager_; // weak ptr |
81 WindowTreeHostManager* window_tree_host_manager_; // weak ptr | 82 WindowTreeHostManager* window_tree_host_manager_; // weak ptr |
82 scoped_ptr<DisplayAnimator> display_animator_; | 83 std::unique_ptr<DisplayAnimator> display_animator_; |
83 scoped_ptr<DisplayChangeLimiter> limiter_; | 84 std::unique_ptr<DisplayChangeLimiter> limiter_; |
84 | 85 |
85 base::WeakPtrFactory<DisplayConfigurationController> weak_ptr_factory_; | 86 base::WeakPtrFactory<DisplayConfigurationController> weak_ptr_factory_; |
86 | 87 |
87 DISALLOW_COPY_AND_ASSIGN(DisplayConfigurationController); | 88 DISALLOW_COPY_AND_ASSIGN(DisplayConfigurationController); |
88 }; | 89 }; |
89 | 90 |
90 } // namespace ash | 91 } // namespace ash |
91 | 92 |
92 #endif // ASH_DISPLAY_DISPLAY_CONFIGURATION_CONTROLLER_H_ | 93 #endif // ASH_DISPLAY_DISPLAY_CONFIGURATION_CONTROLLER_H_ |
OLD | NEW |