Index: ui/display/chromeos/display_configurator.h |
diff --git a/ui/display/chromeos/display_configurator.h b/ui/display/chromeos/display_configurator.h |
index 3c660d7b3c8c8b23ab8f82faa777f275794456e2..cfef0bdb620f0114f9f4d2f43a7c5f579aacccfd 100644 |
--- a/ui/display/chromeos/display_configurator.h |
+++ b/ui/display/chromeos/display_configurator.h |
@@ -13,7 +13,6 @@ |
#include "base/event_types.h" |
#include "base/memory/scoped_ptr.h" |
-#include "base/memory/weak_ptr.h" |
#include "base/observer_list.h" |
#include "base/timer/timer.h" |
#include "third_party/cros_system_api/dbus/service_constants.h" |
@@ -32,7 +31,6 @@ |
class DisplayMode; |
class DisplaySnapshot; |
class NativeDisplayDelegate; |
-class UpdateDisplayConfigurationTask; |
// This class interacts directly with the system display configurator. |
class DISPLAY_EXPORT DisplayConfigurator : public NativeDisplayObserver { |
@@ -174,7 +172,7 @@ |
DisplayConfigurator(); |
virtual ~DisplayConfigurator(); |
- MultipleDisplayState display_state() const { return current_display_state_; } |
+ MultipleDisplayState display_state() const { return display_state_; } |
chromeos::DisplayPowerState requested_power_state() const { |
return requested_power_state_; |
} |
@@ -224,12 +222,12 @@ |
// the display(s) in question so that the low power state is engaged. |
// |flags| contains bitwise-or-ed kSetDisplayPower* values. Returns true if |
// the system successfully enters (or was already in) |power_state|. |
- void SetDisplayPower(chromeos::DisplayPowerState power_state, int flags); |
+ bool SetDisplayPower(chromeos::DisplayPowerState power_state, int flags); |
// Force switching the display mode to |new_state|. Returns false if |
// switching failed (possibly because |new_state| is invalid for the |
// current set of connected displays). |
- void SetDisplayMode(MultipleDisplayState new_state); |
+ bool SetDisplayMode(MultipleDisplayState new_state); |
// NativeDisplayDelegate::Observer overrides: |
virtual void OnConfigurationChanged() override; |
@@ -281,8 +279,6 @@ |
ui::ColorCalibrationProfile new_profile); |
private: |
- class DisplayLayoutManagerImpl; |
- |
// Mapping a display_id to a protection request bitmask. |
typedef std::map<int64_t, uint32_t> ContentProtections; |
// Mapping a client to its protection request. |
@@ -292,6 +288,29 @@ |
// Performs platform specific delegate initialization. |
scoped_ptr<NativeDisplayDelegate> CreatePlatformNativeDisplayDelegate(); |
+ // Updates |cached_displays_| to contain currently-connected displays. Calls |
+ // |delegate_->GetDisplays()| and then does additional work, like finding the |
+ // mirror mode and setting user-preferred modes. Note that the server must be |
+ // grabbed via |delegate_->GrabServer()| first. |
+ void UpdateCachedDisplays(); |
+ |
+ // Helper method for UpdateCachedDisplays() that initializes the passed-in |
+ // displays' |mirror_mode| fields by looking for a mode in |internal_display| |
+ // and |external_display| having the same resolution. Returns false if a |
+ // shared |
+ // mode wasn't found or created. |
+ // |
+ // |try_panel_fitting| allows creating a panel-fitting mode for |
+ // |internal_display| instead of only searching for a matching mode (note that |
+ // it may lead to a crash if |internal_info| is not capable of panel fitting). |
+ // |
+ // |preserve_aspect| limits the search/creation only to the modes having the |
+ // native aspect ratio of |external_display|. |
+ bool FindMirrorMode(DisplayState* internal_display, |
+ DisplayState* external_display, |
+ bool try_panel_fitting, |
+ bool preserve_aspect); |
+ |
// Configures displays. Invoked by |configure_timer_|. |
void ConfigureDisplays(); |
@@ -301,6 +320,22 @@ |
// Notifies observers about an attempted state change. |
void NotifyObservers(bool success, MultipleDisplayState attempted_state); |
+ |
+ // Switches to the state specified in |display_state| and |power_state|. |
+ // If the hardware mirroring failed and |mirroring_controller_| is set, |
+ // it switches to |STATE_DUAL_EXTENDED| and calls |SetSoftwareMirroring()| |
+ // to enable software based mirroring. |
+ // On success, updates |display_state_|, |power_state_|, and |
+ // |cached_displays_| and returns true. |
+ bool EnterStateOrFallBackToSoftwareMirroring( |
+ MultipleDisplayState display_state, |
+ chromeos::DisplayPowerState power_state); |
+ |
+ // Switches to the state specified in |display_state| and |power_state|. |
+ // On success, updates |display_state_|, |power_state_|, and |
+ // |cached_displays_| and returns true. |
+ bool EnterState(MultipleDisplayState display_state, |
+ chromeos::DisplayPowerState power_state); |
// Returns the display state that should be used with |cached_displays_| while |
// in |power_state|. |
@@ -316,23 +351,6 @@ |
// Applies display protections according to requests. |
bool ApplyProtections(const ContentProtections& requests); |
- |
- // If |configuration_task_| isn't initialized, initializes it and starts the |
- // configuration task. |
- void RunPendingConfiguration(); |
- |
- // Callback for |configuration_taks_|. When the configuration process finishes |
- // this is called with the result (|success|) and the updated display state. |
- void OnConfigured(bool success, |
- const std::vector<DisplayState>& displays, |
- const gfx::Size& framebuffer_size, |
- MultipleDisplayState new_display_state, |
- chromeos::DisplayPowerState new_power_state); |
- |
- // Helps in identifying if a configuration task needs to be scheduled. |
- // Return true if any of the |requested_*| parameters have been updated. False |
- // otherwise. |
- bool ShouldRunConfigurationTask() const; |
StateController* state_controller_; |
SoftwareMirroringController* mirroring_controller_; |
@@ -348,34 +366,20 @@ |
// configuration to immediately fail without changing the state. |
bool configure_display_; |
- // Current configuration state. |
- MultipleDisplayState current_display_state_; |
+ // The current display state. |
+ MultipleDisplayState display_state_; |
+ |
+ gfx::Size framebuffer_size_; |
+ |
+ // The last-requested and current power state. These may differ if |
+ // configuration fails: SetDisplayMode() needs the last-requested state while |
+ // SetDisplayPower() needs the current state. |
+ chromeos::DisplayPowerState requested_power_state_; |
chromeos::DisplayPowerState current_power_state_; |
- |
- // Pending requests. These values are used when triggering the next display |
- // configuration. |
- // |
- // Stores the user requested state or INVALID if nothing was requested. |
- MultipleDisplayState requested_display_state_; |
- |
- // Stores the requested power state. |
- chromeos::DisplayPowerState requested_power_state_; |
- |
- // True if |requested_power_state_| has been changed due to a user request. |
- bool requested_power_state_change_; |
- |
- // Bitwise-or value of the |kSetDisplayPower*| flags defined above. |
- int requested_power_flags_; |
- |
- // True if the caller wants to force the display configuration process. |
- bool force_configure_; |
// Most-recently-used display configuration. Note that the actual |
// configuration changes asynchronously. |
DisplayStateList cached_displays_; |
- |
- // Most-recently-used framebuffer size. |
- gfx::Size framebuffer_size_; |
ObserverList<Observer> observers_; |
@@ -393,13 +397,6 @@ |
// Display controlled by an external entity. |
bool display_externally_controlled_; |
- scoped_ptr<DisplayLayoutManager> layout_manager_; |
- |
- scoped_ptr<UpdateDisplayConfigurationTask> configuration_task_; |
- |
- // This must be the last variable. |
- base::WeakPtrFactory<DisplayConfigurator> weak_ptr_factory_; |
- |
DISALLOW_COPY_AND_ASSIGN(DisplayConfigurator); |
}; |