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