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. |
| 146 // |
| 147 // Note that the same error code is also returned in the SwapBuffers callback. |
| 148 // It is recommended to handle error in the SwapBuffers callback because |
| 149 // GetError is synchronous. This function may be useful in rare cases where |
| 150 // drawing a frame is expensive and you want to verify the result of |
| 151 // ResizeBuffers before attemptimg to draw a frame. |
| 152 // |
| 153 // The following error codes may be returned: |
| 154 // - PP_ERROR_NOMEMORY |
| 155 // - PP_ERROR_CONTEXT_LOST |
| 156 int32_t (*GetError)(PP_Resource context); |
| 157 |
113 // Resizes the backing surface for context. | 158 // Resizes the backing surface for context. |
114 // | 159 // |
115 // On failure the following error codes may be returned: | 160 // On failure the following error codes may be returned: |
116 // - PP_ERROR_BADRESOURCE if context is invalid. | 161 // - PP_ERROR_BADRESOURCE if context is invalid. |
117 // - PP_ERROR_BADARGUMENT if the value specified for width or height | 162 // - PP_ERROR_BADARGUMENT if the value specified for width or height |
118 // is less than zero. | 163 // is less than zero. |
119 // | 164 // |
120 // If the surface could not be resized due to insufficient resources, | 165 // If the surface could not be resized due to insufficient resources, |
121 // PP_ERROR_NOMEMORY error is returned on the next SwapBuffers callback. | 166 // PP_ERROR_NOMEMORY error is returned on the next SwapBuffers callback. |
122 int32_t (*ResizeBuffers)(PP_Resource context, | 167 int32_t (*ResizeBuffers)(PP_Resource context, |
123 int32_t width, int32_t height); | 168 int32_t width, int32_t height); |
124 | 169 |
125 // Makes the contents of the color buffer available for compositing. | 170 // Makes the contents of the color buffer available for compositing. |
126 // This function has no effect on off-screen surfaces - ones not bound | 171 // This function has no effect on off-screen surfaces - ones not bound |
127 // to any plugin instance. The contents of ancillary buffers are always | 172 // to any plugin instance. The contents of ancillary buffers are always |
128 // undefined after calling SwapBuffers. The contents of the color buffer are | 173 // undefined after calling SwapBuffers. The contents of the color buffer are |
129 // undefined if the value of the PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR attribute | 174 // undefined if the value of the PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR attribute |
130 // of context is not PP_GRAPHICS3DATTRIB_BUFFER_PRESERVED. | 175 // of context is not PP_GRAPHICS3DATTRIB_BUFFER_PRESERVED. |
131 // | 176 // |
132 // SwapBuffers performs an implicit flush operation on context. | 177 // SwapBuffers runs in asynchronous mode. Specify a callback function and the |
133 // | 178 // argument for that callback function. The callback function will be executed |
134 // This functions can run in two modes: | 179 // 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 | 180 // 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 | 181 // 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 // | 182 // |
145 // Because the callback is executed (or thread unblocked) only when the | 183 // 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 | 184 // 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 | 185 // 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 | 186 // before painting the next frame, you can ensure you're not generating |
149 // updates faster than the screen can be updated. | 187 // updates faster than the screen can be updated. |
| 188 // |
| 189 // SwapBuffers performs an implicit flush operation on context. |
| 190 // If the context gets into an unrecoverable error condition while |
| 191 // processing a command, the error code will be returned as the argument |
| 192 // for the callback. The callback may return the following error codes: |
| 193 // - PP_ERROR_NOMEMORY |
| 194 // - PP_ERROR_CONTEXT_LOST |
| 195 // Note that the same error code may also be obtained by calling GetError. |
| 196 // |
| 197 // On failure SwapBuffers may return the following error codes: |
| 198 // - PP_ERROR_BADRESOURCE if context is invalid. |
| 199 // - PP_ERROR_BADARGUMENT if callback is invalid. |
150 int32_t (*SwapBuffers)(PP_Resource context, | 200 int32_t (*SwapBuffers)(PP_Resource context, |
151 struct PP_CompletionCallback callback); | 201 struct PP_CompletionCallback callback); |
152 }; | 202 }; |
153 | 203 |
154 #endif /* PPAPI_C_DEV_PPB_GRAPHICS_3D_DEV_H_ */ | 204 #endif /* PPAPI_C_DEV_PPB_GRAPHICS_3D_DEV_H_ */ |
OLD | NEW |