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

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

Issue 2298003002: gfx: Struct traits for GpuMemoryBufferHandle. (Closed)
Patch Set: . Created 4 years, 4 months 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.h
diff --git a/ui/gfx/mojo/buffer_types_traits.h b/ui/gfx/mojo/buffer_types_traits.h
index f63aeba3931347bb8f6d65e9b3d9b85c29160dd1..50c4889836bbbbbdb87c59735342834baf609989 100644
--- a/ui/gfx/mojo/buffer_types_traits.h
+++ b/ui/gfx/mojo/buffer_types_traits.h
@@ -195,6 +195,74 @@ struct StructTraits<gfx::mojom::GpuMemoryBufferIdDataView,
}
};
+template <>
+struct StructTraits<gfx::mojom::NativePixmapPlaneDataView,
+ gfx::NativePixmapPlane> {
+ static int32_t stride(const gfx::NativePixmapPlane& plane) {
+ return plane.stride;
+ }
+ static int32_t offset(const gfx::NativePixmapPlane& plane) {
+ return plane.offset;
+ }
+ static uint64_t modifier(const gfx::NativePixmapPlane& plane) {
+ return plane.modifier;
+ }
+ static bool Read(gfx::mojom::NativePixmapPlaneDataView data,
+ gfx::NativePixmapPlane* out) {
+ out->stride = data.stride();
+ out->offset = data.offset();
+ out->modifier = data.modifier();
+ return true;
+ }
+};
+
+template <>
+struct StructTraits<gfx::mojom::NativePixmapHandleDataView,
+ gfx::NativePixmapHandle> {
+ static bool IsNull(const gfx::NativePixmapHandle& handle) {
+#if defined(USE_OZONE)
+ return false;
+#else
+ // NativePixmapHandle are not used on non-ozone platforms.
+ return true;
+#endif
+ }
+ static std::vector<mojo::ScopedHandle> fds(
Fady Samuel 2016/08/31 17:06:02 This will create a copy of the vector which may be
sadrul 2016/08/31 19:53:19 We return a vector with a move here. I think that
+ const gfx::NativePixmapHandle& pixmap_handle);
+
+ static const std::vector<gfx::NativePixmapPlane>& planes(
+ const gfx::NativePixmapHandle& pixmap_handle) {
+ return pixmap_handle.planes;
+ }
+
+ static bool Read(gfx::mojom::NativePixmapHandleDataView data,
+ gfx::NativePixmapHandle* out);
+};
+
+template <>
+struct StructTraits<gfx::mojom::GpuMemoryBufferHandleDataView,
+ gfx::GpuMemoryBufferHandle> {
+ static gfx::GpuMemoryBufferType type(
+ const gfx::GpuMemoryBufferHandle& handle) {
+ return handle.type;
+ }
+ static gfx::GpuMemoryBufferId id(const gfx::GpuMemoryBufferHandle& handle) {
+ return handle.id;
+ }
+ static mojo::ScopedHandle shared_memory_handle(
+ const gfx::GpuMemoryBufferHandle& handle);
+ static uint32_t offset(const gfx::GpuMemoryBufferHandle& handle) {
+ return handle.offset;
+ }
+ static int32_t stride(const gfx::GpuMemoryBufferHandle& handle) {
+ return handle.stride;
+ }
+ static const gfx::NativePixmapHandle& native_pixmap_handle(
+ const gfx::GpuMemoryBufferHandle& handle);
+ static bool Read(gfx::mojom::GpuMemoryBufferHandleDataView data,
+ gfx::GpuMemoryBufferHandle* handle);
+};
+
} // namespace mojo
#endif // UI_GFX_MOJO_BUFFER_TYPES_TRAITS_H_

Powered by Google App Engine
This is Rietveld 408576698