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