| 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/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 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 scoped_ptr<DrmWindowHost> platform_window( | 136 scoped_ptr<DrmWindowHost> platform_window( |
| 137 new DrmWindowHost(delegate, bounds, gpu_platform_support_host_.get(), | 137 new DrmWindowHost(delegate, bounds, gpu_platform_support_host_.get(), |
| 138 event_factory_ozone_.get(), cursor_.get(), | 138 event_factory_ozone_.get(), cursor_.get(), |
| 139 window_manager_.get(), display_manager_.get())); | 139 window_manager_.get(), display_manager_.get())); |
| 140 platform_window->Initialize(); | 140 platform_window->Initialize(); |
| 141 return platform_window.Pass(); | 141 return platform_window.Pass(); |
| 142 } | 142 } |
| 143 scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() override { | 143 scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() override { |
| 144 return make_scoped_ptr(new DrmNativeDisplayDelegate( | 144 return make_scoped_ptr(new DrmNativeDisplayDelegate( |
| 145 gpu_platform_support_host_.get(), device_manager_.get(), | 145 gpu_platform_support_host_.get(), device_manager_.get(), |
| 146 display_manager_.get(), primary_graphics_card_path_)); | 146 display_manager_.get(), GetPrimaryDisplayCardPath())); |
| 147 } | 147 } |
| 148 void InitializeUI() override { | 148 void InitializeUI() override { |
| 149 primary_graphics_card_path_ = GetPrimaryDisplayCardPath(); | |
| 150 display_manager_.reset(new DisplayManager()); | 149 display_manager_.reset(new DisplayManager()); |
| 151 // Needed since the browser process creates the accelerated widgets and that | 150 // Needed since the browser process creates the accelerated widgets and that |
| 152 // happens through SFO. | 151 // happens through SFO. |
| 153 if (!surface_factory_ozone_) | 152 if (!surface_factory_ozone_) |
| 154 surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_)); | 153 surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_)); |
| 155 device_manager_ = CreateDeviceManager(); | 154 device_manager_ = CreateDeviceManager(); |
| 156 window_manager_.reset(new DrmWindowHostManager()); | 155 window_manager_.reset(new DrmWindowHostManager()); |
| 157 cursor_.reset(new DrmCursor(window_manager_.get())); | 156 cursor_.reset(new DrmCursor(window_manager_.get())); |
| 158 gpu_platform_support_host_.reset( | 157 gpu_platform_support_host_.reset( |
| 159 new DrmGpuPlatformSupportHost(cursor_.get())); | 158 new DrmGpuPlatformSupportHost(cursor_.get())); |
| 160 cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone); | 159 cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone); |
| 161 #if defined(USE_XKBCOMMON) | 160 #if defined(USE_XKBCOMMON) |
| 162 KeyboardLayoutEngineManager::SetKeyboardLayoutEngine(make_scoped_ptr( | 161 KeyboardLayoutEngineManager::SetKeyboardLayoutEngine(make_scoped_ptr( |
| 163 new XkbKeyboardLayoutEngine(xkb_evdev_code_converter_))); | 162 new XkbKeyboardLayoutEngine(xkb_evdev_code_converter_))); |
| 164 #else | 163 #else |
| 165 KeyboardLayoutEngineManager::SetKeyboardLayoutEngine( | 164 KeyboardLayoutEngineManager::SetKeyboardLayoutEngine( |
| 166 make_scoped_ptr(new StubKeyboardLayoutEngine())); | 165 make_scoped_ptr(new StubKeyboardLayoutEngine())); |
| 167 #endif | 166 #endif |
| 168 event_factory_ozone_.reset(new EventFactoryEvdev( | 167 event_factory_ozone_.reset(new EventFactoryEvdev( |
| 169 cursor_.get(), device_manager_.get(), | 168 cursor_.get(), device_manager_.get(), |
| 170 KeyboardLayoutEngineManager::GetKeyboardLayoutEngine())); | 169 KeyboardLayoutEngineManager::GetKeyboardLayoutEngine())); |
| 171 } | 170 } |
| 172 | 171 |
| 173 void InitializeGPU() override { | 172 void InitializeGPU() override { |
| 174 #if defined(OS_CHROMEOS) | 173 #if defined(OS_CHROMEOS) |
| 175 gpu_lock_.reset(new GpuLock()); | 174 gpu_lock_.reset(new GpuLock()); |
| 176 #endif | 175 #endif |
| 177 gl_api_loader_.reset(new GlApiLoader()); | 176 gl_api_loader_.reset(new GlApiLoader()); |
| 178 // Async page flips are supported only on surfaceless mode. | 177 drm_device_manager_.reset(new DrmDeviceManager( |
| 179 gbm_ = new GbmDevice(GetPrimaryDisplayCardPath()); | 178 scoped_ptr<DrmDeviceGenerator>(new GbmDeviceGenerator()))); |
| 180 if (!gbm_->Initialize()) | |
| 181 LOG(FATAL) << "Failed to initialize primary DRM device"; | |
| 182 | |
| 183 drm_device_manager_.reset(new DrmDeviceManager(gbm_)); | |
| 184 buffer_generator_.reset(new GbmBufferGenerator()); | 179 buffer_generator_.reset(new GbmBufferGenerator()); |
| 185 screen_manager_.reset(new ScreenManager(buffer_generator_.get())); | 180 screen_manager_.reset(new ScreenManager(buffer_generator_.get())); |
| 186 // This makes sure that simple targets that do not handle display | |
| 187 // configuration can still use the primary display. | |
| 188 ForceInitializationOfPrimaryDisplay(gbm_, screen_manager_.get()); | |
| 189 | |
| 190 if (!surface_factory_ozone_) | 181 if (!surface_factory_ozone_) |
| 191 surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_)); | 182 surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_)); |
| 192 | 183 |
| 193 surface_factory_ozone_->InitializeGpu(drm_device_manager_.get(), | 184 surface_factory_ozone_->InitializeGpu(drm_device_manager_.get(), |
| 194 screen_manager_.get()); | 185 screen_manager_.get()); |
| 195 scoped_ptr<DrmGpuDisplayManager> ndd(new DrmGpuDisplayManager( | 186 scoped_ptr<DrmGpuDisplayManager> ndd(new DrmGpuDisplayManager( |
| 196 screen_manager_.get(), gbm_, | 187 screen_manager_.get(), drm_device_manager_.get())); |
| 197 scoped_ptr<DrmDeviceGenerator>(new GbmDeviceGenerator()))); | |
| 198 gpu_platform_support_.reset(new DrmGpuPlatformSupport( | 188 gpu_platform_support_.reset(new DrmGpuPlatformSupport( |
| 199 drm_device_manager_.get(), screen_manager_.get(), ndd.Pass())); | 189 drm_device_manager_.get(), screen_manager_.get(), ndd.Pass())); |
| 200 } | 190 } |
| 201 | 191 |
| 202 private: | 192 private: |
| 203 // Objects in both processes. | 193 // Objects in both processes. |
| 204 bool use_surfaceless_; | 194 bool use_surfaceless_; |
| 205 scoped_ptr<GbmSurfaceFactory> surface_factory_ozone_; | 195 scoped_ptr<GbmSurfaceFactory> surface_factory_ozone_; |
| 206 | 196 |
| 207 // Objects in the GPU process. | 197 // Objects in the GPU process. |
| 208 scoped_ptr<GpuLock> gpu_lock_; | 198 scoped_ptr<GpuLock> gpu_lock_; |
| 209 scoped_ptr<GlApiLoader> gl_api_loader_; | 199 scoped_ptr<GlApiLoader> gl_api_loader_; |
| 210 scoped_refptr<GbmDevice> gbm_; | |
| 211 scoped_ptr<DrmDeviceManager> drm_device_manager_; | 200 scoped_ptr<DrmDeviceManager> drm_device_manager_; |
| 212 scoped_ptr<GbmBufferGenerator> buffer_generator_; | 201 scoped_ptr<GbmBufferGenerator> buffer_generator_; |
| 213 scoped_ptr<ScreenManager> screen_manager_; | 202 scoped_ptr<ScreenManager> screen_manager_; |
| 214 scoped_ptr<DrmGpuPlatformSupport> gpu_platform_support_; | 203 scoped_ptr<DrmGpuPlatformSupport> gpu_platform_support_; |
| 215 | 204 |
| 216 // Objects in the Browser process. | 205 // Objects in the Browser process. |
| 217 base::FilePath primary_graphics_card_path_; | |
| 218 scoped_ptr<DeviceManager> device_manager_; | 206 scoped_ptr<DeviceManager> device_manager_; |
| 219 scoped_ptr<BitmapCursorFactoryOzone> cursor_factory_ozone_; | 207 scoped_ptr<BitmapCursorFactoryOzone> cursor_factory_ozone_; |
| 220 scoped_ptr<DrmWindowHostManager> window_manager_; | 208 scoped_ptr<DrmWindowHostManager> window_manager_; |
| 221 scoped_ptr<DrmCursor> cursor_; | 209 scoped_ptr<DrmCursor> cursor_; |
| 222 scoped_ptr<EventFactoryEvdev> event_factory_ozone_; | 210 scoped_ptr<EventFactoryEvdev> event_factory_ozone_; |
| 223 scoped_ptr<DrmGpuPlatformSupportHost> gpu_platform_support_host_; | 211 scoped_ptr<DrmGpuPlatformSupportHost> gpu_platform_support_host_; |
| 224 scoped_ptr<DisplayManager> display_manager_; | 212 scoped_ptr<DisplayManager> display_manager_; |
| 225 | 213 |
| 226 #if defined(USE_XKBCOMMON) | 214 #if defined(USE_XKBCOMMON) |
| 227 XkbEvdevCodes xkb_evdev_code_converter_; | 215 XkbEvdevCodes xkb_evdev_code_converter_; |
| 228 #endif | 216 #endif |
| 229 | 217 |
| 230 DISALLOW_COPY_AND_ASSIGN(OzonePlatformGbm); | 218 DISALLOW_COPY_AND_ASSIGN(OzonePlatformGbm); |
| 231 }; | 219 }; |
| 232 | 220 |
| 233 } // namespace | 221 } // namespace |
| 234 | 222 |
| 235 OzonePlatform* CreateOzonePlatformGbm() { | 223 OzonePlatform* CreateOzonePlatformGbm() { |
| 236 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); | 224 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); |
| 237 #if defined(USE_MESA_PLATFORM_NULL) | 225 #if defined(USE_MESA_PLATFORM_NULL) |
| 238 // Only works with surfaceless. | 226 // Only works with surfaceless. |
| 239 cmd->AppendSwitch(switches::kOzoneUseSurfaceless); | 227 cmd->AppendSwitch(switches::kOzoneUseSurfaceless); |
| 240 #endif | 228 #endif |
| 241 return new OzonePlatformGbm(cmd->HasSwitch(switches::kOzoneUseSurfaceless)); | 229 return new OzonePlatformGbm(cmd->HasSwitch(switches::kOzoneUseSurfaceless)); |
| 242 } | 230 } |
| 243 | 231 |
| 244 } // namespace ui | 232 } // namespace ui |
| OLD | NEW |