| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 #include "mojo/geometry/geometry_type_converters.h" | 5 #include "mojo/geometry/geometry_type_converters.h" |
| 6 | 6 |
| 7 namespace mojo { | 7 namespace mojo { |
| 8 | 8 |
| 9 // static | 9 // static |
| 10 Point TypeConverter<Point, gfx::Point>::ConvertFrom(const gfx::Point& input, | 10 PointPtr TypeConverter<PointPtr, gfx::Point>::ConvertFrom( |
| 11 Buffer* buf) { | 11 const gfx::Point& input) { |
| 12 Point::Builder point(buf); | 12 PointPtr point(Point::New()); |
| 13 point.set_x(input.x()); | 13 point->x = input.x(); |
| 14 point.set_y(input.y()); | 14 point->y = input.y(); |
| 15 return point.Finish(); | 15 return point.Pass(); |
| 16 } | 16 } |
| 17 | 17 |
| 18 // static | 18 // static |
| 19 gfx::Point TypeConverter<Point, gfx::Point>::ConvertTo(const Point& input) { | 19 gfx::Point TypeConverter<PointPtr, gfx::Point>::ConvertTo( |
| 20 return gfx::Point(input.x(), input.y()); | 20 const PointPtr& input) { |
| 21 return gfx::Point(input->x, input->y); |
| 21 } | 22 } |
| 22 | 23 |
| 23 // static | 24 // static |
| 24 Size TypeConverter<Size, gfx::Size>::ConvertFrom(const gfx::Size& input, | 25 SizePtr TypeConverter<SizePtr, gfx::Size>::ConvertFrom(const gfx::Size& input) { |
| 25 Buffer* buf) { | 26 SizePtr size(Size::New()); |
| 26 Size::Builder size(buf); | 27 size->width = input.width(); |
| 27 size.set_width(input.width()); | 28 size->height = input.height(); |
| 28 size.set_height(input.height()); | 29 return size.Pass(); |
| 29 return size.Finish(); | |
| 30 } | 30 } |
| 31 | 31 |
| 32 // static | 32 // static |
| 33 gfx::Size TypeConverter<Size, gfx::Size>::ConvertTo(const Size& input) { | 33 gfx::Size TypeConverter<SizePtr, gfx::Size>::ConvertTo(const SizePtr& input) { |
| 34 return gfx::Size(input.width(), input.height()); | 34 return gfx::Size(input->width, input->height); |
| 35 } | 35 } |
| 36 | 36 |
| 37 // static | 37 // static |
| 38 Rect TypeConverter<Rect, gfx::Rect>::ConvertFrom(const gfx::Rect& input, | 38 RectPtr TypeConverter<RectPtr, gfx::Rect>::ConvertFrom(const gfx::Rect& input) { |
| 39 Buffer* buf) { | 39 RectPtr rect(Rect::New()); |
| 40 Rect::Builder rect(buf); | 40 rect->position = Point::From(input.origin()); |
| 41 rect.set_position(input.origin()); | 41 rect->size = Size::From(input.size()); |
| 42 rect.set_size(input.size()); | 42 return rect.Pass(); |
| 43 return rect.Finish(); | |
| 44 } | 43 } |
| 45 | 44 |
| 46 // static | 45 // static |
| 47 gfx::Rect TypeConverter<Rect, gfx::Rect>::ConvertTo(const Rect& input) { | 46 gfx::Rect TypeConverter<RectPtr, gfx::Rect>::ConvertTo(const RectPtr& input) { |
| 48 return gfx::Rect(input.position().x(), input.position().y(), | 47 return gfx::Rect(input->position->x, input->position->y, |
| 49 input.size().width(), input.size().height()); | 48 input->size->width, input->size->height); |
| 50 } | 49 } |
| 51 | 50 |
| 52 } // namespace mojo | 51 } // namespace mojo |
| OLD | NEW |