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_
10 #include "base/memory/weak_ptr.h"
11 #include "ui/display/chromeos/configure_displays_task.h"
12 #include "ui/display/chromeos/display_configurator.h"
16 class DisplaySnapshot
;
17 class NativeDisplayDelegate
;
19 class DISPLAY_EXPORT UpdateDisplayConfigurationTask
{
21 typedef base::Callback
<void(
23 const std::vector
<DisplaySnapshot
*>& /* 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
,
34 uint32_t background_color_argb
,
36 const ResponseCallback
& callback
);
37 ~UpdateDisplayConfigurationTask();
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
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
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.
84 uint32_t background_color_argb_
;
86 bool force_configure_
;
88 // Used to signal that the task has finished.
89 ResponseCallback callback_
;
93 // List of updated displays.
94 std::vector
<DisplaySnapshot
*> 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
);
107 #endif // UI_DISPLAY_CHROMEOS_UPDATE_DISPLAY_CONFIGURATION_TASK_H_