| 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/bind.h" | 11 #include "base/bind.h" |
| 12 #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h" | 12 #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h" |
| 13 #include "ui/events/ozone/device/device_manager.h" | 13 #include "ui/events/ozone/device/device_manager.h" |
| 14 #include "ui/events/ozone/evdev/event_factory_evdev.h" | 14 #include "ui/events/ozone/evdev/event_factory_evdev.h" |
| 15 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" | 15 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" |
| 16 #include "ui/ozone/platform/drm/common/drm_util.h" | 16 #include "ui/ozone/platform/drm/common/drm_util.h" |
| 17 #include "ui/ozone/platform/drm/gpu/drm_device_generator.h" | 17 #include "ui/ozone/platform/drm/gpu/drm_device_generator.h" |
| 18 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h" | 18 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h" |
| 19 #include "ui/ozone/platform/drm/gpu/drm_gpu_display_manager.h" | 19 #include "ui/ozone/platform/drm/gpu/drm_gpu_display_manager.h" |
| 20 #include "ui/ozone/platform/drm/gpu/drm_gpu_platform_support.h" | 20 #include "ui/ozone/platform/drm/gpu/drm_gpu_platform_support.h" |
| 21 #include "ui/ozone/platform/drm/gpu/gbm_buffer.h" | 21 #include "ui/ozone/platform/drm/gpu/drm_thread_proxy.h" |
| 22 #include "ui/ozone/platform/drm/gpu/gbm_device.h" | |
| 23 #include "ui/ozone/platform/drm/gpu/gbm_surface_factory.h" | 22 #include "ui/ozone/platform/drm/gpu/gbm_surface_factory.h" |
| 23 #include "ui/ozone/platform/drm/gpu/message_filter_proxy.h" |
| 24 #include "ui/ozone/platform/drm/gpu/proxy_helpers.h" |
| 24 #include "ui/ozone/platform/drm/gpu/scanout_buffer.h" | 25 #include "ui/ozone/platform/drm/gpu/scanout_buffer.h" |
| 25 #include "ui/ozone/platform/drm/gpu/screen_manager.h" | 26 #include "ui/ozone/platform/drm/gpu/screen_manager.h" |
| 26 #include "ui/ozone/platform/drm/host/drm_cursor.h" | 27 #include "ui/ozone/platform/drm/host/drm_cursor.h" |
| 27 #include "ui/ozone/platform/drm/host/drm_display_host_manager.h" | 28 #include "ui/ozone/platform/drm/host/drm_display_host_manager.h" |
| 28 #include "ui/ozone/platform/drm/host/drm_gpu_platform_support_host.h" | 29 #include "ui/ozone/platform/drm/host/drm_gpu_platform_support_host.h" |
| 29 #include "ui/ozone/platform/drm/host/drm_native_display_delegate.h" | 30 #include "ui/ozone/platform/drm/host/drm_native_display_delegate.h" |
| 30 #include "ui/ozone/platform/drm/host/drm_overlay_manager.h" | 31 #include "ui/ozone/platform/drm/host/drm_overlay_manager.h" |
| 31 #include "ui/ozone/platform/drm/host/drm_window_host.h" | 32 #include "ui/ozone/platform/drm/host/drm_window_host.h" |
| 32 #include "ui/ozone/platform/drm/host/drm_window_host_manager.h" | 33 #include "ui/ozone/platform/drm/host/drm_window_host_manager.h" |
| 33 #include "ui/ozone/public/cursor_factory_ozone.h" | 34 #include "ui/ozone/public/cursor_factory_ozone.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 64 private: | 65 private: |
| 65 // HACK: gbm drivers have broken linkage. The Mesa DRI driver references | 66 // HACK: gbm drivers have broken linkage. The Mesa DRI driver references |
| 66 // symbols in the libglapi library however it does not explicitly link against | 67 // symbols in the libglapi library however it does not explicitly link against |
| 67 // it. That caused linkage errors when running an application that does not | 68 // it. That caused linkage errors when running an application that does not |
| 68 // explicitly link against libglapi. | 69 // explicitly link against libglapi. |
| 69 void* glapi_lib_; | 70 void* glapi_lib_; |
| 70 | 71 |
| 71 DISALLOW_COPY_AND_ASSIGN(GlApiLoader); | 72 DISALLOW_COPY_AND_ASSIGN(GlApiLoader); |
| 72 }; | 73 }; |
| 73 | 74 |
| 74 class GbmBufferGenerator : public ScanoutBufferGenerator { | |
| 75 public: | |
| 76 GbmBufferGenerator() {} | |
| 77 ~GbmBufferGenerator() override {} | |
| 78 | |
| 79 // ScanoutBufferGenerator: | |
| 80 scoped_refptr<ScanoutBuffer> Create(const scoped_refptr<DrmDevice>& drm, | |
| 81 gfx::BufferFormat format, | |
| 82 const gfx::Size& size) override { | |
| 83 scoped_refptr<GbmDevice> gbm(static_cast<GbmDevice*>(drm.get())); | |
| 84 return GbmBuffer::CreateBuffer(gbm, format, size, | |
| 85 gfx::BufferUsage::SCANOUT); | |
| 86 } | |
| 87 | |
| 88 protected: | |
| 89 DISALLOW_COPY_AND_ASSIGN(GbmBufferGenerator); | |
| 90 }; | |
| 91 | |
| 92 class GbmDeviceGenerator : public DrmDeviceGenerator { | |
| 93 public: | |
| 94 GbmDeviceGenerator(bool use_atomic) : use_atomic_(use_atomic) {} | |
| 95 ~GbmDeviceGenerator() override {} | |
| 96 | |
| 97 // DrmDeviceGenerator: | |
| 98 scoped_refptr<DrmDevice> CreateDevice(const base::FilePath& path, | |
| 99 base::File file) override { | |
| 100 scoped_refptr<DrmDevice> drm = new GbmDevice(path, file.Pass()); | |
| 101 if (drm->Initialize(use_atomic_)) | |
| 102 return drm; | |
| 103 | |
| 104 return nullptr; | |
| 105 } | |
| 106 | |
| 107 private: | |
| 108 bool use_atomic_; | |
| 109 | |
| 110 DISALLOW_COPY_AND_ASSIGN(GbmDeviceGenerator); | |
| 111 }; | |
| 112 | |
| 113 class OzonePlatformGbm : public OzonePlatform { | 75 class OzonePlatformGbm : public OzonePlatform { |
| 114 public: | 76 public: |
| 115 OzonePlatformGbm() {} | 77 OzonePlatformGbm() {} |
| 116 ~OzonePlatformGbm() override {} | 78 ~OzonePlatformGbm() override {} |
| 117 | 79 |
| 118 // OzonePlatform: | 80 // OzonePlatform: |
| 119 ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override { | 81 ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override { |
| 120 return surface_factory_ozone_.get(); | 82 return surface_factory_.get(); |
| 121 } | 83 } |
| 122 OverlayManagerOzone* GetOverlayManager() override { | 84 OverlayManagerOzone* GetOverlayManager() override { |
| 123 return overlay_manager_.get(); | 85 return overlay_manager_.get(); |
| 124 } | 86 } |
| 125 CursorFactoryOzone* GetCursorFactoryOzone() override { | 87 CursorFactoryOzone* GetCursorFactoryOzone() override { |
| 126 return cursor_factory_ozone_.get(); | 88 return cursor_factory_ozone_.get(); |
| 127 } | 89 } |
| 128 InputController* GetInputController() override { | 90 InputController* GetInputController() override { |
| 129 return event_factory_ozone_->input_controller(); | 91 return event_factory_ozone_->input_controller(); |
| 130 } | 92 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 new DrmGpuPlatformSupportHost(cursor_.get())); | 140 new DrmGpuPlatformSupportHost(cursor_.get())); |
| 179 display_manager_.reset(new DrmDisplayHostManager( | 141 display_manager_.reset(new DrmDisplayHostManager( |
| 180 gpu_platform_support_host_.get(), device_manager_.get(), | 142 gpu_platform_support_host_.get(), device_manager_.get(), |
| 181 event_factory_ozone_->input_controller())); | 143 event_factory_ozone_->input_controller())); |
| 182 cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone); | 144 cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone); |
| 183 overlay_manager_.reset( | 145 overlay_manager_.reset( |
| 184 new DrmOverlayManager(gpu_platform_support_host_.get())); | 146 new DrmOverlayManager(gpu_platform_support_host_.get())); |
| 185 } | 147 } |
| 186 | 148 |
| 187 void InitializeGPU() override { | 149 void InitializeGPU() override { |
| 188 bool use_atomic = false; | |
| 189 #if defined(USE_DRM_ATOMIC) | |
| 190 use_atomic = true; | |
| 191 #endif | |
| 192 gl_api_loader_.reset(new GlApiLoader()); | 150 gl_api_loader_.reset(new GlApiLoader()); |
| 193 drm_device_manager_.reset(new DrmDeviceManager( | 151 // NOTE: Can't start the thread here since this is called before sandbox |
| 194 scoped_ptr<DrmDeviceGenerator>(new GbmDeviceGenerator(use_atomic)))); | 152 // initialization. |
| 195 buffer_generator_.reset(new GbmBufferGenerator()); | 153 drm_thread_.reset(new DrmThreadProxy()); |
| 196 screen_manager_.reset(new ScreenManager(buffer_generator_.get())); | 154 |
| 197 surface_factory_ozone_.reset(new GbmSurfaceFactory()); | 155 surface_factory_.reset(new GbmSurfaceFactory(drm_thread_.get())); |
| 198 surface_factory_ozone_->InitializeGpu(drm_device_manager_.get(), | 156 gpu_platform_support_.reset( |
| 199 screen_manager_.get()); | 157 new DrmGpuPlatformSupport(drm_thread_->CreateMessageFilterProxy())); |
| 200 scoped_ptr<DrmGpuDisplayManager> display_manager(new DrmGpuDisplayManager( | |
| 201 screen_manager_.get(), drm_device_manager_.get())); | |
| 202 gpu_platform_support_.reset(new DrmGpuPlatformSupport( | |
| 203 drm_device_manager_.get(), screen_manager_.get(), | |
| 204 buffer_generator_.get(), display_manager.Pass())); | |
| 205 } | 158 } |
| 206 | 159 |
| 207 private: | 160 private: |
| 208 // Objects in the GPU process. | 161 // Objects in the GPU process. |
| 209 scoped_ptr<GbmSurfaceFactory> surface_factory_ozone_; | 162 scoped_ptr<DrmThreadProxy> drm_thread_; |
| 210 scoped_ptr<GlApiLoader> gl_api_loader_; | 163 scoped_ptr<GlApiLoader> gl_api_loader_; |
| 211 scoped_ptr<DrmDeviceManager> drm_device_manager_; | 164 scoped_ptr<GbmSurfaceFactory> surface_factory_; |
| 212 scoped_ptr<GbmBufferGenerator> buffer_generator_; | |
| 213 scoped_ptr<ScreenManager> screen_manager_; | |
| 214 scoped_ptr<DrmGpuPlatformSupport> gpu_platform_support_; | 165 scoped_ptr<DrmGpuPlatformSupport> gpu_platform_support_; |
| 215 | 166 |
| 216 // Objects in the Browser process. | 167 // Objects in the Browser process. |
| 217 scoped_ptr<DeviceManager> device_manager_; | 168 scoped_ptr<DeviceManager> device_manager_; |
| 218 scoped_ptr<BitmapCursorFactoryOzone> cursor_factory_ozone_; | 169 scoped_ptr<BitmapCursorFactoryOzone> cursor_factory_ozone_; |
| 219 scoped_ptr<DrmWindowHostManager> window_manager_; | 170 scoped_ptr<DrmWindowHostManager> window_manager_; |
| 220 scoped_ptr<DrmCursor> cursor_; | 171 scoped_ptr<DrmCursor> cursor_; |
| 221 scoped_ptr<EventFactoryEvdev> event_factory_ozone_; | 172 scoped_ptr<EventFactoryEvdev> event_factory_ozone_; |
| 222 scoped_ptr<DrmGpuPlatformSupportHost> gpu_platform_support_host_; | 173 scoped_ptr<DrmGpuPlatformSupportHost> gpu_platform_support_host_; |
| 223 scoped_ptr<DrmDisplayHostManager> display_manager_; | 174 scoped_ptr<DrmDisplayHostManager> display_manager_; |
| 224 scoped_ptr<DrmOverlayManager> overlay_manager_; | 175 scoped_ptr<DrmOverlayManager> overlay_manager_; |
| 225 | 176 |
| 226 #if defined(USE_XKBCOMMON) | 177 #if defined(USE_XKBCOMMON) |
| 227 XkbEvdevCodes xkb_evdev_code_converter_; | 178 XkbEvdevCodes xkb_evdev_code_converter_; |
| 228 #endif | 179 #endif |
| 229 | 180 |
| 230 DISALLOW_COPY_AND_ASSIGN(OzonePlatformGbm); | 181 DISALLOW_COPY_AND_ASSIGN(OzonePlatformGbm); |
| 231 }; | 182 }; |
| 232 | 183 |
| 233 } // namespace | 184 } // namespace |
| 234 | 185 |
| 235 OzonePlatform* CreateOzonePlatformGbm() { | 186 OzonePlatform* CreateOzonePlatformGbm() { |
| 236 return new OzonePlatformGbm; | 187 return new OzonePlatformGbm; |
| 237 } | 188 } |
| 238 | 189 |
| 239 } // namespace ui | 190 } // namespace ui |
| OLD | NEW |