| 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 #ifndef MOJO_SERVICES_NATIVE_VIEWPORT_GEOMETRY_CONVERSIONS_H_ | 5 #ifndef MOJO_SERVICES_NATIVE_VIEWPORT_GEOMETRY_CONVERSIONS_H_ |
| 6 #define MOJO_SERVICES_NATIVE_VIEWPORT_GEOMETRY_CONVERSIONS_H_ | 6 #define MOJO_SERVICES_NATIVE_VIEWPORT_GEOMETRY_CONVERSIONS_H_ |
| 7 | 7 |
| 8 #include "mojo/services/native_viewport/native_viewport.mojom.h" | 8 #include "mojo/services/native_viewport/native_viewport.mojom.h" |
| 9 #include "ui/gfx/rect.h" | 9 #include "ui/gfx/rect.h" |
| 10 | 10 |
| 11 namespace mojo { | 11 namespace mojo { |
| 12 | 12 |
| 13 template<> | 13 template<> |
| 14 class TypeConverter<Point, gfx::Point> { | 14 class TypeConverter<PointPtr, gfx::Point> { |
| 15 public: | 15 public: |
| 16 static Point ConvertFrom(const gfx::Point& input, Buffer* buf) { | 16 static PointPtr ConvertFrom(const gfx::Point& input) { |
| 17 Point::Builder point(buf); | 17 PointPtr point(Point::New()); |
| 18 point.set_x(input.x()); | 18 point->x = input.x(); |
| 19 point.set_y(input.y()); | 19 point->y = input.y(); |
| 20 return point.Finish(); | 20 return point.Pass(); |
| 21 } | 21 } |
| 22 static gfx::Point ConvertTo(const Point& input) { | 22 static gfx::Point ConvertTo(const PointPtr& input) { |
| 23 return gfx::Point(input.x(), input.y()); | 23 return gfx::Point(input->x, input->y); |
| 24 } | 24 } |
| 25 | |
| 26 MOJO_ALLOW_IMPLICIT_TYPE_CONVERSION(); | |
| 27 }; | 25 }; |
| 28 | 26 |
| 29 template<> | 27 template<> |
| 30 class TypeConverter<Size, gfx::Size> { | 28 class TypeConverter<SizePtr, gfx::Size> { |
| 31 public: | 29 public: |
| 32 static Size ConvertFrom(const gfx::Size& input, Buffer* buf) { | 30 static SizePtr ConvertFrom(const gfx::Size& input) { |
| 33 Size::Builder size(buf); | 31 SizePtr size(Size::New()); |
| 34 size.set_width(input.width()); | 32 size->width = input.width(); |
| 35 size.set_height(input.height()); | 33 size->height = input.height(); |
| 36 return size.Finish(); | 34 return size.Pass(); |
| 37 } | 35 } |
| 38 static gfx::Size ConvertTo(const Size& input) { | 36 static gfx::Size ConvertTo(const SizePtr& input) { |
| 39 return gfx::Size(input.width(), input.height()); | 37 return gfx::Size(input->width, input->height); |
| 40 } | 38 } |
| 41 | |
| 42 MOJO_ALLOW_IMPLICIT_TYPE_CONVERSION(); | |
| 43 }; | 39 }; |
| 44 | 40 |
| 45 template<> | 41 template<> |
| 46 class TypeConverter<Rect, gfx::Rect> { | 42 class TypeConverter<RectPtr, gfx::Rect> { |
| 47 public: | 43 public: |
| 48 static Rect ConvertFrom(const gfx::Rect& input, Buffer* buf) { | 44 static RectPtr ConvertFrom(const gfx::Rect& input) { |
| 49 Rect::Builder rect(buf); | 45 RectPtr rect(Rect::New()); |
| 50 rect.set_position(input.origin()); | 46 rect->position = Point::From(input.origin()); |
| 51 rect.set_size(input.size()); | 47 rect->size = Size::From(input.size()); |
| 52 return rect.Finish(); | 48 return rect.Pass(); |
| 53 } | 49 } |
| 54 static gfx::Rect ConvertTo(const Rect& input) { | 50 static gfx::Rect ConvertTo(const RectPtr& input) { |
| 55 return gfx::Rect(input.position().x(), input.position().y(), | 51 return gfx::Rect(input->position->x, input->position->y, |
| 56 input.size().width(), input.size().height()); | 52 input->size->width, input->size->height); |
| 57 } | 53 } |
| 58 | |
| 59 MOJO_ALLOW_IMPLICIT_TYPE_CONVERSION(); | |
| 60 }; | 54 }; |
| 61 | 55 |
| 62 } // namespace mojo | 56 } // namespace mojo |
| 63 | 57 |
| 64 #endif // MOJO_SERVICES_NATIVE_VIEWPORT_GEOMETRY_CONVERSIONS_H_ | 58 #endif // MOJO_SERVICES_NATIVE_VIEWPORT_GEOMETRY_CONVERSIONS_H_ |
| OLD | NEW |