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 {
uint64 size;
// A platform-specific handle the underlying memory object.
handle buffer_handle;
handle<platform> buffer_handle;
};
// gfx::NativePixmapHandle
......@@ -81,7 +81,7 @@ struct NativePixmapHandle {
struct AHardwareBufferHandle {
// The actual file descriptor used to wrap the AHardwareBuffer object for
// serialization.
handle buffer_handle;
handle<platform> buffer_handle;
// A message pipe handle which tracks the lifetime of this
// AHardwareBufferHandle. The sender may use this to observe the lifetime
......
......@@ -25,13 +25,13 @@ bool StructTraits<gfx::mojom::BufferUsageAndFormatDataView,
}
#if defined(OS_LINUX) || defined(USE_OZONE)
mojo::ScopedHandle StructTraits<
mojo::PlatformHandle StructTraits<
gfx::mojom::NativePixmapPlaneDataView,
gfx::NativePixmapPlane>::buffer_handle(gfx::NativePixmapPlane& plane) {
#if defined(OS_LINUX)
return mojo::WrapPlatformFile(plane.fd.release());
return mojo::PlatformHandle(std::move(plane.fd));
#elif defined(OS_FUCHSIA)
return mojo::WrapPlatformHandle(mojo::PlatformHandle(std::move(plane.vmo)));
return mojo::PlatformHandle(std::move(plane.vmo));
#endif // defined(OS_LINUX)
}
......@@ -43,8 +43,7 @@ bool StructTraits<
out->offset = data.offset();
out->size = data.size();
mojo::PlatformHandle handle =
mojo::UnwrapPlatformHandle(data.TakeBufferHandle());
mojo::PlatformHandle handle = data.TakeBufferHandle();
#if defined(OS_LINUX)
if (!handle.is_fd())
return false;
......@@ -119,9 +118,8 @@ gfx::mojom::GpuMemoryBufferPlatformHandlePtr StructTraits<
// closed. We will eventually detect this and release the AHB reference.
mojo::MessagePipe tracking_pipe;
auto wrapped_handle = gfx::mojom::AHardwareBufferHandle::New(
mojo::WrapPlatformFile(
handle.android_hardware_buffer.SerializeAsFileDescriptor()
.release()),
mojo::PlatformHandle(
handle.android_hardware_buffer.SerializeAsFileDescriptor()),
std::move(tracking_pipe.handle0));
// Pass ownership of the input handle to our tracking pipe to keep the AHB
......@@ -201,13 +199,9 @@ bool StructTraits<gfx::mojom::GpuMemoryBufferHandleDataView,
if (!buffer_handle)
return false;
base::PlatformFile fd;
MojoResult unwrap_result = mojo::UnwrapPlatformFile(
std::move(buffer_handle->buffer_handle), &fd);
base::ScopedFD scoped_fd(fd);
if (unwrap_result != MOJO_RESULT_OK || !scoped_fd.is_valid())
base::ScopedFD scoped_fd = buffer_handle->buffer_handle.TakeFD();
if (!scoped_fd.is_valid())
return false;
out->android_hardware_buffer = base::android::ScopedHardwareBufferHandle::
DeserializeFromFileDescriptor(std::move(scoped_fd));
return out->android_hardware_buffer.is_valid();
......
......@@ -207,7 +207,7 @@ struct StructTraits<gfx::mojom::NativePixmapPlaneDataView,
static uint64_t size(const gfx::NativePixmapPlane& plane) {
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,
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