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