Commit b87fe3a6 authored by Robert Sesek's avatar Robert Sesek Committed by Commit Bot

Convert non-Windows ui/gfx/mojom/buffer_types.mojom to handle<platform>

Bug: 710376
Change-Id: I77502444e8598321e069b651dd2eed759e397155
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2066066
Commit-Queue: Robert Sesek <rsesek@chromium.org>
Reviewed-by: default avatarDaniele Castagna <dcastagna@chromium.org>
Cr-Commit-Position: refs/heads/master@{#743237}
parent 982b6071
...@@ -56,7 +56,7 @@ struct NativePixmapPlane { ...@@ -56,7 +56,7 @@ struct NativePixmapPlane {
uint64 size; uint64 size;
// A platform-specific handle the underlying memory object. // A platform-specific handle the underlying memory object.
handle buffer_handle; handle<platform> buffer_handle;
}; };
// gfx::NativePixmapHandle // gfx::NativePixmapHandle
...@@ -81,7 +81,7 @@ struct NativePixmapHandle { ...@@ -81,7 +81,7 @@ struct NativePixmapHandle {
struct AHardwareBufferHandle { struct AHardwareBufferHandle {
// The actual file descriptor used to wrap the AHardwareBuffer object for // The actual file descriptor used to wrap the AHardwareBuffer object for
// serialization. // serialization.
handle buffer_handle; handle<platform> buffer_handle;
// A message pipe handle which tracks the lifetime of this // A message pipe handle which tracks the lifetime of this
// AHardwareBufferHandle. The sender may use this to observe the lifetime // AHardwareBufferHandle. The sender may use this to observe the lifetime
......
...@@ -25,13 +25,13 @@ bool StructTraits<gfx::mojom::BufferUsageAndFormatDataView, ...@@ -25,13 +25,13 @@ bool StructTraits<gfx::mojom::BufferUsageAndFormatDataView,
} }
#if defined(OS_LINUX) || defined(USE_OZONE) #if defined(OS_LINUX) || defined(USE_OZONE)
mojo::ScopedHandle StructTraits< mojo::PlatformHandle StructTraits<
gfx::mojom::NativePixmapPlaneDataView, gfx::mojom::NativePixmapPlaneDataView,
gfx::NativePixmapPlane>::buffer_handle(gfx::NativePixmapPlane& plane) { gfx::NativePixmapPlane>::buffer_handle(gfx::NativePixmapPlane& plane) {
#if defined(OS_LINUX) #if defined(OS_LINUX)
return mojo::WrapPlatformFile(plane.fd.release()); return mojo::PlatformHandle(std::move(plane.fd));
#elif defined(OS_FUCHSIA) #elif defined(OS_FUCHSIA)
return mojo::WrapPlatformHandle(mojo::PlatformHandle(std::move(plane.vmo))); return mojo::PlatformHandle(std::move(plane.vmo));
#endif // defined(OS_LINUX) #endif // defined(OS_LINUX)
} }
...@@ -43,8 +43,7 @@ bool StructTraits< ...@@ -43,8 +43,7 @@ bool StructTraits<
out->offset = data.offset(); out->offset = data.offset();
out->size = data.size(); out->size = data.size();
mojo::PlatformHandle handle = mojo::PlatformHandle handle = data.TakeBufferHandle();
mojo::UnwrapPlatformHandle(data.TakeBufferHandle());
#if defined(OS_LINUX) #if defined(OS_LINUX)
if (!handle.is_fd()) if (!handle.is_fd())
return false; return false;
...@@ -119,9 +118,8 @@ gfx::mojom::GpuMemoryBufferPlatformHandlePtr StructTraits< ...@@ -119,9 +118,8 @@ gfx::mojom::GpuMemoryBufferPlatformHandlePtr StructTraits<
// closed. We will eventually detect this and release the AHB reference. // closed. We will eventually detect this and release the AHB reference.
mojo::MessagePipe tracking_pipe; mojo::MessagePipe tracking_pipe;
auto wrapped_handle = gfx::mojom::AHardwareBufferHandle::New( auto wrapped_handle = gfx::mojom::AHardwareBufferHandle::New(
mojo::WrapPlatformFile( mojo::PlatformHandle(
handle.android_hardware_buffer.SerializeAsFileDescriptor() handle.android_hardware_buffer.SerializeAsFileDescriptor()),
.release()),
std::move(tracking_pipe.handle0)); std::move(tracking_pipe.handle0));
// Pass ownership of the input handle to our tracking pipe to keep the AHB // Pass ownership of the input handle to our tracking pipe to keep the AHB
...@@ -201,13 +199,9 @@ bool StructTraits<gfx::mojom::GpuMemoryBufferHandleDataView, ...@@ -201,13 +199,9 @@ bool StructTraits<gfx::mojom::GpuMemoryBufferHandleDataView,
if (!buffer_handle) if (!buffer_handle)
return false; return false;
base::PlatformFile fd; base::ScopedFD scoped_fd = buffer_handle->buffer_handle.TakeFD();
MojoResult unwrap_result = mojo::UnwrapPlatformFile( if (!scoped_fd.is_valid())
std::move(buffer_handle->buffer_handle), &fd);
base::ScopedFD scoped_fd(fd);
if (unwrap_result != MOJO_RESULT_OK || !scoped_fd.is_valid())
return false; return false;
out->android_hardware_buffer = base::android::ScopedHardwareBufferHandle:: out->android_hardware_buffer = base::android::ScopedHardwareBufferHandle::
DeserializeFromFileDescriptor(std::move(scoped_fd)); DeserializeFromFileDescriptor(std::move(scoped_fd));
return out->android_hardware_buffer.is_valid(); return out->android_hardware_buffer.is_valid();
......
...@@ -207,7 +207,7 @@ struct StructTraits<gfx::mojom::NativePixmapPlaneDataView, ...@@ -207,7 +207,7 @@ struct StructTraits<gfx::mojom::NativePixmapPlaneDataView,
static uint64_t size(const gfx::NativePixmapPlane& plane) { static uint64_t size(const gfx::NativePixmapPlane& plane) {
return plane.size; return plane.size;
} }
static mojo::ScopedHandle buffer_handle(gfx::NativePixmapPlane& plane); static mojo::PlatformHandle buffer_handle(gfx::NativePixmapPlane& plane);
static bool Read(gfx::mojom::NativePixmapPlaneDataView data, static bool Read(gfx::mojom::NativePixmapPlaneDataView data,
gfx::NativePixmapPlane* out); gfx::NativePixmapPlane* out);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment