OLD | NEW |
1 /* Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 /* Copyright (c) 2010 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 PPAPI_C_PP_POINT_H_ | 5 #ifndef PPAPI_C_PP_POINT_H_ |
6 #define PPAPI_C_PP_POINT_H_ | 6 #define PPAPI_C_PP_POINT_H_ |
7 | 7 |
8 /** | 8 /** |
9 * @file | 9 * @file |
10 * This file defines the API to create a 2 dimensional point. | 10 * This file defines the API to create a 2 dimensional point. |
11 * 0,0 is the upper-left starting coordinate. | 11 * 0,0 is the upper-left starting coordinate. |
12 */ | 12 */ |
13 | 13 |
14 #include "ppapi/c/pp_macros.h" | 14 #include "ppapi/c/pp_macros.h" |
15 #include "ppapi/c/pp_stdint.h" | 15 #include "ppapi/c/pp_stdint.h" |
16 | 16 |
17 /** | 17 /** |
18 * | 18 * |
19 * @addtogroup Structs | 19 * @addtogroup Structs |
20 * @{ | 20 * @{ |
21 */ | 21 */ |
22 | 22 |
23 /** | 23 /** |
24 * The PP_Point structure defines the x and y coordinates of a point. | 24 * The PP_Point structure defines the integer x and y coordinates of a point. |
25 */ | 25 */ |
26 struct PP_Point { | 26 struct PP_Point { |
27 /** | 27 /** |
28 * This value represents the horizontal coordinate of a point, starting with 0 | 28 * This value represents the horizontal coordinate of a point, starting with 0 |
29 * as the left-most coordinate. | 29 * as the left-most coordinate. |
30 */ | 30 */ |
31 int32_t x; | 31 int32_t x; |
32 | 32 |
33 /** | 33 /** |
34 * This value represents the vertical coordinate of a point, starting with 0 | 34 * This value represents the vertical coordinate of a point, starting with 0 |
35 * as the top-most coordinate. | 35 * as the top-most coordinate. |
36 */ | 36 */ |
37 int32_t y; | 37 int32_t y; |
38 }; | 38 }; |
39 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_Point, 8); | 39 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_Point, 8); |
| 40 |
| 41 /** |
| 42 * The PP_FloatPoint structure defines the floating-point x and y coordinates |
| 43 * of a point. |
| 44 */ |
| 45 struct PP_FloatPoint { |
| 46 float x; |
| 47 float y; |
| 48 }; |
| 49 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_FloatPoint, 8); |
40 /** | 50 /** |
41 * @} | 51 * @} |
42 */ | 52 */ |
43 | 53 |
44 /** | 54 /** |
45 * @addtogroup Functions | 55 * @addtogroup Functions |
46 * @{ | 56 * @{ |
47 */ | 57 */ |
48 | 58 |
49 /** | 59 /** |
50 * PP_MakePoint() creates a PP_Point given the x and y coordinates as int32_t | 60 * PP_MakePoint() creates a PP_Point given the x and y coordinates as int32_t |
51 * values. | 61 * values. |
52 * @param[in] x An int32_t value representing a horizontal coordinate of a | 62 * @param[in] x An int32_t value representing a horizontal coordinate of a |
53 * point, starting with 0 as the left-most coordinate. | 63 * point, starting with 0 as the left-most coordinate. |
54 * @param[in] y An int32_t value representing a vertical coordinate of a point, | 64 * @param[in] y An int32_t value representing a vertical coordinate of a point, |
55 * starting with 0 as the top-most coordinate. | 65 * starting with 0 as the top-most coordinate. |
56 * @return A PP_Point structure. | 66 * @return A PP_Point structure. |
57 */ | 67 */ |
58 PP_INLINE struct PP_Point PP_MakePoint(int32_t x, int32_t y) { | 68 PP_INLINE struct PP_Point PP_MakePoint(int32_t x, int32_t y) { |
59 struct PP_Point ret; | 69 struct PP_Point ret; |
60 ret.x = x; | 70 ret.x = x; |
61 ret.y = y; | 71 ret.y = y; |
62 return ret; | 72 return ret; |
63 } | 73 } |
| 74 |
| 75 PP_INLINE struct PP_FloatPoint PP_MakeFloatPoint(float x, float y) { |
| 76 struct PP_FloatPoint ret; |
| 77 ret.x = x; |
| 78 ret.y = y; |
| 79 return ret; |
| 80 } |
64 /** | 81 /** |
65 * @} | 82 * @} |
66 */ | 83 */ |
67 | 84 |
68 #endif /* PPAPI_C_PP_POINT_H_ */ | 85 #endif /* PPAPI_C_PP_POINT_H_ */ |
69 | 86 |
OLD | NEW |