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

Side by Side 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, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_GFX_GEOMETRY_MOJO_GEOMETRY_STRUCT_TRAITS_H_ 5 #ifndef UI_GFX_GEOMETRY_MOJO_GEOMETRY_STRUCT_TRAITS_H_
6 #define UI_GFX_GEOMETRY_MOJO_GEOMETRY_STRUCT_TRAITS_H_ 6 #define UI_GFX_GEOMETRY_MOJO_GEOMETRY_STRUCT_TRAITS_H_
7 7
8 #include "ui/gfx/geometry/insets.h" 8 #include "ui/gfx/geometry/insets.h"
9 #include "ui/gfx/geometry/insets_f.h" 9 #include "ui/gfx/geometry/insets_f.h"
10 #include "ui/gfx/geometry/mojo/geometry.mojom.h" 10 #include "ui/gfx/geometry/mojo/geometry.mojom.h"
11 #include "ui/gfx/geometry/point.h" 11 #include "ui/gfx/geometry/point.h"
12 #include "ui/gfx/geometry/point_f.h" 12 #include "ui/gfx/geometry/point_f.h"
13 #include "ui/gfx/geometry/rect.h" 13 #include "ui/gfx/geometry/rect.h"
14 #include "ui/gfx/geometry/rect_f.h" 14 #include "ui/gfx/geometry/rect_f.h"
15 #include "ui/gfx/geometry/size.h" 15 #include "ui/gfx/geometry/size.h"
16 #include "ui/gfx/geometry/size_f.h" 16 #include "ui/gfx/geometry/size_f.h"
17 #include "ui/gfx/geometry/vector2d.h"
18 #include "ui/gfx/geometry/vector2d_f.h"
17 19
18 namespace mojo { 20 namespace mojo {
19 21
20 template <> 22 template <>
21 struct StructTraits<gfx::mojom::Insets, gfx::Insets> { 23 struct StructTraits<gfx::mojom::Insets, gfx::Insets> {
22 static int top(const gfx::Insets& p) { return p.top(); } 24 static int top(const gfx::Insets& p) { return p.top(); }
23 static int left(const gfx::Insets& p) { return p.left(); } 25 static int left(const gfx::Insets& p) { return p.left(); }
24 static int bottom(const gfx::Insets& p) { return p.bottom(); } 26 static int bottom(const gfx::Insets& p) { return p.bottom(); }
25 static int right(const gfx::Insets& p) { return p.right(); } 27 static int right(const gfx::Insets& p) { return p.right(); }
26 static bool Read(gfx::mojom::InsetsDataView data, gfx::Insets* out) { 28 static bool Read(gfx::mojom::InsetsDataView data, gfx::Insets* out) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 template <> 100 template <>
99 struct StructTraits<gfx::mojom::SizeF, gfx::SizeF> { 101 struct StructTraits<gfx::mojom::SizeF, gfx::SizeF> {
100 static float width(const gfx::SizeF& p) { return p.width(); } 102 static float width(const gfx::SizeF& p) { return p.width(); }
101 static float height(const gfx::SizeF& p) { return p.height(); } 103 static float height(const gfx::SizeF& p) { return p.height(); }
102 static bool Read(gfx::mojom::SizeFDataView data, gfx::SizeF* out) { 104 static bool Read(gfx::mojom::SizeFDataView data, gfx::SizeF* out) {
103 out->SetSize(data.width(), data.height()); 105 out->SetSize(data.width(), data.height());
104 return true; 106 return true;
105 } 107 }
106 }; 108 };
107 109
110 template <>
111 struct StructTraits<gfx::mojom::Vector2d, gfx::Vector2d> {
112 static int x(const gfx::Vector2d& v) { return v.x(); }
113 static int y(const gfx::Vector2d& v) { return v.y(); }
114 static bool Read(gfx::mojom::Vector2dDataView data, gfx::Vector2d* out) {
115 out->set_x(data.x());
116 out->set_y(data.y());
117 return true;
118 }
119 };
120
121 template <>
122 struct StructTraits<gfx::mojom::Vector2dF, gfx::Vector2dF> {
123 static float x(const gfx::Vector2dF& v) { return v.x(); }
124 static float y(const gfx::Vector2dF& v) { return v.y(); }
125 static bool Read(gfx::mojom::Vector2dFDataView data, gfx::Vector2dF* out) {
126 out->set_x(data.x());
127 out->set_y(data.y());
128 return true;
129 }
130 };
131
108 } // namespace mojo 132 } // namespace mojo
109 133
110 #endif // UI_GFX_GEOMETRY_MOJO_GEOMETRY_STRUCT_TRAITS_H_ 134 #endif // UI_GFX_GEOMETRY_MOJO_GEOMETRY_STRUCT_TRAITS_H_
OLDNEW
« 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