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

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: fix test on chromeos 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>
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,
dmichael (off chromium) 2013/09/17 17:25:33 = 0?
kcwu 2013/09/17 23:15:32 Done.
57 OUTPUT_PROTECTION_METHOD_HDCP = 1 << 0,
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
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 // Register a client for output protection and request a client id. Returns
244 // 0 if requesting failed.
245 virtual uint64_t RegisterOutputProtectionClient() = 0;
246 // Unregister the client.
247 virtual void UnregisterOutputProtectionClient(uint64_t client_id) = 0;
248 // Query link status and protection status. Returns true on success.
249 virtual bool QueryOutputProtectionStatus(
250 uint64_t client_id,
251 uint32_t* link_mask,
252 uint32_t* protection_mask) = 0;
253
254 // Request the desired protection methods. Returns true when the protection
255 // request has been made.
256 virtual bool EnableOutputProtection(
257 uint64_t client_id,
258 uint32_t desired_method_mask) = 0;
221 }; 259 };
222 260
223 // Helper class used by tests. 261 // Helper class used by tests.
224 class TestApi { 262 class TestApi {
225 public: 263 public:
226 TestApi(OutputConfigurator* configurator, int xrandr_event_base) 264 TestApi(OutputConfigurator* configurator, int xrandr_event_base)
227 : configurator_(configurator), 265 : configurator_(configurator),
228 xrandr_event_base_(xrandr_event_base) {} 266 xrandr_event_base_(xrandr_event_base) {}
229 ~TestApi() {} 267 ~TestApi() {}
230 268
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 void ResumeDisplays(); 379 void ResumeDisplays();
342 380
343 const std::map<int, float>& GetMirroredDisplayAreaRatioMap() { 381 const std::map<int, float>& GetMirroredDisplayAreaRatioMap() {
344 return mirrored_display_area_ratio_map_; 382 return mirrored_display_area_ratio_map_;
345 } 383 }
346 384
347 // Configure outputs with |kConfigureDelayMs| delay, 385 // Configure outputs with |kConfigureDelayMs| delay,
348 // so that time-consuming ConfigureOutputs() won't be called multiple times. 386 // so that time-consuming ConfigureOutputs() won't be called multiple times.
349 void ScheduleConfigureOutputs(); 387 void ScheduleConfigureOutputs();
350 388
389 // Register a client for output protection and request a client id. Returns
390 // 0 if requesting failed.
391 uint64_t RegisterOutputProtectionClient();
392 // Unregister the client.
393 void UnregisterOutputProtectionClient(uint64_t client_id);
394 // Query link status and protection status.
395 // |link_mask| is the type of connected output links, which is a bitmask
396 // of PP_OutputProtectionLinkType_Private values. |protection_mask| is the
397 // desired protection methods, which is a bitmask of the
398 // PP_OutputProtectionMethod_Private values.
399 // Returns true on success.
400 bool QueryOutputProtectionStatus(
401 uint64_t client_id,
402 uint32_t* link_mask,
403 uint32_t* protection_mask);
404
405 // Request the desired protection methods.
406 // |protection_mask| is the desired protection methods, which is a bitmask
407 // of the PP_OutputProtectionMethod_Private values.
408 // Returns true when the protection request has been made.
409 bool EnableOutputProtection(
410 uint64_t client_id,
411 uint32_t desired_method_mask);
412
351 private: 413 private:
352 // Configure outputs. 414 // Configure outputs.
353 void ConfigureOutputs(); 415 void ConfigureOutputs();
354 416
355 // Notifies observers about an attempted state change. 417 // Notifies observers about an attempted state change.
356 void NotifyObservers(bool success, OutputState attempted_state); 418 void NotifyObservers(bool success, OutputState attempted_state);
357 419
358 // Switches to the state specified in |output_state| and |power_state|. 420 // Switches to the state specified in |output_state| and |power_state|.
359 // If the hardware mirroring failed and |mirroring_controller_| is set, 421 // If the hardware mirroring failed and |mirroring_controller_| is set,
360 // it switches to |STATE_DUAL_EXTENDED| and calls |SetSoftwareMirroring()| 422 // it switches to |STATE_DUAL_EXTENDED| and calls |SetSoftwareMirroring()|
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 scoped_ptr<base::OneShotTimer<OutputConfigurator> > configure_timer_; 491 scoped_ptr<base::OneShotTimer<OutputConfigurator> > configure_timer_;
430 492
431 DISALLOW_COPY_AND_ASSIGN(OutputConfigurator); 493 DISALLOW_COPY_AND_ASSIGN(OutputConfigurator);
432 }; 494 };
433 495
434 typedef std::vector<OutputConfigurator::OutputSnapshot> OutputSnapshotList; 496 typedef std::vector<OutputConfigurator::OutputSnapshot> OutputSnapshotList;
435 497
436 } // namespace chromeos 498 } // namespace chromeos
437 499
438 #endif // CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ 500 #endif // CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698