2 ** Copyright 2007, The Android Open Source Project
4 ** Licensed under the Apache License, Version 2.0 (the "License");
5 ** you may not use this file except in compliance with the License.
6 ** You may obtain a copy of the License at
8 ** http://www.apache.org/licenses/LICENSE-2.0
10 ** Unless required by applicable law or agreed to in writing, software
11 ** distributed under the License is distributed on an "AS IS" BASIS,
12 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 ** See the License for the specific language governing permissions and
14 ** limitations under the License.
21 #include <sys/ioctl.h>
23 #include <GLES2/gl2.h>
24 #include <GLES2/gl2ext.h>
26 #include <cutils/log.h>
27 #include <cutils/properties.h>
32 using namespace android;
34 // ----------------------------------------------------------------------------
35 // Actual GL entry-points
36 // ----------------------------------------------------------------------------
40 #undef CALL_GL_API_RETURN
44 #ifdef HAVE_ARM_TLS_REGISTER
45 #define GET_TLS(reg) \
46 "mrc p15, 0, " #reg ", c13, c0, 3 \n"
48 #define GET_TLS(reg) \
49 "mov " #reg ", #0xFFFF0FFF \n" \
50 "ldr " #reg ", [" #reg ", #-15] \n"
53 #define API_ENTRY(_api) __attribute__((naked)) _api
55 #define CALL_GL_API(_api, ...) \
58 "ldr r12, [r12, %[tls]] \n" \
60 "ldrne pc, [r12, %[api]] \n" \
64 : [tls] "J"(TLS_SLOT_OPENGL_API*4), \
65 [api] "J"(__builtin_offsetof(gl_hooks_t, gl._api)) \
69 #define CALL_GL_API_RETURN(_api, ...) \
70 CALL_GL_API(_api, __VA_ARGS__) \
71 return 0; // placate gcc's warnings. never reached.
75 #define API_ENTRY(_api) _api
77 #define CALL_GL_API(_api, ...) \
78 gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl; \
79 _c->_api(__VA_ARGS__);
81 #define CALL_GL_API_RETURN(_api, ...) \
82 gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl; \
83 return _c->_api(__VA_ARGS__)
90 #include "gl2ext_api.in"
95 #undef CALL_GL_API_RETURN
98 * glGetString() is special because we expose some extensions in the wrapper
101 extern "C" const GLubyte * __glGetString(GLenum name);
103 const GLubyte * glGetString(GLenum name)
105 const GLubyte * ret = egl_get_string_for_current_context(name);
107 ret = __glGetString(name);