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