Chromium Code Reviews| 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 |
| 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 "base/message_loop/message_loop.h" | |
| 15 #include "base/synchronization/waitable_event.h" | |
| 16 #include "base/threading/thread.h" | |
| 14 #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h" | 17 #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h" |
| 15 #include "ui/events/ozone/device/device_manager.h" | 18 #include "ui/events/ozone/device/device_manager.h" |
| 16 #include "ui/events/ozone/evdev/event_factory_evdev.h" | 19 #include "ui/events/ozone/evdev/event_factory_evdev.h" |
| 17 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" | 20 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" |
| 18 #include "ui/ozone/platform/drm/common/drm_util.h" | 21 #include "ui/ozone/platform/drm/common/drm_util.h" |
| 19 #include "ui/ozone/platform/drm/gpu/drm_device_generator.h" | 22 #include "ui/ozone/platform/drm/gpu/drm_device_generator.h" |
| 20 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h" | 23 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h" |
| 21 #include "ui/ozone/platform/drm/gpu/drm_gpu_display_manager.h" | 24 #include "ui/ozone/platform/drm/gpu/drm_gpu_display_manager.h" |
| 22 #include "ui/ozone/platform/drm/gpu/drm_gpu_platform_support.h" | 25 #include "ui/ozone/platform/drm/gpu/drm_gpu_platform_support.h" |
| 23 #include "ui/ozone/platform/drm/gpu/gbm_buffer.h" | 26 #include "ui/ozone/platform/drm/gpu/gbm_buffer.h" |
| 24 #include "ui/ozone/platform/drm/gpu/gbm_device.h" | 27 #include "ui/ozone/platform/drm/gpu/gbm_device.h" |
| 25 #include "ui/ozone/platform/drm/gpu/gbm_surface.h" | 28 #include "ui/ozone/platform/drm/gpu/gbm_surface.h" |
| 26 #include "ui/ozone/platform/drm/gpu/gbm_surface_factory.h" | 29 #include "ui/ozone/platform/drm/gpu/gbm_surface_factory.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" |
| 37 #include "ui/ozone/public/gpu_platform_support.h" | 40 #include "ui/ozone/public/gpu_platform_support.h" |
| 38 #include "ui/ozone/public/gpu_platform_support_host.h" | 41 #include "ui/ozone/public/gpu_platform_support_host.h" |
| 42 #include "ui/ozone/public/ozone_gpu_test_helper.h" | |
| 39 #include "ui/ozone/public/ozone_platform.h" | 43 #include "ui/ozone/public/ozone_platform.h" |
| 40 #include "ui/ozone/public/ozone_switches.h" | 44 #include "ui/ozone/public/ozone_switches.h" |
| 41 | 45 |
| 42 #if defined(USE_XKBCOMMON) | 46 #if defined(USE_XKBCOMMON) |
| 43 #include "ui/events/ozone/layout/xkb/xkb_evdev_codes.h" | 47 #include "ui/events/ozone/layout/xkb/xkb_evdev_codes.h" |
| 44 #include "ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h" | 48 #include "ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h" |
| 45 #else | 49 #else |
| 46 #include "ui/events/ozone/layout/stub/stub_keyboard_layout_engine.h" | 50 #include "ui/events/ozone/layout/stub/stub_keyboard_layout_engine.h" |
| 47 #endif | 51 #endif |
| 48 | 52 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 | 105 |
| 102 return nullptr; | 106 return nullptr; |
| 103 } | 107 } |
| 104 | 108 |
| 105 private: | 109 private: |
| 106 bool use_atomic_; | 110 bool use_atomic_; |
| 107 | 111 |
| 108 DISALLOW_COPY_AND_ASSIGN(GbmDeviceGenerator); | 112 DISALLOW_COPY_AND_ASSIGN(GbmDeviceGenerator); |
| 109 }; | 113 }; |
| 110 | 114 |
| 115 void Noop(base::WaitableEvent* done) { | |
| 116 done->Signal(); | |
| 117 } | |
| 118 | |
| 111 class OzonePlatformGbm : public OzonePlatform { | 119 class OzonePlatformGbm : public OzonePlatform { |
| 112 public: | 120 public: |
| 113 OzonePlatformGbm(bool use_surfaceless) : use_surfaceless_(use_surfaceless) {} | 121 OzonePlatformGbm(bool use_surfaceless) : use_surfaceless_(use_surfaceless) {} |
| 114 ~OzonePlatformGbm() override {} | 122 ~OzonePlatformGbm() override {} |
| 115 | 123 |
| 116 // OzonePlatform: | 124 // OzonePlatform: |
| 117 ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override { | 125 ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override { |
| 118 return surface_factory_ozone_.get(); | 126 return surface_factory_ozone_.get(); |
| 119 } | 127 } |
| 120 OverlayManagerOzone* GetOverlayManager() override { | 128 OverlayManagerOzone* GetOverlayManager() override { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 183 surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_)); | 191 surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_)); |
| 184 surface_factory_ozone_->InitializeGpu(drm_device_manager_.get(), | 192 surface_factory_ozone_->InitializeGpu(drm_device_manager_.get(), |
| 185 screen_manager_.get()); | 193 screen_manager_.get()); |
| 186 scoped_ptr<DrmGpuDisplayManager> display_manager(new DrmGpuDisplayManager( | 194 scoped_ptr<DrmGpuDisplayManager> display_manager(new DrmGpuDisplayManager( |
| 187 screen_manager_.get(), drm_device_manager_.get())); | 195 screen_manager_.get(), drm_device_manager_.get())); |
| 188 gpu_platform_support_.reset(new DrmGpuPlatformSupport( | 196 gpu_platform_support_.reset(new DrmGpuPlatformSupport( |
| 189 drm_device_manager_.get(), screen_manager_.get(), | 197 drm_device_manager_.get(), screen_manager_.get(), |
| 190 buffer_generator_.get(), display_manager.Pass())); | 198 buffer_generator_.get(), display_manager.Pass())); |
| 191 } | 199 } |
| 192 | 200 |
| 201 // Must initialize everything synchronously. It's why this method creates | |
| 202 // |ui_thread_| and |gpu_ipc_thread_|, and then requests initialization, and | |
| 203 // then waits for all initialization done. | |
| 204 void InitializeTest() override { | |
| 205 message_loop_for_test_.reset(new base::MessageLoopForUI); | |
| 206 | |
| 207 ui_thread_.reset(new base::Thread("test_ui_thread")); | |
|
spang
2015/07/13 17:08:26
Creating a "UI thread" won't work because any call
| |
| 208 ui_thread_->Start(); | |
| 209 { | |
| 210 base::WaitableEvent done(false, false); | |
| 211 ui_thread_->task_runner()->PostTask( | |
| 212 FROM_HERE, base::Bind(&OzonePlatformGbm::InitializeUIForTest, | |
| 213 base::Unretained(this), &done)); | |
| 214 done.Wait(); | |
| 215 } | |
| 216 | |
| 217 InitializeGPU(); | |
| 218 | |
| 219 gpu_ipc_thread_.reset(new base::Thread("test_gpu_ipc_thread")); | |
| 220 gpu_ipc_thread_->Start(); | |
| 221 gpu_helper_.reset(new ui::OzoneGpuTestHelper); | |
| 222 gpu_helper_->Initialize(ui_thread_->task_runner(), | |
| 223 gpu_ipc_thread_->task_runner()); | |
| 224 { | |
| 225 base::WaitableEvent done(false, false); | |
| 226 gpu_ipc_thread_->task_runner()->PostTask(FROM_HERE, | |
| 227 base::Bind(&Noop, &done)); | |
| 228 done.Wait(); | |
| 229 } | |
| 230 } | |
| 231 | |
| 193 private: | 232 private: |
| 233 void InitializeUIForTest(base::WaitableEvent* done) { | |
| 234 InitializeUI(); | |
| 235 done->Signal(); | |
| 236 } | |
| 237 | |
| 194 // Objects in both processes. | 238 // Objects in both processes. |
| 195 bool use_surfaceless_; | 239 bool use_surfaceless_; |
| 196 | 240 |
| 197 // Objects in the GPU process. | 241 // Objects in the GPU process. |
| 198 scoped_ptr<GbmSurfaceFactory> surface_factory_ozone_; | 242 scoped_ptr<GbmSurfaceFactory> surface_factory_ozone_; |
| 199 scoped_ptr<GlApiLoader> gl_api_loader_; | 243 scoped_ptr<GlApiLoader> gl_api_loader_; |
| 200 scoped_ptr<DrmDeviceManager> drm_device_manager_; | 244 scoped_ptr<DrmDeviceManager> drm_device_manager_; |
| 201 scoped_ptr<GbmBufferGenerator> buffer_generator_; | 245 scoped_ptr<GbmBufferGenerator> buffer_generator_; |
| 202 scoped_ptr<ScreenManager> screen_manager_; | 246 scoped_ptr<ScreenManager> screen_manager_; |
| 203 scoped_ptr<DrmGpuPlatformSupport> gpu_platform_support_; | 247 scoped_ptr<DrmGpuPlatformSupport> gpu_platform_support_; |
| 204 | 248 |
| 205 // Objects in the Browser process. | 249 // Objects in the Browser process. |
| 206 scoped_ptr<DeviceManager> device_manager_; | 250 scoped_ptr<DeviceManager> device_manager_; |
| 207 scoped_ptr<BitmapCursorFactoryOzone> cursor_factory_ozone_; | 251 scoped_ptr<BitmapCursorFactoryOzone> cursor_factory_ozone_; |
| 208 scoped_ptr<DrmWindowHostManager> window_manager_; | 252 scoped_ptr<DrmWindowHostManager> window_manager_; |
| 209 scoped_ptr<DrmCursor> cursor_; | 253 scoped_ptr<DrmCursor> cursor_; |
| 210 scoped_ptr<EventFactoryEvdev> event_factory_ozone_; | 254 scoped_ptr<EventFactoryEvdev> event_factory_ozone_; |
| 211 scoped_ptr<DrmGpuPlatformSupportHost> gpu_platform_support_host_; | 255 scoped_ptr<DrmGpuPlatformSupportHost> gpu_platform_support_host_; |
| 212 scoped_ptr<DrmDisplayHostManager> display_manager_; | 256 scoped_ptr<DrmDisplayHostManager> display_manager_; |
| 213 scoped_ptr<DrmOverlayManager> overlay_manager_; | 257 scoped_ptr<DrmOverlayManager> overlay_manager_; |
| 214 | 258 |
| 259 // for test | |
| 260 scoped_ptr<base::MessageLoopForUI> message_loop_for_test_; | |
| 261 scoped_ptr<base::Thread> ui_thread_; | |
| 262 scoped_ptr<base::Thread> gpu_ipc_thread_; | |
| 263 scoped_ptr<ui::OzoneGpuTestHelper> gpu_helper_; | |
| 264 | |
| 215 #if defined(USE_XKBCOMMON) | 265 #if defined(USE_XKBCOMMON) |
| 216 XkbEvdevCodes xkb_evdev_code_converter_; | 266 XkbEvdevCodes xkb_evdev_code_converter_; |
| 217 #endif | 267 #endif |
| 218 | 268 |
| 219 DISALLOW_COPY_AND_ASSIGN(OzonePlatformGbm); | 269 DISALLOW_COPY_AND_ASSIGN(OzonePlatformGbm); |
| 220 }; | 270 }; |
| 221 | 271 |
| 222 } // namespace | 272 } // namespace |
| 223 | 273 |
| 224 OzonePlatform* CreateOzonePlatformGbm() { | 274 OzonePlatform* CreateOzonePlatformGbm() { |
| 225 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); | 275 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); |
| 226 #if defined(USE_MESA_PLATFORM_NULL) | 276 #if defined(USE_MESA_PLATFORM_NULL) |
| 227 // Only works with surfaceless. | 277 // Only works with surfaceless. |
| 228 cmd->AppendSwitch(switches::kOzoneUseSurfaceless); | 278 cmd->AppendSwitch(switches::kOzoneUseSurfaceless); |
| 229 #endif | 279 #endif |
| 230 return new OzonePlatformGbm(cmd->HasSwitch(switches::kOzoneUseSurfaceless)); | 280 return new OzonePlatformGbm(cmd->HasSwitch(switches::kOzoneUseSurfaceless)); |
| 231 } | 281 } |
| 232 | 282 |
| 233 } // namespace ui | 283 } // namespace ui |
| OLD | NEW |