Jesse Hall | 21558da | 2013-08-06 15:31:22 -0700 | [diff] [blame] | 1 | /* |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 2 | ** Copyright 2007, The Android Open Source Project |
| 3 | ** |
Jesse Hall | 21558da | 2013-08-06 15:31:22 -0700 | [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 |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 7 | ** |
Jesse Hall | 21558da | 2013-08-06 15:31:22 -0700 | [diff] [blame] | 8 | ** http://www.apache.org/licenses/LICENSE-2.0 |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 9 | ** |
Jesse Hall | 21558da | 2013-08-06 15:31:22 -0700 | [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 |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 14 | ** limitations under the License. |
| 15 | */ |
| 16 | |
Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 17 | #define __STDC_LIMIT_MACROS 1 |
| 18 | |
Mathias Agopian | 4b9511c | 2011-11-13 23:52:47 -0800 | [diff] [blame] | 19 | #include <string.h> |
| 20 | |
Mathias Agopian | 39c24a2 | 2013-04-04 23:17:56 -0700 | [diff] [blame] | 21 | #include "../egl_impl.h" |
| 22 | |
Jamie Gennis | aca51c0 | 2011-11-03 17:42:43 -0700 | [diff] [blame] | 23 | #include "egl_cache.h" |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 24 | #include "egl_display.h" |
| 25 | #include "egl_object.h" |
| 26 | #include "egl_tls.h" |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 27 | #include "Loader.h" |
Mathias Agopian | 7db993a | 2012-03-25 00:49:46 -0700 | [diff] [blame] | 28 | #include <cutils/properties.h> |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 29 | |
| 30 | // ---------------------------------------------------------------------------- |
| 31 | namespace android { |
| 32 | // ---------------------------------------------------------------------------- |
| 33 | |
Mathias Agopian | 4b9511c | 2011-11-13 23:52:47 -0800 | [diff] [blame] | 34 | static char const * const sVendorString = "Android"; |
| 35 | static char const * const sVersionString = "1.4 Android META-EGL"; |
Mathias Agopian | cc2b156 | 2012-05-21 14:01:37 -0700 | [diff] [blame] | 36 | static char const * const sClientApiString = "OpenGL_ES"; |
Mathias Agopian | 4b9511c | 2011-11-13 23:52:47 -0800 | [diff] [blame] | 37 | |
Jesse Hall | 21558da | 2013-08-06 15:31:22 -0700 | [diff] [blame] | 38 | extern char const * const gBuiltinExtensionString; |
Mathias Agopian | e9b3dfb | 2013-03-27 14:30:19 -0700 | [diff] [blame] | 39 | extern char const * const gExtensionString; |
Mathias Agopian | 4b9511c | 2011-11-13 23:52:47 -0800 | [diff] [blame] | 40 | |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 41 | extern void setGLHooksThreadSpecific(gl_hooks_t const *value); |
| 42 | |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 43 | // ---------------------------------------------------------------------------- |
| 44 | |
Jesse Hall | c2e4122 | 2013-08-08 13:40:22 -0700 | [diff] [blame] | 45 | static bool findExtension(const char* exts, const char* name, size_t nameLen) { |
| 46 | if (exts) { |
Kalle Raita | 7804aa2 | 2016-04-18 16:03:37 -0700 | [diff] [blame] | 47 | for (const char* match = strstr(exts, name); match; match = strstr(match + nameLen, name)) { |
| 48 | if (match[nameLen] == '\0' || match[nameLen] == ' ') { |
| 49 | return true; |
| 50 | } |
Jesse Hall | c2e4122 | 2013-08-08 13:40:22 -0700 | [diff] [blame] | 51 | } |
| 52 | } |
| 53 | return false; |
| 54 | } |
| 55 | |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 56 | egl_display_t egl_display_t::sDisplay[NUM_DISPLAYS]; |
| 57 | |
| 58 | egl_display_t::egl_display_t() : |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 59 | magic('_dpy'), finishOnSwap(false), traceGpuCompletion(false), refs(0), eglIsInitialized(false) { |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | egl_display_t::~egl_display_t() { |
| 63 | magic = 0; |
Jamie Gennis | 7660108 | 2011-11-06 14:14:33 -0800 | [diff] [blame] | 64 | egl_cache_t::get()->terminate(); |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | egl_display_t* egl_display_t::get(EGLDisplay dpy) { |
| 68 | uintptr_t index = uintptr_t(dpy)-1U; |
Jesse Hall | d6e9946 | 2016-09-28 11:26:57 -0700 | [diff] [blame] | 69 | if (index >= NUM_DISPLAYS || !sDisplay[index].isValid()) { |
| 70 | return nullptr; |
| 71 | } |
| 72 | return &sDisplay[index]; |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | void egl_display_t::addObject(egl_object_t* object) { |
| 76 | Mutex::Autolock _l(lock); |
| 77 | objects.add(object); |
| 78 | } |
| 79 | |
Mathias Agopian | 5b287a6 | 2011-05-16 18:58:55 -0700 | [diff] [blame] | 80 | void egl_display_t::removeObject(egl_object_t* object) { |
| 81 | Mutex::Autolock _l(lock); |
| 82 | objects.remove(object); |
| 83 | } |
| 84 | |
Mathias Agopian | f0480de | 2011-11-13 20:50:07 -0800 | [diff] [blame] | 85 | bool egl_display_t::getObject(egl_object_t* object) const { |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 86 | Mutex::Autolock _l(lock); |
| 87 | if (objects.indexOf(object) >= 0) { |
Mathias Agopian | f0480de | 2011-11-13 20:50:07 -0800 | [diff] [blame] | 88 | if (object->getDisplay() == this) { |
| 89 | object->incRef(); |
| 90 | return true; |
| 91 | } |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 92 | } |
| 93 | return false; |
| 94 | } |
| 95 | |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 96 | EGLDisplay egl_display_t::getFromNativeDisplay(EGLNativeDisplayType disp) { |
| 97 | if (uintptr_t(disp) >= NUM_DISPLAYS) |
| 98 | return NULL; |
| 99 | |
| 100 | return sDisplay[uintptr_t(disp)].getDisplay(disp); |
| 101 | } |
| 102 | |
| 103 | EGLDisplay egl_display_t::getDisplay(EGLNativeDisplayType display) { |
| 104 | |
| 105 | Mutex::Autolock _l(lock); |
| 106 | |
| 107 | // get our driver loader |
| 108 | Loader& loader(Loader::getInstance()); |
| 109 | |
Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 110 | egl_connection_t* const cnx = &gEGLImpl; |
| 111 | if (cnx->dso && disp.dpy == EGL_NO_DISPLAY) { |
| 112 | EGLDisplay dpy = cnx->egl.eglGetDisplay(display); |
| 113 | disp.dpy = dpy; |
| 114 | if (dpy == EGL_NO_DISPLAY) { |
| 115 | loader.close(cnx->dso); |
| 116 | cnx->dso = NULL; |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 117 | } |
| 118 | } |
| 119 | |
| 120 | return EGLDisplay(uintptr_t(display) + 1U); |
| 121 | } |
| 122 | |
| 123 | EGLBoolean egl_display_t::initialize(EGLint *major, EGLint *minor) { |
| 124 | |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 125 | { |
| 126 | Mutex::Autolock _rf(refLock); |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 127 | |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 128 | refs++; |
| 129 | if (refs > 1) { |
| 130 | if (major != NULL) |
| 131 | *major = VERSION_MAJOR; |
| 132 | if (minor != NULL) |
| 133 | *minor = VERSION_MINOR; |
| 134 | while(!eglIsInitialized) refCond.wait(refLock); |
| 135 | return EGL_TRUE; |
| 136 | } |
| 137 | |
| 138 | while(eglIsInitialized) refCond.wait(refLock); |
| 139 | } |
| 140 | |
| 141 | { |
| 142 | Mutex::Autolock _l(lock); |
| 143 | |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 144 | setGLHooksThreadSpecific(&gHooksNoContext); |
| 145 | |
| 146 | // initialize each EGL and |
| 147 | // build our own extension string first, based on the extension we know |
| 148 | // and the extension supported by our client implementation |
| 149 | |
| 150 | egl_connection_t* const cnx = &gEGLImpl; |
| 151 | cnx->major = -1; |
| 152 | cnx->minor = -1; |
| 153 | if (cnx->dso) { |
| 154 | EGLDisplay idpy = disp.dpy; |
| 155 | if (cnx->egl.eglInitialize(idpy, &cnx->major, &cnx->minor)) { |
| 156 | //ALOGD("initialized dpy=%p, ver=%d.%d, cnx=%p", |
| 157 | // idpy, cnx->major, cnx->minor, cnx); |
| 158 | |
| 159 | // display is now initialized |
| 160 | disp.state = egl_display_t::INITIALIZED; |
| 161 | |
| 162 | // get the query-strings for this display for each implementation |
| 163 | disp.queryString.vendor = cnx->egl.eglQueryString(idpy, |
| 164 | EGL_VENDOR); |
| 165 | disp.queryString.version = cnx->egl.eglQueryString(idpy, |
| 166 | EGL_VERSION); |
| 167 | disp.queryString.extensions = cnx->egl.eglQueryString(idpy, |
| 168 | EGL_EXTENSIONS); |
| 169 | disp.queryString.clientApi = cnx->egl.eglQueryString(idpy, |
| 170 | EGL_CLIENT_APIS); |
| 171 | |
| 172 | } else { |
| 173 | ALOGW("eglInitialize(%p) failed (%s)", idpy, |
| 174 | egl_tls_t::egl_strerror(cnx->egl.eglGetError())); |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | // the query strings are per-display |
| 179 | mVendorString.setTo(sVendorString); |
| 180 | mVersionString.setTo(sVersionString); |
| 181 | mClientApiString.setTo(sClientApiString); |
| 182 | |
| 183 | mExtensionString.setTo(gBuiltinExtensionString); |
| 184 | char const* start = gExtensionString; |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 185 | do { |
Nicolas Capens | ecc0c9a | 2015-10-30 12:55:21 -0400 | [diff] [blame] | 186 | // length of the extension name |
| 187 | size_t len = strcspn(start, " "); |
| 188 | if (len) { |
| 189 | // NOTE: we could avoid the copy if we had strnstr. |
| 190 | const String8 ext(start, len); |
| 191 | if (findExtension(disp.queryString.extensions, ext.string(), |
| 192 | len)) { |
| 193 | mExtensionString.append(ext + " "); |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 194 | } |
Nicolas Capens | ecc0c9a | 2015-10-30 12:55:21 -0400 | [diff] [blame] | 195 | // advance to the next extension name, skipping the space. |
| 196 | start += len; |
| 197 | start += (*start == ' ') ? 1 : 0; |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 198 | } |
Nicolas Capens | ecc0c9a | 2015-10-30 12:55:21 -0400 | [diff] [blame] | 199 | } while (*start != '\0'); |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 200 | |
| 201 | egl_cache_t::get()->initialize(this); |
| 202 | |
| 203 | char value[PROPERTY_VALUE_MAX]; |
| 204 | property_get("debug.egl.finish", value, "0"); |
| 205 | if (atoi(value)) { |
| 206 | finishOnSwap = true; |
| 207 | } |
| 208 | |
| 209 | property_get("debug.egl.traceGpuCompletion", value, "0"); |
| 210 | if (atoi(value)) { |
| 211 | traceGpuCompletion = true; |
| 212 | } |
| 213 | |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 214 | if (major != NULL) |
| 215 | *major = VERSION_MAJOR; |
| 216 | if (minor != NULL) |
| 217 | *minor = VERSION_MINOR; |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 218 | } |
| 219 | |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 220 | { |
| 221 | Mutex::Autolock _rf(refLock); |
| 222 | eglIsInitialized = true; |
| 223 | refCond.broadcast(); |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 224 | } |
| 225 | |
Mathias Agopian | 7773c43 | 2012-02-13 20:06:08 -0800 | [diff] [blame] | 226 | return EGL_TRUE; |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 227 | } |
| 228 | |
| 229 | EGLBoolean egl_display_t::terminate() { |
| 230 | |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 231 | { |
| 232 | Mutex::Autolock _rl(refLock); |
| 233 | if (refs == 0) { |
| 234 | /* |
| 235 | * From the EGL spec (3.2): |
| 236 | * "Termination of a display that has already been terminated, |
| 237 | * (...), is allowed, but the only effect of such a call is |
| 238 | * to return EGL_TRUE (...) |
| 239 | */ |
| 240 | return EGL_TRUE; |
| 241 | } |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 242 | |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 243 | // this is specific to Android, display termination is ref-counted. |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 244 | refs--; |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 245 | if (refs > 0) { |
| 246 | return EGL_TRUE; |
| 247 | } |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 248 | } |
| 249 | |
| 250 | EGLBoolean res = EGL_FALSE; |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 251 | |
| 252 | { |
| 253 | Mutex::Autolock _l(lock); |
| 254 | |
| 255 | egl_connection_t* const cnx = &gEGLImpl; |
| 256 | if (cnx->dso && disp.state == egl_display_t::INITIALIZED) { |
| 257 | if (cnx->egl.eglTerminate(disp.dpy) == EGL_FALSE) { |
| 258 | ALOGW("eglTerminate(%p) failed (%s)", disp.dpy, |
| 259 | egl_tls_t::egl_strerror(cnx->egl.eglGetError())); |
| 260 | } |
| 261 | // REVISIT: it's unclear what to do if eglTerminate() fails |
| 262 | disp.state = egl_display_t::TERMINATED; |
| 263 | res = EGL_TRUE; |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 264 | } |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 265 | |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 266 | // Reset the extension string since it will be regenerated if we get |
| 267 | // reinitialized. |
| 268 | mExtensionString.setTo(""); |
| 269 | |
| 270 | // Mark all objects remaining in the list as terminated, unless |
| 271 | // there are no reference to them, it which case, we're free to |
| 272 | // delete them. |
| 273 | size_t count = objects.size(); |
Dan Albert | eacd31f | 2016-02-02 15:08:34 -0800 | [diff] [blame] | 274 | ALOGW_IF(count, "eglTerminate() called w/ %zu objects remaining", count); |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 275 | for (size_t i=0 ; i<count ; i++) { |
| 276 | egl_object_t* o = objects.itemAt(i); |
| 277 | o->destroy(); |
| 278 | } |
| 279 | |
| 280 | // this marks all object handles are "terminated" |
| 281 | objects.clear(); |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 282 | } |
| 283 | |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 284 | { |
| 285 | Mutex::Autolock _rl(refLock); |
| 286 | eglIsInitialized = false; |
| 287 | refCond.broadcast(); |
Mathias Agopian | 5b287a6 | 2011-05-16 18:58:55 -0700 | [diff] [blame] | 288 | } |
| 289 | |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 290 | return res; |
| 291 | } |
| 292 | |
Mathias Agopian | fb87e54 | 2012-01-30 18:20:52 -0800 | [diff] [blame] | 293 | void egl_display_t::loseCurrent(egl_context_t * cur_c) |
| 294 | { |
| 295 | if (cur_c) { |
Mathias Agopian | a4b2c04 | 2012-02-03 15:24:51 -0800 | [diff] [blame] | 296 | egl_display_t* display = cur_c->getDisplay(); |
| 297 | if (display) { |
| 298 | display->loseCurrentImpl(cur_c); |
| 299 | } |
| 300 | } |
| 301 | } |
Mathias Agopian | fb87e54 | 2012-01-30 18:20:52 -0800 | [diff] [blame] | 302 | |
Mathias Agopian | a4b2c04 | 2012-02-03 15:24:51 -0800 | [diff] [blame] | 303 | void egl_display_t::loseCurrentImpl(egl_context_t * cur_c) |
| 304 | { |
| 305 | // by construction, these are either 0 or valid (possibly terminated) |
| 306 | // it should be impossible for these to be invalid |
| 307 | ContextRef _cur_c(cur_c); |
| 308 | SurfaceRef _cur_r(cur_c ? get_surface(cur_c->read) : NULL); |
| 309 | SurfaceRef _cur_d(cur_c ? get_surface(cur_c->draw) : NULL); |
Mathias Agopian | fb87e54 | 2012-01-30 18:20:52 -0800 | [diff] [blame] | 310 | |
Mathias Agopian | a4b2c04 | 2012-02-03 15:24:51 -0800 | [diff] [blame] | 311 | { // scope for the lock |
| 312 | Mutex::Autolock _l(lock); |
Mathias Agopian | fb87e54 | 2012-01-30 18:20:52 -0800 | [diff] [blame] | 313 | cur_c->onLooseCurrent(); |
| 314 | |
Mathias Agopian | fb87e54 | 2012-01-30 18:20:52 -0800 | [diff] [blame] | 315 | } |
Mathias Agopian | a4b2c04 | 2012-02-03 15:24:51 -0800 | [diff] [blame] | 316 | |
| 317 | // This cannot be called with the lock held because it might end-up |
| 318 | // calling back into EGL (in particular when a surface is destroyed |
| 319 | // it calls ANativeWindow::disconnect |
| 320 | _cur_c.release(); |
| 321 | _cur_r.release(); |
| 322 | _cur_d.release(); |
Mathias Agopian | fb87e54 | 2012-01-30 18:20:52 -0800 | [diff] [blame] | 323 | } |
| 324 | |
| 325 | EGLBoolean egl_display_t::makeCurrent(egl_context_t* c, egl_context_t* cur_c, |
Mark Salyzyn | 92dc3fc | 2014-03-12 13:12:44 -0700 | [diff] [blame] | 326 | EGLSurface draw, EGLSurface read, EGLContext /*ctx*/, |
Mathias Agopian | fb87e54 | 2012-01-30 18:20:52 -0800 | [diff] [blame] | 327 | EGLSurface impl_draw, EGLSurface impl_read, EGLContext impl_ctx) |
| 328 | { |
Mathias Agopian | fb87e54 | 2012-01-30 18:20:52 -0800 | [diff] [blame] | 329 | EGLBoolean result; |
Mathias Agopian | a4b2c04 | 2012-02-03 15:24:51 -0800 | [diff] [blame] | 330 | |
| 331 | // by construction, these are either 0 or valid (possibly terminated) |
| 332 | // it should be impossible for these to be invalid |
| 333 | ContextRef _cur_c(cur_c); |
| 334 | SurfaceRef _cur_r(cur_c ? get_surface(cur_c->read) : NULL); |
| 335 | SurfaceRef _cur_d(cur_c ? get_surface(cur_c->draw) : NULL); |
| 336 | |
| 337 | { // scope for the lock |
| 338 | Mutex::Autolock _l(lock); |
Mathias Agopian | fb87e54 | 2012-01-30 18:20:52 -0800 | [diff] [blame] | 339 | if (c) { |
Mathias Agopian | a4b2c04 | 2012-02-03 15:24:51 -0800 | [diff] [blame] | 340 | result = c->cnx->egl.eglMakeCurrent( |
Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 341 | disp.dpy, impl_draw, impl_read, impl_ctx); |
Mathias Agopian | a4b2c04 | 2012-02-03 15:24:51 -0800 | [diff] [blame] | 342 | if (result == EGL_TRUE) { |
| 343 | c->onMakeCurrent(draw, read); |
| 344 | } |
| 345 | } else { |
| 346 | result = cur_c->cnx->egl.eglMakeCurrent( |
Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 347 | disp.dpy, impl_draw, impl_read, impl_ctx); |
Mathias Agopian | a4b2c04 | 2012-02-03 15:24:51 -0800 | [diff] [blame] | 348 | if (result == EGL_TRUE) { |
| 349 | cur_c->onLooseCurrent(); |
| 350 | } |
Mathias Agopian | fb87e54 | 2012-01-30 18:20:52 -0800 | [diff] [blame] | 351 | } |
| 352 | } |
Mathias Agopian | a4b2c04 | 2012-02-03 15:24:51 -0800 | [diff] [blame] | 353 | |
| 354 | if (result == EGL_TRUE) { |
| 355 | // This cannot be called with the lock held because it might end-up |
| 356 | // calling back into EGL (in particular when a surface is destroyed |
| 357 | // it calls ANativeWindow::disconnect |
| 358 | _cur_c.release(); |
| 359 | _cur_r.release(); |
| 360 | _cur_d.release(); |
| 361 | } |
| 362 | |
Mathias Agopian | fb87e54 | 2012-01-30 18:20:52 -0800 | [diff] [blame] | 363 | return result; |
| 364 | } |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 365 | |
Jesse Hall | c2e4122 | 2013-08-08 13:40:22 -0700 | [diff] [blame] | 366 | bool egl_display_t::haveExtension(const char* name, size_t nameLen) const { |
| 367 | if (!nameLen) { |
| 368 | nameLen = strlen(name); |
| 369 | } |
| 370 | return findExtension(mExtensionString.string(), name, nameLen); |
| 371 | } |
| 372 | |
Jesse Hall | a0fef1c | 2012-04-17 12:02:26 -0700 | [diff] [blame] | 373 | // ---------------------------------------------------------------------------- |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 374 | }; // namespace android |
| 375 | // ---------------------------------------------------------------------------- |