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

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

Issue 2295923002: gfx: Struct traits for GpuMemoryBufferId and GpuMemoryBufferType. (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
« ui/gfx/mojo/buffer_types.typemap ('K') | « ui/gfx/mojo/buffer_types.typemap ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/mojo/buffer_types_enum_traits.h
diff --git a/ui/gfx/mojo/buffer_types_enum_traits.h b/ui/gfx/mojo/buffer_types_enum_traits.h
index 163747fa719750fec3692efba7f3c24626ca5e45..53e2ace18acdbd2883c06c4975a3eb97eaba1c94 100644
--- a/ui/gfx/mojo/buffer_types_enum_traits.h
+++ b/ui/gfx/mojo/buffer_types_enum_traits.h
@@ -139,6 +139,62 @@ struct EnumTraits<gfx::mojom::BufferUsage, gfx::BufferUsage> {
}
};
+template <>
+struct EnumTraits<gfx::mojom::GpuMemoryBufferType, gfx::GpuMemoryBufferType> {
+ static gfx::mojom::GpuMemoryBufferType ToMojom(
+ gfx::GpuMemoryBufferType type) {
+ switch (type) {
+ case gfx::GpuMemoryBufferType::EMPTY_BUFFER:
+ return gfx::mojom::GpuMemoryBufferType::EMPTY_BUFFER;
+ case gfx::GpuMemoryBufferType::SHARED_MEMORY_BUFFER:
+ return gfx::mojom::GpuMemoryBufferType::SHARED_MEMORY_BUFFER;
+ case gfx::GpuMemoryBufferType::IO_SURFACE_BUFFER:
+ return gfx::mojom::GpuMemoryBufferType::IO_SURFACE_BUFFER;
+ case gfx::GpuMemoryBufferType::SURFACE_TEXTURE_BUFFER:
+ return gfx::mojom::GpuMemoryBufferType::SURFACE_TEXTURE_BUFFER;
+ case gfx::GpuMemoryBufferType::OZONE_NATIVE_PIXMAP:
+ return gfx::mojom::GpuMemoryBufferType::OZONE_NATIVE_PIXMAP;
+ }
+ NOTREACHED();
+ return gfx::mojom::GpuMemoryBufferType::LAST;
+ }
+
+ static bool FromMojom(gfx::mojom::GpuMemoryBufferType input,
+ gfx::GpuMemoryBufferType* out) {
+ switch (input) {
+ case gfx::mojom::GpuMemoryBufferType::EMPTY_BUFFER:
+ *out = gfx::GpuMemoryBufferType::EMPTY_BUFFER;
+ return true;
+ case gfx::mojom::GpuMemoryBufferType::SHARED_MEMORY_BUFFER:
+ *out = gfx::GpuMemoryBufferType::SHARED_MEMORY_BUFFER;
+ return true;
+ case gfx::mojom::GpuMemoryBufferType::IO_SURFACE_BUFFER:
+ *out = gfx::GpuMemoryBufferType::IO_SURFACE_BUFFER;
+ return true;
+ case gfx::mojom::GpuMemoryBufferType::SURFACE_TEXTURE_BUFFER:
+ *out = gfx::GpuMemoryBufferType::SURFACE_TEXTURE_BUFFER;
+ return true;
+ case gfx::mojom::GpuMemoryBufferType::OZONE_NATIVE_PIXMAP:
+ *out = gfx::GpuMemoryBufferType::OZONE_NATIVE_PIXMAP;
+ return true;
+ }
+ return false;
+ }
+};
+
+template <>
+struct StructTraits<gfx::mojom::GpuMemoryBufferIdDataView,
+ gfx::GpuMemoryBufferId> {
+ static int32_t id(const gfx::GpuMemoryBufferId& buffer_id) {
+ return buffer_id.id;
+ }
+ static bool Read(gfx::mojom::GpuMemoryBufferIdDataView data,
+ gfx::GpuMemoryBufferId* out) {
+ out->id = data.id();
+ return true;
+ }
+};
+
} // namespace mojo
#endif // UI_GFX_MOJO_BUFFER_TYPES_ENUM_TRAITS_H_
« ui/gfx/mojo/buffer_types.typemap ('K') | « ui/gfx/mojo/buffer_types.typemap ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698