OLD | NEW |
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/dri/ozone_platform_gbm.h" | 5 #include "ui/ozone/platform/dri/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/dri/display_manager.h" | 18 #include "ui/ozone/platform/dri/display_manager.h" |
19 #include "ui/ozone/platform/dri/dri_cursor.h" | 19 #include "ui/ozone/platform/dri/dri_cursor.h" |
20 #include "ui/ozone/platform/dri/dri_gpu_platform_support.h" | 20 #include "ui/ozone/platform/dri/dri_gpu_platform_support.h" |
21 #include "ui/ozone/platform/dri/dri_gpu_platform_support_host.h" | 21 #include "ui/ozone/platform/dri/dri_gpu_platform_support_host.h" |
22 #include "ui/ozone/platform/dri/dri_util.h" | 22 #include "ui/ozone/platform/dri/dri_util.h" |
23 #include "ui/ozone/platform/dri/dri_window.h" | 23 #include "ui/ozone/platform/dri/dri_window.h" |
24 #include "ui/ozone/platform/dri/dri_window_delegate_manager.h" | 24 #include "ui/ozone/platform/dri/dri_window_delegate_manager.h" |
25 #include "ui/ozone/platform/dri/dri_window_manager.h" | 25 #include "ui/ozone/platform/dri/dri_window_manager.h" |
26 #include "ui/ozone/platform/dri/drm_device_generator.h" | 26 #include "ui/ozone/platform/dri/drm_device_generator.h" |
27 #include "ui/ozone/platform/dri/drm_device_manager.h" | 27 #include "ui/ozone/platform/dri/drm_device_manager.h" |
28 #include "ui/ozone/platform/dri/gbm_buffer.h" | 28 #include "ui/ozone/platform/dri/gbm_buffer.h" |
| 29 #include "ui/ozone/platform/dri/gbm_device.h" |
29 #include "ui/ozone/platform/dri/gbm_surface.h" | 30 #include "ui/ozone/platform/dri/gbm_surface.h" |
30 #include "ui/ozone/platform/dri/gbm_surface_factory.h" | 31 #include "ui/ozone/platform/dri/gbm_surface_factory.h" |
31 #include "ui/ozone/platform/dri/gbm_wrapper.h" | |
32 #include "ui/ozone/platform/dri/native_display_delegate_dri.h" | 32 #include "ui/ozone/platform/dri/native_display_delegate_dri.h" |
33 #include "ui/ozone/platform/dri/native_display_delegate_proxy.h" | 33 #include "ui/ozone/platform/dri/native_display_delegate_proxy.h" |
34 #include "ui/ozone/platform/dri/scanout_buffer.h" | 34 #include "ui/ozone/platform/dri/scanout_buffer.h" |
35 #include "ui/ozone/platform/dri/screen_manager.h" | 35 #include "ui/ozone/platform/dri/screen_manager.h" |
36 #include "ui/ozone/public/cursor_factory_ozone.h" | 36 #include "ui/ozone/public/cursor_factory_ozone.h" |
37 #include "ui/ozone/public/gpu_platform_support.h" | 37 #include "ui/ozone/public/gpu_platform_support.h" |
38 #include "ui/ozone/public/gpu_platform_support_host.h" | 38 #include "ui/ozone/public/gpu_platform_support_host.h" |
39 #include "ui/ozone/public/ozone_platform.h" | 39 #include "ui/ozone/public/ozone_platform.h" |
40 #include "ui/ozone/public/ozone_switches.h" | 40 #include "ui/ozone/public/ozone_switches.h" |
41 | 41 |
(...skipping 27 matching lines...) Expand all Loading... |
69 | 69 |
70 DISALLOW_COPY_AND_ASSIGN(GlApiLoader); | 70 DISALLOW_COPY_AND_ASSIGN(GlApiLoader); |
71 }; | 71 }; |
72 | 72 |
73 class GbmBufferGenerator : public ScanoutBufferGenerator { | 73 class GbmBufferGenerator : public ScanoutBufferGenerator { |
74 public: | 74 public: |
75 GbmBufferGenerator() {} | 75 GbmBufferGenerator() {} |
76 ~GbmBufferGenerator() override {} | 76 ~GbmBufferGenerator() override {} |
77 | 77 |
78 // ScanoutBufferGenerator: | 78 // ScanoutBufferGenerator: |
79 scoped_refptr<ScanoutBuffer> Create(const scoped_refptr<DriWrapper>& drm, | 79 scoped_refptr<ScanoutBuffer> Create(const scoped_refptr<DrmDevice>& drm, |
80 const gfx::Size& size) override { | 80 const gfx::Size& size) override { |
81 scoped_refptr<GbmWrapper> gbm(static_cast<GbmWrapper*>(drm.get())); | 81 scoped_refptr<GbmDevice> gbm(static_cast<GbmDevice*>(drm.get())); |
82 return GbmBuffer::CreateBuffer(gbm, SurfaceFactoryOzone::RGBA_8888, size, | 82 return GbmBuffer::CreateBuffer(gbm, SurfaceFactoryOzone::RGBA_8888, size, |
83 true); | 83 true); |
84 } | 84 } |
85 | 85 |
86 protected: | 86 protected: |
87 DISALLOW_COPY_AND_ASSIGN(GbmBufferGenerator); | 87 DISALLOW_COPY_AND_ASSIGN(GbmBufferGenerator); |
88 }; | 88 }; |
89 | 89 |
90 class GbmDeviceGenerator : public DrmDeviceGenerator { | 90 class GbmDeviceGenerator : public DrmDeviceGenerator { |
91 public: | 91 public: |
92 GbmDeviceGenerator() {} | 92 GbmDeviceGenerator() {} |
93 ~GbmDeviceGenerator() override {} | 93 ~GbmDeviceGenerator() override {} |
94 | 94 |
95 // DrmDeviceGenerator: | 95 // DrmDeviceGenerator: |
96 scoped_refptr<DriWrapper> CreateDevice(const base::FilePath& path, | 96 scoped_refptr<DrmDevice> CreateDevice(const base::FilePath& path, |
97 base::File file) override { | 97 base::File file) override { |
98 scoped_refptr<DriWrapper> drm = new GbmWrapper(path, file.Pass()); | 98 scoped_refptr<DrmDevice> drm = new GbmDevice(path, file.Pass()); |
99 if (drm->Initialize()) | 99 if (drm->Initialize()) |
100 return drm; | 100 return drm; |
101 | 101 |
102 return nullptr; | 102 return nullptr; |
103 } | 103 } |
104 | 104 |
105 private: | 105 private: |
106 DISALLOW_COPY_AND_ASSIGN(GbmDeviceGenerator); | 106 DISALLOW_COPY_AND_ASSIGN(GbmDeviceGenerator); |
107 }; | 107 }; |
108 | 108 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 make_scoped_ptr(new StubKeyboardLayoutEngine())); | 168 make_scoped_ptr(new StubKeyboardLayoutEngine())); |
169 #endif | 169 #endif |
170 event_factory_ozone_.reset(new EventFactoryEvdev( | 170 event_factory_ozone_.reset(new EventFactoryEvdev( |
171 cursor_.get(), device_manager_.get(), | 171 cursor_.get(), device_manager_.get(), |
172 KeyboardLayoutEngineManager::GetKeyboardLayoutEngine())); | 172 KeyboardLayoutEngineManager::GetKeyboardLayoutEngine())); |
173 } | 173 } |
174 | 174 |
175 void InitializeGPU() override { | 175 void InitializeGPU() override { |
176 gl_api_loader_.reset(new GlApiLoader()); | 176 gl_api_loader_.reset(new GlApiLoader()); |
177 // Async page flips are supported only on surfaceless mode. | 177 // Async page flips are supported only on surfaceless mode. |
178 gbm_ = new GbmWrapper(GetPrimaryDisplayCardPath()); | 178 gbm_ = new GbmDevice(GetPrimaryDisplayCardPath()); |
179 if (!gbm_->Initialize()) | 179 if (!gbm_->Initialize()) |
180 LOG(FATAL) << "Failed to initialize primary DRM device"; | 180 LOG(FATAL) << "Failed to initialize primary DRM device"; |
181 | 181 |
182 drm_device_manager_.reset(new DrmDeviceManager(gbm_)); | 182 drm_device_manager_.reset(new DrmDeviceManager(gbm_)); |
183 buffer_generator_.reset(new GbmBufferGenerator()); | 183 buffer_generator_.reset(new GbmBufferGenerator()); |
184 screen_manager_.reset(new ScreenManager(buffer_generator_.get())); | 184 screen_manager_.reset(new ScreenManager(buffer_generator_.get())); |
185 // This makes sure that simple targets that do not handle display | 185 // This makes sure that simple targets that do not handle display |
186 // configuration can still use the primary display. | 186 // configuration can still use the primary display. |
187 ForceInitializationOfPrimaryDisplay(gbm_, screen_manager_.get()); | 187 ForceInitializationOfPrimaryDisplay(gbm_, screen_manager_.get()); |
188 | 188 |
189 window_delegate_manager_.reset(new DriWindowDelegateManager()); | 189 window_delegate_manager_.reset(new DriWindowDelegateManager()); |
190 if (!surface_factory_ozone_) | 190 if (!surface_factory_ozone_) |
191 surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_)); | 191 surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_)); |
192 | 192 |
193 surface_factory_ozone_->InitializeGpu(drm_device_manager_.get(), | 193 surface_factory_ozone_->InitializeGpu(drm_device_manager_.get(), |
194 window_delegate_manager_.get()); | 194 window_delegate_manager_.get()); |
195 scoped_ptr<NativeDisplayDelegateDri> ndd(new NativeDisplayDelegateDri( | 195 scoped_ptr<NativeDisplayDelegateDri> ndd(new NativeDisplayDelegateDri( |
196 screen_manager_.get(), gbm_, | 196 screen_manager_.get(), gbm_, |
197 scoped_ptr<DrmDeviceGenerator>(new GbmDeviceGenerator()))); | 197 scoped_ptr<DrmDeviceGenerator>(new GbmDeviceGenerator()))); |
198 gpu_platform_support_.reset(new DriGpuPlatformSupport( | 198 gpu_platform_support_.reset(new DriGpuPlatformSupport( |
199 drm_device_manager_.get(), window_delegate_manager_.get(), | 199 drm_device_manager_.get(), window_delegate_manager_.get(), |
200 screen_manager_.get(), ndd.Pass())); | 200 screen_manager_.get(), ndd.Pass())); |
201 } | 201 } |
202 | 202 |
203 private: | 203 private: |
204 bool use_surfaceless_; | 204 bool use_surfaceless_; |
205 base::FilePath primary_graphics_card_path_; | 205 base::FilePath primary_graphics_card_path_; |
206 scoped_ptr<GlApiLoader> gl_api_loader_; | 206 scoped_ptr<GlApiLoader> gl_api_loader_; |
207 scoped_refptr<GbmWrapper> gbm_; | 207 scoped_refptr<GbmDevice> gbm_; |
208 scoped_ptr<DrmDeviceManager> drm_device_manager_; | 208 scoped_ptr<DrmDeviceManager> drm_device_manager_; |
209 scoped_ptr<GbmBufferGenerator> buffer_generator_; | 209 scoped_ptr<GbmBufferGenerator> buffer_generator_; |
210 scoped_ptr<ScreenManager> screen_manager_; | 210 scoped_ptr<ScreenManager> screen_manager_; |
211 scoped_ptr<DeviceManager> device_manager_; | 211 scoped_ptr<DeviceManager> device_manager_; |
212 | 212 |
213 scoped_ptr<GbmSurfaceFactory> surface_factory_ozone_; | 213 scoped_ptr<GbmSurfaceFactory> surface_factory_ozone_; |
214 scoped_ptr<BitmapCursorFactoryOzone> cursor_factory_ozone_; | 214 scoped_ptr<BitmapCursorFactoryOzone> cursor_factory_ozone_; |
215 scoped_ptr<EventFactoryEvdev> event_factory_ozone_; | 215 scoped_ptr<EventFactoryEvdev> event_factory_ozone_; |
216 | 216 |
217 scoped_ptr<DriGpuPlatformSupport> gpu_platform_support_; | 217 scoped_ptr<DriGpuPlatformSupport> gpu_platform_support_; |
(...skipping 17 matching lines...) Expand all Loading... |
235 OzonePlatform* CreateOzonePlatformGbm() { | 235 OzonePlatform* CreateOzonePlatformGbm() { |
236 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); | 236 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); |
237 #if defined(USE_MESA_PLATFORM_NULL) | 237 #if defined(USE_MESA_PLATFORM_NULL) |
238 // Only works with surfaceless. | 238 // Only works with surfaceless. |
239 cmd->AppendSwitch(switches::kOzoneUseSurfaceless); | 239 cmd->AppendSwitch(switches::kOzoneUseSurfaceless); |
240 #endif | 240 #endif |
241 return new OzonePlatformGbm(cmd->HasSwitch(switches::kOzoneUseSurfaceless)); | 241 return new OzonePlatformGbm(cmd->HasSwitch(switches::kOzoneUseSurfaceless)); |
242 } | 242 } |
243 | 243 |
244 } // namespace ui | 244 } // namespace ui |
OLD | NEW |