| 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/macros.h" | 18 #include "base/macros.h" |
| 18 #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h" | 19 #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h" |
| 19 #include "ui/events/ozone/device/device_manager.h" | 20 #include "ui/events/ozone/device/device_manager.h" |
| 20 #include "ui/events/ozone/evdev/event_factory_evdev.h" | 21 #include "ui/events/ozone/evdev/event_factory_evdev.h" |
| 21 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" | 22 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" |
| 22 #include "ui/ozone/platform/drm/common/drm_util.h" | 23 #include "ui/ozone/platform/drm/common/drm_util.h" |
| 23 #include "ui/ozone/platform/drm/gpu/drm_device_generator.h" | 24 #include "ui/ozone/platform/drm/gpu/drm_device_generator.h" |
| 24 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h" | 25 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h" |
| 25 #include "ui/ozone/platform/drm/gpu/drm_gpu_display_manager.h" | 26 #include "ui/ozone/platform/drm/gpu/drm_gpu_display_manager.h" |
| 26 #include "ui/ozone/platform/drm/gpu/drm_gpu_platform_support.h" | 27 #include "ui/ozone/platform/drm/gpu/drm_gpu_platform_support.h" |
| 27 #include "ui/ozone/platform/drm/gpu/drm_thread_message_proxy.h" | 28 #include "ui/ozone/platform/drm/gpu/drm_thread_message_proxy.h" |
| 28 #include "ui/ozone/platform/drm/gpu/drm_thread_proxy.h" | 29 #include "ui/ozone/platform/drm/gpu/drm_thread_proxy.h" |
| 29 #include "ui/ozone/platform/drm/gpu/gbm_surface_factory.h" | 30 #include "ui/ozone/platform/drm/gpu/gbm_surface_factory.h" |
| 30 #include "ui/ozone/platform/drm/gpu/proxy_helpers.h" | 31 #include "ui/ozone/platform/drm/gpu/proxy_helpers.h" |
| 31 #include "ui/ozone/platform/drm/gpu/scanout_buffer.h" | 32 #include "ui/ozone/platform/drm/gpu/scanout_buffer.h" |
| 32 #include "ui/ozone/platform/drm/gpu/screen_manager.h" | 33 #include "ui/ozone/platform/drm/gpu/screen_manager.h" |
| 33 #include "ui/ozone/platform/drm/host/drm_cursor.h" | 34 #include "ui/ozone/platform/drm/host/drm_cursor.h" |
| 34 #include "ui/ozone/platform/drm/host/drm_display_host_manager.h" | 35 #include "ui/ozone/platform/drm/host/drm_display_host_manager.h" |
| 35 #include "ui/ozone/platform/drm/host/drm_gpu_platform_support_host.h" | 36 #include "ui/ozone/platform/drm/host/drm_gpu_platform_support_host.h" |
| 36 #include "ui/ozone/platform/drm/host/drm_native_display_delegate.h" | 37 #include "ui/ozone/platform/drm/host/drm_native_display_delegate.h" |
| 37 #include "ui/ozone/platform/drm/host/drm_overlay_manager.h" | 38 #include "ui/ozone/platform/drm/host/drm_overlay_manager.h" |
| 38 #include "ui/ozone/platform/drm/host/drm_window_host.h" | 39 #include "ui/ozone/platform/drm/host/drm_window_host.h" |
| 39 #include "ui/ozone/platform/drm/host/drm_window_host_manager.h" | 40 #include "ui/ozone/platform/drm/host/drm_window_host_manager.h" |
| 41 #include "ui/ozone/platform/drm/mus_thread_proxy.h" |
| 40 #include "ui/ozone/public/cursor_factory_ozone.h" | 42 #include "ui/ozone/public/cursor_factory_ozone.h" |
| 41 #include "ui/ozone/public/gpu_platform_support.h" | 43 #include "ui/ozone/public/gpu_platform_support.h" |
| 42 #include "ui/ozone/public/gpu_platform_support_host.h" | 44 #include "ui/ozone/public/gpu_platform_support_host.h" |
| 43 #include "ui/ozone/public/ozone_platform.h" | 45 #include "ui/ozone/public/ozone_platform.h" |
| 44 #include "ui/ozone/public/ozone_switches.h" | 46 #include "ui/ozone/public/ozone_switches.h" |
| 45 | 47 |
| 46 #if defined(USE_XKBCOMMON) | 48 #if defined(USE_XKBCOMMON) |
| 47 #include "ui/events/ozone/layout/xkb/xkb_evdev_codes.h" | 49 #include "ui/events/ozone/layout/xkb/xkb_evdev_codes.h" |
| 48 #include "ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h" | 50 #include "ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h" |
| 49 #else | 51 #else |
| (...skipping 19 matching lines...) Expand all Loading... |
| 69 // symbols in the libglapi library however it does not explicitly link against | 71 // symbols in the libglapi library however it does not explicitly link against |
| 70 // it. That caused linkage errors when running an application that does not | 72 // it. That caused linkage errors when running an application that does not |
| 71 // explicitly link against libglapi. | 73 // explicitly link against libglapi. |
| 72 void* glapi_lib_; | 74 void* glapi_lib_; |
| 73 | 75 |
| 74 DISALLOW_COPY_AND_ASSIGN(GlApiLoader); | 76 DISALLOW_COPY_AND_ASSIGN(GlApiLoader); |
| 75 }; | 77 }; |
| 76 | 78 |
| 77 // Returns true if we should operate in Mus mode. | 79 // Returns true if we should operate in Mus mode. |
| 78 bool RunningInsideMus() { | 80 bool RunningInsideMus() { |
| 79 // TODO(rjkroege): Implement. | 81 bool has_channel_handle = base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 80 return false; | 82 "mojo-platform-channel-handle"); |
| 83 return has_channel_handle; |
| 81 } | 84 } |
| 82 | 85 |
| 83 class OzonePlatformGbm : public OzonePlatform { | 86 class OzonePlatformGbm : public OzonePlatform { |
| 84 public: | 87 public: |
| 85 OzonePlatformGbm() {} | 88 OzonePlatformGbm() {} |
| 86 ~OzonePlatformGbm() override {} | 89 ~OzonePlatformGbm() override {} |
| 87 | 90 |
| 88 // OzonePlatform: | 91 // OzonePlatform: |
| 89 ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override { | 92 ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override { |
| 90 return surface_factory_.get(); | 93 return surface_factory_.get(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 103 } | 106 } |
| 104 GpuPlatformSupportHost* GetGpuPlatformSupportHost() override { | 107 GpuPlatformSupportHost* GetGpuPlatformSupportHost() override { |
| 105 return gpu_platform_support_host_.get(); | 108 return gpu_platform_support_host_.get(); |
| 106 } | 109 } |
| 107 scoped_ptr<SystemInputInjector> CreateSystemInputInjector() override { | 110 scoped_ptr<SystemInputInjector> CreateSystemInputInjector() override { |
| 108 return event_factory_ozone_->CreateSystemInputInjector(); | 111 return event_factory_ozone_->CreateSystemInputInjector(); |
| 109 } | 112 } |
| 110 scoped_ptr<PlatformWindow> CreatePlatformWindow( | 113 scoped_ptr<PlatformWindow> CreatePlatformWindow( |
| 111 PlatformWindowDelegate* delegate, | 114 PlatformWindowDelegate* delegate, |
| 112 const gfx::Rect& bounds) override { | 115 const gfx::Rect& bounds) override { |
| 116 GpuThreadAdapter* adapter = gpu_platform_support_host_.get(); |
| 117 if (RunningInsideMus()) { |
| 118 DCHECK(drm_thread_) << "drm_thread_ should exist (and be running) here."; |
| 119 adapter = mus_thread_proxy_.get(); |
| 120 } |
| 121 |
| 113 scoped_ptr<DrmWindowHost> platform_window(new DrmWindowHost( | 122 scoped_ptr<DrmWindowHost> platform_window(new DrmWindowHost( |
| 114 delegate, bounds, gpu_platform_support_host_.get(), | 123 delegate, bounds, adapter, event_factory_ozone_.get(), cursor_.get(), |
| 115 event_factory_ozone_.get(), cursor_.get(), window_manager_.get(), | 124 window_manager_.get(), display_manager_.get(), overlay_manager_.get())); |
| 116 display_manager_.get(), overlay_manager_.get())); | |
| 117 platform_window->Initialize(); | 125 platform_window->Initialize(); |
| 118 return std::move(platform_window); | 126 return std::move(platform_window); |
| 119 } | 127 } |
| 120 scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() override { | 128 scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() override { |
| 121 return make_scoped_ptr( | 129 return make_scoped_ptr( |
| 122 new DrmNativeDisplayDelegate(display_manager_.get())); | 130 new DrmNativeDisplayDelegate(display_manager_.get())); |
| 123 } | 131 } |
| 124 base::ScopedFD OpenClientNativePixmapDevice() const override { | 132 base::ScopedFD OpenClientNativePixmapDevice() const override { |
| 125 #if defined(USE_VGEM_MAP) | 133 #if defined(USE_VGEM_MAP) |
| 126 int vgem_fd = drmOpenWithType("vgem", nullptr, DRM_NODE_RENDER); | 134 int vgem_fd = drmOpenWithType("vgem", nullptr, DRM_NODE_RENDER); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 142 #else | 150 #else |
| 143 KeyboardLayoutEngineManager::SetKeyboardLayoutEngine( | 151 KeyboardLayoutEngineManager::SetKeyboardLayoutEngine( |
| 144 make_scoped_ptr(new StubKeyboardLayoutEngine())); | 152 make_scoped_ptr(new StubKeyboardLayoutEngine())); |
| 145 #endif | 153 #endif |
| 146 event_factory_ozone_.reset(new EventFactoryEvdev( | 154 event_factory_ozone_.reset(new EventFactoryEvdev( |
| 147 cursor_.get(), device_manager_.get(), | 155 cursor_.get(), device_manager_.get(), |
| 148 KeyboardLayoutEngineManager::GetKeyboardLayoutEngine())); | 156 KeyboardLayoutEngineManager::GetKeyboardLayoutEngine())); |
| 149 | 157 |
| 150 GpuThreadAdapter* adapter; | 158 GpuThreadAdapter* adapter; |
| 151 if (RunningInsideMus()) { | 159 if (RunningInsideMus()) { |
| 152 NOTIMPLEMENTED(); | 160 gl_api_loader_.reset(new GlApiLoader()); |
| 153 adapter = 0; | 161 mus_thread_proxy_.reset(new MusThreadProxy()); |
| 162 adapter = mus_thread_proxy_.get(); |
| 154 } else { | 163 } else { |
| 155 gpu_platform_support_host_.reset( | 164 gpu_platform_support_host_.reset( |
| 156 new DrmGpuPlatformSupportHost(cursor_.get())); | 165 new DrmGpuPlatformSupportHost(cursor_.get())); |
| 157 adapter = gpu_platform_support_host_.get(); | 166 adapter = gpu_platform_support_host_.get(); |
| 158 } | 167 } |
| 159 | 168 |
| 160 display_manager_.reset( | 169 display_manager_.reset( |
| 161 new DrmDisplayHostManager(adapter, device_manager_.get(), | 170 new DrmDisplayHostManager(adapter, device_manager_.get(), |
| 162 event_factory_ozone_->input_controller())); | 171 event_factory_ozone_->input_controller())); |
| 163 cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone); | 172 cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone); |
| 164 overlay_manager_.reset( | 173 overlay_manager_.reset( |
| 165 new DrmOverlayManager(adapter, window_manager_.get())); | 174 new DrmOverlayManager(adapter, window_manager_.get())); |
| 166 | 175 |
| 167 if (RunningInsideMus()) { | 176 if (RunningInsideMus()) { |
| 168 NOTIMPLEMENTED(); | 177 mus_thread_proxy_->ProvideManagers(display_manager_.get(), |
| 178 overlay_manager_.get()); |
| 169 } | 179 } |
| 170 } | 180 } |
| 171 | 181 |
| 172 void InitializeGPU() override { | 182 void InitializeGPU() override { |
| 173 InterThreadMessagingProxy* itmp; | 183 InterThreadMessagingProxy* itmp; |
| 174 if (RunningInsideMus()) { | 184 if (RunningInsideMus()) { |
| 175 NOTIMPLEMENTED(); | 185 DCHECK(mus_thread_proxy_); |
| 176 itmp = 0; | 186 itmp = mus_thread_proxy_.get(); |
| 177 } else { | 187 } else { |
| 178 gl_api_loader_.reset(new GlApiLoader()); | 188 gl_api_loader_.reset(new GlApiLoader()); |
| 179 scoped_refptr<DrmThreadMessageProxy> message_proxy( | 189 scoped_refptr<DrmThreadMessageProxy> message_proxy( |
| 180 new DrmThreadMessageProxy()); | 190 new DrmThreadMessageProxy()); |
| 181 itmp = message_proxy.get(); | 191 itmp = message_proxy.get(); |
| 182 gpu_platform_support_.reset(new DrmGpuPlatformSupport(message_proxy)); | 192 gpu_platform_support_.reset(new DrmGpuPlatformSupport(message_proxy)); |
| 183 } | 193 } |
| 184 | 194 |
| 185 // NOTE: Can't start the thread here since this is called before sandbox | 195 // NOTE: Can't start the thread here since this is called before sandbox |
| 186 // initialization in multi-process Chrome. In mus, we start the DRM thread. | 196 // initialization in multi-process Chrome. In mus, we start the DRM thread. |
| 187 drm_thread_.reset(new DrmThreadProxy()); | 197 drm_thread_.reset(new DrmThreadProxy()); |
| 188 drm_thread_->BindThreadIntoMessagingProxy(itmp); | 198 drm_thread_->BindThreadIntoMessagingProxy(itmp); |
| 189 | 199 |
| 190 surface_factory_.reset(new GbmSurfaceFactory(drm_thread_.get())); | 200 surface_factory_.reset(new GbmSurfaceFactory(drm_thread_.get())); |
| 191 if (RunningInsideMus()) { | 201 if (RunningInsideMus()) { |
| 192 NOTIMPLEMENTED(); | 202 mus_thread_proxy_->StartDrmThread(); |
| 193 } | 203 } |
| 194 } | 204 } |
| 195 | 205 |
| 196 private: | 206 private: |
| 197 // Objects in the GPU process. | 207 // Objects in the GPU process. |
| 198 scoped_ptr<DrmThreadProxy> drm_thread_; | 208 scoped_ptr<DrmThreadProxy> drm_thread_; |
| 199 scoped_ptr<GlApiLoader> gl_api_loader_; | 209 scoped_ptr<GlApiLoader> gl_api_loader_; |
| 200 scoped_ptr<GbmSurfaceFactory> surface_factory_; | 210 scoped_ptr<GbmSurfaceFactory> surface_factory_; |
| 201 scoped_ptr<DrmGpuPlatformSupport> gpu_platform_support_; | 211 scoped_ptr<DrmGpuPlatformSupport> gpu_platform_support_; |
| 202 | 212 |
| 203 // Objects in the Browser process. | 213 // Objects in the Browser process. |
| 204 scoped_ptr<DeviceManager> device_manager_; | 214 scoped_ptr<DeviceManager> device_manager_; |
| 205 scoped_ptr<BitmapCursorFactoryOzone> cursor_factory_ozone_; | 215 scoped_ptr<BitmapCursorFactoryOzone> cursor_factory_ozone_; |
| 206 scoped_ptr<DrmWindowHostManager> window_manager_; | 216 scoped_ptr<DrmWindowHostManager> window_manager_; |
| 207 scoped_ptr<DrmCursor> cursor_; | 217 scoped_ptr<DrmCursor> cursor_; |
| 208 scoped_ptr<EventFactoryEvdev> event_factory_ozone_; | 218 scoped_ptr<EventFactoryEvdev> event_factory_ozone_; |
| 209 scoped_ptr<DrmGpuPlatformSupportHost> gpu_platform_support_host_; | 219 scoped_ptr<DrmGpuPlatformSupportHost> gpu_platform_support_host_; |
| 210 scoped_ptr<DrmDisplayHostManager> display_manager_; | 220 scoped_ptr<DrmDisplayHostManager> display_manager_; |
| 211 scoped_ptr<DrmOverlayManager> overlay_manager_; | 221 scoped_ptr<DrmOverlayManager> overlay_manager_; |
| 212 | 222 |
| 223 // Bridges the DRM, GPU and main threads in mus. |
| 224 scoped_ptr<MusThreadProxy> mus_thread_proxy_; |
| 225 |
| 213 #if defined(USE_XKBCOMMON) | 226 #if defined(USE_XKBCOMMON) |
| 214 XkbEvdevCodes xkb_evdev_code_converter_; | 227 XkbEvdevCodes xkb_evdev_code_converter_; |
| 215 #endif | 228 #endif |
| 216 | 229 |
| 217 DISALLOW_COPY_AND_ASSIGN(OzonePlatformGbm); | 230 DISALLOW_COPY_AND_ASSIGN(OzonePlatformGbm); |
| 218 }; | 231 }; |
| 219 | 232 |
| 220 } // namespace | 233 } // namespace |
| 221 | 234 |
| 222 OzonePlatform* CreateOzonePlatformGbm() { | 235 OzonePlatform* CreateOzonePlatformGbm() { |
| 223 return new OzonePlatformGbm; | 236 return new OzonePlatformGbm; |
| 224 } | 237 } |
| 225 | 238 |
| 226 } // namespace ui | 239 } // namespace ui |
| OLD | NEW |