| 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 <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <gbm.h> | 9 #include <gbm.h> |
| 10 #include <stdlib.h> | 10 #include <stdlib.h> |
| 11 #include <xf86drm.h> | 11 #include <xf86drm.h> |
| 12 | 12 |
| 13 #include <memory> | 13 #include <memory> |
| 14 #include <utility> | 14 #include <utility> |
| 15 | 15 |
| 16 #include "base/bind.h" | 16 #include "base/bind.h" |
| 17 #include "base/command_line.h" | 17 #include "base/command_line.h" |
| 18 #include "base/macros.h" | 18 #include "base/macros.h" |
| 19 #include "base/memory/ptr_util.h" |
| 19 #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h" | 20 #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h" |
| 20 #include "ui/events/ozone/device/device_manager.h" | 21 #include "ui/events/ozone/device/device_manager.h" |
| 21 #include "ui/events/ozone/evdev/event_factory_evdev.h" | 22 #include "ui/events/ozone/evdev/event_factory_evdev.h" |
| 22 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" | 23 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" |
| 23 #include "ui/ozone/platform/drm/common/drm_util.h" | 24 #include "ui/ozone/platform/drm/common/drm_util.h" |
| 24 #include "ui/ozone/platform/drm/gpu/drm_device_generator.h" | 25 #include "ui/ozone/platform/drm/gpu/drm_device_generator.h" |
| 25 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h" | 26 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h" |
| 26 #include "ui/ozone/platform/drm/gpu/drm_gpu_display_manager.h" | 27 #include "ui/ozone/platform/drm/gpu/drm_gpu_display_manager.h" |
| 27 #include "ui/ozone/platform/drm/gpu/drm_gpu_platform_support.h" | 28 #include "ui/ozone/platform/drm/gpu/drm_gpu_platform_support.h" |
| 28 #include "ui/ozone/platform/drm/gpu/drm_thread_message_proxy.h" | 29 #include "ui/ozone/platform/drm/gpu/drm_thread_message_proxy.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 } | 101 } |
| 101 InputController* GetInputController() override { | 102 InputController* GetInputController() override { |
| 102 return event_factory_ozone_->input_controller(); | 103 return event_factory_ozone_->input_controller(); |
| 103 } | 104 } |
| 104 GpuPlatformSupport* GetGpuPlatformSupport() override { | 105 GpuPlatformSupport* GetGpuPlatformSupport() override { |
| 105 return gpu_platform_support_.get(); | 106 return gpu_platform_support_.get(); |
| 106 } | 107 } |
| 107 GpuPlatformSupportHost* GetGpuPlatformSupportHost() override { | 108 GpuPlatformSupportHost* GetGpuPlatformSupportHost() override { |
| 108 return gpu_platform_support_host_.get(); | 109 return gpu_platform_support_host_.get(); |
| 109 } | 110 } |
| 110 scoped_ptr<SystemInputInjector> CreateSystemInputInjector() override { | 111 std::unique_ptr<SystemInputInjector> CreateSystemInputInjector() override { |
| 111 return event_factory_ozone_->CreateSystemInputInjector(); | 112 return event_factory_ozone_->CreateSystemInputInjector(); |
| 112 } | 113 } |
| 113 scoped_ptr<PlatformWindow> CreatePlatformWindow( | 114 std::unique_ptr<PlatformWindow> CreatePlatformWindow( |
| 114 PlatformWindowDelegate* delegate, | 115 PlatformWindowDelegate* delegate, |
| 115 const gfx::Rect& bounds) override { | 116 const gfx::Rect& bounds) override { |
| 116 GpuThreadAdapter* adapter = gpu_platform_support_host_.get(); | 117 GpuThreadAdapter* adapter = gpu_platform_support_host_.get(); |
| 117 if (RunningInsideMus()) { | 118 if (RunningInsideMus()) { |
| 118 DCHECK(drm_thread_) << "drm_thread_ should exist (and be running) here."; | 119 DCHECK(drm_thread_) << "drm_thread_ should exist (and be running) here."; |
| 119 adapter = mus_thread_proxy_.get(); | 120 adapter = mus_thread_proxy_.get(); |
| 120 } | 121 } |
| 121 | 122 |
| 122 scoped_ptr<DrmWindowHost> platform_window(new DrmWindowHost( | 123 std::unique_ptr<DrmWindowHost> platform_window(new DrmWindowHost( |
| 123 delegate, bounds, adapter, event_factory_ozone_.get(), cursor_.get(), | 124 delegate, bounds, adapter, event_factory_ozone_.get(), cursor_.get(), |
| 124 window_manager_.get(), display_manager_.get(), overlay_manager_.get())); | 125 window_manager_.get(), display_manager_.get(), overlay_manager_.get())); |
| 125 platform_window->Initialize(); | 126 platform_window->Initialize(); |
| 126 return std::move(platform_window); | 127 return std::move(platform_window); |
| 127 } | 128 } |
| 128 scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() override { | 129 std::unique_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() |
| 129 return make_scoped_ptr( | 130 override { |
| 131 return base::WrapUnique( |
| 130 new DrmNativeDisplayDelegate(display_manager_.get())); | 132 new DrmNativeDisplayDelegate(display_manager_.get())); |
| 131 } | 133 } |
| 132 void InitializeUI() override { | 134 void InitializeUI() override { |
| 133 device_manager_ = CreateDeviceManager(); | 135 device_manager_ = CreateDeviceManager(); |
| 134 window_manager_.reset(new DrmWindowHostManager()); | 136 window_manager_.reset(new DrmWindowHostManager()); |
| 135 cursor_.reset(new DrmCursor(window_manager_.get())); | 137 cursor_.reset(new DrmCursor(window_manager_.get())); |
| 136 #if defined(USE_XKBCOMMON) | 138 #if defined(USE_XKBCOMMON) |
| 137 KeyboardLayoutEngineManager::SetKeyboardLayoutEngine(make_scoped_ptr( | 139 KeyboardLayoutEngineManager::SetKeyboardLayoutEngine(base::WrapUnique( |
| 138 new XkbKeyboardLayoutEngine(xkb_evdev_code_converter_))); | 140 new XkbKeyboardLayoutEngine(xkb_evdev_code_converter_))); |
| 139 #else | 141 #else |
| 140 KeyboardLayoutEngineManager::SetKeyboardLayoutEngine( | 142 KeyboardLayoutEngineManager::SetKeyboardLayoutEngine( |
| 141 make_scoped_ptr(new StubKeyboardLayoutEngine())); | 143 base::WrapUnique(new StubKeyboardLayoutEngine())); |
| 142 #endif | 144 #endif |
| 143 event_factory_ozone_.reset(new EventFactoryEvdev( | 145 event_factory_ozone_.reset(new EventFactoryEvdev( |
| 144 cursor_.get(), device_manager_.get(), | 146 cursor_.get(), device_manager_.get(), |
| 145 KeyboardLayoutEngineManager::GetKeyboardLayoutEngine())); | 147 KeyboardLayoutEngineManager::GetKeyboardLayoutEngine())); |
| 146 | 148 |
| 147 GpuThreadAdapter* adapter; | 149 GpuThreadAdapter* adapter; |
| 148 if (RunningInsideMus()) { | 150 if (RunningInsideMus()) { |
| 149 gl_api_loader_.reset(new GlApiLoader()); | 151 gl_api_loader_.reset(new GlApiLoader()); |
| 150 mus_thread_proxy_.reset(new MusThreadProxy()); | 152 mus_thread_proxy_.reset(new MusThreadProxy()); |
| 151 adapter = mus_thread_proxy_.get(); | 153 adapter = mus_thread_proxy_.get(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 drm_thread_->BindThreadIntoMessagingProxy(itmp); | 190 drm_thread_->BindThreadIntoMessagingProxy(itmp); |
| 189 | 191 |
| 190 surface_factory_.reset(new GbmSurfaceFactory(drm_thread_.get())); | 192 surface_factory_.reset(new GbmSurfaceFactory(drm_thread_.get())); |
| 191 if (RunningInsideMus()) { | 193 if (RunningInsideMus()) { |
| 192 mus_thread_proxy_->StartDrmThread(); | 194 mus_thread_proxy_->StartDrmThread(); |
| 193 } | 195 } |
| 194 } | 196 } |
| 195 | 197 |
| 196 private: | 198 private: |
| 197 // Objects in the GPU process. | 199 // Objects in the GPU process. |
| 198 scoped_ptr<DrmThreadProxy> drm_thread_; | 200 std::unique_ptr<DrmThreadProxy> drm_thread_; |
| 199 scoped_ptr<GlApiLoader> gl_api_loader_; | 201 std::unique_ptr<GlApiLoader> gl_api_loader_; |
| 200 scoped_ptr<GbmSurfaceFactory> surface_factory_; | 202 std::unique_ptr<GbmSurfaceFactory> surface_factory_; |
| 201 scoped_ptr<DrmGpuPlatformSupport> gpu_platform_support_; | 203 std::unique_ptr<DrmGpuPlatformSupport> gpu_platform_support_; |
| 202 | 204 |
| 203 // Objects in the Browser process. | 205 // Objects in the Browser process. |
| 204 scoped_ptr<DeviceManager> device_manager_; | 206 std::unique_ptr<DeviceManager> device_manager_; |
| 205 scoped_ptr<BitmapCursorFactoryOzone> cursor_factory_ozone_; | 207 std::unique_ptr<BitmapCursorFactoryOzone> cursor_factory_ozone_; |
| 206 scoped_ptr<DrmWindowHostManager> window_manager_; | 208 std::unique_ptr<DrmWindowHostManager> window_manager_; |
| 207 scoped_ptr<DrmCursor> cursor_; | 209 std::unique_ptr<DrmCursor> cursor_; |
| 208 scoped_ptr<EventFactoryEvdev> event_factory_ozone_; | 210 std::unique_ptr<EventFactoryEvdev> event_factory_ozone_; |
| 209 scoped_ptr<DrmGpuPlatformSupportHost> gpu_platform_support_host_; | 211 std::unique_ptr<DrmGpuPlatformSupportHost> gpu_platform_support_host_; |
| 210 scoped_ptr<DrmDisplayHostManager> display_manager_; | 212 std::unique_ptr<DrmDisplayHostManager> display_manager_; |
| 211 scoped_ptr<DrmOverlayManager> overlay_manager_; | 213 std::unique_ptr<DrmOverlayManager> overlay_manager_; |
| 212 | 214 |
| 213 // Bridges the DRM, GPU and main threads in mus. | 215 // Bridges the DRM, GPU and main threads in mus. |
| 214 scoped_ptr<MusThreadProxy> mus_thread_proxy_; | 216 std::unique_ptr<MusThreadProxy> mus_thread_proxy_; |
| 215 | 217 |
| 216 #if defined(USE_XKBCOMMON) | 218 #if defined(USE_XKBCOMMON) |
| 217 XkbEvdevCodes xkb_evdev_code_converter_; | 219 XkbEvdevCodes xkb_evdev_code_converter_; |
| 218 #endif | 220 #endif |
| 219 | 221 |
| 220 DISALLOW_COPY_AND_ASSIGN(OzonePlatformGbm); | 222 DISALLOW_COPY_AND_ASSIGN(OzonePlatformGbm); |
| 221 }; | 223 }; |
| 222 | 224 |
| 223 } // namespace | 225 } // namespace |
| 224 | 226 |
| 225 OzonePlatform* CreateOzonePlatformGbm() { | 227 OzonePlatform* CreateOzonePlatformGbm() { |
| 226 return new OzonePlatformGbm; | 228 return new OzonePlatformGbm; |
| 227 } | 229 } |
| 228 | 230 |
| 229 } // namespace ui | 231 } // namespace ui |
| OLD | NEW |