Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 /* Copyright (c) 2011 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_DEV_PPB_GRAPHICS_3D_DEV_H_ | 5 #ifndef PPAPI_C_DEV_PPB_GRAPHICS_3D_DEV_H_ |
| 6 #define PPAPI_C_DEV_PPB_GRAPHICS_3D_DEV_H_ | 6 #define PPAPI_C_DEV_PPB_GRAPHICS_3D_DEV_H_ |
| 7 | 7 |
| 8 #include "ppapi/c/dev/pp_graphics_3d_dev.h" | 8 #include "ppapi/c/dev/pp_graphics_3d_dev.h" |
| 9 | 9 |
| 10 #include "ppapi/c/pp_bool.h" | 10 #include "ppapi/c/pp_bool.h" |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 // context = g3d->Create(instance, attribs, &context); | 21 // context = g3d->Create(instance, attribs, &context); |
| 22 // inst->BindGraphics(instance, context); | 22 // inst->BindGraphics(instance, context); |
| 23 // | 23 // |
| 24 // // Present one frame. | 24 // // Present one frame. |
| 25 // gles2->Clear(context, GL_COLOR_BUFFER); | 25 // gles2->Clear(context, GL_COLOR_BUFFER); |
| 26 // g3d->SwapBuffers(context); | 26 // g3d->SwapBuffers(context); |
| 27 // | 27 // |
| 28 // // Shutdown. | 28 // // Shutdown. |
| 29 // core->ReleaseResource(context); | 29 // core->ReleaseResource(context); |
| 30 | 30 |
| 31 #define PPB_GRAPHICS_3D_DEV_INTERFACE_0_8 "PPB_Graphics3D(Dev);0.8" | 31 #define PPB_GRAPHICS_3D_DEV_INTERFACE_0_9 "PPB_Graphics3D(Dev);0.9" |
| 32 #define PPB_GRAPHICS_3D_DEV_INTERFACE PPB_GRAPHICS_3D_DEV_INTERFACE_0_8 | 32 #define PPB_GRAPHICS_3D_DEV_INTERFACE PPB_GRAPHICS_3D_DEV_INTERFACE_0_9 |
| 33 | 33 |
| 34 struct PPB_Graphics3D_Dev { | 34 struct PPB_Graphics3D_Dev { |
| 35 // Retrieves the maximum supported value for the given attribute. | |
| 36 // | |
| 37 // This function may be used to check if a particular attribute value is | |
| 38 // supported before attempting to create a context. | |
| 39 // Attributes that can be queried for include: | |
| 40 // - PP_GRAPHICS3DATTRIB_ALPHA_SIZE | |
| 41 // - PP_GRAPHICS3DATTRIB_BLUE_SIZE | |
| 42 // - PP_GRAPHICS3DATTRIB_GREEN_SIZE | |
| 43 // - PP_GRAPHICS3DATTRIB_RED_SIZE | |
| 44 // - PP_GRAPHICS3DATTRIB_DEPTH_SIZE | |
| 45 // - PP_GRAPHICS3DATTRIB_STENCIL_SIZE | |
| 46 // - PP_GRAPHICS3DATTRIB_SAMPLES | |
| 47 // - PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS | |
| 48 // - PP_GRAPHICS3DATTRIB_WIDTH | |
| 49 // - PP_GRAPHICS3DATTRIB_HEIGHT | |
| 50 // | |
| 51 // On failure the following error codes may be returned: | |
| 52 // - PP_ERROR_BADRESOURCE if instance is invalid. | |
| 53 // - PP_ERROR_BADARGUMENT if attribute is invalid or value is NULL | |
| 54 int32_t (*GetAttribMaxValue)(PP_Resource instance, | |
| 55 int32_t attribute, int32_t* value); | |
| 56 | |
| 35 // Creates and initializes a rendering context and returns a handle to it. | 57 // Creates and initializes a rendering context and returns a handle to it. |
| 36 // The returned context is off-screen to start with. It must be attached to | 58 // The returned context is off-screen to start with. It must be attached to |
| 37 // a plugin instance using PPB_Instance::BindGraphics to draw on the web page. | 59 // a plugin instance using PPB_Instance::BindGraphics to draw on the web page. |
| 38 // | 60 // |
| 39 // If share_context is not NULL, then all shareable data, as defined | 61 // If share_context is not NULL, then all shareable data, as defined |
| 40 // by the client API (note that for OpenGL and OpenGL ES, shareable data | 62 // by the client API (note that for OpenGL and OpenGL ES, shareable data |
| 41 // excludes texture objects named 0) will be shared by share_context, all | 63 // excludes texture objects named 0) will be shared by share_context, all |
| 42 // other contexts share_context already shares with, and the newly created | 64 // other contexts share_context already shares with, and the newly created |
| 43 // context. An arbitrary number of PPB_Graphics3D_Dev can share data in | 65 // context. An arbitrary number of PPB_Graphics3D_Dev can share data in |
| 44 // this fashion. | 66 // this fashion. |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 74 // | 96 // |
| 75 // On failure NULL resource is returned. | 97 // On failure NULL resource is returned. |
| 76 PP_Resource (*Create)(PP_Instance instance, | 98 PP_Resource (*Create)(PP_Instance instance, |
| 77 PP_Resource share_context, | 99 PP_Resource share_context, |
| 78 const int32_t* attrib_list); | 100 const int32_t* attrib_list); |
| 79 | 101 |
| 80 // Returns PP_TRUE if the given resource is a valid PPB_Graphics3D_Dev, | 102 // Returns PP_TRUE if the given resource is a valid PPB_Graphics3D_Dev, |
| 81 // PP_FALSE if it is an invalid resource or is a resource of another type. | 103 // PP_FALSE if it is an invalid resource or is a resource of another type. |
| 82 PP_Bool (*IsGraphics3D)(PP_Resource resource); | 104 PP_Bool (*IsGraphics3D)(PP_Resource resource); |
| 83 | 105 |
| 84 // Retrieves the values for each attribute in attrib_list. The list | 106 // Retrieves the value for each attribute in attrib_list. The list |
| 85 // has the same structure as described for PPB_Graphics3D_Dev::Create. | 107 // has the same structure as described for PPB_Graphics3D_Dev::Create. |
| 86 // It is both input and output structure for this function. | 108 // It is both input and output structure for this function. |
| 87 // | 109 // |
| 88 // All attributes specified in PPB_Graphics3D_Dev::Create can be queried for. | 110 // All attributes specified in PPB_Graphics3D_Dev::Create can be queried for. |
| 89 // On failure the following error codes may be returned: | 111 // On failure the following error codes may be returned: |
| 90 // - PP_ERROR_BADRESOURCE if context is invalid. | 112 // - PP_ERROR_BADRESOURCE if context is invalid. |
| 91 // - PP_GRAPHICS3DERROR_BAD_ATTRIBUTE if any attribute in the attrib_list | 113 // - PP_ERROR_BADARGUMENT if attrib_list is NULL or any attribute in the |
| 92 // is not a valid attribute | 114 // attrib_list is not a valid attribute. |
| 93 // | 115 // |
| 94 // Example usage: To get the values for rgb bits in the color buffer, | 116 // Example usage: To get the values for rgb bits in the color buffer, |
| 95 // this function must be called as following: | 117 // this function must be called as following: |
| 96 // int attrib_list[] = {PP_GRAPHICS3DATTRIB_RED_SIZE, 0, | 118 // int attrib_list[] = {PP_GRAPHICS3DATTRIB_RED_SIZE, 0, |
| 97 // PP_GRAPHICS3DATTRIB_GREEN_SIZE, 0, | 119 // PP_GRAPHICS3DATTRIB_GREEN_SIZE, 0, |
| 98 // PP_GRAPHICS3DATTRIB_BLUE_SIZE, 0, | 120 // PP_GRAPHICS3DATTRIB_BLUE_SIZE, 0, |
| 99 // PP_GRAPHICS3DATTRIB_NONE}; | 121 // PP_GRAPHICS3DATTRIB_NONE}; |
| 100 // GetAttribs(context, attrib_list); | 122 // GetAttribs(context, attrib_list); |
| 101 // int red_bits = attrib_list[1]; | 123 // int red_bits = attrib_list[1]; |
| 102 // int green_bits = attrib_list[3]; | 124 // int green_bits = attrib_list[3]; |
| 103 // int blue_bits = attrib_list[5]; | 125 // int blue_bits = attrib_list[5]; |
| 104 int32_t (*GetAttribs)(PP_Resource context, int32_t* attrib_list); | 126 int32_t (*GetAttribs)(PP_Resource context, int32_t* attrib_list); |
| 105 | 127 |
| 106 // Sets the values for each attribute in attrib_list. The list | 128 // Sets the values for each attribute in attrib_list. The list |
| 107 // has the same structure as described for PPB_Graphics3D_Dev::Create. | 129 // has the same structure as described for PPB_Graphics3D_Dev::Create. |
| 108 // | 130 // |
| 109 // Attributes that can be specified are: | 131 // Attributes that can be specified are: |
| 110 // - PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR | 132 // - PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR |
| 133 // | |
| 134 // On failure the following error codes may be returned: | |
| 135 // - PP_ERROR_BADRESOURCE if context is invalid. | |
| 136 // - PP_ERROR_BADARGUMENT if attrib_list is NULL or any attribute in the | |
| 137 // attrib_list is not a valid attribute. | |
| 111 int32_t (*SetAttribs)(PP_Resource context, int32_t* attrib_list); | 138 int32_t (*SetAttribs)(PP_Resource context, int32_t* attrib_list); |
| 112 | 139 |
| 140 // The recoverable error conditions that have no side effect are | |
| 141 // detected and returned immediately by all functions in this interface. | |
| 142 // In addition the implementation may get into a fatal state while | |
| 143 // processing a command. In this case the application must detroy the | |
| 144 // context and reinitialize client API state and objects to continue | |
| 145 // rendering. Note that the same error code is also returned in the swap | |
|
brettw
2011/09/02 20:21:45
It's not clear to me when I'm supposed to call thi
alokp
2011/09/02 21:41:02
The context may get lost anytime. It may go out of
brettw
2011/09/02 22:14:24
Then I'd like to add to the comment that this retu
alokp
2011/09/02 23:45:07
I already have this in the comment - "Note that th
| |
| 146 // buffers callback. | |
| 147 // | |
| 148 // The following error codes may be returned: | |
| 149 // - PP_ERROR_NOMEMORY | |
| 150 // - PP_ERROR_CONTEXT_LOST | |
| 151 int32_t (*GetError)(PP_Resource context); | |
| 152 | |
| 113 // Resizes the backing surface for context. | 153 // Resizes the backing surface for context. |
| 114 // | 154 // |
| 115 // On failure the following error codes may be returned: | 155 // On failure the following error codes may be returned: |
| 116 // - PP_ERROR_BADRESOURCE if context is invalid. | 156 // - PP_ERROR_BADRESOURCE if context is invalid. |
| 117 // - PP_ERROR_BADARGUMENT if the value specified for width or height | 157 // - PP_ERROR_BADARGUMENT if the value specified for width or height |
| 118 // is less than zero. | 158 // is less than zero. |
| 119 // | 159 // |
| 120 // If the surface could not be resized due to insufficient resources, | 160 // If the surface could not be resized due to insufficient resources, |
| 121 // PP_ERROR_NOMEMORY error is returned on the next SwapBuffers callback. | 161 // PP_ERROR_NOMEMORY error is returned on the next SwapBuffers callback. |
| 122 int32_t (*ResizeBuffers)(PP_Resource context, | 162 int32_t (*ResizeBuffers)(PP_Resource context, |
| 123 int32_t width, int32_t height); | 163 int32_t width, int32_t height); |
| 124 | 164 |
| 125 // Makes the contents of the color buffer available for compositing. | 165 // Makes the contents of the color buffer available for compositing. |
| 126 // This function has no effect on off-screen surfaces - ones not bound | 166 // This function has no effect on off-screen surfaces - ones not bound |
| 127 // to any plugin instance. The contents of ancillary buffers are always | 167 // to any plugin instance. The contents of ancillary buffers are always |
| 128 // undefined after calling SwapBuffers. The contents of the color buffer are | 168 // undefined after calling SwapBuffers. The contents of the color buffer are |
| 129 // undefined if the value of the PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR attribute | 169 // undefined if the value of the PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR attribute |
| 130 // of context is not PP_GRAPHICS3DATTRIB_BUFFER_PRESERVED. | 170 // of context is not PP_GRAPHICS3DATTRIB_BUFFER_PRESERVED. |
| 131 // | 171 // |
| 132 // SwapBuffers performs an implicit flush operation on context. | 172 // SwapBuffers runs in asynchronous mode. Specify a callback function and the |
| 133 // | 173 // argument for that callback function. The callback function will be executed |
| 134 // This functions can run in two modes: | 174 // on the calling thread after the color buffer has been composited with |
| 135 // - In synchronous mode, you specify NULL for the callback and the callback | 175 // rest of the html page. While you are waiting for a SwapBuffers callback, |
| 136 // data. This function will block the calling thread until the image has | 176 // additional calls to SwapBuffers will fail. |
| 137 // been painted to the screen. It is not legal to block the main thread of | |
| 138 // the plugin, you can use synchronous mode only from background threads. | |
| 139 // - In asynchronous mode, you specify a callback function and the argument | |
| 140 // for that callback function. The callback function will be executed on | |
| 141 // the calling thread when the image has been painted to the screen. While | |
| 142 // you are waiting for a Flush callback, additional calls to Flush will | |
| 143 // fail. | |
| 144 // | 177 // |
| 145 // Because the callback is executed (or thread unblocked) only when the | 178 // Because the callback is executed (or thread unblocked) only when the |
| 146 // plugin's current state is actually on the screen, this function provides a | 179 // plugin's current state is actually on the screen, this function provides a |
| 147 // way to rate limit animations. By waiting until the image is on the screen | 180 // way to rate limit animations. By waiting until the image is on the screen |
| 148 // before painting the next frame, you can ensure you're not generating | 181 // before painting the next frame, you can ensure you're not generating |
| 149 // updates faster than the screen can be updated. | 182 // updates faster than the screen can be updated. |
| 183 // | |
| 184 // SwapBuffers performs an implicit flush operation on context. | |
| 185 // If the context gets into an unrecoverable error condition while | |
| 186 // processing a command, the error code will be returned as the argument | |
| 187 // for the callback. | |
| 188 // | |
| 189 // On failure the following error codes may be returned: | |
| 190 // - PP_ERROR_BADRESOURCE if context is invalid. | |
| 191 // - PP_ERROR_BADARGUMENT if callback is invalid. | |
| 150 int32_t (*SwapBuffers)(PP_Resource context, | 192 int32_t (*SwapBuffers)(PP_Resource context, |
| 151 struct PP_CompletionCallback callback); | 193 struct PP_CompletionCallback callback); |
| 152 }; | 194 }; |
| 153 | 195 |
| 154 #endif /* PPAPI_C_DEV_PPB_GRAPHICS_3D_DEV_H_ */ | 196 #endif /* PPAPI_C_DEV_PPB_GRAPHICS_3D_DEV_H_ */ |
| OLD | NEW |