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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 void* glapi_lib_; | 68 void* glapi_lib_; |
68 | 69 |
69 DISALLOW_COPY_AND_ASSIGN(GlApiLoader); | 70 DISALLOW_COPY_AND_ASSIGN(GlApiLoader); |
70 }; | 71 }; |
71 | 72 |
72 class GbmBufferGenerator : public ScanoutBufferGenerator { | 73 class GbmBufferGenerator : public ScanoutBufferGenerator { |
73 public: | 74 public: |
74 GbmBufferGenerator() {} | 75 GbmBufferGenerator() {} |
75 ~GbmBufferGenerator() override {} | 76 ~GbmBufferGenerator() override {} |
76 | 77 |
| 78 // ScanoutBufferGenerator: |
77 scoped_refptr<ScanoutBuffer> Create(const scoped_refptr<DriWrapper>& drm, | 79 scoped_refptr<ScanoutBuffer> Create(const scoped_refptr<DriWrapper>& drm, |
78 const gfx::Size& size) override { | 80 const gfx::Size& size) override { |
79 scoped_refptr<GbmWrapper> gbm(static_cast<GbmWrapper*>(drm.get())); | 81 scoped_refptr<GbmWrapper> gbm(static_cast<GbmWrapper*>(drm.get())); |
80 return GbmBuffer::CreateBuffer(gbm, SurfaceFactoryOzone::RGBA_8888, size, | 82 return GbmBuffer::CreateBuffer(gbm, SurfaceFactoryOzone::RGBA_8888, size, |
81 true); | 83 true); |
82 } | 84 } |
83 | 85 |
84 protected: | 86 protected: |
85 DISALLOW_COPY_AND_ASSIGN(GbmBufferGenerator); | 87 DISALLOW_COPY_AND_ASSIGN(GbmBufferGenerator); |
86 }; | 88 }; |
87 | 89 |
| 90 class GbmDeviceGenerator : public DrmDeviceGenerator { |
| 91 public: |
| 92 GbmDeviceGenerator() {} |
| 93 ~GbmDeviceGenerator() override {} |
| 94 |
| 95 // DrmDeviceGenerator: |
| 96 scoped_refptr<DriWrapper> CreateDevice(const base::FilePath& path, |
| 97 base::File file) override { |
| 98 scoped_refptr<DriWrapper> drm = new GbmWrapper(path, file.Pass()); |
| 99 drm->Initialize(); |
| 100 return drm; |
| 101 } |
| 102 |
| 103 private: |
| 104 DISALLOW_COPY_AND_ASSIGN(GbmDeviceGenerator); |
| 105 }; |
| 106 |
88 class OzonePlatformGbm : public OzonePlatform { | 107 class OzonePlatformGbm : public OzonePlatform { |
89 public: | 108 public: |
90 OzonePlatformGbm(bool use_surfaceless) : use_surfaceless_(use_surfaceless) { | 109 OzonePlatformGbm(bool use_surfaceless) : use_surfaceless_(use_surfaceless) { |
91 } | 110 } |
92 ~OzonePlatformGbm() override {} | 111 ~OzonePlatformGbm() override {} |
93 | 112 |
94 // OzonePlatform: | 113 // OzonePlatform: |
95 ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override { | 114 ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override { |
96 return surface_factory_ozone_.get(); | 115 return surface_factory_ozone_.get(); |
97 } | 116 } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 // This makes sure that simple targets that do not handle display | 180 // This makes sure that simple targets that do not handle display |
162 // configuration can still use the primary display. | 181 // configuration can still use the primary display. |
163 ForceInitializationOfPrimaryDisplay(gbm_, screen_manager_.get()); | 182 ForceInitializationOfPrimaryDisplay(gbm_, screen_manager_.get()); |
164 | 183 |
165 window_delegate_manager_.reset(new DriWindowDelegateManager()); | 184 window_delegate_manager_.reset(new DriWindowDelegateManager()); |
166 if (!surface_factory_ozone_) | 185 if (!surface_factory_ozone_) |
167 surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_)); | 186 surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_)); |
168 | 187 |
169 surface_factory_ozone_->InitializeGpu(gbm_, drm_device_manager_.get(), | 188 surface_factory_ozone_->InitializeGpu(gbm_, drm_device_manager_.get(), |
170 window_delegate_manager_.get()); | 189 window_delegate_manager_.get()); |
171 scoped_ptr<NativeDisplayDelegateDri> ndd( | 190 scoped_ptr<NativeDisplayDelegateDri> ndd(new NativeDisplayDelegateDri( |
172 new NativeDisplayDelegateDri(screen_manager_.get(), gbm_)); | 191 screen_manager_.get(), gbm_, |
| 192 scoped_ptr<DrmDeviceGenerator>(new GbmDeviceGenerator()))); |
173 gpu_platform_support_.reset(new DriGpuPlatformSupport( | 193 gpu_platform_support_.reset(new DriGpuPlatformSupport( |
174 drm_device_manager_.get(), window_delegate_manager_.get(), | 194 drm_device_manager_.get(), window_delegate_manager_.get(), |
175 screen_manager_.get(), ndd.Pass())); | 195 screen_manager_.get(), ndd.Pass())); |
176 } | 196 } |
177 | 197 |
178 private: | 198 private: |
179 bool use_surfaceless_; | 199 bool use_surfaceless_; |
180 scoped_ptr<GlApiLoader> gl_api_loader_; | 200 scoped_ptr<GlApiLoader> gl_api_loader_; |
181 scoped_refptr<GbmWrapper> gbm_; | 201 scoped_refptr<GbmWrapper> gbm_; |
182 scoped_ptr<DrmDeviceManager> drm_device_manager_; | 202 scoped_ptr<DrmDeviceManager> drm_device_manager_; |
(...skipping 26 matching lines...) Expand all Loading... |
209 OzonePlatform* CreateOzonePlatformGbm() { | 229 OzonePlatform* CreateOzonePlatformGbm() { |
210 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); | 230 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); |
211 #if defined(USE_MESA_PLATFORM_NULL) | 231 #if defined(USE_MESA_PLATFORM_NULL) |
212 // Only works with surfaceless. | 232 // Only works with surfaceless. |
213 cmd->AppendSwitch(switches::kOzoneUseSurfaceless); | 233 cmd->AppendSwitch(switches::kOzoneUseSurfaceless); |
214 #endif | 234 #endif |
215 return new OzonePlatformGbm(cmd->HasSwitch(switches::kOzoneUseSurfaceless)); | 235 return new OzonePlatformGbm(cmd->HasSwitch(switches::kOzoneUseSurfaceless)); |
216 } | 236 } |
217 | 237 |
218 } // namespace ui | 238 } // namespace ui |
OLD | NEW |