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_PPB_IMAGE_DATA_H_ | 5 #ifndef PPAPI_C_PPB_IMAGE_DATA_H_ |
6 #define PPAPI_C_PPB_IMAGE_DATA_H_ | 6 #define PPAPI_C_PPB_IMAGE_DATA_H_ |
7 | 7 |
8 #include "ppapi/c/pp_bool.h" | 8 #include "ppapi/c/pp_bool.h" |
9 #include "ppapi/c/pp_instance.h" | 9 #include "ppapi/c/pp_instance.h" |
10 #include "ppapi/c/pp_macros.h" | 10 #include "ppapi/c/pp_macros.h" |
11 #include "ppapi/c/pp_module.h" | 11 #include "ppapi/c/pp_module.h" |
12 #include "ppapi/c/pp_resource.h" | 12 #include "ppapi/c/pp_resource.h" |
13 #include "ppapi/c/pp_size.h" | 13 #include "ppapi/c/pp_size.h" |
14 #include "ppapi/c/pp_stdint.h" | 14 #include "ppapi/c/pp_stdint.h" |
15 | 15 |
16 /** | 16 /** |
17 * @file | 17 * @file |
18 * Defines the API ... | 18 * This file defines the PPB_ImageData struct for determining how a browser |
| 19 * handles image data. |
19 */ | 20 */ |
20 | 21 |
21 /** | 22 /** |
22 * @addtogroup Enums | 23 * @addtogroup Enums |
23 * @{ | 24 * @{ |
24 */ | 25 */ |
25 | 26 |
| 27 /** |
| 28 * PP_ImageDataFormat is an enumeration of the different types of |
| 29 * image data formats. |
| 30 */ |
26 typedef enum { | 31 typedef enum { |
27 PP_IMAGEDATAFORMAT_BGRA_PREMUL, | 32 PP_IMAGEDATAFORMAT_BGRA_PREMUL, |
28 PP_IMAGEDATAFORMAT_RGBA_PREMUL | 33 PP_IMAGEDATAFORMAT_RGBA_PREMUL |
29 } PP_ImageDataFormat; | 34 } PP_ImageDataFormat; |
30 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_ImageDataFormat, 4); | 35 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_ImageDataFormat, 4); |
31 /** | 36 /** |
32 * @} | 37 * @} |
33 */ | 38 */ |
34 | 39 |
35 /** | 40 /** |
36 * @addtogroup Structs | 41 * @addtogroup Structs |
37 * @{ | 42 * @{ |
38 */ | 43 */ |
| 44 |
| 45 /** |
| 46 * The PP_ImageDataDesc structure represents a description of image data. |
| 47 */ |
39 struct PP_ImageDataDesc { | 48 struct PP_ImageDataDesc { |
| 49 |
| 50 /** |
| 51 * This value represents one of the image data types in the |
| 52 * PP_ImageDataFormat enum. |
| 53 */ |
40 PP_ImageDataFormat format; | 54 PP_ImageDataFormat format; |
41 | 55 |
42 /** Size of the bitmap in pixels. */ | 56 /** This value represents the size of the bitmap in pixels. */ |
43 struct PP_Size size; | 57 struct PP_Size size; |
44 | 58 |
45 /** The row width in bytes. This may be different than width * 4 since there | 59 /** |
46 * may be padding at the end of the lines. | 60 * This value represents the row width in bytes. This may be different than |
| 61 * width * 4 since there may be padding at the end of the lines. |
47 */ | 62 */ |
48 int32_t stride; | 63 int32_t stride; |
49 }; | 64 }; |
50 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_ImageDataDesc, 16); | 65 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_ImageDataDesc, 16); |
51 /** | 66 /** |
52 * @} | 67 * @} |
53 */ | 68 */ |
54 | 69 |
55 #define PPB_IMAGEDATA_INTERFACE "PPB_ImageData;0.3" | 70 #define PPB_IMAGEDATA_INTERFACE "PPB_ImageData;0.3" |
56 | 71 |
57 /** | 72 /** |
58 * @addtogroup Interfaces | 73 * @addtogroup Interfaces |
59 * @{ | 74 * @{ |
60 */ | 75 */ |
| 76 |
| 77 /** |
| 78 * The PPB_ImageData interface contains pointers to several functions for |
| 79 * determining the browser's treatment of image data. |
| 80 */ |
61 struct PPB_ImageData { | 81 struct PPB_ImageData { |
62 /** | 82 /** |
63 * Returns the browser's preferred format for image data. This format will be | 83 * GetNativeImageDataFormat is a pointer to a function that returns the |
64 * the format is uses internally for painting. Other formats may require | 84 * browser's preferred format for image data. The browser uses this format |
65 * internal conversions to paint or may have additional restrictions depending | 85 * internally for painting. Other formats may require internal conversions |
66 * on the function. | 86 * to paint or may have additional restrictions depending on the function. |
| 87 * |
| 88 * @return PP_ImageDataFormat containing the preferred format. |
67 */ | 89 */ |
68 PP_ImageDataFormat (*GetNativeImageDataFormat)(); | 90 PP_ImageDataFormat (*GetNativeImageDataFormat)(); |
69 | 91 |
70 /** | 92 /** |
71 * Returns PP_TRUE if the given image data format is supported by the browser. | 93 * IsImageDataFormatSupported is a pointer to a function that determines if |
| 94 * the given image data format is supported by the browser. |
| 95 * |
| 96 * @param[in] format The image data format. |
| 97 * @return PP_Bool with PP_TRUE if the given image data format is supported |
| 98 * by the browser. |
72 */ | 99 */ |
73 PP_Bool (*IsImageDataFormatSupported)(PP_ImageDataFormat format); | 100 PP_Bool (*IsImageDataFormatSupported)(PP_ImageDataFormat format); |
74 | 101 |
75 /** | 102 /** |
76 * Allocates an image data resource with the given format and size. The | 103 * Create is a pointer to a function that allocates an image data resource |
77 * return value will have a nonzero ID on success, or zero on failure. | 104 * with the given format and size. |
78 * Failure means the instance, image size, or format was invalid. | |
79 * | 105 * |
| 106 * For security reasons, if uninitialized, the bitmap will not contain random |
| 107 * memory, but may contain data from a previous image produced by the same |
| 108 * plugin if the bitmap was cached and re-used. |
| 109 * |
| 110 * @param[in] instance A PP_Instance indentifying one instance of a module. |
| 111 * @param[in] format The desired image data format. |
| 112 * @param[in] size A pointer to a PP_Size containing the image size. |
| 113 * @param[in] init_to_zero A PP_Bool to determine transparency at creation. |
80 * Set the init_to_zero flag if you want the bitmap initialized to | 114 * Set the init_to_zero flag if you want the bitmap initialized to |
81 * transparent during the creation process. If this flag is not set, the | 115 * transparent during the creation process. If this flag is not set, the |
82 * current contents of the bitmap will be undefined, and the plugin should | 116 * current contents of the bitmap will be undefined, and the plugin should |
83 * be sure to set all the pixels. | 117 * be sure to set all the pixels. |
84 * | 118 * |
85 * For security reasons, if uninitialized, the bitmap will not contain random | 119 * @return A PP_Resource with a nonzero ID on succes or zero on failure. |
86 * memory, but may contain data from a previous image produced by the same | 120 * Failure means the instance, image size, or format was invalid. |
87 * plugin if the bitmap was cached and re-used. | |
88 */ | 121 */ |
89 PP_Resource (*Create)(PP_Instance instance, | 122 PP_Resource (*Create)(PP_Instance instance, |
90 PP_ImageDataFormat format, | 123 PP_ImageDataFormat format, |
91 const struct PP_Size* size, | 124 const struct PP_Size* size, |
92 PP_Bool init_to_zero); | 125 PP_Bool init_to_zero); |
93 | 126 |
94 /** | 127 /** |
95 * Returns PP_TRUE if the given resource is an image data. Returns PP_FALSE if | 128 * IsImageData is a pointer to a function that determiens if a given resource |
96 * the resource is invalid or some type other than an image data. | 129 * is image data. |
| 130 * |
| 131 * @param[in] image_data A PP_Resource corresponding to image data. |
| 132 * @return A PP_Bool with PP_TRUE if the given resrouce is an image data |
| 133 * or PP_FALSE if the resource is invalid or some type other than image data. |
97 */ | 134 */ |
98 PP_Bool (*IsImageData)(PP_Resource image_data); | 135 PP_Bool (*IsImageData)(PP_Resource image_data); |
99 | 136 |
100 /** | 137 /** |
101 * Computes the description of the image data. Returns PP_TRUE on success, | 138 * Describe is a pointer to a function that computes the description of the |
102 * PP_FALSE if the resource is not an image data. On PP_FALSE, the |desc| | 139 * image data. |
| 140 * |
| 141 * @param[in] image_data A PP_Resource corresponding to image data. |
| 142 * @param[in/out] desc A pointer to a PP_ImageDataDesc containing the |
| 143 * description. |
| 144 * @return A PP_Bool with PP_TRUE on success or PP_FALSE |
| 145 * if the resource is not an image data. On PP_FALSE, the |desc| |
103 * structure will be filled with 0. | 146 * structure will be filled with 0. |
104 */ | 147 */ |
105 PP_Bool (*Describe)(PP_Resource image_data, | 148 PP_Bool (*Describe)(PP_Resource image_data, |
106 struct PP_ImageDataDesc* desc); | 149 struct PP_ImageDataDesc* desc); |
107 | 150 |
108 /** | 151 /** |
109 * Maps this bitmap into the plugin address space and returns a pointer to the | 152 * Map is a pointer to a function that maps an image data into the plugin |
110 * beginning of the data. | 153 * address space. |
| 154 * |
| 155 * @param[in] image_data A PP_Resource corresponding to image data. |
| 156 * @return A pointer to the beginning of the data. |
111 */ | 157 */ |
112 void* (*Map)(PP_Resource image_data); | 158 void* (*Map)(PP_Resource image_data); |
113 | 159 |
| 160 /** |
| 161 * Unmap is a pointer to a function that unmaps an image data from the plugin |
| 162 * address space. |
| 163 * |
| 164 * @param[in] image_data A PP_Resource corresponding to image data. |
| 165 |
114 void (*Unmap)(PP_Resource image_data); | 166 void (*Unmap)(PP_Resource image_data); |
115 }; | 167 }; |
116 /** | 168 /** |
117 * @} | 169 * @} |
118 */ | 170 */ |
119 | 171 |
120 #endif /* PPAPI_C_PPB_IMAGE_DATA_H_ */ | 172 #endif /* PPAPI_C_PPB_IMAGE_DATA_H_ */ |
121 | 173 |
OLD | NEW |