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