Chromium Code Reviews
|
| OLD | NEW |
|---|---|
| (Empty) | |
| 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 */ | |
| 5 | |
| 6 /** | |
| 7 * Defines the <code>PPB_Graphics3D</code> struct representing a 3D graphics | |
| 8 * context within the browser. | |
| 9 */ | |
| 10 | |
| 11 label Chrome { | |
| 12 M15 = 1.0 | |
| 13 }; | |
| 14 | |
| 15 /** | |
| 16 * <code>PPB_Graphics3D</code> defines the interface for a 3D graphics context. | |
| 17 * <strong>Example usage from plugin code:</strong> | |
| 18 * | |
| 19 * <strong>Setup:</strong> | |
| 20 * <code> | |
| 21 * PP_Resource context; | |
| 22 * int32_t attribs[] = {PP_GRAPHICS3DATTRIB_WIDTH, 800, | |
| 23 * PP_GRAPHICS3DATTRIB_HEIGHT, 800, | |
| 24 * PP_GRAPHICS3DATTRIB_NONE}; | |
| 25 * context = g3d->Create(instance, attribs, &context); | |
| 26 * inst->BindGraphics(instance, context); | |
| 27 * </code> | |
| 28 * | |
| 29 * <strong>Present one frame:</strong> | |
| 30 * <code> | |
| 31 * gles2->Clear(context, GL_COLOR_BUFFER); | |
| 32 * g3d->SwapBuffers(context); | |
| 33 * </code> | |
| 34 * | |
| 35 * <strong>Shutdown:</strong> | |
| 36 * <code> | |
| 37 * core->ReleaseResource(context); | |
| 38 * </code> | |
| 39 */ | |
| 40 interface PPB_Graphics3D { | |
| 41 /** | |
| 42 * GetAttribMaxValue() retrieves the maximum supported value for the | |
| 43 * given attribute. This function may be used to check if a particular | |
| 44 * attribute value is supported before attempting to create a context. | |
| 45 * | |
| 46 * @param[in] instance The module instance. | |
| 47 * @param[in] attribute The attribute for which maximum value is queried. | |
| 48 * Attributes that can be queried for include: | |
| 49 * - <code>PP_GRAPHICS3DATTRIB_ALPHA_SIZE</code> | |
| 50 * - <code>PP_GRAPHICS3DATTRIB_BLUE_SIZE</code> | |
| 51 * - <code>PP_GRAPHICS3DATTRIB_GREEN_SIZE</code> | |
| 52 * - <code>PP_GRAPHICS3DATTRIB_RED_SIZE</code> | |
| 53 * - <code>PP_GRAPHICS3DATTRIB_DEPTH_SIZE</code> | |
| 54 * - <code>PP_GRAPHICS3DATTRIB_STENCIL_SIZE</code> | |
| 55 * - <code>PP_GRAPHICS3DATTRIB_SAMPLES</code> | |
| 56 * - <code>PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS</code> | |
| 57 * - <code>PP_GRAPHICS3DATTRIB_WIDTH</code> | |
| 58 * - <code>PP_GRAPHICS3DATTRIB_HEIGHT</code> | |
| 59 * @param[out] value The maximum supported value for <code>attribute</code> | |
| 60 * | |
| 61 * @return Returns <code>PP_TRUE</code> on success or the following on error: | |
| 62 * - <code>PP_ERROR_BADRESOURCE</code> if <code>instance</code> is invalid | |
| 63 * - <code>PP_ERROR_BADARGUMENT</code> if <code>attribute</code> is invalid | |
| 64 * or <code>value</code> is 0 | |
| 65 */ | |
| 66 int32_t GetAttribMaxValue( | |
| 67 [in] PP_Resource instance, | |
| 68 [in] int32_t attribute, | |
| 69 [out] int32_t[] value); | |
|
noelallen1
2012/02/06 22:26:57
This is a value, not an array. [out] int32_t valu
alokp
2012/02/06 22:32:47
done.
| |
| 70 | |
| 71 /** | |
| 72 * Create() creates and initializes a 3D rendering context. | |
| 73 * The returned context is off-screen to start with. It must be attached to | |
| 74 * a plugin instance using <code>PPB_Instance::BindGraphics</code> to draw | |
| 75 * on the web page. | |
| 76 * | |
| 77 * @param[in] instance The module instance. | |
| 78 * | |
| 79 * @param[in] share_context The 3D context with which the created context | |
| 80 * would share resources. If <code>share_context</code> is not 0, then all | |
| 81 * shareable data, as defined by the client API (note that for OpenGL and | |
| 82 * OpenGL ES, shareable data excludes texture objects named 0) will be shared | |
| 83 * by <code>share_context<code>, all other contexts <code>share_context</code> | |
| 84 * already shares with, and the newly created context. An arbitrary number of | |
| 85 * <code>PPB_Graphics3D</code> can share data in this fashion. | |
| 86 * | |
| 87 * @param[out] attrib_list specifies a list of attributes for the context. | |
| 88 * It is a list of attribute name-value pairs in which each attribute is | |
| 89 * immediately followed by the corresponding desired value. The list is | |
| 90 * terminated with <code>PP_GRAPHICS3DATTRIB_NONE</code>. | |
| 91 * The <code>attrib_list<code> may be 0 or empty (first attribute is | |
| 92 * <code>PP_GRAPHICS3DATTRIB_NONE</code>). If an attribute is not | |
| 93 * specified in <code>attrib_list</code>, then the default value is used | |
| 94 * (it is said to be specified implicitly). | |
| 95 * Attributes for the context are chosen according to an attribute-specific | |
| 96 * criteria. Attributes can be classified into two categories: | |
| 97 * - AtLeast: The attribute value in the returned context meets or exceeds | |
| 98 * the value specified in <code>attrib_list</code>. | |
| 99 * - Exact: The attribute value in the returned context is equal to | |
| 100 * the value specified in <code>attrib_list</code>. | |
| 101 * | |
| 102 * Attributes that can be specified in <code>attrib_list</code> include: | |
| 103 * - <code>PP_GRAPHICS3DATTRIB_ALPHA_SIZE</code>: | |
| 104 * Category: AtLeast Default: 0. | |
| 105 * - <code>PP_GRAPHICS3DATTRIB_BLUE_SIZE</code>: | |
| 106 * Category: AtLeast Default: 0. | |
| 107 * - <code>PP_GRAPHICS3DATTRIB_GREEN_SIZE</code>: | |
| 108 * Category: AtLeast Default: 0. | |
| 109 * - <code>PP_GRAPHICS3DATTRIB_RED_SIZE</code>: | |
| 110 * Category: AtLeast Default: 0. | |
| 111 * - <code>PP_GRAPHICS3DATTRIB_DEPTH_SIZE</code>: | |
| 112 * Category: AtLeast Default: 0. | |
| 113 * - <code>PP_GRAPHICS3DATTRIB_STENCIL_SIZE</code>: | |
| 114 * Category: AtLeast Default: 0. | |
| 115 * - <code>PP_GRAPHICS3DATTRIB_SAMPLES</code>: | |
| 116 * Category: AtLeast Default: 0. | |
| 117 * - <code>PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS</code>: | |
| 118 * Category: AtLeast Default: 0. | |
| 119 * - <code>PP_GRAPHICS3DATTRIB_WIDTH</code>: | |
| 120 * Category: Exact Default: 0. | |
| 121 * - <code>PP_GRAPHICS3DATTRIB_HEIGHT</code>: | |
| 122 * Category: Exact Default: 0. | |
| 123 * - <code>PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR</code>: | |
| 124 * Category: Exact Default: Implementation defined. | |
| 125 * | |
| 126 * @return A <code>PP_Resource</code> containing the 3D graphics context if | |
| 127 * successful or 0 if unsuccessful. | |
| 128 */ | |
| 129 PP_Resource Create( | |
| 130 [in] PP_Instance instance, | |
| 131 [in] PP_Resource share_context, | |
| 132 [in] int32_t[] attrib_list); | |
| 133 | |
| 134 /** | |
| 135 * IsGraphics3D() determines if the given resource is a valid | |
| 136 * <code>Graphics3D</code> context. | |
| 137 * | |
| 138 * @param[in] resource A <code>Graphics3D</code> context resource. | |
| 139 * | |
| 140 * @return PP_TRUE if the given resource is a valid <code>Graphics3D</code>, | |
| 141 * <code>PP_FALSE</code> if it is an invalid resource or is a resource of | |
| 142 * another type. | |
| 143 */ | |
| 144 PP_Bool IsGraphics3D( | |
| 145 [in] PP_Resource resource); | |
| 146 | |
| 147 /** | |
| 148 * GetAttribs() retrieves the value for each attribute in | |
| 149 * <code>attrib_list</code>. | |
| 150 * | |
| 151 * @param[in] context The 3D graphics context. | |
| 152 * @param[in,out] attrib_list The list of attributes that are queried. | |
| 153 * <code>attrib_list</code> has the same structure as described for | |
| 154 * <code>PPB_Graphics3D::Create</code>. It is both input and output | |
| 155 * structure for this function. All attributes specified in | |
| 156 * <code>PPB_Graphics3D::Create</code> can be queried for. | |
| 157 * | |
| 158 * @return Returns <code>PP_OK</code> on success or: | |
| 159 * - <code>PP_ERROR_BADRESOURCE</code> if context is invalid | |
| 160 * - <code>PP_ERROR_BADARGUMENT</code> if attrib_list is 0 or any attribute | |
| 161 * in the <code>attrib_list</code> is not a valid attribute. | |
| 162 * | |
| 163 * <strong>Example usage:</strong> To get the values for rgb bits in the | |
| 164 * color buffer, this function must be called as following: | |
| 165 * <code> | |
| 166 * int attrib_list[] = {PP_GRAPHICS3DATTRIB_RED_SIZE, 0, | |
| 167 * PP_GRAPHICS3DATTRIB_GREEN_SIZE, 0, | |
| 168 * PP_GRAPHICS3DATTRIB_BLUE_SIZE, 0, | |
| 169 * PP_GRAPHICS3DATTRIB_NONE}; | |
| 170 * GetAttribs(context, attrib_list); | |
| 171 * int red_bits = attrib_list[1]; | |
| 172 * int green_bits = attrib_list[3]; | |
| 173 * int blue_bits = attrib_list[5]; | |
| 174 * </code> | |
| 175 */ | |
| 176 int32_t GetAttribs( | |
| 177 [in] PP_Resource context, | |
| 178 [out] int32_t[] attrib_list); | |
|
noelallen1
2012/02/06 22:26:57
inout not just out. Out implies that we are alloc
alokp
2012/02/06 22:32:47
Changing it to inout did not fix it. I still have
| |
| 179 | |
| 180 /** | |
| 181 * SetAttribs() sets the values for each attribute in | |
| 182 * <code>attrib_list</code>. | |
| 183 * | |
| 184 * @param[in] context The 3D graphics context. | |
| 185 * @param[in] attrib_list The list of attributes whose values need to be set. | |
| 186 * <code>attrib_list</code> has the same structure as described for | |
| 187 * <code>PPB_Graphics3D::Create</code>. | |
| 188 * Attributes that can be specified are: | |
| 189 * - <code>PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR</code> | |
| 190 * | |
| 191 * @return Returns <code>PP_OK</code> on success or: | |
| 192 * - <code>PP_ERROR_BADRESOURCE</code> if <code>context</code> is invalid. | |
| 193 * - <code>PP_ERROR_BADARGUMENT</code> if <code>attrib_list</code> is 0 or | |
| 194 * any attribute in the <code>attrib_list</code> is not a valid attribute. | |
| 195 */ | |
| 196 int32_t SetAttribs( | |
| 197 [in] PP_Resource context, | |
| 198 [in] int32_t[] attrib_list); | |
| 199 | |
| 200 /** | |
| 201 * GetError() returns the current state of the given 3D context. | |
| 202 * | |
| 203 * The recoverable error conditions that have no side effect are | |
| 204 * detected and returned immediately by all functions in this interface. | |
| 205 * In addition the implementation may get into a fatal state while | |
| 206 * processing a command. In this case the application must detroy the | |
| 207 * context and reinitialize client API state and objects to continue | |
| 208 * rendering. | |
| 209 * | |
| 210 * Note that the same error code is also returned in the SwapBuffers callback. | |
| 211 * It is recommended to handle error in the SwapBuffers callback because | |
| 212 * GetError is synchronous. This function may be useful in rare cases where | |
| 213 * drawing a frame is expensive and you want to verify the result of | |
| 214 * ResizeBuffers before attemptimg to draw a frame. | |
| 215 * | |
| 216 * @param[in] The 3D graphics context. | |
| 217 * @return Returns: | |
| 218 * - <code>PP_OK</code> if no error | |
| 219 * - <code>PP_ERROR_NOMEMORY</code> | |
| 220 * - <code>PP_ERROR_CONTEXT_LOST</code> | |
| 221 */ | |
| 222 int32_t GetError( | |
| 223 [in] PP_Resource context); | |
| 224 | |
| 225 /** | |
| 226 * ResizeBuffers() resizes the backing surface for context. | |
| 227 * | |
| 228 * If the surface could not be resized due to insufficient resources, | |
| 229 * <code>PP_ERROR_NOMEMORY</code> error is returned on the next | |
| 230 * <code>SwapBuffers</code> callback. | |
| 231 * | |
| 232 * @param[in] context The 3D graphics context. | |
| 233 * @param[in] width The width of the backing surface. | |
| 234 * @param[in] height The height of the backing surface. | |
| 235 * @return Returns <code>PP_OK</code> on success or: | |
| 236 * - <code>PP_ERROR_BADRESOURCE</code> if context is invalid. | |
| 237 * - <code>PP_ERROR_BADARGUMENT</code> if the value specified for | |
| 238 * <code>width</code> or <code>height</code> is less than zero. | |
| 239 */ | |
| 240 int32_t ResizeBuffers( | |
| 241 [in] PP_Resource context, | |
| 242 [in] int32_t width, | |
| 243 [in] int32_t height); | |
| 244 | |
| 245 /** | |
| 246 * SwapBuffers() makes the contents of the color buffer available for | |
| 247 * compositing. This function has no effect on off-screen surfaces - ones not | |
| 248 * bound to any plugin instance. The contents of ancillary buffers are always | |
| 249 * undefined after calling <code>SwapBuffers</code>. The contents of the color | |
| 250 * buffer are undefined if the value of the | |
| 251 * <code>PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR</code> attribute of context is not | |
| 252 * <code>PP_GRAPHICS3DATTRIB_BUFFER_PRESERVED</code>. | |
| 253 * | |
| 254 * <code>SwapBuffers</code> runs in asynchronous mode. Specify a callback | |
| 255 * function and the argument for that callback function. The callback function | |
| 256 * will be executed on the calling thread after the color buffer has been | |
| 257 * composited with rest of the html page. While you are waiting for a | |
| 258 * SwapBuffers callback, additional calls to SwapBuffers will fail. | |
| 259 * | |
| 260 * Because the callback is executed (or thread unblocked) only when the | |
| 261 * plugin's current state is actually on the screen, this function provides a | |
| 262 * way to rate limit animations. By waiting until the image is on the screen | |
| 263 * before painting the next frame, you can ensure you're not generating | |
| 264 * updates faster than the screen can be updated. | |
| 265 * | |
| 266 * SwapBuffers performs an implicit flush operation on context. | |
| 267 * If the context gets into an unrecoverable error condition while | |
| 268 * processing a command, the error code will be returned as the argument | |
| 269 * for the callback. The callback may return the following error codes: | |
| 270 * - <code>PP_ERROR_NOMEMORY</code> | |
| 271 * - <code>PP_ERROR_CONTEXT_LOST</code> | |
| 272 * Note that the same error code may also be obtained by calling GetError. | |
| 273 * | |
| 274 * @param[in] context The 3D graphics context. | |
| 275 * @param[in] callback The callback that will executed when | |
| 276 * <code>SwapBuffers</code> completes. | |
| 277 * | |
| 278 * @return Returns PP_OK on success or: | |
| 279 * - <code>PP_ERROR_BADRESOURCE</code> if context is invalid. | |
| 280 * - <code>PP_ERROR_BADARGUMENT</code> if callback is invalid. | |
| 281 * | |
| 282 */ | |
| 283 int32_t SwapBuffers( | |
| 284 [in] PP_Resource context, | |
| 285 [in] PP_CompletionCallback callback); | |
| 286 }; | |
| 287 | |
| OLD | NEW |