diff options
author | alokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-10 09:39:55 +0000 |
---|---|---|
committer | alokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-10 09:39:55 +0000 |
commit | af9388e71330d539947284bbc18297de4d64df36 (patch) | |
tree | 721d8aad75904e25c699cb6f0104b661ead1b151 | |
parent | 1cb53a36fa25d7afedb5a0b550e43a541f892c8b (diff) | |
download | chromium_src-af9388e71330d539947284bbc18297de4d64df36.zip chromium_src-af9388e71330d539947284bbc18297de4d64df36.tar.gz chromium_src-af9388e71330d539947284bbc18297de4d64df36.tar.bz2 |
Added idl file for Pepper 3D.
Review URL: http://codereview.chromium.org/9340003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121419 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ppapi/api/ppb_graphics_3d.idl | 293 | ||||
-rw-r--r-- | ppapi/c/ppb_graphics_3d.h | 314 | ||||
-rw-r--r-- | ppapi/cpp/graphics_3d.cc | 10 | ||||
-rw-r--r-- | ppapi/cpp/graphics_3d.h | 10 | ||||
-rw-r--r-- | ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.cc | 10 | ||||
-rw-r--r-- | ppapi/shared_impl/ppb_graphics_3d_shared.cc | 4 | ||||
-rw-r--r-- | ppapi/shared_impl/ppb_graphics_3d_shared.h | 4 | ||||
-rw-r--r-- | ppapi/thunk/ppb_graphics_3d_api.h | 6 | ||||
-rw-r--r-- | ppapi/thunk/ppb_graphics_3d_thunk.cc | 6 |
9 files changed, 511 insertions, 146 deletions
diff --git a/ppapi/api/ppb_graphics_3d.idl b/ppapi/api/ppb_graphics_3d.idl new file mode 100644 index 0000000..454b3e3 --- /dev/null +++ b/ppapi/api/ppb_graphics_3d.idl @@ -0,0 +1,293 @@ +/* Copyright (c) 2012 The Chromium Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/** + * Defines the <code>PPB_Graphics3D</code> struct representing a 3D graphics + * context within the browser. + */ + +label Chrome { + M15 = 1.0 +}; + +#inline c +/* Add 3D graphics enums */ +#include "ppapi/c/pp_graphics_3d.h" +#endinl + +/** + * <code>PPB_Graphics3D</code> defines the interface for a 3D graphics context. + * <strong>Example usage from plugin code:</strong> + * + * <strong>Setup:</strong> + * <code> + * PP_Resource context; + * int32_t attribs[] = {PP_GRAPHICS3DATTRIB_WIDTH, 800, + * PP_GRAPHICS3DATTRIB_HEIGHT, 800, + * PP_GRAPHICS3DATTRIB_NONE}; + * context = g3d->Create(instance, attribs, &context); + * inst->BindGraphics(instance, context); + * </code> + * + * <strong>Present one frame:</strong> + * <code> + * gles2->Clear(context, GL_COLOR_BUFFER); + * g3d->SwapBuffers(context); + * </code> + * + * <strong>Shutdown:</strong> + * <code> + * core->ReleaseResource(context); + * </code> + */ +[macro="PPB_GRAPHICS_3D_INTERFACE"] +interface PPB_Graphics3D { + /** + * GetAttribMaxValue() retrieves the maximum supported value for the + * given attribute. This function may be used to check if a particular + * attribute value is supported before attempting to create a context. + * + * @param[in] instance The module instance. + * @param[in] attribute The attribute for which maximum value is queried. + * Attributes that can be queried for include: + * - <code>PP_GRAPHICS3DATTRIB_ALPHA_SIZE</code> + * - <code>PP_GRAPHICS3DATTRIB_BLUE_SIZE</code> + * - <code>PP_GRAPHICS3DATTRIB_GREEN_SIZE</code> + * - <code>PP_GRAPHICS3DATTRIB_RED_SIZE</code> + * - <code>PP_GRAPHICS3DATTRIB_DEPTH_SIZE</code> + * - <code>PP_GRAPHICS3DATTRIB_STENCIL_SIZE</code> + * - <code>PP_GRAPHICS3DATTRIB_SAMPLES</code> + * - <code>PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS</code> + * - <code>PP_GRAPHICS3DATTRIB_WIDTH</code> + * - <code>PP_GRAPHICS3DATTRIB_HEIGHT</code> + * @param[out] value The maximum supported value for <code>attribute</code> + * + * @return Returns <code>PP_TRUE</code> on success or the following on error: + * - <code>PP_ERROR_BADRESOURCE</code> if <code>instance</code> is invalid + * - <code>PP_ERROR_BADARGUMENT</code> if <code>attribute</code> is invalid + * or <code>value</code> is 0 + */ + int32_t GetAttribMaxValue( + [in] PP_Resource instance, + [in] int32_t attribute, + [out] int32_t value); + + /** + * Create() creates and initializes a 3D rendering context. + * The returned context is off-screen to start with. It must be attached to + * a plugin instance using <code>PPB_Instance::BindGraphics</code> to draw + * on the web page. + * + * @param[in] instance The module instance. + * + * @param[in] share_context The 3D context with which the created context + * would share resources. If <code>share_context</code> is not 0, then all + * shareable data, as defined by the client API (note that for OpenGL and + * OpenGL ES, shareable data excludes texture objects named 0) will be shared + * by <code>share_context<code>, all other contexts <code>share_context</code> + * already shares with, and the newly created context. An arbitrary number of + * <code>PPB_Graphics3D</code> can share data in this fashion. + * + * @param[out] attrib_list specifies a list of attributes for the context. + * It is a list of attribute name-value pairs in which each attribute is + * immediately followed by the corresponding desired value. The list is + * terminated with <code>PP_GRAPHICS3DATTRIB_NONE</code>. + * The <code>attrib_list<code> may be 0 or empty (first attribute is + * <code>PP_GRAPHICS3DATTRIB_NONE</code>). If an attribute is not + * specified in <code>attrib_list</code>, then the default value is used + * (it is said to be specified implicitly). + * Attributes for the context are chosen according to an attribute-specific + * criteria. Attributes can be classified into two categories: + * - AtLeast: The attribute value in the returned context meets or exceeds + * the value specified in <code>attrib_list</code>. + * - Exact: The attribute value in the returned context is equal to + * the value specified in <code>attrib_list</code>. + * + * Attributes that can be specified in <code>attrib_list</code> include: + * - <code>PP_GRAPHICS3DATTRIB_ALPHA_SIZE</code>: + * Category: AtLeast Default: 0. + * - <code>PP_GRAPHICS3DATTRIB_BLUE_SIZE</code>: + * Category: AtLeast Default: 0. + * - <code>PP_GRAPHICS3DATTRIB_GREEN_SIZE</code>: + * Category: AtLeast Default: 0. + * - <code>PP_GRAPHICS3DATTRIB_RED_SIZE</code>: + * Category: AtLeast Default: 0. + * - <code>PP_GRAPHICS3DATTRIB_DEPTH_SIZE</code>: + * Category: AtLeast Default: 0. + * - <code>PP_GRAPHICS3DATTRIB_STENCIL_SIZE</code>: + * Category: AtLeast Default: 0. + * - <code>PP_GRAPHICS3DATTRIB_SAMPLES</code>: + * Category: AtLeast Default: 0. + * - <code>PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS</code>: + * Category: AtLeast Default: 0. + * - <code>PP_GRAPHICS3DATTRIB_WIDTH</code>: + * Category: Exact Default: 0. + * - <code>PP_GRAPHICS3DATTRIB_HEIGHT</code>: + * Category: Exact Default: 0. + * - <code>PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR</code>: + * Category: Exact Default: Implementation defined. + * + * @return A <code>PP_Resource</code> containing the 3D graphics context if + * successful or 0 if unsuccessful. + */ + PP_Resource Create( + [in] PP_Instance instance, + [in] PP_Resource share_context, + [in] int32_t[] attrib_list); + + /** + * IsGraphics3D() determines if the given resource is a valid + * <code>Graphics3D</code> context. + * + * @param[in] resource A <code>Graphics3D</code> context resource. + * + * @return PP_TRUE if the given resource is a valid <code>Graphics3D</code>, + * <code>PP_FALSE</code> if it is an invalid resource or is a resource of + * another type. + */ + PP_Bool IsGraphics3D( + [in] PP_Resource resource); + + /** + * GetAttribs() retrieves the value for each attribute in + * <code>attrib_list</code>. + * + * @param[in] context The 3D graphics context. + * @param[in,out] attrib_list The list of attributes that are queried. + * <code>attrib_list</code> has the same structure as described for + * <code>PPB_Graphics3D::Create</code>. It is both input and output + * structure for this function. All attributes specified in + * <code>PPB_Graphics3D::Create</code> can be queried for. + * + * @return Returns <code>PP_OK</code> on success or: + * - <code>PP_ERROR_BADRESOURCE</code> if context is invalid + * - <code>PP_ERROR_BADARGUMENT</code> if attrib_list is 0 or any attribute + * in the <code>attrib_list</code> is not a valid attribute. + * + * <strong>Example usage:</strong> To get the values for rgb bits in the + * color buffer, this function must be called as following: + * <code> + * int attrib_list[] = {PP_GRAPHICS3DATTRIB_RED_SIZE, 0, + * PP_GRAPHICS3DATTRIB_GREEN_SIZE, 0, + * PP_GRAPHICS3DATTRIB_BLUE_SIZE, 0, + * PP_GRAPHICS3DATTRIB_NONE}; + * GetAttribs(context, attrib_list); + * int red_bits = attrib_list[1]; + * int green_bits = attrib_list[3]; + * int blue_bits = attrib_list[5]; + * </code> + */ + int32_t GetAttribs( + [in] PP_Resource context, + [inout] int32_t[] attrib_list); + + /** + * SetAttribs() sets the values for each attribute in + * <code>attrib_list</code>. + * + * @param[in] context The 3D graphics context. + * @param[in] attrib_list The list of attributes whose values need to be set. + * <code>attrib_list</code> has the same structure as described for + * <code>PPB_Graphics3D::Create</code>. + * Attributes that can be specified are: + * - <code>PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR</code> + * + * @return Returns <code>PP_OK</code> on success or: + * - <code>PP_ERROR_BADRESOURCE</code> if <code>context</code> is invalid. + * - <code>PP_ERROR_BADARGUMENT</code> if <code>attrib_list</code> is 0 or + * any attribute in the <code>attrib_list</code> is not a valid attribute. + */ + int32_t SetAttribs( + [in] PP_Resource context, + [in] int32_t[] attrib_list); + + /** + * GetError() returns the current state of the given 3D context. + * + * The recoverable error conditions that have no side effect are + * detected and returned immediately by all functions in this interface. + * In addition the implementation may get into a fatal state while + * processing a command. In this case the application must detroy the + * context and reinitialize client API state and objects to continue + * rendering. + * + * Note that the same error code is also returned in the SwapBuffers callback. + * It is recommended to handle error in the SwapBuffers callback because + * GetError is synchronous. This function may be useful in rare cases where + * drawing a frame is expensive and you want to verify the result of + * ResizeBuffers before attemptimg to draw a frame. + * + * @param[in] The 3D graphics context. + * @return Returns: + * - <code>PP_OK</code> if no error + * - <code>PP_ERROR_NOMEMORY</code> + * - <code>PP_ERROR_CONTEXT_LOST</code> + */ + int32_t GetError( + [in] PP_Resource context); + + /** + * ResizeBuffers() resizes the backing surface for context. + * + * If the surface could not be resized due to insufficient resources, + * <code>PP_ERROR_NOMEMORY</code> error is returned on the next + * <code>SwapBuffers</code> callback. + * + * @param[in] context The 3D graphics context. + * @param[in] width The width of the backing surface. + * @param[in] height The height of the backing surface. + * @return Returns <code>PP_OK</code> on success or: + * - <code>PP_ERROR_BADRESOURCE</code> if context is invalid. + * - <code>PP_ERROR_BADARGUMENT</code> if the value specified for + * <code>width</code> or <code>height</code> is less than zero. + */ + int32_t ResizeBuffers( + [in] PP_Resource context, + [in] int32_t width, + [in] int32_t height); + + /** + * SwapBuffers() makes the contents of the color buffer available for + * compositing. This function has no effect on off-screen surfaces - ones not + * bound to any plugin instance. The contents of ancillary buffers are always + * undefined after calling <code>SwapBuffers</code>. The contents of the color + * buffer are undefined if the value of the + * <code>PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR</code> attribute of context is not + * <code>PP_GRAPHICS3DATTRIB_BUFFER_PRESERVED</code>. + * + * <code>SwapBuffers</code> runs in asynchronous mode. Specify a callback + * function and the argument for that callback function. The callback function + * will be executed on the calling thread after the color buffer has been + * composited with rest of the html page. While you are waiting for a + * SwapBuffers callback, additional calls to SwapBuffers will fail. + * + * Because the callback is executed (or thread unblocked) only when the + * plugin's current state is actually on the screen, this function provides a + * way to rate limit animations. By waiting until the image is on the screen + * before painting the next frame, you can ensure you're not generating + * updates faster than the screen can be updated. + * + * SwapBuffers performs an implicit flush operation on context. + * If the context gets into an unrecoverable error condition while + * processing a command, the error code will be returned as the argument + * for the callback. The callback may return the following error codes: + * - <code>PP_ERROR_NOMEMORY</code> + * - <code>PP_ERROR_CONTEXT_LOST</code> + * Note that the same error code may also be obtained by calling GetError. + * + * @param[in] context The 3D graphics context. + * @param[in] callback The callback that will executed when + * <code>SwapBuffers</code> completes. + * + * @return Returns PP_OK on success or: + * - <code>PP_ERROR_BADRESOURCE</code> if context is invalid. + * - <code>PP_ERROR_BADARGUMENT</code> if callback is invalid. + * + */ + int32_t SwapBuffers( + [in] PP_Resource context, + [in] PP_CompletionCallback callback); +}; + diff --git a/ppapi/c/ppb_graphics_3d.h b/ppapi/c/ppb_graphics_3d.h index 9e8ae099..8f482e6 100644 --- a/ppapi/c/ppb_graphics_3d.h +++ b/ppapi/c/ppb_graphics_3d.h @@ -2,127 +2,181 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ + +/* From ppb_graphics_3d.idl modified Tue Feb 07 11:38:46 2012. */ + #ifndef PPAPI_C_PPB_GRAPHICS_3D_H_ #define PPAPI_C_PPB_GRAPHICS_3D_H_ -#include "ppapi/c/pp_graphics_3d.h" - #include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" +#include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" +#include "ppapi/c/pp_stdint.h" -/* Example usage from plugin code: +#define PPB_GRAPHICS_3D_INTERFACE_1_0 "PPB_Graphics3D;1.0" +#define PPB_GRAPHICS_3D_INTERFACE PPB_GRAPHICS_3D_INTERFACE_1_0 + +/** + * @file + * Defines the <code>PPB_Graphics3D</code> struct representing a 3D graphics + * context within the browser. + */ + + +/* Add 3D graphics enums */ +#include "ppapi/c/pp_graphics_3d.h" + +/** + * @addtogroup Interfaces + * @{ + */ +/** + * <code>PPB_Graphics3D</code> defines the interface for a 3D graphics context. + * <strong>Example usage from plugin code:</strong> * - * // Setup. + * <strong>Setup:</strong> + * <code> * PP_Resource context; * int32_t attribs[] = {PP_GRAPHICS3DATTRIB_WIDTH, 800, * PP_GRAPHICS3DATTRIB_HEIGHT, 800, * PP_GRAPHICS3DATTRIB_NONE}; * context = g3d->Create(instance, attribs, &context); * inst->BindGraphics(instance, context); + * </code> * - * // Present one frame. + * <strong>Present one frame:</strong> + * <code> * gles2->Clear(context, GL_COLOR_BUFFER); * g3d->SwapBuffers(context); + * </code> * - * // Shutdown. + * <strong>Shutdown:</strong> + * <code> * core->ReleaseResource(context); + * </code> */ - -#define PPB_GRAPHICS_3D_INTERFACE_1_0 "PPB_Graphics3D;1.0" -#define PPB_GRAPHICS_3D_INTERFACE PPB_GRAPHICS_3D_INTERFACE_1_0 - struct PPB_Graphics3D_1_0 { /** - * Retrieves the maximum supported value for the given attribute. + * GetAttribMaxValue() retrieves the maximum supported value for the + * given attribute. This function may be used to check if a particular + * attribute value is supported before attempting to create a context. * - * This function may be used to check if a particular attribute value is - * supported before attempting to create a context. + * @param[in] instance The module instance. + * @param[in] attribute The attribute for which maximum value is queried. * Attributes that can be queried for include: - * - PP_GRAPHICS3DATTRIB_ALPHA_SIZE - * - PP_GRAPHICS3DATTRIB_BLUE_SIZE - * - PP_GRAPHICS3DATTRIB_GREEN_SIZE - * - PP_GRAPHICS3DATTRIB_RED_SIZE - * - PP_GRAPHICS3DATTRIB_DEPTH_SIZE - * - PP_GRAPHICS3DATTRIB_STENCIL_SIZE - * - PP_GRAPHICS3DATTRIB_SAMPLES - * - PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS - * - PP_GRAPHICS3DATTRIB_WIDTH - * - PP_GRAPHICS3DATTRIB_HEIGHT - * - * On failure the following error codes may be returned: - * - PP_ERROR_BADRESOURCE if instance is invalid. - * - PP_ERROR_BADARGUMENT if attribute is invalid or value is NULL + * - <code>PP_GRAPHICS3DATTRIB_ALPHA_SIZE</code> + * - <code>PP_GRAPHICS3DATTRIB_BLUE_SIZE</code> + * - <code>PP_GRAPHICS3DATTRIB_GREEN_SIZE</code> + * - <code>PP_GRAPHICS3DATTRIB_RED_SIZE</code> + * - <code>PP_GRAPHICS3DATTRIB_DEPTH_SIZE</code> + * - <code>PP_GRAPHICS3DATTRIB_STENCIL_SIZE</code> + * - <code>PP_GRAPHICS3DATTRIB_SAMPLES</code> + * - <code>PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS</code> + * - <code>PP_GRAPHICS3DATTRIB_WIDTH</code> + * - <code>PP_GRAPHICS3DATTRIB_HEIGHT</code> + * @param[out] value The maximum supported value for <code>attribute</code> + * + * @return Returns <code>PP_TRUE</code> on success or the following on error: + * - <code>PP_ERROR_BADRESOURCE</code> if <code>instance</code> is invalid + * - <code>PP_ERROR_BADARGUMENT</code> if <code>attribute</code> is invalid + * or <code>value</code> is 0 */ int32_t (*GetAttribMaxValue)(PP_Resource instance, - int32_t attribute, int32_t* value); - + int32_t attribute, + int32_t* value); /** - * Creates and initializes a rendering context and returns a handle to it. + * Create() creates and initializes a 3D rendering context. * The returned context is off-screen to start with. It must be attached to - * a plugin instance using PPB_Instance::BindGraphics to draw on the web page. - * - * If share_context is not NULL, then all shareable data, as defined - * by the client API (note that for OpenGL and OpenGL ES, shareable data - * excludes texture objects named 0) will be shared by share_context, all - * other contexts share_context already shares with, and the newly created - * context. An arbitrary number of PPB_Graphics3D can share data in - * this fashion. - * - * attrib_list specifies a list of attributes for the context. It is a list - * of attribute name-value pairs in which each attribute is immediately - * followed by the corresponding desired value. The list is terminated with - * PP_GRAPHICS3DATTRIB_NONE. The attrib_list may be NULL or empty - * (first attribute is PP_GRAPHICS3DATTRIB_NONE). If an attribute is not - * specified in attrib_list, then the default value is used (it is said to - * be specified implicitly). + * a plugin instance using <code>PPB_Instance::BindGraphics</code> to draw + * on the web page. + * + * @param[in] instance The module instance. + * + * @param[in] share_context The 3D context with which the created context + * would share resources. If <code>share_context</code> is not 0, then all + * shareable data, as defined by the client API (note that for OpenGL and + * OpenGL ES, shareable data excludes texture objects named 0) will be shared + * by <code>share_context<code>, all other contexts <code>share_context</code> + * already shares with, and the newly created context. An arbitrary number of + * <code>PPB_Graphics3D</code> can share data in this fashion. * + * @param[out] attrib_list specifies a list of attributes for the context. + * It is a list of attribute name-value pairs in which each attribute is + * immediately followed by the corresponding desired value. The list is + * terminated with <code>PP_GRAPHICS3DATTRIB_NONE</code>. + * The <code>attrib_list<code> may be 0 or empty (first attribute is + * <code>PP_GRAPHICS3DATTRIB_NONE</code>). If an attribute is not + * specified in <code>attrib_list</code>, then the default value is used + * (it is said to be specified implicitly). * Attributes for the context are chosen according to an attribute-specific * criteria. Attributes can be classified into two categories: * - AtLeast: The attribute value in the returned context meets or exceeds - * the value specified in attrib_list. + * the value specified in <code>attrib_list</code>. * - Exact: The attribute value in the returned context is equal to - * the value specified in attrib_list. - * - * Attributes that can be specified in attrib_list include: - * - PP_GRAPHICS3DATTRIB_ALPHA_SIZE: Category: AtLeast Default: 0. - * - PP_GRAPHICS3DATTRIB_BLUE_SIZE: Category: AtLeast Default: 0. - * - PP_GRAPHICS3DATTRIB_GREEN_SIZE: Category: AtLeast Default: 0. - * - PP_GRAPHICS3DATTRIB_RED_SIZE: Category: AtLeast Default: 0. - * - PP_GRAPHICS3DATTRIB_DEPTH_SIZE: Category: AtLeast Default: 0. - * - PP_GRAPHICS3DATTRIB_STENCIL_SIZE: Category: AtLeast Default: 0. - * - PP_GRAPHICS3DATTRIB_SAMPLES: Category: AtLeast Default: 0. - * - PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS: Category: AtLeast Default: 0. - * - PP_GRAPHICS3DATTRIB_WIDTH: Category: Exact Default: 0. - * - PP_GRAPHICS3DATTRIB_HEIGHT: Category: Exact Default: 0. - * - PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR: + * the value specified in <code>attrib_list</code>. + * + * Attributes that can be specified in <code>attrib_list</code> include: + * - <code>PP_GRAPHICS3DATTRIB_ALPHA_SIZE</code>: + * Category: AtLeast Default: 0. + * - <code>PP_GRAPHICS3DATTRIB_BLUE_SIZE</code>: + * Category: AtLeast Default: 0. + * - <code>PP_GRAPHICS3DATTRIB_GREEN_SIZE</code>: + * Category: AtLeast Default: 0. + * - <code>PP_GRAPHICS3DATTRIB_RED_SIZE</code>: + * Category: AtLeast Default: 0. + * - <code>PP_GRAPHICS3DATTRIB_DEPTH_SIZE</code>: + * Category: AtLeast Default: 0. + * - <code>PP_GRAPHICS3DATTRIB_STENCIL_SIZE</code>: + * Category: AtLeast Default: 0. + * - <code>PP_GRAPHICS3DATTRIB_SAMPLES</code>: + * Category: AtLeast Default: 0. + * - <code>PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS</code>: + * Category: AtLeast Default: 0. + * - <code>PP_GRAPHICS3DATTRIB_WIDTH</code>: + * Category: Exact Default: 0. + * - <code>PP_GRAPHICS3DATTRIB_HEIGHT</code>: + * Category: Exact Default: 0. + * - <code>PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR</code>: * Category: Exact Default: Implementation defined. * - * On failure NULL resource is returned. + * @return A <code>PP_Resource</code> containing the 3D graphics context if + * successful or 0 if unsuccessful. */ PP_Resource (*Create)(PP_Instance instance, PP_Resource share_context, - const int32_t* attrib_list); - + const int32_t attrib_list[]); /** - * Returns PP_TRUE if the given resource is a valid PPB_Graphics3D, - * PP_FALSE if it is an invalid resource or is a resource of another type. + * IsGraphics3D() determines if the given resource is a valid + * <code>Graphics3D</code> context. + * + * @param[in] resource A <code>Graphics3D</code> context resource. + * + * @return PP_TRUE if the given resource is a valid <code>Graphics3D</code>, + * <code>PP_FALSE</code> if it is an invalid resource or is a resource of + * another type. */ PP_Bool (*IsGraphics3D)(PP_Resource resource); - /** - * Retrieves the value for each attribute in attrib_list. The list - * has the same structure as described for PPB_Graphics3D::Create. - * It is both input and output structure for this function. - * - * All attributes specified in PPB_Graphics3D.Create can be queried for. - * On failure the following error codes may be returned: - * - PP_ERROR_BADRESOURCE if context is invalid. - * - PP_ERROR_BADARGUMENT if attrib_list is NULL or any attribute in the - * attrib_list is not a valid attribute. - * - * Example usage: To get the values for rgb bits in the color buffer, - * this function must be called as following: + * GetAttribs() retrieves the value for each attribute in + * <code>attrib_list</code>. + * + * @param[in] context The 3D graphics context. + * @param[in,out] attrib_list The list of attributes that are queried. + * <code>attrib_list</code> has the same structure as described for + * <code>PPB_Graphics3D::Create</code>. It is both input and output + * structure for this function. All attributes specified in + * <code>PPB_Graphics3D::Create</code> can be queried for. + * + * @return Returns <code>PP_OK</code> on success or: + * - <code>PP_ERROR_BADRESOURCE</code> if context is invalid + * - <code>PP_ERROR_BADARGUMENT</code> if attrib_list is 0 or any attribute + * in the <code>attrib_list</code> is not a valid attribute. + * + * <strong>Example usage:</strong> To get the values for rgb bits in the + * color buffer, this function must be called as following: + * <code> * int attrib_list[] = {PP_GRAPHICS3DATTRIB_RED_SIZE, 0, * PP_GRAPHICS3DATTRIB_GREEN_SIZE, 0, * PP_GRAPHICS3DATTRIB_BLUE_SIZE, 0, @@ -131,24 +185,29 @@ struct PPB_Graphics3D_1_0 { * int red_bits = attrib_list[1]; * int green_bits = attrib_list[3]; * int blue_bits = attrib_list[5]; + * </code> */ - int32_t (*GetAttribs)(PP_Resource context, int32_t* attrib_list); - + int32_t (*GetAttribs)(PP_Resource context, int32_t attrib_list[]); /** - * Sets the values for each attribute in attrib_list. The list - * has the same structure as described for PPB_Graphics3D.Create. + * SetAttribs() sets the values for each attribute in + * <code>attrib_list</code>. * + * @param[in] context The 3D graphics context. + * @param[in] attrib_list The list of attributes whose values need to be set. + * <code>attrib_list</code> has the same structure as described for + * <code>PPB_Graphics3D::Create</code>. * Attributes that can be specified are: - * - PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR + * - <code>PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR</code> * - * On failure the following error codes may be returned: - * - PP_ERROR_BADRESOURCE if context is invalid. - * - PP_ERROR_BADARGUMENT if attrib_list is NULL or any attribute in the - * attrib_list is not a valid attribute. + * @return Returns <code>PP_OK</code> on success or: + * - <code>PP_ERROR_BADRESOURCE</code> if <code>context</code> is invalid. + * - <code>PP_ERROR_BADARGUMENT</code> if <code>attrib_list</code> is 0 or + * any attribute in the <code>attrib_list</code> is not a valid attribute. */ - int32_t (*SetAttribs)(PP_Resource context, int32_t* attrib_list); - + int32_t (*SetAttribs)(PP_Resource context, const int32_t attrib_list[]); /** + * GetError() returns the current state of the given 3D context. + * * The recoverable error conditions that have no side effect are * detected and returned immediately by all functions in this interface. * In addition the implementation may get into a fatal state while @@ -162,39 +221,43 @@ struct PPB_Graphics3D_1_0 { * drawing a frame is expensive and you want to verify the result of * ResizeBuffers before attemptimg to draw a frame. * - * The following error codes may be returned: - * - PP_ERROR_NOMEMORY - * - PP_ERROR_CONTEXT_LOST + * @param[in] The 3D graphics context. + * @return Returns: + * - <code>PP_OK</code> if no error + * - <code>PP_ERROR_NOMEMORY</code> + * - <code>PP_ERROR_CONTEXT_LOST</code> */ int32_t (*GetError)(PP_Resource context); - /** - * Resizes the backing surface for context. - * - * On failure the following error codes may be returned: - * - PP_ERROR_BADRESOURCE if context is invalid. - * - PP_ERROR_BADARGUMENT if the value specified for width or height - * is less than zero. + * ResizeBuffers() resizes the backing surface for context. * * If the surface could not be resized due to insufficient resources, - * PP_ERROR_NOMEMORY error is returned on the next SwapBuffers callback. + * <code>PP_ERROR_NOMEMORY</code> error is returned on the next + * <code>SwapBuffers</code> callback. + * + * @param[in] context The 3D graphics context. + * @param[in] width The width of the backing surface. + * @param[in] height The height of the backing surface. + * @return Returns <code>PP_OK</code> on success or: + * - <code>PP_ERROR_BADRESOURCE</code> if context is invalid. + * - <code>PP_ERROR_BADARGUMENT</code> if the value specified for + * <code>width</code> or <code>height</code> is less than zero. */ - int32_t (*ResizeBuffers)(PP_Resource context, - int32_t width, int32_t height); - + int32_t (*ResizeBuffers)(PP_Resource context, int32_t width, int32_t height); /** - * Makes the contents of the color buffer available for compositing. - * This function has no effect on off-screen surfaces - ones not bound - * to any plugin instance. The contents of ancillary buffers are always - * undefined after calling SwapBuffers. The contents of the color buffer are - * undefined if the value of the PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR attribute - * of context is not PP_GRAPHICS3DATTRIB_BUFFER_PRESERVED. - * - * SwapBuffers runs in asynchronous mode. Specify a callback function and the - * argument for that callback function. The callback function will be executed - * on the calling thread after the color buffer has been composited with - * rest of the html page. While you are waiting for a SwapBuffers callback, - * additional calls to SwapBuffers will fail. + * SwapBuffers() makes the contents of the color buffer available for + * compositing. This function has no effect on off-screen surfaces - ones not + * bound to any plugin instance. The contents of ancillary buffers are always + * undefined after calling <code>SwapBuffers</code>. The contents of the color + * buffer are undefined if the value of the + * <code>PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR</code> attribute of context is not + * <code>PP_GRAPHICS3DATTRIB_BUFFER_PRESERVED</code>. + * + * <code>SwapBuffers</code> runs in asynchronous mode. Specify a callback + * function and the argument for that callback function. The callback function + * will be executed on the calling thread after the color buffer has been + * composited with rest of the html page. While you are waiting for a + * SwapBuffers callback, additional calls to SwapBuffers will fail. * * Because the callback is executed (or thread unblocked) only when the * plugin's current state is actually on the screen, this function provides a @@ -206,18 +269,27 @@ struct PPB_Graphics3D_1_0 { * If the context gets into an unrecoverable error condition while * processing a command, the error code will be returned as the argument * for the callback. The callback may return the following error codes: - * - PP_ERROR_NOMEMORY - * - PP_ERROR_CONTEXT_LOST + * - <code>PP_ERROR_NOMEMORY</code> + * - <code>PP_ERROR_CONTEXT_LOST</code> * Note that the same error code may also be obtained by calling GetError. * - * On failure SwapBuffers may return the following error codes: - * - PP_ERROR_BADRESOURCE if context is invalid. - * - PP_ERROR_BADARGUMENT if callback is invalid. + * @param[in] context The 3D graphics context. + * @param[in] callback The callback that will executed when + * <code>SwapBuffers</code> completes. + * + * @return Returns PP_OK on success or: + * - <code>PP_ERROR_BADRESOURCE</code> if context is invalid. + * - <code>PP_ERROR_BADARGUMENT</code> if callback is invalid. + * */ int32_t (*SwapBuffers)(PP_Resource context, struct PP_CompletionCallback callback); }; typedef struct PPB_Graphics3D_1_0 PPB_Graphics3D; +/** + * @} + */ #endif /* PPAPI_C_PPB_GRAPHICS_3D_H_ */ + diff --git a/ppapi/cpp/graphics_3d.cc b/ppapi/cpp/graphics_3d.cc index 24ea8a42..cce5547 100644 --- a/ppapi/cpp/graphics_3d.cc +++ b/ppapi/cpp/graphics_3d.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -24,7 +24,7 @@ Graphics3D::Graphics3D() { } Graphics3D::Graphics3D(const Instance* instance, - const int32_t* attrib_list) { + const int32_t attrib_list[]) { if (has_interface<PPB_Graphics3D>()) { PassRefFromConstructor(get_interface<PPB_Graphics3D>()->Create( instance->pp_instance(), 0, attrib_list)); @@ -33,7 +33,7 @@ Graphics3D::Graphics3D(const Instance* instance, Graphics3D::Graphics3D(const Instance* instance, const Graphics3D& share_context, - const int32_t* attrib_list) { + const int32_t attrib_list[]) { if (has_interface<PPB_Graphics3D>()) { PassRefFromConstructor(get_interface<PPB_Graphics3D>()->Create( instance->pp_instance(), @@ -45,7 +45,7 @@ Graphics3D::Graphics3D(const Instance* instance, Graphics3D::~Graphics3D() { } -int32_t Graphics3D::GetAttribs(int32_t* attrib_list) const { +int32_t Graphics3D::GetAttribs(int32_t attrib_list[]) const { if (!has_interface<PPB_Graphics3D>()) return PP_ERROR_NOINTERFACE; @@ -54,7 +54,7 @@ int32_t Graphics3D::GetAttribs(int32_t* attrib_list) const { attrib_list); } -int32_t Graphics3D::SetAttribs(int32_t* attrib_list) { +int32_t Graphics3D::SetAttribs(const int32_t attrib_list[]) { if (!has_interface<PPB_Graphics3D>()) return PP_ERROR_NOINTERFACE; diff --git a/ppapi/cpp/graphics_3d.h b/ppapi/cpp/graphics_3d.h index d9e1fdb..9d89e28 100644 --- a/ppapi/cpp/graphics_3d.h +++ b/ppapi/cpp/graphics_3d.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -62,7 +62,7 @@ class Graphics3D : public Resource { /// /// On failure, the object will be is_null(). Graphics3D(const Instance* instance, - const int32_t* attrib_list); + const int32_t attrib_list[]); /// A constructor for creating and initializing a 3D rendering context. The /// returned context is created off-screen. It must be attached to a @@ -86,7 +86,7 @@ class Graphics3D : public Resource { /// On failure, the object will be is_null(). Graphics3D(const Instance* instance, const Graphics3D& share_context, - const int32_t* attrib_list); + const int32_t attrib_list[]); /// Destructor. ~Graphics3D(); @@ -120,7 +120,7 @@ class Graphics3D : public Resource { /// </code> /// /// This example retrieves the values for rgb bits in the color buffer. - int32_t GetAttribs(int32_t* attrib_list) const; + int32_t GetAttribs(int32_t attrib_list[]) const; /// SetAttribs() sets the values for each attribute in /// <code>attrib_list</code>. The list has the same structure as the list @@ -133,7 +133,7 @@ class Graphics3D : public Resource { /// - PP_ERROR_BADRESOURCE if context is invalid. /// - PP_ERROR_BADARGUMENT if attrib_list is NULL or any attribute in the /// attrib_list is not a valid attribute. - int32_t SetAttribs(int32_t* attrib_list); + int32_t SetAttribs(const int32_t attrib_list[]); /// ResizeBuffers() resizes the backing surface for the context. /// diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.cc b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.cc index a3220f9..01c14dc 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.cc @@ -31,7 +31,7 @@ const size_t kStartTransferBufferSize = 4 * 1024 * 1024; const size_t kMinTransferBufferSize = 256 * 1024; const size_t kMaxTransferBufferSize = 16 * 1024 * 1024; -int32_t GetNumAttribs(const int32_t* attrib_list) { +int32_t GetNumAttribs(const int32_t attrib_list[]) { int32_t num = 0; if (attrib_list) { // skip over attrib pairs @@ -64,7 +64,7 @@ int32_t GetAttribMaxValue(PP_Instance instance, PP_Resource Create(PP_Instance instance, PP_Resource share_context, - const int32_t* attrib_list) { + const int32_t attrib_list[]) { DebugPrintf("PPB_Graphics3D::Create: instance=%"NACL_PRId32"\n", instance); PP_Resource graphics3d_id = kInvalidResourceId; nacl_abi_size_t num_attribs = GetNumAttribs(attrib_list); @@ -93,7 +93,7 @@ PP_Bool IsGraphics3D(PP_Resource resource) { } int32_t GetAttribs(PP_Resource graphics3d_id, - int32_t* attrib_list) { + int32_t attrib_list[]) { int32_t pp_error; nacl_abi_size_t num_attribs = GetNumAttribs(attrib_list); NaClSrpcError retval = @@ -110,14 +110,14 @@ int32_t GetAttribs(PP_Resource graphics3d_id, } int32_t SetAttribs(PP_Resource graphics3d_id, - int32_t* attrib_list) { + const int32_t attrib_list[]) { int32_t pp_error; nacl_abi_size_t num_attribs = GetNumAttribs(attrib_list); NaClSrpcError retval = PpbGraphics3DRpcClient::PPB_Graphics3D_SetAttribs( GetMainSrpcChannel(), graphics3d_id, - num_attribs, attrib_list, + num_attribs, const_cast<int32_t *>(attrib_list), &pp_error); if (retval != NACL_SRPC_RESULT_OK) { return PP_ERROR_BADARGUMENT; diff --git a/ppapi/shared_impl/ppb_graphics_3d_shared.cc b/ppapi/shared_impl/ppb_graphics_3d_shared.cc index 37b3d0b..e21b77e 100644 --- a/ppapi/shared_impl/ppb_graphics_3d_shared.cc +++ b/ppapi/shared_impl/ppb_graphics_3d_shared.cc @@ -31,12 +31,12 @@ thunk::PPB_Graphics3D_API* PPB_Graphics3D_Shared::AsPPB_Graphics3D_API() { return this; } -int32_t PPB_Graphics3D_Shared::GetAttribs(int32_t* attrib_list) { +int32_t PPB_Graphics3D_Shared::GetAttribs(int32_t attrib_list[]) { // TODO(alokp): Implement me. return PP_ERROR_FAILED; } -int32_t PPB_Graphics3D_Shared::SetAttribs(int32_t* attrib_list) { +int32_t PPB_Graphics3D_Shared::SetAttribs(const int32_t attrib_list[]) { // TODO(alokp): Implement me. return PP_ERROR_FAILED; } diff --git a/ppapi/shared_impl/ppb_graphics_3d_shared.h b/ppapi/shared_impl/ppb_graphics_3d_shared.h index 2a89e40..ee72144 100644 --- a/ppapi/shared_impl/ppb_graphics_3d_shared.h +++ b/ppapi/shared_impl/ppb_graphics_3d_shared.h @@ -32,8 +32,8 @@ class PPAPI_SHARED_EXPORT PPB_Graphics3D_Shared virtual thunk::PPB_Graphics3D_API* AsPPB_Graphics3D_API() OVERRIDE; // PPB_Graphics3D_API implementation. - virtual int32_t GetAttribs(int32_t* attrib_list) OVERRIDE; - virtual int32_t SetAttribs(int32_t* attrib_list) OVERRIDE; + virtual int32_t GetAttribs(int32_t attrib_list[]) OVERRIDE; + virtual int32_t SetAttribs(const int32_t attrib_list[]) OVERRIDE; virtual int32_t GetError() OVERRIDE; virtual int32_t ResizeBuffers(int32_t width, int32_t height) OVERRIDE; virtual int32_t SwapBuffers(PP_CompletionCallback callback) OVERRIDE; diff --git a/ppapi/thunk/ppb_graphics_3d_api.h b/ppapi/thunk/ppb_graphics_3d_api.h index 4e1980a..84dc829 100644 --- a/ppapi/thunk/ppb_graphics_3d_api.h +++ b/ppapi/thunk/ppb_graphics_3d_api.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -18,8 +18,8 @@ class PPAPI_THUNK_EXPORT PPB_Graphics3D_API { virtual ~PPB_Graphics3D_API() {} // Graphics3D API. - virtual int32_t GetAttribs(int32_t* attrib_list) = 0; - virtual int32_t SetAttribs(int32_t* attrib_list) = 0; + virtual int32_t GetAttribs(int32_t attrib_list[]) = 0; + virtual int32_t SetAttribs(const int32_t attrib_list[]) = 0; virtual int32_t GetError() = 0; virtual int32_t ResizeBuffers(int32_t width, int32_t height) = 0; virtual int32_t SwapBuffers(PP_CompletionCallback callback) = 0; diff --git a/ppapi/thunk/ppb_graphics_3d_thunk.cc b/ppapi/thunk/ppb_graphics_3d_thunk.cc index 0aeeb27..2c7bd50 100644 --- a/ppapi/thunk/ppb_graphics_3d_thunk.cc +++ b/ppapi/thunk/ppb_graphics_3d_thunk.cc @@ -25,7 +25,7 @@ int32_t GetAttribMaxValue(PP_Resource instance, PP_Resource Create(PP_Instance instance, PP_Resource share_context, - const int32_t* attrib_list) { + const int32_t attrib_list[]) { EnterResourceCreation enter(instance); if (enter.failed()) return 0; @@ -38,14 +38,14 @@ PP_Bool IsGraphics3D(PP_Resource resource) { return PP_FromBool(enter.succeeded()); } -int32_t GetAttribs(PP_Resource graphics_3d, int32_t* attrib_list) { +int32_t GetAttribs(PP_Resource graphics_3d, int32_t attrib_list[]) { EnterGraphics3D enter(graphics_3d, true); if (enter.failed()) return enter.retval(); return enter.object()->GetAttribs(attrib_list); } -int32_t SetAttribs(PP_Resource graphics_3d, int32_t* attrib_list) { +int32_t SetAttribs(PP_Resource graphics_3d, const int32_t attrib_list[]) { EnterGraphics3D enter(graphics_3d, true); if (enter.failed()) return enter.retval(); |