| 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 <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/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 16 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
| 17 #include "base/timer/timer.h" | 17 #include "base/timer/timer.h" |
| 18 #include "chromeos/chromeos_export.h" | 18 #include "chromeos/chromeos_export.h" |
| 19 #include "third_party/cros_system_api/dbus/service_constants.h" | 19 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 20 | 20 |
| 21 // Forward declarations for Xlib and Xrandr. | 21 // Forward declarations for Xlib and Xrandr. |
| 22 // This is so unused X definitions don't pollute the namespace. | 22 // This is so unused X definitions don't pollute the namespace. |
| 23 typedef unsigned long XID; | 23 typedef unsigned long XID; |
| 24 typedef XID RROutput; | 24 typedef XID RROutput; |
| 25 typedef XID RRCrtc; | 25 typedef XID RRCrtc; |
| 26 typedef XID RRMode; | 26 typedef XID RRMode; |
| 27 | 27 |
| 28 namespace chrome { |
| 29 class PepperOutputProtectionHost; |
| 30 } // namespace chrome |
| 31 |
| 28 namespace chromeos { | 32 namespace chromeos { |
| 29 | 33 |
| 30 // Used to describe the state of a multi-display configuration. | 34 // Used to describe the state of a multi-display configuration. |
| 31 enum OutputState { | 35 enum OutputState { |
| 32 STATE_INVALID, | 36 STATE_INVALID, |
| 33 STATE_HEADLESS, | 37 STATE_HEADLESS, |
| 34 STATE_SINGLE, | 38 STATE_SINGLE, |
| 35 STATE_DUAL_MIRROR, | 39 STATE_DUAL_MIRROR, |
| 36 STATE_DUAL_EXTENDED, | 40 STATE_DUAL_EXTENDED, |
| 37 }; | 41 }; |
| 38 | 42 |
| 43 // Video output link types. |
| 44 enum OutputLinkType { |
| 45 OUTPUT_LINK_TYPE_NONE = 0, |
| 46 OUTPUT_LINK_TYPE_UNKNOWN = 1 << 0, |
| 47 OUTPUT_LINK_TYPE_INTERNAL = 1 << 1, |
| 48 OUTPUT_LINK_TYPE_VGA = 1 << 2, |
| 49 OUTPUT_LINK_TYPE_HDMI = 1 << 3, |
| 50 OUTPUT_LINK_TYPE_DVI = 1 << 4, |
| 51 OUTPUT_LINK_TYPE_DISPLAYPORT = 1 << 5, |
| 52 }; |
| 53 |
| 54 // Content protection methods applied on video output link. |
| 55 enum OutputProtectionMethod { |
| 56 OUTPUT_PROTECTION_METHOD_NONE, |
| 57 OUTPUT_PROTECTION_METHOD_HDCP, |
| 58 }; |
| 59 |
| 39 // This class interacts directly with the underlying Xrandr API to manipulate | 60 // This class interacts directly with the underlying Xrandr API to manipulate |
| 40 // CTRCs and Outputs. | 61 // CTRCs and Outputs. |
| 41 class CHROMEOS_EXPORT OutputConfigurator | 62 class CHROMEOS_EXPORT OutputConfigurator |
| 42 : public base::MessageLoop::Dispatcher, | 63 : public base::MessageLoop::Dispatcher, |
| 43 public base::MessagePumpObserver { | 64 public base::MessagePumpObserver { |
| 44 public: | 65 public: |
| 45 struct ModeInfo { | 66 struct ModeInfo { |
| 46 ModeInfo(); | 67 ModeInfo(); |
| 47 ModeInfo(int width, int height, bool interlaced); | 68 ModeInfo(int width, int height, bool interlaced); |
| 48 | 69 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 // |touch_device_id| the ID of the touchscreen device to configure. | 232 // |touch_device_id| the ID of the touchscreen device to configure. |
| 212 // |ctm| contains the desired transformation parameters. The offsets | 233 // |ctm| contains the desired transformation parameters. The offsets |
| 213 // in it should be normalized so that 1 corresponds to the X or Y axis | 234 // in it should be normalized so that 1 corresponds to the X or Y axis |
| 214 // size for the corresponding offset. | 235 // size for the corresponding offset. |
| 215 virtual void ConfigureCTM(int touch_device_id, | 236 virtual void ConfigureCTM(int touch_device_id, |
| 216 const CoordinateTransformation& ctm) = 0; | 237 const CoordinateTransformation& ctm) = 0; |
| 217 | 238 |
| 218 // Sends a D-Bus message to the power manager telling it that the | 239 // Sends a D-Bus message to the power manager telling it that the |
| 219 // machine is or is not projecting. | 240 // machine is or is not projecting. |
| 220 virtual void SendProjectingStateToPowerManager(bool projecting) = 0; | 241 virtual void SendProjectingStateToPowerManager(bool projecting) = 0; |
| 242 |
| 243 virtual uint64_t RegisterOutputProtectionClient() = 0; |
| 244 virtual void UnregisterOutputProtectionClient(uint64_t client_id) = 0; |
| 245 // Query link status and protection status. Returns true on success. |
| 246 virtual bool QueryOutputProtectionStatus( |
| 247 uint64_t client_id, |
| 248 uint32_t* link_mask, |
| 249 uint32_t* protection_mask) = 0; |
| 250 |
| 251 // Request the desired protection methods. Returns true when the protection |
| 252 // request has been made. |
| 253 virtual bool EnableOutputProtection( |
| 254 uint64_t client_id, |
| 255 uint32_t desired_method_mask) = 0; |
| 221 }; | 256 }; |
| 222 | 257 |
| 223 // Helper class used by tests. | 258 // Helper class used by tests. |
| 224 class TestApi { | 259 class TestApi { |
| 225 public: | 260 public: |
| 226 TestApi(OutputConfigurator* configurator, int xrandr_event_base) | 261 TestApi(OutputConfigurator* configurator, int xrandr_event_base) |
| 227 : configurator_(configurator), | 262 : configurator_(configurator), |
| 228 xrandr_event_base_(xrandr_event_base) {} | 263 xrandr_event_base_(xrandr_event_base) {} |
| 229 ~TestApi() {} | 264 ~TestApi() {} |
| 230 | 265 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 void ResumeDisplays(); | 376 void ResumeDisplays(); |
| 342 | 377 |
| 343 const std::map<int, float>& GetMirroredDisplayAreaRatioMap() { | 378 const std::map<int, float>& GetMirroredDisplayAreaRatioMap() { |
| 344 return mirrored_display_area_ratio_map_; | 379 return mirrored_display_area_ratio_map_; |
| 345 } | 380 } |
| 346 | 381 |
| 347 // Configure outputs with |kConfigureDelayMs| delay, | 382 // Configure outputs with |kConfigureDelayMs| delay, |
| 348 // so that time-consuming ConfigureOutputs() won't be called multiple times. | 383 // so that time-consuming ConfigureOutputs() won't be called multiple times. |
| 349 void ScheduleConfigureOutputs(); | 384 void ScheduleConfigureOutputs(); |
| 350 | 385 |
| 386 uint64_t RegisterOutputProtectionClient(); |
| 387 void UnregisterOutputProtectionClient(uint64_t client_id); |
| 388 // Query link status and protection status. |
| 389 // |link_mask| is the type of connected output links, which is a bitmask |
| 390 // of PP_OutputProtectionLinkType_Private values. |protection_mask| is the |
| 391 // desired protection methods, which is a bitmask of the |
| 392 // PP_OutputProtectionMethod_Private values. |
| 393 // Returns true on success. |
| 394 bool QueryOutputProtectionStatus( |
| 395 uint64_t client_id, |
| 396 uint32_t* link_mask, |
| 397 uint32_t* protection_mask); |
| 398 |
| 399 // Request the desired protection methods. |
| 400 // |protection_mask| is the desired protection methods, which is a bitmask |
| 401 // of the PP_OutputProtectionMethod_Private values. |
| 402 // Returns true when the protection request has been made. |
| 403 bool EnableOutputProtection( |
| 404 uint64_t client_id, |
| 405 uint32_t desired_method_mask); |
| 406 |
| 351 private: | 407 private: |
| 352 // Configure outputs. | 408 // Configure outputs. |
| 353 void ConfigureOutputs(); | 409 void ConfigureOutputs(); |
| 354 | 410 |
| 355 // Notifies observers about an attempted state change. | 411 // Notifies observers about an attempted state change. |
| 356 void NotifyObservers(bool success, OutputState attempted_state); | 412 void NotifyObservers(bool success, OutputState attempted_state); |
| 357 | 413 |
| 358 // Switches to the state specified in |output_state| and |power_state|. | 414 // Switches to the state specified in |output_state| and |power_state|. |
| 359 // If the hardware mirroring failed and |mirroring_controller_| is set, | 415 // If the hardware mirroring failed and |mirroring_controller_| is set, |
| 360 // it switches to |STATE_DUAL_EXTENDED| and calls |SetSoftwareMirroring()| | 416 // it switches to |STATE_DUAL_EXTENDED| and calls |SetSoftwareMirroring()| |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 scoped_ptr<base::OneShotTimer<OutputConfigurator> > configure_timer_; | 485 scoped_ptr<base::OneShotTimer<OutputConfigurator> > configure_timer_; |
| 430 | 486 |
| 431 DISALLOW_COPY_AND_ASSIGN(OutputConfigurator); | 487 DISALLOW_COPY_AND_ASSIGN(OutputConfigurator); |
| 432 }; | 488 }; |
| 433 | 489 |
| 434 typedef std::vector<OutputConfigurator::OutputSnapshot> OutputSnapshotList; | 490 typedef std::vector<OutputConfigurator::OutputSnapshot> OutputSnapshotList; |
| 435 | 491 |
| 436 } // namespace chromeos | 492 } // namespace chromeos |
| 437 | 493 |
| 438 #endif // CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ | 494 #endif // CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ |
| OLD | NEW |