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

Unified Diff: ui/gfx/geometry/mojo/geometry_struct_traits.h

Issue 2033583002: Implement gfx::Vector2d and gfx::Vector2dF StructTraits (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unnecessary deps Created 4 years, 7 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
« no previous file with comments | « ui/gfx/geometry/mojo/geometry.typemap ('k') | ui/gfx/geometry/mojo/geometry_struct_traits_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/geometry/mojo/geometry_struct_traits.h
diff --git a/ui/gfx/geometry/mojo/geometry_struct_traits.h b/ui/gfx/geometry/mojo/geometry_struct_traits.h
index 41e7b4e374f55b7001e73897bb24439c44452dda..abafe98d4166ac045a4e2d238d7d906e4567143d 100644
--- a/ui/gfx/geometry/mojo/geometry_struct_traits.h
+++ b/ui/gfx/geometry/mojo/geometry_struct_traits.h
@@ -14,6 +14,8 @@
#include "ui/gfx/geometry/rect_f.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/geometry/size_f.h"
+#include "ui/gfx/geometry/vector2d.h"
+#include "ui/gfx/geometry/vector2d_f.h"
namespace mojo {
@@ -105,6 +107,28 @@ struct StructTraits<gfx::mojom::SizeF, gfx::SizeF> {
}
};
+template <>
+struct StructTraits<gfx::mojom::Vector2d, gfx::Vector2d> {
+ static int x(const gfx::Vector2d& v) { return v.x(); }
+ static int y(const gfx::Vector2d& v) { return v.y(); }
+ static bool Read(gfx::mojom::Vector2dDataView data, gfx::Vector2d* out) {
+ out->set_x(data.x());
+ out->set_y(data.y());
+ return true;
+ }
+};
+
+template <>
+struct StructTraits<gfx::mojom::Vector2dF, gfx::Vector2dF> {
+ static float x(const gfx::Vector2dF& v) { return v.x(); }
+ static float y(const gfx::Vector2dF& v) { return v.y(); }
+ static bool Read(gfx::mojom::Vector2dFDataView data, gfx::Vector2dF* out) {
+ out->set_x(data.x());
+ out->set_y(data.y());
+ return true;
+ }
+};
+
} // namespace mojo
#endif // UI_GFX_GEOMETRY_MOJO_GEOMETRY_STRUCT_TRAITS_H_
« no previous file with comments | « ui/gfx/geometry/mojo/geometry.typemap ('k') | ui/gfx/geometry/mojo/geometry_struct_traits_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698