Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Unified Diff: ui/gfx/mojo/buffer_types_traits.cc

Issue 2537423004: mus: Add support for sending IOSurface mach_ports over mojo. (Closed)
Patch Set: . Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
}
« mojo/public/cpp/system/platform_handle.cc ('K') | « ui/gfx/mojo/buffer_types_traits.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698