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

Side by Side Diff: ui/gfx/geometry/mojo/geometry_struct_traits.h

Issue 2253293002: Mojo C++ bindings: change the first template parameter of StructTraits and UnionTraits. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@91_extra
Patch Set: rebase 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 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" 17 #include "ui/gfx/geometry/vector2d.h"
18 #include "ui/gfx/geometry/vector2d_f.h" 18 #include "ui/gfx/geometry/vector2d_f.h"
19 19
20 namespace mojo { 20 namespace mojo {
21 21
22 template <> 22 template <>
23 struct StructTraits<gfx::mojom::Insets, gfx::Insets> { 23 struct StructTraits<gfx::mojom::InsetsDataView, gfx::Insets> {
24 static int top(const gfx::Insets& p) { return p.top(); } 24 static int top(const gfx::Insets& p) { return p.top(); }
25 static int left(const gfx::Insets& p) { return p.left(); } 25 static int left(const gfx::Insets& p) { return p.left(); }
26 static int bottom(const gfx::Insets& p) { return p.bottom(); } 26 static int bottom(const gfx::Insets& p) { return p.bottom(); }
27 static int right(const gfx::Insets& p) { return p.right(); } 27 static int right(const gfx::Insets& p) { return p.right(); }
28 static bool Read(gfx::mojom::InsetsDataView data, gfx::Insets* out) { 28 static bool Read(gfx::mojom::InsetsDataView data, gfx::Insets* out) {
29 out->Set(data.top(), data.left(), data.bottom(), data.right()); 29 out->Set(data.top(), data.left(), data.bottom(), data.right());
30 return true; 30 return true;
31 } 31 }
32 }; 32 };
33 33
34 template <> 34 template <>
35 struct StructTraits<gfx::mojom::InsetsF, gfx::InsetsF> { 35 struct StructTraits<gfx::mojom::InsetsFDataView, gfx::InsetsF> {
36 static float top(const gfx::InsetsF& p) { return p.top(); } 36 static float top(const gfx::InsetsF& p) { return p.top(); }
37 static float left(const gfx::InsetsF& p) { return p.left(); } 37 static float left(const gfx::InsetsF& p) { return p.left(); }
38 static float bottom(const gfx::InsetsF& p) { return p.bottom(); } 38 static float bottom(const gfx::InsetsF& p) { return p.bottom(); }
39 static float right(const gfx::InsetsF& p) { return p.right(); } 39 static float right(const gfx::InsetsF& p) { return p.right(); }
40 static bool Read(gfx::mojom::InsetsFDataView data, gfx::InsetsF* out) { 40 static bool Read(gfx::mojom::InsetsFDataView data, gfx::InsetsF* out) {
41 out->Set(data.top(), data.left(), data.bottom(), data.right()); 41 out->Set(data.top(), data.left(), data.bottom(), data.right());
42 return true; 42 return true;
43 } 43 }
44 }; 44 };
45 45
46 template <> 46 template <>
47 struct StructTraits<gfx::mojom::Point, gfx::Point> { 47 struct StructTraits<gfx::mojom::PointDataView, gfx::Point> {
48 static int x(const gfx::Point& p) { return p.x(); } 48 static int x(const gfx::Point& p) { return p.x(); }
49 static int y(const gfx::Point& p) { return p.y(); } 49 static int y(const gfx::Point& p) { return p.y(); }
50 static bool Read(gfx::mojom::PointDataView data, gfx::Point* out) { 50 static bool Read(gfx::mojom::PointDataView data, gfx::Point* out) {
51 out->SetPoint(data.x(), data.y()); 51 out->SetPoint(data.x(), data.y());
52 return true; 52 return true;
53 } 53 }
54 }; 54 };
55 55
56 template <> 56 template <>
57 struct StructTraits<gfx::mojom::PointF, gfx::PointF> { 57 struct StructTraits<gfx::mojom::PointFDataView, gfx::PointF> {
58 static float x(const gfx::PointF& p) { return p.x(); } 58 static float x(const gfx::PointF& p) { return p.x(); }
59 static float y(const gfx::PointF& p) { return p.y(); } 59 static float y(const gfx::PointF& p) { return p.y(); }
60 static bool Read(gfx::mojom::PointFDataView data, gfx::PointF* out) { 60 static bool Read(gfx::mojom::PointFDataView data, gfx::PointF* out) {
61 out->SetPoint(data.x(), data.y()); 61 out->SetPoint(data.x(), data.y());
62 return true; 62 return true;
63 } 63 }
64 }; 64 };
65 65
66 template <> 66 template <>
67 struct StructTraits<gfx::mojom::Rect, gfx::Rect> { 67 struct StructTraits<gfx::mojom::RectDataView, gfx::Rect> {
68 static int x(const gfx::Rect& p) { return p.x(); } 68 static int x(const gfx::Rect& p) { return p.x(); }
69 static int y(const gfx::Rect& p) { return p.y(); } 69 static int y(const gfx::Rect& p) { return p.y(); }
70 static int width(const gfx::Rect& p) { return p.width(); } 70 static int width(const gfx::Rect& p) { return p.width(); }
71 static int height(const gfx::Rect& p) { return p.height(); } 71 static int height(const gfx::Rect& p) { return p.height(); }
72 static bool Read(gfx::mojom::RectDataView data, gfx::Rect* out) { 72 static bool Read(gfx::mojom::RectDataView data, gfx::Rect* out) {
73 if (data.width() < 0 || data.height() < 0) 73 if (data.width() < 0 || data.height() < 0)
74 return false; 74 return false;
75 75
76 out->SetRect(data.x(), data.y(), data.width(), data.height()); 76 out->SetRect(data.x(), data.y(), data.width(), data.height());
77 return true; 77 return true;
78 } 78 }
79 }; 79 };
80 80
81 template <> 81 template <>
82 struct StructTraits<gfx::mojom::RectF, gfx::RectF> { 82 struct StructTraits<gfx::mojom::RectFDataView, gfx::RectF> {
83 static float x(const gfx::RectF& p) { return p.x(); } 83 static float x(const gfx::RectF& p) { return p.x(); }
84 static float y(const gfx::RectF& p) { return p.y(); } 84 static float y(const gfx::RectF& p) { return p.y(); }
85 static float width(const gfx::RectF& p) { return p.width(); } 85 static float width(const gfx::RectF& p) { return p.width(); }
86 static float height(const gfx::RectF& p) { return p.height(); } 86 static float height(const gfx::RectF& p) { return p.height(); }
87 static bool Read(gfx::mojom::RectFDataView data, gfx::RectF* out) { 87 static bool Read(gfx::mojom::RectFDataView data, gfx::RectF* out) {
88 if (data.width() < 0 || data.height() < 0) 88 if (data.width() < 0 || data.height() < 0)
89 return false; 89 return false;
90 90
91 out->SetRect(data.x(), data.y(), data.width(), data.height()); 91 out->SetRect(data.x(), data.y(), data.width(), data.height());
92 return true; 92 return true;
93 } 93 }
94 }; 94 };
95 95
96 template <> 96 template <>
97 struct StructTraits<gfx::mojom::Size, gfx::Size> { 97 struct StructTraits<gfx::mojom::SizeDataView, gfx::Size> {
98 static int width(const gfx::Size& p) { return p.width(); } 98 static int width(const gfx::Size& p) { return p.width(); }
99 static int height(const gfx::Size& p) { return p.height(); } 99 static int height(const gfx::Size& p) { return p.height(); }
100 static bool Read(gfx::mojom::SizeDataView data, gfx::Size* out) { 100 static bool Read(gfx::mojom::SizeDataView data, gfx::Size* out) {
101 if (data.width() < 0 || data.height() < 0) 101 if (data.width() < 0 || data.height() < 0)
102 return false; 102 return false;
103 103
104 out->SetSize(data.width(), data.height()); 104 out->SetSize(data.width(), data.height());
105 return true; 105 return true;
106 } 106 }
107 }; 107 };
108 108
109 template <> 109 template <>
110 struct StructTraits<gfx::mojom::SizeF, gfx::SizeF> { 110 struct StructTraits<gfx::mojom::SizeFDataView, gfx::SizeF> {
111 static float width(const gfx::SizeF& p) { return p.width(); } 111 static float width(const gfx::SizeF& p) { return p.width(); }
112 static float height(const gfx::SizeF& p) { return p.height(); } 112 static float height(const gfx::SizeF& p) { return p.height(); }
113 static bool Read(gfx::mojom::SizeFDataView data, gfx::SizeF* out) { 113 static bool Read(gfx::mojom::SizeFDataView data, gfx::SizeF* out) {
114 if (data.width() < 0 || data.height() < 0) 114 if (data.width() < 0 || data.height() < 0)
115 return false; 115 return false;
116 116
117 out->SetSize(data.width(), data.height()); 117 out->SetSize(data.width(), data.height());
118 return true; 118 return true;
119 } 119 }
120 }; 120 };
121 121
122 template <> 122 template <>
123 struct StructTraits<gfx::mojom::Vector2d, gfx::Vector2d> { 123 struct StructTraits<gfx::mojom::Vector2dDataView, gfx::Vector2d> {
124 static int x(const gfx::Vector2d& v) { return v.x(); } 124 static int x(const gfx::Vector2d& v) { return v.x(); }
125 static int y(const gfx::Vector2d& v) { return v.y(); } 125 static int y(const gfx::Vector2d& v) { return v.y(); }
126 static bool Read(gfx::mojom::Vector2dDataView data, gfx::Vector2d* out) { 126 static bool Read(gfx::mojom::Vector2dDataView data, gfx::Vector2d* out) {
127 out->set_x(data.x()); 127 out->set_x(data.x());
128 out->set_y(data.y()); 128 out->set_y(data.y());
129 return true; 129 return true;
130 } 130 }
131 }; 131 };
132 132
133 template <> 133 template <>
134 struct StructTraits<gfx::mojom::Vector2dF, gfx::Vector2dF> { 134 struct StructTraits<gfx::mojom::Vector2dFDataView, gfx::Vector2dF> {
135 static float x(const gfx::Vector2dF& v) { return v.x(); } 135 static float x(const gfx::Vector2dF& v) { return v.x(); }
136 static float y(const gfx::Vector2dF& v) { return v.y(); } 136 static float y(const gfx::Vector2dF& v) { return v.y(); }
137 static bool Read(gfx::mojom::Vector2dFDataView data, gfx::Vector2dF* out) { 137 static bool Read(gfx::mojom::Vector2dFDataView data, gfx::Vector2dF* out) {
138 out->set_x(data.x()); 138 out->set_x(data.x());
139 out->set_y(data.y()); 139 out->set_y(data.y());
140 return true; 140 return true;
141 } 141 }
142 }; 142 };
143 143
144 } // namespace mojo 144 } // namespace mojo
145 145
146 #endif // UI_GFX_GEOMETRY_MOJO_GEOMETRY_STRUCT_TRAITS_H_ 146 #endif // UI_GFX_GEOMETRY_MOJO_GEOMETRY_STRUCT_TRAITS_H_
OLDNEW
« no previous file with comments | « ui/events/mojo/latency_info_struct_traits.cc ('k') | ui/gfx/mojo/accelerated_widget_struct_traits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698