OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CONTENT_RENDERER_PEPPER_GFX_CONVERSION_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_GFX_CONVERSION_H_ |
6 #define CONTENT_RENDERER_PEPPER_GFX_CONVERSION_H_ | 6 #define CONTENT_RENDERER_PEPPER_GFX_CONVERSION_H_ |
7 | 7 |
8 #include "ppapi/c/pp_point.h" | 8 #include "ppapi/c/pp_point.h" |
9 #include "ppapi/c/pp_rect.h" | 9 #include "ppapi/c/pp_rect.h" |
10 #include "ppapi/c/pp_size.h" | 10 #include "ppapi/c/pp_size.h" |
11 #include "ui/gfx/point.h" | 11 #include "ui/gfx/point.h" |
12 #include "ui/gfx/rect.h" | 12 #include "ui/gfx/rect.h" |
13 #include "ui/gfx/rect_f.h" | |
14 #include "ui/gfx/size.h" | 13 #include "ui/gfx/size.h" |
15 | 14 |
16 // Conversions for graphics types between our gfx library and PPAPI. | 15 // Conversions for graphics types between our gfx library and PPAPI. |
17 // The style of naming is to match the PP_Bool conversions. | 16 // The style of naming is to match the PP_Bool conversions. |
18 | 17 |
19 namespace content { | 18 namespace content { |
20 | 19 |
21 inline gfx::Point PP_ToGfxPoint(const PP_Point& p) { | 20 inline gfx::Point PP_ToGfxPoint(const PP_Point& p) { |
22 return gfx::Point(p.x, p.y); | 21 return gfx::Point(p.x, p.y); |
23 } | 22 } |
24 | 23 |
25 inline PP_Point PP_FromGfxPoint(const gfx::Point& p) { | 24 inline PP_Point PP_FromGfxPoint(const gfx::Point& p) { |
26 return PP_MakePoint(p.x(), p.y()); | 25 return PP_MakePoint(p.x(), p.y()); |
27 } | 26 } |
28 | 27 |
29 inline gfx::Rect PP_ToGfxRect(const PP_Rect& r) { | 28 inline gfx::Rect PP_ToGfxRect(const PP_Rect& r) { |
30 return gfx::Rect(r.point.x, r.point.y, r.size.width, r.size.height); | 29 return gfx::Rect(r.point.x, r.point.y, r.size.width, r.size.height); |
31 } | 30 } |
32 | 31 |
33 inline gfx::RectF PP_ToGfxRectF(const PP_FloatRect& r) { | |
34 return gfx::RectF(r.point.x, r.point.y, r.size.width, r.size.height); | |
35 } | |
36 | |
37 inline PP_Rect PP_FromGfxRect(const gfx::Rect& r) { | 32 inline PP_Rect PP_FromGfxRect(const gfx::Rect& r) { |
38 return PP_MakeRectFromXYWH(r.x(), r.y(), r.width(), r.height()); | 33 return PP_MakeRectFromXYWH(r.x(), r.y(), r.width(), r.height()); |
39 } | 34 } |
40 | 35 |
41 inline gfx::Size PP_ToGfxSize(const PP_Size& s) { | 36 inline gfx::Size PP_ToGfxSize(const PP_Size& s) { |
42 return gfx::Size(s.width, s.height); | 37 return gfx::Size(s.width, s.height); |
43 } | 38 } |
44 | 39 |
45 inline PP_Size PP_FromGfxSize(const gfx::Size& s) { | 40 inline PP_Size PP_FromGfxSize(const gfx::Size& s) { |
46 return PP_MakeSize(s.width(), s.height()); | 41 return PP_MakeSize(s.width(), s.height()); |
47 } | 42 } |
48 | 43 |
49 } // namespace content | 44 } // namespace content |
50 | 45 |
51 #endif // CONTENT_RENDERER_PEPPER_GFX_CONVERSION_H_ | 46 #endif // CONTENT_RENDERER_PEPPER_GFX_CONVERSION_H_ |
OLD | NEW |