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(NativeDisplayDelegate
* delegate
,
29 DisplayLayoutManager
* layout_manager
,
30 MultipleDisplayState new_display_state
,
31 chromeos::DisplayPowerState new_power_state
,
33 uint32_t background_color_argb
,
35 const ResponseCallback
& callback
);
36 ~UpdateDisplayConfigurationTask();
41 // Callback to NativeDisplayDelegate::GetDisplays().
42 void OnDisplaysUpdated(const std::vector
<DisplaySnapshot
*>& displays
);
44 // Callback to ConfigureDisplaysTask used to process the result of a display
46 void OnStateEntered(ConfigureDisplaysTask::Status status
);
48 // If the initial display configuration run failed due to errors entering
49 // mirror more, another configuration run is executed to enter software
50 // mirroring. This is the callback used to process the result of that
52 void OnEnableSoftwareMirroring(ConfigureDisplaysTask::Status status
);
54 // Starts the configuration process. |callback| is used to continue the task
55 // after |configure_taks_| finishes executing.
56 void EnterState(const ConfigureDisplaysTask::ResponseCallback
& callback
);
58 // Finishes display configuration and runs |callback_|.
59 void FinishConfiguration(bool success
);
61 // Returns true if the DPMS state should be force to on.
62 bool ShouldForceDpms() const;
64 // Returns true if a display configuration is required.
65 bool ShouldConfigure() const;
67 // Returns a display state based on the power state.
68 MultipleDisplayState
ChooseDisplayState() const;
70 NativeDisplayDelegate
* delegate_
; // Not owned.
71 DisplayLayoutManager
* layout_manager_
; // Not owned.
73 // Requested display state.
74 MultipleDisplayState new_display_state_
;
76 // Requested power state.
77 chromeos::DisplayPowerState new_power_state_
;
79 // Bitwise-or-ed values for the kSetDisplayPower* values defined in
80 // DisplayConfigurator.
83 uint32_t background_color_argb_
;
85 bool force_configure_
;
87 // Used to signal that the task has finished.
88 ResponseCallback callback_
;
92 // List of updated displays.
93 std::vector
<DisplaySnapshot
*> cached_displays_
;
95 gfx::Size framebuffer_size_
;
97 scoped_ptr
<ConfigureDisplaysTask
> configure_task_
;
99 base::WeakPtrFactory
<UpdateDisplayConfigurationTask
> weak_ptr_factory_
;
101 DISALLOW_COPY_AND_ASSIGN(UpdateDisplayConfigurationTask
);
106 #endif // UI_DISPLAY_CHROMEOS_UPDATE_DISPLAY_CONFIGURATION_TASK_H_