Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: ppapi/c/dev/ppb_graphics_3d_dev.h

Issue 7576012: Removed config management from Graphics3D API. It will be better handled in the EGL helper library. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/c/dev/pp_graphics_3d_dev.h ('k') | ppapi/c/dev/ppb_graphics_3d_trusted_dev.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "ppapi/c/pp_instance.h" 11 #include "ppapi/c/pp_instance.h"
12 #include "ppapi/c/pp_resource.h" 12 #include "ppapi/c/pp_resource.h"
13 #include "ppapi/c/pp_var.h" 13 #include "ppapi/c/pp_var.h"
14 14
15 // Example usage from plugin code: 15 // Example usage from plugin code:
16 // 16 //
17 // // Setup. 17 // // Setup.
18 // PP_Resource context; 18 // PP_Resource context;
19 // int32_t config, num_config; 19 // int32_t attribs[] = {PP_GRAPHICS3DATTRIB_WIDTH, 800,
20 // g3d->GetConfigs(&config, 1, &num_config); 20 // PP_GRAPHICS3DATTRIB_HEIGHT, 800,
21 // int32_t attribs[] = {PP_GRAPHICS_3D_SURFACE_WIDTH, 800, 21 // PP_GRAPHICS3DATTRIB_NONE};
22 // PP_GRAPHICS_3D_SURFACE_HEIGHT, 800, 22 // context = g3d->Create(instance, attribs, &context);
23 // PP_GRAPHICS_3D_ATTRIB_NONE};
24 // context = g3d->Create(instance, config, attribs, &context);
25 // inst->BindGraphics(instance, context); 23 // inst->BindGraphics(instance, context);
26 // 24 //
27 // // Present one frame. 25 // // Present one frame.
28 // gles2->Clear(context, GL_COLOR_BUFFER); 26 // gles2->Clear(context, GL_COLOR_BUFFER);
29 // g3d->SwapBuffers(context); 27 // g3d->SwapBuffers(context);
30 // 28 //
31 // // Shutdown. 29 // // Shutdown.
32 // core->ReleaseResource(context); 30 // core->ReleaseResource(context);
33 31
34 #define PPB_GRAPHICS_3D_DEV_INTERFACE_0_6 "PPB_Graphics3D(Dev);0.6" 32 #define PPB_GRAPHICS_3D_DEV_INTERFACE_0_7 "PPB_Graphics3D(Dev);0.7"
35 #define PPB_GRAPHICS_3D_DEV_INTERFACE PPB_GRAPHICS_3D_DEV_INTERFACE_0_6 33 #define PPB_GRAPHICS_3D_DEV_INTERFACE PPB_GRAPHICS_3D_DEV_INTERFACE_0_7
36 34
37 struct PPB_Graphics3D_Dev { 35 struct PPB_Graphics3D_Dev {
38 // TODO(alokp): Do these functions need module argument?
39
40 // Retrieves the list of all available PP_Config3D_Devs.
41 // configs is a pointer to a buffer containing config_size elements.
42 // On success, PP_OK is returned. The number of configurations is returned
43 // in num_config, and elements 0 through num_config - 1 of configs are filled
44 // in with valid PP_Config3D_Devs. No more than config_size
45 // PP_Config3D_Devs will be returned even if more are available.
46 // However, if GetConfigs is called with configs = NULL, then no
47 // configurations are returned, but the total number of configurations
48 // available will be returned in num_config.
49 //
50 // On failure following error codes are returned:
51 // PP_ERROR_BADARGUMENT if num_config is NULL.
52 // PP_ERROR_FAILED for everything else.
53 int32_t (*GetConfigs)(PP_Config3D_Dev* configs,
54 int32_t config_size,
55 int32_t* num_config);
56
57 // Retrieves the values for each attribute in attrib_list.
58 // attrib_list is a list of attribute name-value pairs terminated with
59 // PP_GRAPHICS3DCONFIGATTRIB_NONE. It is both input and output structure
60 // for this function.
61 //
62 // On success PP_OK is returned and attrib_list is populated with
63 // values of the attributes specified in attrib_list.
64 // On failure following error codes are returned:
65 // PP_GRAPHICS3DERROR_BAD_CONFIG if config is not valid
66 // PP_ERROR_BADARGUMENT if attrib_list is NULL or malformed
67 // PP_GRAPHICS3DERROR_BAD_ATTRIBUTE if any of the attributes in the
68 // attrib_list is not recognized.
69 //
70 // Example usage: To get the values for rgb bits in the color buffer,
71 // this function must be called as following:
72 // int attrib_list[] = {PP_GRAPHICS3DCONFIGATTRIB_RED_SIZE, 0,
73 // PP_GRAPHICS3DCONFIGATTRIB_GREEN_SIZE, 0,
74 // PP_GRAPHICS3DCONFIGATTRIB_BLUE_SIZE, 0,
75 // PP_GRAPHICS3DCONFIGATTRIB_NONE};
76 // GetConfigAttribs(config, attrib_list);
77 // int red_bits = attrib_list[1];
78 // int green_bits = attrib_list[3];
79 // int blue_bits = attrib_list[5];
80 int32_t (*GetConfigAttribs)(PP_Config3D_Dev config,
81 int32_t* attrib_list);
82
83 // Returns a string describing some aspect of the Graphics3D implementation. 36 // Returns a string describing some aspect of the Graphics3D implementation.
84 // name may be one of: 37 // name may be one of:
85 // - PP_GRAPHICS3DSTRING_CLIENT_APIS: describes which client rendering APIs
86 // are supported. It is zero-terminated and contains a space-separated list
87 // of API names, which must include at least one of "OpenGL" or "OpenGL_ES".
88 // - PP_GRAPHICS3DSTRING_EXTENSIONS: describes which extensions are supported 38 // - PP_GRAPHICS3DSTRING_EXTENSIONS: describes which extensions are supported
89 // by the implementation. The string is zero-terminated and contains a 39 // by the implementation. The string is zero-terminated and contains a
90 // space-separated list of extension names; extension names themselves do 40 // space-separated list of extension names; extension names themselves do
91 // not contain spaces. If there are no extensions, then the empty string is 41 // not contain spaces. If there are no extensions, then the empty string is
92 // returned. 42 // returned.
93 // - PP_GRAPHICS3DSTRING_VENDOR: Implementation dependent. 43 // - PP_GRAPHICS3DSTRING_VENDOR: Implementation dependent.
94 // - PP_GRAPHICS3DSTRING_VERSION: The format of the string is: 44 // - PP_GRAPHICS3DSTRING_VERSION: The format of the string is:
95 // <major version.minor version><space><vendor specific info> 45 // <major version.minor version><space><vendor specific info>
96 // Both the major and minor portions of the version number are numeric. 46 // Both the major and minor portions of the version number are numeric.
97 // The vendor-specific information is optional; if present, its format and 47 // The vendor-specific information is optional; if present, its format and
98 // contents are implementation specific. 48 // contents are implementation specific.
99 // On failure, PP_VARTYPE_UNDEFINED is returned. 49 // On failure, PP_VARTYPE_UNDEFINED is returned.
50 //
51 // TODO(alokp): Does this function need module argument?
52 //
100 struct PP_Var (*GetString)(int32_t name); 53 struct PP_Var (*GetString)(int32_t name);
101 54
102 // Creates and initializes a rendering context and returns a handle to it. 55 // Creates and initializes a rendering context and returns a handle to it.
103 // The returned context is off-screen to start with. It must be attached to 56 // The returned context is off-screen to start with. It must be attached to
104 // a plugin instance using PPB_Instance::BindGraphics to draw on the web page. 57 // a plugin instance using PPB_Instance::BindGraphics to draw on the web page.
105 // 58 //
106 // If share_context is not NULL, then all shareable data, as defined 59 // If share_context is not NULL, then all shareable data, as defined
107 // by the client API (note that for OpenGL and OpenGL ES, shareable data 60 // by the client API (note that for OpenGL and OpenGL ES, shareable data
108 // excludes texture objects named 0) will be shared by share_context, all 61 // excludes texture objects named 0) will be shared by share_context, all
109 // other contexts share_context already shares with, and the newly created 62 // other contexts share_context already shares with, and the newly created
110 // context. An arbitrary number of PPB_Context3D_Dev can share data in 63 // context. An arbitrary number of PPB_Graphics3D_Dev can share data in
111 // this fashion. 64 // this fashion.
112 // 65 //
113 // attrib_list specifies a list of attributes for the context. The list 66 // attrib_list specifies a list of attributes for the context. It is a list
114 // has the same structure as described for 67 // of attribute name-value pairs in which each attribute is immediately
115 // PPB_Graphics3D_Dev::GetConfigAttribs. attrib_list may be NULL or empty 68 // followed by the corresponding desired value. The list is terminated with
116 // (first attribute is PP_GRAPHICS_3D_ATTRIB_NONE), in which case attributes 69 // PP_GRAPHICS3DATTRIB_NONE. The attrib_list may be NULL or empty
117 // assume their default values. 70 // (first attribute is PP_GRAPHICS3DATTRIB_NONE). If an attribute is not
71 // specified in attrib_list, then the default value is used (it is said to
72 // be specified implicitly).
73 //
74 // Attributes for the context are chosen according to an attribute-specific
75 // criteria. Attributes can be classified into two categories:
76 // - AtLeast: The attribute value in the returned context meets or exceeds
77 // the value specified in attrib_list.
78 // - Exact: The attribute value in the returned context is equal to
79 // the value specified in attrib_list.
80 //
118 // Attributes that can be specified in attrib_list include: 81 // Attributes that can be specified in attrib_list include:
119 // - PP_GRAPHICS3DATTRIB_CONTEXT_CLIENT_VERSION: may only be specified when 82 // - PP_GRAPHICS3DATTRIB_ALPHA_SIZE: Category: AtLeast Default: 0.
120 // creating a OpenGL ES context. 83 // - PP_GRAPHICS3DATTRIB_BLUE_SIZE: Category: AtLeast Default: 0.
121 // - PP_GRAPHICS3DATTRIB_WIDTH: The default value is zero. 84 // - PP_GRAPHICS3DATTRIB_GREEN_SIZE: Category: AtLeast Default: 0.
122 // - PP_GRAPHICS3DATTRIB_HEIGHT: The default value is zero. 85 // - PP_GRAPHICS3DATTRIB_RED_SIZE: Category: AtLeast Default: 0.
123 // - PP_GRAPHICS3DATTRIB_LARGEST_SURFACE: If true, creates the largest 86 // - PP_GRAPHICS3DATTRIB_DEPTH_SIZE: Category: AtLeast Default: 0.
124 // possible surface when the allocation of the surface would otherwise fail. 87 // - PP_GRAPHICS3DATTRIB_STENCIL_SIZE: Category: AtLeast Default: 0.
125 // The width and height of the allocated surface will never exceed the 88 // - PP_GRAPHICS3DATTRIB_SAMPLES: Category: AtLeast Default: 0.
126 // values of PP_GRAPHICS3DATTRIB_WIDTH and PP_GRAPHICS3DATTRIB_HEIGHT, 89 // - PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS: Category: AtLeast Default: 0.
127 // respectively. If this option is used, PPB_Graphics3D_Dev::GetAttrib 90 // - PP_GRAPHICS3DATTRIB_WIDTH: Category: Exact Default: 0.
128 // can be used to retrieve surface dimensions. 91 // - PP_GRAPHICS3DATTRIB_HEIGHT: Category: Exact Default: 0.
129 // - PP_GRAPHICS3DATTRIB_RENDER_BUFFER 92 // - PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR:
93 // Category: Exact Default: Implementation defined.
130 // 94 //
131 // It will fail to create a context if config is not a valid PP_Config3D_Dev, 95 // On failure NULL resource is returned.
132 // or does not support the requested client API (this includes requesting
133 // creation of an OpenGL ES 1.x context when the
134 // PP_GRAPHICS3DATTRIB_RENDERABLE_TYPE attribute of config does not
135 // contain PP_GRAPHICS3DATTRIBVALUE_OPENGL_ES_BIT, or creation of an
136 // OpenGL ES 2.x context when the attribute does not contain
137 // PP_GRAPHICS3DATTRIBVALUE_OPENGL_ES2_BIT).
138 //
139 // On failure Create returns NULL resource.
140 PP_Resource (*Create)(PP_Instance instance, 96 PP_Resource (*Create)(PP_Instance instance,
141 PP_Config3D_Dev config,
142 PP_Resource share_context, 97 PP_Resource share_context,
143 const int32_t* attrib_list); 98 const int32_t* attrib_list);
144 99
145 // Returns PP_TRUE if the given resource is a valid PPB_Graphics3D_Dev, 100 // Returns PP_TRUE if the given resource is a valid PPB_Graphics3D_Dev,
146 // PP_FALSE if it is an invalid resource or is a resource of another type. 101 // PP_FALSE if it is an invalid resource or is a resource of another type.
147 PP_Bool (*IsGraphics3D)(PP_Resource resource); 102 PP_Bool (*IsGraphics3D)(PP_Resource resource);
148 103
149 // Retrieves the values for each attribute in attrib_list. The list 104 // Retrieves the values for each attribute in attrib_list. The list
150 // has the same structure as described for 105 // has the same structure as described for PPB_Graphics3D_Dev::Create.
151 // PPB_Graphics3D_Dev::GetConfigAttribs. 106 // It is both input and output structure for this function.
152 // 107 //
153 // Attributes that can be queried for include: 108 // All attributes specified in PPB_Graphics3D_Dev::Create can be queried for.
154 // - PP_GRAPHICS3DATTRIB_CONFIG_ID: returns the ID of the 109 // In addition the following attributes can be queried for as well:
155 // PP_Config3D_Dev with respect to which the context was created. 110 // - PP_GRAPHICS3DATTRIB_MAX_SURFACE_HEIGHT
alokp 2011/08/04 19:02:51 Querying for the maximum surface size creates a ch
piman 2011/08/15 19:44:02 I don't disagree with the chicken-and-egg problem.
alokp 2011/08/15 20:59:31 I can leave it here, but max-surface-size is the m
156 // - PP_GRAPHICS3DATTRIB_CONTEXT_CLIENT_TYPE: returns the type of client API 111 // - PP_GRAPHICS3DATTRIB_MAX_SURFACE_PIXELS
157 // this context supports. 112 // - PP_GRAPHICS3DATTRIB_MAX_SURFACE_WIDTH
158 // - PP_GRAPHICS3DATTRIB_CONTEXT_CLIENT_VERSION: returns the version of the
159 // client API this context supports, as specified at context creation time.
160 // - PP_GRAPHICS3DATTRIB_RENDER_BUFFER: returns the buffer which client API
161 // rendering via this context will use. Either
162 // PP_GRAPHICS3DATTRIBVALUE_BACK_BUFFER or
163 // PP_GRAPHICS3DATTRIBVALUE_SINGLE_BUFFER may be returned depending on the
164 // buffer requested by the setting of the PP_GRAPHICS3DATTRIB_RENDER_BUFFER
165 // property of the context.
166 // - PP_GRAPHICS3DATTRIB_LARGEST_SURFACE: returns the same attribute value
167 // specified when the context was created with PPB_Graphics3D_Dev::Create.
168 // - PP_GRAPHICS3DATTRIB_WIDTH and PP_GRAPHICS3DATTRIB_HEIGHT: The returned
169 // size may be less than the requested size if
170 // PP_GRAPHICS3DATTRIB_LARGEST_SURFACE is true.
171 // - PP_GRAPHICS3DATTRIB_MULTISAMPLE_RESOLVE
172 // - PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR
173 // 113 //
174 // On failure the following error codes may be returned: 114 // On failure the following error codes may be returned:
175 // - PP_ERROR_BADRESOURCE if context is invalid. 115 // - PP_ERROR_BADRESOURCE if context is invalid.
176 // - PP_GRAPHICS3DERROR_BAD_ATTRIBUTE if any attribute in the attrib_list 116 // - PP_GRAPHICS3DERROR_BAD_ATTRIBUTE if any attribute in the attrib_list
177 // is not a valid attribute 117 // is not a valid attribute
178 int32_t (*GetAttribs)(PP_Resource context, 118 //
179 int32_t* attrib_list); 119 // Example usage: To get the values for rgb bits in the color buffer,
120 // this function must be called as following:
121 // int attrib_list[] = {PP_GRAPHICS3DATTRIB_RED_SIZE, 0,
122 // PP_GRAPHICS3DATTRIB_GREEN_SIZE, 0,
123 // PP_GRAPHICS3DATTRIB_BLUE_SIZE, 0,
124 // PP_GRAPHICS3DATTRIB_NONE};
125 // GetAttribs(context, attrib_list);
126 // int red_bits = attrib_list[1];
127 // int green_bits = attrib_list[3];
128 // int blue_bits = attrib_list[5];
129 int32_t (*GetAttribs)(PP_Resource context, int32_t* attrib_list);
180 130
181 // Sets the values for each attribute in attrib_list. The list 131 // Sets the values for each attribute in attrib_list. The list
182 // has the same structure as described for 132 // has the same structure as described for PPB_Graphics3D_Dev::Create.
183 // PPB_Graphics3D_Dev::GetConfigAttribs.
184 // 133 //
185 // Attributes that can be specified are: 134 // Attributes that can be specified are:
186 // - PP_GRAPHICS3DATTRIB_MULTISAMPLE_RESOLVE: If value 135 // - PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR
187 // is PP_GRAPHICS3DATTRIBVALUE_MULTISAMPLE_RESOLVE_BOX, and the 136 int32_t (*SetAttribs)(PP_Resource context, int32_t* attrib_list);
188 // PP_GRAPHICS3DATTRIB_SURFACE_TYPE attribute used to create surface does
189 // not contain PP_GRAPHICS3DATTRIBVALUE_MULTISAMPLE_RESOLVE_BOX_BIT, a
190 // PP_GRAPHICS3DERROR_BAD_MATCH error is returned.
191 // - PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR: If value is
192 // PP_GRAPHICS3DATTRIBVALUE_BUFFER_PRESERVED, and the
193 // PP_GRAPHICS3DATTRIB_SURFACE_TYPE attribute used to create surface
194 // does not contain PP_GRAPHICS3DATTRIBVALUE_SWAP_BEHAVIOR_PRESERVED_BIT,
195 // a PP_GRAPHICS3DERROR_BAD_MATCH error is returned.
196 int32_t (*SetAttribs)(PP_Resource context,
197 int32_t* attrib_list);
198 137
199 // Resizes the backing surface for context. 138 // Resizes the backing surface for context.
200 // 139 //
201 // On failure the following error codes may be returned: 140 // On failure the following error codes may be returned:
202 // - PP_ERROR_BADRESOURCE if context is invalid. 141 // - PP_ERROR_BADRESOURCE if context is invalid.
203 // - PP_ERROR_BADARGUMENT if the value specified for width or height 142 // - PP_ERROR_BADARGUMENT if the value specified for width or height
204 // is less than zero. 143 // is less than zero.
205 // 144 //
206 // If the surface could not be resized due to insufficient resources, 145 // If the surface could not be resized due to insufficient resources,
207 // PP_ERROR_NOMEMORY error is returned on the next SwapBuffers callback. 146 // PP_ERROR_NOMEMORY error is returned on the next SwapBuffers callback.
208 int32_t (*ResizeBuffers)(PP_Resource context, 147 int32_t (*ResizeBuffers)(PP_Resource context,
209 int32_t width, int32_t height); 148 int32_t width, int32_t height);
210 149
211 // Makes the contents of the color buffer available for compositing. 150 // Makes the contents of the color buffer available for compositing.
212 // This function has no effect on off-screen surfaces - ones not bound 151 // This function has no effect on off-screen surfaces - ones not bound
213 // to any plugin instance. The contents of ancillary buffers are always 152 // to any plugin instance. The contents of ancillary buffers are always
214 // undefined after calling SwapBuffers. The contents of the color buffer are 153 // undefined after calling SwapBuffers. The contents of the color buffer are
215 // undefined if the value of the PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR attribute 154 // undefined if the value of the PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR attribute
216 // of context is not PP_GRAPHICS3DATTRIBVALUE_BUFFER_PRESERVED. 155 // of context is not PP_GRAPHICS3DATTRIB_BUFFER_PRESERVED.
217 // 156 //
218 // SwapBuffers performs an implicit flush operation on context. 157 // SwapBuffers performs an implicit flush operation on context.
219 // 158 //
220 // This functions can run in two modes: 159 // This functions can run in two modes:
221 // - In synchronous mode, you specify NULL for the callback and the callback 160 // - In synchronous mode, you specify NULL for the callback and the callback
222 // data. This function will block the calling thread until the image has 161 // data. This function will block the calling thread until the image has
223 // been painted to the screen. It is not legal to block the main thread of 162 // been painted to the screen. It is not legal to block the main thread of
224 // the plugin, you can use synchronous mode only from background threads. 163 // the plugin, you can use synchronous mode only from background threads.
225 // - In asynchronous mode, you specify a callback function and the argument 164 // - In asynchronous mode, you specify a callback function and the argument
226 // for that callback function. The callback function will be executed on 165 // for that callback function. The callback function will be executed on
227 // the calling thread when the image has been painted to the screen. While 166 // the calling thread when the image has been painted to the screen. While
228 // you are waiting for a Flush callback, additional calls to Flush will 167 // you are waiting for a Flush callback, additional calls to Flush will
229 // fail. 168 // fail.
230 // 169 //
231 // Because the callback is executed (or thread unblocked) only when the 170 // Because the callback is executed (or thread unblocked) only when the
232 // plugin's current state is actually on the screen, this function provides a 171 // plugin's current state is actually on the screen, this function provides a
233 // way to rate limit animations. By waiting until the image is on the screen 172 // way to rate limit animations. By waiting until the image is on the screen
234 // before painting the next frame, you can ensure you're not generating 173 // before painting the next frame, you can ensure you're not generating
235 // updates faster than the screen can be updated. 174 // updates faster than the screen can be updated.
236 int32_t (*SwapBuffers)(PP_Resource context, 175 int32_t (*SwapBuffers)(PP_Resource context,
237 struct PP_CompletionCallback callback); 176 struct PP_CompletionCallback callback);
238 }; 177 };
239 178
240 #endif /* PPAPI_C_DEV_PPB_GRAPHICS_3D_DEV_H_ */ 179 #endif /* PPAPI_C_DEV_PPB_GRAPHICS_3D_DEV_H_ */
OLDNEW
« no previous file with comments | « ppapi/c/dev/pp_graphics_3d_dev.h ('k') | ppapi/c/dev/ppb_graphics_3d_trusted_dev.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698