Refactor android test results logging.
[chromium-blink-merge.git] / ppapi / api / ppb_image_data.idl
blob4934f796be41b844f4ab0404ab89abe580037f9c
1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
4 */
6 /**
7 * This file defines the <code>PPB_ImageData</code> struct for determining how
8 * a browser handles image data.
9 */
11 label Chrome {
12 M14 = 1.0
15 /**
16 * <code>PP_ImageDataFormat</code> is an enumeration of the different types of
17 * image data formats.
19 * The third part of each enumeration value describes the memory layout from
20 * the lowest address to the highest. For example, BGRA means the B component
21 * is stored in the lowest address, no matter what endianness the platform is
22 * using.
24 * The PREMUL suffix implies pre-multiplied alpha is used. In this mode, the
25 * red, green and blue color components of the pixel data supplied to an image
26 * data should be pre-multiplied by their alpha value. For example: starting
27 * with floating point color components, here is how to convert them to 8-bit
28 * premultiplied components for image data:
30 * ...components of a pixel, floats ranging from 0 to 1...
31 * <code>float red = 1.0f;</code>
32 * <code>float green = 0.50f;</code>
33 * <code>float blue = 0.0f;</code>
34 * <code>float alpha = 0.75f;</code>
35 * ...components for image data are 8-bit values ranging from 0 to 255...
36 * <code>uint8_t image_data_red_premul = (uint8_t)(red * alpha * 255.0f);
37 * </code>
38 * <code>uint8_t image_data_green_premul = (uint8_t)(green * alpha * 255.0f);
39 * </code>
40 * <code>uint8_t image_data_blue_premul = (uint8_t)(blue * alpha * 255.0f);
41 * </code>
42 * <code>uint8_t image_data_alpha_premul = (uint8_t)(alpha * 255.0f);</code>
44 * <strong>Note:</strong> The resulting pre-multiplied red, green and blue
45 * components should not be greater than the alpha value.
47 [assert_size(4)]
48 enum PP_ImageDataFormat {
49 PP_IMAGEDATAFORMAT_BGRA_PREMUL,
50 PP_IMAGEDATAFORMAT_RGBA_PREMUL
53 /**
54 * The <code>PP_ImageDataDesc</code> structure represents a description of
55 * image data.
57 [assert_size(16)]
58 struct PP_ImageDataDesc {
59 /**
60 * This value represents one of the image data types in the
61 * <code>PP_ImageDataFormat</code> enum.
63 PP_ImageDataFormat format;
65 /** This value represents the size of the bitmap in pixels. */
66 PP_Size size;
68 /**
69 * This value represents the row width in bytes. This may be different than
70 * width * 4 since there may be padding at the end of the lines.
72 int32_t stride;
75 /**
76 * The <code>PPB_ImageData</code> interface contains pointers to several
77 * functions for determining the browser's treatment of image data.
79 interface PPB_ImageData {
80 /**
81 * GetNativeImageDataFormat() returns the browser's preferred format for
82 * image data. The browser uses this format internally for painting. Other
83 * formats may require internal conversions to paint or may have additional
84 * restrictions depending on the function.
86 * @return A <code>PP_ImageDataFormat</code> containing the preferred format.
88 PP_ImageDataFormat GetNativeImageDataFormat();
90 /**
91 * IsImageDataFormatSupported() determines if the given image data format is
92 * supported by the browser. Note: <code>PP_IMAGEDATAFORMAT_BGRA_PREMUL</code>
93 * and <code>PP_IMAGEDATAFORMAT_RGBA_PREMUL</code> formats are always
94 * supported. Other image formats do not make this guarantee, and should be
95 * checked first with IsImageDataFormatSupported() before using.
97 * @param[in] format The image data format.
99 * @return A <code>PP_Bool</code> with <code>PP_TRUE</code> if the given
100 * image data format is supported by the browser.
102 PP_Bool IsImageDataFormatSupported(
103 [in] PP_ImageDataFormat format);
106 * Create() allocates an image data resource with the given format and size.
108 * For security reasons, if uninitialized, the bitmap will not contain random
109 * memory, but may contain data from a previous image produced by the same
110 * module if the bitmap was cached and re-used.
112 * @param[in] instance A <code>PP_Instance</code> identifying one instance
113 * of a module.
114 * @param[in] format The desired image data format.
115 * @param[in] size A pointer to a <code>PP_Size</code> containing the image
116 * size.
117 * @param[in] init_to_zero A <code>PP_Bool</code> to determine transparency
118 * at creation.
119 * Set the <code>init_to_zero</code> flag if you want the bitmap initialized
120 * to transparent during the creation process. If this flag is not set, the
121 * current contents of the bitmap will be undefined, and the module should
122 * be sure to set all the pixels.
124 * @return A <code>PP_Resource</code> with a nonzero ID on success or zero on
125 * failure. Failure means the instance, image size, or format was invalid.
127 PP_Resource Create(
128 [in] PP_Instance instance,
129 [in] PP_ImageDataFormat format,
130 [in] PP_Size size,
131 [in] PP_Bool init_to_zero);
134 * IsImageData() determines if a given resource is image data.
136 * @param[in] image_data A <code>PP_Resource</code> corresponding to image
137 * data.
139 * @return A <code>PP_Bool</code> with <code>PP_TRUE</code> if the given
140 * resource is an image data or <code>PP_FALSE</code> if the resource is
141 * invalid or some type other than image data.
143 PP_Bool IsImageData(
144 [in] PP_Resource image_data);
147 * Describe() computes the description of the
148 * image data.
150 * @param[in] image_data A <code>PP_Resource</code> corresponding to image
151 * data.
152 * @param[in,out] desc A pointer to a <code>PP_ImageDataDesc</code>
153 * containing the description.
155 * @return A <code>PP_Bool</code> with <code>PP_TRUE</code> on success or
156 * <code>PP_FALSE</code> if the resource is not an image data. On
157 * <code>PP_FALSE</code>, the <code>desc</code> structure will be filled
158 * with 0.
160 PP_Bool Describe(
161 [in] PP_Resource image_data,
162 [out] PP_ImageDataDesc desc);
165 * Map() maps an image data into the module address space.
167 * @param[in] image_data A <code>PP_Resource</code> corresponding to image
168 * data.
170 * @return A pointer to the beginning of the data.
172 mem_t Map(
173 [in] PP_Resource image_data);
176 * Unmap is a pointer to a function that unmaps an image data from the module
177 * address space.
179 * @param[in] image_data A <code>PP_Resource</code> corresponding to image
180 * data.
182 void Unmap(
183 [in] PP_Resource image_data);