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

Side by Side Diff: ui/ozone/platform/drm/gpu/drm_device_manager.h

Issue 1124063003: drm: GPU process manages VGEM fd. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: io code is moved to io thread Created 5 years, 7 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
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 #include <vector>
10 10
11 #include "base/files/file_path.h"
12 #include "base/files/scoped_file.h"
11 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
13 #include "base/synchronization/lock.h" 15 #include "base/synchronization/lock.h"
14 #include "base/threading/thread_checker.h" 16 #include "base/threading/thread_checker.h"
15 #include "ui/gfx/native_widget_types.h" 17 #include "ui/gfx/native_widget_types.h"
16 #include "ui/ozone/ozone_export.h" 18 #include "ui/ozone/ozone_export.h"
17 19
18 namespace base { 20 namespace base {
19 class FilePath;
20 struct FileDescriptor; 21 struct FileDescriptor;
21 class SingleThreadTaskRunner; 22 class SingleThreadTaskRunner;
22 } 23 }
23 24
24 namespace ui { 25 namespace ui {
25 26
26 class DrmDevice; 27 class DrmDevice;
27 class DrmDeviceGenerator; 28 class DrmDeviceGenerator;
28 29
29 typedef std::vector<scoped_refptr<DrmDevice>> DrmDeviceVector; 30 typedef std::vector<scoped_refptr<DrmDevice>> DrmDeviceVector;
30 31
31 // Tracks the mapping between widgets and the DRM devices used to allocate 32 // Tracks the mapping between widgets and the DRM devices used to allocate
32 // buffers for the window represented by the widget. 33 // buffers for the window represented by the widget.
33 // Note: All calls are protected by a lock since 34 // Note: All calls are protected by a lock since
34 // GetDrmDevice(gfx::AcceleratedWidget) may be called on the IO thread. 35 // GetDrmDevice(gfx::AcceleratedWidget) may be called on the IO thread.
35 class OZONE_EXPORT DrmDeviceManager { 36 class OZONE_EXPORT DrmDeviceManager {
36 public: 37 public:
37 DrmDeviceManager(scoped_ptr<DrmDeviceGenerator> drm_device_generator); 38 DrmDeviceManager(scoped_ptr<DrmDeviceGenerator> drm_device_generator);
38 ~DrmDeviceManager(); 39 ~DrmDeviceManager();
39 40
40 // The first device registered is assumed to be the primary device. 41 // The first device registered is assumed to be the primary device.
41 bool AddDrmDevice(const base::FilePath& path, const base::FileDescriptor& fd); 42 bool AddDrmDevice(const base::FilePath& path,
43 const base::FileDescriptor& fd,
44 bool is_vgem);
42 void RemoveDrmDevice(const base::FilePath& path); 45 void RemoveDrmDevice(const base::FilePath& path);
43 46
44 void InitializeIOTaskRunner( 47 void InitializeIOTaskRunner(
45 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); 48 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
46 49
47 // Updates the device associated with |widget|. 50 // Updates the device associated with |widget|.
48 void UpdateDrmDevice(gfx::AcceleratedWidget widget, 51 void UpdateDrmDevice(gfx::AcceleratedWidget widget,
49 const scoped_refptr<DrmDevice>& device); 52 const scoped_refptr<DrmDevice>& device);
50 53
51 // Removes the device associated with |widget|. 54 // Removes the device associated with |widget|.
52 void RemoveDrmDevice(gfx::AcceleratedWidget widget); 55 void RemoveDrmDevice(gfx::AcceleratedWidget widget);
53 56
54 // Returns the device associated with |widget|. If there is no association 57 // Returns the device associated with |widget|. If there is no association
55 // returns |primary_device_|. 58 // returns |primary_device_|.
56 scoped_refptr<DrmDevice> GetDrmDevice(gfx::AcceleratedWidget widget); 59 scoped_refptr<DrmDevice> GetDrmDevice(gfx::AcceleratedWidget widget);
57 60
58 const DrmDeviceVector& GetDrmDevices() const; 61 const DrmDeviceVector& GetDrmDevices() const;
59 62
63 int GetVgemDevice() const;
reveman 2015/05/12 13:47:01 Why not use DrmDevice::get_fd?
dshwang 2015/05/12 14:11:42 ditto to above answer.
64
60 private: 65 private:
61 // With the exception of GetDrmDevice() all functions must be called on GPU 66 // With the exception of GetDrmDevice() all functions must be called on GPU
62 // main. 67 // main.
63 base::ThreadChecker thread_checker_; 68 base::ThreadChecker thread_checker_;
64 69
65 scoped_ptr<DrmDeviceGenerator> drm_device_generator_; 70 scoped_ptr<DrmDeviceGenerator> drm_device_generator_;
66 71
67 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; 72 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
68 73
69 DrmDeviceVector devices_; 74 DrmDeviceVector devices_;
70 75
71 std::map<gfx::AcceleratedWidget, scoped_refptr<DrmDevice>> drm_device_map_; 76 std::map<gfx::AcceleratedWidget, scoped_refptr<DrmDevice>> drm_device_map_;
72 77
73 // This device represents the primary graphics device and is used when: 78 // This device represents the primary graphics device and is used when:
74 // 1) 'widget == kNullAcceleratedWidget' when the API requesting a buffer has 79 // 1) 'widget == kNullAcceleratedWidget' when the API requesting a buffer has
75 // no knowledge of the surface/display it belongs to (currently this happens 80 // no knowledge of the surface/display it belongs to (currently this happens
76 // for video buffers), or 81 // for video buffers), or
77 // 2) in order to allocate buffers for unmatched surfaces (surfaces without a 82 // 2) in order to allocate buffers for unmatched surfaces (surfaces without a
78 // display; ie: when in headless mode). 83 // display; ie: when in headless mode).
79 scoped_refptr<DrmDevice> primary_device_; 84 scoped_refptr<DrmDevice> primary_device_;
80 85
86 base::ScopedFD vgem_device_;
87 base::FilePath vgem_path_;
88
81 // This class is accessed from the main thread and the IO thread. This lock 89 // This class is accessed from the main thread and the IO thread. This lock
82 // protects access to the device map. 90 // protects access to the device map.
83 base::Lock lock_; 91 base::Lock lock_;
84 92
85 DISALLOW_COPY_AND_ASSIGN(DrmDeviceManager); 93 DISALLOW_COPY_AND_ASSIGN(DrmDeviceManager);
86 }; 94 };
87 95
88 } // namespace ui 96 } // namespace ui
89 97
90 #endif // UI_OZONE_PLATFORM_DRM_GPU_DRM_DEVICE_MANAGER_H_ 98 #endif // UI_OZONE_PLATFORM_DRM_GPU_DRM_DEVICE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698