| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ | 5 #ifndef UI_DISPLAY_CHROMEOS_OUTPUT_CONFIGURATOR_H_ |
| 6 #define CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ | 6 #define UI_DISPLAY_CHROMEOS_OUTPUT_CONFIGURATOR_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/event_types.h" | 13 #include "base/event_types.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
| 16 #include "base/timer/timer.h" | 16 #include "base/timer/timer.h" |
| 17 #include "chromeos/chromeos_export.h" | |
| 18 #include "chromeos/display/native_display_observer.h" | |
| 19 #include "third_party/cros_system_api/dbus/service_constants.h" | 17 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 18 #include "ui/display/chromeos/native_display_observer.h" |
| 20 #include "ui/display/display_constants.h" | 19 #include "ui/display/display_constants.h" |
| 20 #include "ui/display/display_export.h" |
| 21 | 21 |
| 22 // Forward declarations for Xlib and Xrandr. | 22 // Forward declarations for Xlib and Xrandr. |
| 23 // This is so unused X definitions don't pollute the namespace. | 23 // This is so unused X definitions don't pollute the namespace. |
| 24 typedef unsigned long XID; | 24 typedef unsigned long XID; |
| 25 typedef XID RROutput; | 25 typedef XID RROutput; |
| 26 typedef XID RRCrtc; | 26 typedef XID RRCrtc; |
| 27 typedef XID RRMode; | 27 typedef XID RRMode; |
| 28 | 28 |
| 29 namespace chromeos { | 29 namespace ui { |
| 30 | 30 |
| 31 class NativeDisplayDelegate; | 31 class NativeDisplayDelegate; |
| 32 | 32 |
| 33 // This class interacts directly with the underlying Xrandr API to manipulate | 33 // This class interacts directly with the underlying Xrandr API to manipulate |
| 34 // CTRCs and Outputs. | 34 // CTRCs and Outputs. |
| 35 class CHROMEOS_EXPORT OutputConfigurator | 35 class DISPLAY_EXPORT OutputConfigurator : public NativeDisplayObserver { |
| 36 : public NativeDisplayObserver { | |
| 37 public: | 36 public: |
| 38 typedef uint64_t OutputProtectionClientId; | 37 typedef uint64_t OutputProtectionClientId; |
| 39 static const OutputProtectionClientId kInvalidClientId = 0; | 38 static const OutputProtectionClientId kInvalidClientId = 0; |
| 40 | 39 |
| 41 struct ModeInfo { | 40 struct ModeInfo { |
| 42 ModeInfo(); | 41 ModeInfo(); |
| 43 ModeInfo(int width, int height, bool interlaced, float refresh_rate); | 42 ModeInfo(int width, int height, bool interlaced, float refresh_rate); |
| 44 | 43 |
| 45 int width; | 44 int width; |
| 46 int height; | 45 int height; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 int x; | 86 int x; |
| 88 int y; | 87 int y; |
| 89 | 88 |
| 90 // Output's physical dimensions. | 89 // Output's physical dimensions. |
| 91 uint64 width_mm; | 90 uint64 width_mm; |
| 92 uint64 height_mm; | 91 uint64 height_mm; |
| 93 | 92 |
| 94 bool is_aspect_preserving_scaling; | 93 bool is_aspect_preserving_scaling; |
| 95 | 94 |
| 96 // The type of output. | 95 // The type of output. |
| 97 ui::OutputType type; | 96 OutputType type; |
| 98 | 97 |
| 99 // Map from mode IDs to details about the corresponding modes. | 98 // Map from mode IDs to details about the corresponding modes. |
| 100 ModeInfoMap mode_infos; | 99 ModeInfoMap mode_infos; |
| 101 | 100 |
| 102 // XInput device ID or 0 if this output isn't a touchscreen. | 101 // XInput device ID or 0 if this output isn't a touchscreen. |
| 103 int touch_device_id; | 102 int touch_device_id; |
| 104 | 103 |
| 105 CoordinateTransformation transform; | 104 CoordinateTransformation transform; |
| 106 | 105 |
| 107 // Display id for this output. | 106 // Display id for this output. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 120 | 119 |
| 121 // Called after the display mode has been changed. |output| contains the | 120 // Called after the display mode has been changed. |output| contains the |
| 122 // just-applied configuration. Note that the X server is no longer grabbed | 121 // just-applied configuration. Note that the X server is no longer grabbed |
| 123 // when this method is called, so the actual configuration could've changed | 122 // when this method is called, so the actual configuration could've changed |
| 124 // already. | 123 // already. |
| 125 virtual void OnDisplayModeChanged( | 124 virtual void OnDisplayModeChanged( |
| 126 const std::vector<OutputSnapshot>& outputs) {} | 125 const std::vector<OutputSnapshot>& outputs) {} |
| 127 | 126 |
| 128 // Called after a display mode change attempt failed. |failed_new_state| is | 127 // Called after a display mode change attempt failed. |failed_new_state| is |
| 129 // the new state which the system failed to enter. | 128 // the new state which the system failed to enter. |
| 130 virtual void OnDisplayModeChangeFailed(ui::OutputState failed_new_state) {} | 129 virtual void OnDisplayModeChangeFailed(OutputState failed_new_state) {} |
| 131 }; | 130 }; |
| 132 | 131 |
| 133 // Interface for classes that make decisions about which output state | 132 // Interface for classes that make decisions about which output state |
| 134 // should be used. | 133 // should be used. |
| 135 class StateController { | 134 class StateController { |
| 136 public: | 135 public: |
| 137 virtual ~StateController() {} | 136 virtual ~StateController() {} |
| 138 | 137 |
| 139 // Called when displays are detected. | 138 // Called when displays are detected. |
| 140 virtual ui::OutputState GetStateForDisplayIds( | 139 virtual OutputState GetStateForDisplayIds( |
| 141 const std::vector<int64>& display_ids) const = 0; | 140 const std::vector<int64>& display_ids) const = 0; |
| 142 | 141 |
| 143 // Queries the resolution (|width|x|height|) in pixels | 142 // Queries the resolution (|width|x|height|) in pixels |
| 144 // to select output mode for the given display id. | 143 // to select output mode for the given display id. |
| 145 virtual bool GetResolutionForDisplayId(int64 display_id, | 144 virtual bool GetResolutionForDisplayId(int64 display_id, |
| 146 int* width, | 145 int* width, |
| 147 int* height) const = 0; | 146 int* height) const = 0; |
| 148 }; | 147 }; |
| 149 | 148 |
| 150 // Interface for classes that implement software based mirroring. | 149 // Interface for classes that implement software based mirroring. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 173 // |ctm| contains the desired transformation parameters. The offsets | 172 // |ctm| contains the desired transformation parameters. The offsets |
| 174 // in it should be normalized so that 1 corresponds to the X or Y axis | 173 // in it should be normalized so that 1 corresponds to the X or Y axis |
| 175 // size for the corresponding offset. | 174 // size for the corresponding offset. |
| 176 virtual void ConfigureCTM(int touch_device_id, | 175 virtual void ConfigureCTM(int touch_device_id, |
| 177 const CoordinateTransformation& ctm) = 0; | 176 const CoordinateTransformation& ctm) = 0; |
| 178 }; | 177 }; |
| 179 | 178 |
| 180 // Helper class used by tests. | 179 // Helper class used by tests. |
| 181 class TestApi { | 180 class TestApi { |
| 182 public: | 181 public: |
| 183 TestApi(OutputConfigurator* configurator) | 182 TestApi(OutputConfigurator* configurator) : configurator_(configurator) {} |
| 184 : configurator_(configurator) {} | |
| 185 ~TestApi() {} | 183 ~TestApi() {} |
| 186 | 184 |
| 187 // If |configure_timer_| is started, stops the timer, runs | 185 // If |configure_timer_| is started, stops the timer, runs |
| 188 // ConfigureOutputs(), and returns true; returns false otherwise. | 186 // ConfigureOutputs(), and returns true; returns false otherwise. |
| 189 bool TriggerConfigureTimeout(); | 187 bool TriggerConfigureTimeout(); |
| 190 | 188 |
| 191 private: | 189 private: |
| 192 OutputConfigurator* configurator_; // not owned | 190 OutputConfigurator* configurator_; // not owned |
| 193 | 191 |
| 194 DISALLOW_COPY_AND_ASSIGN(TestApi); | 192 DISALLOW_COPY_AND_ASSIGN(TestApi); |
| 195 }; | 193 }; |
| 196 | 194 |
| 197 // Flags that can be passed to SetDisplayPower(). | 195 // Flags that can be passed to SetDisplayPower(). |
| 198 static const int kSetDisplayPowerNoFlags = 0; | 196 static const int kSetDisplayPowerNoFlags = 0; |
| 199 // Configure displays even if the passed-in state matches |power_state_|. | 197 // Configure displays even if the passed-in state matches |power_state_|. |
| 200 static const int kSetDisplayPowerForceProbe = 1 << 0; | 198 static const int kSetDisplayPowerForceProbe = 1 << 0; |
| 201 // Do not change the state if multiple displays are connected or if the | 199 // Do not change the state if multiple displays are connected or if the |
| 202 // only connected display is external. | 200 // only connected display is external. |
| 203 static const int kSetDisplayPowerOnlyIfSingleInternalDisplay = 1 << 1; | 201 static const int kSetDisplayPowerOnlyIfSingleInternalDisplay = 1 << 1; |
| 204 | 202 |
| 205 // Gap between screens so cursor at bottom of active display doesn't | 203 // Gap between screens so cursor at bottom of active display doesn't |
| 206 // partially appear on top of inactive display. Higher numbers guard | 204 // partially appear on top of inactive display. Higher numbers guard |
| 207 // against larger cursors, but also waste more memory. | 205 // against larger cursors, but also waste more memory. |
| 208 // For simplicity, this is hard-coded to avoid the complexity of always | 206 // For simplicity, this is hard-coded to avoid the complexity of always |
| 209 // determining the DPI of the screen and rationalizing which screen we | 207 // determining the DPI of the screen and rationalizing which screen we |
| 210 // need to use for the DPI calculation. | 208 // need to use for the DPI calculation. |
| 211 // See crbug.com/130188 for initial discussion. | 209 // See crbug.com/130188 for initial discussion. |
| 212 static const int kVerticalGap = 60; | 210 static const int kVerticalGap = 60; |
| 213 | 211 |
| 214 // Returns a pointer to the ModeInfo struct in |output| corresponding to | 212 // Returns a pointer to the ModeInfo struct in |output| corresponding to |
| 215 // |mode|, or NULL if the struct isn't present. | 213 // |mode|, or NULL if the struct isn't present. |
| 216 static const ModeInfo* GetModeInfo(const OutputSnapshot& output, | 214 static const ModeInfo* GetModeInfo(const OutputSnapshot& output, RRMode mode); |
| 217 RRMode mode); | |
| 218 | 215 |
| 219 // Returns the mode within |output| that matches the given size with highest | 216 // Returns the mode within |output| that matches the given size with highest |
| 220 // refresh rate. Returns None if no matching output was found. | 217 // refresh rate. Returns None if no matching output was found. |
| 221 static RRMode FindOutputModeMatchingSize(const OutputSnapshot& output, | 218 static RRMode FindOutputModeMatchingSize(const OutputSnapshot& output, |
| 222 int width, | 219 int width, |
| 223 int height); | 220 int height); |
| 224 | 221 |
| 225 OutputConfigurator(); | 222 OutputConfigurator(); |
| 226 virtual ~OutputConfigurator(); | 223 virtual ~OutputConfigurator(); |
| 227 | 224 |
| 228 ui::OutputState output_state() const { return output_state_; } | 225 OutputState output_state() const { return output_state_; } |
| 229 DisplayPowerState power_state() const { return power_state_; } | 226 chromeos::DisplayPowerState power_state() const { return power_state_; } |
| 230 const std::vector<OutputSnapshot>& cached_outputs() const { | 227 const std::vector<OutputSnapshot>& cached_outputs() const { |
| 231 return cached_outputs_; | 228 return cached_outputs_; |
| 232 } | 229 } |
| 233 | 230 |
| 234 void set_state_controller(StateController* controller) { | 231 void set_state_controller(StateController* controller) { |
| 235 state_controller_ = controller; | 232 state_controller_ = controller; |
| 236 } | 233 } |
| 237 void set_mirroring_controller(SoftwareMirroringController* controller) { | 234 void set_mirroring_controller(SoftwareMirroringController* controller) { |
| 238 mirroring_controller_ = controller; | 235 mirroring_controller_ = controller; |
| 239 } | 236 } |
| 240 | 237 |
| 241 // Replaces |native_display_delegate_| with |delegate| and sets | 238 // Replaces |native_display_delegate_| with |delegate| and sets |
| 242 // |configure_display_| to true. Should be called before Init(). | 239 // |configure_display_| to true. Should be called before Init(). |
| 243 void SetNativeDisplayDelegateForTesting( | 240 void SetNativeDisplayDelegateForTesting( |
| 244 scoped_ptr<NativeDisplayDelegate> delegate); | 241 scoped_ptr<NativeDisplayDelegate> delegate); |
| 245 | 242 |
| 246 void SetTouchscreenDelegateForTesting( | 243 void SetTouchscreenDelegateForTesting( |
| 247 scoped_ptr<TouchscreenDelegate> delegate); | 244 scoped_ptr<TouchscreenDelegate> delegate); |
| 248 | 245 |
| 249 // Sets the initial value of |power_state_|. Must be called before Start(). | 246 // Sets the initial value of |power_state_|. Must be called before Start(). |
| 250 void SetInitialDisplayPower(DisplayPowerState power_state); | 247 void SetInitialDisplayPower(chromeos::DisplayPowerState power_state); |
| 251 | 248 |
| 252 // Initialization, must be called right after constructor. | 249 // Initialization, must be called right after constructor. |
| 253 // |is_panel_fitting_enabled| indicates hardware panel fitting support. | 250 // |is_panel_fitting_enabled| indicates hardware panel fitting support. |
| 254 void Init(bool is_panel_fitting_enabled); | 251 void Init(bool is_panel_fitting_enabled); |
| 255 | 252 |
| 256 // Does initial configuration of displays during startup. | 253 // Does initial configuration of displays during startup. |
| 257 // If |background_color_argb| is non zero and there are multiple displays, | 254 // If |background_color_argb| is non zero and there are multiple displays, |
| 258 // OutputConfigurator sets the background color of X's RootWindow to this | 255 // OutputConfigurator sets the background color of X's RootWindow to this |
| 259 // color. | 256 // color. |
| 260 void ForceInitialConfigure(uint32 background_color_argb); | 257 void ForceInitialConfigure(uint32 background_color_argb); |
| 261 | 258 |
| 262 // Stop handling display configuration events/requests. | 259 // Stop handling display configuration events/requests. |
| 263 void PrepareForExit(); | 260 void PrepareForExit(); |
| 264 | 261 |
| 265 // Called when powerd notifies us that some set of displays should be turned | 262 // Called when powerd notifies us that some set of displays should be turned |
| 266 // on or off. This requires enabling or disabling the CRTC associated with | 263 // on or off. This requires enabling or disabling the CRTC associated with |
| 267 // the display(s) in question so that the low power state is engaged. | 264 // the display(s) in question so that the low power state is engaged. |
| 268 // |flags| contains bitwise-or-ed kSetDisplayPower* values. | 265 // |flags| contains bitwise-or-ed kSetDisplayPower* values. |
| 269 bool SetDisplayPower(DisplayPowerState power_state, int flags); | 266 bool SetDisplayPower(chromeos::DisplayPowerState power_state, int flags); |
| 270 | 267 |
| 271 // Force switching the display mode to |new_state|. Returns false if | 268 // Force switching the display mode to |new_state|. Returns false if |
| 272 // switching failed (possibly because |new_state| is invalid for the | 269 // switching failed (possibly because |new_state| is invalid for the |
| 273 // current set of connected outputs). | 270 // current set of connected outputs). |
| 274 bool SetDisplayMode(ui::OutputState new_state); | 271 bool SetDisplayMode(OutputState new_state); |
| 275 | 272 |
| 276 // NativeDisplayDelegate::Observer overrides: | 273 // NativeDisplayDelegate::Observer overrides: |
| 277 virtual void OnConfigurationChanged() OVERRIDE; | 274 virtual void OnConfigurationChanged() OVERRIDE; |
| 278 | 275 |
| 279 void AddObserver(Observer* observer); | 276 void AddObserver(Observer* observer); |
| 280 void RemoveObserver(Observer* observer); | 277 void RemoveObserver(Observer* observer); |
| 281 | 278 |
| 282 // Sets all the displays into pre-suspend mode; usually this means | 279 // Sets all the displays into pre-suspend mode; usually this means |
| 283 // configure them for their resume state. This allows faster resume on | 280 // configure them for their resume state. This allows faster resume on |
| 284 // machines where display configuration is slow. | 281 // machines where display configuration is slow. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 297 OutputProtectionClientId RegisterOutputProtectionClient(); | 294 OutputProtectionClientId RegisterOutputProtectionClient(); |
| 298 | 295 |
| 299 // Unregisters the client. | 296 // Unregisters the client. |
| 300 void UnregisterOutputProtectionClient(OutputProtectionClientId client_id); | 297 void UnregisterOutputProtectionClient(OutputProtectionClientId client_id); |
| 301 | 298 |
| 302 // Queries link status and protection status. | 299 // Queries link status and protection status. |
| 303 // |link_mask| is the type of connected output links, which is a bitmask of | 300 // |link_mask| is the type of connected output links, which is a bitmask of |
| 304 // OutputType values. |protection_mask| is the desired protection methods, | 301 // OutputType values. |protection_mask| is the desired protection methods, |
| 305 // which is a bitmask of the OutputProtectionMethod values. | 302 // which is a bitmask of the OutputProtectionMethod values. |
| 306 // Returns true on success. | 303 // Returns true on success. |
| 307 bool QueryOutputProtectionStatus( | 304 bool QueryOutputProtectionStatus(OutputProtectionClientId client_id, |
| 308 OutputProtectionClientId client_id, | 305 int64 display_id, |
| 309 int64 display_id, | 306 uint32_t* link_mask, |
| 310 uint32_t* link_mask, | 307 uint32_t* protection_mask); |
| 311 uint32_t* protection_mask); | |
| 312 | 308 |
| 313 // Requests the desired protection methods. | 309 // Requests the desired protection methods. |
| 314 // |protection_mask| is the desired protection methods, which is a bitmask | 310 // |protection_mask| is the desired protection methods, which is a bitmask |
| 315 // of the OutputProtectionMethod values. | 311 // of the OutputProtectionMethod values. |
| 316 // Returns true when the protection request has been made. | 312 // Returns true when the protection request has been made. |
| 317 bool EnableOutputProtection( | 313 bool EnableOutputProtection(OutputProtectionClientId client_id, |
| 318 OutputProtectionClientId client_id, | 314 int64 display_id, |
| 319 int64 display_id, | 315 uint32_t desired_protection_mask); |
| 320 uint32_t desired_protection_mask); | |
| 321 | 316 |
| 322 private: | 317 private: |
| 323 // Mapping a display_id to a protection request bitmask. | 318 // Mapping a display_id to a protection request bitmask. |
| 324 typedef std::map<int64, uint32_t> DisplayProtections; | 319 typedef std::map<int64, uint32_t> DisplayProtections; |
| 325 // Mapping a client to its protection request. | 320 // Mapping a client to its protection request. |
| 326 typedef std::map<OutputProtectionClientId, | 321 typedef std::map<OutputProtectionClientId, DisplayProtections> |
| 327 DisplayProtections> ProtectionRequests; | 322 ProtectionRequests; |
| 328 | 323 |
| 329 // Updates |cached_outputs_| to contain currently-connected outputs. Calls | 324 // Updates |cached_outputs_| to contain currently-connected outputs. Calls |
| 330 // |delegate_->GetOutputs()| and then does additional work, like finding the | 325 // |delegate_->GetOutputs()| and then does additional work, like finding the |
| 331 // mirror mode and setting user-preferred modes. Note that the server must be | 326 // mirror mode and setting user-preferred modes. Note that the server must be |
| 332 // grabbed via |delegate_->GrabServer()| first. | 327 // grabbed via |delegate_->GrabServer()| first. |
| 333 void UpdateCachedOutputs(); | 328 void UpdateCachedOutputs(); |
| 334 | 329 |
| 335 // Helper method for UpdateCachedOutputs() that initializes the passed-in | 330 // Helper method for UpdateCachedOutputs() that initializes the passed-in |
| 336 // outputs' |mirror_mode| fields by looking for a mode in |internal_output| | 331 // outputs' |mirror_mode| fields by looking for a mode in |internal_output| |
| 337 // and |external_output| having the same resolution. Returns false if a shared | 332 // and |external_output| having the same resolution. Returns false if a shared |
| 338 // mode wasn't found or created. | 333 // mode wasn't found or created. |
| 339 // | 334 // |
| 340 // |try_panel_fitting| allows creating a panel-fitting mode for | 335 // |try_panel_fitting| allows creating a panel-fitting mode for |
| 341 // |internal_output| instead of only searching for a matching mode (note that | 336 // |internal_output| instead of only searching for a matching mode (note that |
| 342 // it may lead to a crash if |internal_info| is not capable of panel fitting). | 337 // it may lead to a crash if |internal_info| is not capable of panel fitting). |
| 343 // | 338 // |
| 344 // |preserve_aspect| limits the search/creation only to the modes having the | 339 // |preserve_aspect| limits the search/creation only to the modes having the |
| 345 // native aspect ratio of |external_output|. | 340 // native aspect ratio of |external_output|. |
| 346 bool FindMirrorMode(OutputSnapshot* internal_output, | 341 bool FindMirrorMode(OutputSnapshot* internal_output, |
| 347 OutputSnapshot* external_output, | 342 OutputSnapshot* external_output, |
| 348 bool try_panel_fitting, | 343 bool try_panel_fitting, |
| 349 bool preserve_aspect); | 344 bool preserve_aspect); |
| 350 | 345 |
| 351 // Configures outputs. | 346 // Configures outputs. |
| 352 void ConfigureOutputs(); | 347 void ConfigureOutputs(); |
| 353 | 348 |
| 354 // Notifies observers about an attempted state change. | 349 // Notifies observers about an attempted state change. |
| 355 void NotifyObservers(bool success, ui::OutputState attempted_state); | 350 void NotifyObservers(bool success, OutputState attempted_state); |
| 356 | 351 |
| 357 // Switches to the state specified in |output_state| and |power_state|. | 352 // Switches to the state specified in |output_state| and |power_state|. |
| 358 // If the hardware mirroring failed and |mirroring_controller_| is set, | 353 // If the hardware mirroring failed and |mirroring_controller_| is set, |
| 359 // it switches to |STATE_DUAL_EXTENDED| and calls |SetSoftwareMirroring()| | 354 // it switches to |STATE_DUAL_EXTENDED| and calls |SetSoftwareMirroring()| |
| 360 // to enable software based mirroring. | 355 // to enable software based mirroring. |
| 361 // On success, updates |output_state_|, |power_state_|, and |cached_outputs_| | 356 // On success, updates |output_state_|, |power_state_|, and |cached_outputs_| |
| 362 // and returns true. | 357 // and returns true. |
| 363 bool EnterStateOrFallBackToSoftwareMirroring(ui::OutputState output_state, | 358 bool EnterStateOrFallBackToSoftwareMirroring( |
| 364 DisplayPowerState power_state); | 359 OutputState output_state, |
| 360 chromeos::DisplayPowerState power_state); |
| 365 | 361 |
| 366 // Switches to the state specified in |output_state| and |power_state|. | 362 // Switches to the state specified in |output_state| and |power_state|. |
| 367 // On success, updates |output_state_|, |power_state_|, and | 363 // On success, updates |output_state_|, |power_state_|, and |
| 368 // |cached_outputs_| and returns true. | 364 // |cached_outputs_| and returns true. |
| 369 bool EnterState(ui::OutputState output_state, DisplayPowerState power_state); | 365 bool EnterState(OutputState output_state, |
| 366 chromeos::DisplayPowerState power_state); |
| 370 | 367 |
| 371 // Returns the output state that should be used with |cached_outputs_| while | 368 // Returns the output state that should be used with |cached_outputs_| while |
| 372 // in |power_state|. | 369 // in |power_state|. |
| 373 ui::OutputState ChooseOutputState(DisplayPowerState power_state) const; | 370 OutputState ChooseOutputState(chromeos::DisplayPowerState power_state) const; |
| 374 | 371 |
| 375 // Computes the relevant transformation for mirror mode. | 372 // Computes the relevant transformation for mirror mode. |
| 376 // |output| is the output on which mirror mode is being applied. | 373 // |output| is the output on which mirror mode is being applied. |
| 377 // Returns the transformation or identity if computations fail. | 374 // Returns the transformation or identity if computations fail. |
| 378 CoordinateTransformation GetMirrorModeCTM( | 375 CoordinateTransformation GetMirrorModeCTM( |
| 379 const OutputConfigurator::OutputSnapshot& output); | 376 const OutputConfigurator::OutputSnapshot& output); |
| 380 | 377 |
| 381 // Computes the relevant transformation for extended mode. | 378 // Computes the relevant transformation for extended mode. |
| 382 // |output| is the output on which extended mode is being applied. | 379 // |output| is the output on which extended mode is being applied. |
| 383 // |width| and |height| are the width and height of the combined framebuffer. | 380 // |width| and |height| are the width and height of the combined framebuffer. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 412 std::map<int, float> mirrored_display_area_ratio_map_; | 409 std::map<int, float> mirrored_display_area_ratio_map_; |
| 413 | 410 |
| 414 // This is detected by the constructor to determine whether or not we should | 411 // This is detected by the constructor to determine whether or not we should |
| 415 // be enabled. If we aren't running on ChromeOS, we can't assume that the | 412 // be enabled. If we aren't running on ChromeOS, we can't assume that the |
| 416 // Xrandr X11 extension is supported. | 413 // Xrandr X11 extension is supported. |
| 417 // If this flag is set to false, any attempts to change the output | 414 // If this flag is set to false, any attempts to change the output |
| 418 // configuration to immediately fail without changing the state. | 415 // configuration to immediately fail without changing the state. |
| 419 bool configure_display_; | 416 bool configure_display_; |
| 420 | 417 |
| 421 // The current display state. | 418 // The current display state. |
| 422 ui::OutputState output_state_; | 419 OutputState output_state_; |
| 423 | 420 |
| 424 // The current power state. | 421 // The current power state. |
| 425 DisplayPowerState power_state_; | 422 chromeos::DisplayPowerState power_state_; |
| 426 | 423 |
| 427 // Most-recently-used output configuration. Note that the actual | 424 // Most-recently-used output configuration. Note that the actual |
| 428 // configuration changes asynchronously. | 425 // configuration changes asynchronously. |
| 429 std::vector<OutputSnapshot> cached_outputs_; | 426 std::vector<OutputSnapshot> cached_outputs_; |
| 430 | 427 |
| 431 ObserverList<Observer> observers_; | 428 ObserverList<Observer> observers_; |
| 432 | 429 |
| 433 // The timer to delay configuring outputs. See also the comments in | 430 // The timer to delay configuring outputs. See also the comments in |
| 434 // Dispatch(). | 431 // Dispatch(). |
| 435 scoped_ptr<base::OneShotTimer<OutputConfigurator> > configure_timer_; | 432 scoped_ptr<base::OneShotTimer<OutputConfigurator> > configure_timer_; |
| 436 | 433 |
| 437 // Id for next output protection client. | 434 // Id for next output protection client. |
| 438 OutputProtectionClientId next_output_protection_client_id_; | 435 OutputProtectionClientId next_output_protection_client_id_; |
| 439 | 436 |
| 440 // Output protection requests of each client. | 437 // Output protection requests of each client. |
| 441 ProtectionRequests client_protection_requests_; | 438 ProtectionRequests client_protection_requests_; |
| 442 | 439 |
| 443 DISALLOW_COPY_AND_ASSIGN(OutputConfigurator); | 440 DISALLOW_COPY_AND_ASSIGN(OutputConfigurator); |
| 444 }; | 441 }; |
| 445 | 442 |
| 446 typedef std::vector<OutputConfigurator::OutputSnapshot> OutputSnapshotList; | 443 typedef std::vector<OutputConfigurator::OutputSnapshot> OutputSnapshotList; |
| 447 | 444 |
| 448 } // namespace chromeos | 445 } // namespace ui |
| 449 | 446 |
| 450 #endif // CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ | 447 #endif // UI_DISPLAY_CHROMEOS_OUTPUT_CONFIGURATOR_H_ |
| OLD | NEW |