blob: c25615f8d4f088111639ef76217f477e2b3e9738 [file] [log] [blame]
[email protected]6ea69542010-12-20 18:15:591/* 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
3 * found in the LICENSE file.
4 */
[email protected]1758e882010-11-01 16:16:505#ifndef PPAPI_C_PPB_IMAGE_DATA_H_
6#define PPAPI_C_PPB_IMAGE_DATA_H_
7
[email protected]6f2e3912010-11-05 14:45:448#include "ppapi/c/pp_bool.h"
[email protected]7ca87c22011-01-07 05:33:209#include "ppapi/c/pp_instance.h"
[email protected]1ad2a1db2010-12-13 20:04:3110#include "ppapi/c/pp_macros.h"
[email protected]1758e882010-11-01 16:16:5011#include "ppapi/c/pp_module.h"
12#include "ppapi/c/pp_resource.h"
13#include "ppapi/c/pp_size.h"
14#include "ppapi/c/pp_stdint.h"
15
[email protected]040d5e82011-01-28 15:38:3816/**
17 * @file
[email protected]5651386f2011-03-09 23:25:5318 * This file defines the PPB_ImageData struct for determining how a browser
19 * handles image data.
[email protected]040d5e82011-01-28 15:38:3820 */
21
22/**
23 * @addtogroup Enums
24 * @{
25 */
26
[email protected]5651386f2011-03-09 23:25:5327/**
28 * PP_ImageDataFormat is an enumeration of the different types of
29 * image data formats.
[email protected]7af3e122011-03-23 18:23:5730 *
31 * 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
33 * is stored in the lowest address, no matter what endianness the platform is
34 * using.
[email protected]5651386f2011-03-09 23:25:5335 */
[email protected]1758e882010-11-01 16:16:5036typedef enum {
37 PP_IMAGEDATAFORMAT_BGRA_PREMUL,
38 PP_IMAGEDATAFORMAT_RGBA_PREMUL
39} PP_ImageDataFormat;
[email protected]1ad2a1db2010-12-13 20:04:3140PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_ImageDataFormat, 4);
[email protected]040d5e82011-01-28 15:38:3841/**
42 * @}
43 */
[email protected]1758e882010-11-01 16:16:5044
[email protected]040d5e82011-01-28 15:38:3845/**
46 * @addtogroup Structs
47 * @{
48 */
[email protected]5651386f2011-03-09 23:25:5349
50/**
51 * The PP_ImageDataDesc structure represents a description of image data.
52 */
[email protected]1758e882010-11-01 16:16:5053struct PP_ImageDataDesc {
[email protected]5651386f2011-03-09 23:25:5354
55 /**
56 * This value represents one of the image data types in the
57 * PP_ImageDataFormat enum.
58 */
[email protected]1758e882010-11-01 16:16:5059 PP_ImageDataFormat format;
60
[email protected]5651386f2011-03-09 23:25:5361 /** This value represents the size of the bitmap in pixels. */
[email protected]6f2e3912010-11-05 14:45:4462 struct PP_Size size;
[email protected]1758e882010-11-01 16:16:5063
[email protected]5651386f2011-03-09 23:25:5364 /**
65 * This value represents the row width in bytes. This may be different than
66 * width * 4 since there may be padding at the end of the lines.
[email protected]6ea69542010-12-20 18:15:5967 */
[email protected]1758e882010-11-01 16:16:5068 int32_t stride;
69};
[email protected]1ad2a1db2010-12-13 20:04:3170PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_ImageDataDesc, 16);
[email protected]040d5e82011-01-28 15:38:3871/**
72 * @}
73 */
[email protected]1758e882010-11-01 16:16:5074
[email protected]7ca87c22011-01-07 05:33:2075#define PPB_IMAGEDATA_INTERFACE "PPB_ImageData;0.3"
[email protected]1758e882010-11-01 16:16:5076
77/**
[email protected]040d5e82011-01-28 15:38:3878 * @addtogroup Interfaces
[email protected]1758e882010-11-01 16:16:5079 * @{
80 */
[email protected]5651386f2011-03-09 23:25:5381
82/**
83 * The PPB_ImageData interface contains pointers to several functions for
84 * determining the browser's treatment of image data.
85 */
[email protected]1758e882010-11-01 16:16:5086struct PPB_ImageData {
87 /**
[email protected]5651386f2011-03-09 23:25:5388 * GetNativeImageDataFormat is a pointer to a function that returns the
89 * browser's preferred format for image data. The browser uses this format
90 * internally for painting. Other formats may require internal conversions
91 * to paint or may have additional restrictions depending on the function.
92 *
93 * @return PP_ImageDataFormat containing the preferred format.
[email protected]1758e882010-11-01 16:16:5094 */
95 PP_ImageDataFormat (*GetNativeImageDataFormat)();
96
97 /**
[email protected]5651386f2011-03-09 23:25:5398 * IsImageDataFormatSupported is a pointer to a function that determines if
99 * the given image data format is supported by the browser.
100 *
101 * @param[in] format The image data format.
102 * @return PP_Bool with PP_TRUE if the given image data format is supported
103 * by the browser.
[email protected]1758e882010-11-01 16:16:50104 */
[email protected]6f2e3912010-11-05 14:45:44105 PP_Bool (*IsImageDataFormatSupported)(PP_ImageDataFormat format);
[email protected]1758e882010-11-01 16:16:50106
107 /**
[email protected]5651386f2011-03-09 23:25:53108 * Create is a pointer to a function that allocates an image data resource
109 * with the given format and size.
[email protected]1758e882010-11-01 16:16:50110 *
[email protected]5651386f2011-03-09 23:25:53111 * For security reasons, if uninitialized, the bitmap will not contain random
112 * memory, but may contain data from a previous image produced by the same
113 * plugin if the bitmap was cached and re-used.
114 *
115 * @param[in] instance A PP_Instance indentifying one instance of a module.
116 * @param[in] format The desired image data format.
117 * @param[in] size A pointer to a PP_Size containing the image size.
118 * @param[in] init_to_zero A PP_Bool to determine transparency at creation.
[email protected]1758e882010-11-01 16:16:50119 * Set the init_to_zero flag if you want the bitmap initialized to
120 * transparent during the creation process. If this flag is not set, the
121 * current contents of the bitmap will be undefined, and the plugin should
122 * be sure to set all the pixels.
123 *
[email protected]5651386f2011-03-09 23:25:53124 * @return A PP_Resource with a nonzero ID on succes or zero on failure.
125 * Failure means the instance, image size, or format was invalid.
[email protected]1758e882010-11-01 16:16:50126 */
[email protected]7ca87c22011-01-07 05:33:20127 PP_Resource (*Create)(PP_Instance instance,
[email protected]1758e882010-11-01 16:16:50128 PP_ImageDataFormat format,
129 const struct PP_Size* size,
[email protected]6f2e3912010-11-05 14:45:44130 PP_Bool init_to_zero);
[email protected]1758e882010-11-01 16:16:50131
132 /**
[email protected]5651386f2011-03-09 23:25:53133 * IsImageData is a pointer to a function that determiens if a given resource
134 * is image data.
135 *
136 * @param[in] image_data A PP_Resource corresponding to image data.
137 * @return A PP_Bool with PP_TRUE if the given resrouce is an image data
138 * or PP_FALSE if the resource is invalid or some type other than image data.
[email protected]1758e882010-11-01 16:16:50139 */
[email protected]6f2e3912010-11-05 14:45:44140 PP_Bool (*IsImageData)(PP_Resource image_data);
[email protected]1758e882010-11-01 16:16:50141
142 /**
[email protected]5651386f2011-03-09 23:25:53143 * Describe is a pointer to a function that computes the description of the
144 * image data.
145 *
146 * @param[in] image_data A PP_Resource corresponding to image data.
147 * @param[in/out] desc A pointer to a PP_ImageDataDesc containing the
148 * description.
149 * @return A PP_Bool with PP_TRUE on success or PP_FALSE
150 * if the resource is not an image data. On PP_FALSE, the |desc|
[email protected]6f2e3912010-11-05 14:45:44151 * structure will be filled with 0.
[email protected]1758e882010-11-01 16:16:50152 */
[email protected]6f2e3912010-11-05 14:45:44153 PP_Bool (*Describe)(PP_Resource image_data,
154 struct PP_ImageDataDesc* desc);
[email protected]1758e882010-11-01 16:16:50155
156 /**
[email protected]5651386f2011-03-09 23:25:53157 * Map is a pointer to a function that maps an image data into the plugin
158 * address space.
159 *
160 * @param[in] image_data A PP_Resource corresponding to image data.
161 * @return A pointer to the beginning of the data.
[email protected]1758e882010-11-01 16:16:50162 */
163 void* (*Map)(PP_Resource image_data);
164
[email protected]5651386f2011-03-09 23:25:53165 /**
166 * Unmap is a pointer to a function that unmaps an image data from the plugin
167 * address space.
168 *
169 * @param[in] image_data A PP_Resource corresponding to image data.
170 */
[email protected]1758e882010-11-01 16:16:50171 void (*Unmap)(PP_Resource image_data);
172};
[email protected]1758e882010-11-01 16:16:50173/**
174 * @}
[email protected]1758e882010-11-01 16:16:50175 */
[email protected]040d5e82011-01-28 15:38:38176
[email protected]6ea69542010-12-20 18:15:59177#endif /* PPAPI_C_PPB_IMAGE_DATA_H_ */