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

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, 3 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/at_exit.h" 11 #include "base/at_exit.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h" 14 #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h"
15 #include "ui/events/ozone/device/device_manager.h" 15 #include "ui/events/ozone/device/device_manager.h"
16 #include "ui/events/ozone/evdev/event_factory_evdev.h" 16 #include "ui/events/ozone/evdev/event_factory_evdev.h"
17 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" 17 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h"
18 #include "ui/ozone/platform/drm/common/drm_util.h" 18 #include "ui/ozone/platform/drm/common/drm_util.h"
19 #include "ui/ozone/platform/drm/gpu/drm_device_generator.h" 19 #include "ui/ozone/platform/drm/gpu/drm_device_generator.h"
20 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h" 20 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h"
21 #include "ui/ozone/platform/drm/gpu/drm_gpu_display_manager.h" 21 #include "ui/ozone/platform/drm/gpu/drm_gpu_display_manager.h"
22 #include "ui/ozone/platform/drm/gpu/drm_gpu_platform_support.h" 22 #include "ui/ozone/platform/drm/gpu/drm_gpu_platform_support.h"
23 #include "ui/ozone/platform/drm/gpu/drm_gpu_platform_support_proxy.h"
24 #include "ui/ozone/platform/drm/gpu/drm_thread.h"
23 #include "ui/ozone/platform/drm/gpu/gbm_buffer.h" 25 #include "ui/ozone/platform/drm/gpu/gbm_buffer.h"
24 #include "ui/ozone/platform/drm/gpu/gbm_device.h" 26 #include "ui/ozone/platform/drm/gpu/gbm_device.h"
25 #include "ui/ozone/platform/drm/gpu/gbm_surface.h" 27 #include "ui/ozone/platform/drm/gpu/gbm_surface.h"
26 #include "ui/ozone/platform/drm/gpu/gbm_surface_factory.h" 28 #include "ui/ozone/platform/drm/gpu/gbm_surface_factory.h"
29 #include "ui/ozone/platform/drm/gpu/proxy_helpers.h"
27 #include "ui/ozone/platform/drm/gpu/scanout_buffer.h" 30 #include "ui/ozone/platform/drm/gpu/scanout_buffer.h"
28 #include "ui/ozone/platform/drm/gpu/screen_manager.h" 31 #include "ui/ozone/platform/drm/gpu/screen_manager.h"
29 #include "ui/ozone/platform/drm/host/drm_cursor.h" 32 #include "ui/ozone/platform/drm/host/drm_cursor.h"
30 #include "ui/ozone/platform/drm/host/drm_display_host_manager.h" 33 #include "ui/ozone/platform/drm/host/drm_display_host_manager.h"
31 #include "ui/ozone/platform/drm/host/drm_gpu_platform_support_host.h" 34 #include "ui/ozone/platform/drm/host/drm_gpu_platform_support_host.h"
32 #include "ui/ozone/platform/drm/host/drm_native_display_delegate.h" 35 #include "ui/ozone/platform/drm/host/drm_native_display_delegate.h"
33 #include "ui/ozone/platform/drm/host/drm_overlay_manager.h" 36 #include "ui/ozone/platform/drm/host/drm_overlay_manager.h"
34 #include "ui/ozone/platform/drm/host/drm_window_host.h" 37 #include "ui/ozone/platform/drm/host/drm_window_host.h"
35 #include "ui/ozone/platform/drm/host/drm_window_host_manager.h" 38 #include "ui/ozone/platform/drm/host/drm_window_host_manager.h"
36 #include "ui/ozone/public/cursor_factory_ozone.h" 39 #include "ui/ozone/public/cursor_factory_ozone.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 108
106 return nullptr; 109 return nullptr;
107 } 110 }
108 111
109 private: 112 private:
110 bool use_atomic_; 113 bool use_atomic_;
111 114
112 DISALLOW_COPY_AND_ASSIGN(GbmDeviceGenerator); 115 DISALLOW_COPY_AND_ASSIGN(GbmDeviceGenerator);
113 }; 116 };
114 117
118 class GbmThread : public DrmThread {
119 public:
120 GbmThread(bool use_surfaceless) : use_surfaceless_(use_surfaceless) {}
121 ~GbmThread() override {}
122
123 // DrmThread:
124 void Init() override {
125 bool use_atomic = false;
126 #if defined(USE_DRM_ATOMIC)
127 use_atomic = true;
128 #endif
129
130 device_manager_.reset(new DrmDeviceManager(
131 make_scoped_ptr(new GbmDeviceGenerator(use_atomic))));
132 buffer_generator_.reset(new GbmBufferGenerator());
133 screen_manager_.reset(new ScreenManager(buffer_generator_.get()));
134
135 scoped_ptr<DrmGpuDisplayManager> display_manager(
136 new DrmGpuDisplayManager(screen_manager_.get(), device_manager_.get()));
137 gpu_platform_support_.reset(new DrmGpuPlatformSupport(
138 device_manager_.get(), screen_manager_.get(), buffer_generator_.get(),
139 display_manager.Pass()));
140 }
141
142 private:
143 bool use_surfaceless_;
144
145 DISALLOW_COPY_AND_ASSIGN(GbmThread);
146 };
147
115 class OzonePlatformGbm : public OzonePlatform { 148 class OzonePlatformGbm : public OzonePlatform {
116 public: 149 public:
117 OzonePlatformGbm(bool use_surfaceless) : use_surfaceless_(use_surfaceless) {} 150 OzonePlatformGbm(bool use_surfaceless) : use_surfaceless_(use_surfaceless) {}
118 ~OzonePlatformGbm() override {} 151 ~OzonePlatformGbm() override {}
119 152
120 // OzonePlatform: 153 // OzonePlatform:
121 ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override { 154 ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override {
122 return surface_factory_ozone_.get(); 155 return surface_factory_.get();
123 } 156 }
124 OverlayManagerOzone* GetOverlayManager() override { 157 OverlayManagerOzone* GetOverlayManager() override {
125 return overlay_manager_.get(); 158 return overlay_manager_.get();
126 } 159 }
127 CursorFactoryOzone* GetCursorFactoryOzone() override { 160 CursorFactoryOzone* GetCursorFactoryOzone() override {
128 return cursor_factory_ozone_.get(); 161 return cursor_factory_ozone_.get();
129 } 162 }
130 InputController* GetInputController() override { 163 InputController* GetInputController() override {
131 return event_factory_ozone_->input_controller(); 164 return event_factory_ozone_->input_controller();
132 } 165 }
133 GpuPlatformSupport* GetGpuPlatformSupport() override { 166 GpuPlatformSupport* GetGpuPlatformSupport() override {
167 if (!gpu_platform_support_)
168 InitializeDrmThread();
169
134 return gpu_platform_support_.get(); 170 return gpu_platform_support_.get();
135 } 171 }
136 GpuPlatformSupportHost* GetGpuPlatformSupportHost() override { 172 GpuPlatformSupportHost* GetGpuPlatformSupportHost() override {
137 return gpu_platform_support_host_.get(); 173 return gpu_platform_support_host_.get();
138 } 174 }
139 scoped_ptr<SystemInputInjector> CreateSystemInputInjector() override { 175 scoped_ptr<SystemInputInjector> CreateSystemInputInjector() override {
140 return event_factory_ozone_->CreateSystemInputInjector(); 176 return event_factory_ozone_->CreateSystemInputInjector();
141 } 177 }
142 scoped_ptr<PlatformWindow> CreatePlatformWindow( 178 scoped_ptr<PlatformWindow> CreatePlatformWindow(
143 PlatformWindowDelegate* delegate, 179 PlatformWindowDelegate* delegate,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 new DrmGpuPlatformSupportHost(cursor_.get())); 216 new DrmGpuPlatformSupportHost(cursor_.get()));
181 display_manager_.reset(new DrmDisplayHostManager( 217 display_manager_.reset(new DrmDisplayHostManager(
182 gpu_platform_support_host_.get(), device_manager_.get(), 218 gpu_platform_support_host_.get(), device_manager_.get(),
183 event_factory_ozone_->input_controller())); 219 event_factory_ozone_->input_controller()));
184 cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone); 220 cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone);
185 overlay_manager_.reset(new DrmOverlayManager( 221 overlay_manager_.reset(new DrmOverlayManager(
186 use_surfaceless_, gpu_platform_support_host_.get())); 222 use_surfaceless_, gpu_platform_support_host_.get()));
187 } 223 }
188 224
189 void InitializeGPU() override { 225 void InitializeGPU() override {
190 bool use_atomic = false;
191 #if defined(USE_DRM_ATOMIC)
192 use_atomic = true;
193 #endif
194 gl_api_loader_.reset(new GlApiLoader()); 226 gl_api_loader_.reset(new GlApiLoader());
195 drm_device_manager_.reset(new DrmDeviceManager( 227 drm_thread_.reset(new GbmThread(use_surfaceless_));
196 scoped_ptr<DrmDeviceGenerator>(new GbmDeviceGenerator(use_atomic)))); 228
197 buffer_generator_.reset(new GbmBufferGenerator()); 229 surface_factory_.reset(
198 screen_manager_.reset(new ScreenManager(buffer_generator_.get())); 230 new GbmSurfaceFactory(use_surfaceless_, drm_thread_.get()));
199 surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_));
200 surface_factory_ozone_->InitializeGpu(drm_device_manager_.get(),
201 screen_manager_.get());
202 scoped_ptr<DrmGpuDisplayManager> display_manager(new DrmGpuDisplayManager(
203 screen_manager_.get(), drm_device_manager_.get()));
204 gpu_platform_support_.reset(new DrmGpuPlatformSupport(
205 drm_device_manager_.get(), screen_manager_.get(),
206 buffer_generator_.get(), display_manager.Pass()));
207 } 231 }
208 232
209 private: 233 private:
234 void InitializeDrmThread() {
235 drm_thread_->Start();
236 gpu_platform_support_ = drm_thread_->CreateGpuPlatformSupportProxy();
237 }
238
210 // Objects in both processes. 239 // Objects in both processes.
211 bool use_surfaceless_; 240 bool use_surfaceless_;
212 241
213 // Objects in the GPU process. 242 // Objects in the GPU process.
214 scoped_ptr<GbmSurfaceFactory> surface_factory_ozone_; 243 scoped_ptr<DrmThread> drm_thread_;
215 scoped_ptr<GlApiLoader> gl_api_loader_; 244 scoped_ptr<GlApiLoader> gl_api_loader_;
216 scoped_ptr<DrmDeviceManager> drm_device_manager_; 245 scoped_ptr<GbmSurfaceFactory> surface_factory_;
217 scoped_ptr<GbmBufferGenerator> buffer_generator_; 246 scoped_ptr<DrmGpuPlatformSupportProxy> gpu_platform_support_;
218 scoped_ptr<ScreenManager> screen_manager_;
219 scoped_ptr<DrmGpuPlatformSupport> gpu_platform_support_;
220 247
221 // Objects in the Browser process. 248 // Objects in the Browser process.
222 scoped_ptr<DeviceManager> device_manager_; 249 scoped_ptr<DeviceManager> device_manager_;
223 scoped_ptr<BitmapCursorFactoryOzone> cursor_factory_ozone_; 250 scoped_ptr<BitmapCursorFactoryOzone> cursor_factory_ozone_;
224 scoped_ptr<DrmWindowHostManager> window_manager_; 251 scoped_ptr<DrmWindowHostManager> window_manager_;
225 scoped_ptr<DrmCursor> cursor_; 252 scoped_ptr<DrmCursor> cursor_;
226 scoped_ptr<EventFactoryEvdev> event_factory_ozone_; 253 scoped_ptr<EventFactoryEvdev> event_factory_ozone_;
227 scoped_ptr<DrmGpuPlatformSupportHost> gpu_platform_support_host_; 254 scoped_ptr<DrmGpuPlatformSupportHost> gpu_platform_support_host_;
228 scoped_ptr<DrmDisplayHostManager> display_manager_; 255 scoped_ptr<DrmDisplayHostManager> display_manager_;
229 scoped_ptr<DrmOverlayManager> overlay_manager_; 256 scoped_ptr<DrmOverlayManager> overlay_manager_;
(...skipping 10 matching lines...) Expand all
240 OzonePlatform* CreateOzonePlatformGbm() { 267 OzonePlatform* CreateOzonePlatformGbm() {
241 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); 268 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess();
242 #if defined(USE_MESA_PLATFORM_NULL) 269 #if defined(USE_MESA_PLATFORM_NULL)
243 // Only works with surfaceless. 270 // Only works with surfaceless.
244 cmd->AppendSwitch(switches::kOzoneUseSurfaceless); 271 cmd->AppendSwitch(switches::kOzoneUseSurfaceless);
245 #endif 272 #endif
246 return new OzonePlatformGbm(cmd->HasSwitch(switches::kOzoneUseSurfaceless)); 273 return new OzonePlatformGbm(cmd->HasSwitch(switches::kOzoneUseSurfaceless));
247 } 274 }
248 275
249 } // namespace ui 276 } // namespace ui
OLDNEW
« ui/ozone/platform/drm/gpu/drm_window_proxy.cc ('K') | « ui/ozone/platform/drm/ozone_platform_drm.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698