summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authoralokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-23 04:51:52 +0000
committeralokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-23 04:51:52 +0000
commitbe8fd116e295fd7ef6c75e4dd717017d68c7fd57 (patch)
treec6ef9e02c1e60d189ead67e9a7ce90f01c8da2e8 /ppapi
parent79cc8d9d943c79c2e5237265591d36b884470fbf (diff)
downloadchromium_src-be8fd116e295fd7ef6c75e4dd717017d68c7fd57.zip
chromium_src-be8fd116e295fd7ef6c75e4dd717017d68c7fd57.tar.gz
chromium_src-be8fd116e295fd7ef6c75e4dd717017d68c7fd57.tar.bz2
Added ppapi::Context3D interface. The API has already been reviewed. I am adding the new API incrementally so as not to break the demos.
Review URL: http://codereview.chromium.org/6062003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70037 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/c/dev/pp_graphics_3d_dev.h177
-rw-r--r--ppapi/c/dev/ppb_context_3d_dev.h128
-rw-r--r--ppapi/c/dev/ppb_graphics_3d_dev.h146
-rw-r--r--ppapi/c/dev/ppb_opengles_dev.h2
-rw-r--r--ppapi/cpp/dev/context_3d_dev.cc58
-rw-r--r--ppapi/cpp/dev/context_3d_dev.h38
-rw-r--r--ppapi/cpp/dev/graphics_3d_dev.cc94
-rw-r--r--ppapi/cpp/dev/graphics_3d_dev.h40
-rw-r--r--ppapi/cpp/instance.cc4
-rw-r--r--ppapi/cpp/instance.h5
-rw-r--r--ppapi/ppapi.gyp4
-rw-r--r--ppapi/tests/all_c_includes.h2
12 files changed, 519 insertions, 179 deletions
diff --git a/ppapi/c/dev/pp_graphics_3d_dev.h b/ppapi/c/dev/pp_graphics_3d_dev.h
new file mode 100644
index 0000000..6ea2506
--- /dev/null
+++ b/ppapi/c/dev/pp_graphics_3d_dev.h
@@ -0,0 +1,177 @@
+/* Copyright (c) 2010 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef PPAPI_C_DEV_PP_GRAPHICS_3D_DEV_H_
+#define PPAPI_C_DEV_PP_GRAPHICS_3D_DEV_H_
+
+#include "ppapi/c/pp_stdint.h"
+
+// TODO(alokp): Using PP_Graphics3D prefix is making these enum names rather
+// long. Can we just use PP_GL? It will be a nice short replacement of EGL.
+// In which case we should rename associated classes as - PP_GL, PP_GLContext,
+// PP_GLContext, PP_GLSurface, PP_GLConfig, and PP_OpenGLES2.
+//
+// Another option is to rename Surface3D and Context3D to Graphics3DSurface
+// and Graphics3DContext respectively But this does not make the names
+// any shorter.
+
+enum PP_Graphics3DError_Dev {
+ PP_GRAPHICS3DERROR_BAD_ACCESS = 0x3002,
+ PP_GRAPHICS3DERROR_BAD_ATTRIBUTE = 0x3004,
+ PP_GRAPHICS3DERROR_BAD_CONFIG = 0x3005,
+ PP_GRAPHICS3DERROR_BAD_CONTEXT = 0x3006,
+ PP_GRAPHICS3DERROR_BAD_MATCH = 0x3009,
+ PP_GRAPHICS3DERROR_BAD_SURFACE = 0x300D,
+ PP_GRAPHICS3DERROR_CONTEXT_LOST = 0x300E
+};
+
+enum PP_Graphics3DString_Dev {
+ PP_GRAPHICS3DSTRING_VENDOR = 0x3053,
+ PP_GRAPHICS3DSTRING_VERSION = 0x3054,
+ // Which extensions are supported.
+ PP_GRAPHICS3DSTRING_EXTENSIONS = 0x3055,
+ // Which client rendering APIs are supported.
+ PP_GRAPHICS3DSTRING_CLIENT_APIS = 0x308D
+};
+
+enum PP_Graphics3DAttrib_Dev {
+ // Total color component bits in the color buffer.
+ PP_GRAPHICS3DATTRIB_BUFFER_SIZE = 0x3020,
+ // Bits of Alpha in the color buffer.
+ PP_GRAPHICS3DATTRIB_ALPHA_SIZE = 0x3021,
+ // Bits of Blue in the color buffer.
+ PP_GRAPHICS3DATTRIB_BLUE_SIZE = 0x3022,
+ // Bits of Green in the color buffer.
+ PP_GRAPHICS3DATTRIB_GREEN_SIZE = 0x3023,
+ // Bits of Red in the color buffer.
+ PP_GRAPHICS3DATTRIB_RED_SIZE = 0x3024,
+ // Bits of Z in the depth buffer.
+ PP_GRAPHICS3DATTRIB_DEPTH_SIZE = 0x3025,
+ // Bits of Stencil in the stencil buffer.
+ PP_GRAPHICS3DATTRIB_STENCIL_SIZE = 0x3026,
+ // Any caveats for the configuration.
+ PP_GRAPHICS3DATTRIB_CONFIG_CAVEAT = 0x3027,
+ // Unique EGLConfig identifier.
+ PP_GRAPHICS3DATTRIB_CONFIG_ID = 0x3028,
+ // Maximum height of surface.
+ PP_GRAPHICS3DATTRIB_MAX_SURFACE_HEIGHT = 0x302A,
+ // Maximum size of surface.
+ PP_GRAPHICS3DATTRIB_MAX_SURFACE_PIXELS = 0x302B,
+ // Maximum width of surface.
+ PP_GRAPHICS3DATTRIB_MAX_SURFACE_WIDTH = 0x302C,
+ // Number of samples per pixel.
+ PP_GRAPHICS3DATTRIB_SAMPLES = 0x3031,
+ // Number of multisample buffers.
+ PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS = 0x3032,
+ // Which types of EGL surfaces are supported.
+ PP_GRAPHICS3DATTRIB_SURFACE_TYPE = 0x3033,
+ // Type of transparency supported.
+ PP_GRAPHICS3DATTRIB_TRANSPARENT_TYPE = 0x3034,
+ // Transparent blue value.
+ PP_GRAPHICS3DATTRIB_TRANSPARENT_BLUE_VALUE = 0x3035,
+ // Transparent green value.
+ PP_GRAPHICS3DATTRIB_TRANSPARENT_GREEN_VALUE = 0x3036,
+ // Transparent red value.
+ PP_GRAPHICS3DATTRIB_TRANSPARENT_RED_VALUE = 0x3037,
+ // Attrib list terminator.
+ PP_GRAPHICS3DATTRIB_NONE = 0x3038,
+ // TODO(alokp): Find out if we can support swap intervals. Remove them if not.
+ // Minimum swap interval.
+ PP_GRAPHICS3DATTRIB_MIN_SWAP_INTERVAL = 0x303B,
+ // Maximum swap interval.
+ PP_GRAPHICS3DATTRIB_MAX_SWAP_INTERVAL = 0x303C,
+ // Bits of Luminance in the color buffer.
+ PP_GRAPHICS3DATTRIB_LUMINANCE_SIZE = 0x303D,
+ // Bits of Alpha Mask in the mask buffer.
+ PP_GRAPHICS3DATTRIB_ALPHA_MASK_SIZE = 0x303E,
+ // Color buffer type.
+ PP_GRAPHICS3DATTRIB_COLOR_BUFFER_TYPE = 0x303F,
+ // Which client APIs are supported.
+ PP_GRAPHICS3DATTRIB_RENDERABLE_TYPE = 0x3040,
+ // Whether contexts created with this config are conformant.
+ PP_GRAPHICS3DATTRIB_CONFORMANT = 0x3042,
+
+ // Surface-specific attributes.
+ // Height of surface in pixels.
+ PP_GRAPHICS3DATTRIB_HEIGHT = 0x3056,
+ // Width of surface in pixels.
+ PP_GRAPHICS3DATTRIB_WIDTH = 0x3057,
+ // If true, largest possible surface is created.
+ PP_GRAPHICS3DATTRIB_LARGEST_SURFACE = 0x3058,
+ // The buffer which client API renders to.
+ PP_GRAPHICS3DATTRIB_RENDER_BUFFER = 0x3086,
+ // Specifies the effect on the color buffer of posting a surface
+ // with SwapBuffers.
+ PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR = 0x3093,
+ // Specifies the filter to use when resolving the multisample buffer.
+ PP_GRAPHICS3DATTRIB_MULTISAMPLE_RESOLVE = 0x3099,
+
+ // Context-specific attributes.
+ // Which client API the context supports.
+ PP_GRAPHICS3DATTRIB_CONTEXT_CLIENT_TYPE = 0x3097,
+ // Version of OpenGL ES supported by a context.
+ // An attribute value of 1 specifies OpenGL ES 1.x.
+ // An attribute value of 2 specifies OpenGL ES 2.x.
+ // The default value for PP_GRAPHICS3DATTRIB_CONTEXT_CLIENT_VERSION is 1.
+ // This attribute is only meaningful for an OpenGL ES context.
+ PP_GRAPHICS3DATTRIB_CONTEXT_CLIENT_VERSION = 0x3098
+};
+
+enum PP_Graphics3DAttribValue_Dev {
+ PP_GRAPHICS3DATTRIBVALUE_NONE = 0x3038,
+
+ // PP_GRAPHICS3DATTRIB_CONFIG_CAVEAT values.
+ PP_GRAPHICS3DATTRIBVALUE_SLOW_CONFIG = 0x3050,
+ PP_GRAPHICS3DATTRIBVALUE_NON_CONFORMANT_CONFIG = 0x3051,
+
+ // PP_GRAPHICS3DATTRIB_TRANSPARENT_TYPE values.
+ PP_GRAPHICS3DATTRIBVALUE_TRANSPARENT_RGB = 0x3052,
+
+ // PP_GRAPHICS3DATTRIB_COLOR_BUFFER_TYPE values.
+ PP_GRAPHICS3DATTRIBVALUE_RGB_BUFFER = 0x308E,
+ PP_GRAPHICS3DATTRIBVALUE_LUMINANCE_BUFFER = 0x308F,
+
+ // PP_GRAPHICS3DATTRIB_SURFACE_TYPE mask bits.
+ // Indicates if box filter (PP_GRAPHICS3DATTRIBVALUE_MULTISAMPLE_RESOLVE_BOX)
+ // for resolving the multisample buffer is supported.
+ PP_GRAPHICS3DATTRIBVALUE_MULTISAMPLE_RESOLVE_BOX_BIT = 0x0200,
+ PP_GRAPHICS3DATTRIBVALUE_SWAP_BEHAVIOR_PRESERVED_BIT = 0x0400,
+
+ // PP_GRAPHICS3DATTRIB_RENDERABLE_TYPE mask bits.
+ PP_GRAPHICS3DATTRIBVALUE_OPENGL_ES_BIT = 0x0001,
+ PP_GRAPHICS3DATTRIBVALUE_OPENGL_ES2_BIT = 0x0004,
+ PP_GRAPHICS3DATTRIBVALUE_OPENGL_BIT = 0x0008,
+
+ // PP_GRAPHICS3DATTRIB_RENDER_BUFFER values.
+ // The default value is PP_GRAPHICS3DATTRIBVALUE_BACK_BUFFER.
+ // Surface contains two color buffers and client APIs render into
+ // the back buffer.
+ PP_GRAPHICS3DATTRIBVALUE_BACK_BUFFER = 0x3084,
+ // Surface contains a single color buffer.
+ PP_GRAPHICS3DATTRIBVALUE_SINGLE_BUFFER = 0x3085,
+
+ // PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR values.
+ // The initial value is chosen by the implementation.
+ // Indicates that color buffer contents are unaffected.
+ PP_GRAPHICS3DATTRIBVALUE_BUFFER_PRESERVED = 0x3094,
+ // Indicates that color buffer contents may be destroyed or changed.
+ PP_GRAPHICS3DATTRIBVALUE_BUFFER_DESTROYED = 0x3095,
+
+ // PP_GRAPHICS3DATTRIB_MULTISAMPLE_RESOLVE values.
+ // The default value is PP_GRAPHICS3DATTRIBVALUE_MULTISAMPLE_RESOLVE_DEFAULT.
+ // The default implementation-defined filtering method.
+ PP_GRAPHICS3DATTRIBVALUE_MULTISAMPLE_RESOLVE_DEFAULT = 0x309A,
+ // One-pixel wide box filter placing equal weighting on all
+ // multisample values.
+ PP_GRAPHICS3DATTRIBVALUE_MULTISAMPLE_RESOLVE_BOX = 0x309B,
+
+ // PP_GRAPHICS3DATTRIB_CONTEXT_CLIENT_TYPE values.
+ PP_GRAPHICS3DATTRIBVALUE_OPENGL_ES_API = 0x30A0,
+ PP_GRAPHICS3DATTRIBVALUE_OPENGL_API = 0x30A2
+};
+
+typedef int32_t PP_Config3D_Dev;
+
+#endif // PPAPI_C_DEV_PP_GRAPHICS_3D_DEV_H_
diff --git a/ppapi/c/dev/ppb_context_3d_dev.h b/ppapi/c/dev/ppb_context_3d_dev.h
new file mode 100644
index 0000000..79969a3
--- /dev/null
+++ b/ppapi/c/dev/ppb_context_3d_dev.h
@@ -0,0 +1,128 @@
+/* Copyright (c) 2010 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef PPAPI_C_DEV_PPB_CONTEXT_3D_DEV_H_
+#define PPAPI_C_DEV_PPB_CONTEXT_3D_DEV_H_
+
+#include "ppapi/c/dev/pp_graphics_3d_dev.h"
+
+#include "ppapi/c/pp_bool.h"
+#include "ppapi/c/pp_instance.h"
+#include "ppapi/c/pp_resource.h"
+
+#define PPB_CONTEXT_3D_DEV_INTERFACE "PPB_Context3D(Dev);0.1"
+
+struct PPB_Context3D_Dev {
+ // Creates and initializes a rendering context and returns a handle to it.
+ // The context can be used to render to any compatible PPB_Surface3D_Dev.
+ //
+ // If share_context is not NULL, then all shareable data, as defined
+ // by the client API (note that for OpenGL and OpenGL ES, shareable data
+ // excludes texture objects named 0) will be shared by share_context, all
+ // other contexts share_context already shares with, and the newly created
+ // context. An arbitrary number of PPB_Context3D_Dev can share data in
+ // this fashion.
+ //
+ // attrib_list specifies a list of attributes for the context. The list
+ // has the same structure as described for
+ // PPB_Graphics3D_Dev::GetConfigAttribs. The only attribute that can be
+ // specified in attrib_list is PP_GRAPHICS3DATTRIB_CONTEXT_CLIENT_VERSION,
+ // and this attribute may only be specified when creating a OpenGL ES context.
+ // attrib_list may be NULL or empty (first attribute is EGL_NONE), in which
+ // case attributes assume their default values.
+ //
+ // If config is not a valid PP_Config3D_Dev, or does not support
+ // the requested client API, then an PP_GRAPHICS3DERROR_BAD_CONFIG error is
+ // generated (this includes requesting creation of an OpenGL ES 1.x context
+ // when the PP_GRAPHICS3DATTRIB_RENDERABLE_TYPE attribute of config does not
+ // contain PP_GRAPHICS3DATTRIBVALUE_OPENGL_ES_BIT, or creation of an
+ // OpenGL ES 2.x context when the attribute does not contain
+ // PP_GRAPHICS3DATTRIBVALUE_OPENGL_ES2_BIT).
+ //
+ // On failure Create returns NULL resource.
+ PP_Resource (*Create)(PP_Instance instance,
+ PP_Config3D_Dev config,
+ PP_Resource share_context,
+ const int32_t* attrib_list);
+
+ // Returns PP_TRUE if the given resource is a valid PPB_Context3D_Dev,
+ // PP_FALSE if it is an invalid resource or is a resource of another type.
+ PP_Bool (*IsContext3D)(PP_Resource resource);
+
+ // Returns in value the value of attribute for context.
+ // Attributes that can be queried for include:
+ // - PP_GRAPHICS3DATTRIB_CONFIG_ID: returns the ID of the
+ // PP_Config3D_Dev with respect to which the context was created.
+ // - PP_GRAPHICS3DATTRIB_CONTEXT_CLIENT_TYPE: returns the type of client API
+ // this context supports.
+ // - PP_GRAPHICS3DATTRIB_CONTEXT_CLIENT_VERSION: returns the version of the
+ // client API this context supports, as specified at context creation time.
+ // - PP_GRAPHICS3DATTRIB_RENDER_BUFFER: returns the buffer which client API
+ // rendering via this context will use. The value returned depends on
+ // properties of both the context, and the surface to which the context
+ // is bound:
+ // - If the context is bound to a surface, then either
+ // PP_GRAPHICS3DATTRIBVALUE_BACK_BUFFER or
+ // PP_GRAPHICS3DATTRIBVALUE_SINGLE_BUFFER may be returned. The value
+ // returned depends on the buffer requested by the setting of the
+ // PP_GRAPHICS3DATTRIB_RENDER_BUFFER property of the surface.
+ // - If the context is not bound to a surface, then
+ // PP_GRAPHICS3DATTRIBVALUE_NONE will be returned.
+ //
+ // On failure the following error codes may be returned:
+ // - PP_GRAPHICS3DERROR_BAD_ATTRIBUTE if attribute is not a valid attribute
+ // - PP_GRAPHICS3DERROR_BAD_CONTEXT if context is invalid.
+ int32_t (*GetAttrib)(PP_Resource context,
+ int32_t attribute,
+ int32_t* value);
+
+ // Binds context to the draw and read surfaces.
+ // For an OpenGL or OpenGL ES context, draw is used for all operations except
+ // for any pixel data read back or copied, which is taken from the frame
+ // buffer values of read. Note that the same PPB_Surface3D_Dev may be
+ // specified for both draw and read.
+ //
+ // On failure the following error codes may be returned:
+ // - PP_GRAPHICS3DERROR_BAD_MATCH: if draw or read surfaces are not
+ // compatible with context.
+ // - PP_GRAPHICS3DERROR_BAD_ACCESS: if either draw or read is bound to any
+ // other context.
+ // - PP_GRAPHICS3DERROR_BAD_CONTEXT: if context is not a valid context.
+ // - PP_GRAPHICS3DERROR_BAD_SURFACE: if either draw or read are not valid
+ // surfaces.
+ // - PP_GRAPHICS3DERROR_BAD_MATCH:fIf draw and read cannot fit into
+ // graphics memory simultaneously.
+ // - PP_ERROR_NOMEMORY: if the ancillary buffers for draw and read cannot
+ // be allocated.
+ // - PP_GRAPHICS3DERROR_CONTEXT_LOST: if a power management event has
+ // occurred.
+ //
+ // If draw is destroyed after BindSurfaces is called, then subsequent
+ // rendering commands will be processed and the context state will be updated,
+ // but the surface contents become undefined. If read is destroyed after
+ // BindSurfaces then pixel values read from the framebuffer (e.g., as result
+ // of calling glReadPixels) are undefined.
+ //
+ // To unbind surfaces set draw and read to NULL.
+ int32_t (*BindSurfaces)(PP_Resource context,
+ PP_Resource draw,
+ PP_Resource read);
+
+ // Returns the surfaces bound to the context for drawing and reading in
+ // draw and read respectively.
+ //
+ // On failure, the following error codes can be returned:
+ // - PP_GRAPHICS3DERROR_BAD_CONTEXT: if context is not a valid context.
+ // - PP_ERROR_BADARGUMENT: if either draw or read is NULL.
+ int32_t (*GetBoundSurfaces)(PP_Resource context,
+ PP_Resource* draw,
+ PP_Resource* read);
+
+ // TODO(alokp): Move to PPB_Surface3D_Dev
+ int32_t (*SwapBuffers)(PP_Resource context,
+ struct PP_CompletionCallback callback);
+};
+
+#endif // PPAPI_C_DEV_PPB_CONTEXT_3D_DEV_H_
diff --git a/ppapi/c/dev/ppb_graphics_3d_dev.h b/ppapi/c/dev/ppb_graphics_3d_dev.h
index cb67d46..6d5374a 100644
--- a/ppapi/c/dev/ppb_graphics_3d_dev.h
+++ b/ppapi/c/dev/ppb_graphics_3d_dev.h
@@ -5,92 +5,96 @@
#ifndef PPAPI_C_DEV_PPB_GRAPHICS_3D_DEV_H_
#define PPAPI_C_DEV_PPB_GRAPHICS_3D_DEV_H_
-#include "ppapi/c/pp_bool.h"
-#include "ppapi/c/pp_instance.h"
-#include "ppapi/c/pp_module.h"
-#include "ppapi/c/pp_resource.h"
-#include "ppapi/c/pp_stdint.h"
+#include "ppapi/c/dev/pp_graphics_3d_dev.h"
// Example usage from plugin code:
//
-// PP_Resource context = device->Create(module, config, contextAttribList);
-// CHECK(context);
+// // Setup.
+// PP_Resource context, surface;
+// int32_t config, num_config;
+// g3d->GetConfigs(&config, 1, &num_config);
+// int32_t attribs[] = {PP_GRAPHICS_3D_SURFACE_WIDTH, 800,
+// PP_GRAPHICS_3D_SURFACE_HEIGHT, 800,
+// PP_GRAPHICS_3D_ATTRIB_NONE};
+// c3d->Create(instance, config, NULL, NULL, &context);
+// s3d->Create(instance, config, attribs, &surface);
+// c3d->BindSurfaces(context, surface, surface);
+// inst->BindGraphics(instance, surface);
//
// // Present one frame.
-// CHECK(device->MakeCurrent(context));
-// glClear(GL_COLOR_BUFFER);
-// CHECK(device->MakeCurrent(NULL));
-// CHECK(device->SwapBuffers(context));
+// gles2->Clear(context, GL_COLOR_BUFFER);
+// c3d->SwapBuffers(context);
//
// // Shutdown.
// core->ReleaseResource(context);
+// core->ReleaseResource(surface);
#define PPB_GRAPHICS_3D_DEV_INTERFACE "PPB_Graphics3D(Dev);0.2"
-// These are the same error codes as used by EGL.
-enum {
- PP_GRAPHICS_3D_ERROR_SUCCESS = 0x3000,
- PP_GRAPHICS_3D_ERROR_NOT_INITIALIZED = 0x3001,
- PP_GRAOHICS_3D_ERROR_BAD_CONTEXT = 0x3006,
- PP_GRAPHICS_3D_ERROR_BAD_PARAMETER = 0x300C,
- PP_GRAPHICS_3D_ERROR_CONTEXT_LOST = 0x300E
-};
-
-// QueryString targets, matching EGL ones.
-enum {
- EGL_VENDOR = 0x3053,
- EGL_VERSION = 0x3054,
- EGL_EXTENSIONS = 0x3055,
- EGL_CLIENT_APIS = 0x308D
-};
-
struct PPB_Graphics3D_Dev {
- PP_Bool (*IsGraphics3D)(PP_Resource resource);
-
- // EGL-like configuration ----------------------------------------------------
- PP_Bool (*GetConfigs)(int32_t* configs,
+ // TODO(alokp): Do these functions need module argument.
+
+ // Retrieves the list of all available PP_Config3D_Devs.
+ // configs is a pointer to a buffer containing config_size elements.
+ // On success, PP_OK is returned. The number of configurations is returned
+ // in num_config, and elements 0 through num_config - 1 of configs are filled
+ // in with valid PP_Config3D_Devs. No more than config_size
+ // PP_Config3D_Devs will be returned even if more are available.
+ // However, if GetConfigs is called with configs = NULL, then no
+ // configurations are returned, but the total number of configurations
+ // available will be returned in num_config.
+ //
+ // On failure following error codes are returned:
+ // PP_ERROR_BADARGUMENT if num_config is NULL.
+ // PP_ERROR_FAILED for everything else.
+ int32_t (*GetConfigs)(PP_Config3D_Dev* configs,
int32_t config_size,
int32_t* num_config);
- PP_Bool (*ChooseConfig)(const int32_t* attrib_list,
- int32_t* configs,
- int32_t config_size,
- int32_t* num_config);
-
- // TODO(apatrick): What to do if the browser window is moved to
- // another display? Do the configs potentially change?
- PP_Bool (*GetConfigAttrib)(int32_t config, int32_t attribute, int32_t* value);
-
- const char* (*QueryString)(int32_t name);
- // ---------------------------------------------------------------------------
-
-
- // Create a reference counted 3D context. Releasing a context while it is
- // current automatically sets the current context to NULL. This is only true
- // for the releasing thread. Releasing a context while it is current on
- // another thread leads to undefined behavior.
- PP_Resource (*CreateContext)(PP_Instance instance,
- int32_t config,
- int32_t share_context,
- const int32_t* attrib_list);
-
- // Get the address of any GL functions, whether core or part of an extension.
- // Any thread.
- void* (*GetProcAddress)(const char* name);
-
- // Snapshots the rendered frame and makes it available for composition with
- // the rest of the page. The alpha channel is used for translucency effects.
- // One means fully opaque. Zero means fully transparent. Any thread.
- // TODO(apatrick): premultiplied alpha or linear alpha? Premultiplied alpha is
- // better for correct alpha blending effect. Most existing OpenGL code assumes
- // linear. I could convert from linear to premultiplied during the copy from
- // back-buffer to offscreen "front-buffer".
- PP_Bool (*SwapBuffers)(PP_Resource context);
-
- // Returns the current error for this thread. This is not associated with a
- // particular context. It is distinct from the GL error returned by
- // glGetError.
- uint32_t (*GetError)();
+ // Retrieves the values for each attribute in attrib_list.
+ // attrib_list is a list of attribute name-value pairs terminated with
+ // PP_GRAPHICS3DCONFIGATTRIB_NONE. It is both input and output structure
+ // for this function.
+ //
+ // On success PP_OK is returned and attrib_list is populated with
+ // values of the attributes specified in attrib_list.
+ // On failure following error codes are returned:
+ // PP_GRAPHICS3DERROR_BAD_CONFIG if config is not valid
+ // PP_ERROR_BADARGUMENT if attrib_list is NULL or malformed
+ // PP_GRAPHICS3DERROR_BAD_ATTRIBUTE if any of the attributes in the
+ // attrib_list is not recognized.
+ //
+ // Example usage: To get the values for rgb bits in the color buffer,
+ // this function must be called as following:
+ // int attrib_list[] = {PP_GRAPHICS3DCONFIGATTRIB_RED_SIZE, 0,
+ // PP_GRAPHICS3DCONFIGATTRIB_GREEN_SIZE, 0,
+ // PP_GRAPHICS3DCONFIGATTRIB_BLUE_SIZE, 0,
+ // PP_GRAPHICS3DCONFIGATTRIB_NONE};
+ // GetConfigAttribs(config, attrib_list);
+ // int red_bits = attrib_list[1];
+ // int green_bits = attrib_list[3];
+ // int blue_bits = attrib_list[5];
+ int32_t (*GetConfigAttribs)(PP_Config3D_Dev config,
+ int32_t* attrib_list);
+
+ // Returns a string describing some aspect of the Graphics3D implementation.
+ // name may be one of:
+ // - PP_GRAPHICS3DSTRING_CLIENT_APIS: describes which client rendering APIs
+ // are supported. It is zero-terminated and contains a space-separated list
+ // of API names, which must include at least one of "OpenGL" or "OpenGL_ES".
+ // - PP_GRAPHICS3DSTRING_EXTENSIONS: describes which extensions are supported
+ // by the implementation. The string is zero-terminated and contains a
+ // space-separated list of extension names; extension names themselves do
+ // not contain spaces. If there are no extensions, then the empty string is
+ // returned.
+ // - PP_GRAPHICS3DSTRING_VENDOR: Implementation dependent.
+ // - PP_GRAPHICS3DSTRING_VERSION: The format of the string is:
+ // <major version.minor version><space><vendor specific info>
+ // Both the major and minor portions of the version number are numeric.
+ // The vendor-specific information is optional; if present, its format and
+ // contents are implementation specific.
+ // On failure, PP_VARTYPE_UNDEFINED is returned.
+ struct PP_Var (*GetString)(int32_t name);
};
#endif /* PPAPI_C_DEV_PPB_GRAPHICS_3D_DEV_H_ */
diff --git a/ppapi/c/dev/ppb_opengles_dev.h b/ppapi/c/dev/ppb_opengles_dev.h
index 76baa89..254a313 100644
--- a/ppapi/c/dev/ppb_opengles_dev.h
+++ b/ppapi/c/dev/ppb_opengles_dev.h
@@ -8,6 +8,8 @@
#ifndef PPAPI_C_DEV_PPB_OPENGLES_DEV_H_
#define PPAPI_C_DEV_PPB_OPENGLES_DEV_H_
+#include "ppapi/c/pp_resource.h"
+
#ifndef __gl2_h_
typedef unsigned int GLenum;
typedef void GLvoid;
diff --git a/ppapi/cpp/dev/context_3d_dev.cc b/ppapi/cpp/dev/context_3d_dev.cc
new file mode 100644
index 0000000..47f51ac
--- /dev/null
+++ b/ppapi/cpp/dev/context_3d_dev.cc
@@ -0,0 +1,58 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ppapi/cpp/dev/context_3d_dev.h"
+
+#include "ppapi/c/pp_completion_callback.h"
+#include "ppapi/c/dev/ppb_opengles_dev.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/cpp/instance.h"
+#include "ppapi/cpp/module_impl.h"
+
+namespace pp {
+
+namespace {
+
+template <> const char* interface_name<PPB_Context3D_Dev>() {
+ return PPB_CONTEXT_3D_DEV_INTERFACE;
+}
+
+template <> const char* interface_name<PPB_OpenGLES2_Dev>() {
+ return PPB_OPENGLES2_DEV_INTERFACE;
+}
+
+} // namespace
+
+Context3D_Dev Context3D_Dev::FromResource(PP_Resource resource_id) {
+ if (has_interface<PPB_Context3D_Dev>() &&
+ get_interface<PPB_Context3D_Dev>()->IsContext3D(resource_id))
+ return Context3D_Dev(resource_id);
+
+ return Context3D_Dev();
+}
+
+Context3D_Dev::Context3D_Dev(const Instance& instance,
+ PP_Config3D_Dev config,
+ const Context3D_Dev& share_context,
+ const int32_t* attrib_list) {
+ if (has_interface<PPB_Context3D_Dev>() &&
+ has_interface<PPB_OpenGLES2_Dev>()) {
+ PassRefFromConstructor(get_interface<PPB_Context3D_Dev>()->Create(
+ instance.pp_instance(),
+ config,
+ share_context.pp_resource(),
+ attrib_list));
+ }
+}
+
+int32_t Context3D_Dev::SwapBuffers() const {
+ if (!has_interface<PPB_Context3D_Dev>())
+ return PP_ERROR_NOINTERFACE;
+
+ return get_interface<PPB_Context3D_Dev>()->SwapBuffers(
+ pp_resource(),
+ PP_BlockUntilComplete());
+}
+
+} // namespace pp
diff --git a/ppapi/cpp/dev/context_3d_dev.h b/ppapi/cpp/dev/context_3d_dev.h
new file mode 100644
index 0000000..51881f3
--- /dev/null
+++ b/ppapi/cpp/dev/context_3d_dev.h
@@ -0,0 +1,38 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef PPAPI_CPP_DEV_GRAPHICS_3D_DEV_H_
+#define PPAPI_CPP_DEV_GRAPHICS_3D_DEV_H_
+
+#include "ppapi/c/dev/ppb_context_3d_dev.h"
+
+#include "ppapi/cpp/instance.h"
+#include "ppapi/cpp/resource.h"
+
+namespace pp {
+
+class CompletionCallback;
+
+class Context3D_Dev : public Resource {
+ public:
+ // Creates an is_null() Context3D object.
+ Context3D_Dev() {}
+
+ Context3D_Dev(const Instance& instance,
+ PP_Config3D_Dev config,
+ const Context3D_Dev& share_context,
+ const int32_t* attrib_list);
+
+ // TODO(alokp): Move to Surface3D.
+ int32_t SwapBuffers() const;
+
+ protected:
+ explicit Context3D_Dev(PP_Resource resource_id) : Resource(resource_id) {}
+ static Context3D_Dev FromResource(PP_Resource resource_id);
+};
+
+} // namespace pp
+
+#endif // PPAPI_CPP_DEV_GRAPHICS_3D_DEV_H_
+
diff --git a/ppapi/cpp/dev/graphics_3d_dev.cc b/ppapi/cpp/dev/graphics_3d_dev.cc
index 579b610..f0a587e 100644
--- a/ppapi/cpp/dev/graphics_3d_dev.cc
+++ b/ppapi/cpp/dev/graphics_3d_dev.cc
@@ -4,11 +4,9 @@
#include "ppapi/cpp/dev/graphics_3d_dev.h"
-#include "ppapi/cpp/common.h"
-#include "ppapi/cpp/instance.h"
-#include "ppapi/cpp/resource.h"
-#include "ppapi/cpp/module.h"
+#include "ppapi/c/pp_errors.h"
#include "ppapi/cpp/module_impl.h"
+#include "ppapi/cpp/var.h"
namespace pp {
@@ -18,87 +16,37 @@ template <> const char* interface_name<PPB_Graphics3D_Dev>() {
return PPB_GRAPHICS_3D_DEV_INTERFACE;
}
-template <> const char* interface_name<PPB_OpenGLES2_Dev>() {
- return PPB_OPENGLES2_DEV_INTERFACE;
-}
-
} // namespace
// static
-bool Graphics3D_Dev::GetConfigs(int32_t *configs, int32_t config_size,
- int32_t *num_config) {
- if (has_interface<PPB_Graphics3D_Dev>()) {
- return PPBoolToBool(get_interface<PPB_Graphics3D_Dev>()->GetConfigs(
- configs, config_size, num_config));
- }
- return false;
-}
+int32_t Graphics3D_Dev::GetConfigs(int32_t *configs,
+ int32_t config_size,
+ int32_t *num_config) {
+ if (!has_interface<PPB_Graphics3D_Dev>())
+ return PP_ERROR_NOINTERFACE;
-// static
-bool Graphics3D_Dev::ChooseConfig(const int32_t *attrib_list, int32_t *configs,
- int32_t config_size, int32_t *num_config) {
- if (has_interface<PPB_Graphics3D_Dev>()) {
- return PPBoolToBool(get_interface<PPB_Graphics3D_Dev>()->ChooseConfig(
- attrib_list, configs, config_size, num_config));
- }
- return false;
+ return get_interface<PPB_Graphics3D_Dev>()->GetConfigs(
+ configs, config_size, num_config);
}
// static
-bool Graphics3D_Dev::GetConfigAttrib(int32_t config, int32_t attribute,
- int32_t *value) {
- if (has_interface<PPB_Graphics3D_Dev>()) {
- return PPBoolToBool(get_interface<PPB_Graphics3D_Dev>()->GetConfigAttrib(
- config, attribute, value));
- }
- return false;
-}
+int32_t Graphics3D_Dev::GetConfigAttribs(PP_Config3D_Dev config,
+ int32_t* attrib_list) {
+ if (!has_interface<PPB_Graphics3D_Dev>())
+ return PP_ERROR_NOINTERFACE;
-// static
-const char* Graphics3D_Dev::QueryString(int32_t name) {
- if (has_interface<PPB_Graphics3D_Dev>())
- return get_interface<PPB_Graphics3D_Dev>()->QueryString(name);
- return NULL;
+ return get_interface<PPB_Graphics3D_Dev>()->GetConfigAttribs(
+ config, attrib_list);
}
// static
-void* Graphics3D_Dev::GetProcAddress(const char* name) {
- if (has_interface<PPB_Graphics3D_Dev>())
- return get_interface<PPB_Graphics3D_Dev>()->GetProcAddress(name);
- return NULL;
-}
-
-Graphics3D_Dev Graphics3D_Dev::FromResource(PP_Resource resource_id) {
- if (has_interface<PPB_Graphics3D_Dev>() &&
- get_interface<PPB_Graphics3D_Dev>()->IsGraphics3D(resource_id))
- return Graphics3D_Dev(resource_id);
- return Graphics3D_Dev();
-}
-
-uint32_t Graphics3D_Dev::GetError() {
- if (has_interface<PPB_Graphics3D_Dev>())
- return get_interface<PPB_Graphics3D_Dev>()->GetError();
- return PP_GRAPHICS_3D_ERROR_NOT_INITIALIZED;
-}
-
-const PPB_OpenGLES2_Dev* Graphics3D_Dev::GetImplementation() {
- return get_interface<PPB_OpenGLES2_Dev>();
-}
-
-Graphics3D_Dev::Graphics3D_Dev(const Instance& instance,
- int32_t config,
- int32_t share_context,
- const int32_t* attrib_list) {
- if (has_interface<PPB_Graphics3D_Dev>() &&
- has_interface<PPB_OpenGLES2_Dev>()) {
- PassRefFromConstructor(get_interface<PPB_Graphics3D_Dev>()->CreateContext(
- instance.pp_instance(), config, share_context, attrib_list));
- }
-}
+Var Graphics3D_Dev::GetString(int32_t name) {
+ if (!has_interface<PPB_Graphics3D_Dev>())
+ return Var();
-bool Graphics3D_Dev::SwapBuffers() const {
- return has_interface<PPB_Graphics3D_Dev>() &&
- get_interface<PPB_Graphics3D_Dev>()->SwapBuffers(pp_resource());
+ return Var(Var::PassRef(),
+ get_interface<PPB_Graphics3D_Dev>()->GetString(name));
}
} // namespace pp
+
diff --git a/ppapi/cpp/dev/graphics_3d_dev.h b/ppapi/cpp/dev/graphics_3d_dev.h
index 43bd0b0..dece4c0 100644
--- a/ppapi/cpp/dev/graphics_3d_dev.h
+++ b/ppapi/cpp/dev/graphics_3d_dev.h
@@ -6,43 +6,21 @@
#define PPAPI_CPP_DEV_GRAPHICS_3D_DEV_H_
#include "ppapi/c/dev/ppb_graphics_3d_dev.h"
-#include "ppapi/c/dev/ppb_opengles_dev.h"
-#include "ppapi/cpp/instance.h"
-#include "ppapi/cpp/resource.h"
namespace pp {
-class Graphics3D_Dev : public Resource {
- public:
- static bool GetConfigs(int32_t* configs, int32_t config_size,
- int32_t* num_config);
-
- static bool ChooseConfig(const int32_t* attrib_list, int32_t* configs,
- int32_t config_size, int32_t* num_config);
-
- static bool GetConfigAttrib(int32_t config, int32_t attribute,
- int32_t* value);
-
- static const char* QueryString(int32_t name);
+class Var;
- static void* GetProcAddress(const char* name);
-
- static uint32_t GetError();
- static const PPB_OpenGLES2_Dev* GetImplementation();
-
- // Creates an is_null() Graphics3D object.
- Graphics3D_Dev() {}
-
- Graphics3D_Dev(const Instance& instance,
- int32_t config,
- int32_t share_context,
- const int32_t* attrib_list);
+class Graphics3D_Dev {
+ public:
+ static int32_t GetConfigs(PP_Config3D_Dev* configs,
+ int32_t config_size,
+ int32_t* num_config);
- bool SwapBuffers() const;
+ static int32_t GetConfigAttribs(PP_Config3D_Dev config,
+ int32_t* attrib_list);
- protected:
- explicit Graphics3D_Dev(PP_Resource resource_id) : Resource(resource_id) {}
- static Graphics3D_Dev FromResource(PP_Resource resource_id);
+ static Var GetString(int32_t name);
};
} // namespace pp
diff --git a/ppapi/cpp/instance.cc b/ppapi/cpp/instance.cc
index 379518d..369b277 100644
--- a/ppapi/cpp/instance.cc
+++ b/ppapi/cpp/instance.cc
@@ -7,7 +7,7 @@
#include "ppapi/c/dev/ppp_printing_dev.h"
#include "ppapi/c/ppb_instance.h"
#include "ppapi/cpp/common.h"
-#include "ppapi/cpp/dev/graphics_3d_dev.h"
+#include "ppapi/cpp/dev/context_3d_dev.h"
#include "ppapi/cpp/graphics_2d.h"
#include "ppapi/cpp/image_data.h"
#include "ppapi/cpp/logging.h"
@@ -91,7 +91,7 @@ bool Instance::BindGraphics(const Graphics2D& graphics) {
pp_instance(), graphics.pp_resource()));
}
-bool Instance::BindGraphics(const Graphics3D_Dev& graphics) {
+bool Instance::BindGraphics(const Context3D_Dev& graphics) {
if (!has_interface<PPB_Instance>())
return false;
return PPBoolToBool(get_interface<PPB_Instance>()->BindGraphics(
diff --git a/ppapi/cpp/instance.h b/ppapi/cpp/instance.h
index d74995e..161d6b0 100644
--- a/ppapi/cpp/instance.h
+++ b/ppapi/cpp/instance.h
@@ -26,7 +26,7 @@ struct PP_InputEvent;
namespace pp {
class Graphics2D;
-class Graphics3D_Dev;
+class Context3D_Dev;
class ImageData;
class Point;
class Rect;
@@ -89,7 +89,8 @@ class Instance {
bool BindGraphics(const Graphics2D& graphics);
/** See PPB_Instance.BindGraphics. */
- bool BindGraphics(const Graphics3D_Dev& graphics);
+ // TODO(alokp): Change it to Surface3D.
+ bool BindGraphics(const Context3D_Dev& graphics);
/** See PPB_Instance.IsFullFrame. */
bool IsFullFrame();
diff --git a/ppapi/ppapi.gyp b/ppapi/ppapi.gyp
index 16ca6ec..0bc5ea0 100644
--- a/ppapi/ppapi.gyp
+++ b/ppapi/ppapi.gyp
@@ -66,12 +66,14 @@
# Dev interfaces.
'c/dev/pp_cursor_type_dev.h',
'c/dev/pp_file_info_dev.h',
+ 'c/dev/pp_graphics_3d_dev.h',
'c/dev/pp_video_dev.h',
'c/dev/ppb_audio_config_dev.h',
'c/dev/ppb_audio_dev.h',
'c/dev/ppb_audio_trusted_dev.h',
'c/dev/ppb_buffer_dev.h',
'c/dev/ppb_char_set_dev.h',
+ 'c/dev/ppb_context_3d_dev.h',
'c/dev/ppb_cursor_control_dev.h',
'c/dev/ppb_directory_reader_dev.h',
'c/dev/ppb_file_chooser_dev.h',
@@ -164,6 +166,8 @@
'cpp/dev/audio_dev.h',
'cpp/dev/buffer_dev.cc',
'cpp/dev/buffer_dev.h',
+ 'cpp/dev/context_3d_dev.cc',
+ 'cpp/dev/context_3d_dev.h',
'cpp/dev/directory_entry_dev.cc',
'cpp/dev/directory_entry_dev.h',
'cpp/dev/directory_reader_dev.cc',
diff --git a/ppapi/tests/all_c_includes.h b/ppapi/tests/all_c_includes.h
index 5f337db..3661bfc 100644
--- a/ppapi/tests/all_c_includes.h
+++ b/ppapi/tests/all_c_includes.h
@@ -11,12 +11,14 @@
#include "ppapi/c/dev/deprecated_bool.h"
#include "ppapi/c/dev/pp_cursor_type_dev.h"
#include "ppapi/c/dev/pp_file_info_dev.h"
+#include "ppapi/c/dev/pp_graphics_3d_dev.h"
#include "ppapi/c/dev/pp_video_dev.h"
#include "ppapi/c/dev/ppb_audio_config_dev.h"
#include "ppapi/c/dev/ppb_audio_dev.h"
#include "ppapi/c/dev/ppb_audio_trusted_dev.h"
#include "ppapi/c/dev/ppb_buffer_dev.h"
#include "ppapi/c/dev/ppb_char_set_dev.h"
+#include "ppapi/c/dev/ppb_context_3d_dev.h"
#include "ppapi/c/dev/ppb_cursor_control_dev.h"
#include "ppapi/c/dev/ppb_directory_reader_dev.h"
#include "ppapi/c/dev/ppb_file_chooser_dev.h"