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

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

Issue 2534533002: gfx: Fix [de]serializing non-shm GpuMemoryBufferHandle. (Closed)
Patch Set: test Created 4 years, 1 month 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
« no previous file with comments | « no previous file | ui/gfx/mojo/struct_traits_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 42fa1b824e1e36effc1df93e5b53eb260e1c651e..891b30092fe649b5f847a4aceb1bfb981374f430 100644
--- a/ui/gfx/mojo/buffer_types_traits.cc
+++ b/ui/gfx/mojo/buffer_types_traits.cc
@@ -63,7 +63,7 @@ bool StructTraits<
mojo::ScopedHandle StructTraits<gfx::mojom::GpuMemoryBufferHandleDataView,
gfx::GpuMemoryBufferHandle>::
shared_memory_handle(const gfx::GpuMemoryBufferHandle& handle) {
- if (handle.is_null())
+ if (handle.type != gfx::SHARED_MEMORY_BUFFER)
return mojo::ScopedHandle();
base::PlatformFile platform_file = base::kInvalidPlatformFile;
#if defined(OS_WIN)
@@ -95,30 +95,31 @@ bool StructTraits<gfx::mojom::GpuMemoryBufferHandleDataView,
if (!data.ReadType(&out->type) || !data.ReadId(&out->id))
return false;
- mojo::ScopedHandle handle = data.TakeSharedMemoryHandle();
- if (handle.is_valid()) {
- base::PlatformFile platform_file;
- MojoResult unwrap_result = mojo::UnwrapPlatformFile(
- std::move(handle), &platform_file);
- if (unwrap_result != MOJO_RESULT_OK)
- return false;
+ if (out->type == gfx::SHARED_MEMORY_BUFFER) {
+ mojo::ScopedHandle handle = data.TakeSharedMemoryHandle();
+ if (handle.is_valid()) {
+ base::PlatformFile platform_file;
+ MojoResult unwrap_result =
+ mojo::UnwrapPlatformFile(std::move(handle), &platform_file);
+ if (unwrap_result != MOJO_RESULT_OK)
+ return false;
#if defined(OS_WIN)
- out->handle =
- base::SharedMemoryHandle(platform_file, base::GetCurrentProcId());
+ out->handle =
+ base::SharedMemoryHandle(platform_file, base::GetCurrentProcId());
#elif defined(OS_MACOSX) || defined(OS_IOS)
- // TODO: Add support for mach_port on mac.
- out->handle = base::SharedMemoryHandle();
+ // TODO: Add support for mach_port on mac.
+ out->handle = base::SharedMemoryHandle();
#else
- out->handle = base::SharedMemoryHandle(platform_file, true);
+ out->handle = base::SharedMemoryHandle(platform_file, true);
#endif
- } else {
- out->handle = base::SharedMemoryHandle();
- }
+ }
- out->offset = data.offset();
- out->stride = data.stride();
+ out->offset = data.offset();
+ out->stride = data.stride();
+ }
#if defined(USE_OZONE)
- if (!data.ReadNativePixmapHandle(&out->native_pixmap_handle))
+ if (out->type == gfx::OZONE_NATIVE_PIXMAP &&
+ !data.ReadNativePixmapHandle(&out->native_pixmap_handle))
return false;
#endif
return true;
« no previous file with comments | « no previous file | ui/gfx/mojo/struct_traits_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698