diff options
-rw-r--r-- | gpu/command_buffer/client/gles2_lib.cc | 7 | ||||
-rw-r--r-- | gpu/command_buffer/client/gles2_lib.h | 16 | ||||
-rw-r--r-- | gpu/pgl/pgl.cc | 16 | ||||
-rw-r--r-- | gpu/pgl/pgl.h | 18 |
4 files changed, 36 insertions, 21 deletions
diff --git a/gpu/command_buffer/client/gles2_lib.cc b/gpu/command_buffer/client/gles2_lib.cc index 87f74c4..cd7cfed 100644 --- a/gpu/command_buffer/client/gles2_lib.cc +++ b/gpu/command_buffer/client/gles2_lib.cc @@ -6,12 +6,7 @@ namespace gles2 { -::gpu::gles2::GLES2Implementation* g_gl_impl; - -bool InitGLES2Lib() { - // TODO(gman): Encapulate initalizing the GLES2 library for client apps. - return false; -} +THREAD_LOCAL ::gpu::gles2::GLES2Implementation* g_gl_impl; } // namespace gles2 diff --git a/gpu/command_buffer/client/gles2_lib.h b/gpu/command_buffer/client/gles2_lib.h index b7fd864..e2825fa 100644 --- a/gpu/command_buffer/client/gles2_lib.h +++ b/gpu/command_buffer/client/gles2_lib.h @@ -9,18 +9,24 @@ #include "gpu/command_buffer/client/gles2_implementation.h" +#if defined(_MSC_VER) +#define THREAD_LOCAL __declspec(thread) +#else +#define THREAD_LOCAL __thread +#endif + namespace gles2 { -extern ::gpu::gles2::GLES2Implementation* g_gl_impl; +extern THREAD_LOCAL gpu::gles2::GLES2Implementation* g_gl_impl; -inline ::gpu::gles2::GLES2Implementation* GetGLContext() { +inline gpu::gles2::GLES2Implementation* GetGLContext() { return g_gl_impl; } -// Initializes the GLES2 library. -bool InitGLES2Lib(); +inline void SetGLContext(gpu::gles2::GLES2Implementation* impl) { + g_gl_impl = impl; +} } // namespace gles2 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_LIB_H_ - diff --git a/gpu/pgl/pgl.cc b/gpu/pgl/pgl.cc index c403265..2fd3d8b 100644 --- a/gpu/pgl/pgl.cc +++ b/gpu/pgl/pgl.cc @@ -8,12 +8,6 @@ #include "gpu/pgl/command_buffer_pepper.h" #include "gpu/pgl/pgl.h" -#if defined(_MSC_VER) -#define THREAD_LOCAL __declspec(thread) -#else -#define THREAD_LOCAL __thread -#endif - namespace { const int32 kTransferBufferSize = 512 * 1024; @@ -111,9 +105,9 @@ void PGLContextImpl::Destroy() { bool PGLContextImpl::MakeCurrent(PGLContextImpl* pgl_context) { g_current_pgl_context = pgl_context; if (pgl_context) - gles2::g_gl_impl = pgl_context->gles2_implementation_; + gles2::SetGLContext(pgl_context->gles2_implementation_); else - gles2::g_gl_impl = NULL; + gles2::SetGLContext(NULL); return true; } @@ -143,7 +137,11 @@ PGLBoolean pglMakeCurrent(PGLContext pgl_context) { return PGLContextImpl::MakeCurrent(static_cast<PGLContextImpl*>(pgl_context)); } -PGLBoolean pglSwapBuffers() { +PGLContext pglGetCurrentContext(void) { + return g_current_pgl_context; +} + +PGLBoolean pglSwapBuffers(void) { if (!g_current_pgl_context) return false; diff --git a/gpu/pgl/pgl.h b/gpu/pgl/pgl.h index 6914aae..f848968 100644 --- a/gpu/pgl/pgl.h +++ b/gpu/pgl/pgl.h @@ -8,16 +8,32 @@ #include "npapi.h" #include "npapi_extensions.h" +#ifdef __cplusplus extern "C" { +#endif + typedef void* PGLContext; typedef bool PGLBoolean; +// Create A PGL context from a Pepper 3D device context. PGLContext pglCreateContext(NPP npp, NPDevice* device, NPDeviceContext3D* device_context); + +// Set the current PGL context for the calling thread. PGLBoolean pglMakeCurrent(PGLContext pgl_context); -PGLBoolean pglSwapBuffers(); + +// Get the calling thread's current PGL context. +PGLContext pglGetCurrentContext(void); + +// Display everything that has been rendered since the last call. +PGLBoolean pglSwapBuffers(void); + +// Destroy the given PGL context. PGLBoolean pglDestroyContext(PGLContext pgl_context); + +#ifdef __cplusplus } // extern "C" +#endif #endif // GPU_PGL_PGL_H |