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

Unified Diff: mojo/geometry/geometry_type_converters.cc

Issue 298563003: Move geometry types to a more central location. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 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 | « mojo/geometry/geometry_type_converters.h ('k') | mojo/geometry/mojo_geometry_export.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/geometry/geometry_type_converters.cc
diff --git a/mojo/geometry/geometry_type_converters.cc b/mojo/geometry/geometry_type_converters.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b01d249b27fbdd84fad2bf72c1f9dca835b06e31
--- /dev/null
+++ b/mojo/geometry/geometry_type_converters.cc
@@ -0,0 +1,52 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "mojo/geometry/geometry_type_converters.h"
+
+namespace mojo {
+
+// static
+Point TypeConverter<Point, gfx::Point>::ConvertFrom(const gfx::Point& input,
+ Buffer* buf) {
+ Point::Builder point(buf);
+ point.set_x(input.x());
+ point.set_y(input.y());
+ return point.Finish();
+}
+
+// static
+gfx::Point TypeConverter<Point, gfx::Point>::ConvertTo(const Point& input) {
+ return gfx::Point(input.x(), input.y());
+}
+
+// static
+Size TypeConverter<Size, gfx::Size>::ConvertFrom(const gfx::Size& input,
+ Buffer* buf) {
+ Size::Builder size(buf);
+ size.set_width(input.width());
+ size.set_height(input.height());
+ return size.Finish();
+}
+
+// static
+gfx::Size TypeConverter<Size, gfx::Size>::ConvertTo(const Size& input) {
+ return gfx::Size(input.width(), input.height());
+}
+
+// static
+Rect TypeConverter<Rect, gfx::Rect>::ConvertFrom(const gfx::Rect& input,
+ Buffer* buf) {
+ Rect::Builder rect(buf);
+ rect.set_position(input.origin());
+ rect.set_size(input.size());
+ return rect.Finish();
+}
+
+// static
+gfx::Rect TypeConverter<Rect, gfx::Rect>::ConvertTo(const Rect& input) {
+ return gfx::Rect(input.position().x(), input.position().y(),
+ input.size().width(), input.size().height());
+}
+
+} // namespace mojo
« no previous file with comments | « mojo/geometry/geometry_type_converters.h ('k') | mojo/geometry/mojo_geometry_export.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698