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/gpu/gbm_surface_factory.h" | 5 #include "ui/ozone/platform/drm/gpu/gbm_surface_factory.h" |
6 | 6 |
7 #include <gbm.h> | 7 #include <gbm.h> |
8 | 8 |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/posix/eintr_wrapper.h" | 10 #include "base/posix/eintr_wrapper.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/surface_ozone_canvas.h" | 22 #include "ui/ozone/public/surface_ozone_canvas.h" |
23 #include "ui/ozone/public/surface_ozone_egl.h" | 23 #include "ui/ozone/public/surface_ozone_egl.h" |
24 | 24 |
| 25 #include "base/command_line.h" |
| 26 #include "ui/ozone/platform/drm/gpu/intel_drm_pixmap.h" |
| 27 #include "ui/ozone/public/ozone_switches.h" |
| 28 |
25 namespace ui { | 29 namespace ui { |
26 | 30 |
27 namespace { | 31 namespace { |
28 | 32 |
29 bool ShareToRenderProcess(int fd, base::FileDescriptor* new_handle) { | 33 bool ShareToRenderProcess(int fd, base::FileDescriptor* new_handle) { |
30 int duped_handle = HANDLE_EINTR(dup(fd)); | 34 int duped_handle = HANDLE_EINTR(dup(fd)); |
31 if (duped_handle < 0) { | 35 if (duped_handle < 0) { |
32 DPLOG(ERROR) << "dup() failed."; | 36 DPLOG(ERROR) << "dup() failed."; |
33 *new_handle = base::FileDescriptor(); | 37 *new_handle = base::FileDescriptor(); |
34 return false; | 38 return false; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 } | 127 } |
124 | 128 |
125 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap( | 129 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap( |
126 gfx::AcceleratedWidget widget, | 130 gfx::AcceleratedWidget widget, |
127 gfx::Size size, | 131 gfx::Size size, |
128 BufferFormat format, | 132 BufferFormat format, |
129 BufferUsage usage) { | 133 BufferUsage usage) { |
130 scoped_refptr<GbmDevice> gbm = GetGbmDevice(widget); | 134 scoped_refptr<GbmDevice> gbm = GetGbmDevice(widget); |
131 DCHECK(gbm); | 135 DCHECK(gbm); |
132 | 136 |
| 137 bool enable_intel_drm = base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 138 switches::kOzoneUseIntelDrm); |
| 139 if (enable_intel_drm && usage == MAP) { |
| 140 scoped_refptr<IntelDrmPixmap> pixmap = IntelDrmPixmap::Create( |
| 141 base::FileDescriptor(gbm->get_fd(), false), format, size); |
| 142 if (!pixmap.get()) |
| 143 return nullptr; |
| 144 return pixmap; |
| 145 } |
| 146 |
133 scoped_refptr<GbmBuffer> buffer = | 147 scoped_refptr<GbmBuffer> buffer = |
134 GbmBuffer::CreateBuffer(gbm, format, size, usage == SCANOUT); | 148 GbmBuffer::CreateBuffer(gbm, format, size, usage == SCANOUT); |
135 if (!buffer.get()) | 149 if (!buffer.get()) |
136 return nullptr; | 150 return nullptr; |
137 | 151 |
138 scoped_refptr<GbmPixmap> pixmap(new GbmPixmap(buffer, screen_manager_)); | 152 scoped_refptr<GbmPixmap> pixmap(new GbmPixmap(buffer, screen_manager_)); |
139 if (!pixmap->Initialize()) | 153 if (!pixmap->Initialize()) |
140 return nullptr; | 154 return nullptr; |
141 | 155 |
142 return pixmap; | 156 return pixmap; |
(...skipping 20 matching lines...) Expand all Loading... |
163 return allow_surfaceless_; | 177 return allow_surfaceless_; |
164 } | 178 } |
165 | 179 |
166 scoped_refptr<GbmDevice> GbmSurfaceFactory::GetGbmDevice( | 180 scoped_refptr<GbmDevice> GbmSurfaceFactory::GetGbmDevice( |
167 gfx::AcceleratedWidget widget) { | 181 gfx::AcceleratedWidget widget) { |
168 return static_cast<GbmDevice*>( | 182 return static_cast<GbmDevice*>( |
169 drm_device_manager_->GetDrmDevice(widget).get()); | 183 drm_device_manager_->GetDrmDevice(widget).get()); |
170 } | 184 } |
171 | 185 |
172 } // namespace ui | 186 } // namespace ui |
OLD | NEW |