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 <set> | |
10 | 9 |
| 10 #include "base/containers/scoped_ptr_hash_map.h" |
11 #include "base/files/file.h" | 11 #include "base/files/file.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/ref_counted.h" | |
15 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
16 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
17 #include "ui/display/types/native_display_delegate.h" | 16 #include "ui/display/types/native_display_delegate.h" |
18 #include "ui/events/ozone/device/device_event_observer.h" | 17 #include "ui/events/ozone/device/device_event_observer.h" |
19 #include "ui/ozone/platform/drm/host/sequenced_scheduler.h" | 18 #include "ui/ozone/platform/drm/host/sequenced_scheduler.h" |
20 #include "ui/ozone/public/gpu_platform_support_host.h" | 19 #include "ui/ozone/public/gpu_platform_support_host.h" |
21 | 20 |
22 namespace ui { | 21 namespace ui { |
23 | 22 |
24 class DeviceManager; | 23 class DeviceManager; |
25 class DisplayManager; | 24 class DisplayManager; |
| 25 class DrmDeviceHandle; |
26 class DrmGpuPlatformSupportHost; | 26 class DrmGpuPlatformSupportHost; |
27 | 27 |
28 struct DisplaySnapshot_Params; | 28 struct DisplaySnapshot_Params; |
29 | 29 |
30 class DrmNativeDisplayDelegate : public NativeDisplayDelegate, | 30 class DrmNativeDisplayDelegate : public NativeDisplayDelegate, |
31 public DeviceEventObserver, | 31 public DeviceEventObserver, |
32 public GpuPlatformSupportHost { | 32 public GpuPlatformSupportHost { |
33 public: | 33 public: |
34 DrmNativeDisplayDelegate(DrmGpuPlatformSupportHost* proxy, | 34 DrmNativeDisplayDelegate(DrmGpuPlatformSupportHost* proxy, |
35 DeviceManager* device_manager, | 35 DeviceManager* device_manager, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // IPC::Listener overrides: | 75 // IPC::Listener overrides: |
76 bool OnMessageReceived(const IPC::Message& message) override; | 76 bool OnMessageReceived(const IPC::Message& message) override; |
77 | 77 |
78 private: | 78 private: |
79 void OnUpdateNativeDisplays( | 79 void OnUpdateNativeDisplays( |
80 const std::vector<DisplaySnapshot_Params>& displays); | 80 const std::vector<DisplaySnapshot_Params>& displays); |
81 void OnDisplayConfigured(int64_t display_id, bool status); | 81 void OnDisplayConfigured(int64_t display_id, bool status); |
82 | 82 |
83 // Called as a result of finishing to process the display hotplug event. These | 83 // Called as a result of finishing to process the display hotplug event. These |
84 // are responsible for dequing the event and scheduling the next event. | 84 // are responsible for dequing the event and scheduling the next event. |
85 void OnAddGraphicsDevice(const base::FilePath& path, base::File file); | 85 void OnAddGraphicsDevice(const base::FilePath& path); |
86 void OnUpdateGraphicsDevice(); | 86 void OnUpdateGraphicsDevice(); |
87 void OnRemoveGraphicsDevice(const base::FilePath& path); | 87 void OnRemoveGraphicsDevice(const base::FilePath& path); |
88 | 88 |
89 void RunUpdateDisplaysCallback(const GetDisplaysCallback& callback) const; | 89 void RunUpdateDisplaysCallback(const GetDisplaysCallback& callback) const; |
90 | 90 |
91 DrmGpuPlatformSupportHost* proxy_; // Not owned. | 91 DrmGpuPlatformSupportHost* proxy_; // Not owned. |
92 DeviceManager* device_manager_; // Not owned. | 92 DeviceManager* device_manager_; // Not owned. |
93 DisplayManager* display_manager_; // Not owned. | 93 DisplayManager* display_manager_; // Not owned. |
94 | 94 |
95 // File path for the primary graphics card which is opened by default in the | 95 // File path for the primary graphics card which is opened by default in the |
96 // GPU process. We'll avoid opening this in hotplug events since it will race | 96 // GPU process. We'll avoid opening this in hotplug events since it will race |
97 // with the GPU process trying to open it and aquire DRM master. | 97 // with the GPU process trying to open it and aquire DRM master. |
98 const base::FilePath primary_graphics_card_path_; | 98 const base::FilePath primary_graphics_card_path_; |
99 | 99 |
100 // Keeps track if there is a dummy display. This happens on initialization | 100 // Keeps track if there is a dummy display. This happens on initialization |
101 // when there is no connection to the GPU to update the displays. | 101 // when there is no connection to the GPU to update the displays. |
102 bool has_dummy_display_; | 102 bool has_dummy_display_; |
103 | 103 |
104 ScopedVector<DisplaySnapshot> displays_; | 104 ScopedVector<DisplaySnapshot> displays_; |
105 ObserverList<NativeDisplayObserver> observers_; | 105 ObserverList<NativeDisplayObserver> observers_; |
106 | 106 |
107 GetDisplaysCallback get_displays_callback_; | 107 GetDisplaysCallback get_displays_callback_; |
108 | 108 |
109 // Map between display_id and the configuration callback. | 109 // Map between display_id and the configuration callback. |
110 std::map<int64_t, ConfigureCallback> configure_callback_map_; | 110 std::map<int64_t, ConfigureCallback> configure_callback_map_; |
111 | 111 |
112 // Keeps track of all the active DRM devices. | 112 // Keeps track of all the active DRM devices. |
113 std::set<base::FilePath> drm_devices_; | 113 base::ScopedPtrHashMap<base::FilePath, DrmDeviceHandle> drm_devices_; |
114 | 114 |
115 // Used to asynchronously process display hotplug events in the correct order. | 115 // Used to asynchronously process display hotplug events in the correct order. |
116 SequencedScheduler scheduler_; | 116 SequencedScheduler scheduler_; |
117 | 117 |
118 base::WeakPtrFactory<DrmNativeDisplayDelegate> weak_ptr_factory_; | 118 base::WeakPtrFactory<DrmNativeDisplayDelegate> weak_ptr_factory_; |
119 | 119 |
120 DISALLOW_COPY_AND_ASSIGN(DrmNativeDisplayDelegate); | 120 DISALLOW_COPY_AND_ASSIGN(DrmNativeDisplayDelegate); |
121 }; | 121 }; |
122 | 122 |
123 } // namespace ui | 123 } // namespace ui |
124 | 124 |
125 #endif // UI_OZONE_PLATFORM_DRM_HOST_NATIVE_DISPLAY_DELEGATE_HOST_H_ | 125 #endif // UI_OZONE_PLATFORM_DRM_HOST_NATIVE_DISPLAY_DELEGATE_HOST_H_ |
OLD | NEW |