[Ozone-Drm] Add support for async content protection
[chromium-blink-merge.git] / ui / ozone / platform / drm / host / drm_native_display_delegate.h
blobb6d6063a8ab0f789f5daa399b237b9554587eb96
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef UI_OZONE_PLATFORM_DRM_HOST_NATIVE_DISPLAY_DELEGATE_HOST_H_
6 #define UI_OZONE_PLATFORM_DRM_HOST_NATIVE_DISPLAY_DELEGATE_HOST_H_
8 #include <map>
10 #include "base/files/file.h"
11 #include "base/files/file_path.h"
12 #include "base/macros.h"
13 #include "base/memory/scoped_vector.h"
14 #include "base/observer_list.h"
15 #include "ui/display/types/native_display_delegate.h"
16 #include "ui/events/ozone/device/device_event_observer.h"
17 #include "ui/ozone/public/gpu_platform_support_host.h"
19 namespace ui {
21 class DeviceManager;
22 class DisplayManager;
23 class DrmGpuPlatformSupportHost;
25 struct DisplaySnapshot_Params;
27 class DrmNativeDisplayDelegate : public NativeDisplayDelegate,
28 public DeviceEventObserver,
29 public GpuPlatformSupportHost {
30 public:
31 DrmNativeDisplayDelegate(DrmGpuPlatformSupportHost* proxy,
32 DeviceManager* device_manager,
33 DisplayManager* display_manager,
34 const base::FilePath& primary_graphics_card_path);
35 ~DrmNativeDisplayDelegate() override;
37 // NativeDisplayDelegate overrides:
38 void Initialize() override;
39 void GrabServer() override;
40 void UngrabServer() override;
41 bool TakeDisplayControl() override;
42 bool RelinquishDisplayControl() override;
43 void SyncWithServer() override;
44 void SetBackgroundColor(uint32_t color_argb) override;
45 void ForceDPMSOn() override;
46 void GetDisplays(const GetDisplaysCallback& callback) override;
47 void AddMode(const DisplaySnapshot& output, const DisplayMode* mode) override;
48 void Configure(const DisplaySnapshot& output,
49 const DisplayMode* mode,
50 const gfx::Point& origin,
51 const ConfigureCallback& callback) override;
52 void CreateFrameBuffer(const gfx::Size& size) override;
53 bool GetHDCPState(const DisplaySnapshot& output, HDCPState* state) override;
54 bool SetHDCPState(const DisplaySnapshot& output, HDCPState state) override;
55 void GetHDCPState(const DisplaySnapshot& output,
56 const GetHDCPStateCallback& callback) override;
57 void SetHDCPState(const DisplaySnapshot& output,
58 HDCPState state,
59 const SetHDCPStateCallback& callback) override;
60 std::vector<ColorCalibrationProfile> GetAvailableColorCalibrationProfiles(
61 const DisplaySnapshot& output) override;
62 bool SetColorCalibrationProfile(const DisplaySnapshot& output,
63 ColorCalibrationProfile new_profile) override;
64 void AddObserver(NativeDisplayObserver* observer) override;
65 void RemoveObserver(NativeDisplayObserver* observer) override;
67 // DeviceEventObserver overrides:
68 void OnDeviceEvent(const DeviceEvent& event) override;
70 // GpuPlatformSupportHost:
71 void OnChannelEstablished(
72 int host_id,
73 scoped_refptr<base::SingleThreadTaskRunner> send_runner,
74 const base::Callback<void(IPC::Message*)>& send_callback) override;
75 void OnChannelDestroyed(int host_id) override;
77 // IPC::Listener overrides:
78 bool OnMessageReceived(const IPC::Message& message) override;
80 private:
81 void OnUpdateNativeDisplays(
82 const std::vector<DisplaySnapshot_Params>& displays);
83 void OnDisplayConfigured(int64_t display_id, bool status);
85 void OnNewGraphicsDevice(const base::FilePath& path, base::File file);
87 void OnHDCPStateReceived(int64_t display_id, bool status, HDCPState state);
88 void OnHDCPStateUpdated(int64_t display_id, bool status);
90 void RunUpdateDisplaysCallback(const GetDisplaysCallback& callback) const;
92 DrmGpuPlatformSupportHost* proxy_; // Not owned.
93 DeviceManager* device_manager_; // Not owned.
94 DisplayManager* display_manager_; // Not owned.
96 // File path for the primary graphics card which is opened by default in the
97 // GPU process. We'll avoid opening this in hotplug events since it will race
98 // with the GPU process trying to open it and aquire DRM master.
99 const base::FilePath primary_graphics_card_path_;
101 // Keeps track if there is a dummy display. This happens on initialization
102 // when there is no connection to the GPU to update the displays.
103 bool has_dummy_display_;
105 ScopedVector<DisplaySnapshot> displays_;
106 ObserverList<NativeDisplayObserver> observers_;
108 GetDisplaysCallback get_displays_callback_;
110 // Map between display_id and the configuration callback.
111 std::map<int64_t, ConfigureCallback> configure_callback_map_;
113 std::map<int64_t, GetHDCPStateCallback> get_hdcp_state_callback_map_;
115 std::map<int64_t, SetHDCPStateCallback> set_hdcp_state_callback_map_;
117 base::WeakPtrFactory<DrmNativeDisplayDelegate> weak_ptr_factory_;
119 DISALLOW_COPY_AND_ASSIGN(DrmNativeDisplayDelegate);
122 } // namespace ui
124 #endif // UI_OZONE_PLATFORM_DRM_HOST_NATIVE_DISPLAY_DELEGATE_HOST_H_