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 14 matching lines...) Expand all Loading... | |
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_8 "PPB_Graphics3D(Dev);0.8" |
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_8 |
33 | 33 |
34 struct PPB_Graphics3D_Dev { | 34 struct PPB_Graphics3D_Dev { |
35 // Retrieves the maximum supported value for each attribute in attrib_list. | |
36 // The list has the same structure as described for | |
37 // PPB_Graphics3D_Dev::GetAttribs. | |
38 // | |
39 // This function may be used before attempting to create a context to check | |
40 // if a particular attribute value is supported. | |
41 // Attributes that can be specified in attrib_list include: | |
42 // - PP_GRAPHICS3DATTRIB_ALPHA_SIZE | |
43 // - PP_GRAPHICS3DATTRIB_BLUE_SIZE | |
44 // - PP_GRAPHICS3DATTRIB_GREEN_SIZE | |
45 // - PP_GRAPHICS3DATTRIB_RED_SIZE | |
46 // - PP_GRAPHICS3DATTRIB_DEPTH_SIZE | |
47 // - PP_GRAPHICS3DATTRIB_STENCIL_SIZE | |
48 // - PP_GRAPHICS3DATTRIB_SAMPLES | |
49 // - PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS | |
50 // - PP_GRAPHICS3DATTRIB_WIDTH | |
51 // - PP_GRAPHICS3DATTRIB_HEIGHT | |
52 // | |
53 // On failure the following error codes may be returned: | |
54 // - PP_ERROR_BADRESOURCE if instance is invalid. | |
55 // - PP_ERROR_BADARGUMENT if attrib_list is NULL or any attribute in the | |
56 // attrib_list is not a valid attribute | |
57 int32_t (*GetAttribsMaxValue)(PP_Resource instance, int32_t* attrib_list); | |
58 | |
35 // Creates and initializes a rendering context and returns a handle to it. | 59 // 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 | 60 // 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. | 61 // a plugin instance using PPB_Instance::BindGraphics to draw on the web page. |
38 // | 62 // |
39 // If share_context is not NULL, then all shareable data, as defined | 63 // 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 | 64 // 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 | 65 // excludes texture objects named 0) will be shared by share_context, all |
42 // other contexts share_context already shares with, and the newly created | 66 // other contexts share_context already shares with, and the newly created |
43 // context. An arbitrary number of PPB_Graphics3D_Dev can share data in | 67 // context. An arbitrary number of PPB_Graphics3D_Dev can share data in |
44 // this fashion. | 68 // this fashion. |
(...skipping 15 matching lines...) Expand all Loading... | |
60 // | 84 // |
61 // Attributes that can be specified in attrib_list include: | 85 // Attributes that can be specified in attrib_list include: |
62 // - PP_GRAPHICS3DATTRIB_ALPHA_SIZE: Category: AtLeast Default: 0. | 86 // - PP_GRAPHICS3DATTRIB_ALPHA_SIZE: Category: AtLeast Default: 0. |
63 // - PP_GRAPHICS3DATTRIB_BLUE_SIZE: Category: AtLeast Default: 0. | 87 // - PP_GRAPHICS3DATTRIB_BLUE_SIZE: Category: AtLeast Default: 0. |
64 // - PP_GRAPHICS3DATTRIB_GREEN_SIZE: Category: AtLeast Default: 0. | 88 // - PP_GRAPHICS3DATTRIB_GREEN_SIZE: Category: AtLeast Default: 0. |
65 // - PP_GRAPHICS3DATTRIB_RED_SIZE: Category: AtLeast Default: 0. | 89 // - PP_GRAPHICS3DATTRIB_RED_SIZE: Category: AtLeast Default: 0. |
66 // - PP_GRAPHICS3DATTRIB_DEPTH_SIZE: Category: AtLeast Default: 0. | 90 // - PP_GRAPHICS3DATTRIB_DEPTH_SIZE: Category: AtLeast Default: 0. |
67 // - PP_GRAPHICS3DATTRIB_STENCIL_SIZE: Category: AtLeast Default: 0. | 91 // - PP_GRAPHICS3DATTRIB_STENCIL_SIZE: Category: AtLeast Default: 0. |
68 // - PP_GRAPHICS3DATTRIB_SAMPLES: Category: AtLeast Default: 0. | 92 // - PP_GRAPHICS3DATTRIB_SAMPLES: Category: AtLeast Default: 0. |
69 // - PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS: Category: AtLeast Default: 0. | 93 // - PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS: Category: AtLeast Default: 0. |
94 // - PP_GRAPHICS3DATTRIB_BIND_RGB: Category: Exact Default: PP_FALSE. | |
70 // - PP_GRAPHICS3DATTRIB_WIDTH: Category: Exact Default: 0. | 95 // - PP_GRAPHICS3DATTRIB_WIDTH: Category: Exact Default: 0. |
71 // - PP_GRAPHICS3DATTRIB_HEIGHT: Category: Exact Default: 0. | 96 // - PP_GRAPHICS3DATTRIB_HEIGHT: Category: Exact Default: 0. |
72 // - PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR: | 97 // - PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR: |
73 // Category: Exact Default: Implementation defined. | 98 // Category: Exact Default: Implementation defined. |
74 // | 99 // |
75 // On failure NULL resource is returned. | 100 // On failure NULL resource is returned. |
76 PP_Resource (*Create)(PP_Instance instance, | 101 PP_Resource (*Create)(PP_Instance instance, |
77 PP_Resource share_context, | 102 PP_Resource share_context, |
78 const int32_t* attrib_list); | 103 const int32_t* attrib_list); |
79 | 104 |
80 // Returns PP_TRUE if the given resource is a valid PPB_Graphics3D_Dev, | 105 // 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. | 106 // PP_FALSE if it is an invalid resource or is a resource of another type. |
82 PP_Bool (*IsGraphics3D)(PP_Resource resource); | 107 PP_Bool (*IsGraphics3D)(PP_Resource resource); |
83 | 108 |
84 // Retrieves the values for each attribute in attrib_list. The list | 109 // Retrieves the value for each attribute in attrib_list. The list |
85 // has the same structure as described for PPB_Graphics3D_Dev::Create. | 110 // has the same structure as described for PPB_Graphics3D_Dev::Create. |
86 // It is both input and output structure for this function. | 111 // It is both input and output structure for this function. |
87 // | 112 // |
88 // All attributes specified in PPB_Graphics3D_Dev::Create can be queried for. | 113 // All attributes specified in PPB_Graphics3D_Dev::Create can be queried for. |
89 // On failure the following error codes may be returned: | 114 // On failure the following error codes may be returned: |
90 // - PP_ERROR_BADRESOURCE if context is invalid. | 115 // - PP_ERROR_BADRESOURCE if context is invalid. |
91 // - PP_GRAPHICS3DERROR_BAD_ATTRIBUTE if any attribute in the attrib_list | 116 // - PP_ERROR_BADARGUMENT if attrib_list is NULL or any attribute in the |
92 // is not a valid attribute | 117 // attrib_list is not a valid attribute. |
93 // | 118 // |
94 // Example usage: To get the values for rgb bits in the color buffer, | 119 // Example usage: To get the values for rgb bits in the color buffer, |
95 // this function must be called as following: | 120 // this function must be called as following: |
96 // int attrib_list[] = {PP_GRAPHICS3DATTRIB_RED_SIZE, 0, | 121 // int attrib_list[] = {PP_GRAPHICS3DATTRIB_RED_SIZE, 0, |
97 // PP_GRAPHICS3DATTRIB_GREEN_SIZE, 0, | 122 // PP_GRAPHICS3DATTRIB_GREEN_SIZE, 0, |
98 // PP_GRAPHICS3DATTRIB_BLUE_SIZE, 0, | 123 // PP_GRAPHICS3DATTRIB_BLUE_SIZE, 0, |
99 // PP_GRAPHICS3DATTRIB_NONE}; | 124 // PP_GRAPHICS3DATTRIB_NONE}; |
100 // GetAttribs(context, attrib_list); | 125 // GetAttribs(context, attrib_list); |
101 // int red_bits = attrib_list[1]; | 126 // int red_bits = attrib_list[1]; |
102 // int green_bits = attrib_list[3]; | 127 // int green_bits = attrib_list[3]; |
103 // int blue_bits = attrib_list[5]; | 128 // int blue_bits = attrib_list[5]; |
104 int32_t (*GetAttribs)(PP_Resource context, int32_t* attrib_list); | 129 int32_t (*GetAttribs)(PP_Resource context, int32_t* attrib_list); |
105 | 130 |
106 // Sets the values for each attribute in attrib_list. The list | 131 // Sets the values for each attribute in attrib_list. The list |
107 // has the same structure as described for PPB_Graphics3D_Dev::Create. | 132 // has the same structure as described for PPB_Graphics3D_Dev::Create. |
108 // | 133 // |
109 // Attributes that can be specified are: | 134 // Attributes that can be specified are: |
135 // - PP_GRAPHICS3DATTRIB_BIND_RGB | |
110 // - PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR | 136 // - PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR |
137 // | |
138 // On failure the following error codes may be returned: | |
139 // - PP_ERROR_BADRESOURCE if context is invalid. | |
140 // - PP_ERROR_BADARGUMENT if attrib_list is NULL or any attribute in the | |
141 // attrib_list is not a valid attribute. | |
111 int32_t (*SetAttribs)(PP_Resource context, int32_t* attrib_list); | 142 int32_t (*SetAttribs)(PP_Resource context, int32_t* attrib_list); |
112 | 143 |
144 // The recoverable error conditions that have no side effect are | |
145 // detected and returned immediately by all functions in this interface. | |
146 // In addition the implementation may get into a fatal state while | |
147 // processing a command. In this case the application must detroy the | |
148 // context and reinitialize client API state and objects to continue | |
149 // rendering. Note that the same error code is also returned in the swap | |
150 // buffers callback. | |
151 // | |
152 // The following error codes may be returned: | |
153 // - PP_ERROR_NOMEMORY | |
154 // - PP_GRAPHICS3DERROR_CONTEXT_LOST | |
brettw
2011/08/25 19:25:31
I'm OK just calling this PP_ERROR_CONTEXT_LOST. We
alokp
2011/09/01 20:22:36
Done.
| |
155 int32_t (*GetError)(PP_Resource context); | |
156 | |
113 // Resizes the backing surface for context. | 157 // Resizes the backing surface for context. |
114 // | 158 // |
115 // On failure the following error codes may be returned: | 159 // On failure the following error codes may be returned: |
116 // - PP_ERROR_BADRESOURCE if context is invalid. | 160 // - PP_ERROR_BADRESOURCE if context is invalid. |
117 // - PP_ERROR_BADARGUMENT if the value specified for width or height | 161 // - PP_ERROR_BADARGUMENT if the value specified for width or height |
118 // is less than zero. | 162 // is less than zero. |
119 // | 163 // |
120 // If the surface could not be resized due to insufficient resources, | 164 // If the surface could not be resized due to insufficient resources, |
121 // PP_ERROR_NOMEMORY error is returned on the next SwapBuffers callback. | 165 // PP_ERROR_NOMEMORY error is returned on the next SwapBuffers callback. |
122 int32_t (*ResizeBuffers)(PP_Resource context, | 166 int32_t (*ResizeBuffers)(PP_Resource context, |
123 int32_t width, int32_t height); | 167 int32_t width, int32_t height); |
124 | 168 |
125 // Makes the contents of the color buffer available for compositing. | 169 // Makes the contents of the color buffer available for compositing. |
126 // This function has no effect on off-screen surfaces - ones not bound | 170 // This function has no effect on off-screen surfaces - ones not bound |
127 // to any plugin instance. The contents of ancillary buffers are always | 171 // to any plugin instance. The contents of ancillary buffers are always |
128 // undefined after calling SwapBuffers. The contents of the color buffer are | 172 // undefined after calling SwapBuffers. The contents of the color buffer are |
129 // undefined if the value of the PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR attribute | 173 // undefined if the value of the PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR attribute |
130 // of context is not PP_GRAPHICS3DATTRIB_BUFFER_PRESERVED. | 174 // of context is not PP_GRAPHICS3DATTRIB_BUFFER_PRESERVED. |
131 // | 175 // |
132 // SwapBuffers performs an implicit flush operation on context. | 176 // SwapBuffers runs in asynchronous mode. Specify a callback function and the |
133 // | 177 // argument for that callback function. The callback function will be executed |
134 // This functions can run in two modes: | 178 // 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 | 179 // rest of the html page. While you are waiting for a Flush callback, |
136 // data. This function will block the calling thread until the image has | 180 // additional calls to Flush 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 // | 181 // |
145 // Because the callback is executed (or thread unblocked) only when the | 182 // 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 | 183 // 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 | 184 // 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 | 185 // before painting the next frame, you can ensure you're not generating |
149 // updates faster than the screen can be updated. | 186 // updates faster than the screen can be updated. |
187 // | |
188 // SwapBuffers performs an implicit flush operation on context. | |
189 // If the context gets into an unrecoverable error condition while | |
190 // processing a command, the error code will be returned as the argument | |
191 // for the callback. | |
192 // | |
193 // On failure the following error codes may be returned: | |
194 // - PP_ERROR_BADRESOURCE if context is invalid. | |
195 // - PP_ERROR_BADARGUMENT if callback is invalid. | |
150 int32_t (*SwapBuffers)(PP_Resource context, | 196 int32_t (*SwapBuffers)(PP_Resource context, |
151 struct PP_CompletionCallback callback); | 197 struct PP_CompletionCallback callback); |
152 }; | 198 }; |
153 | 199 |
154 #endif /* PPAPI_C_DEV_PPB_GRAPHICS_3D_DEV_H_ */ | 200 #endif /* PPAPI_C_DEV_PPB_GRAPHICS_3D_DEV_H_ */ |
OLD | NEW |