1// Copyright (c) 2009 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#include "gpu/command_buffer/client/gles2_lib.h" 6#include <string.h> 7#include "gpu/command_buffer/common/thread_local.h" 8 9namespace gles2 { 10 11// This is defined in gles2_c_lib_autogen.h 12extern "C" { 13extern const NameToFunc g_gles2_function_table[]; 14} 15 16// TODO(kbr): the use of this anonymous namespace core dumps the 17// linker on Mac OS X 10.6 when the symbol ordering file is used 18// namespace { 19static gpu::ThreadLocalKey g_gl_context_key; 20// } // namespace anonymous 21 22void Initialize() { 23 g_gl_context_key = gpu::ThreadLocalAlloc(); 24} 25 26void Terminate() { 27 gpu::ThreadLocalFree(g_gl_context_key); 28 g_gl_context_key = 0; 29} 30 31gpu::gles2::GLES2Interface* GetGLContext() { 32 return static_cast<gpu::gles2::GLES2Interface*>( 33 gpu::ThreadLocalGetValue(g_gl_context_key)); 34} 35 36void SetGLContext(gpu::gles2::GLES2Interface* context) { 37 gpu::ThreadLocalSetValue(g_gl_context_key, context); 38} 39 40GLES2FunctionPointer GetGLFunctionPointer(const char* name) { 41 for (const NameToFunc* named_function = g_gles2_function_table; 42 named_function->name; 43 ++named_function) { 44 if (!strcmp(name, named_function->name)) { 45 return named_function->func; 46 } 47 } 48 return NULL; 49} 50 51} // namespace gles2 52 53 54 55 56