Roll leveldb 3f7758:803d69 (v1.17 -> v1.18)
[chromium-blink-merge.git] / gpu / command_buffer / client / gles2_lib.cc
blob6c8b0ead13c95bd1e8dd5a106cc9cdfea232d0ac
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.
5 #include "gpu/command_buffer/client/gles2_lib.h"
6 #include <string.h>
7 #include "gpu/command_buffer/common/thread_local.h"
9 namespace gles2 {
11 // This is defined in gles2_c_lib_autogen.h
12 extern "C" {
13 extern const NameToFunc g_gles2_function_table[];
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 {
19 static gpu::ThreadLocalKey g_gl_context_key;
20 // } // namespace anonymous
22 void Initialize() {
23 g_gl_context_key = gpu::ThreadLocalAlloc();
26 void Terminate() {
27 gpu::ThreadLocalFree(g_gl_context_key);
28 g_gl_context_key = 0;
31 gpu::gles2::GLES2Interface* GetGLContext() {
32 return static_cast<gpu::gles2::GLES2Interface*>(
33 gpu::ThreadLocalGetValue(g_gl_context_key));
36 void SetGLContext(gpu::gles2::GLES2Interface* context) {
37 gpu::ThreadLocalSetValue(g_gl_context_key, context);
40 GLES2FunctionPointer 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;
48 return NULL;
51 } // namespace gles2