OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 UI_DISPLAY_CHROMEOS_DISPLAY_CONFIGURATOR_H_ | 5 #ifndef UI_DISPLAY_CHROMEOS_DISPLAY_CONFIGURATOR_H_ |
6 #define UI_DISPLAY_CHROMEOS_DISPLAY_CONFIGURATOR_H_ | 6 #define UI_DISPLAY_CHROMEOS_DISPLAY_CONFIGURATOR_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 22 matching lines...) Expand all Loading... | |
33 class DisplaySnapshot; | 33 class DisplaySnapshot; |
34 class NativeDisplayDelegate; | 34 class NativeDisplayDelegate; |
35 class UpdateDisplayConfigurationTask; | 35 class UpdateDisplayConfigurationTask; |
36 | 36 |
37 // This class interacts directly with the system display configurator. | 37 // This class interacts directly with the system display configurator. |
38 class DISPLAY_EXPORT DisplayConfigurator : public NativeDisplayObserver { | 38 class DISPLAY_EXPORT DisplayConfigurator : public NativeDisplayObserver { |
39 public: | 39 public: |
40 typedef uint64_t ContentProtectionClientId; | 40 typedef uint64_t ContentProtectionClientId; |
41 static const ContentProtectionClientId kInvalidClientId = 0; | 41 static const ContentProtectionClientId kInvalidClientId = 0; |
42 | 42 |
43 typedef base::Callback<void(bool)> ConfigurationCallback; | |
44 | |
43 struct DisplayState { | 45 struct DisplayState { |
44 DisplayState(); | 46 DisplayState(); |
45 | 47 |
46 DisplaySnapshot* display; // Not owned. | 48 DisplaySnapshot* display; // Not owned. |
47 | 49 |
48 // User-selected mode for the display. | 50 // User-selected mode for the display. |
49 const DisplayMode* selected_mode; | 51 const DisplayMode* selected_mode; |
50 | 52 |
51 // Mode used when displaying the same desktop on multiple displays. | 53 // Mode used when displaying the same desktop on multiple displays. |
52 const DisplayMode* mirror_mode; | 54 const DisplayMode* mirror_mode; |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
215 // DisplayConfigurator sets the background color of X's RootWindow to this | 217 // DisplayConfigurator sets the background color of X's RootWindow to this |
216 // color. | 218 // color. |
217 void ForceInitialConfigure(uint32_t background_color_argb); | 219 void ForceInitialConfigure(uint32_t background_color_argb); |
218 | 220 |
219 // Stop handling display configuration events/requests. | 221 // Stop handling display configuration events/requests. |
220 void PrepareForExit(); | 222 void PrepareForExit(); |
221 | 223 |
222 // Called when powerd notifies us that some set of displays should be turned | 224 // Called when powerd notifies us that some set of displays should be turned |
223 // on or off. This requires enabling or disabling the CRTC associated with | 225 // on or off. This requires enabling or disabling the CRTC associated with |
224 // the display(s) in question so that the low power state is engaged. | 226 // the display(s) in question so that the low power state is engaged. |
225 // |flags| contains bitwise-or-ed kSetDisplayPower* values. Returns true if | 227 // |flags| contains bitwise-or-ed kSetDisplayPower* values. After the |
226 // the system successfully enters (or was already in) |power_state|. | 228 // configuration finishes |callback| is called with the status of the |
227 void SetDisplayPower(chromeos::DisplayPowerState power_state, int flags); | 229 // operation. |
230 void SetDisplayPower(chromeos::DisplayPowerState power_state, | |
231 int flags, | |
232 const ConfigurationCallback& callback); | |
228 | 233 |
229 // Force switching the display mode to |new_state|. Returns false if | 234 // Force switching the display mode to |new_state|. Returns false if |
230 // switching failed (possibly because |new_state| is invalid for the | 235 // switching failed (possibly because |new_state| is invalid for the |
231 // current set of connected displays). | 236 // current set of connected displays). |
232 void SetDisplayMode(MultipleDisplayState new_state); | 237 void SetDisplayMode(MultipleDisplayState new_state); |
233 | 238 |
234 // NativeDisplayDelegate::Observer overrides: | 239 // NativeDisplayDelegate::Observer overrides: |
235 void OnConfigurationChanged() override; | 240 void OnConfigurationChanged() override; |
236 | 241 |
237 void AddObserver(Observer* observer); | 242 void AddObserver(Observer* observer); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
327 const std::vector<DisplayState>& displays, | 332 const std::vector<DisplayState>& displays, |
328 const gfx::Size& framebuffer_size, | 333 const gfx::Size& framebuffer_size, |
329 MultipleDisplayState new_display_state, | 334 MultipleDisplayState new_display_state, |
330 chromeos::DisplayPowerState new_power_state); | 335 chromeos::DisplayPowerState new_power_state); |
331 | 336 |
332 // Helps in identifying if a configuration task needs to be scheduled. | 337 // Helps in identifying if a configuration task needs to be scheduled. |
333 // Return true if any of the |requested_*| parameters have been updated. False | 338 // Return true if any of the |requested_*| parameters have been updated. False |
334 // otherwise. | 339 // otherwise. |
335 bool ShouldRunConfigurationTask() const; | 340 bool ShouldRunConfigurationTask() const; |
336 | 341 |
342 // Helper functions which will call the callbacks in | |
343 // |pending_configuration_callbacks_| and |queued_configuration_callbacks_| | |
344 // and clear the lists after. |success| is the configuration status used when | |
345 // calling the callbacks. | |
346 void CallAndClearPendingCallbacks(bool success); | |
347 void CallAndClearQueuedCallbacks(bool success); | |
348 | |
337 StateController* state_controller_; | 349 StateController* state_controller_; |
338 SoftwareMirroringController* mirroring_controller_; | 350 SoftwareMirroringController* mirroring_controller_; |
339 scoped_ptr<NativeDisplayDelegate> native_display_delegate_; | 351 scoped_ptr<NativeDisplayDelegate> native_display_delegate_; |
340 | 352 |
341 // Used to enable modes which rely on panel fitting. | 353 // Used to enable modes which rely on panel fitting. |
342 bool is_panel_fitting_enabled_; | 354 bool is_panel_fitting_enabled_; |
343 | 355 |
344 // This is detected by the constructor to determine whether or not we should | 356 // This is detected by the constructor to determine whether or not we should |
345 // be enabled. If we aren't running on ChromeOS, we can't assume that the | 357 // be enabled. If we aren't running on ChromeOS, we can't assume that the |
346 // Xrandr X11 extension is supported. | 358 // Xrandr X11 extension is supported. |
(...skipping 13 matching lines...) Expand all Loading... | |
360 | 372 |
361 // Stores the requested power state. | 373 // Stores the requested power state. |
362 chromeos::DisplayPowerState requested_power_state_; | 374 chromeos::DisplayPowerState requested_power_state_; |
363 | 375 |
364 // True if |requested_power_state_| has been changed due to a user request. | 376 // True if |requested_power_state_| has been changed due to a user request. |
365 bool requested_power_state_change_; | 377 bool requested_power_state_change_; |
366 | 378 |
367 // Bitwise-or value of the |kSetDisplayPower*| flags defined above. | 379 // Bitwise-or value of the |kSetDisplayPower*| flags defined above. |
368 int requested_power_flags_; | 380 int requested_power_flags_; |
369 | 381 |
382 // List of callbacks from callers waiting for the display configuration to | |
383 // start/finish. Note these callbacks belong to pending request not a | |
Daniel Erat
2015/01/30 17:14:07
the use of "pending" here is pretty confusing give
dnicoara
2015/01/30 18:25:28
Done.
| |
384 // request currently active. | |
385 std::vector<ConfigurationCallback> queued_configuration_callbacks_; | |
386 | |
387 // List of callbacks belonging to the currently running display configuration | |
388 // task. | |
389 std::vector<ConfigurationCallback> pending_configuration_callbacks_; | |
390 | |
370 // True if the caller wants to force the display configuration process. | 391 // True if the caller wants to force the display configuration process. |
371 bool force_configure_; | 392 bool force_configure_; |
372 | 393 |
373 // Most-recently-used display configuration. Note that the actual | 394 // Most-recently-used display configuration. Note that the actual |
374 // configuration changes asynchronously. | 395 // configuration changes asynchronously. |
375 DisplayStateList cached_displays_; | 396 DisplayStateList cached_displays_; |
376 | 397 |
377 // Most-recently-used framebuffer size. | 398 // Most-recently-used framebuffer size. |
378 gfx::Size framebuffer_size_; | 399 gfx::Size framebuffer_size_; |
379 | 400 |
(...skipping 19 matching lines...) Expand all Loading... | |
399 | 420 |
400 // This must be the last variable. | 421 // This must be the last variable. |
401 base::WeakPtrFactory<DisplayConfigurator> weak_ptr_factory_; | 422 base::WeakPtrFactory<DisplayConfigurator> weak_ptr_factory_; |
402 | 423 |
403 DISALLOW_COPY_AND_ASSIGN(DisplayConfigurator); | 424 DISALLOW_COPY_AND_ASSIGN(DisplayConfigurator); |
404 }; | 425 }; |
405 | 426 |
406 } // namespace ui | 427 } // namespace ui |
407 | 428 |
408 #endif // UI_DISPLAY_CHROMEOS_DISPLAY_CONFIGURATOR_H_ | 429 #endif // UI_DISPLAY_CHROMEOS_DISPLAY_CONFIGURATOR_H_ |
OLD | NEW |