Correctly track texture cleared state for sharing
[chromium-blink-merge.git] / ui / display / chromeos / update_display_configuration_task.h
blob868f76fce50b0623ee3847b572ed2d0d06e6470e
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.
5 #ifndef UI_DISPLAY_CHROMEOS_UPDATE_DISPLAY_CONFIGURATION_TASK_H_
6 #define UI_DISPLAY_CHROMEOS_UPDATE_DISPLAY_CONFIGURATION_TASK_H_
8 #include <vector>
10 #include "base/memory/weak_ptr.h"
11 #include "ui/display/chromeos/configure_displays_task.h"
12 #include "ui/display/chromeos/display_configurator.h"
14 namespace ui {
16 class DisplaySnapshot;
17 class NativeDisplayDelegate;
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;
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();
39 void Run();
41 private:
42 // Callback to NativeDisplayDelegate::GetDisplays().
43 void OnDisplaysUpdated(const std::vector<DisplaySnapshot*>& displays);
45 // Callback to ConfigureDisplaysTask used to process the result of a display
46 // configuration run.
47 void OnStateEntered(ConfigureDisplaysTask::Status status);
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);
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);
59 // Finishes display configuration and runs |callback_|.
60 void FinishConfiguration(bool success);
62 // Returns true if the DPMS state should be force to on.
63 bool ShouldForceDpms() const;
65 // Returns true if a display configuration is required.
66 bool ShouldConfigure() const;
68 // Returns a display state based on the power state.
69 MultipleDisplayState ChooseDisplayState() const;
71 NativeDisplayDelegate* delegate_; // Not owned.
72 DisplayConfigurator::DisplayLayoutManager* layout_manager_; // Not owned.
74 // Requested display state.
75 MultipleDisplayState new_display_state_;
77 // Requested power state.
78 chromeos::DisplayPowerState new_power_state_;
80 // Bitwise-or-ed values for the kSetDisplayPower* values defined in
81 // DisplayConfigurator.
82 int power_flags_;
84 uint32_t background_color_argb_;
86 bool force_configure_;
88 // Used to signal that the task has finished.
89 ResponseCallback callback_;
91 bool force_dpms_;
93 // List of updated displays.
94 std::vector<DisplayConfigurator::DisplayState> cached_displays_;
96 gfx::Size framebuffer_size_;
98 scoped_ptr<ConfigureDisplaysTask> configure_task_;
100 base::WeakPtrFactory<UpdateDisplayConfigurationTask> weak_ptr_factory_;
102 DISALLOW_COPY_AND_ASSIGN(UpdateDisplayConfigurationTask);
105 } // namespace ui
107 #endif // UI_DISPLAY_CHROMEOS_UPDATE_DISPLAY_CONFIGURATION_TASK_H_