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/dri/ozone_platform_gbm.h" | 5 #include "ui/ozone/platform/dri/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 "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h" | 14 #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h" |
15 #include "ui/events/ozone/device/device_manager.h" | 15 #include "ui/events/ozone/device/device_manager.h" |
16 #include "ui/events/ozone/evdev/event_factory_evdev.h" | 16 #include "ui/events/ozone/evdev/event_factory_evdev.h" |
17 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" | 17 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" |
18 #include "ui/ozone/platform/dri/display_manager.h" | 18 #include "ui/ozone/platform/dri/display_manager.h" |
19 #include "ui/ozone/platform/dri/dri_cursor.h" | 19 #include "ui/ozone/platform/dri/dri_cursor.h" |
20 #include "ui/ozone/platform/dri/dri_gpu_platform_support.h" | 20 #include "ui/ozone/platform/dri/dri_gpu_platform_support.h" |
21 #include "ui/ozone/platform/dri/dri_gpu_platform_support_host.h" | 21 #include "ui/ozone/platform/dri/dri_gpu_platform_support_host.h" |
22 #include "ui/ozone/platform/dri/dri_util.h" | 22 #include "ui/ozone/platform/dri/dri_util.h" |
23 #include "ui/ozone/platform/dri/dri_window.h" | 23 #include "ui/ozone/platform/dri/dri_window.h" |
24 #include "ui/ozone/platform/dri/dri_window_delegate_manager.h" | 24 #include "ui/ozone/platform/dri/dri_window_delegate_manager.h" |
25 #include "ui/ozone/platform/dri/dri_window_manager.h" | 25 #include "ui/ozone/platform/dri/dri_window_manager.h" |
| 26 #include "ui/ozone/platform/dri/drm_device_generator.h" |
26 #include "ui/ozone/platform/dri/drm_device_manager.h" | 27 #include "ui/ozone/platform/dri/drm_device_manager.h" |
27 #include "ui/ozone/platform/dri/gbm_buffer.h" | 28 #include "ui/ozone/platform/dri/gbm_buffer.h" |
28 #include "ui/ozone/platform/dri/gbm_surface.h" | 29 #include "ui/ozone/platform/dri/gbm_surface.h" |
29 #include "ui/ozone/platform/dri/gbm_surface_factory.h" | 30 #include "ui/ozone/platform/dri/gbm_surface_factory.h" |
30 #include "ui/ozone/platform/dri/gbm_wrapper.h" | 31 #include "ui/ozone/platform/dri/gbm_wrapper.h" |
31 #include "ui/ozone/platform/dri/native_display_delegate_dri.h" | 32 #include "ui/ozone/platform/dri/native_display_delegate_dri.h" |
32 #include "ui/ozone/platform/dri/native_display_delegate_proxy.h" | 33 #include "ui/ozone/platform/dri/native_display_delegate_proxy.h" |
33 #include "ui/ozone/platform/dri/scanout_buffer.h" | 34 #include "ui/ozone/platform/dri/scanout_buffer.h" |
34 #include "ui/ozone/platform/dri/screen_manager.h" | 35 #include "ui/ozone/platform/dri/screen_manager.h" |
35 #include "ui/ozone/public/cursor_factory_ozone.h" | 36 #include "ui/ozone/public/cursor_factory_ozone.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 class GbmBufferGenerator : public ScanoutBufferGenerator { |
75 public: | 76 public: |
76 GbmBufferGenerator() {} | 77 GbmBufferGenerator() {} |
77 ~GbmBufferGenerator() override {} | 78 ~GbmBufferGenerator() override {} |
78 | 79 |
| 80 // ScanoutBufferGenerator: |
79 scoped_refptr<ScanoutBuffer> Create(const scoped_refptr<DriWrapper>& drm, | 81 scoped_refptr<ScanoutBuffer> Create(const scoped_refptr<DriWrapper>& drm, |
80 const gfx::Size& size) override { | 82 const gfx::Size& size) override { |
81 scoped_refptr<GbmWrapper> gbm(static_cast<GbmWrapper*>(drm.get())); | 83 scoped_refptr<GbmWrapper> gbm(static_cast<GbmWrapper*>(drm.get())); |
82 return GbmBuffer::CreateBuffer(gbm, SurfaceFactoryOzone::RGBA_8888, size, | 84 return GbmBuffer::CreateBuffer(gbm, SurfaceFactoryOzone::RGBA_8888, size, |
83 true); | 85 true); |
84 } | 86 } |
85 | 87 |
86 protected: | 88 protected: |
87 DISALLOW_COPY_AND_ASSIGN(GbmBufferGenerator); | 89 DISALLOW_COPY_AND_ASSIGN(GbmBufferGenerator); |
88 }; | 90 }; |
89 | 91 |
| 92 class GbmDeviceGenerator : public DrmDeviceGenerator { |
| 93 public: |
| 94 GbmDeviceGenerator() {} |
| 95 ~GbmDeviceGenerator() override {} |
| 96 |
| 97 // DrmDeviceGenerator: |
| 98 scoped_refptr<DriWrapper> CreateDevice(const base::FilePath& path, |
| 99 base::File file) override { |
| 100 scoped_refptr<DriWrapper> drm = new GbmWrapper(path, file.Pass()); |
| 101 drm->Initialize(); |
| 102 return drm; |
| 103 } |
| 104 |
| 105 private: |
| 106 DISALLOW_COPY_AND_ASSIGN(GbmDeviceGenerator); |
| 107 }; |
| 108 |
90 class OzonePlatformGbm : public OzonePlatform { | 109 class OzonePlatformGbm : public OzonePlatform { |
91 public: | 110 public: |
92 OzonePlatformGbm(bool use_surfaceless) : use_surfaceless_(use_surfaceless) { | 111 OzonePlatformGbm(bool use_surfaceless) : use_surfaceless_(use_surfaceless) { |
93 } | 112 } |
94 ~OzonePlatformGbm() override {} | 113 ~OzonePlatformGbm() override {} |
95 | 114 |
96 // OzonePlatform: | 115 // OzonePlatform: |
97 ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override { | 116 ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override { |
98 return surface_factory_ozone_.get(); | 117 return surface_factory_ozone_.get(); |
99 } | 118 } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 // This makes sure that simple targets that do not handle display | 182 // This makes sure that simple targets that do not handle display |
164 // configuration can still use the primary display. | 183 // configuration can still use the primary display. |
165 ForceInitializationOfPrimaryDisplay(gbm_, screen_manager_.get()); | 184 ForceInitializationOfPrimaryDisplay(gbm_, screen_manager_.get()); |
166 | 185 |
167 window_delegate_manager_.reset(new DriWindowDelegateManager()); | 186 window_delegate_manager_.reset(new DriWindowDelegateManager()); |
168 if (!surface_factory_ozone_) | 187 if (!surface_factory_ozone_) |
169 surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_)); | 188 surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_)); |
170 | 189 |
171 surface_factory_ozone_->InitializeGpu(gbm_, drm_device_manager_.get(), | 190 surface_factory_ozone_->InitializeGpu(gbm_, drm_device_manager_.get(), |
172 window_delegate_manager_.get()); | 191 window_delegate_manager_.get()); |
173 scoped_ptr<NativeDisplayDelegateDri> ndd( | 192 scoped_ptr<NativeDisplayDelegateDri> ndd(new NativeDisplayDelegateDri( |
174 new NativeDisplayDelegateDri(screen_manager_.get(), gbm_)); | 193 screen_manager_.get(), gbm_, |
| 194 scoped_ptr<DrmDeviceGenerator>(new GbmDeviceGenerator()))); |
175 gpu_platform_support_.reset(new DriGpuPlatformSupport( | 195 gpu_platform_support_.reset(new DriGpuPlatformSupport( |
176 drm_device_manager_.get(), window_delegate_manager_.get(), | 196 drm_device_manager_.get(), window_delegate_manager_.get(), |
177 screen_manager_.get(), ndd.Pass())); | 197 screen_manager_.get(), ndd.Pass())); |
178 } | 198 } |
179 | 199 |
180 private: | 200 private: |
181 bool use_surfaceless_; | 201 bool use_surfaceless_; |
182 scoped_ptr<GlApiLoader> gl_api_loader_; | 202 scoped_ptr<GlApiLoader> gl_api_loader_; |
183 scoped_refptr<GbmWrapper> gbm_; | 203 scoped_refptr<GbmWrapper> gbm_; |
184 scoped_ptr<DrmDeviceManager> drm_device_manager_; | 204 scoped_ptr<DrmDeviceManager> drm_device_manager_; |
(...skipping 26 matching lines...) Expand all Loading... |
211 OzonePlatform* CreateOzonePlatformGbm() { | 231 OzonePlatform* CreateOzonePlatformGbm() { |
212 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); | 232 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); |
213 #if defined(USE_MESA_PLATFORM_NULL) | 233 #if defined(USE_MESA_PLATFORM_NULL) |
214 // Only works with surfaceless. | 234 // Only works with surfaceless. |
215 cmd->AppendSwitch(switches::kOzoneUseSurfaceless); | 235 cmd->AppendSwitch(switches::kOzoneUseSurfaceless); |
216 #endif | 236 #endif |
217 return new OzonePlatformGbm(cmd->HasSwitch(switches::kOzoneUseSurfaceless)); | 237 return new OzonePlatformGbm(cmd->HasSwitch(switches::kOzoneUseSurfaceless)); |
218 } | 238 } |
219 | 239 |
220 } // namespace ui | 240 } // namespace ui |
OLD | NEW |