OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ | 5 #ifndef CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ |
6 #define CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ | 6 #define CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 public: | 55 public: |
56 // Called when the change of the display mode finished. It will usually | 56 // Called when the change of the display mode finished. It will usually |
57 // start the fading in the displays. | 57 // start the fading in the displays. |
58 virtual void OnDisplayModeChanged() {} | 58 virtual void OnDisplayModeChanged() {} |
59 | 59 |
60 // Called when the change of the display mode is issued but failed. | 60 // Called when the change of the display mode is issued but failed. |
61 // |failed_new_state| is the new state which the system failed to enter. | 61 // |failed_new_state| is the new state which the system failed to enter. |
62 virtual void OnDisplayModeChangeFailed(OutputState failed_new_state) {} | 62 virtual void OnDisplayModeChangeFailed(OutputState failed_new_state) {} |
63 }; | 63 }; |
64 | 64 |
| 65 class Delegate { |
| 66 public: |
| 67 // Called when displays are detected first time. This is to allow |
| 68 // chrome to select the display mode when started. |
| 69 virtual OutputState GetStateForOutputs( |
| 70 const std::vector<RROutput>& outputs) const = 0; |
| 71 }; |
| 72 |
65 OutputConfigurator(); | 73 OutputConfigurator(); |
66 virtual ~OutputConfigurator(); | 74 virtual ~OutputConfigurator(); |
67 | 75 |
68 int connected_output_count() const { return connected_output_count_; } | 76 int connected_output_count() const { return connected_output_count_; } |
69 | 77 |
70 OutputState output_state() const { return output_state_; } | 78 OutputState output_state() const { return output_state_; } |
71 | 79 |
| 80 void set_delegate(Delegate* delegate) { delegate_ = delegate; } |
| 81 |
72 // Initialization, must be called right after constructor. | 82 // Initialization, must be called right after constructor. |
73 // |is_panel_fitting_enabled| indicates hardware panel fitting support. | 83 // |is_panel_fitting_enabled| indicates hardware panel fitting support. |
74 // If |background_color_argb| is non zero and there are multiple displays, | 84 // If |background_color_argb| is non zero and there are multiple displays, |
75 // OutputConfigurator sets the background color of X's RootWindow to this | 85 // OutputConfigurator sets the background color of X's RootWindow to this |
76 // color. | 86 // color. |
77 void Init(bool is_panel_fitting_enabled, uint32 background_color_argb); | 87 void Init(bool is_panel_fitting_enabled, uint32 background_color_argb); |
78 | 88 |
79 // Stop handling display configuration events/requests. | 89 // Stop handling display configuration events/requests. |
80 void Stop(); | 90 void Stop(); |
81 | 91 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 XRRScreenResources* screen, | 175 XRRScreenResources* screen, |
166 Window window, | 176 Window window, |
167 OutputState output_state, | 177 OutputState output_state, |
168 DisplayPowerState power_state, | 178 DisplayPowerState power_state, |
169 const std::vector<OutputSnapshot>& outputs); | 179 const std::vector<OutputSnapshot>& outputs); |
170 | 180 |
171 // Outputs UMA metrics of previous state (the state that is being left). | 181 // Outputs UMA metrics of previous state (the state that is being left). |
172 // Updates |mirror_mode_preserved_aspect_| and |last_enter_state_time_|. | 182 // Updates |mirror_mode_preserved_aspect_| and |last_enter_state_time_|. |
173 void RecordPreviousStateUMA(); | 183 void RecordPreviousStateUMA(); |
174 | 184 |
| 185 // Returns next state. |
| 186 OutputState GetNextState(Display* display, |
| 187 XRRScreenResources* screen, |
| 188 OutputState current_state, |
| 189 const std::vector<OutputSnapshot>& outputs) const; |
| 190 |
| 191 |
175 // Tells if the output specified by |output_info| is for internal display. | 192 // Tells if the output specified by |output_info| is for internal display. |
176 static bool IsInternalOutput(const XRROutputInfo* output_info); | 193 static bool IsInternalOutput(const XRROutputInfo* output_info); |
177 | 194 |
178 // Returns output's native mode, None if not found. | 195 // Returns output's native mode, None if not found. |
179 static RRMode GetOutputNativeMode(const XRROutputInfo* output_info); | 196 static RRMode GetOutputNativeMode(const XRROutputInfo* output_info); |
180 | 197 |
| 198 Delegate* delegate_; |
| 199 |
181 // This is detected by the constructor to determine whether or not we should | 200 // This is detected by the constructor to determine whether or not we should |
182 // be enabled. If we aren't running on ChromeOS, we can't assume that the | 201 // be enabled. If we aren't running on ChromeOS, we can't assume that the |
183 // Xrandr X11 extension is supported. | 202 // Xrandr X11 extension is supported. |
184 // If this flag is set to false, any attempts to change the output | 203 // If this flag is set to false, any attempts to change the output |
185 // configuration to immediately fail without changing the state. | 204 // configuration to immediately fail without changing the state. |
186 bool configure_display_; | 205 bool configure_display_; |
187 | 206 |
188 // This is set externally in Init, | 207 // This is set externally in Init, |
189 // and is used to enable modes which rely on panel fitting. | 208 // and is used to enable modes which rely on panel fitting. |
190 bool is_panel_fitting_enabled_; | 209 bool is_panel_fitting_enabled_; |
(...skipping 27 matching lines...) Expand all Loading... |
218 | 237 |
219 // Indicates the time at which |output_state_| was entered. | 238 // Indicates the time at which |output_state_| was entered. |
220 base::TimeTicks last_enter_state_time_; | 239 base::TimeTicks last_enter_state_time_; |
221 | 240 |
222 DISALLOW_COPY_AND_ASSIGN(OutputConfigurator); | 241 DISALLOW_COPY_AND_ASSIGN(OutputConfigurator); |
223 }; | 242 }; |
224 | 243 |
225 } // namespace chromeos | 244 } // namespace chromeos |
226 | 245 |
227 #endif // CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ | 246 #endif // CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ |
OLD | NEW |