| Jesse Hall | 4774338 | 2013-02-08 11:13:46 -0800 | [diff] [blame] | 1 | /* | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2 | ** Copyright 2007, The Android Open Source Project | 
|  | 3 | ** | 
| Jesse Hall | 4774338 | 2013-02-08 11:13:46 -0800 | [diff] [blame] | 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 | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 7 | ** | 
| Jesse Hall | 4774338 | 2013-02-08 11:13:46 -0800 | [diff] [blame] | 8 | **     http://www.apache.org/licenses/LICENSE-2.0 | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 9 | ** | 
| Jesse Hall | 4774338 | 2013-02-08 11:13:46 -0800 | [diff] [blame] | 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 | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 14 | ** limitations under the License. | 
|  | 15 | */ | 
|  | 16 |  | 
| Mathias Agopian | d8fb7b5 | 2009-05-17 18:50:16 -0700 | [diff] [blame] | 17 | #include <stdlib.h> | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 18 |  | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 19 | #include <EGL/egl.h> | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 20 |  | 
| Michael Hoisie | 4e0f56b | 2020-04-30 18:40:55 -0400 | [diff] [blame] | 21 | #include <android-base/properties.h> | 
| Mathias Agopian | 311b479 | 2017-02-28 15:00:49 -0800 | [diff] [blame] | 22 |  | 
| Mark Salyzyn | 7823e12 | 2016-09-29 08:08:05 -0700 | [diff] [blame] | 23 | #include <log/log.h> | 
| Mathias Agopian | 311b479 | 2017-02-28 15:00:49 -0800 | [diff] [blame] | 24 |  | 
| Mathias Agopian | 39c24a2 | 2013-04-04 23:17:56 -0700 | [diff] [blame] | 25 | #include "../egl_impl.h" | 
| Mathias Agopian | 39c24a2 | 2013-04-04 23:17:56 -0700 | [diff] [blame] | 26 |  | 
| Mathias Agopian | 39c24a2 | 2013-04-04 23:17:56 -0700 | [diff] [blame] | 27 | #include "egldefs.h" | 
| Mathias Agopian | 311b479 | 2017-02-28 15:00:49 -0800 | [diff] [blame] | 28 | #include "egl_tls.h" | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 29 | #include "egl_display.h" | 
|  | 30 | #include "egl_object.h" | 
| Cody Northrop | 629ce4e | 2018-10-15 07:22:09 -0600 | [diff] [blame] | 31 | #include "egl_layers.h" | 
| Mathias Agopian | 5f1af04 | 2017-03-09 18:50:05 -0800 | [diff] [blame] | 32 | #include "CallStack.h" | 
| Mathias Agopian | 311b479 | 2017-02-28 15:00:49 -0800 | [diff] [blame] | 33 | #include "Loader.h" | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 34 |  | 
|  | 35 | // ---------------------------------------------------------------------------- | 
|  | 36 | namespace android { | 
|  | 37 | // ---------------------------------------------------------------------------- | 
|  | 38 |  | 
| Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 39 | egl_connection_t gEGLImpl; | 
|  | 40 | gl_hooks_t gHooks[2]; | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 41 | gl_hooks_t gHooksNoContext; | 
|  | 42 | pthread_key_t gGLWrapperKey = -1; | 
| Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 43 |  | 
|  | 44 | // ---------------------------------------------------------------------------- | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 45 |  | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 46 | void setGLHooksThreadSpecific(gl_hooks_t const *value) { | 
| Jack Palevich | a2dd6cf | 2010-10-26 15:21:24 -0700 | [diff] [blame] | 47 | setGlThreadSpecific(value); | 
|  | 48 | } | 
|  | 49 |  | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 50 | /*****************************************************************************/ | 
|  | 51 |  | 
| Mathias Agopian | 6f08712 | 2010-09-23 16:38:38 -0700 | [diff] [blame] | 52 | static int gl_no_context() { | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 53 | if (egl_tls_t::logNoContextCall()) { | 
| Mathias Agopian | 455e360 | 2012-09-26 17:19:48 -0700 | [diff] [blame] | 54 | char const* const error = "call to OpenGL ES API with " | 
|  | 55 | "no current context (logged once per thread)"; | 
|  | 56 | if (LOG_NDEBUG) { | 
|  | 57 | ALOGE(error); | 
|  | 58 | } else { | 
|  | 59 | LOG_ALWAYS_FATAL(error); | 
|  | 60 | } | 
| Michael Hoisie | 4e0f56b | 2020-04-30 18:40:55 -0400 | [diff] [blame] | 61 | if (base::GetBoolProperty("debug.egl.callstack", false)) { | 
| Mathias Agopian | 5f1af04 | 2017-03-09 18:50:05 -0800 | [diff] [blame] | 62 | CallStack::log(LOG_TAG); | 
| Mathias Agopian | ecfe091 | 2011-09-06 17:24:05 -0700 | [diff] [blame] | 63 | } | 
| Mathias Agopian | d274eae | 2009-07-31 16:21:17 -0700 | [diff] [blame] | 64 | } | 
| Mathias Agopian | 6f08712 | 2010-09-23 16:38:38 -0700 | [diff] [blame] | 65 | return 0; | 
| Mathias Agopian | 05c5311 | 2010-09-23 11:32:52 -0700 | [diff] [blame] | 66 | } | 
|  | 67 |  | 
| Jesse Hall | 4774338 | 2013-02-08 11:13:46 -0800 | [diff] [blame] | 68 | static void early_egl_init(void) | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 69 | { | 
| Dan Stoza | c3289c4 | 2014-01-17 11:38:34 -0800 | [diff] [blame] | 70 | int numHooks = sizeof(gHooksNoContext) / sizeof(EGLFuncPointer); | 
|  | 71 | EGLFuncPointer *iter = reinterpret_cast<EGLFuncPointer*>(&gHooksNoContext); | 
|  | 72 | for (int hook = 0; hook < numHooks; ++hook) { | 
|  | 73 | *(iter++) = reinterpret_cast<EGLFuncPointer>(gl_no_context); | 
|  | 74 | } | 
| Mathias Agopian | 05c5311 | 2010-09-23 11:32:52 -0700 | [diff] [blame] | 75 |  | 
| Jack Palevich | a2dd6cf | 2010-10-26 15:21:24 -0700 | [diff] [blame] | 76 | setGLHooksThreadSpecific(&gHooksNoContext); | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 77 | } | 
|  | 78 |  | 
|  | 79 | static pthread_once_t once_control = PTHREAD_ONCE_INIT; | 
|  | 80 | static int sEarlyInitState = pthread_once(&once_control, &early_egl_init); | 
|  | 81 |  | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 82 | // ---------------------------------------------------------------------------- | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 83 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 84 | egl_display_ptr validate_display(EGLDisplay dpy) { | 
|  | 85 | egl_display_ptr dp = get_display(dpy); | 
| Mathias Agopian | 5b287a6 | 2011-05-16 18:58:55 -0700 | [diff] [blame] | 86 | if (!dp) | 
| Yi Kong | 48a6cd2 | 2018-07-18 10:07:09 -0700 | [diff] [blame] | 87 | return setError(EGL_BAD_DISPLAY, egl_display_ptr(nullptr)); | 
| Mathias Agopian | 5b287a6 | 2011-05-16 18:58:55 -0700 | [diff] [blame] | 88 | if (!dp->isReady()) | 
| Yi Kong | 48a6cd2 | 2018-07-18 10:07:09 -0700 | [diff] [blame] | 89 | return setError(EGL_NOT_INITIALIZED, egl_display_ptr(nullptr)); | 
| Eric Hassold | 3ede7c1 | 2011-03-23 15:59:00 -0700 | [diff] [blame] | 90 |  | 
|  | 91 | return dp; | 
|  | 92 | } | 
|  | 93 |  | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 94 | egl_display_ptr validate_display_connection(EGLDisplay dpy, | 
|  | 95 | egl_connection_t*& cnx) { | 
| Yi Kong | 48a6cd2 | 2018-07-18 10:07:09 -0700 | [diff] [blame] | 96 | cnx = nullptr; | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 97 | egl_display_ptr dp = validate_display(dpy); | 
| Mathias Agopian | 5b287a6 | 2011-05-16 18:58:55 -0700 | [diff] [blame] | 98 | if (!dp) | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 99 | return dp; | 
|  | 100 | cnx = &gEGLImpl; | 
| Yi Kong | 48a6cd2 | 2018-07-18 10:07:09 -0700 | [diff] [blame] | 101 | if (cnx->dso == nullptr) { | 
|  | 102 | return setError(EGL_BAD_CONFIG, egl_display_ptr(nullptr)); | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 103 | } | 
| Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 104 | return dp; | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 105 | } | 
|  | 106 |  | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 107 | // ---------------------------------------------------------------------------- | 
|  | 108 |  | 
| Mathias Agopian | 48d438d | 2012-01-28 21:44:00 -0800 | [diff] [blame] | 109 | const GLubyte * egl_get_string_for_current_context(GLenum name) { | 
|  | 110 | // NOTE: returning NULL here will fall-back to the default | 
|  | 111 | // implementation. | 
|  | 112 |  | 
|  | 113 | EGLContext context = egl_tls_t::getContext(); | 
|  | 114 | if (context == EGL_NO_CONTEXT) | 
| Yi Kong | 48a6cd2 | 2018-07-18 10:07:09 -0700 | [diff] [blame] | 115 | return nullptr; | 
| Mathias Agopian | 48d438d | 2012-01-28 21:44:00 -0800 | [diff] [blame] | 116 |  | 
|  | 117 | egl_context_t const * const c = get_context(context); | 
| Yi Kong | 48a6cd2 | 2018-07-18 10:07:09 -0700 | [diff] [blame] | 118 | if (c == nullptr) // this should never happen, by construction | 
|  | 119 | return nullptr; | 
| Mathias Agopian | 48d438d | 2012-01-28 21:44:00 -0800 | [diff] [blame] | 120 |  | 
|  | 121 | if (name != GL_EXTENSIONS) | 
| Yi Kong | 48a6cd2 | 2018-07-18 10:07:09 -0700 | [diff] [blame] | 122 | return nullptr; | 
| Mathias Agopian | 48d438d | 2012-01-28 21:44:00 -0800 | [diff] [blame] | 123 |  | 
| Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 124 | return (const GLubyte *)c->gl_extensions.c_str(); | 
| Mathias Agopian | 48d438d | 2012-01-28 21:44:00 -0800 | [diff] [blame] | 125 | } | 
|  | 126 |  | 
| Alistair Strachan | edfe72e | 2015-05-22 14:10:09 -0700 | [diff] [blame] | 127 | const GLubyte * egl_get_string_for_current_context(GLenum name, GLuint index) { | 
|  | 128 | // NOTE: returning NULL here will fall-back to the default | 
|  | 129 | // implementation. | 
|  | 130 |  | 
|  | 131 | EGLContext context = egl_tls_t::getContext(); | 
|  | 132 | if (context == EGL_NO_CONTEXT) | 
| Yi Kong | 48a6cd2 | 2018-07-18 10:07:09 -0700 | [diff] [blame] | 133 | return nullptr; | 
| Alistair Strachan | edfe72e | 2015-05-22 14:10:09 -0700 | [diff] [blame] | 134 |  | 
|  | 135 | egl_context_t const * const c = get_context(context); | 
| Yi Kong | 48a6cd2 | 2018-07-18 10:07:09 -0700 | [diff] [blame] | 136 | if (c == nullptr) // this should never happen, by construction | 
|  | 137 | return nullptr; | 
| Alistair Strachan | edfe72e | 2015-05-22 14:10:09 -0700 | [diff] [blame] | 138 |  | 
|  | 139 | if (name != GL_EXTENSIONS) | 
| Yi Kong | 48a6cd2 | 2018-07-18 10:07:09 -0700 | [diff] [blame] | 140 | return nullptr; | 
| Alistair Strachan | edfe72e | 2015-05-22 14:10:09 -0700 | [diff] [blame] | 141 |  | 
|  | 142 | // if index is out of bounds, assume it will be in the default | 
|  | 143 | // implementation too, so we don't have to generate a GL error here | 
|  | 144 | if (index >= c->tokenized_gl_extensions.size()) | 
| Yi Kong | 48a6cd2 | 2018-07-18 10:07:09 -0700 | [diff] [blame] | 145 | return nullptr; | 
| Alistair Strachan | edfe72e | 2015-05-22 14:10:09 -0700 | [diff] [blame] | 146 |  | 
| Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 147 | return (const GLubyte *)c->tokenized_gl_extensions[index].c_str(); | 
| Alistair Strachan | edfe72e | 2015-05-22 14:10:09 -0700 | [diff] [blame] | 148 | } | 
|  | 149 |  | 
|  | 150 | GLint egl_get_num_extensions_for_current_context() { | 
|  | 151 | // NOTE: returning -1 here will fall-back to the default | 
|  | 152 | // implementation. | 
|  | 153 |  | 
|  | 154 | EGLContext context = egl_tls_t::getContext(); | 
|  | 155 | if (context == EGL_NO_CONTEXT) | 
|  | 156 | return -1; | 
|  | 157 |  | 
|  | 158 | egl_context_t const * const c = get_context(context); | 
| Yi Kong | 48a6cd2 | 2018-07-18 10:07:09 -0700 | [diff] [blame] | 159 | if (c == nullptr) // this should never happen, by construction | 
| Alistair Strachan | edfe72e | 2015-05-22 14:10:09 -0700 | [diff] [blame] | 160 | return -1; | 
|  | 161 |  | 
|  | 162 | return (GLint)c->tokenized_gl_extensions.size(); | 
|  | 163 | } | 
|  | 164 |  | 
| Cody Northrop | 68d1035 | 2018-10-15 07:22:09 -0600 | [diff] [blame] | 165 | egl_connection_t* egl_get_connection() { | 
|  | 166 | return &gEGLImpl; | 
|  | 167 | } | 
|  | 168 |  | 
| Mathias Agopian | 48d438d | 2012-01-28 21:44:00 -0800 | [diff] [blame] | 169 | // ---------------------------------------------------------------------------- | 
|  | 170 |  | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 171 | static EGLBoolean egl_init_drivers_locked() { | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 172 | if (sEarlyInitState) { | 
| Mathias Agopian | 923c661 | 2009-08-17 18:07:06 -0700 | [diff] [blame] | 173 | // initialized by static ctor. should be set here. | 
|  | 174 | return EGL_FALSE; | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 175 | } | 
|  | 176 |  | 
| Mathias Agopian | de58697 | 2009-05-28 17:39:03 -0700 | [diff] [blame] | 177 | // get our driver loader | 
| Mathias Agopian | 923c661 | 2009-08-17 18:07:06 -0700 | [diff] [blame] | 178 | Loader& loader(Loader::getInstance()); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 179 |  | 
| Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 180 | // dynamically load our EGL implementation | 
|  | 181 | egl_connection_t* cnx = &gEGLImpl; | 
| Yiwei Zhang | 5e21eb3 | 2019-06-05 00:26:03 -0700 | [diff] [blame] | 182 | cnx->hooks[egl_connection_t::GLESv1_INDEX] = &gHooks[egl_connection_t::GLESv1_INDEX]; | 
|  | 183 | cnx->hooks[egl_connection_t::GLESv2_INDEX] = &gHooks[egl_connection_t::GLESv2_INDEX]; | 
|  | 184 | cnx->dso = loader.open(cnx); | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 185 |  | 
| Cody Northrop | 629ce4e | 2018-10-15 07:22:09 -0600 | [diff] [blame] | 186 | // Check to see if any layers are enabled and route functions through them | 
|  | 187 | if (cnx->dso) { | 
|  | 188 | // Layers can be enabled long after the drivers have been loaded. | 
|  | 189 | // They will only be initialized once. | 
|  | 190 | LayerLoader& layer_loader(LayerLoader::getInstance()); | 
|  | 191 | layer_loader.InitLayers(cnx); | 
|  | 192 | } | 
|  | 193 |  | 
| Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 194 | return cnx->dso ? EGL_TRUE : EGL_FALSE; | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 195 | } | 
|  | 196 |  | 
| Charlie Lao | 95c7aea | 2020-01-10 11:12:03 -0800 | [diff] [blame] | 197 |  | 
| Charlie Lao | c51d5f5 | 2020-01-14 11:05:53 -0800 | [diff] [blame] | 198 | // this mutex protects driver load logic as a critical section since it accesses to global variable | 
|  | 199 | // like gEGLImpl | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 200 | static pthread_mutex_t sInitDriverMutex = PTHREAD_MUTEX_INITIALIZER; | 
|  | 201 |  | 
|  | 202 | EGLBoolean egl_init_drivers() { | 
| Mathias Agopian | 923c661 | 2009-08-17 18:07:06 -0700 | [diff] [blame] | 203 | EGLBoolean res; | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 204 | pthread_mutex_lock(&sInitDriverMutex); | 
| Mathias Agopian | 923c661 | 2009-08-17 18:07:06 -0700 | [diff] [blame] | 205 | res = egl_init_drivers_locked(); | 
| Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 206 | pthread_mutex_unlock(&sInitDriverMutex); | 
| Mathias Agopian | 923c661 | 2009-08-17 18:07:06 -0700 | [diff] [blame] | 207 | return res; | 
|  | 208 | } | 
| Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 209 |  | 
| Michael Lentine | 12c4bda | 2014-09-11 12:24:13 -0700 | [diff] [blame] | 210 | static pthread_mutex_t sLogPrintMutex = PTHREAD_MUTEX_INITIALIZER; | 
| Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 211 | static std::chrono::steady_clock::time_point sLogPrintTime; | 
|  | 212 | static constexpr std::chrono::seconds DURATION(1); | 
| Michael Lentine | 12c4bda | 2014-09-11 12:24:13 -0700 | [diff] [blame] | 213 |  | 
| Mathias Agopian | 1cadb25 | 2011-05-23 17:26:14 -0700 | [diff] [blame] | 214 | void gl_unimplemented() { | 
| Michael Lentine | 12c4bda | 2014-09-11 12:24:13 -0700 | [diff] [blame] | 215 | bool printLog = false; | 
| Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 216 | auto now = std::chrono::steady_clock::now(); | 
| Michael Lentine | 12c4bda | 2014-09-11 12:24:13 -0700 | [diff] [blame] | 217 | pthread_mutex_lock(&sLogPrintMutex); | 
| Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 218 | if ((now - sLogPrintTime) > DURATION) { | 
| Michael Lentine | 12c4bda | 2014-09-11 12:24:13 -0700 | [diff] [blame] | 219 | sLogPrintTime = now; | 
|  | 220 | printLog = true; | 
|  | 221 | } | 
|  | 222 | pthread_mutex_unlock(&sLogPrintMutex); | 
|  | 223 | if (printLog) { | 
|  | 224 | ALOGE("called unimplemented OpenGL ES API"); | 
| Michael Hoisie | 4e0f56b | 2020-04-30 18:40:55 -0400 | [diff] [blame] | 225 | if (base::GetBoolProperty("debug.egl.callstack", false)) { | 
| Mathias Agopian | 5f1af04 | 2017-03-09 18:50:05 -0800 | [diff] [blame] | 226 | CallStack::log(LOG_TAG); | 
| Michael Lentine | 12c4bda | 2014-09-11 12:24:13 -0700 | [diff] [blame] | 227 | } | 
| Mathias Agopian | a6bb107 | 2013-08-07 20:10:20 -0700 | [diff] [blame] | 228 | } | 
| Mathias Agopian | 1cadb25 | 2011-05-23 17:26:14 -0700 | [diff] [blame] | 229 | } | 
|  | 230 |  | 
| Mathias Agopian | 48d438d | 2012-01-28 21:44:00 -0800 | [diff] [blame] | 231 | void gl_noop() { | 
|  | 232 | } | 
|  | 233 |  | 
| Mathias Agopian | 1cadb25 | 2011-05-23 17:26:14 -0700 | [diff] [blame] | 234 | // ---------------------------------------------------------------------------- | 
|  | 235 |  | 
| Mathias Agopian | 1cadb25 | 2011-05-23 17:26:14 -0700 | [diff] [blame] | 236 | void setGlThreadSpecific(gl_hooks_t const *value) { | 
|  | 237 | gl_hooks_t const * volatile * tls_hooks = get_tls_hooks(); | 
|  | 238 | tls_hooks[TLS_SLOT_OPENGL_API] = value; | 
|  | 239 | } | 
|  | 240 |  | 
| Mathias Agopian | 1cadb25 | 2011-05-23 17:26:14 -0700 | [diff] [blame] | 241 | // ---------------------------------------------------------------------------- | 
|  | 242 | // GL / EGL hooks | 
|  | 243 | // ---------------------------------------------------------------------------- | 
|  | 244 |  | 
|  | 245 | #undef GL_ENTRY | 
|  | 246 | #undef EGL_ENTRY | 
|  | 247 | #define GL_ENTRY(_r, _api, ...) #_api, | 
|  | 248 | #define EGL_ENTRY(_r, _api, ...) #_api, | 
|  | 249 |  | 
|  | 250 | char const * const gl_names[] = { | 
| Mathias Agopian | 39c24a2 | 2013-04-04 23:17:56 -0700 | [diff] [blame] | 251 | #include "../entries.in" | 
| Yi Kong | 48a6cd2 | 2018-07-18 10:07:09 -0700 | [diff] [blame] | 252 | nullptr | 
| Mathias Agopian | 1cadb25 | 2011-05-23 17:26:14 -0700 | [diff] [blame] | 253 | }; | 
|  | 254 |  | 
| Yiwei Zhang | 7cc5892 | 2018-10-10 11:37:43 -0700 | [diff] [blame] | 255 | char const * const gl_names_1[] = { | 
|  | 256 | #include "../entries_gles1.in" | 
|  | 257 | nullptr | 
|  | 258 | }; | 
|  | 259 |  | 
| Mathias Agopian | 1cadb25 | 2011-05-23 17:26:14 -0700 | [diff] [blame] | 260 | char const * const egl_names[] = { | 
|  | 261 | #include "egl_entries.in" | 
| Yi Kong | 48a6cd2 | 2018-07-18 10:07:09 -0700 | [diff] [blame] | 262 | nullptr | 
| Mathias Agopian | 1cadb25 | 2011-05-23 17:26:14 -0700 | [diff] [blame] | 263 | }; | 
|  | 264 |  | 
| Cody Northrop | 68d1035 | 2018-10-15 07:22:09 -0600 | [diff] [blame] | 265 | char const * const platform_names[] = { | 
|  | 266 | #include "platform_entries.in" | 
|  | 267 | nullptr | 
|  | 268 | }; | 
|  | 269 |  | 
| Mathias Agopian | 1cadb25 | 2011-05-23 17:26:14 -0700 | [diff] [blame] | 270 | #undef GL_ENTRY | 
|  | 271 | #undef EGL_ENTRY | 
|  | 272 |  | 
|  | 273 |  | 
| Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 274 | // ---------------------------------------------------------------------------- | 
|  | 275 | }; // namespace android | 
|  | 276 | // ---------------------------------------------------------------------------- | 
|  | 277 |  |