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

Side by Side Diff: ui/ozone/platform/drm/ozone_platform_gbm.cc

Issue 1311043016: Switch DRM platform to using a separate thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mv-drm-calls-on-thread2
Patch Set: . Created 5 years, 2 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 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 #include "ui/ozone/platform/drm/ozone_platform_gbm.h" 5 #include "ui/ozone/platform/drm/ozone_platform_gbm.h"
6 6
7 #include <dlfcn.h> 7 #include <dlfcn.h>
8 #include <gbm.h> 8 #include <gbm.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h" 12 #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h"
13 #include "ui/events/ozone/device/device_manager.h" 13 #include "ui/events/ozone/device/device_manager.h"
14 #include "ui/events/ozone/evdev/event_factory_evdev.h" 14 #include "ui/events/ozone/evdev/event_factory_evdev.h"
15 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" 15 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h"
16 #include "ui/ozone/platform/drm/common/drm_util.h" 16 #include "ui/ozone/platform/drm/common/drm_util.h"
17 #include "ui/ozone/platform/drm/gpu/drm_device_generator.h" 17 #include "ui/ozone/platform/drm/gpu/drm_device_generator.h"
18 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h" 18 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h"
19 #include "ui/ozone/platform/drm/gpu/drm_gpu_display_manager.h" 19 #include "ui/ozone/platform/drm/gpu/drm_gpu_display_manager.h"
20 #include "ui/ozone/platform/drm/gpu/drm_gpu_platform_support.h" 20 #include "ui/ozone/platform/drm/gpu/drm_gpu_platform_support.h"
21 #include "ui/ozone/platform/drm/gpu/gbm_buffer.h" 21 #include "ui/ozone/platform/drm/gpu/drm_thread.h"
22 #include "ui/ozone/platform/drm/gpu/gbm_device.h"
23 #include "ui/ozone/platform/drm/gpu/gbm_surface_factory.h" 22 #include "ui/ozone/platform/drm/gpu/gbm_surface_factory.h"
23 #include "ui/ozone/platform/drm/gpu/proxy_helpers.h"
24 #include "ui/ozone/platform/drm/gpu/scanout_buffer.h" 24 #include "ui/ozone/platform/drm/gpu/scanout_buffer.h"
25 #include "ui/ozone/platform/drm/gpu/screen_manager.h" 25 #include "ui/ozone/platform/drm/gpu/screen_manager.h"
26 #include "ui/ozone/platform/drm/host/drm_cursor.h" 26 #include "ui/ozone/platform/drm/host/drm_cursor.h"
27 #include "ui/ozone/platform/drm/host/drm_display_host_manager.h" 27 #include "ui/ozone/platform/drm/host/drm_display_host_manager.h"
28 #include "ui/ozone/platform/drm/host/drm_gpu_platform_support_host.h" 28 #include "ui/ozone/platform/drm/host/drm_gpu_platform_support_host.h"
29 #include "ui/ozone/platform/drm/host/drm_native_display_delegate.h" 29 #include "ui/ozone/platform/drm/host/drm_native_display_delegate.h"
30 #include "ui/ozone/platform/drm/host/drm_overlay_manager.h" 30 #include "ui/ozone/platform/drm/host/drm_overlay_manager.h"
31 #include "ui/ozone/platform/drm/host/drm_window_host.h" 31 #include "ui/ozone/platform/drm/host/drm_window_host.h"
32 #include "ui/ozone/platform/drm/host/drm_window_host_manager.h" 32 #include "ui/ozone/platform/drm/host/drm_window_host_manager.h"
33 #include "ui/ozone/public/cursor_factory_ozone.h" 33 #include "ui/ozone/public/cursor_factory_ozone.h"
(...skipping 30 matching lines...) Expand all
64 private: 64 private:
65 // HACK: gbm drivers have broken linkage. The Mesa DRI driver references 65 // HACK: gbm drivers have broken linkage. The Mesa DRI driver references
66 // symbols in the libglapi library however it does not explicitly link against 66 // symbols in the libglapi library however it does not explicitly link against
67 // it. That caused linkage errors when running an application that does not 67 // it. That caused linkage errors when running an application that does not
68 // explicitly link against libglapi. 68 // explicitly link against libglapi.
69 void* glapi_lib_; 69 void* glapi_lib_;
70 70
71 DISALLOW_COPY_AND_ASSIGN(GlApiLoader); 71 DISALLOW_COPY_AND_ASSIGN(GlApiLoader);
72 }; 72 };
73 73
74 class GbmBufferGenerator : public ScanoutBufferGenerator {
75 public:
76 GbmBufferGenerator() {}
77 ~GbmBufferGenerator() override {}
78
79 // ScanoutBufferGenerator:
80 scoped_refptr<ScanoutBuffer> Create(const scoped_refptr<DrmDevice>& drm,
81 gfx::BufferFormat format,
82 const gfx::Size& size) override {
83 scoped_refptr<GbmDevice> gbm(static_cast<GbmDevice*>(drm.get()));
84 return GbmBuffer::CreateBuffer(gbm, format, size,
85 gfx::BufferUsage::SCANOUT);
86 }
87
88 protected:
89 DISALLOW_COPY_AND_ASSIGN(GbmBufferGenerator);
90 };
91
92 class GbmDeviceGenerator : public DrmDeviceGenerator {
93 public:
94 GbmDeviceGenerator(bool use_atomic) : use_atomic_(use_atomic) {}
95 ~GbmDeviceGenerator() override {}
96
97 // DrmDeviceGenerator:
98 scoped_refptr<DrmDevice> CreateDevice(const base::FilePath& path,
99 base::File file) override {
100 scoped_refptr<DrmDevice> drm = new GbmDevice(path, file.Pass());
101 if (drm->Initialize(use_atomic_))
102 return drm;
103
104 return nullptr;
105 }
106
107 private:
108 bool use_atomic_;
109
110 DISALLOW_COPY_AND_ASSIGN(GbmDeviceGenerator);
111 };
112
113 class OzonePlatformGbm : public OzonePlatform { 74 class OzonePlatformGbm : public OzonePlatform {
114 public: 75 public:
115 OzonePlatformGbm() {} 76 OzonePlatformGbm() {}
116 ~OzonePlatformGbm() override {} 77 ~OzonePlatformGbm() override {}
117 78
118 // OzonePlatform: 79 // OzonePlatform:
119 ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override { 80 ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override {
120 return surface_factory_ozone_.get(); 81 return surface_factory_.get();
121 } 82 }
122 OverlayManagerOzone* GetOverlayManager() override { 83 OverlayManagerOzone* GetOverlayManager() override {
123 return overlay_manager_.get(); 84 return overlay_manager_.get();
124 } 85 }
125 CursorFactoryOzone* GetCursorFactoryOzone() override { 86 CursorFactoryOzone* GetCursorFactoryOzone() override {
126 return cursor_factory_ozone_.get(); 87 return cursor_factory_ozone_.get();
127 } 88 }
128 InputController* GetInputController() override { 89 InputController* GetInputController() override {
129 return event_factory_ozone_->input_controller(); 90 return event_factory_ozone_->input_controller();
130 } 91 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 new DrmGpuPlatformSupportHost(cursor_.get())); 139 new DrmGpuPlatformSupportHost(cursor_.get()));
179 display_manager_.reset(new DrmDisplayHostManager( 140 display_manager_.reset(new DrmDisplayHostManager(
180 gpu_platform_support_host_.get(), device_manager_.get(), 141 gpu_platform_support_host_.get(), device_manager_.get(),
181 event_factory_ozone_->input_controller())); 142 event_factory_ozone_->input_controller()));
182 cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone); 143 cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone);
183 overlay_manager_.reset( 144 overlay_manager_.reset(
184 new DrmOverlayManager(gpu_platform_support_host_.get())); 145 new DrmOverlayManager(gpu_platform_support_host_.get()));
185 } 146 }
186 147
187 void InitializeGPU() override { 148 void InitializeGPU() override {
188 bool use_atomic = false;
189 #if defined(USE_DRM_ATOMIC)
190 use_atomic = true;
191 #endif
192 gl_api_loader_.reset(new GlApiLoader()); 149 gl_api_loader_.reset(new GlApiLoader());
193 drm_device_manager_.reset(new DrmDeviceManager( 150 // NOTE: Can't start the thread here since this is called before sandbox
194 scoped_ptr<DrmDeviceGenerator>(new GbmDeviceGenerator(use_atomic)))); 151 // initialization.
195 buffer_generator_.reset(new GbmBufferGenerator()); 152 drm_thread_.reset(new DrmThread());
196 screen_manager_.reset(new ScreenManager(buffer_generator_.get())); 153
197 surface_factory_ozone_.reset(new GbmSurfaceFactory()); 154 surface_factory_.reset(new GbmSurfaceFactory(drm_thread_.get()));
198 surface_factory_ozone_->InitializeGpu(drm_device_manager_.get(), 155 gpu_platform_support_.reset(new DrmGpuPlatformSupport(drm_thread_.get()));
199 screen_manager_.get());
200 scoped_ptr<DrmGpuDisplayManager> display_manager(new DrmGpuDisplayManager(
201 screen_manager_.get(), drm_device_manager_.get()));
202 gpu_platform_support_.reset(new DrmGpuPlatformSupport(
203 drm_device_manager_.get(), screen_manager_.get(),
204 buffer_generator_.get(), display_manager.Pass()));
205 } 156 }
206 157
207 private: 158 private:
208 // Objects in the GPU process. 159 // Objects in the GPU process.
209 scoped_ptr<GbmSurfaceFactory> surface_factory_ozone_; 160 scoped_ptr<DrmThread> drm_thread_;
210 scoped_ptr<GlApiLoader> gl_api_loader_; 161 scoped_ptr<GlApiLoader> gl_api_loader_;
211 scoped_ptr<DrmDeviceManager> drm_device_manager_; 162 scoped_ptr<GbmSurfaceFactory> surface_factory_;
212 scoped_ptr<GbmBufferGenerator> buffer_generator_;
213 scoped_ptr<ScreenManager> screen_manager_;
214 scoped_ptr<DrmGpuPlatformSupport> gpu_platform_support_; 163 scoped_ptr<DrmGpuPlatformSupport> gpu_platform_support_;
215 164
216 // Objects in the Browser process. 165 // Objects in the Browser process.
217 scoped_ptr<DeviceManager> device_manager_; 166 scoped_ptr<DeviceManager> device_manager_;
218 scoped_ptr<BitmapCursorFactoryOzone> cursor_factory_ozone_; 167 scoped_ptr<BitmapCursorFactoryOzone> cursor_factory_ozone_;
219 scoped_ptr<DrmWindowHostManager> window_manager_; 168 scoped_ptr<DrmWindowHostManager> window_manager_;
220 scoped_ptr<DrmCursor> cursor_; 169 scoped_ptr<DrmCursor> cursor_;
221 scoped_ptr<EventFactoryEvdev> event_factory_ozone_; 170 scoped_ptr<EventFactoryEvdev> event_factory_ozone_;
222 scoped_ptr<DrmGpuPlatformSupportHost> gpu_platform_support_host_; 171 scoped_ptr<DrmGpuPlatformSupportHost> gpu_platform_support_host_;
223 scoped_ptr<DrmDisplayHostManager> display_manager_; 172 scoped_ptr<DrmDisplayHostManager> display_manager_;
224 scoped_ptr<DrmOverlayManager> overlay_manager_; 173 scoped_ptr<DrmOverlayManager> overlay_manager_;
225 174
226 #if defined(USE_XKBCOMMON) 175 #if defined(USE_XKBCOMMON)
227 XkbEvdevCodes xkb_evdev_code_converter_; 176 XkbEvdevCodes xkb_evdev_code_converter_;
228 #endif 177 #endif
229 178
230 DISALLOW_COPY_AND_ASSIGN(OzonePlatformGbm); 179 DISALLOW_COPY_AND_ASSIGN(OzonePlatformGbm);
231 }; 180 };
232 181
233 } // namespace 182 } // namespace
234 183
235 OzonePlatform* CreateOzonePlatformGbm() { 184 OzonePlatform* CreateOzonePlatformGbm() {
236 return new OzonePlatformGbm; 185 return new OzonePlatformGbm;
237 } 186 }
238 187
239 } // namespace ui 188 } // namespace ui
OLDNEW
« ui/ozone/platform/drm/gpu/drm_thread.cc ('K') | « ui/ozone/platform/drm/gpu/screen_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698