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_DRI_DRI_WRAPPER_H_ | 5 #ifndef UI_OZONE_PLATFORM_DRI_DRI_WRAPPER_H_ |
6 #define UI_OZONE_PLATFORM_DRI_DRI_WRAPPER_H_ | 6 #define UI_OZONE_PLATFORM_DRI_DRI_WRAPPER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
15 #include "base/threading/thread.h" | 15 #include "base/threading/thread.h" |
16 #include "ui/gfx/geometry/rect.h" | 16 #include "ui/gfx/geometry/rect.h" |
17 #include "ui/gfx/geometry/rect_f.h" | 17 #include "ui/gfx/geometry/rect_f.h" |
18 #include "ui/gfx/overlay_transform.h" | 18 #include "ui/gfx/overlay_transform.h" |
19 #include "ui/ozone/platform/dri/hardware_display_plane_manager.h" | 19 #include "ui/ozone/platform/dri/hardware_display_plane_manager.h" |
20 #include "ui/ozone/platform/dri/scoped_drm_types.h" | 20 #include "ui/ozone/platform/dri/scoped_drm_types.h" |
21 | 21 |
22 typedef struct _drmEventContext drmEventContext; | 22 typedef struct _drmEventContext drmEventContext; |
23 typedef struct _drmModeModeInfo drmModeModeInfo; | 23 typedef struct _drmModeModeInfo drmModeModeInfo; |
24 | 24 |
25 struct SkImageInfo; | 25 struct SkImageInfo; |
26 | 26 |
27 namespace ui { | 27 namespace ui { |
28 | 28 |
29 class HardwareDisplayPlaneManager; | 29 class HardwareDisplayPlaneManager; |
| 30 class IOHelperThread; |
30 | 31 |
31 // Wraps DRM calls into a nice interface. Used to provide different | 32 // Wraps DRM calls into a nice interface. Used to provide different |
32 // implementations of the DRM calls. For the actual implementation the DRM API | 33 // implementations of the DRM calls. For the actual implementation the DRM API |
33 // would be called. In unit tests this interface would be stubbed. | 34 // would be called. In unit tests this interface would be stubbed. |
34 class DriWrapper { | 35 class DriWrapper { |
35 public: | 36 public: |
36 typedef base::Callback<void(unsigned int /* frame */, | 37 typedef base::Callback<void(unsigned int /* frame */, |
37 unsigned int /* seconds */, | 38 unsigned int /* seconds */, |
38 unsigned int /* useconds */)> PageFlipCallback; | 39 unsigned int /* useconds */)> PageFlipCallback; |
39 | 40 |
40 DriWrapper(const char* device_path, bool use_sync_flips); | 41 // TODO(dnicoara) We should be passing a TaskRunner, however we cannot |
| 42 // initialize the thread that early since the Ozone platform (and DriWrapper) |
| 43 // is initializing before the sandbox. |
| 44 DriWrapper(const char* device_path, IOHelperThread* io_thread); |
41 virtual ~DriWrapper(); | 45 virtual ~DriWrapper(); |
42 | 46 |
43 // Open device. | 47 // Open device. |
44 virtual void Initialize(); | 48 virtual void Initialize(); |
45 | 49 |
46 // Get the CRTC state. This is generally used to save state before using the | 50 // Get the CRTC state. This is generally used to save state before using the |
47 // CRTC. When the user finishes using the CRTC, the user should restore the | 51 // CRTC. When the user finishes using the CRTC, the user should restore the |
48 // CRTC to it's initial state. Use |SetCrtc| to restore the state. | 52 // CRTC to it's initial state. Use |SetCrtc| to restore the state. |
49 virtual ScopedDrmCrtcPtr GetCrtc(uint32_t crtc_id); | 53 virtual ScopedDrmCrtcPtr GetCrtc(uint32_t crtc_id); |
50 | 54 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 // after the sandbox is up, thus the late initialization. | 160 // after the sandbox is up, thus the late initialization. |
157 virtual void InitializeIOWatcher(); | 161 virtual void InitializeIOWatcher(); |
158 | 162 |
159 // The file descriptor associated with this wrapper. All DRM operations will | 163 // The file descriptor associated with this wrapper. All DRM operations will |
160 // be performed using this FD. | 164 // be performed using this FD. |
161 // TODO(dnicoara) Make this a base::File | 165 // TODO(dnicoara) Make this a base::File |
162 int fd_; | 166 int fd_; |
163 | 167 |
164 scoped_ptr<HardwareDisplayPlaneManager> plane_manager_; | 168 scoped_ptr<HardwareDisplayPlaneManager> plane_manager_; |
165 | 169 |
166 // If we need to block when performing page flips this is set to true. | |
167 bool use_sync_flips_; | |
168 | |
169 private: | 170 private: |
170 class IOWatcher; | 171 class IOWatcher; |
171 | 172 |
172 // Path to DRM device. | 173 // Path to DRM device. |
173 const char* device_path_; | 174 const char* device_path_; |
174 | 175 |
175 // Helper thread to perform IO listener operations. | 176 // Helper thread to perform IO listener operations. |
176 // TODO(dnicoara) This should really be supported by the main thread. | 177 // TODO(dnicoara) This should really be supported by the main thread. |
177 // Alternatively we should have a way to access the IO thread's task runner. | 178 // Alternatively we should have a way to access the IO thread's task runner. |
178 base::Thread io_thread_; | 179 IOHelperThread* io_thread_; |
179 | 180 |
180 // Watcher for |fd_| listening for page flip events. | 181 // Watcher for |fd_| listening for page flip events. |
181 scoped_refptr<IOWatcher> watcher_; | 182 scoped_refptr<IOWatcher> watcher_; |
182 | 183 |
183 DISALLOW_COPY_AND_ASSIGN(DriWrapper); | 184 DISALLOW_COPY_AND_ASSIGN(DriWrapper); |
184 }; | 185 }; |
185 | 186 |
186 } // namespace ui | 187 } // namespace ui |
187 | 188 |
188 #endif // UI_OZONE_PLATFORM_DRI_DRI_WRAPPER_H_ | 189 #endif // UI_OZONE_PLATFORM_DRI_DRI_WRAPPER_H_ |
OLD | NEW |