Chromium Code Reviews| 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 CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ |
| 6 #define CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ | 6 #define CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ |
| 7 | 7 |
| 8 #include <map> | |
| 8 #include <vector> | 9 #include <vector> |
| 9 | 10 |
| 10 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 11 #include "base/event_types.h" | 12 #include "base/event_types.h" |
| 12 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
| 13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/message_loop.h" | 15 #include "base/message_loop.h" |
| 15 #include "base/timer.h" | 16 #include "base/timer.h" |
| 16 #include "chromeos/chromeos_export.h" | 17 #include "chromeos/chromeos_export.h" |
| 17 #include "third_party/cros_system_api/dbus/service_constants.h" | 18 #include "third_party/cros_system_api/dbus/service_constants.h" |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 276 | 277 |
| 277 // Sets all the displays into pre-suspend mode; usually this means | 278 // Sets all the displays into pre-suspend mode; usually this means |
| 278 // configure them for their resume state. This allows faster resume on | 279 // configure them for their resume state. This allows faster resume on |
| 279 // machines where display configuration is slow. | 280 // machines where display configuration is slow. |
| 280 void SuspendDisplays(); | 281 void SuspendDisplays(); |
| 281 | 282 |
| 282 // Reprobes displays to handle changes made while the system was | 283 // Reprobes displays to handle changes made while the system was |
| 283 // suspended. | 284 // suspended. |
| 284 void ResumeDisplays(); | 285 void ResumeDisplays(); |
| 285 | 286 |
| 287 std::map<int, float>* GetMirroredDisplayAreaRatioMap() { | |
|
oshima
2013/04/18 08:38:12
can this be
const std::map<int, float>&
?
Yufeng Shen (Slow to review)
2013/04/18 16:22:56
Done.
| |
| 288 return &mirrored_display_area_ratio_map_; | |
| 289 } | |
| 290 | |
| 286 private: | 291 private: |
| 287 // Configure outputs. | 292 // Configure outputs. |
| 288 void ConfigureOutputs(); | 293 void ConfigureOutputs(); |
| 289 | 294 |
| 290 // Fires OnDisplayModeChanged() event to the observers. | 295 // Fires OnDisplayModeChanged() event to the observers. |
| 291 void NotifyOnDisplayChanged(); | 296 void NotifyOnDisplayChanged(); |
| 292 | 297 |
| 293 // Switches to the state specified in |output_state| and |power_state|. | 298 // Switches to the state specified in |output_state| and |power_state|. |
| 294 // On success, updates |output_state_| and |power_state_| and returns true. | 299 // On success, updates |output_state_| and |power_state_| and returns true. |
| 295 bool EnterState(OutputState output_state, | 300 bool EnterState(OutputState output_state, |
| 296 DisplayPowerState power_state, | 301 DisplayPowerState power_state, |
| 297 const std::vector<OutputSnapshot>& outputs); | 302 const std::vector<OutputSnapshot>& outputs); |
| 298 | 303 |
| 299 // Returns the output state that should be used with |outputs| connected | 304 // Returns the output state that should be used with |outputs| connected |
| 300 // while in |power_state|. | 305 // while in |power_state|. |
| 301 OutputState GetOutputState(const std::vector<OutputSnapshot>& outputs, | 306 OutputState GetOutputState(const std::vector<OutputSnapshot>& outputs, |
| 302 DisplayPowerState power_state) const; | 307 DisplayPowerState power_state) const; |
| 303 | 308 |
| 304 // Computes the relevant transformation for mirror mode. | 309 // Computes the relevant transformation for mirror mode. |
| 305 // |output| is the output on which mirror mode is being applied. | 310 // |output| is the output on which mirror mode is being applied. |
| 306 // Returns the transformation or identity if computations fail. | 311 // Returns the transformation or identity if computations fail. |
| 307 CoordinateTransformation GetMirrorModeCTM( | 312 CoordinateTransformation GetMirrorModeCTM( |
| 308 const OutputConfigurator::OutputSnapshot* output); | 313 const OutputConfigurator::OutputSnapshot* output); |
| 309 | 314 |
| 315 // Returns the ratio between mirrored mode area and native mode area: | |
| 316 // (mirror_mode_width * mirrow_mode_height) / (native_width * native_height) | |
| 317 float GetMirroredDisplayAreaRatio( | |
| 318 const OutputConfigurator::OutputSnapshot* output); | |
| 319 | |
| 310 StateController* state_controller_; | 320 StateController* state_controller_; |
| 311 scoped_ptr<Delegate> delegate_; | 321 scoped_ptr<Delegate> delegate_; |
| 312 | 322 |
| 323 // Key of the map is the touch display's id, and the value of the map is the | |
| 324 // touch display's area ratio in mirror mode defined as : | |
| 325 // mirror_mode_area / native_mode_area. | |
| 326 // This is used for scaling touch event's radius when the touch display is in | |
| 327 // mirror mode : | |
| 328 // new_touch_radius = sqrt(area_ratio) * old_touch_radius | |
| 329 std::map<int, float> mirrored_display_area_ratio_map_; | |
| 330 | |
| 313 // This is detected by the constructor to determine whether or not we should | 331 // This is detected by the constructor to determine whether or not we should |
| 314 // be enabled. If we aren't running on ChromeOS, we can't assume that the | 332 // be enabled. If we aren't running on ChromeOS, we can't assume that the |
| 315 // Xrandr X11 extension is supported. | 333 // Xrandr X11 extension is supported. |
| 316 // If this flag is set to false, any attempts to change the output | 334 // If this flag is set to false, any attempts to change the output |
| 317 // configuration to immediately fail without changing the state. | 335 // configuration to immediately fail without changing the state. |
| 318 bool configure_display_; | 336 bool configure_display_; |
| 319 | 337 |
| 320 // The base of the event numbers used to represent XRandr events used in | 338 // The base of the event numbers used to represent XRandr events used in |
| 321 // decoding events regarding output add/remove. | 339 // decoding events regarding output add/remove. |
| 322 int xrandr_event_base_; | 340 int xrandr_event_base_; |
| 323 | 341 |
| 324 // The current display state. | 342 // The current display state. |
| 325 OutputState output_state_; | 343 OutputState output_state_; |
| 326 | 344 |
| 327 // The current power state. | 345 // The current power state. |
| 328 DisplayPowerState power_state_; | 346 DisplayPowerState power_state_; |
| 329 | 347 |
| 330 ObserverList<Observer> observers_; | 348 ObserverList<Observer> observers_; |
| 331 | 349 |
| 332 // The timer to delay configuring outputs. See also the comments in | 350 // The timer to delay configuring outputs. See also the comments in |
| 333 // Dispatch(). | 351 // Dispatch(). |
| 334 scoped_ptr<base::OneShotTimer<OutputConfigurator> > configure_timer_; | 352 scoped_ptr<base::OneShotTimer<OutputConfigurator> > configure_timer_; |
| 335 | 353 |
| 336 DISALLOW_COPY_AND_ASSIGN(OutputConfigurator); | 354 DISALLOW_COPY_AND_ASSIGN(OutputConfigurator); |
| 337 }; | 355 }; |
| 338 | 356 |
| 339 } // namespace chromeos | 357 } // namespace chromeos |
| 340 | 358 |
| 341 #endif // CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ | 359 #endif // CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ |
| OLD | NEW |