From 98c41b12a3dd200ba88db7c3c8ab8740da4ead90 Mon Sep 17 00:00:00 2001 From: "apatrick@chromium.org" Date: Tue, 19 Jan 2010 22:15:39 +0000 Subject: Added pglGetCurrentContext. Make gles2 implementation pointer global variable thread local. TEST=none BUG=none Review URL: http://codereview.chromium.org/549090 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36560 0039d316-1c4b-4281-b951-d872f2087c98 --- gpu/pgl/pgl.cc | 16 +++++++--------- gpu/pgl/pgl.h | 18 +++++++++++++++++- 2 files changed, 24 insertions(+), 10 deletions(-) (limited to 'gpu/pgl') 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(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 -- cgit v1.1