1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL Utilities
3 * ---------------------------------------------
5 * Copyright 2014 The Android Open Source Project
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 * \brief OpenGL wrapper implementation.
22 *//*--------------------------------------------------------------------*/
24 #include "glwWrapper.hpp"
25 #include "glwFunctions.hpp"
26 #include "deThreadLocal.h"
32 #include "glwTypes.inl"
33 #include "glwEnums.inl"
40 #if defined(DE_THREAD_LOCAL)
42 // Thread-local current function table.
43 DE_THREAD_LOCAL const glw::Functions* s_functions = DE_NULL;
45 void setCurrentThreadFunctions (const glw::Functions* gl)
50 inline const glw::Functions* getCurrentThreadFunctions (void)
55 #else // defined(DE_THREAD_LOCAL)
64 : m_ptr(deThreadLocal_create())
67 throw std::runtime_error("glw: TLS allocation failed");
70 inline void set (const glw::Functions* gl)
72 deThreadLocal_set(m_ptr, (void*)gl);
75 inline const glw::Functions* get (void) const
77 return (const glw::Functions*)deThreadLocal_get(m_ptr);
86 // Initialized in startup.
87 static FunctionTLSPtr s_functions;
89 void setCurrentThreadFunctions (const glw::Functions* gl)
94 inline const glw::Functions* getCurrentThreadFunctions (void)
96 return s_functions.get();
99 #endif // defined(DE_THREAD_LOCAL)
105 #include "glwImpl.inl"