OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef UI_DISPLAY_CHROMEOS_UPDATE_DISPLAY_CONFIGURATION_TASK_H_ |
| 6 #define UI_DISPLAY_CHROMEOS_UPDATE_DISPLAY_CONFIGURATION_TASK_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/memory/weak_ptr.h" |
| 11 #include "ui/display/chromeos/configure_displays_task.h" |
| 12 #include "ui/display/chromeos/display_configurator.h" |
| 13 |
| 14 namespace ui { |
| 15 |
| 16 class DisplaySnapshot; |
| 17 class NativeDisplayDelegate; |
| 18 |
| 19 class DISPLAY_EXPORT UpdateDisplayConfigurationTask { |
| 20 public: |
| 21 typedef base::Callback<void( |
| 22 bool /* success */, |
| 23 const std::vector<DisplayConfigurator::DisplayState>& /* displays */, |
| 24 const gfx::Size& /* framebuffer_size */, |
| 25 MultipleDisplayState /* new_display_state */, |
| 26 chromeos::DisplayPowerState /* new_power_state */)> ResponseCallback; |
| 27 |
| 28 UpdateDisplayConfigurationTask( |
| 29 NativeDisplayDelegate* delegate, |
| 30 DisplayConfigurator::DisplayLayoutManager* layout_manager, |
| 31 MultipleDisplayState new_display_state, |
| 32 chromeos::DisplayPowerState new_power_state, |
| 33 int power_flags, |
| 34 uint32_t background_color_argb, |
| 35 bool force_configure, |
| 36 const ResponseCallback& callback); |
| 37 ~UpdateDisplayConfigurationTask(); |
| 38 |
| 39 void Run(); |
| 40 |
| 41 private: |
| 42 // Callback to NativeDisplayDelegate::GetDisplays(). |
| 43 void OnDisplaysUpdated(const std::vector<DisplaySnapshot*>& displays); |
| 44 |
| 45 // Callback to ConfigureDisplaysTask used to process the result of a display |
| 46 // configuration run. |
| 47 void OnStateEntered(ConfigureDisplaysTask::Status status); |
| 48 |
| 49 // If the initial display configuration run failed due to errors entering |
| 50 // mirror more, another configuration run is executed to enter software |
| 51 // mirroring. This is the callback used to process the result of that |
| 52 // configuration. |
| 53 void OnEnableSoftwareMirroring(ConfigureDisplaysTask::Status status); |
| 54 |
| 55 // Starts the configuration process. |callback| is used to continue the task |
| 56 // after |configure_taks_| finishes executing. |
| 57 void EnterState(const ConfigureDisplaysTask::ResponseCallback& callback); |
| 58 |
| 59 // Finishes display configuration and runs |callback_|. |
| 60 void FinishConfiguration(bool success); |
| 61 |
| 62 // Returns true if the DPMS state should be force to on. |
| 63 bool ShouldForceDpms() const; |
| 64 |
| 65 // Returns true if a display configuration is required. |
| 66 bool ShouldConfigure() const; |
| 67 |
| 68 // Returns a display state based on the power state. |
| 69 MultipleDisplayState ChooseDisplayState() const; |
| 70 |
| 71 NativeDisplayDelegate* delegate_; // Not owned. |
| 72 DisplayConfigurator::DisplayLayoutManager* layout_manager_; // Not owned. |
| 73 |
| 74 // Requested display state. |
| 75 MultipleDisplayState new_display_state_; |
| 76 |
| 77 // Requested power state. |
| 78 chromeos::DisplayPowerState new_power_state_; |
| 79 |
| 80 // Bitwise-or-ed values for the kSetDisplayPower* values defined in |
| 81 // DisplayConfigurator. |
| 82 int power_flags_; |
| 83 |
| 84 uint32_t background_color_argb_; |
| 85 |
| 86 bool force_configure_; |
| 87 |
| 88 // Used to signal that the task has finished. |
| 89 ResponseCallback callback_; |
| 90 |
| 91 bool force_dpms_; |
| 92 |
| 93 // List of updated displays. |
| 94 std::vector<DisplayConfigurator::DisplayState> cached_displays_; |
| 95 |
| 96 gfx::Size framebuffer_size_; |
| 97 |
| 98 scoped_ptr<ConfigureDisplaysTask> configure_task_; |
| 99 |
| 100 base::WeakPtrFactory<UpdateDisplayConfigurationTask> weak_ptr_factory_; |
| 101 |
| 102 DISALLOW_COPY_AND_ASSIGN(UpdateDisplayConfigurationTask); |
| 103 }; |
| 104 |
| 105 } // namespace ui |
| 106 |
| 107 #endif // UI_DISPLAY_CHROMEOS_UPDATE_DISPLAY_CONFIGURATION_TASK_H_ |
OLD | NEW |