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/gbm_surface_factory.h" | 5 #include "ui/ozone/platform/drm/gbm_surface_factory.h" |
6 | 6 |
7 #include <gbm.h> | 7 #include <gbm.h> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "third_party/khronos/EGL/egl.h" | 11 #include "third_party/khronos/EGL/egl.h" |
12 #include "ui/ozone/common/egl_util.h" | 12 #include "ui/ozone/common/egl_util.h" |
13 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h" | 13 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h" |
14 #include "ui/ozone/platform/drm/gpu/drm_window.h" | 14 #include "ui/ozone/platform/drm/gpu/drm_window.h" |
15 #include "ui/ozone/platform/drm/gpu/gbm_buffer.h" | 15 #include "ui/ozone/platform/drm/gpu/gbm_buffer.h" |
16 #include "ui/ozone/platform/drm/gpu/gbm_device.h" | 16 #include "ui/ozone/platform/drm/gpu/gbm_device.h" |
17 #include "ui/ozone/platform/drm/gpu/gbm_surface.h" | 17 #include "ui/ozone/platform/drm/gpu/gbm_surface.h" |
18 #include "ui/ozone/platform/drm/gpu/gbm_surfaceless.h" | 18 #include "ui/ozone/platform/drm/gpu/gbm_surfaceless.h" |
19 #include "ui/ozone/platform/drm/gpu/hardware_display_controller.h" | 19 #include "ui/ozone/platform/drm/gpu/hardware_display_controller.h" |
20 #include "ui/ozone/platform/drm/gpu/screen_manager.h" | 20 #include "ui/ozone/platform/drm/gpu/screen_manager.h" |
21 #include "ui/ozone/public/native_pixmap.h" | 21 #include "ui/ozone/public/native_pixmap.h" |
22 #include "ui/ozone/public/overlay_candidates_ozone.h" | 22 #include "ui/ozone/public/overlay_candidates_ozone.h" |
23 #include "ui/ozone/public/ozone_switches.h" | 23 #include "ui/ozone/public/ozone_switches.h" |
24 #include "ui/ozone/public/surface_ozone_canvas.h" | 24 #include "ui/ozone/public/surface_ozone_canvas.h" |
25 #include "ui/ozone/public/surface_ozone_egl.h" | 25 #include "ui/ozone/public/surface_ozone_egl.h" |
26 | 26 |
| 27 #if defined(ARCH_CPU_X86_FAMILY) |
| 28 #include "ui/ozone/platform/drm/gpu/gbm_map_pixmap_intel.h" |
| 29 #endif |
| 30 |
27 namespace ui { | 31 namespace ui { |
28 namespace { | 32 namespace { |
29 | 33 |
30 class SingleOverlay : public OverlayCandidatesOzone { | 34 class SingleOverlay : public OverlayCandidatesOzone { |
31 public: | 35 public: |
32 SingleOverlay() {} | 36 SingleOverlay() {} |
33 ~SingleOverlay() override {} | 37 ~SingleOverlay() override {} |
34 | 38 |
35 void CheckOverlaySupport(OverlaySurfaceCandidateList* candidates) override { | 39 void CheckOverlaySupport(OverlaySurfaceCandidateList* candidates) override { |
36 if (candidates->size() == 2) { | 40 if (candidates->size() == 2) { |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 return nullptr; | 155 return nullptr; |
152 | 156 |
153 return make_scoped_ptr(new GbmSurfaceless(screen_manager_->GetWindow(widget), | 157 return make_scoped_ptr(new GbmSurfaceless(screen_manager_->GetWindow(widget), |
154 drm_device_manager_)); | 158 drm_device_manager_)); |
155 } | 159 } |
156 | 160 |
157 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap( | 161 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap( |
158 gfx::AcceleratedWidget widget, | 162 gfx::AcceleratedWidget widget, |
159 gfx::Size size, | 163 gfx::Size size, |
160 BufferFormat format, | 164 BufferFormat format, |
161 BufferUsage usage) { | 165 BufferUsage usage, |
162 if (usage == MAP) | 166 gfx::GpuMemoryBufferHandle* handle) { |
163 return nullptr; | 167 DCHECK(handle || usage == SCANOUT); |
164 | |
165 scoped_refptr<GbmDevice> gbm = GetGbmDevice(widget); | 168 scoped_refptr<GbmDevice> gbm = GetGbmDevice(widget); |
166 DCHECK(gbm); | 169 DCHECK(gbm); |
167 | 170 |
168 scoped_refptr<GbmBuffer> buffer = | 171 #if defined(ARCH_CPU_X86_FAMILY) |
169 GbmBuffer::CreateBuffer(gbm, format, size, true); | 172 if (usage == MAP) { |
| 173 scoped_refptr<GbmMapPixmapIntel> pixmap = |
| 174 GbmMapPixmapIntel::CreatePixmap(gbm, format, size, handle); |
| 175 if (!pixmap.get()) |
| 176 return nullptr; |
| 177 return pixmap; |
| 178 } |
| 179 #endif |
| 180 |
| 181 scoped_refptr<GbmBuffer> buffer = GbmBuffer::CreateBuffer(gbm, format, size); |
170 if (!buffer.get()) | 182 if (!buffer.get()) |
171 return nullptr; | 183 return nullptr; |
172 | 184 |
173 scoped_refptr<GbmPixmap> pixmap(new GbmPixmap(buffer)); | 185 scoped_refptr<GbmPixmap> pixmap(new GbmPixmap(buffer)); |
174 if (!pixmap->Initialize()) | 186 if (!pixmap->Initialize()) |
175 return nullptr; | 187 return nullptr; |
176 | 188 |
177 return pixmap; | 189 return pixmap; |
178 } | 190 } |
179 | 191 |
(...skipping 28 matching lines...) Expand all Loading... |
208 return true; | 220 return true; |
209 } | 221 } |
210 | 222 |
211 bool GbmSurfaceFactory::CanShowPrimaryPlaneAsOverlay() { | 223 bool GbmSurfaceFactory::CanShowPrimaryPlaneAsOverlay() { |
212 return allow_surfaceless_; | 224 return allow_surfaceless_; |
213 } | 225 } |
214 | 226 |
215 bool GbmSurfaceFactory::CanCreateNativePixmap(BufferUsage usage) { | 227 bool GbmSurfaceFactory::CanCreateNativePixmap(BufferUsage usage) { |
216 switch (usage) { | 228 switch (usage) { |
217 case MAP: | 229 case MAP: |
218 return false; | |
219 case SCANOUT: | 230 case SCANOUT: |
220 return true; | 231 return true; |
221 } | 232 } |
222 NOTREACHED(); | 233 NOTREACHED(); |
223 return false; | 234 return false; |
224 } | 235 } |
225 | 236 |
226 scoped_refptr<GbmDevice> GbmSurfaceFactory::GetGbmDevice( | 237 scoped_refptr<GbmDevice> GbmSurfaceFactory::GetGbmDevice( |
227 gfx::AcceleratedWidget widget) { | 238 gfx::AcceleratedWidget widget) { |
228 return static_cast<GbmDevice*>( | 239 return static_cast<GbmDevice*>( |
229 drm_device_manager_->GetDrmDevice(widget).get()); | 240 drm_device_manager_->GetDrmDevice(widget).get()); |
230 } | 241 } |
231 | 242 |
232 } // namespace ui | 243 } // namespace ui |
OLD | NEW |