| Index: ui/gfx/mojo/buffer_types_traits.cc
|
| diff --git a/ui/gfx/mojo/buffer_types_traits.cc b/ui/gfx/mojo/buffer_types_traits.cc
|
| index 891b30092fe649b5f847a4aceb1bfb981374f430..b5b8bbde324010396eff6f39f19c3f7c3092fa5c 100644
|
| --- a/ui/gfx/mojo/buffer_types_traits.cc
|
| +++ b/ui/gfx/mojo/buffer_types_traits.cc
|
| @@ -88,6 +88,18 @@ StructTraits<gfx::mojom::GpuMemoryBufferHandleDataView,
|
| #endif
|
| }
|
|
|
| +mojo::ScopedHandle StructTraits<gfx::mojom::GpuMemoryBufferHandleDataView,
|
| + gfx::GpuMemoryBufferHandle>::
|
| + mach_port(const gfx::GpuMemoryBufferHandle& handle) {
|
| +#if defined(OS_MACOSX) && !defined(OS_IOS)
|
| + if (handle.type != gfx::IO_SURFACE_BUFFER)
|
| + return mojo::ScopedHandle();
|
| + return mojo::WrapMachPort(handle.mach_port.get());
|
| +#else
|
| + return mojo::ScopedHandle();
|
| +#endif
|
| +}
|
| +
|
| bool StructTraits<gfx::mojom::GpuMemoryBufferHandleDataView,
|
| gfx::GpuMemoryBufferHandle>::
|
| Read(gfx::mojom::GpuMemoryBufferHandleDataView data,
|
| @@ -122,6 +134,16 @@ bool StructTraits<gfx::mojom::GpuMemoryBufferHandleDataView,
|
| !data.ReadNativePixmapHandle(&out->native_pixmap_handle))
|
| return false;
|
| #endif
|
| +#if defined(OS_MACOSX) && !defined(OS_IOS)
|
| + if (out->type == gfx::IO_SURFACE_BUFFER) {
|
| + mach_port_t mach_port;
|
| + MojoResult unwrap_result =
|
| + mojo::UnwrapMachPort(data.TakeMachPort(), &mach_port);
|
| + if (unwrap_result != MOJO_RESULT_OK)
|
| + return false;
|
| + out->mach_port.reset(mach_port);
|
| + }
|
| +#endif
|
| return true;
|
| }
|
|
|
|
|