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

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: update & fix clang 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
« no previous file with comments | « ui/ozone/platform/drm/gpu/screen_manager_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_message_proxy.h"
22 #include "ui/ozone/platform/drm/gpu/gbm_device.h" 22 #include "ui/ozone/platform/drm/gpu/drm_thread_proxy.h"
23 #include "ui/ozone/platform/drm/gpu/gbm_surface_factory.h" 23 #include "ui/ozone/platform/drm/gpu/gbm_surface_factory.h"
24 #include "ui/ozone/platform/drm/gpu/proxy_helpers.h"
24 #include "ui/ozone/platform/drm/gpu/scanout_buffer.h" 25 #include "ui/ozone/platform/drm/gpu/scanout_buffer.h"
25 #include "ui/ozone/platform/drm/gpu/screen_manager.h" 26 #include "ui/ozone/platform/drm/gpu/screen_manager.h"
26 #include "ui/ozone/platform/drm/host/drm_cursor.h" 27 #include "ui/ozone/platform/drm/host/drm_cursor.h"
27 #include "ui/ozone/platform/drm/host/drm_display_host_manager.h" 28 #include "ui/ozone/platform/drm/host/drm_display_host_manager.h"
28 #include "ui/ozone/platform/drm/host/drm_gpu_platform_support_host.h" 29 #include "ui/ozone/platform/drm/host/drm_gpu_platform_support_host.h"
29 #include "ui/ozone/platform/drm/host/drm_native_display_delegate.h" 30 #include "ui/ozone/platform/drm/host/drm_native_display_delegate.h"
30 #include "ui/ozone/platform/drm/host/drm_overlay_manager.h" 31 #include "ui/ozone/platform/drm/host/drm_overlay_manager.h"
31 #include "ui/ozone/platform/drm/host/drm_window_host.h" 32 #include "ui/ozone/platform/drm/host/drm_window_host.h"
32 #include "ui/ozone/platform/drm/host/drm_window_host_manager.h" 33 #include "ui/ozone/platform/drm/host/drm_window_host_manager.h"
33 #include "ui/ozone/public/cursor_factory_ozone.h" 34 #include "ui/ozone/public/cursor_factory_ozone.h"
(...skipping 30 matching lines...) Expand all
64 private: 65 private:
65 // HACK: gbm drivers have broken linkage. The Mesa DRI driver references 66 // HACK: gbm drivers have broken linkage. The Mesa DRI driver references
66 // symbols in the libglapi library however it does not explicitly link against 67 // 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 68 // it. That caused linkage errors when running an application that does not
68 // explicitly link against libglapi. 69 // explicitly link against libglapi.
69 void* glapi_lib_; 70 void* glapi_lib_;
70 71
71 DISALLOW_COPY_AND_ASSIGN(GlApiLoader); 72 DISALLOW_COPY_AND_ASSIGN(GlApiLoader);
72 }; 73 };
73 74
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,
100 bool is_primary_device) override {
101 scoped_refptr<DrmDevice> drm =
102 new GbmDevice(path, file.Pass(), is_primary_device);
103 if (drm->Initialize(use_atomic_))
104 return drm;
105
106 return nullptr;
107 }
108
109 private:
110 bool use_atomic_;
111
112 DISALLOW_COPY_AND_ASSIGN(GbmDeviceGenerator);
113 };
114
115 class OzonePlatformGbm : public OzonePlatform { 75 class OzonePlatformGbm : public OzonePlatform {
116 public: 76 public:
117 OzonePlatformGbm() {} 77 OzonePlatformGbm() {}
118 ~OzonePlatformGbm() override {} 78 ~OzonePlatformGbm() override {}
119 79
120 // OzonePlatform: 80 // OzonePlatform:
121 ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override { 81 ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override {
122 return surface_factory_ozone_.get(); 82 return surface_factory_.get();
123 } 83 }
124 OverlayManagerOzone* GetOverlayManager() override { 84 OverlayManagerOzone* GetOverlayManager() override {
125 return overlay_manager_.get(); 85 return overlay_manager_.get();
126 } 86 }
127 CursorFactoryOzone* GetCursorFactoryOzone() override { 87 CursorFactoryOzone* GetCursorFactoryOzone() override {
128 return cursor_factory_ozone_.get(); 88 return cursor_factory_ozone_.get();
129 } 89 }
130 InputController* GetInputController() override { 90 InputController* GetInputController() override {
131 return event_factory_ozone_->input_controller(); 91 return event_factory_ozone_->input_controller();
132 } 92 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 new DrmGpuPlatformSupportHost(cursor_.get())); 141 new DrmGpuPlatformSupportHost(cursor_.get()));
182 display_manager_.reset(new DrmDisplayHostManager( 142 display_manager_.reset(new DrmDisplayHostManager(
183 gpu_platform_support_host_.get(), device_manager_.get(), 143 gpu_platform_support_host_.get(), device_manager_.get(),
184 event_factory_ozone_->input_controller())); 144 event_factory_ozone_->input_controller()));
185 cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone); 145 cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone);
186 overlay_manager_.reset(new DrmOverlayManager( 146 overlay_manager_.reset(new DrmOverlayManager(
187 gpu_platform_support_host_.get(), window_manager_.get())); 147 gpu_platform_support_host_.get(), window_manager_.get()));
188 } 148 }
189 149
190 void InitializeGPU() override { 150 void InitializeGPU() override {
191 bool use_atomic = false;
192 #if defined(USE_DRM_ATOMIC)
193 use_atomic = true;
194 #endif
195 gl_api_loader_.reset(new GlApiLoader()); 151 gl_api_loader_.reset(new GlApiLoader());
196 drm_device_manager_.reset(new DrmDeviceManager( 152 // NOTE: Can't start the thread here since this is called before sandbox
197 scoped_ptr<DrmDeviceGenerator>(new GbmDeviceGenerator(use_atomic)))); 153 // initialization.
198 buffer_generator_.reset(new GbmBufferGenerator()); 154 drm_thread_.reset(new DrmThreadProxy());
199 screen_manager_.reset(new ScreenManager(buffer_generator_.get())); 155
200 surface_factory_ozone_.reset(new GbmSurfaceFactory()); 156 surface_factory_.reset(new GbmSurfaceFactory(drm_thread_.get()));
201 surface_factory_ozone_->InitializeGpu(drm_device_manager_.get(), 157 gpu_platform_support_.reset(
202 screen_manager_.get()); 158 new DrmGpuPlatformSupport(drm_thread_->CreateDrmThreadMessageProxy()));
203 scoped_ptr<DrmGpuDisplayManager> display_manager(new DrmGpuDisplayManager(
204 screen_manager_.get(), drm_device_manager_.get()));
205 gpu_platform_support_.reset(new DrmGpuPlatformSupport(
206 drm_device_manager_.get(), screen_manager_.get(),
207 buffer_generator_.get(), display_manager.Pass()));
208 } 159 }
209 160
210 private: 161 private:
211 // Objects in the GPU process. 162 // Objects in the GPU process.
212 scoped_ptr<GbmSurfaceFactory> surface_factory_ozone_; 163 scoped_ptr<DrmThreadProxy> drm_thread_;
213 scoped_ptr<GlApiLoader> gl_api_loader_; 164 scoped_ptr<GlApiLoader> gl_api_loader_;
214 scoped_ptr<DrmDeviceManager> drm_device_manager_; 165 scoped_ptr<GbmSurfaceFactory> surface_factory_;
215 scoped_ptr<GbmBufferGenerator> buffer_generator_;
216 scoped_ptr<ScreenManager> screen_manager_;
217 scoped_ptr<DrmGpuPlatformSupport> gpu_platform_support_; 166 scoped_ptr<DrmGpuPlatformSupport> gpu_platform_support_;
218 167
219 // Objects in the Browser process. 168 // Objects in the Browser process.
220 scoped_ptr<DeviceManager> device_manager_; 169 scoped_ptr<DeviceManager> device_manager_;
221 scoped_ptr<BitmapCursorFactoryOzone> cursor_factory_ozone_; 170 scoped_ptr<BitmapCursorFactoryOzone> cursor_factory_ozone_;
222 scoped_ptr<DrmWindowHostManager> window_manager_; 171 scoped_ptr<DrmWindowHostManager> window_manager_;
223 scoped_ptr<DrmCursor> cursor_; 172 scoped_ptr<DrmCursor> cursor_;
224 scoped_ptr<EventFactoryEvdev> event_factory_ozone_; 173 scoped_ptr<EventFactoryEvdev> event_factory_ozone_;
225 scoped_ptr<DrmGpuPlatformSupportHost> gpu_platform_support_host_; 174 scoped_ptr<DrmGpuPlatformSupportHost> gpu_platform_support_host_;
226 scoped_ptr<DrmDisplayHostManager> display_manager_; 175 scoped_ptr<DrmDisplayHostManager> display_manager_;
227 scoped_ptr<DrmOverlayManager> overlay_manager_; 176 scoped_ptr<DrmOverlayManager> overlay_manager_;
228 177
229 #if defined(USE_XKBCOMMON) 178 #if defined(USE_XKBCOMMON)
230 XkbEvdevCodes xkb_evdev_code_converter_; 179 XkbEvdevCodes xkb_evdev_code_converter_;
231 #endif 180 #endif
232 181
233 DISALLOW_COPY_AND_ASSIGN(OzonePlatformGbm); 182 DISALLOW_COPY_AND_ASSIGN(OzonePlatformGbm);
234 }; 183 };
235 184
236 } // namespace 185 } // namespace
237 186
238 OzonePlatform* CreateOzonePlatformGbm() { 187 OzonePlatform* CreateOzonePlatformGbm() {
239 return new OzonePlatformGbm; 188 return new OzonePlatformGbm;
240 } 189 }
241 190
242 } // namespace ui 191 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/drm/gpu/screen_manager_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698