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

Unified Diff: mojo/services/native_viewport/geometry_conversions.h

Issue 294833002: Mojo: more idiomatic C++ bindings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more 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
Index: mojo/services/native_viewport/geometry_conversions.h
diff --git a/mojo/services/native_viewport/geometry_conversions.h b/mojo/services/native_viewport/geometry_conversions.h
index 27e9c5a99f51587a75fad4663b90aeee603d6cd4..998052c7bc85e194498674140e2c324c64e81e0a 100644
--- a/mojo/services/native_viewport/geometry_conversions.h
+++ b/mojo/services/native_viewport/geometry_conversions.h
@@ -11,52 +11,46 @@
namespace mojo {
template<>
-class TypeConverter<Point, gfx::Point> {
+class TypeConverter<PointPtr, gfx::Point> {
public:
- static 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 PointPtr ConvertFrom(const gfx::Point& input) {
+ PointPtr point(Point::New());
+ point->x = input.x();
+ point->y = input.y();
+ return point.Pass();
}
- static gfx::Point ConvertTo(const Point& input) {
- return gfx::Point(input.x(), input.y());
+ static gfx::Point ConvertTo(const PointPtr& input) {
+ return gfx::Point(input->x, input->y);
}
-
- MOJO_ALLOW_IMPLICIT_TYPE_CONVERSION();
};
template<>
-class TypeConverter<Size, gfx::Size> {
+class TypeConverter<SizePtr, gfx::Size> {
public:
- static 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 SizePtr ConvertFrom(const gfx::Size& input) {
+ SizePtr size(Size::New());
+ size->width = input.width();
+ size->height = input.height();
+ return size.Pass();
}
- static gfx::Size ConvertTo(const Size& input) {
- return gfx::Size(input.width(), input.height());
+ static gfx::Size ConvertTo(const SizePtr& input) {
+ return gfx::Size(input->width, input->height);
}
-
- MOJO_ALLOW_IMPLICIT_TYPE_CONVERSION();
};
template<>
-class TypeConverter<Rect, gfx::Rect> {
+class TypeConverter<RectPtr, gfx::Rect> {
public:
- static 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 RectPtr ConvertFrom(const gfx::Rect& input) {
+ RectPtr rect(Rect::New());
+ rect->position = Point::From(input.origin());
+ rect->size = Size::From(input.size());
+ return rect.Pass();
}
- static gfx::Rect ConvertTo(const Rect& input) {
- return gfx::Rect(input.position().x(), input.position().y(),
- input.size().width(), input.size().height());
+ static gfx::Rect ConvertTo(const RectPtr& input) {
+ return gfx::Rect(input->position->x, input->position->y,
+ input->size->width, input->size->height);
}
-
- MOJO_ALLOW_IMPLICIT_TYPE_CONVERSION();
};
} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698