Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(251)

Side by Side Diff: chromeos/display/output_configurator.h

Issue 24039002: Pepper API implementation for output protection. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: use cached_outputs_ in output_configurator Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
56 // HDCP protection state.
57 enum HDCPState {
58 HDCP_STATE_UNDESIRED,
59 HDCP_STATE_DESIRED,
60 HDCP_STATE_ENABLED
61 };
62
39 // This class interacts directly with the underlying Xrandr API to manipulate 63 // This class interacts directly with the underlying Xrandr API to manipulate
40 // CTRCs and Outputs. 64 // CTRCs and Outputs.
41 class CHROMEOS_EXPORT OutputConfigurator 65 class CHROMEOS_EXPORT OutputConfigurator
42 : public base::MessageLoop::Dispatcher, 66 : public base::MessageLoop::Dispatcher,
43 public base::MessagePumpObserver { 67 public base::MessagePumpObserver {
44 public: 68 public:
69 typedef uint64_t OutputProtectionClientId;
70
45 struct ModeInfo { 71 struct ModeInfo {
46 ModeInfo(); 72 ModeInfo();
47 ModeInfo(int width, int height, bool interlaced, float refresh_rate); 73 ModeInfo(int width, int height, bool interlaced, float refresh_rate);
48 74
49 int width; 75 int width;
50 int height; 76 int height;
51 bool interlaced; 77 bool interlaced;
52 float refresh_rate; 78 float refresh_rate;
53 }; 79 };
54 80
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 RRMode selected_mode; 114 RRMode selected_mode;
89 115
90 // Output's origin on the framebuffer. 116 // Output's origin on the framebuffer.
91 int x; 117 int x;
92 int y; 118 int y;
93 119
94 // Output's physical dimensions. 120 // Output's physical dimensions.
95 uint64 width_mm; 121 uint64 width_mm;
96 uint64 height_mm; 122 uint64 height_mm;
97 123
98 bool is_internal; 124 bool is_internal;
Daniel Erat 2013/09/23 19:31:43 mind adding a TODO to remove this, since it should
kcwu 2013/09/24 13:55:06 Done.
99 bool is_aspect_preserving_scaling; 125 bool is_aspect_preserving_scaling;
100 126
127 // The type of output.
128 OutputType type;
129
101 // Map from mode IDs to details about the corresponding modes. 130 // Map from mode IDs to details about the corresponding modes.
102 ModeInfoMap mode_infos; 131 ModeInfoMap mode_infos;
103 132
104 // XInput device ID or 0 if this output isn't a touchscreen. 133 // XInput device ID or 0 if this output isn't a touchscreen.
105 int touch_device_id; 134 int touch_device_id;
106 135
107 CoordinateTransformation transform; 136 CoordinateTransformation transform;
108 137
109 // Display id for this output. 138 // Display id for this output.
110 int64 display_id; 139 int64 display_id;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 // |touch_device_id| the ID of the touchscreen device to configure. 244 // |touch_device_id| the ID of the touchscreen device to configure.
216 // |ctm| contains the desired transformation parameters. The offsets 245 // |ctm| contains the desired transformation parameters. The offsets
217 // in it should be normalized so that 1 corresponds to the X or Y axis 246 // in it should be normalized so that 1 corresponds to the X or Y axis
218 // size for the corresponding offset. 247 // size for the corresponding offset.
219 virtual void ConfigureCTM(int touch_device_id, 248 virtual void ConfigureCTM(int touch_device_id,
220 const CoordinateTransformation& ctm) = 0; 249 const CoordinateTransformation& ctm) = 0;
221 250
222 // Sends a D-Bus message to the power manager telling it that the 251 // Sends a D-Bus message to the power manager telling it that the
223 // machine is or is not projecting. 252 // machine is or is not projecting.
224 virtual void SendProjectingStateToPowerManager(bool projecting) = 0; 253 virtual void SendProjectingStateToPowerManager(bool projecting) = 0;
254
255 // Gets HDCP state of output.
256 virtual bool GetHDCPState(RROutput id, HDCPState* state) = 0;
257
258 // Sets HDCP state of output.
259 virtual bool SetHDCPState(RROutput id, HDCPState state) = 0;
225 }; 260 };
226 261
227 // Helper class used by tests. 262 // Helper class used by tests.
228 class TestApi { 263 class TestApi {
229 public: 264 public:
230 TestApi(OutputConfigurator* configurator, int xrandr_event_base) 265 TestApi(OutputConfigurator* configurator, int xrandr_event_base)
231 : configurator_(configurator), 266 : configurator_(configurator),
232 xrandr_event_base_(xrandr_event_base) {} 267 xrandr_event_base_(xrandr_event_base) {}
233 ~TestApi() {} 268 ~TestApi() {}
234 269
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 void ResumeDisplays(); 386 void ResumeDisplays();
352 387
353 const std::map<int, float>& GetMirroredDisplayAreaRatioMap() { 388 const std::map<int, float>& GetMirroredDisplayAreaRatioMap() {
354 return mirrored_display_area_ratio_map_; 389 return mirrored_display_area_ratio_map_;
355 } 390 }
356 391
357 // Configure outputs with |kConfigureDelayMs| delay, 392 // Configure outputs with |kConfigureDelayMs| delay,
358 // so that time-consuming ConfigureOutputs() won't be called multiple times. 393 // so that time-consuming ConfigureOutputs() won't be called multiple times.
359 void ScheduleConfigureOutputs(); 394 void ScheduleConfigureOutputs();
360 395
396 // Registers a client for output protection and requests a client id. Returns
397 // 0 if requesting failed.
398 OutputProtectionClientId RegisterOutputProtectionClient();
399
400 // Unregisters the client.
401 void UnregisterOutputProtectionClient(OutputProtectionClientId client_id);
402
403 // Queries link status and protection status.
404 // |link_mask| is the type of connected output links, which is a bitmask of
405 // OutputType values. |protection_mask| is the desired protection methods,
406 // which is a bitmask of the OutputProtectionMethod values.
407 // Returns true on success.
408 bool QueryOutputProtectionStatus(
409 OutputProtectionClientId client_id,
410 uint32_t* link_mask,
411 uint32_t* protection_mask);
412
413 // Requests the desired protection methods.
414 // |protection_mask| is the desired protection methods, which is a bitmask
415 // of the OutputProtectionMethod values.
416 // Returns true when the protection request has been made.
417 bool EnableOutputProtection(
418 OutputProtectionClientId client_id,
419 uint32_t desired_protection_mask);
420
361 private: 421 private:
422 // Mapping a client to its protection request bitmask.
423 typedef std::map<chromeos::OutputConfigurator::OutputProtectionClientId,
424 uint32_t> ProtectionRequests;
425
362 // Returns currently-connected outputs. This method is a wrapper around 426 // Returns currently-connected outputs. This method is a wrapper around
363 // |delegate_->GetOutputs()| that does additional work, like finding the 427 // |delegate_->GetOutputs()| that does additional work, like finding the
364 // mirror mode and setting user-preferred modes. Note that the server must 428 // mirror mode and setting user-preferred modes. Note that the server must
365 // be grabbed via |delegate_->GrabServer()| first. 429 // be grabbed via |delegate_->GrabServer()| first.
366 std::vector<OutputSnapshot> GetOutputs(); 430 std::vector<OutputSnapshot> GetOutputs();
367 431
368 // Helper method for GetOutputs() that initializes the passed-in outputs' 432 // Helper method for GetOutputs() that initializes the passed-in outputs'
369 // |mirror_mode| fields by looking for a mode in |internal_output| and 433 // |mirror_mode| fields by looking for a mode in |internal_output| and
370 // |external_output| having the same resolution. Returns false if a shared 434 // |external_output| having the same resolution. Returns false if a shared
371 // mode wasn't found or created. 435 // mode wasn't found or created.
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 // Most-recently-used output configuration. Note that the actual 520 // Most-recently-used output configuration. Note that the actual
457 // configuration changes asynchronously. 521 // configuration changes asynchronously.
458 std::vector<OutputSnapshot> cached_outputs_; 522 std::vector<OutputSnapshot> cached_outputs_;
459 523
460 ObserverList<Observer> observers_; 524 ObserverList<Observer> observers_;
461 525
462 // The timer to delay configuring outputs. See also the comments in 526 // The timer to delay configuring outputs. See also the comments in
463 // Dispatch(). 527 // Dispatch().
464 scoped_ptr<base::OneShotTimer<OutputConfigurator> > configure_timer_; 528 scoped_ptr<base::OneShotTimer<OutputConfigurator> > configure_timer_;
465 529
530 // Id for next output protection client.
531 OutputProtectionClientId next_output_protection_client_id_;
532
533 // Output protection requests of each client.
534 ProtectionRequests client_protection_requests_;
535
466 DISALLOW_COPY_AND_ASSIGN(OutputConfigurator); 536 DISALLOW_COPY_AND_ASSIGN(OutputConfigurator);
467 }; 537 };
468 538
469 typedef std::vector<OutputConfigurator::OutputSnapshot> OutputSnapshotList; 539 typedef std::vector<OutputConfigurator::OutputSnapshot> OutputSnapshotList;
470 540
471 } // namespace chromeos 541 } // namespace chromeos
472 542
473 #endif // CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ 543 #endif // CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698