OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_GPU_DRM_DEVICE_MANAGER_H_ | 5 #ifndef UI_OZONE_PLATFORM_DRM_GPU_DRM_DEVICE_MANAGER_H_ |
6 #define UI_OZONE_PLATFORM_DRM_GPU_DRM_DEVICE_MANAGER_H_ | 6 #define UI_OZONE_PLATFORM_DRM_GPU_DRM_DEVICE_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <vector> | |
9 | 10 |
10 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | |
11 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
12 #include "ui/gfx/native_widget_types.h" | 14 #include "ui/gfx/native_widget_types.h" |
13 #include "ui/ozone/ozone_export.h" | 15 #include "ui/ozone/ozone_export.h" |
14 | 16 |
17 namespace base { | |
18 class FilePath; | |
19 struct FileDescriptor; | |
20 class SingleThreadTaskRunner; | |
21 } | |
22 | |
15 namespace ui { | 23 namespace ui { |
16 | 24 |
17 class DrmDevice; | 25 class DrmDevice; |
26 class DrmDeviceGenerator; | |
18 | 27 |
19 // Tracks the mapping between widgets and the DRM devices used to allocate | 28 // Tracks the mapping between widgets and the DRM devices used to allocate |
20 // buffers for the window represented by the widget. | 29 // buffers for the window represented by the widget. |
21 class OZONE_EXPORT DrmDeviceManager { | 30 class OZONE_EXPORT DrmDeviceManager { |
22 public: | 31 public: |
23 DrmDeviceManager(const scoped_refptr<DrmDevice>& primary_device); | 32 DrmDeviceManager(scoped_ptr<DrmDeviceGenerator> drm_device_generator); |
24 ~DrmDeviceManager(); | 33 ~DrmDeviceManager(); |
25 | 34 |
35 bool AddDrmDevice(const base::FilePath& path, const base::FileDescriptor& fd); | |
36 void RemoveDrmDevice(const base::FilePath& path); | |
37 | |
38 void InitializeIOTaskRunner( | |
39 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); | |
40 | |
26 // Updates the device associated with |widget|. | 41 // Updates the device associated with |widget|. |
27 void UpdateDrmDevice(gfx::AcceleratedWidget widget, | 42 void UpdateDrmDevice(gfx::AcceleratedWidget widget, |
28 const scoped_refptr<DrmDevice>& device); | 43 const scoped_refptr<DrmDevice>& device); |
29 | 44 |
30 // Removes the device associated with |widget|. | 45 // Removes the device associated with |widget|. |
31 void RemoveDrmDevice(gfx::AcceleratedWidget widget); | 46 void RemoveDrmDevice(gfx::AcceleratedWidget widget); |
32 | 47 |
33 // Returns the device associated with |widget|. If there is no association | 48 // Returns the device associated with |widget|. If there is no association |
34 // returns |primary_device_|. | 49 // returns |primary_device_|. |
35 scoped_refptr<DrmDevice> GetDrmDevice(gfx::AcceleratedWidget widget); | 50 scoped_refptr<DrmDevice> GetDrmDevice(gfx::AcceleratedWidget widget); |
36 | 51 |
52 std::vector<scoped_refptr<DrmDevice>> GetDrmDevices(); | |
53 | |
37 private: | 54 private: |
55 scoped_ptr<DrmDeviceGenerator> drm_device_generator_; | |
56 | |
57 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | |
58 | |
59 std::vector<scoped_refptr<DrmDevice>> devices_; | |
alexst (slow to review)
2015/04/22 18:27:56
typedef DrmDeviceVector?
dnicoara
2015/04/22 18:41:30
It is only used in a handful of places and doesn't
| |
60 | |
38 std::map<gfx::AcceleratedWidget, scoped_refptr<DrmDevice>> drm_device_map_; | 61 std::map<gfx::AcceleratedWidget, scoped_refptr<DrmDevice>> drm_device_map_; |
39 | 62 |
40 // This device represents the primary graphics device and is used when: | 63 // This device represents the primary graphics device and is used when: |
41 // 1) 'widget == kNullAcceleratedWidget' when the API requesting a buffer has | 64 // 1) 'widget == kNullAcceleratedWidget' when the API requesting a buffer has |
42 // no knowledge of the surface/display it belongs to (currently this happens | 65 // no knowledge of the surface/display it belongs to (currently this happens |
43 // for video buffers), or | 66 // for video buffers), or |
44 // 2) in order to allocate buffers for unmatched surfaces (surfaces without a | 67 // 2) in order to allocate buffers for unmatched surfaces (surfaces without a |
45 // display; ie: when in headless mode). | 68 // display; ie: when in headless mode). |
46 scoped_refptr<DrmDevice> primary_device_; | 69 scoped_refptr<DrmDevice> primary_device_; |
47 | 70 |
48 // This class is accessed from the main thread and the IO thread. This lock | 71 // This class is accessed from the main thread and the IO thread. This lock |
49 // protects access to the device map. | 72 // protects access to the device map. |
50 base::Lock lock_; | 73 base::Lock lock_; |
51 | 74 |
52 DISALLOW_COPY_AND_ASSIGN(DrmDeviceManager); | 75 DISALLOW_COPY_AND_ASSIGN(DrmDeviceManager); |
53 }; | 76 }; |
54 | 77 |
55 } // namespace ui | 78 } // namespace ui |
56 | 79 |
57 #endif // UI_OZONE_PLATFORM_DRM_GPU_DRM_DEVICE_MANAGER_H_ | 80 #endif // UI_OZONE_PLATFORM_DRM_GPU_DRM_DEVICE_MANAGER_H_ |
OLD | NEW |