OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 UI_OZONE_PLATFORM_DRM_HOST_NATIVE_DISPLAY_DELEGATE_HOST_H_ | 5 #ifndef UI_OZONE_PLATFORM_DRM_HOST_NATIVE_DISPLAY_DELEGATE_HOST_H_ |
6 #define UI_OZONE_PLATFORM_DRM_HOST_NATIVE_DISPLAY_DELEGATE_HOST_H_ | 6 #define UI_OZONE_PLATFORM_DRM_HOST_NATIVE_DISPLAY_DELEGATE_HOST_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
| 9 #include <queue> |
| 10 #include <set> |
9 | 11 |
10 #include "base/files/file.h" | 12 #include "base/files/file.h" |
11 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
12 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_vector.h" | 16 #include "base/memory/scoped_vector.h" |
14 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
15 #include "ui/display/types/native_display_delegate.h" | 18 #include "ui/display/types/native_display_delegate.h" |
| 19 #include "ui/events/ozone/device/device_event.h" |
16 #include "ui/events/ozone/device/device_event_observer.h" | 20 #include "ui/events/ozone/device/device_event_observer.h" |
17 #include "ui/ozone/public/gpu_platform_support_host.h" | 21 #include "ui/ozone/public/gpu_platform_support_host.h" |
18 | 22 |
19 namespace ui { | 23 namespace ui { |
20 | 24 |
21 class DeviceManager; | 25 class DeviceManager; |
22 class DisplayManager; | 26 class DisplayManager; |
23 class DrmGpuPlatformSupportHost; | 27 class DrmGpuPlatformSupportHost; |
24 | 28 |
25 struct DisplaySnapshot_Params; | 29 struct DisplaySnapshot_Params; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 void OnChannelEstablished( | 73 void OnChannelEstablished( |
70 int host_id, | 74 int host_id, |
71 scoped_refptr<base::SingleThreadTaskRunner> send_runner, | 75 scoped_refptr<base::SingleThreadTaskRunner> send_runner, |
72 const base::Callback<void(IPC::Message*)>& send_callback) override; | 76 const base::Callback<void(IPC::Message*)>& send_callback) override; |
73 void OnChannelDestroyed(int host_id) override; | 77 void OnChannelDestroyed(int host_id) override; |
74 | 78 |
75 // IPC::Listener overrides: | 79 // IPC::Listener overrides: |
76 bool OnMessageReceived(const IPC::Message& message) override; | 80 bool OnMessageReceived(const IPC::Message& message) override; |
77 | 81 |
78 private: | 82 private: |
| 83 struct DisplayEvent { |
| 84 DisplayEvent(DeviceEvent::ActionType action_type, |
| 85 const base::FilePath& path) |
| 86 : action_type(action_type), path(path) {} |
| 87 |
| 88 DeviceEvent::ActionType action_type; |
| 89 base::FilePath path; |
| 90 }; |
| 91 |
79 void OnUpdateNativeDisplays( | 92 void OnUpdateNativeDisplays( |
80 const std::vector<DisplaySnapshot_Params>& displays); | 93 const std::vector<DisplaySnapshot_Params>& displays); |
81 void OnDisplayConfigured(int64_t display_id, bool status); | 94 void OnDisplayConfigured(int64_t display_id, bool status); |
82 | 95 |
83 void OnNewGraphicsDevice(const base::FilePath& path, base::File file); | 96 void ProcessEvent(); |
| 97 |
| 98 // Called as a result of finishing to process the display hotplug event. These |
| 99 // are responsible for dequing the event and scheduling the next event. |
| 100 void OnAddGraphicsDevice(const base::FilePath& path, base::File file); |
| 101 void OnUpdateGraphicsDevice(); |
| 102 void OnRemoveGraphicsDevice(const base::FilePath& path); |
84 | 103 |
85 void OnHDCPStateReceived(int64_t display_id, bool status, HDCPState state); | 104 void OnHDCPStateReceived(int64_t display_id, bool status, HDCPState state); |
86 void OnHDCPStateUpdated(int64_t display_id, bool status); | 105 void OnHDCPStateUpdated(int64_t display_id, bool status); |
87 | 106 |
88 void RunUpdateDisplaysCallback(const GetDisplaysCallback& callback) const; | 107 void RunUpdateDisplaysCallback(const GetDisplaysCallback& callback) const; |
89 | 108 |
90 DrmGpuPlatformSupportHost* proxy_; // Not owned. | 109 DrmGpuPlatformSupportHost* proxy_; // Not owned. |
91 DeviceManager* device_manager_; // Not owned. | 110 DeviceManager* device_manager_; // Not owned. |
92 DisplayManager* display_manager_; // Not owned. | 111 DisplayManager* display_manager_; // Not owned. |
93 | 112 |
(...skipping 11 matching lines...) Expand all Loading... |
105 | 124 |
106 GetDisplaysCallback get_displays_callback_; | 125 GetDisplaysCallback get_displays_callback_; |
107 | 126 |
108 // Map between display_id and the configuration callback. | 127 // Map between display_id and the configuration callback. |
109 std::map<int64_t, ConfigureCallback> configure_callback_map_; | 128 std::map<int64_t, ConfigureCallback> configure_callback_map_; |
110 | 129 |
111 std::map<int64_t, GetHDCPStateCallback> get_hdcp_state_callback_map_; | 130 std::map<int64_t, GetHDCPStateCallback> get_hdcp_state_callback_map_; |
112 | 131 |
113 std::map<int64_t, SetHDCPStateCallback> set_hdcp_state_callback_map_; | 132 std::map<int64_t, SetHDCPStateCallback> set_hdcp_state_callback_map_; |
114 | 133 |
| 134 // Used to serialize display event processing. This is done since |
| 135 // opening/closing DRM devices cannot be done on the UI thread and are handled |
| 136 // on a worker thread. Thus, we need to queue events in order to process them |
| 137 // in the correct order. |
| 138 std::queue<DisplayEvent> event_queue_; |
| 139 |
| 140 // True if a display event is currently being processed on a worker thread. |
| 141 bool task_pending_; |
| 142 |
| 143 // Keeps track of all the active DRM devices. |
| 144 std::set<base::FilePath> drm_devices_; |
| 145 |
115 base::WeakPtrFactory<DrmNativeDisplayDelegate> weak_ptr_factory_; | 146 base::WeakPtrFactory<DrmNativeDisplayDelegate> weak_ptr_factory_; |
116 | 147 |
117 DISALLOW_COPY_AND_ASSIGN(DrmNativeDisplayDelegate); | 148 DISALLOW_COPY_AND_ASSIGN(DrmNativeDisplayDelegate); |
118 }; | 149 }; |
119 | 150 |
120 } // namespace ui | 151 } // namespace ui |
121 | 152 |
122 #endif // UI_OZONE_PLATFORM_DRM_HOST_NATIVE_DISPLAY_DELEGATE_HOST_H_ | 153 #endif // UI_OZONE_PLATFORM_DRM_HOST_NATIVE_DISPLAY_DELEGATE_HOST_H_ |
OLD | NEW |