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_DRM_DEVICE_H_ |
6 #define UI_OZONE_PLATFORM_DRI_DRI_WRAPPER_H_ | 6 #define UI_OZONE_PLATFORM_DRI_DRM_DEVICE_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/files/file.h" | 13 #include "base/files/file.h" |
14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
(...skipping 14 matching lines...) Expand all Loading... |
31 class SingleThreadTaskRunner; | 31 class SingleThreadTaskRunner; |
32 } // namespace base | 32 } // namespace base |
33 | 33 |
34 namespace ui { | 34 namespace ui { |
35 | 35 |
36 class HardwareDisplayPlaneManager; | 36 class HardwareDisplayPlaneManager; |
37 | 37 |
38 // Wraps DRM calls into a nice interface. Used to provide different | 38 // Wraps DRM calls into a nice interface. Used to provide different |
39 // implementations of the DRM calls. For the actual implementation the DRM API | 39 // implementations of the DRM calls. For the actual implementation the DRM API |
40 // would be called. In unit tests this interface would be stubbed. | 40 // would be called. In unit tests this interface would be stubbed. |
41 class OZONE_EXPORT DriWrapper : public base::RefCountedThreadSafe<DriWrapper> { | 41 class OZONE_EXPORT DrmDevice : public base::RefCountedThreadSafe<DrmDevice> { |
42 public: | 42 public: |
43 typedef base::Callback<void(unsigned int /* frame */, | 43 typedef base::Callback<void(unsigned int /* frame */, |
44 unsigned int /* seconds */, | 44 unsigned int /* seconds */, |
45 unsigned int /* useconds */)> PageFlipCallback; | 45 unsigned int /* useconds */)> PageFlipCallback; |
46 | 46 |
47 DriWrapper(const base::FilePath& device_path); | 47 DrmDevice(const base::FilePath& device_path); |
48 DriWrapper(const base::FilePath& device_path, base::File file); | 48 DrmDevice(const base::FilePath& device_path, base::File file); |
49 | 49 |
50 // Open device. | 50 // Open device. |
51 virtual bool Initialize(); | 51 virtual bool Initialize(); |
52 | 52 |
53 // |task_runner| will be used to asynchronously page flip. | 53 // |task_runner| will be used to asynchronously page flip. |
54 virtual void InitializeTaskRunner( | 54 virtual void InitializeTaskRunner( |
55 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); | 55 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); |
56 | 56 |
57 // Get the CRTC state. This is generally used to save state before using the | 57 // Get the CRTC state. This is generally used to save state before using the |
58 // CRTC. When the user finishes using the CRTC, the user should restore the | 58 // CRTC. When the user finishes using the CRTC, the user should restore the |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 // the returned object must be freed using FreePropertyBlob(). | 134 // the returned object must be freed using FreePropertyBlob(). |
135 virtual ScopedDrmPropertyBlobPtr GetPropertyBlob(drmModeConnector* connector, | 135 virtual ScopedDrmPropertyBlobPtr GetPropertyBlob(drmModeConnector* connector, |
136 const char* name); | 136 const char* name); |
137 | 137 |
138 // Set the cursor to be displayed in CRTC |crtc_id|. (width, height) is the | 138 // Set the cursor to be displayed in CRTC |crtc_id|. (width, height) is the |
139 // cursor size pointed by |handle|. | 139 // cursor size pointed by |handle|. |
140 virtual bool SetCursor(uint32_t crtc_id, | 140 virtual bool SetCursor(uint32_t crtc_id, |
141 uint32_t handle, | 141 uint32_t handle, |
142 const gfx::Size& size); | 142 const gfx::Size& size); |
143 | 143 |
144 | |
145 // Move the cursor on CRTC |crtc_id| to (x, y); | 144 // Move the cursor on CRTC |crtc_id| to (x, y); |
146 virtual bool MoveCursor(uint32_t crtc_id, const gfx::Point& point); | 145 virtual bool MoveCursor(uint32_t crtc_id, const gfx::Point& point); |
147 | 146 |
148 virtual bool CreateDumbBuffer(const SkImageInfo& info, | 147 virtual bool CreateDumbBuffer(const SkImageInfo& info, |
149 uint32_t* handle, | 148 uint32_t* handle, |
150 uint32_t* stride, | 149 uint32_t* stride, |
151 void** pixels); | 150 void** pixels); |
152 | 151 |
153 virtual void DestroyDumbBuffer(const SkImageInfo& info, | 152 virtual void DestroyDumbBuffer(const SkImageInfo& info, |
154 uint32_t handle, | 153 uint32_t handle, |
155 uint32_t stride, | 154 uint32_t stride, |
156 void* pixels); | 155 void* pixels); |
157 | 156 |
158 // Drm master related | 157 // Drm master related |
159 virtual bool SetMaster(); | 158 virtual bool SetMaster(); |
160 virtual bool DropMaster(); | 159 virtual bool DropMaster(); |
161 | 160 |
162 int get_fd() const { return file_.GetPlatformFile(); } | 161 int get_fd() const { return file_.GetPlatformFile(); } |
163 | 162 |
164 base::FilePath device_path() const { return device_path_; } | 163 base::FilePath device_path() const { return device_path_; } |
165 | 164 |
166 HardwareDisplayPlaneManager* plane_manager() { return plane_manager_.get(); } | 165 HardwareDisplayPlaneManager* plane_manager() { return plane_manager_.get(); } |
167 | 166 |
168 protected: | 167 protected: |
169 friend class base::RefCountedThreadSafe<DriWrapper>; | 168 friend class base::RefCountedThreadSafe<DrmDevice>; |
170 | 169 |
171 virtual ~DriWrapper(); | 170 virtual ~DrmDevice(); |
172 | 171 |
173 scoped_ptr<HardwareDisplayPlaneManager> plane_manager_; | 172 scoped_ptr<HardwareDisplayPlaneManager> plane_manager_; |
174 | 173 |
175 private: | 174 private: |
176 class IOWatcher; | 175 class IOWatcher; |
177 | 176 |
178 // Path to DRM device. | 177 // Path to DRM device. |
179 const base::FilePath device_path_; | 178 const base::FilePath device_path_; |
180 | 179 |
181 // DRM device. | 180 // DRM device. |
182 base::File file_; | 181 base::File file_; |
183 | 182 |
184 // Helper thread to perform IO listener operations. | 183 // Helper thread to perform IO listener operations. |
185 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 184 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
186 | 185 |
187 // Watcher for |fd_| listening for page flip events. | 186 // Watcher for |fd_| listening for page flip events. |
188 scoped_refptr<IOWatcher> watcher_; | 187 scoped_refptr<IOWatcher> watcher_; |
189 | 188 |
190 DISALLOW_COPY_AND_ASSIGN(DriWrapper); | 189 DISALLOW_COPY_AND_ASSIGN(DrmDevice); |
191 }; | 190 }; |
192 | 191 |
193 } // namespace ui | 192 } // namespace ui |
194 | 193 |
195 #endif // UI_OZONE_PLATFORM_DRI_DRI_WRAPPER_H_ | 194 #endif // UI_OZONE_PLATFORM_DRI_DRM_DEVICE_H_ |
OLD | NEW |