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_EXAMPLES_PEPPER_CONTAINER_APP_TYPE_CONVERTERS_H_
6 #define MOJO_EXAMPLES_PEPPER_CONTAINER_APP_TYPE_CONVERTERS_H_
8 #include "mojo/public/cpp/bindings/type_converter.h"
9 #include "mojo/services/native_viewport/native_viewport.mojom.h"
10 #include "ppapi/c/pp_point.h"
11 #include "ppapi/c/pp_rect.h"
12 #include "ppapi/c/pp_size.h"
17 class TypeConverter<Point, PP_Point> {
19 static Point ConvertFrom(const PP_Point& input, Buffer* buf) {
20 Point::Builder point(buf);
23 return point.Finish();
26 static PP_Point ConvertTo(const Point& input) {
27 return PP_MakePoint(static_cast<int32_t>(input.x()),
28 static_cast<int32_t>(input.y()));
31 MOJO_ALLOW_IMPLICIT_TYPE_CONVERSION();
35 class TypeConverter<Size, PP_Size> {
37 static Size ConvertFrom(const PP_Size& input, Buffer* buf) {
38 Size::Builder size(buf);
39 size.set_width(input.width);
40 size.set_height(input.height);
44 static PP_Size ConvertTo(const Size& input) {
45 return PP_MakeSize(static_cast<int32_t>(input.width()),
46 static_cast<int32_t>(input.height()));
49 MOJO_ALLOW_IMPLICIT_TYPE_CONVERSION();
53 class TypeConverter<Rect, PP_Rect> {
55 static Rect ConvertFrom(const PP_Rect& input, Buffer* buf) {
56 Rect::Builder rect(buf);
57 rect.set_position(input.point);
58 rect.set_size(input.size);
62 static PP_Rect ConvertTo(const Rect& input) {
63 PP_Rect rect = { input.position().To<PP_Point>(),
64 input.size().To<PP_Size>() };
68 MOJO_ALLOW_IMPLICIT_TYPE_CONVERSION();
73 #endif // MOJO_EXAMPLES_PEPPER_CONTAINER_APP_TYPE_CONVERTERS_H_