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

Side by Side Diff: ui/ozone/platform/drm/host/drm_display_host_manager.h

Issue 1285183008: Ozone integration. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: add missing license header Created 5 years, 4 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
(Empty)
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.
4
5 #ifndef UI_OZONE_PLATFORM_DRM_HOST_DRM_DISPLAY_HOST_MANAGER_H_
6 #define UI_OZONE_PLATFORM_DRM_HOST_DRM_DISPLAY_HOST_MANAGER_H_
7
8 #include <queue>
9 #include <set>
10
11 #include "base/files/scoped_file.h"
12 #include "base/memory/scoped_vector.h"
13 #include "base/memory/weak_ptr.h"
14 #include "ui/display/types/native_display_delegate.h"
15 #include "ui/events/ozone/device/device_event.h"
16 #include "ui/events/ozone/device/device_event_observer.h"
17 #include "ui/events/ozone/evdev/event_factory_evdev.h"
18
19 namespace ui {
20
21 class DeviceManager;
22 class DrmDeviceHandle;
23 class DrmDisplayHost;
24 class DrmGpuPlatformSupportHost;
25 class DrmNativeDisplayDelegate;
26
27 struct DisplaySnapshot_Params;
28
29 class DrmDisplayHostManager : public DeviceEventObserver {
30 public:
31 // Note: IO is performed in this constructor.
32 DrmDisplayHostManager(DrmGpuPlatformSupportHost* proxy,
33 DeviceManager* device_manager,
34 InputControllerEvdev* input_controller);
35 ~DrmDisplayHostManager() override;
36
37 DrmDisplayHost* GetDisplay(int64_t display_id);
38
39 void AddDelegate(DrmNativeDisplayDelegate* delegate);
40 void RemoveDelegate(DrmNativeDisplayDelegate* delegate);
41
42 void TakeDisplayControl(const DisplayControlCallback& callback);
43 void RelinquishDisplayControl(const DisplayControlCallback& callback);
44 void UpdateDisplays(const GetDisplaysCallback& callback);
45
46 // DeviceEventObserver overrides:
47 void OnDeviceEvent(const DeviceEvent& event) override;
48
49 // Note: IO is performed in OnChannelEstablished.
50 void OnChannelEstablished(int host_id);
51 void OnChannelDestroyed(int host_id);
52
53 void OnUpdateNativeDisplays(
54 const std::vector<DisplaySnapshot_Params>& displays);
55 void OnDisplayConfigured(int64_t display_id, bool status);
56
57 // Called as a result of finishing to process the display hotplug event. These
58 // are responsible for dequing the event and scheduling the next event.
59 void OnAddGraphicsDevice(const base::FilePath& path,
60 scoped_ptr<DrmDeviceHandle> handle);
61 void OnUpdateGraphicsDevice();
62 void OnRemoveGraphicsDevice(const base::FilePath& path);
63
64 void OnHDCPStateReceived(int64_t display_id, bool status, HDCPState state);
65 void OnHDCPStateUpdated(int64_t display_id, bool status);
66
67 void OnTakeDisplayControl(bool status);
68 void OnRelinquishDisplayControl(bool status);
69
70 private:
71 struct DisplayEvent {
72 DisplayEvent(DeviceEvent::ActionType action_type,
73 const base::FilePath& path)
74 : action_type(action_type), path(path) {}
75
76 DeviceEvent::ActionType action_type;
77 base::FilePath path;
78 };
79
80
81 void ProcessEvent();
82
83 void RunUpdateDisplaysCallback(const GetDisplaysCallback& callback) const;
84
85 void NotifyDisplayDelegate() const;
86
87 DrmGpuPlatformSupportHost* proxy_; // Not owned.
88 DeviceManager* device_manager_; // Not owned.
89 InputControllerEvdev* input_controller_; // Not owned.
90
91 DrmNativeDisplayDelegate* delegate_ = nullptr; // Not owned.
92
93 // File path for the primary graphics card which is opened by default in the
94 // GPU process. We'll avoid opening this in hotplug events since it will race
95 // with the GPU process trying to open it and aquire DRM master.
96 base::FilePath primary_graphics_card_path_;
97
98 // File path for virtual gem (VGEM) device.
99 base::FilePath vgem_card_path_;
100
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_ = false;
104
105 ScopedVector<DrmDisplayHost> displays_;
106
107 GetDisplaysCallback get_displays_callback_;
108
109 bool display_externally_controlled_ = false;
110 bool display_control_change_pending_ = false;
111 DisplayControlCallback take_display_control_callback_;
112 DisplayControlCallback relinquish_display_control_callback_;
113
114 // Used to serialize display event processing. This is done since
115 // opening/closing DRM devices cannot be done on the UI thread and are handled
116 // on a worker thread. Thus, we need to queue events in order to process them
117 // in the correct order.
118 std::queue<DisplayEvent> event_queue_;
119
120 // True if a display event is currently being processed on a worker thread.
121 bool task_pending_ = false;
122
123 // Keeps track of all the active DRM devices.
124 std::set<base::FilePath> drm_devices_;
125
126 // This is used to cache the primary DRM device until the channel is
127 // established.
128 scoped_ptr<DrmDeviceHandle> primary_drm_device_handle_;
129
130 // Manages the VGEM device by itself and doesn't send it to GPU process.
131 base::ScopedFD vgem_card_device_file_;
132
133 base::WeakPtrFactory<DrmDisplayHostManager> weak_ptr_factory_;
134
135 DISALLOW_COPY_AND_ASSIGN(DrmDisplayHostManager);
136 };
137
138 } // namespace ui
139
140 #endif // UI_OZONE_PLATFORM_DRM_HOST_DRM_DISPLAY_HOST_MANAGER_H_
OLDNEW
« no previous file with comments | « ui/ozone/platform/drm/host/drm_display_host.cc ('k') | ui/ozone/platform/drm/host/drm_display_host_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698