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 #include "mojo/services/public/cpp/geometry/geometry_type_converters.h" 6 7 namespace mojo { 8 9 // static 10 PointPtr TypeConverter<PointPtr, gfx::Point>::ConvertFrom( 11 const gfx::Point& input) { 12 PointPtr point(Point::New()); 13 point->x = input.x(); 14 point->y = input.y(); 15 return point.Pass(); 16 } 17 18 // static 19 gfx::Point TypeConverter<PointPtr, gfx::Point>::ConvertTo( 20 const PointPtr& input) { 21 if (!input) 22 return gfx::Point(); 23 return gfx::Point(input->x, input->y); 24 } 25 26 // static 27 SizePtr TypeConverter<SizePtr, gfx::Size>::ConvertFrom(const gfx::Size& input) { 28 SizePtr size(Size::New()); 29 size->width = input.width(); 30 size->height = input.height(); 31 return size.Pass(); 32 } 33 34 // static 35 gfx::Size TypeConverter<SizePtr, gfx::Size>::ConvertTo(const SizePtr& input) { 36 if (!input) 37 return gfx::Size(); 38 return gfx::Size(input->width, input->height); 39 } 40 41 // static 42 RectPtr TypeConverter<RectPtr, gfx::Rect>::ConvertFrom(const gfx::Rect& input) { 43 RectPtr rect(Rect::New()); 44 rect->x = input.x(); 45 rect->y = input.y(); 46 rect->width = input.width(); 47 rect->height = input.height(); 48 return rect.Pass(); 49 } 50 51 // static 52 gfx::Rect TypeConverter<RectPtr, gfx::Rect>::ConvertTo(const RectPtr& input) { 53 if (!input) 54 return gfx::Rect(); 55 return gfx::Rect(input->x, input->y, input->width, input->height); 56 } 57 58 } // namespace mojo 59