Chromium Code Reviews| Index: ppapi/lib/gl/gles2/gl2ext_ppapi.c |
| =================================================================== |
| --- ppapi/lib/gl/gles2/gl2ext_ppapi.c (revision 69442) |
| +++ ppapi/lib/gl/gles2/gl2ext_ppapi.c (working copy) |
| @@ -4,26 +4,50 @@ |
| #include "ppapi/lib/gl/gles2/gl2ext_ppapi.h" |
| -static const struct PPB_OpenGLES_Dev* g_gles2_interface; |
| +#ifndef GL_FALSE |
| +#define GL_FALSE 0 |
| +#endif // GL_FALSE |
| -int GL_APIENTRY glInitializePPAPI( |
| - PP_Module module, |
| +#ifndef GL_TRUE |
| +#define GL_TRUE 1 |
| +#endif // GL_TRUE |
| + |
| +// TODO(alokp): This will need to be thread-safe if we build gles2 as a |
| +// shared library. |
| +static const struct PPB_OpenGLES2_Dev* g_gles2_interface = NULL; |
| + |
| +#if __GNUC__ >= 4 |
| +#define PP_TLS __thread |
| +#elif defined(_MSC_VER) |
| +#define PP_TLS __declspec(thread) |
|
apatrick_chromium
2010/12/16 22:46:00
This probably isn't an issue for NaCl but perhaps
alokp
2010/12/20 17:24:40
I guess I will have to do the same then. There is
|
| +#else |
| +#error "Thread-local storage not supported" |
| +#endif |
| +// TODO(alokp): Make sure PP_TLS works on all supported platforms. |
| +static PP_TLS PP_Resource g_current_context = 0; |
| + |
| +GLboolean GL_APIENTRY glInitializePPAPI( |
| PPB_GetInterface get_browser_interface) { |
| - return 0; |
| + if (!g_gles2_interface) { |
| + g_gles2_interface = get_browser_interface(PPB_OPENGLES2_DEV_INTERFACE); |
| + } |
| + return g_gles2_interface ? GL_TRUE : GL_FALSE; |
| } |
| -int GL_APIENTRY glTerminatePPAPI() { |
| - return 0; |
| +GLboolean GL_APIENTRY glTerminatePPAPI() { |
| + g_gles2_interface = NULL; |
| + return GL_TRUE; |
| } |
| void GL_APIENTRY glSetCurrentContextPPAPI(PP_Resource context) { |
| + g_current_context = context; |
| } |
| PP_Resource GL_APIENTRY glGetCurrentContextPPAPI() { |
| - return 0; |
| + return g_current_context; |
| } |
| -const struct PPB_OpenGLES_Dev* GL_APIENTRY glGetInterfacePPAPI() { |
| +const struct PPB_OpenGLES2_Dev* GL_APIENTRY glGetInterfacePPAPI() { |
| return g_gles2_interface; |
| } |