| 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 <memory> |
| 9 #include <vector> | 10 #include <vector> |
| 10 | 11 |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | |
| 14 #include "ui/gfx/native_widget_types.h" | 14 #include "ui/gfx/native_widget_types.h" |
| 15 | 15 |
| 16 namespace base { | 16 namespace base { |
| 17 class FilePath; | 17 class FilePath; |
| 18 struct FileDescriptor; | 18 struct FileDescriptor; |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace ui { | 21 namespace ui { |
| 22 | 22 |
| 23 class DrmDevice; | 23 class DrmDevice; |
| 24 class DrmDeviceGenerator; | 24 class DrmDeviceGenerator; |
| 25 | 25 |
| 26 typedef std::vector<scoped_refptr<DrmDevice>> DrmDeviceVector; | 26 typedef std::vector<scoped_refptr<DrmDevice>> DrmDeviceVector; |
| 27 | 27 |
| 28 // 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 |
| 29 // buffers for the window represented by the widget. | 29 // buffers for the window represented by the widget. |
| 30 class DrmDeviceManager { | 30 class DrmDeviceManager { |
| 31 public: | 31 public: |
| 32 DrmDeviceManager(scoped_ptr<DrmDeviceGenerator> drm_device_generator); | 32 DrmDeviceManager(std::unique_ptr<DrmDeviceGenerator> drm_device_generator); |
| 33 ~DrmDeviceManager(); | 33 ~DrmDeviceManager(); |
| 34 | 34 |
| 35 // The first device registered is assumed to be the primary device. | 35 // The first device registered is assumed to be the primary device. |
| 36 bool AddDrmDevice(const base::FilePath& path, const base::FileDescriptor& fd); | 36 bool AddDrmDevice(const base::FilePath& path, const base::FileDescriptor& fd); |
| 37 void RemoveDrmDevice(const base::FilePath& path); | 37 void RemoveDrmDevice(const base::FilePath& path); |
| 38 | 38 |
| 39 // Updates the device associated with |widget|. | 39 // Updates the device associated with |widget|. |
| 40 void UpdateDrmDevice(gfx::AcceleratedWidget widget, | 40 void UpdateDrmDevice(gfx::AcceleratedWidget widget, |
| 41 const scoped_refptr<DrmDevice>& device); | 41 const scoped_refptr<DrmDevice>& device); |
| 42 | 42 |
| 43 // Removes the device associated with |widget|. | 43 // Removes the device associated with |widget|. |
| 44 void RemoveDrmDevice(gfx::AcceleratedWidget widget); | 44 void RemoveDrmDevice(gfx::AcceleratedWidget widget); |
| 45 | 45 |
| 46 // Returns the device associated with |widget|. If there is no association | 46 // Returns the device associated with |widget|. If there is no association |
| 47 // returns |primary_device_|. | 47 // returns |primary_device_|. |
| 48 scoped_refptr<DrmDevice> GetDrmDevice(gfx::AcceleratedWidget widget); | 48 scoped_refptr<DrmDevice> GetDrmDevice(gfx::AcceleratedWidget widget); |
| 49 | 49 |
| 50 // Returns |primary_device_|. | 50 // Returns |primary_device_|. |
| 51 scoped_refptr<DrmDevice> GetPrimaryDrmDevice(); | 51 scoped_refptr<DrmDevice> GetPrimaryDrmDevice(); |
| 52 | 52 |
| 53 const DrmDeviceVector& GetDrmDevices() const; | 53 const DrmDeviceVector& GetDrmDevices() const; |
| 54 | 54 |
| 55 private: | 55 private: |
| 56 scoped_ptr<DrmDeviceGenerator> drm_device_generator_; | 56 std::unique_ptr<DrmDeviceGenerator> drm_device_generator_; |
| 57 | 57 |
| 58 DrmDeviceVector devices_; | 58 DrmDeviceVector devices_; |
| 59 | 59 |
| 60 std::map<gfx::AcceleratedWidget, scoped_refptr<DrmDevice>> drm_device_map_; | 60 std::map<gfx::AcceleratedWidget, scoped_refptr<DrmDevice>> drm_device_map_; |
| 61 | 61 |
| 62 // This device represents the primary graphics device and is used when: | 62 // This device represents the primary graphics device and is used when: |
| 63 // 1) 'widget == kNullAcceleratedWidget' when the API requesting a buffer has | 63 // 1) 'widget == kNullAcceleratedWidget' when the API requesting a buffer has |
| 64 // no knowledge of the surface/display it belongs to (currently this happens | 64 // no knowledge of the surface/display it belongs to (currently this happens |
| 65 // for video buffers), or | 65 // for video buffers), or |
| 66 // 2) in order to allocate buffers for unmatched surfaces (surfaces without a | 66 // 2) in order to allocate buffers for unmatched surfaces (surfaces without a |
| 67 // display; ie: when in headless mode). | 67 // display; ie: when in headless mode). |
| 68 scoped_refptr<DrmDevice> primary_device_; | 68 scoped_refptr<DrmDevice> primary_device_; |
| 69 | 69 |
| 70 DISALLOW_COPY_AND_ASSIGN(DrmDeviceManager); | 70 DISALLOW_COPY_AND_ASSIGN(DrmDeviceManager); |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 } // namespace ui | 73 } // namespace ui |
| 74 | 74 |
| 75 #endif // UI_OZONE_PLATFORM_DRM_GPU_DRM_DEVICE_MANAGER_H_ | 75 #endif // UI_OZONE_PLATFORM_DRM_GPU_DRM_DEVICE_MANAGER_H_ |
| OLD | NEW |