OLD | NEW |
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 | 17 |
18 namespace mojo { | 18 namespace mojo { |
19 | 19 |
20 template <> | 20 template <> |
21 struct StructTraits<mojo::Insets, gfx::Insets> { | 21 struct StructTraits<gfx::mojom::Insets, gfx::Insets> { |
22 static int top(const gfx::Insets& p) { return p.top(); } | 22 static int top(const gfx::Insets& p) { return p.top(); } |
23 static int left(const gfx::Insets& p) { return p.left(); } | 23 static int left(const gfx::Insets& p) { return p.left(); } |
24 static int bottom(const gfx::Insets& p) { return p.bottom(); } | 24 static int bottom(const gfx::Insets& p) { return p.bottom(); } |
25 static int right(const gfx::Insets& p) { return p.right(); } | 25 static int right(const gfx::Insets& p) { return p.right(); } |
26 static bool Read(mojo::InsetsDataView data, gfx::Insets* out) { | 26 static bool Read(gfx::mojom::InsetsDataView data, gfx::Insets* out) { |
27 out->Set(data.top(), data.left(), data.bottom(), data.right()); | 27 out->Set(data.top(), data.left(), data.bottom(), data.right()); |
28 return true; | 28 return true; |
29 } | 29 } |
30 }; | 30 }; |
31 | 31 |
32 template <> | 32 template <> |
33 struct StructTraits<mojo::InsetsF, gfx::InsetsF> { | 33 struct StructTraits<gfx::mojom::InsetsF, gfx::InsetsF> { |
34 static float top(const gfx::InsetsF& p) { return p.top(); } | 34 static float top(const gfx::InsetsF& p) { return p.top(); } |
35 static float left(const gfx::InsetsF& p) { return p.left(); } | 35 static float left(const gfx::InsetsF& p) { return p.left(); } |
36 static float bottom(const gfx::InsetsF& p) { return p.bottom(); } | 36 static float bottom(const gfx::InsetsF& p) { return p.bottom(); } |
37 static float right(const gfx::InsetsF& p) { return p.right(); } | 37 static float right(const gfx::InsetsF& p) { return p.right(); } |
38 static bool Read(mojo::InsetsFDataView data, gfx::InsetsF* out) { | 38 static bool Read(gfx::mojom::InsetsFDataView data, gfx::InsetsF* out) { |
39 out->Set(data.top(), data.left(), data.bottom(), data.right()); | 39 out->Set(data.top(), data.left(), data.bottom(), data.right()); |
40 return true; | 40 return true; |
41 } | 41 } |
42 }; | 42 }; |
43 | 43 |
44 template <> | 44 template <> |
45 struct StructTraits<mojo::Point, gfx::Point> { | 45 struct StructTraits<gfx::mojom::Point, gfx::Point> { |
46 static int x(const gfx::Point& p) { return p.x(); } | 46 static int x(const gfx::Point& p) { return p.x(); } |
47 static int y(const gfx::Point& p) { return p.y(); } | 47 static int y(const gfx::Point& p) { return p.y(); } |
48 static bool Read(mojo::PointDataView data, gfx::Point* out) { | 48 static bool Read(gfx::mojom::PointDataView data, gfx::Point* out) { |
49 out->SetPoint(data.x(), data.y()); | 49 out->SetPoint(data.x(), data.y()); |
50 return true; | 50 return true; |
51 } | 51 } |
52 }; | 52 }; |
53 | 53 |
54 template <> | 54 template <> |
55 struct StructTraits<mojo::PointF, gfx::PointF> { | 55 struct StructTraits<gfx::mojom::PointF, gfx::PointF> { |
56 static float x(const gfx::PointF& p) { return p.x(); } | 56 static float x(const gfx::PointF& p) { return p.x(); } |
57 static float y(const gfx::PointF& p) { return p.y(); } | 57 static float y(const gfx::PointF& p) { return p.y(); } |
58 static bool Read(mojo::PointFDataView data, gfx::PointF* out) { | 58 static bool Read(gfx::mojom::PointFDataView data, gfx::PointF* out) { |
59 out->SetPoint(data.x(), data.y()); | 59 out->SetPoint(data.x(), data.y()); |
60 return true; | 60 return true; |
61 } | 61 } |
62 }; | 62 }; |
63 | 63 |
64 template <> | 64 template <> |
65 struct StructTraits<mojo::Rect, gfx::Rect> { | 65 struct StructTraits<gfx::mojom::Rect, gfx::Rect> { |
66 static int x(const gfx::Rect& p) { return p.x(); } | 66 static int x(const gfx::Rect& p) { return p.x(); } |
67 static int y(const gfx::Rect& p) { return p.y(); } | 67 static int y(const gfx::Rect& p) { return p.y(); } |
68 static int width(const gfx::Rect& p) { return p.width(); } | 68 static int width(const gfx::Rect& p) { return p.width(); } |
69 static int height(const gfx::Rect& p) { return p.height(); } | 69 static int height(const gfx::Rect& p) { return p.height(); } |
70 static bool Read(mojo::RectDataView data, gfx::Rect* out) { | 70 static bool Read(gfx::mojom::RectDataView data, gfx::Rect* out) { |
71 out->SetRect(data.x(), data.y(), data.width(), data.height()); | 71 out->SetRect(data.x(), data.y(), data.width(), data.height()); |
72 return true; | 72 return true; |
73 } | 73 } |
74 }; | 74 }; |
75 | 75 |
76 template <> | 76 template <> |
77 struct StructTraits<mojo::RectF, gfx::RectF> { | 77 struct StructTraits<gfx::mojom::RectF, gfx::RectF> { |
78 static float x(const gfx::RectF& p) { return p.x(); } | 78 static float x(const gfx::RectF& p) { return p.x(); } |
79 static float y(const gfx::RectF& p) { return p.y(); } | 79 static float y(const gfx::RectF& p) { return p.y(); } |
80 static float width(const gfx::RectF& p) { return p.width(); } | 80 static float width(const gfx::RectF& p) { return p.width(); } |
81 static float height(const gfx::RectF& p) { return p.height(); } | 81 static float height(const gfx::RectF& p) { return p.height(); } |
82 static bool Read(mojo::RectFDataView data, gfx::RectF* out) { | 82 static bool Read(gfx::mojom::RectFDataView data, gfx::RectF* out) { |
83 out->SetRect(data.x(), data.y(), data.width(), data.height()); | 83 out->SetRect(data.x(), data.y(), data.width(), data.height()); |
84 return true; | 84 return true; |
85 } | 85 } |
86 }; | 86 }; |
87 | 87 |
88 template <> | 88 template <> |
89 struct StructTraits<mojo::Size, gfx::Size> { | 89 struct StructTraits<gfx::mojom::Size, gfx::Size> { |
90 static int width(const gfx::Size& p) { return p.width(); } | 90 static int width(const gfx::Size& p) { return p.width(); } |
91 static int height(const gfx::Size& p) { return p.height(); } | 91 static int height(const gfx::Size& p) { return p.height(); } |
92 static bool Read(mojo::SizeDataView data, gfx::Size* out) { | 92 static bool Read(gfx::mojom::SizeDataView data, gfx::Size* out) { |
93 out->SetSize(data.width(), data.height()); | 93 out->SetSize(data.width(), data.height()); |
94 return true; | 94 return true; |
95 } | 95 } |
96 }; | 96 }; |
97 | 97 |
98 template <> | 98 template <> |
99 struct StructTraits<mojo::SizeF, gfx::SizeF> { | 99 struct StructTraits<gfx::mojom::SizeF, gfx::SizeF> { |
100 static float width(const gfx::SizeF& p) { return p.width(); } | 100 static float width(const gfx::SizeF& p) { return p.width(); } |
101 static float height(const gfx::SizeF& p) { return p.height(); } | 101 static float height(const gfx::SizeF& p) { return p.height(); } |
102 static bool Read(mojo::SizeFDataView data, gfx::SizeF* out) { | 102 static bool Read(gfx::mojom::SizeFDataView data, gfx::SizeF* out) { |
103 out->SetSize(data.width(), data.height()); | 103 out->SetSize(data.width(), data.height()); |
104 return true; | 104 return true; |
105 } | 105 } |
106 }; | 106 }; |
107 | 107 |
108 } // namespace mojo | 108 } // namespace mojo |
109 | 109 |
110 #endif // UI_GFX_GEOMETRY_MOJO_GEOMETRY_STRUCT_TRAITS_H_ | 110 #endif // UI_GFX_GEOMETRY_MOJO_GEOMETRY_STRUCT_TRAITS_H_ |
OLD | NEW |