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

Side by Side Diff: mojo/converters/geometry/geometry_type_converters.cc

Issue 2009073003: Move mojo/converters/geometry -> ui/gfx/geometry/mojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . 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
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "mojo/converters/geometry/geometry_type_converters.h"
6
7 namespace mojo {
8
9 // static
10 PointPtr TypeConverter<PointPtr, gfx::Point>::Convert(const gfx::Point& input) {
11 PointPtr point(Point::New());
12 point->x = input.x();
13 point->y = input.y();
14 return point;
15 }
16
17 // static
18 gfx::Point TypeConverter<gfx::Point, PointPtr>::Convert(const PointPtr& input) {
19 if (input.is_null())
20 return gfx::Point();
21 return gfx::Point(input->x, input->y);
22 }
23
24 // static
25 PointFPtr TypeConverter<PointFPtr, gfx::PointF>::Convert(
26 const gfx::PointF& input) {
27 PointFPtr point(PointF::New());
28 point->x = input.x();
29 point->y = input.y();
30 return point;
31 }
32
33 // static
34 gfx::PointF TypeConverter<gfx::PointF, PointFPtr>::Convert(
35 const PointFPtr& input) {
36 if (input.is_null())
37 return gfx::PointF();
38 return gfx::PointF(input->x, input->y);
39 }
40
41 // static
42 SizePtr TypeConverter<SizePtr, gfx::Size>::Convert(const gfx::Size& input) {
43 SizePtr size(Size::New());
44 size->width = input.width();
45 size->height = input.height();
46 return size;
47 }
48
49 // static
50 gfx::Size TypeConverter<gfx::Size, SizePtr>::Convert(const SizePtr& input) {
51 if (input.is_null())
52 return gfx::Size();
53 return gfx::Size(input->width, input->height);
54 }
55
56 // static
57 RectPtr TypeConverter<RectPtr, gfx::Rect>::Convert(const gfx::Rect& input) {
58 RectPtr rect(Rect::New());
59 rect->x = input.x();
60 rect->y = input.y();
61 rect->width = input.width();
62 rect->height = input.height();
63 return rect;
64 }
65
66 // static
67 gfx::Rect TypeConverter<gfx::Rect, RectPtr>::Convert(const RectPtr& input) {
68 if (input.is_null())
69 return gfx::Rect();
70 return gfx::Rect(input->x, input->y, input->width, input->height);
71 }
72
73 // static
74 RectFPtr TypeConverter<RectFPtr, gfx::RectF>::Convert(const gfx::RectF& input) {
75 RectFPtr rect(RectF::New());
76 rect->x = input.x();
77 rect->y = input.y();
78 rect->width = input.width();
79 rect->height = input.height();
80 return rect;
81 }
82
83 // static
84 gfx::RectF TypeConverter<gfx::RectF, RectFPtr>::Convert(const RectFPtr& input) {
85 if (input.is_null())
86 return gfx::RectF();
87 return gfx::RectF(input->x, input->y, input->width, input->height);
88 }
89
90 // static
91 Rect TypeConverter<Rect, gfx::Rect>::Convert(const gfx::Rect& input) {
92 Rect rect;
93 rect.x = input.x();
94 rect.y = input.y();
95 rect.width = input.width();
96 rect.height = input.height();
97 return rect;
98 }
99
100 // static
101 gfx::Rect TypeConverter<gfx::Rect, Rect>::Convert(const Rect& input) {
102 return gfx::Rect(input.x, input.y, input.width, input.height);
103 }
104
105 // static
106 Size TypeConverter<Size, gfx::Size>::Convert(const gfx::Size& input) {
107 Size size;
108 size.width = input.width();
109 size.height = input.height();
110 return size;
111 }
112
113 // static
114 gfx::Size TypeConverter<gfx::Size, Size>::Convert(const Size& input) {
115 return gfx::Size(input.width, input.height);
116 }
117
118 // static
119 Insets TypeConverter<Insets, gfx::Insets>::Convert(const gfx::Insets& input) {
120 Insets insets;
121 insets.top = input.top();
122 insets.left = input.left();
123 insets.bottom = input.bottom();
124 insets.right = input.right();
125 return insets;
126 }
127
128 // static
129 gfx::Insets TypeConverter<gfx::Insets, Insets>::Convert(const Insets& input) {
130 return gfx::Insets(input.top, input.left, input.bottom, input.right);
131 }
132
133 // static
134 InsetsPtr TypeConverter<InsetsPtr, gfx::Insets>::Convert(
135 const gfx::Insets& input) {
136 InsetsPtr insets(Insets::New());
137 insets->top = input.top();
138 insets->left = input.left();
139 insets->bottom = input.bottom();
140 insets->right = input.right();
141 return insets;
142 }
143
144 // static
145 gfx::Insets TypeConverter<gfx::Insets, InsetsPtr>::Convert(
146 const InsetsPtr& input) {
147 if (input.is_null())
148 return gfx::Insets();
149
150 return gfx::Insets(input->top, input->left, input->bottom, input->right);
151 }
152
153 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698