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

Side by Side Diff: ppapi/cpp/graphics_3d.h

Issue 8004005: New and updated documentation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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 | « no previous file | ppapi/cpp/graphics_3d_client.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_CPP_GRAPHICS_3D_H_ 5 #ifndef PPAPI_CPP_GRAPHICS_3D_H_
6 #define PPAPI_CPP_GRAPHICS_3D_H_ 6 #define PPAPI_CPP_GRAPHICS_3D_H_
7 7
8 #include "ppapi/c/ppb_graphics_3d.h" 8 #include "ppapi/c/ppb_graphics_3d.h"
9 #include "ppapi/cpp/resource.h" 9 #include "ppapi/cpp/resource.h"
10 10
11 /// @file
12 /// This file defines the API to create a 3D rendering context in the browser.
11 namespace pp { 13 namespace pp {
12 14
13 class CompletionCallback; 15 class CompletionCallback;
14 class Instance; 16 class Instance;
15 class Var; 17 class Var;
16 18
19 /// This class represents a 3D rendering context in the browser.
17 class Graphics3D : public Resource { 20 class Graphics3D : public Resource {
18 public: 21 public:
19 /// Creates an is_null() Graphics3D object. 22 /// Default constructor for creating an is_null() Graphics3D object.
20 Graphics3D(); 23 Graphics3D();
21 24
22 /// Creates and initializes a 3D rendering context. The returned context is 25 /// A constructor for creating and and initializing a 3D rendering context.
23 /// off-screen to start with. It must be attached to a plugin instance using 26 /// The returned context is created off-screen and must be attached
24 /// Instance::BindGraphics to draw on the web page. 27 /// to a module instance using <code>Instance::BindGraphics</code> to draw on
28 /// the web page.
25 /// 29 ///
26 /// @param[in] instance The instance that will own the new Graphics3D. 30 /// @param[in] instance The instance that will own the new Graphics3D.
27 /// 31 ///
28 /// @param[in] attrib_list The list of attributes for the context. It is a 32 /// @param[in] attrib_list The list of attributes (name=value pairs) for the
29 /// list of attribute name-value pairs in which each attribute is immediately 33 /// context. The list is terminated with
30 /// followed by the corresponding desired value. The list is terminated with 34 /// <code>PP_GRAPHICS3DATTRIB_NONE</code>. The <code>attrib_list</code> may
31 /// PP_GRAPHICS3DATTRIB_NONE. The attrib_list may be NULL or empty 35 /// be <code>NULL</code> or empty (first attribute is
32 /// (first attribute is PP_GRAPHICS3DATTRIB_NONE). If an attribute is not 36 /// <code>PP_GRAPHICS3DATTRIB_NONE</code>). If an attribute is not specified
33 /// specified in attrib_list, then the default value is used (it is said to 37 /// in <code>attrib_list</code>, then the default value is used.
34 /// be specified implicitly).
35 /// 38 ///
36 /// Attributes for the context are chosen according to an attribute-specific 39 /// Attributes are classified into two categories:
37 /// criteria. Attributes can be classified into two categories:
38 /// - AtLeast: The attribute value in the returned context meets or exceeds
39 /// the value specified in attrib_list.
40 /// - Exact: The attribute value in the returned context is equal to
41 /// the value specified in attrib_list.
42 /// 40 ///
43 /// Attributes that can be specified in attrib_list include: 41 /// 1. AtLeast: The attribute value in the returned context will meet or
44 /// - PP_GRAPHICS3DATTRIB_ALPHA_SIZE: Category: AtLeast Default: 0. 42 /// exceed the value requested when creating the object.
45 /// - PP_GRAPHICS3DATTRIB_BLUE_SIZE: Category: AtLeast Default: 0. 43 /// 2. Exact: The attribute value in the returned context is equal to
46 /// - PP_GRAPHICS3DATTRIB_GREEN_SIZE: Category: AtLeast Default: 0. 44 /// the value requested when creating the object.
47 /// - PP_GRAPHICS3DATTRIB_RED_SIZE: Category: AtLeast Default: 0. 45 ///
48 /// - PP_GRAPHICS3DATTRIB_DEPTH_SIZE: Category: AtLeast Default: 0. 46 /// AtLeast attributes are (all have default values of 0):
49 /// - PP_GRAPHICS3DATTRIB_STENCIL_SIZE: Category: AtLeast Default: 0. 47 ///
50 /// - PP_GRAPHICS3DATTRIB_SAMPLES: Category: AtLeast Default: 0. 48 /// <code>PP_GRAPHICS3DATTRIB_ALPHA_SIZE</code>
51 /// - PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS: Category: AtLeast Default: 0. 49 /// <code>PP_GRAPHICS3DATTRIB_BLUE_SIZE</code>
52 /// - PP_GRAPHICS3DATTRIB_WIDTH: Category: Exact Default: 0. 50 /// <code>PP_GRAPHICS3DATTRIB_GREEN_SIZE</code>
53 /// - PP_GRAPHICS3DATTRIB_HEIGHT: Category: Exact Default: 0. 51 /// <code>PP_GRAPHICS3DATTRIB_RED_SIZE</code>
54 /// - PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR: 52 /// <code>PP_GRAPHICS3DATTRIB_DEPTH_SIZE</code>
55 /// Category: Exact Default: Implementation defined. 53 /// <code>PP_GRAPHICS3DATTRIB_STENCIL_SIZE</code>
54 /// <code>PP_GRAPHICS3DATTRIB_SAMPLES</code>
55 /// <code>PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS</code>
56 ///
57 /// Exact attributes are:
58 ///
59 /// <code>PP_GRAPHICS3DATTRIB_WIDTH</code> Default 0
60 /// <code>PP_GRAPHICS3DATTRIB_HEIGHT</code> Default 0
61 /// <code>PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR</code>
62 /// Default: Implementation defined.
56 /// 63 ///
57 /// On failure, the object will be is_null(). 64 /// On failure, the object will be is_null().
58 Graphics3D(const Instance* instance, 65 Graphics3D(const Instance* instance,
59 const int32_t* attrib_list); 66 const int32_t* attrib_list);
60 67
61 /// Creates and initializes a 3D rendering context. The returned context is 68 /// A constructor for creating and initializing a 3D rendering context. The
62 /// off-screen to start with. It must be attached to a plugin instance using 69 /// returned context is created off-screen. It must be attached to a
63 /// Instance::BindGraphics to draw on the web page. 70 /// module instance using <code>Instance::BindGraphics</code> to draw on the
71 /// web page.
64 /// 72 ///
65 /// This is identical to the 2-argument version except that this version 73 /// This constructor is identical to the 2-argument version except that this
66 /// allows sharing of resources with another context. 74 /// version allows sharing of resources with another context.
67 /// 75 ///
68 /// @param[in] instance The instance that will own the new Graphics3D. 76 /// @param[in] instance The instance that will own the new Graphics3D.
69 /// 77 ///
70 /// @param[in] share_context Specifies the context with which all 78 /// @param[in] share_context Specifies the context with which all
71 /// shareable data will be shared. The shareable data is defined by the 79 /// shareable data will be shared. The shareable data is defined by the
72 /// client API (note that for OpenGL and OpenGL ES, shareable data excludes 80 /// client API (note that for OpenGL and OpenGL ES, shareable data excludes
73 /// texture objects named 0). An arbitrary number of Graphics3D resources 81 /// texture objects named 0). An arbitrary number of Graphics3D resources
74 /// can share data in this fashion. 82 /// can share data in this fashion.
75 // 83 //
76 /// @param[in] attrib_list The list of attributes for the context. See the 84 /// @param[in] attrib_list The list of attributes for the context. See the
77 /// 2-argument version for more information. 85 /// 2-argument version of this constructor for more information.
78 /// 86 ///
79 /// On failure, the object will be is_null(). 87 /// On failure, the object will be is_null().
80 Graphics3D(const Instance* instance, 88 Graphics3D(const Instance* instance,
81 const Graphics3D& share_context, 89 const Graphics3D& share_context,
82 const int32_t* attrib_list); 90 const int32_t* attrib_list);
83 91
92 /// Destructor.
84 ~Graphics3D(); 93 ~Graphics3D();
85 94
86 /// Retrieves the value for each attribute in attrib_list. The list 95 /// GetAttribs() retrieves the value for each attribute in
87 /// has the same structure as described for the constructor. 96 /// <code>attrib_list</code>. The list has the same structure as described
88 /// It is both input and output structure for this function. 97 /// for the constructor. All attribute values specified in
98 /// <code>pp_graphics_3d.h</code> can be retrieved.
89 /// 99 ///
90 /// All attributes specified in PPB_Graphics3D.Create can be queried for. 100 /// @param[in,out] attrib_list The list of attributes (name=value pairs) for
91 /// On failure the following error codes may be returned: 101 /// the context. The list is terminated with
92 /// - PP_ERROR_BADRESOURCE if context is invalid. 102 /// <code>PP_GRAPHICS3DATTRIB_NONE</code>.
93 /// - PP_ERROR_BADARGUMENT if attrib_list is NULL or any attribute in the
94 /// attrib_list is not a valid attribute.
95 /// 103 ///
96 /// Example usage: To get the values for rgb bits in the color buffer, 104 /// The following error codes may be returned on failure:
97 /// this function must be called as following: 105 ///
106 /// PP_ERROR_BADRESOURCE if context is invalid.
107 /// PP_ERROR_BADARGUMENT if <code>attrib_list</code> is NULL or any attribute
108 /// in the <code>attrib_list</code> is not a valid attribute.
109 ///
110 /// <strong>Example:</strong>
111 ///
112 /// <code>
98 /// int attrib_list[] = {PP_GRAPHICS3DATTRIB_RED_SIZE, 0, 113 /// int attrib_list[] = {PP_GRAPHICS3DATTRIB_RED_SIZE, 0,
99 /// PP_GRAPHICS3DATTRIB_GREEN_SIZE, 0, 114 /// PP_GRAPHICS3DATTRIB_GREEN_SIZE, 0,
100 /// PP_GRAPHICS3DATTRIB_BLUE_SIZE, 0, 115 /// PP_GRAPHICS3DATTRIB_BLUE_SIZE, 0,
101 /// PP_GRAPHICS3DATTRIB_NONE}; 116 /// PP_GRAPHICS3DATTRIB_NONE};
102 /// GetAttribs(context, attrib_list); 117 /// GetAttribs(context, attrib_list);
103 /// int red_bits = attrib_list[1]; 118 /// int red_bits = attrib_list[1];
104 /// int green_bits = attrib_list[3]; 119 /// int green_bits = attrib_list[3];
105 /// int blue_bits = attrib_list[5]; 120 /// int blue_bits = attrib_list[5];
121 /// </code>
122 ///
123 /// This example retrieves the values for rgb bits in the color buffer.
106 int32_t GetAttribs(int32_t* attrib_list) const; 124 int32_t GetAttribs(int32_t* attrib_list) const;
107 125
108 /// Sets the values for each attribute in attrib_list. The list 126 /// SetAttribs() sets the values for each attribute in
109 /// has the same structure as described for PPB_Graphics3D.Create. 127 /// <code>attrib_list</code>. The list has the same structure as the list
128 /// used in the constructors.
110 /// 129 ///
111 /// Attributes that can be specified are: 130 /// Attributes that can be specified are:
112 /// - PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR 131 /// - PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR
113 /// 132 ///
114 /// On failure the following error codes may be returned: 133 /// On failure the following error codes may be returned:
115 /// - PP_ERROR_BADRESOURCE if context is invalid. 134 /// - PP_ERROR_BADRESOURCE if context is invalid.
116 /// - PP_ERROR_BADARGUMENT if attrib_list is NULL or any attribute in the 135 /// - PP_ERROR_BADARGUMENT if attrib_list is NULL or any attribute in the
117 /// attrib_list is not a valid attribute. 136 /// attrib_list is not a valid attribute.
118 int32_t SetAttribs(int32_t* attrib_list); 137 int32_t SetAttribs(int32_t* attrib_list);
119 138
120 /// Resizes the backing surface for the context. 139 /// ResizeBuffers() resizes the backing surface for the context.
121 /// 140 ///
122 /// On failure the following error codes may be returned: 141 /// @param[in] width The width of the backing surface.
123 /// - PP_ERROR_BADRESOURCE if context is invalid. 142 /// @param[in] height The height of the backing surface.
124 /// - PP_ERROR_BADARGUMENT if the value specified for width or height
125 /// is less than zero.
126 /// 143 ///
127 /// If the surface could not be resized due to insufficient resources, 144 /// @return An int32_t containing <code>PP_ERROR_BADRESOURCE</code> if
128 /// PP_ERROR_NOMEMORY error is returned on the next SwapBuffers callback. 145 /// context is invalid or <code>PP_ERROR_BADARGUMENT</code> if the value
146 /// specified for width or height is less than zero.
147 /// <code>PP_ERROR_NOMEMORY</code> might be returned on the next
148 /// SwapBuffers() callback if the surface could not be resized due to
149 /// insufficient resources.
129 int32_t ResizeBuffers(int32_t width, int32_t height); 150 int32_t ResizeBuffers(int32_t width, int32_t height);
130 151
131 /// Makes the contents of the color buffer available for compositing. 152 /// SwapBuffers() makes the contents of the color buffer available for
132 /// This function has no effect on off-screen surfaces - ones not bound 153 /// compositing. This function has no effect on off-screen surfaces: surfaces
133 /// to any plugin instance. The contents of ancillary buffers are always 154 /// not bound to any module instance. The contents of ancillary buffers are
134 /// undefined after calling SwapBuffers. The contents of the color buffer are 155 /// always undefined after calling SwapBuffers(). The contents of the color
135 /// undefined if the value of the PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR attribute 156 /// buffer are undefined if the value of the
136 /// of context is not PP_GRAPHICS3DATTRIB_BUFFER_PRESERVED. 157 /// <code>PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR</code> attribute of context is
158 /// not <code>PP_GRAPHICS3DATTRIB_BUFFER_PRESERVED</code>.
137 /// 159 ///
138 /// SwapBuffers runs in asynchronous mode. Specify a callback function and the 160 /// SwapBuffers() runs in asynchronous mode. Specify a callback function and
139 /// argument for that callback function. The callback function will be 161 /// the argument for that callback function. The callback function will be
140 /// executed on the calling thread after the color buffer has been composited 162 /// executed on the calling thread after the color buffer has been composited
141 /// with rest of the html page. While you are waiting for a SwapBuffers 163 /// with rest of the html page. While you are waiting for a SwapBuffers()
142 /// callback, additional calls to SwapBuffers will fail. 164 /// callback, additional calls to SwapBuffers() will fail.
143 /// 165 ///
144 /// Because the callback is executed (or thread unblocked) only when the 166 /// Because the callback is executed (or thread unblocked) only when the
145 /// plugin's current state is actually on the screen, this function provides a 167 /// instance's current state is actually on the screen, this function
146 /// way to rate limit animations. By waiting until the image is on the screen 168 /// provides a way to rate limit animations. By waiting until the image is on
147 /// before painting the next frame, you can ensure you're not generating 169 /// the screen before painting the next frame, you can ensure you're not
148 /// updates faster than the screen can be updated. 170 /// generating updates faster than the screen can be updated.
149 /// 171 ///
150 /// SwapBuffers performs an implicit flush operation on context. 172 /// SwapBuffers() performs an implicit flush operation on context.
151 /// If the context gets into an unrecoverable error condition while 173 /// If the context gets into an unrecoverable error condition while
152 /// processing a command, the error code will be returned as the argument 174 /// processing a command, the error code will be returned as the argument
153 /// for the callback. The callback may return the following error codes: 175 /// for the callback. The callback may return the following error codes:
154 /// - PP_ERROR_NOMEMORY
155 /// - PP_ERROR_CONTEXT_LOST
156 /// Note that the same error code may also be obtained by calling GetError.
157 /// 176 ///
158 /// On failure SwapBuffers may return the following error codes: 177 /// <code>PP_ERROR_NOMEMORY</code>
159 /// - PP_ERROR_BADRESOURCE if context is invalid. 178 /// <code>PP_ERROR_CONTEXT_LOST</code>
160 /// - PP_ERROR_BADARGUMENT if callback is invalid. 179 ///
180 /// Note that the same error code may also be obtained by calling GetError().
181 ///
182 /// param[in] cc A <code>CompletionCallback</code> to be called upon
183 /// completion of SwapBuffers().
184 ///
185 /// @return An int32_t containing <code>PP_ERROR_BADRESOURCE</code> if
186 /// context is invalid or <code>PP_ERROR_BADARGUMENT</code> if callback is
187 /// invalid.
161 int32_t SwapBuffers(const CompletionCallback& cc); 188 int32_t SwapBuffers(const CompletionCallback& cc);
162 }; 189 };
163 190
164 } // namespace pp 191 } // namespace pp
165 192
166 #endif // PPAPI_CPP_GRAPHICS_3D_H_ 193 #endif // PPAPI_CPP_GRAPHICS_3D_H_
167 194
OLDNEW
« no previous file with comments | « no previous file | ppapi/cpp/graphics_3d_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698