The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | ** Copyright 2007, The Android Open Source Project |
| 3 | ** |
| 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 |
| 7 | ** |
| 8 | ** http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | ** |
| 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. |
| 15 | */ |
| 16 | |
| 17 | #ifndef ANDROID_GLES_CM_HOOKS_H |
| 18 | #define ANDROID_GLES_CM_HOOKS_H |
| 19 | |
| 20 | #include <ctype.h> |
| 21 | #include <string.h> |
| 22 | #include <errno.h> |
| 23 | |
Mathias Agopian | 9d17c05 | 2009-05-28 17:39:03 -0700 | [diff] [blame] | 24 | #include <pthread.h> |
| 25 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 26 | #include <EGL/egl.h> |
Mathias Agopian | e29254e | 2009-04-22 18:24:18 -0700 | [diff] [blame] | 27 | #include <EGL/eglext.h> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 28 | #include <GLES/gl.h> |
Mathias Agopian | e29254e | 2009-04-22 18:24:18 -0700 | [diff] [blame] | 29 | #include <GLES/glext.h> |
Mathias Agopian | 2820bd4 | 2009-05-27 20:38:06 -0700 | [diff] [blame] | 30 | #include <GLES2/gl2.h> |
| 31 | #include <GLES2/gl2ext.h> |
| 32 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 33 | #if !defined(__arm__) |
| 34 | #define USE_SLOW_BINDING 1 |
| 35 | #else |
| 36 | #define USE_SLOW_BINDING 0 |
| 37 | #endif |
| 38 | #undef NELEM |
| 39 | #define NELEM(x) (sizeof(x)/sizeof(*(x))) |
Mathias Agopian | 3944eab | 2010-08-02 17:34:32 -0700 | [diff] [blame] | 40 | #define MAX_NUMBER_OF_GL_EXTENSIONS 64 |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 41 | |
| 42 | |
Mathias Agopian | e29254e | 2009-04-22 18:24:18 -0700 | [diff] [blame] | 43 | #if defined(HAVE_ANDROID_OS) && !USE_SLOW_BINDING && __OPTIMIZE__ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 44 | #define USE_FAST_TLS_KEY 1 |
| 45 | #else |
| 46 | #define USE_FAST_TLS_KEY 0 |
| 47 | #endif |
| 48 | |
| 49 | #if USE_FAST_TLS_KEY |
| 50 | # include <bionic_tls.h> /* special private C library header */ |
| 51 | #endif |
| 52 | |
| 53 | // ---------------------------------------------------------------------------- |
| 54 | namespace android { |
| 55 | // ---------------------------------------------------------------------------- |
| 56 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 57 | // GL / EGL hooks |
| 58 | |
| 59 | #undef GL_ENTRY |
| 60 | #undef EGL_ENTRY |
| 61 | #define GL_ENTRY(_r, _api, ...) _r (*_api)(__VA_ARGS__); |
| 62 | #define EGL_ENTRY(_r, _api, ...) _r (*_api)(__VA_ARGS__); |
| 63 | |
Mathias Agopian | 6fc5699 | 2009-10-14 02:06:37 -0700 | [diff] [blame] | 64 | struct egl_t { |
| 65 | #include "EGL/egl_entries.in" |
| 66 | }; |
| 67 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 68 | struct gl_hooks_t { |
| 69 | struct gl_t { |
Mathias Agopian | 6fc5699 | 2009-10-14 02:06:37 -0700 | [diff] [blame] | 70 | #include "entries.in" |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 71 | } gl; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 72 | struct gl_ext_t { |
Mathias Agopian | 3944eab | 2010-08-02 17:34:32 -0700 | [diff] [blame] | 73 | __eglMustCastToProperFunctionPointerType extensions[MAX_NUMBER_OF_GL_EXTENSIONS]; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 74 | } ext; |
| 75 | }; |
| 76 | #undef GL_ENTRY |
| 77 | #undef EGL_ENTRY |
| 78 | |
Mathias Agopian | f56a960 | 2011-05-23 17:26:14 -0700 | [diff] [blame] | 79 | EGLAPI void setGlThreadSpecific(gl_hooks_t const *value); |
| 80 | EGLAPI gl_hooks_t const* getGlThreadSpecific(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 81 | |
| 82 | // ---------------------------------------------------------------------------- |
| 83 | }; // namespace android |
| 84 | // ---------------------------------------------------------------------------- |
| 85 | |
| 86 | #endif /* ANDROID_GLES_CM_HOOKS_H */ |