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" |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 return nullptr; | 143 return nullptr; |
144 | 144 |
145 return make_scoped_ptr(new GbmSurfaceless(screen_manager_->GetWindow(widget), | 145 return make_scoped_ptr(new GbmSurfaceless(screen_manager_->GetWindow(widget), |
146 drm_device_manager_)); | 146 drm_device_manager_)); |
147 } | 147 } |
148 | 148 |
149 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap( | 149 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap( |
150 gfx::AcceleratedWidget widget, | 150 gfx::AcceleratedWidget widget, |
151 gfx::Size size, | 151 gfx::Size size, |
152 BufferFormat format, | 152 BufferFormat format, |
153 BufferUsage usage) { | 153 BufferUsage usage, |
154 if (usage == MAP) | 154 gfx::GpuMemoryBufferHandle* handle) { |
155 return nullptr; | 155 DCHECK(handle || usage == SCANOUT); |
156 | |
157 scoped_refptr<GbmDevice> gbm = GetGbmDevice(widget); | 156 scoped_refptr<GbmDevice> gbm = GetGbmDevice(widget); |
158 DCHECK(gbm); | 157 DCHECK(gbm); |
159 | 158 |
160 scoped_refptr<GbmBuffer> buffer = | 159 scoped_refptr<GbmBuffer> buffer = |
161 GbmBuffer::CreateBuffer(gbm, format, size, true); | 160 GbmBuffer::CreateBuffer(gbm, format, size, usage == SCANOUT); |
162 if (!buffer.get()) | 161 if (!buffer.get()) |
163 return nullptr; | 162 return nullptr; |
164 | 163 |
165 scoped_refptr<GbmPixmap> pixmap(new GbmPixmap(buffer)); | 164 scoped_refptr<GbmPixmap> pixmap(new GbmPixmap(buffer)); |
166 if (!pixmap->Initialize()) | 165 if (!pixmap->Initialize()) |
167 return nullptr; | 166 return nullptr; |
168 | 167 |
| 168 if (usage == MAP) { |
| 169 DCHECK(handle); |
| 170 pixmap->ExportDmaBuf(drm_device_manager_->GetVgemDevice(), handle); |
| 171 } |
| 172 |
169 return pixmap; | 173 return pixmap; |
170 } | 174 } |
171 | 175 |
172 OverlayCandidatesOzone* GbmSurfaceFactory::GetOverlayCandidates( | 176 OverlayCandidatesOzone* GbmSurfaceFactory::GetOverlayCandidates( |
173 gfx::AcceleratedWidget w) { | 177 gfx::AcceleratedWidget w) { |
174 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 178 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
175 switches::kOzoneTestSingleOverlaySupport)) | 179 switches::kOzoneTestSingleOverlaySupport)) |
176 return new SingleOverlay(); | 180 return new SingleOverlay(); |
177 return NULL; | 181 return NULL; |
178 } | 182 } |
(...skipping 16 matching lines...) Expand all Loading... |
195 return true; | 199 return true; |
196 } | 200 } |
197 | 201 |
198 bool GbmSurfaceFactory::CanShowPrimaryPlaneAsOverlay() { | 202 bool GbmSurfaceFactory::CanShowPrimaryPlaneAsOverlay() { |
199 return allow_surfaceless_; | 203 return allow_surfaceless_; |
200 } | 204 } |
201 | 205 |
202 bool GbmSurfaceFactory::CanCreateNativePixmap(BufferUsage usage) { | 206 bool GbmSurfaceFactory::CanCreateNativePixmap(BufferUsage usage) { |
203 switch (usage) { | 207 switch (usage) { |
204 case MAP: | 208 case MAP: |
205 return false; | |
206 case SCANOUT: | 209 case SCANOUT: |
207 return true; | 210 return true; |
208 } | 211 } |
209 NOTREACHED(); | 212 NOTREACHED(); |
210 return false; | 213 return false; |
211 } | 214 } |
212 | 215 |
213 scoped_refptr<GbmDevice> GbmSurfaceFactory::GetGbmDevice( | 216 scoped_refptr<GbmDevice> GbmSurfaceFactory::GetGbmDevice( |
214 gfx::AcceleratedWidget widget) { | 217 gfx::AcceleratedWidget widget) { |
215 return static_cast<GbmDevice*>( | 218 return static_cast<GbmDevice*>( |
216 drm_device_manager_->GetDrmDevice(widget).get()); | 219 drm_device_manager_->GetDrmDevice(widget).get()); |
217 } | 220 } |
218 | 221 |
219 } // namespace ui | 222 } // namespace ui |
OLD | NEW |