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> |
(...skipping 18 matching lines...) Expand all Loading... | |
29 | 29 |
30 // Used to describe the state of a multi-display configuration. | 30 // Used to describe the state of a multi-display configuration. |
31 enum OutputState { | 31 enum OutputState { |
32 STATE_INVALID, | 32 STATE_INVALID, |
33 STATE_HEADLESS, | 33 STATE_HEADLESS, |
34 STATE_SINGLE, | 34 STATE_SINGLE, |
35 STATE_DUAL_MIRROR, | 35 STATE_DUAL_MIRROR, |
36 STATE_DUAL_EXTENDED, | 36 STATE_DUAL_EXTENDED, |
37 }; | 37 }; |
38 | 38 |
39 // Video output types. | |
40 enum OutputType { | |
41 OUTPUT_TYPE_NONE = 0, | |
42 OUTPUT_TYPE_UNKNOWN = 1 << 0, | |
43 OUTPUT_TYPE_INTERNAL = 1 << 1, | |
44 OUTPUT_TYPE_VGA = 1 << 2, | |
45 OUTPUT_TYPE_HDMI = 1 << 3, | |
46 OUTPUT_TYPE_DVI = 1 << 4, | |
47 OUTPUT_TYPE_DISPLAYPORT = 1 << 5, | |
48 }; | |
49 | |
50 // Content protection methods applied on video output. | |
51 enum OutputProtectionMethod { | |
52 OUTPUT_PROTECTION_METHOD_NONE = 0, | |
53 OUTPUT_PROTECTION_METHOD_HDCP = 1 << 0, | |
54 }; | |
55 | |
39 // This class interacts directly with the underlying Xrandr API to manipulate | 56 // This class interacts directly with the underlying Xrandr API to manipulate |
40 // CTRCs and Outputs. | 57 // CTRCs and Outputs. |
41 class CHROMEOS_EXPORT OutputConfigurator | 58 class CHROMEOS_EXPORT OutputConfigurator |
42 : public base::MessageLoop::Dispatcher, | 59 : public base::MessageLoop::Dispatcher, |
43 public base::MessagePumpObserver { | 60 public base::MessagePumpObserver { |
44 public: | 61 public: |
62 typedef uint64_t OutputProtectionClientId; | |
63 | |
45 struct ModeInfo { | 64 struct ModeInfo { |
46 ModeInfo(); | 65 ModeInfo(); |
47 ModeInfo(int width, int height, bool interlaced, float refresh_rate); | 66 ModeInfo(int width, int height, bool interlaced, float refresh_rate); |
48 | 67 |
49 int width; | 68 int width; |
50 int height; | 69 int height; |
51 bool interlaced; | 70 bool interlaced; |
52 float refresh_rate; | 71 float refresh_rate; |
53 }; | 72 }; |
54 | 73 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
215 // |touch_device_id| the ID of the touchscreen device to configure. | 234 // |touch_device_id| the ID of the touchscreen device to configure. |
216 // |ctm| contains the desired transformation parameters. The offsets | 235 // |ctm| contains the desired transformation parameters. The offsets |
217 // in it should be normalized so that 1 corresponds to the X or Y axis | 236 // in it should be normalized so that 1 corresponds to the X or Y axis |
218 // size for the corresponding offset. | 237 // size for the corresponding offset. |
219 virtual void ConfigureCTM(int touch_device_id, | 238 virtual void ConfigureCTM(int touch_device_id, |
220 const CoordinateTransformation& ctm) = 0; | 239 const CoordinateTransformation& ctm) = 0; |
221 | 240 |
222 // Sends a D-Bus message to the power manager telling it that the | 241 // Sends a D-Bus message to the power manager telling it that the |
223 // machine is or is not projecting. | 242 // machine is or is not projecting. |
224 virtual void SendProjectingStateToPowerManager(bool projecting) = 0; | 243 virtual void SendProjectingStateToPowerManager(bool projecting) = 0; |
244 | |
245 // Query link status and protection status. Returns true on success. | |
Daniel Erat
2013/09/20 15:00:24
nit: s/Query/Queries/
kcwu
2013/09/23 18:00:02
Done.
| |
246 virtual bool QueryOutputProtectionStatus( | |
247 OutputProtectionClientId 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 | |
Daniel Erat
2013/09/20 15:00:24
nit: s/Request/Requests/
kcwu
2013/09/23 18:00:02
Done.
| |
252 // request has been made. | |
253 virtual bool EnableOutputProtection( | |
254 OutputProtectionClientId client_id, | |
255 uint32_t desired_method_mask) = 0; | |
Daniel Erat
2013/09/20 15:00:24
you said that this matches the naming in the idl f
kcwu
2013/09/23 18:00:02
Done.
| |
225 }; | 256 }; |
226 | 257 |
227 // Helper class used by tests. | 258 // Helper class used by tests. |
228 class TestApi { | 259 class TestApi { |
229 public: | 260 public: |
230 TestApi(OutputConfigurator* configurator, int xrandr_event_base) | 261 TestApi(OutputConfigurator* configurator, int xrandr_event_base) |
231 : configurator_(configurator), | 262 : configurator_(configurator), |
232 xrandr_event_base_(xrandr_event_base) {} | 263 xrandr_event_base_(xrandr_event_base) {} |
233 ~TestApi() {} | 264 ~TestApi() {} |
234 | 265 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
351 void ResumeDisplays(); | 382 void ResumeDisplays(); |
352 | 383 |
353 const std::map<int, float>& GetMirroredDisplayAreaRatioMap() { | 384 const std::map<int, float>& GetMirroredDisplayAreaRatioMap() { |
354 return mirrored_display_area_ratio_map_; | 385 return mirrored_display_area_ratio_map_; |
355 } | 386 } |
356 | 387 |
357 // Configure outputs with |kConfigureDelayMs| delay, | 388 // Configure outputs with |kConfigureDelayMs| delay, |
358 // so that time-consuming ConfigureOutputs() won't be called multiple times. | 389 // so that time-consuming ConfigureOutputs() won't be called multiple times. |
359 void ScheduleConfigureOutputs(); | 390 void ScheduleConfigureOutputs(); |
360 | 391 |
392 // Registers a client for output protection and request a client id. Returns | |
Daniel Erat
2013/09/20 15:00:24
nit: s/request/requests/
kcwu
2013/09/23 18:00:02
Done.
| |
393 // 0 if requesting failed. | |
394 OutputProtectionClientId RegisterOutputProtectionClient(); | |
395 | |
396 // Unregisters the client. | |
397 void UnregisterOutputProtectionClient(OutputProtectionClientId client_id); | |
398 | |
399 // Queries link status and protection status. | |
400 // |link_mask| is the type of connected output links, which is a bitmask of | |
401 // OutputType values. |protection_mask| is the desired protection methods, | |
402 // which is a bitmask of the OutputProtectionMethod values. | |
403 // Returns true on success. | |
404 bool QueryOutputProtectionStatus( | |
405 OutputProtectionClientId client_id, | |
406 uint32_t* link_mask, | |
407 uint32_t* protection_mask); | |
408 | |
409 // Requests the desired protection methods. | |
410 // |protection_mask| is the desired protection methods, which is a bitmask | |
411 // of the PP_OutputProtectionMethod_Private values. | |
Daniel Erat
2013/09/20 15:00:24
s/PP_OutputProtectionMethod_Private/OutputProtecti
kcwu
2013/09/23 18:00:02
Done.
kcwu
2013/09/23 18:00:02
Done.
| |
412 // Returns true when the protection request has been made. | |
413 bool EnableOutputProtection( | |
414 OutputProtectionClientId client_id, | |
415 uint32_t desired_method_mask); | |
Daniel Erat
2013/09/20 15:00:24
s/method/protection/ here too
kcwu
2013/09/23 18:00:02
Done.
| |
416 | |
361 private: | 417 private: |
362 // Returns currently-connected outputs. This method is a wrapper around | 418 // Returns currently-connected outputs. This method is a wrapper around |
363 // |delegate_->GetOutputs()| that does additional work, like finding the | 419 // |delegate_->GetOutputs()| that does additional work, like finding the |
364 // mirror mode and setting user-preferred modes. Note that the server must | 420 // mirror mode and setting user-preferred modes. Note that the server must |
365 // be grabbed via |delegate_->GrabServer()| first. | 421 // be grabbed via |delegate_->GrabServer()| first. |
366 std::vector<OutputSnapshot> GetOutputs(); | 422 std::vector<OutputSnapshot> GetOutputs(); |
367 | 423 |
368 // Helper method for GetOutputs() that initializes the passed-in outputs' | 424 // Helper method for GetOutputs() that initializes the passed-in outputs' |
369 // |mirror_mode| fields by looking for a mode in |internal_output| and | 425 // |mirror_mode| fields by looking for a mode in |internal_output| and |
370 // |external_output| having the same resolution. Returns false if a shared | 426 // |external_output| having the same resolution. Returns false if a shared |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
456 // Most-recently-used output configuration. Note that the actual | 512 // Most-recently-used output configuration. Note that the actual |
457 // configuration changes asynchronously. | 513 // configuration changes asynchronously. |
458 std::vector<OutputSnapshot> cached_outputs_; | 514 std::vector<OutputSnapshot> cached_outputs_; |
459 | 515 |
460 ObserverList<Observer> observers_; | 516 ObserverList<Observer> observers_; |
461 | 517 |
462 // The timer to delay configuring outputs. See also the comments in | 518 // The timer to delay configuring outputs. See also the comments in |
463 // Dispatch(). | 519 // Dispatch(). |
464 scoped_ptr<base::OneShotTimer<OutputConfigurator> > configure_timer_; | 520 scoped_ptr<base::OneShotTimer<OutputConfigurator> > configure_timer_; |
465 | 521 |
522 // Id for next output protection client. | |
523 OutputProtectionClientId next_output_protection_client_id_; | |
524 | |
466 DISALLOW_COPY_AND_ASSIGN(OutputConfigurator); | 525 DISALLOW_COPY_AND_ASSIGN(OutputConfigurator); |
467 }; | 526 }; |
468 | 527 |
469 typedef std::vector<OutputConfigurator::OutputSnapshot> OutputSnapshotList; | 528 typedef std::vector<OutputConfigurator::OutputSnapshot> OutputSnapshotList; |
470 | 529 |
471 } // namespace chromeos | 530 } // namespace chromeos |
472 | 531 |
473 #endif // CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ | 532 #endif // CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ |
OLD | NEW |