Index: ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.cc |
diff --git a/ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.cc b/ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.cc |
index babdc6767d6b73391733ef3b1407cf020a2a0ba0..1d1d4af239adb38cbf8f80539a67b3f5003af948 100644 |
--- a/ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.cc |
+++ b/ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.cc |
@@ -75,6 +75,7 @@ class GLImageOzoneNativePixmapDmaBuf : public gfx::GLImageLinuxDMABuffer { |
gfx::OverlayTransform transform, |
const gfx::Rect& bounds_rect, |
const gfx::RectF& crop_rect) override { |
+ DCHECK_EQ(pixmap_->GetBufferUsage(), NativePixmap::SCANOUT); |
return OzonePlatform::GetInstance() |
->GetSurfaceFactoryOzone() |
->ScheduleOverlayPlane(widget, z_order, transform, pixmap_, bounds_rect, |
@@ -141,7 +142,8 @@ GpuMemoryBufferFactoryOzoneNativeBuffer:: |
~GpuMemoryBufferFactoryOzoneNativeBuffer() { |
} |
-bool GpuMemoryBufferFactoryOzoneNativeBuffer::CreateGpuMemoryBuffer( |
+gfx::GpuMemoryBufferHandle |
+GpuMemoryBufferFactoryOzoneNativeBuffer::CreateGpuMemoryBuffer( |
gfx::GpuMemoryBufferId id, |
const gfx::Size& size, |
gfx::GpuMemoryBuffer::Format format, |
@@ -156,11 +158,22 @@ bool GpuMemoryBufferFactoryOzoneNativeBuffer::CreateGpuMemoryBuffer( |
if (!pixmap.get()) { |
LOG(ERROR) << "Failed to create pixmap " << size.width() << "x" |
<< size.height() << " format " << format << ", usage " << usage; |
- return false; |
+ return gfx::GpuMemoryBufferHandle(); |
} |
+ |
+ gfx::GpuMemoryBufferHandle handle; |
+ handle.type = gfx::OZONE_NATIVE_BUFFER; |
+ handle.id = id; |
+ if (usage == gfx::GpuMemoryBuffer::MAP) { |
+ handle.handle = |
+ OzonePlatform::GetInstance()->GetSurfaceFactoryOzone()->ExportDmaBuf( |
+ surface_handle, pixmap); |
+ DCHECK(handle.handle.fd > 0) << "Fail to export dma_buf."; |
+ } |
+ |
base::AutoLock lock(native_pixmap_map_lock_); |
native_pixmap_map_[GetIndex(id, client_id)] = pixmap; |
- return true; |
+ return handle; |
} |
void GpuMemoryBufferFactoryOzoneNativeBuffer::DestroyGpuMemoryBuffer( |