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

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

Issue 5567004: Proposed changes to Pepper 3D API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/pp_bool.h" 8 #include "ppapi/c/pp_bool.h"
9 #include "ppapi/c/pp_instance.h"
10 #include "ppapi/c/pp_module.h" 9 #include "ppapi/c/pp_module.h"
11 #include "ppapi/c/pp_resource.h" 10 #include "ppapi/c/pp_resource.h"
12 #include "ppapi/c/pp_stdint.h" 11 #include "ppapi/c/pp_stdint.h"
13 12
14 // Example usage from plugin code: 13 // Example usage from plugin code:
15 // 14 //
16 // PP_Resource context = device->Create(module, config, contextAttribList); 15 // // Setup.
17 // CHECK(context); 16 // PP_Resource context, surface;
17 // int32_t config, num_config;
18 // g3d->GetConfigs(&config, 1, &num_config);
19 // int32_t attribs[] = {PP_GRAPHICS_3D_SURFACE_WIDTH, 800,
20 // PP_GRAPHICS_3D_SURFACE_HEIGHT, 800,
21 // PP_GRAPHICS_3D_ATTRIB_NONE};
22 // c3d->Create(module, config, NULL, NULL, &context);
23 // s3d->Create(module, config, attribs, &surface);
18 // 24 //
19 // // Present one frame. 25 // // Present one frame.
20 // CHECK(device->MakeCurrent(context)); 26 // c3d->BindSurfaces(context, surface, surface);
21 // glClear(GL_COLOR_BUFFER); 27 // gles2->Clear(context, GL_COLOR_BUFFER);
22 // CHECK(device->MakeCurrent(NULL)); 28 // c3d->SwapBuffers(context);
23 // CHECK(device->SwapBuffers(context));
24 // 29 //
25 // // Shutdown. 30 // // Shutdown.
26 // core->ReleaseResource(context); 31 // core->ReleaseResource(context);
32 // core->ReleaseResource(surface);
27 33
28 #define PPB_GRAPHICS_3D_DEV_INTERFACE "PPB_Graphics3D(Dev);0.2" 34 #define PPB_GRAPHICS_3D_DEV_INTERFACE "PPB_Graphics3D(Dev);0.2"
29 35
30 // These are the same error codes as used by EGL.
31 enum {
32 PP_GRAPHICS_3D_ERROR_SUCCESS = 0x3000,
33 PP_GRAPHICS_3D_ERROR_NOT_INITIALIZED = 0x3001,
34 PP_GRAOHICS_3D_ERROR_BAD_CONTEXT = 0x3006,
35 PP_GRAPHICS_3D_ERROR_BAD_PARAMETER = 0x300C,
36 PP_GRAPHICS_3D_ERROR_CONTEXT_LOST = 0x300E
37 };
38
39 // QueryString targets, matching EGL ones.
40 enum {
41 EGL_VENDOR = 0x3053,
42 EGL_VERSION = 0x3054,
43 EGL_EXTENSIONS = 0x3055,
44 EGL_CLIENT_APIS = 0x308D
45 };
46
47 struct PPB_Graphics3D_Dev { 36 struct PPB_Graphics3D_Dev {
48 PP_Bool (*IsGraphics3D)(PP_Resource resource); 37 PP_Bool (*IsGraphics3D)(PP_Resource resource);
49 38
50 // EGL-like configuration ---------------------------------------------------- 39 // TODO(alokp): Do these functions need module argument.
51 PP_Bool (*GetConfigs)(int32_t* configs, 40 int32_t (*GetConfigs)(int32_t* configs,
brettw 2010/12/07 05:51:06 Please provide documentation for all of these func
52 int32_t config_size, 41 int32_t config_size,
53 int32_t* num_config); 42 int32_t* num_config);
54 43
55 PP_Bool (*ChooseConfig)(const int32_t* attrib_list, 44 // attrib_list is a list of name-value pairs.
56 int32_t* configs, 45 int32_t (*GetConfigAttribs)(int32_t config,
57 int32_t config_size, 46 int32_t* attrib_list);
58 int32_t* num_config);
59 47
60 // TODO(apatrick): What to do if the browser window is moved to 48 struct PP_Var (*GetString)(int32_t name);
61 // another display? Do the configs potentially change?
62 PP_Bool (*GetConfigAttrib)(int32_t config, int32_t attribute, int32_t* value);
63
64 const char* (*QueryString)(int32_t name);
65 // ---------------------------------------------------------------------------
66
67
68 // Create a reference counted 3D context. Releasing a context while it is
69 // current automatically sets the current context to NULL. This is only true
70 // for the releasing thread. Releasing a context while it is current on
71 // another thread leads to undefined behavior.
72 PP_Resource (*CreateContext)(PP_Instance instance,
73 int32_t config,
74 int32_t share_context,
75 const int32_t* attrib_list);
76
77 // Get the address of any GL functions, whether core or part of an extension.
78 // Any thread.
79 void* (*GetProcAddress)(const char* name);
80
81 // Make a particular context current of the calling thread. Returns PP_TRUE
82 // on success, PP_FALSE on failure.
83 PP_Bool (*MakeCurent)(PP_Resource context);
84
85 // Returns the calling thread's current context or NULL if no context is
86 // current.
87 PP_Resource (*GetCurrentContext)();
88
89 // Snapshots the rendered frame and makes it available for composition with
90 // the rest of the page. The alpha channel is used for translucency effects.
91 // One means fully opaque. Zero means fully transparent. Any thread.
92 // TODO(apatrick): premultiplied alpha or linear alpha? Premultiplied alpha is
93 // better for correct alpha blending effect. Most existing OpenGL code assumes
94 // linear. I could convert from linear to premultiplied during the copy from
95 // back-buffer to offscreen "front-buffer".
96 PP_Bool (*SwapBuffers)(PP_Resource context);
97
98 // Returns the current error for this thread. This is not associated with a
99 // particular context. It is distinct from the GL error returned by
100 // glGetError.
101 uint32_t (*GetError)();
102 }; 49 };
103 50
104 #endif // PPAPI_C_DEV_PPB_GRAPHICS_3D_DEV_H_ 51 #endif // PPAPI_C_DEV_PPB_GRAPHICS_3D_DEV_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698