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_module.h" | 9 #include "ppapi/c/pp_module.h" |
9 #include "ppapi/c/pp_resource.h" | 10 #include "ppapi/c/pp_resource.h" |
10 #include "ppapi/c/pp_size.h" | 11 #include "ppapi/c/pp_size.h" |
11 #include "ppapi/c/pp_stdint.h" | 12 #include "ppapi/c/pp_stdint.h" |
12 | 13 |
13 typedef enum { | 14 typedef enum { |
14 PP_IMAGEDATAFORMAT_BGRA_PREMUL, | 15 PP_IMAGEDATAFORMAT_BGRA_PREMUL, |
15 PP_IMAGEDATAFORMAT_RGBA_PREMUL | 16 PP_IMAGEDATAFORMAT_RGBA_PREMUL |
16 } PP_ImageDataFormat; | 17 } PP_ImageDataFormat; |
17 | 18 |
18 struct PP_ImageDataDesc { | 19 struct PP_ImageDataDesc { |
19 PP_ImageDataFormat format; | 20 PP_ImageDataFormat format; |
20 | 21 |
21 // Size of the bitmap in pixels. | 22 // Size of the bitmap in pixels. |
22 PP_Size size; | 23 struct PP_Size size; |
23 | 24 |
24 // The row width in bytes. This may be different than width * 4 since there | 25 // The row width in bytes. This may be different than width * 4 since there |
25 // may be padding at the end of the lines. | 26 // may be padding at the end of the lines. |
26 int32_t stride; | 27 int32_t stride; |
27 }; | 28 }; |
28 | 29 |
29 #define PPB_IMAGEDATA_INTERFACE "PPB_ImageData;0.1" | 30 #define PPB_IMAGEDATA_INTERFACE "PPB_ImageData;0.2" |
30 | 31 |
31 /** | 32 /** |
32 * @file | 33 * @file |
33 * Defines the API ... | 34 * Defines the API ... |
34 * | 35 * |
35 * @addtogroup PPB | 36 * @addtogroup PPB |
36 * @{ | 37 * @{ |
37 */ | 38 */ |
38 | 39 |
39 struct PPB_ImageData { | 40 struct PPB_ImageData { |
40 /** | 41 /** |
41 * Returns the browser's preferred format for image data. This format will be | 42 * Returns the browser's preferred format for image data. This format will be |
42 * the format is uses internally for painting. Other formats may require | 43 * the format is uses internally for painting. Other formats may require |
43 * internal conversions to paint or may have additional restrictions depending | 44 * internal conversions to paint or may have additional restrictions depending |
44 * on the function. | 45 * on the function. |
45 */ | 46 */ |
46 PP_ImageDataFormat (*GetNativeImageDataFormat)(); | 47 PP_ImageDataFormat (*GetNativeImageDataFormat)(); |
47 | 48 |
48 /** | 49 /** |
49 * Returns true if the given image data format is supported by the browser. | 50 * Returns PP_TRUE if the given image data format is supported by the browser. |
50 */ | 51 */ |
51 bool (*IsImageDataFormatSupported)(PP_ImageDataFormat format); | 52 PP_Bool (*IsImageDataFormatSupported)(PP_ImageDataFormat format); |
52 | 53 |
53 /** | 54 /** |
54 * Allocates an image data resource with the given format and size. The | 55 * Allocates an image data resource with the given format and size. The |
55 * return value will have a nonzero ID on success, or zero on failure. | 56 * return value will have a nonzero ID on success, or zero on failure. |
56 * Failure means the module handle, image size, or format was invalid. | 57 * Failure means the module handle, image size, or format was invalid. |
57 * | 58 * |
58 * Set the init_to_zero flag if you want the bitmap initialized to | 59 * Set the init_to_zero flag if you want the bitmap initialized to |
59 * transparent during the creation process. If this flag is not set, the | 60 * transparent during the creation process. If this flag is not set, the |
60 * current contents of the bitmap will be undefined, and the plugin should | 61 * current contents of the bitmap will be undefined, and the plugin should |
61 * be sure to set all the pixels. | 62 * be sure to set all the pixels. |
62 * | 63 * |
63 * For security reasons, if uninitialized, the bitmap will not contain random | 64 * For security reasons, if uninitialized, the bitmap will not contain random |
64 * memory, but may contain data from a previous image produced by the same | 65 * memory, but may contain data from a previous image produced by the same |
65 * plugin if the bitmap was cached and re-used. | 66 * plugin if the bitmap was cached and re-used. |
66 */ | 67 */ |
67 PP_Resource (*Create)(PP_Module module, | 68 PP_Resource (*Create)(PP_Module module, |
68 PP_ImageDataFormat format, | 69 PP_ImageDataFormat format, |
69 const struct PP_Size* size, | 70 const struct PP_Size* size, |
70 bool init_to_zero); | 71 PP_Bool init_to_zero); |
71 | 72 |
72 /** | 73 /** |
73 * Returns true if the given resource is an image data. Returns false if the | 74 * Returns PP_TRUE if the given resource is an image data. Returns PP_FALSE if |
74 * resource is invalid or some type other than an image data. | 75 * the resource is invalid or some type other than an image data. |
75 */ | 76 */ |
76 bool (*IsImageData)(PP_Resource image_data); | 77 PP_Bool (*IsImageData)(PP_Resource image_data); |
77 | 78 |
78 /** | 79 /** |
79 * Computes the description of the image data. Returns true on success, false | 80 * Computes the description of the image data. Returns PP_TRUE on success, |
80 * if the resource is not an image data. On false, the |desc| structure will | 81 * PP_FALSE if the resource is not an image data. On PP_FALSE, the |desc| |
81 * be filled with 0. | 82 * structure will be filled with 0. |
82 */ | 83 */ |
83 bool (*Describe)(PP_Resource image_data, | 84 PP_Bool (*Describe)(PP_Resource image_data, |
84 struct PP_ImageDataDesc* desc); | 85 struct PP_ImageDataDesc* desc); |
85 | 86 |
86 /** | 87 /** |
87 * Maps this bitmap into the plugin address space and returns a pointer to the | 88 * Maps this bitmap into the plugin address space and returns a pointer to the |
88 * beginning of the data. | 89 * beginning of the data. |
89 */ | 90 */ |
90 void* (*Map)(PP_Resource image_data); | 91 void* (*Map)(PP_Resource image_data); |
91 | 92 |
92 void (*Unmap)(PP_Resource image_data); | 93 void (*Unmap)(PP_Resource image_data); |
93 }; | 94 }; |
94 | 95 |
95 /** | 96 /** |
96 * @} | 97 * @} |
97 * End addtogroup PPB | 98 * End addtogroup PPB |
98 */ | 99 */ |
99 #endif // PPAPI_C_PPB_IMAGE_DATA_H_ | 100 #endif // PPAPI_C_PPB_IMAGE_DATA_H_ |
OLD | NEW |