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.
5 #ifndef MOJO_SERVICES_NATIVE_VIEWPORT_GEOMETRY_CONVERSIONS_H_
6 #define MOJO_SERVICES_NATIVE_VIEWPORT_GEOMETRY_CONVERSIONS_H_
8 #include "mojom/native_viewport.h"
9 #include "ui/gfx/rect.h"
14 class TypeConverter<Point, gfx::Point> {
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();
22 static gfx::Point ConvertTo(const Point& input) {
23 return gfx::Point(input.x(), input.y());
28 class TypeConverter<Size, gfx::Size> {
30 static Size ConvertFrom(const gfx::Size& input, Buffer* buf) {
31 mojo::AllocationScope scope;
32 Size::Builder size(buf);
33 size.set_width(input.width());
34 size.set_height(input.height());
37 static gfx::Size ConvertTo(const Size& input) {
38 return gfx::Size(input.width(), input.height());
43 class TypeConverter<Rect, gfx::Rect> {
45 static Rect ConvertFrom(const gfx::Rect& input, Buffer* buf) {
46 Rect::Builder rect(buf);
47 rect.set_position(input.origin());
48 rect.set_size(input.size());
51 static gfx::Rect ConvertTo(const Rect& input) {
52 return gfx::Rect(input.position().x(), input.position().y(),
53 input.size().width(), input.size().height());
59 #endif // MOJO_SERVICES_NATIVE_VIEWPORT_GEOMETRY_CONVERSIONS_H_