| 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 |
| 6 /* From ppb_image_data.idl modified Sat Jul 16 16:50:26 2011. */ |
| 7 |
| 5 #ifndef PPAPI_C_PPB_IMAGE_DATA_H_ | 8 #ifndef PPAPI_C_PPB_IMAGE_DATA_H_ |
| 6 #define PPAPI_C_PPB_IMAGE_DATA_H_ | 9 #define PPAPI_C_PPB_IMAGE_DATA_H_ |
| 7 | 10 |
| 8 #include "ppapi/c/pp_bool.h" | 11 #include "ppapi/c/pp_bool.h" |
| 9 #include "ppapi/c/pp_instance.h" | 12 #include "ppapi/c/pp_instance.h" |
| 10 #include "ppapi/c/pp_macros.h" | 13 #include "ppapi/c/pp_macros.h" |
| 11 #include "ppapi/c/pp_module.h" | |
| 12 #include "ppapi/c/pp_resource.h" | 14 #include "ppapi/c/pp_resource.h" |
| 13 #include "ppapi/c/pp_size.h" | 15 #include "ppapi/c/pp_size.h" |
| 14 #include "ppapi/c/pp_stdint.h" | 16 #include "ppapi/c/pp_stdint.h" |
| 15 | 17 |
| 16 /** | 18 /** |
| 17 * @file | 19 * @file |
| 18 * This file defines the <code>PPB_ImageData</code> struct for determining how | 20 * This file defines the <code>PPB_ImageData</code> struct for determining how |
| 19 * a browser handles image data. | 21 * a browser handles image data. |
| 20 */ | 22 */ |
| 21 | 23 |
| 24 |
| 22 /** | 25 /** |
| 23 * @addtogroup Enums | 26 * @addtogroup Enums |
| 24 * @{ | 27 * @{ |
| 25 */ | 28 */ |
| 26 | |
| 27 /** | 29 /** |
| 28 * <code>PP_ImageDataFormat</code> is an enumeration of the different types of | 30 * <code>PP_ImageDataFormat</code> is an enumeration of the different types of |
| 29 * image data formats. | 31 * image data formats. |
| 30 * | 32 * |
| 31 * The third part of each enumeration value describes the memory layout from | 33 * The third part of each enumeration value describes the memory layout from |
| 32 * the lowest address to the highest. For example, BGRA means the B component | 34 * the lowest address to the highest. For example, BGRA means the B component |
| 33 * is stored in the lowest address, no matter what endianness the platform is | 35 * is stored in the lowest address, no matter what endianness the platform is |
| 34 * using. | 36 * using. |
| 35 * | 37 * |
| 36 * The PREMUL suffix implies pre-multiplied alpha is used. In this mode, the | 38 * The PREMUL suffix implies pre-multiplied alpha is used. In this mode, the |
| (...skipping 25 matching lines...) Expand all Loading... |
| 62 } PP_ImageDataFormat; | 64 } PP_ImageDataFormat; |
| 63 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_ImageDataFormat, 4); | 65 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_ImageDataFormat, 4); |
| 64 /** | 66 /** |
| 65 * @} | 67 * @} |
| 66 */ | 68 */ |
| 67 | 69 |
| 68 /** | 70 /** |
| 69 * @addtogroup Structs | 71 * @addtogroup Structs |
| 70 * @{ | 72 * @{ |
| 71 */ | 73 */ |
| 72 | |
| 73 /** | 74 /** |
| 74 * The <code>PP_ImageDataDesc</code> structure represents a description of | 75 * The <code>PP_ImageDataDesc</code> structure represents a description of |
| 75 * image data. | 76 * image data. |
| 76 */ | 77 */ |
| 77 struct PP_ImageDataDesc { | 78 struct PP_ImageDataDesc { |
| 78 | |
| 79 /** | 79 /** |
| 80 * This value represents one of the image data types in the | 80 * This value represents one of the image data types in the |
| 81 * <code>PP_ImageDataFormat</code> enum. | 81 * <code>PP_ImageDataFormat</code> enum. |
| 82 */ | 82 */ |
| 83 PP_ImageDataFormat format; | 83 PP_ImageDataFormat format; |
| 84 | |
| 85 /** This value represents the size of the bitmap in pixels. */ | 84 /** This value represents the size of the bitmap in pixels. */ |
| 86 struct PP_Size size; | 85 struct PP_Size size; |
| 87 | |
| 88 /** | 86 /** |
| 89 * This value represents the row width in bytes. This may be different than | 87 * This value represents the row width in bytes. This may be different than |
| 90 * width * 4 since there may be padding at the end of the lines. | 88 * width * 4 since there may be padding at the end of the lines. |
| 91 */ | 89 */ |
| 92 int32_t stride; | 90 int32_t stride; |
| 93 }; | 91 }; |
| 94 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_ImageDataDesc, 16); | 92 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_ImageDataDesc, 16); |
| 95 /** | 93 /** |
| 96 * @} | 94 * @} |
| 97 */ | 95 */ |
| 98 | 96 |
| 99 #define PPB_IMAGEDATA_INTERFACE_0_3 "PPB_ImageData;0.3" | |
| 100 #define PPB_IMAGEDATA_INTERFACE_1_0 "PPB_ImageData;1.0" | |
| 101 #define PPB_IMAGEDATA_INTERFACE PPB_IMAGEDATA_INTERFACE_1_0 | |
| 102 | |
| 103 /** | 97 /** |
| 104 * @addtogroup Interfaces | 98 * @addtogroup Interfaces |
| 105 * @{ | 99 * @{ |
| 106 */ | 100 */ |
| 107 | |
| 108 /** | 101 /** |
| 109 * The <code>PPB_ImageData</code> interface contains pointers to several | 102 * The <code>PPB_ImageData</code> interface contains pointers to several |
| 110 * functions for determining the browser's treatment of image data. | 103 * functions for determining the browser's treatment of image data. |
| 111 */ | 104 */ |
| 105 #define PPB_IMAGEDATA_INTERFACE_0_3 "PPB_ImageData;0.3" |
| 106 #define PPB_IMAGEDATA_INTERFACE_1_0 "PPB_ImageData;1.0" |
| 107 #define PPB_IMAGEDATA_INTERFACE PPB_IMAGEDATA_INTERFACE_1_0 |
| 108 |
| 112 struct PPB_ImageData { | 109 struct PPB_ImageData { |
| 113 /** | 110 /** |
| 114 * GetNativeImageDataFormat() returns the browser's preferred format for | 111 * GetNativeImageDataFormat() returns the browser's preferred format for |
| 115 * image data. The browser uses this format internally for painting. Other | 112 * image data. The browser uses this format internally for painting. Other |
| 116 * formats may require internal conversions to paint or may have additional | 113 * formats may require internal conversions to paint or may have additional |
| 117 * restrictions depending on the function. | 114 * restrictions depending on the function. |
| 118 * | 115 * |
| 119 * @return A <code>PP_ImageDataFormat</code> containing the preferred format. | 116 * @return A <code>PP_ImageDataFormat</code> containing the preferred format. |
| 120 */ | 117 */ |
| 121 PP_ImageDataFormat (*GetNativeImageDataFormat)(); | 118 PP_ImageDataFormat (*GetNativeImageDataFormat)(); |
| 122 | |
| 123 /** | 119 /** |
| 124 * IsImageDataFormatSupported() determines if the given image data format is | 120 * IsImageDataFormatSupported() determines if the given image data format is |
| 125 * supported by the browser. | 121 * supported by the browser. |
| 126 * | 122 * |
| 127 * @param[in] format The image data format. | 123 * @param[in] format The image data format. |
| 128 * | 124 * |
| 129 * @return A <code>PP_Bool</code> with <code>PP_TRUE</code> if the given | 125 * @return A <code>PP_Bool</code> with <code>PP_TRUE</code> if the given |
| 130 * image data format is supported by the browser. | 126 * image data format is supported by the browser. |
| 131 */ | 127 */ |
| 132 PP_Bool (*IsImageDataFormatSupported)(PP_ImageDataFormat format); | 128 PP_Bool (*IsImageDataFormatSupported)(PP_ImageDataFormat format); |
| 133 | |
| 134 /** | 129 /** |
| 135 * Create() allocates an image data resource with the given format and size. | 130 * Create() allocates an image data resource with the given format and size. |
| 136 * | 131 * |
| 137 * For security reasons, if uninitialized, the bitmap will not contain random | 132 * For security reasons, if uninitialized, the bitmap will not contain random |
| 138 * memory, but may contain data from a previous image produced by the same | 133 * memory, but may contain data from a previous image produced by the same |
| 139 * module if the bitmap was cached and re-used. | 134 * module if the bitmap was cached and re-used. |
| 140 * | 135 * |
| 141 * @param[in] instance A <code>PP_Instance</code> indentifying one instance | 136 * @param[in] instance A <code>PP_Instance</code> indentifying one instance |
| 142 * of a module. | 137 * of a module. |
| 143 * @param[in] format The desired image data format. | 138 * @param[in] format The desired image data format. |
| 144 * @param[in] size A pointer to a <code>PP_Size</code> containing the image | 139 * @param[in] size A pointer to a <code>PP_Size</code> containing the image |
| 145 * size. | 140 * size. |
| 146 * @param[in] init_to_zero A <code>PP_Bool</code> to determine transparency | 141 * @param[in] init_to_zero A <code>PP_Bool</code> to determine transparency |
| 147 * at creation. | 142 * at creation. |
| 148 * Set the <code>init_to_zero</code> flag if you want the bitmap initialized | 143 * Set the <code>init_to_zero</code> flag if you want the bitmap initialized |
| 149 * to transparent during the creation process. If this flag is not set, the | 144 * to transparent during the creation process. If this flag is not set, the |
| 150 * current contents of the bitmap will be undefined, and the module should | 145 * current contents of the bitmap will be undefined, and the module should |
| 151 * be sure to set all the pixels. | 146 * be sure to set all the pixels. |
| 152 * | 147 * |
| 153 * @return A <code>PP_Resource</code> with a nonzero ID on succes or zero on | 148 * @return A <code>PP_Resource</code> with a nonzero ID on succes or zero on |
| 154 * failure. Failure means the instance, image size, or format was invalid. | 149 * failure. Failure means the instance, image size, or format was invalid. |
| 155 */ | 150 */ |
| 156 PP_Resource (*Create)(PP_Instance instance, | 151 PP_Resource (*Create)(PP_Instance instance, |
| 157 PP_ImageDataFormat format, | 152 PP_ImageDataFormat format, |
| 158 const struct PP_Size* size, | 153 const struct PP_Size* size, |
| 159 PP_Bool init_to_zero); | 154 PP_Bool init_to_zero); |
| 160 | |
| 161 /** | 155 /** |
| 162 * IsImageData() determiens if a given resource is image data. | 156 * IsImageData() determiens if a given resource is image data. |
| 163 * | 157 * |
| 164 * @param[in] image_data A <code>PP_Resource</code> corresponding to image | 158 * @param[in] image_data A <code>PP_Resource</code> corresponding to image |
| 165 * data. | 159 * data. |
| 166 * | 160 * |
| 167 * @return A <code>PP_Bool</code> with <code>PP_TRUE</code> if the given | 161 * @return A <code>PP_Bool</code> with <code>PP_TRUE</code> if the given |
| 168 * resrouce is an image data or <code>PP_FALSE</code> if the resource is | 162 * resrouce is an image data or <code>PP_FALSE</code> if the resource is |
| 169 * invalid or some type other than image data. | 163 * invalid or some type other than image data. |
| 170 */ | 164 */ |
| 171 PP_Bool (*IsImageData)(PP_Resource image_data); | 165 PP_Bool (*IsImageData)(PP_Resource image_data); |
| 172 | |
| 173 /** | 166 /** |
| 174 * Describe() computes the description of the | 167 * Describe() computes the description of the |
| 175 * image data. | 168 * image data. |
| 176 * | 169 * |
| 177 * @param[in] image_data A <code>PP_Resource</code> corresponding to image | 170 * @param[in] image_data A <code>PP_Resource</code> corresponding to image |
| 178 * data. | 171 * data. |
| 179 * @param[in,out] desc A pointer to a <code>PP_ImageDataDesc</code> | 172 * @param[in,out] desc A pointer to a <code>PP_ImageDataDesc</code> |
| 180 * containing the description. | 173 * containing the description. |
| 181 * | 174 * |
| 182 * @return A <code>PP_Bool</code> with <code>PP_TRUE</code> on success or | 175 * @return A <code>PP_Bool</code> with <code>PP_TRUE</code> on success or |
| 183 * <code>PP_FALSE</code> if the resource is not an image data. On | 176 * <code>PP_FALSE</code> if the resource is not an image data. On |
| 184 * <code>PP_FALSE</code>, the <code>desc</code> structure will be filled | 177 * <code>PP_FALSE</code>, the <code>desc</code> structure will be filled |
| 185 * with 0. | 178 * with 0. |
| 186 */ | 179 */ |
| 187 PP_Bool (*Describe)(PP_Resource image_data, | 180 PP_Bool (*Describe)(PP_Resource image_data, struct PP_ImageDataDesc* desc); |
| 188 struct PP_ImageDataDesc* desc); | |
| 189 | |
| 190 /** | 181 /** |
| 191 * Map() maps an image data into the module address space. | 182 * Map() maps an image data into the module address space. |
| 192 * | 183 * |
| 193 * @param[in] image_data A <code>PP_Resource</code> corresponding to image | 184 * @param[in] image_data A <code>PP_Resource</code> corresponding to image |
| 194 * data. | 185 * data. |
| 195 * | 186 * |
| 196 * @return A pointer to the beginning of the data. | 187 * @return A pointer to the beginning of the data. |
| 197 */ | 188 */ |
| 198 void* (*Map)(PP_Resource image_data); | 189 void* (*Map)(PP_Resource image_data); |
| 199 | |
| 200 /** | 190 /** |
| 201 * Unmap is a pointer to a function that unmaps an image data from the module | 191 * Unmap is a pointer to a function that unmaps an image data from the module |
| 202 * address space. | 192 * address space. |
| 203 * | 193 * |
| 204 * @param[in] image_data A <code>PP_Resource</code> corresponding to image | 194 * @param[in] image_data A <code>PP_Resource</code> corresponding to image |
| 205 * data. | 195 * data. |
| 206 */ | 196 */ |
| 207 void (*Unmap)(PP_Resource image_data); | 197 void (*Unmap)(PP_Resource image_data); |
| 208 }; | 198 }; |
| 209 /** | 199 /** |
| 210 * @} | 200 * @} |
| 211 */ | 201 */ |
| 212 | 202 |
| 213 #endif /* PPAPI_C_PPB_IMAGE_DATA_H_ */ | 203 #endif /* PPAPI_C_PPB_IMAGE_DATA_H_ */ |
| 204 |
| OLD | NEW |