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 |
Jesse Hall | 1508ae6 | 2017-01-19 17:43:26 -0800 | [diff] [blame] | 18 | #define ATRACE_TAG ATRACE_TAG_GRAPHICS |
Jesse Hall | b29e5e8 | 2012-04-04 16:53:42 -0700 | [diff] [blame] | 19 | |
Mathias Agopian | 311b479 | 2017-02-28 15:00:49 -0800 | [diff] [blame] | 20 | #include "egl_display.h" |
Mathias Agopian | 4b9511c | 2011-11-13 23:52:47 -0800 | [diff] [blame] | 21 | |
Mathias Agopian | 39c24a2 | 2013-04-04 23:17:56 -0700 | [diff] [blame] | 22 | #include "../egl_impl.h" |
| 23 | |
Cody Northrop | 1f00e17 | 2018-04-02 11:23:31 -0600 | [diff] [blame] | 24 | #include <EGL/eglext_angle.h> |
Mathias Agopian | b7f9a24 | 2017-03-08 22:29:31 -0800 | [diff] [blame] | 25 | #include <private/EGL/display.h> |
| 26 | |
Tobin Ehlis | 96a184d | 2018-07-18 16:14:07 -0600 | [diff] [blame] | 27 | #include <cutils/properties.h> |
| 28 | #include "Loader.h" |
| 29 | #include "egl_angle_platform.h" |
Jamie Gennis | aca51c0 | 2011-11-03 17:42:43 -0700 | [diff] [blame] | 30 | #include "egl_cache.h" |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 31 | #include "egl_object.h" |
| 32 | #include "egl_tls.h" |
Tobin Ehlis | 96a184d | 2018-07-18 16:14:07 -0600 | [diff] [blame] | 33 | |
| 34 | #include <android/dlext.h> |
| 35 | #include <dlfcn.h> |
| 36 | #include <graphicsenv/GraphicsEnv.h> |
Mathias Agopian | 311b479 | 2017-02-28 15:00:49 -0800 | [diff] [blame] | 37 | |
Courtney Goeltzenleuchter | e5d6f99 | 2017-07-07 14:55:40 -0600 | [diff] [blame] | 38 | #include <android/hardware/configstore/1.0/ISurfaceFlingerConfigs.h> |
| 39 | #include <configstore/Utils.h> |
| 40 | |
| 41 | using namespace android::hardware::configstore; |
| 42 | using namespace android::hardware::configstore::V1_0; |
| 43 | |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 44 | // ---------------------------------------------------------------------------- |
| 45 | namespace android { |
| 46 | // ---------------------------------------------------------------------------- |
| 47 | |
Mathias Agopian | 4b9511c | 2011-11-13 23:52:47 -0800 | [diff] [blame] | 48 | static char const * const sVendorString = "Android"; |
Courtney Goeltzenleuchter | 015ed67 | 2018-07-27 13:43:23 -0600 | [diff] [blame^] | 49 | static char const* const sVersionString14 = "1.4 Android META-EGL"; |
| 50 | static char const* const sVersionString15 = "1.5 Android META-EGL"; |
Mathias Agopian | cc2b156 | 2012-05-21 14:01:37 -0700 | [diff] [blame] | 51 | static char const * const sClientApiString = "OpenGL_ES"; |
Mathias Agopian | 4b9511c | 2011-11-13 23:52:47 -0800 | [diff] [blame] | 52 | |
Jesse Hall | 21558da | 2013-08-06 15:31:22 -0700 | [diff] [blame] | 53 | extern char const * const gBuiltinExtensionString; |
Mathias Agopian | e9b3dfb | 2013-03-27 14:30:19 -0700 | [diff] [blame] | 54 | extern char const * const gExtensionString; |
Mathias Agopian | 4b9511c | 2011-11-13 23:52:47 -0800 | [diff] [blame] | 55 | |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 56 | extern void setGLHooksThreadSpecific(gl_hooks_t const *value); |
| 57 | |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 58 | // ---------------------------------------------------------------------------- |
| 59 | |
Courtney Goeltzenleuchter | a1e59f1 | 2018-03-05 08:19:25 -0700 | [diff] [blame] | 60 | bool findExtension(const char* exts, const char* name, size_t nameLen) { |
Jesse Hall | c2e4122 | 2013-08-08 13:40:22 -0700 | [diff] [blame] | 61 | if (exts) { |
Courtney Goeltzenleuchter | a1e59f1 | 2018-03-05 08:19:25 -0700 | [diff] [blame] | 62 | if (!nameLen) { |
| 63 | nameLen = strlen(name); |
| 64 | } |
Kalle Raita | 7804aa2 | 2016-04-18 16:03:37 -0700 | [diff] [blame] | 65 | for (const char* match = strstr(exts, name); match; match = strstr(match + nameLen, name)) { |
| 66 | if (match[nameLen] == '\0' || match[nameLen] == ' ') { |
| 67 | return true; |
| 68 | } |
Jesse Hall | c2e4122 | 2013-08-08 13:40:22 -0700 | [diff] [blame] | 69 | } |
| 70 | } |
| 71 | return false; |
| 72 | } |
| 73 | |
Mathias Agopian | b7f9a24 | 2017-03-08 22:29:31 -0800 | [diff] [blame] | 74 | int egl_get_init_count(EGLDisplay dpy) { |
| 75 | egl_display_t* eglDisplay = egl_display_t::get(dpy); |
| 76 | return eglDisplay ? eglDisplay->getRefsCount() : 0; |
| 77 | } |
| 78 | |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 79 | egl_display_t egl_display_t::sDisplay[NUM_DISPLAYS]; |
| 80 | |
| 81 | egl_display_t::egl_display_t() : |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 82 | magic('_dpy'), finishOnSwap(false), traceGpuCompletion(false), refs(0), eglIsInitialized(false) { |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | egl_display_t::~egl_display_t() { |
| 86 | magic = 0; |
Jamie Gennis | 7660108 | 2011-11-06 14:14:33 -0800 | [diff] [blame] | 87 | egl_cache_t::get()->terminate(); |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | egl_display_t* egl_display_t::get(EGLDisplay dpy) { |
Ivan Lozano | 7025b54 | 2017-12-06 14:19:44 -0800 | [diff] [blame] | 91 | if (uintptr_t(dpy) == 0) { |
| 92 | return nullptr; |
| 93 | } |
| 94 | |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 95 | uintptr_t index = uintptr_t(dpy)-1U; |
Jesse Hall | d6e9946 | 2016-09-28 11:26:57 -0700 | [diff] [blame] | 96 | if (index >= NUM_DISPLAYS || !sDisplay[index].isValid()) { |
| 97 | return nullptr; |
| 98 | } |
| 99 | return &sDisplay[index]; |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | void egl_display_t::addObject(egl_object_t* object) { |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 103 | std::lock_guard<std::mutex> _l(lock); |
| 104 | objects.insert(object); |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 105 | } |
| 106 | |
Mathias Agopian | 5b287a6 | 2011-05-16 18:58:55 -0700 | [diff] [blame] | 107 | void egl_display_t::removeObject(egl_object_t* object) { |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 108 | std::lock_guard<std::mutex> _l(lock); |
| 109 | objects.erase(object); |
Mathias Agopian | 5b287a6 | 2011-05-16 18:58:55 -0700 | [diff] [blame] | 110 | } |
| 111 | |
Mathias Agopian | f0480de | 2011-11-13 20:50:07 -0800 | [diff] [blame] | 112 | bool egl_display_t::getObject(egl_object_t* object) const { |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 113 | std::lock_guard<std::mutex> _l(lock); |
| 114 | if (objects.find(object) != objects.end()) { |
Mathias Agopian | f0480de | 2011-11-13 20:50:07 -0800 | [diff] [blame] | 115 | if (object->getDisplay() == this) { |
| 116 | object->incRef(); |
| 117 | return true; |
| 118 | } |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 119 | } |
| 120 | return false; |
| 121 | } |
| 122 | |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 123 | EGLDisplay egl_display_t::getFromNativeDisplay(EGLNativeDisplayType disp) { |
| 124 | if (uintptr_t(disp) >= NUM_DISPLAYS) |
Yi Kong | 48a6cd2 | 2018-07-18 10:07:09 -0700 | [diff] [blame] | 125 | return nullptr; |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 126 | |
| 127 | return sDisplay[uintptr_t(disp)].getDisplay(disp); |
| 128 | } |
| 129 | |
Courtney Goeltzenleuchter | 555f1df | 2018-09-25 14:34:29 -0600 | [diff] [blame] | 130 | static void addAnglePlatformAttributes(egl_connection_t* const cnx, const EGLAttrib* attrib_list, |
| 131 | std::vector<EGLAttrib>& attrs) { |
| 132 | intptr_t vendorEGL = (intptr_t)cnx->vendorEGL; |
| 133 | |
| 134 | EGLint angleBackendDefault = EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE; |
| 135 | if (attrib_list) { |
| 136 | while (*attrib_list != EGL_NONE) { |
| 137 | EGLAttrib attr = *attrib_list++; |
| 138 | EGLAttrib value = *attrib_list++; |
| 139 | if (attr == EGL_PLATFORM_ANGLE_TYPE_ANGLE) { |
| 140 | switch (value) { |
| 141 | case EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE: |
| 142 | angleBackendDefault = EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE; |
| 143 | break; |
| 144 | case EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE: |
| 145 | case EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE: |
| 146 | angleBackendDefault = value; |
| 147 | break; |
| 148 | default: |
| 149 | ALOGW("Invalid EGL_PLATFORM_ANGLE_TYPE_ANGLE attribute: 0x%" PRIxPTR, |
| 150 | value); |
| 151 | break; |
| 152 | } |
| 153 | } |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | cnx->angleBackend = angleBackendDefault; |
| 158 | |
| 159 | // Allow debug property to override application's |
| 160 | char prop[PROPERTY_VALUE_MAX]; |
| 161 | property_get("debug.angle.backend", prop, "0"); |
| 162 | switch (atoi(prop)) { |
| 163 | case 1: |
| 164 | ALOGV("addAnglePlatformAttributes: Requesting OpenGLES back-end"); |
| 165 | cnx->angleBackend = EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE; |
| 166 | break; |
| 167 | case 2: |
| 168 | ALOGV("addAnglePlatformAttributes: Requesting Vulkan back-end"); |
| 169 | cnx->angleBackend = EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE; |
| 170 | break; |
| 171 | default: |
| 172 | break; |
| 173 | } |
| 174 | |
| 175 | attrs.reserve(4 * 2); |
| 176 | |
| 177 | attrs.push_back(EGL_PLATFORM_ANGLE_TYPE_ANGLE); |
| 178 | attrs.push_back(cnx->angleBackend); |
| 179 | |
| 180 | switch (cnx->angleBackend) { |
| 181 | case EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE: |
| 182 | ALOGV("%s: Requesting Vulkan ANGLE back-end", __FUNCTION__); |
| 183 | property_get("debug.angle.validation", prop, "0"); |
| 184 | attrs.push_back(EGL_PLATFORM_ANGLE_DEBUG_LAYERS_ENABLED_ANGLE); |
| 185 | attrs.push_back(atoi(prop)); |
| 186 | break; |
| 187 | case EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE: |
| 188 | ALOGV("%s: Requesting Default ANGLE back-end", __FUNCTION__); |
| 189 | break; |
| 190 | case EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE: |
| 191 | ALOGV("%s: Requesting OpenGL ES ANGLE back-end", __FUNCTION__); |
| 192 | // NOTE: This is only valid if the backend is OpenGL |
| 193 | attrs.push_back(EGL_PLATFORM_ANGLE_EGL_HANDLE_ANGLE); |
| 194 | attrs.push_back(vendorEGL); |
| 195 | break; |
| 196 | default: |
| 197 | ALOGV("%s: Requesting Unknown (%d) ANGLE back-end", __FUNCTION__, cnx->angleBackend); |
| 198 | break; |
| 199 | } |
| 200 | attrs.push_back(EGL_PLATFORM_ANGLE_CONTEXT_VIRTUALIZATION_ANGLE); |
| 201 | attrs.push_back(EGL_FALSE); |
| 202 | } |
| 203 | |
Tobin Ehlis | 96a184d | 2018-07-18 16:14:07 -0600 | [diff] [blame] | 204 | // Initialize function ptrs for ANGLE PlatformMethods struct, used for systrace |
| 205 | bool initializeAnglePlatform(EGLDisplay dpy) { |
| 206 | // Since we're inside libEGL, use dlsym to lookup fptr for ANGLEGetDisplayPlatform |
| 207 | android_namespace_t* ns = android_getAngleNamespace(); |
| 208 | const android_dlextinfo dlextinfo = { |
| 209 | .flags = ANDROID_DLEXT_USE_NAMESPACE, |
| 210 | .library_namespace = ns, |
| 211 | }; |
| 212 | void* so = android_dlopen_ext("libEGL_angle.so", RTLD_LOCAL | RTLD_NOW, &dlextinfo); |
| 213 | angle::AnglePlatformImpl::angleGetDisplayPlatform = |
| 214 | reinterpret_cast<angle::GetDisplayPlatformFunc>(dlsym(so, "ANGLEGetDisplayPlatform")); |
| 215 | |
| 216 | if (!angle::AnglePlatformImpl::angleGetDisplayPlatform) { |
| 217 | ALOGE("dlsym lookup of ANGLEGetDisplayPlatform in libEGL_angle failed!"); |
| 218 | return false; |
| 219 | } |
| 220 | |
| 221 | angle::AnglePlatformImpl::angleResetDisplayPlatform = |
| 222 | reinterpret_cast<angle::ResetDisplayPlatformFunc>( |
| 223 | eglGetProcAddress("ANGLEResetDisplayPlatform")); |
| 224 | |
| 225 | angle::PlatformMethods* platformMethods = nullptr; |
| 226 | if (!((angle::AnglePlatformImpl::angleGetDisplayPlatform)(dpy, angle::g_PlatformMethodNames, |
| 227 | angle::g_NumPlatformMethods, nullptr, |
| 228 | &platformMethods))) { |
| 229 | ALOGE("ANGLEGetDisplayPlatform call failed!"); |
| 230 | return false; |
| 231 | } |
| 232 | if (platformMethods) { |
| 233 | angle::AnglePlatformImpl::assignAnglePlatformMethods(platformMethods); |
| 234 | } else { |
| 235 | ALOGE("In initializeAnglePlatform() platformMethods struct ptr is NULL. Not assigning " |
| 236 | "tracing function ptrs!"); |
| 237 | } |
| 238 | return true; |
| 239 | } |
| 240 | |
Courtney Goeltzenleuchter | 555f1df | 2018-09-25 14:34:29 -0600 | [diff] [blame] | 241 | static EGLDisplay getDisplayAngle(EGLNativeDisplayType display, egl_connection_t* const cnx) { |
Cody Northrop | 1f00e17 | 2018-04-02 11:23:31 -0600 | [diff] [blame] | 242 | EGLDisplay dpy = EGL_NO_DISPLAY; |
| 243 | |
| 244 | // Locally define this until EGL 1.5 is supported |
| 245 | typedef EGLDisplay (*PFNEGLGETPLATFORMDISPLAYPROC)(EGLenum platform, void* native_display, |
| 246 | const EGLAttrib* attrib_list); |
| 247 | |
| 248 | PFNEGLGETPLATFORMDISPLAYPROC eglGetPlatformDisplay = |
| 249 | reinterpret_cast<PFNEGLGETPLATFORMDISPLAYPROC>( |
| 250 | cnx->egl.eglGetProcAddress("eglGetPlatformDisplay")); |
| 251 | |
| 252 | if (eglGetPlatformDisplay) { |
Courtney Goeltzenleuchter | 555f1df | 2018-09-25 14:34:29 -0600 | [diff] [blame] | 253 | std::vector<EGLAttrib> attrs; |
| 254 | addAnglePlatformAttributes(cnx, nullptr, attrs); |
| 255 | attrs.push_back(EGL_NONE); |
Cody Northrop | 1f00e17 | 2018-04-02 11:23:31 -0600 | [diff] [blame] | 256 | |
Cody Northrop | 1f00e17 | 2018-04-02 11:23:31 -0600 | [diff] [blame] | 257 | dpy = eglGetPlatformDisplay(EGL_PLATFORM_ANGLE_ANGLE, |
Courtney Goeltzenleuchter | 555f1df | 2018-09-25 14:34:29 -0600 | [diff] [blame] | 258 | reinterpret_cast<void*>(EGL_DEFAULT_DISPLAY), attrs.data()); |
| 259 | if (dpy == EGL_NO_DISPLAY) { |
| 260 | ALOGE("eglGetPlatformDisplay failed!"); |
Tobin Ehlis | 96a184d | 2018-07-18 16:14:07 -0600 | [diff] [blame] | 261 | } else { |
| 262 | if (!initializeAnglePlatform(dpy)) { |
| 263 | ALOGE("initializeAnglePlatform failed!"); |
| 264 | } |
Courtney Goeltzenleuchter | 555f1df | 2018-09-25 14:34:29 -0600 | [diff] [blame] | 265 | } |
Cody Northrop | 1f00e17 | 2018-04-02 11:23:31 -0600 | [diff] [blame] | 266 | } else { |
| 267 | ALOGE("eglGetDisplay(%p) failed: Unable to look up eglGetPlatformDisplay from ANGLE", |
| 268 | display); |
| 269 | } |
| 270 | |
| 271 | return dpy; |
| 272 | } |
| 273 | |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 274 | EGLDisplay egl_display_t::getDisplay(EGLNativeDisplayType display) { |
| 275 | |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 276 | std::lock_guard<std::mutex> _l(lock); |
Jesse Hall | 1508ae6 | 2017-01-19 17:43:26 -0800 | [diff] [blame] | 277 | ATRACE_CALL(); |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 278 | |
| 279 | // get our driver loader |
| 280 | Loader& loader(Loader::getInstance()); |
| 281 | |
Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 282 | egl_connection_t* const cnx = &gEGLImpl; |
| 283 | if (cnx->dso && disp.dpy == EGL_NO_DISPLAY) { |
Cody Northrop | 1f00e17 | 2018-04-02 11:23:31 -0600 | [diff] [blame] | 284 | EGLDisplay dpy = EGL_NO_DISPLAY; |
| 285 | |
| 286 | if (cnx->useAngle) { |
| 287 | dpy = getDisplayAngle(display, cnx); |
Courtney Goeltzenleuchter | 555f1df | 2018-09-25 14:34:29 -0600 | [diff] [blame] | 288 | } |
| 289 | if (dpy == EGL_NO_DISPLAY) { |
Cody Northrop | 1f00e17 | 2018-04-02 11:23:31 -0600 | [diff] [blame] | 290 | dpy = cnx->egl.eglGetDisplay(display); |
| 291 | } |
| 292 | |
Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 293 | disp.dpy = dpy; |
| 294 | if (dpy == EGL_NO_DISPLAY) { |
| 295 | loader.close(cnx->dso); |
Yi Kong | 48a6cd2 | 2018-07-18 10:07:09 -0700 | [diff] [blame] | 296 | cnx->dso = nullptr; |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 297 | } |
| 298 | } |
| 299 | |
| 300 | return EGLDisplay(uintptr_t(display) + 1U); |
| 301 | } |
| 302 | |
| 303 | EGLBoolean egl_display_t::initialize(EGLint *major, EGLint *minor) { |
| 304 | |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 305 | { // scope for refLock |
| 306 | std::unique_lock<std::mutex> _l(refLock); |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 307 | refs++; |
| 308 | if (refs > 1) { |
Yi Kong | 48a6cd2 | 2018-07-18 10:07:09 -0700 | [diff] [blame] | 309 | if (major != nullptr) |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 310 | *major = VERSION_MAJOR; |
Yi Kong | 48a6cd2 | 2018-07-18 10:07:09 -0700 | [diff] [blame] | 311 | if (minor != nullptr) |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 312 | *minor = VERSION_MINOR; |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 313 | while(!eglIsInitialized) { |
| 314 | refCond.wait(_l); |
| 315 | } |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 316 | return EGL_TRUE; |
| 317 | } |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 318 | while(eglIsInitialized) { |
| 319 | refCond.wait(_l); |
| 320 | } |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 321 | } |
| 322 | |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 323 | { // scope for lock |
| 324 | std::lock_guard<std::mutex> _l(lock); |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 325 | |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 326 | setGLHooksThreadSpecific(&gHooksNoContext); |
| 327 | |
| 328 | // initialize each EGL and |
| 329 | // build our own extension string first, based on the extension we know |
| 330 | // and the extension supported by our client implementation |
| 331 | |
| 332 | egl_connection_t* const cnx = &gEGLImpl; |
| 333 | cnx->major = -1; |
| 334 | cnx->minor = -1; |
| 335 | if (cnx->dso) { |
| 336 | EGLDisplay idpy = disp.dpy; |
| 337 | if (cnx->egl.eglInitialize(idpy, &cnx->major, &cnx->minor)) { |
| 338 | //ALOGD("initialized dpy=%p, ver=%d.%d, cnx=%p", |
| 339 | // idpy, cnx->major, cnx->minor, cnx); |
| 340 | |
| 341 | // display is now initialized |
| 342 | disp.state = egl_display_t::INITIALIZED; |
| 343 | |
| 344 | // get the query-strings for this display for each implementation |
| 345 | disp.queryString.vendor = cnx->egl.eglQueryString(idpy, |
| 346 | EGL_VENDOR); |
| 347 | disp.queryString.version = cnx->egl.eglQueryString(idpy, |
| 348 | EGL_VERSION); |
| 349 | disp.queryString.extensions = cnx->egl.eglQueryString(idpy, |
| 350 | EGL_EXTENSIONS); |
| 351 | disp.queryString.clientApi = cnx->egl.eglQueryString(idpy, |
| 352 | EGL_CLIENT_APIS); |
| 353 | |
| 354 | } else { |
| 355 | ALOGW("eglInitialize(%p) failed (%s)", idpy, |
| 356 | egl_tls_t::egl_strerror(cnx->egl.eglGetError())); |
| 357 | } |
| 358 | } |
| 359 | |
| 360 | // the query strings are per-display |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 361 | mVendorString = sVendorString; |
Courtney Goeltzenleuchter | 015ed67 | 2018-07-27 13:43:23 -0600 | [diff] [blame^] | 362 | mVersionString.clear(); |
| 363 | cnx->driverVersion = EGL_MAKE_VERSION(1, 4, 0); |
| 364 | if ((cnx->major == 1) && (cnx->minor == 5)) { |
| 365 | mVersionString = sVersionString15; |
| 366 | cnx->driverVersion = EGL_MAKE_VERSION(1, 5, 0); |
| 367 | } else if ((cnx->major == 1) && (cnx->minor == 4)) { |
| 368 | mVersionString = sVersionString14; |
| 369 | // Extensions needed for an EGL 1.4 implementation to be |
| 370 | // able to support EGL 1.5 functionality |
| 371 | std::vector<const char*> egl15extensions = { |
| 372 | "EGL_EXT_client_extensions", |
| 373 | // "EGL_EXT_platform_base", // implemented by EGL runtime |
| 374 | "EGL_KHR_image_base", |
| 375 | "EGL_KHR_fence_sync", |
| 376 | "EGL_KHR_wait_sync", |
| 377 | "EGL_KHR_create_context", |
| 378 | "EGL_EXT_create_context_robustness", |
| 379 | "EGL_KHR_gl_colorspace", |
| 380 | "EGL_ANDROID_native_fence_sync", |
| 381 | }; |
| 382 | bool extensionsFound = true; |
| 383 | for (const auto& name : egl15extensions) { |
| 384 | extensionsFound &= findExtension(disp.queryString.extensions, name); |
| 385 | ALOGV("Extension %s: %s", name, |
| 386 | findExtension(disp.queryString.extensions, name) ? "Found" : "Missing"); |
| 387 | } |
| 388 | // NOTE: From the spec: |
| 389 | // Creation of fence sync objects requires support from the bound |
| 390 | // client API, and will not succeed unless the client API satisfies: |
| 391 | // client API is OpenGL ES, and either the OpenGL ES version is 3.0 |
| 392 | // or greater, or the GL_OES_EGL_sync extension is supported. |
| 393 | // We don't have a way to check the GL_EXTENSIONS string at this |
| 394 | // point in the code, assume that GL_OES_EGL_sync is supported |
| 395 | // because EGL_KHR_fence_sync is supported (as verified above). |
| 396 | if (extensionsFound) { |
| 397 | // Have everything needed to emulate EGL 1.5 so report EGL 1.5 |
| 398 | // to the application. |
| 399 | mVersionString = sVersionString15; |
| 400 | cnx->major = 1; |
| 401 | cnx->minor = 5; |
| 402 | } |
| 403 | } |
| 404 | if (mVersionString.empty()) { |
| 405 | ALOGW("Unexpected driver version: %d.%d, want 1.4 or 1.5", cnx->major, cnx->minor); |
| 406 | mVersionString = sVersionString14; |
| 407 | } |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 408 | mClientApiString = sClientApiString; |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 409 | |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 410 | mExtensionString = gBuiltinExtensionString; |
Courtney Goeltzenleuchter | e5d6f99 | 2017-07-07 14:55:40 -0600 | [diff] [blame] | 411 | |
Krzysztof Kosiński | f2fc4e9 | 2018-04-18 16:29:49 -0700 | [diff] [blame] | 412 | hasColorSpaceSupport = findExtension(disp.queryString.extensions, "EGL_KHR_gl_colorspace"); |
| 413 | |
| 414 | // Note: CDD requires that devices supporting wide color and/or HDR color also support |
| 415 | // the EGL_KHR_gl_colorspace extension. |
Courtney Goeltzenleuchter | e5d6f99 | 2017-07-07 14:55:40 -0600 | [diff] [blame] | 416 | bool wideColorBoardConfig = |
| 417 | getBool<ISurfaceFlingerConfigs, &ISurfaceFlingerConfigs::hasWideColorDisplay>( |
| 418 | false); |
| 419 | |
| 420 | // Add wide-color extensions if device can support wide-color |
Krzysztof Kosiński | f2fc4e9 | 2018-04-18 16:29:49 -0700 | [diff] [blame] | 421 | if (wideColorBoardConfig && hasColorSpaceSupport) { |
Courtney Goeltzenleuchter | e5d6f99 | 2017-07-07 14:55:40 -0600 | [diff] [blame] | 422 | mExtensionString.append( |
| 423 | "EGL_EXT_gl_colorspace_scrgb EGL_EXT_gl_colorspace_scrgb_linear " |
| 424 | "EGL_EXT_gl_colorspace_display_p3_linear EGL_EXT_gl_colorspace_display_p3 "); |
| 425 | } |
| 426 | |
Courtney Goeltzenleuchter | 12ffe09 | 2017-11-16 14:27:48 -0700 | [diff] [blame] | 427 | bool hasHdrBoardConfig = |
| 428 | getBool<ISurfaceFlingerConfigs, &ISurfaceFlingerConfigs::hasHDRDisplay>(false); |
| 429 | |
Krzysztof Kosiński | f2fc4e9 | 2018-04-18 16:29:49 -0700 | [diff] [blame] | 430 | if (hasHdrBoardConfig && hasColorSpaceSupport) { |
Courtney Goeltzenleuchter | 12ffe09 | 2017-11-16 14:27:48 -0700 | [diff] [blame] | 431 | // hasHDRBoardConfig indicates the system is capable of supporting HDR content. |
| 432 | // Typically that means there is an HDR capable display attached, but could be |
| 433 | // support for attaching an HDR display. In either case, advertise support for |
| 434 | // HDR color spaces. |
| 435 | mExtensionString.append( |
| 436 | "EGL_EXT_gl_colorspace_bt2020_linear EGL_EXT_gl_colorspace_bt2020_pq "); |
| 437 | } |
| 438 | |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 439 | char const* start = gExtensionString; |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 440 | do { |
Nicolas Capens | ecc0c9a | 2015-10-30 12:55:21 -0400 | [diff] [blame] | 441 | // length of the extension name |
| 442 | size_t len = strcspn(start, " "); |
| 443 | if (len) { |
| 444 | // NOTE: we could avoid the copy if we had strnstr. |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 445 | const std::string ext(start, len); |
| 446 | if (findExtension(disp.queryString.extensions, ext.c_str(), len)) { |
Nicolas Capens | ecc0c9a | 2015-10-30 12:55:21 -0400 | [diff] [blame] | 447 | mExtensionString.append(ext + " "); |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 448 | } |
Nicolas Capens | ecc0c9a | 2015-10-30 12:55:21 -0400 | [diff] [blame] | 449 | // advance to the next extension name, skipping the space. |
| 450 | start += len; |
| 451 | start += (*start == ' ') ? 1 : 0; |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 452 | } |
Nicolas Capens | ecc0c9a | 2015-10-30 12:55:21 -0400 | [diff] [blame] | 453 | } while (*start != '\0'); |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 454 | |
| 455 | egl_cache_t::get()->initialize(this); |
| 456 | |
| 457 | char value[PROPERTY_VALUE_MAX]; |
| 458 | property_get("debug.egl.finish", value, "0"); |
| 459 | if (atoi(value)) { |
| 460 | finishOnSwap = true; |
| 461 | } |
| 462 | |
| 463 | property_get("debug.egl.traceGpuCompletion", value, "0"); |
| 464 | if (atoi(value)) { |
| 465 | traceGpuCompletion = true; |
| 466 | } |
| 467 | |
Yi Kong | 48a6cd2 | 2018-07-18 10:07:09 -0700 | [diff] [blame] | 468 | if (major != nullptr) |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 469 | *major = VERSION_MAJOR; |
Yi Kong | 48a6cd2 | 2018-07-18 10:07:09 -0700 | [diff] [blame] | 470 | if (minor != nullptr) |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 471 | *minor = VERSION_MINOR; |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 472 | } |
| 473 | |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 474 | { // scope for refLock |
| 475 | std::unique_lock<std::mutex> _l(refLock); |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 476 | eglIsInitialized = true; |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 477 | refCond.notify_all(); |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 478 | } |
| 479 | |
Mathias Agopian | 7773c43 | 2012-02-13 20:06:08 -0800 | [diff] [blame] | 480 | return EGL_TRUE; |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 481 | } |
| 482 | |
| 483 | EGLBoolean egl_display_t::terminate() { |
| 484 | |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 485 | { // scope for refLock |
| 486 | std::unique_lock<std::mutex> _rl(refLock); |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 487 | if (refs == 0) { |
| 488 | /* |
| 489 | * From the EGL spec (3.2): |
| 490 | * "Termination of a display that has already been terminated, |
| 491 | * (...), is allowed, but the only effect of such a call is |
| 492 | * to return EGL_TRUE (...) |
| 493 | */ |
| 494 | return EGL_TRUE; |
| 495 | } |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 496 | |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 497 | // this is specific to Android, display termination is ref-counted. |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 498 | refs--; |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 499 | if (refs > 0) { |
| 500 | return EGL_TRUE; |
| 501 | } |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 502 | } |
| 503 | |
| 504 | EGLBoolean res = EGL_FALSE; |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 505 | |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 506 | { // scope for lock |
| 507 | std::lock_guard<std::mutex> _l(lock); |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 508 | |
| 509 | egl_connection_t* const cnx = &gEGLImpl; |
| 510 | if (cnx->dso && disp.state == egl_display_t::INITIALIZED) { |
Tobin Ehlis | 96a184d | 2018-07-18 16:14:07 -0600 | [diff] [blame] | 511 | // If we're using ANGLE reset any custom DisplayPlatform |
| 512 | if (cnx->useAngle && angle::AnglePlatformImpl::angleResetDisplayPlatform) { |
| 513 | (angle::AnglePlatformImpl::angleResetDisplayPlatform)(disp.dpy); |
| 514 | } |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 515 | if (cnx->egl.eglTerminate(disp.dpy) == EGL_FALSE) { |
| 516 | ALOGW("eglTerminate(%p) failed (%s)", disp.dpy, |
| 517 | egl_tls_t::egl_strerror(cnx->egl.eglGetError())); |
| 518 | } |
| 519 | // REVISIT: it's unclear what to do if eglTerminate() fails |
| 520 | disp.state = egl_display_t::TERMINATED; |
| 521 | res = EGL_TRUE; |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 522 | } |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 523 | |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 524 | // Reset the extension string since it will be regenerated if we get |
| 525 | // reinitialized. |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 526 | mExtensionString.clear(); |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 527 | |
| 528 | // Mark all objects remaining in the list as terminated, unless |
| 529 | // there are no reference to them, it which case, we're free to |
| 530 | // delete them. |
| 531 | size_t count = objects.size(); |
Dan Albert | eacd31f | 2016-02-02 15:08:34 -0800 | [diff] [blame] | 532 | ALOGW_IF(count, "eglTerminate() called w/ %zu objects remaining", count); |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 533 | for (auto o : objects) { |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 534 | o->destroy(); |
| 535 | } |
| 536 | |
| 537 | // this marks all object handles are "terminated" |
| 538 | objects.clear(); |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 539 | } |
| 540 | |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 541 | { // scope for refLock |
| 542 | std::unique_lock<std::mutex> _rl(refLock); |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 543 | eglIsInitialized = false; |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 544 | refCond.notify_all(); |
Mathias Agopian | 5b287a6 | 2011-05-16 18:58:55 -0700 | [diff] [blame] | 545 | } |
| 546 | |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 547 | return res; |
| 548 | } |
| 549 | |
Mathias Agopian | fb87e54 | 2012-01-30 18:20:52 -0800 | [diff] [blame] | 550 | void egl_display_t::loseCurrent(egl_context_t * cur_c) |
| 551 | { |
| 552 | if (cur_c) { |
Mathias Agopian | a4b2c04 | 2012-02-03 15:24:51 -0800 | [diff] [blame] | 553 | egl_display_t* display = cur_c->getDisplay(); |
| 554 | if (display) { |
| 555 | display->loseCurrentImpl(cur_c); |
| 556 | } |
| 557 | } |
| 558 | } |
Mathias Agopian | fb87e54 | 2012-01-30 18:20:52 -0800 | [diff] [blame] | 559 | |
Mathias Agopian | a4b2c04 | 2012-02-03 15:24:51 -0800 | [diff] [blame] | 560 | void egl_display_t::loseCurrentImpl(egl_context_t * cur_c) |
| 561 | { |
| 562 | // by construction, these are either 0 or valid (possibly terminated) |
| 563 | // it should be impossible for these to be invalid |
| 564 | ContextRef _cur_c(cur_c); |
Yi Kong | 48a6cd2 | 2018-07-18 10:07:09 -0700 | [diff] [blame] | 565 | SurfaceRef _cur_r(cur_c ? get_surface(cur_c->read) : nullptr); |
| 566 | SurfaceRef _cur_d(cur_c ? get_surface(cur_c->draw) : nullptr); |
Mathias Agopian | fb87e54 | 2012-01-30 18:20:52 -0800 | [diff] [blame] | 567 | |
Mathias Agopian | a4b2c04 | 2012-02-03 15:24:51 -0800 | [diff] [blame] | 568 | { // scope for the lock |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 569 | std::lock_guard<std::mutex> _l(lock); |
Mathias Agopian | fb87e54 | 2012-01-30 18:20:52 -0800 | [diff] [blame] | 570 | cur_c->onLooseCurrent(); |
| 571 | |
Mathias Agopian | fb87e54 | 2012-01-30 18:20:52 -0800 | [diff] [blame] | 572 | } |
Mathias Agopian | a4b2c04 | 2012-02-03 15:24:51 -0800 | [diff] [blame] | 573 | |
| 574 | // This cannot be called with the lock held because it might end-up |
| 575 | // calling back into EGL (in particular when a surface is destroyed |
| 576 | // it calls ANativeWindow::disconnect |
| 577 | _cur_c.release(); |
| 578 | _cur_r.release(); |
| 579 | _cur_d.release(); |
Mathias Agopian | fb87e54 | 2012-01-30 18:20:52 -0800 | [diff] [blame] | 580 | } |
| 581 | |
| 582 | 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] | 583 | EGLSurface draw, EGLSurface read, EGLContext /*ctx*/, |
Mathias Agopian | fb87e54 | 2012-01-30 18:20:52 -0800 | [diff] [blame] | 584 | EGLSurface impl_draw, EGLSurface impl_read, EGLContext impl_ctx) |
| 585 | { |
Mathias Agopian | fb87e54 | 2012-01-30 18:20:52 -0800 | [diff] [blame] | 586 | EGLBoolean result; |
Mathias Agopian | a4b2c04 | 2012-02-03 15:24:51 -0800 | [diff] [blame] | 587 | |
| 588 | // by construction, these are either 0 or valid (possibly terminated) |
| 589 | // it should be impossible for these to be invalid |
| 590 | ContextRef _cur_c(cur_c); |
Yi Kong | 48a6cd2 | 2018-07-18 10:07:09 -0700 | [diff] [blame] | 591 | SurfaceRef _cur_r(cur_c ? get_surface(cur_c->read) : nullptr); |
| 592 | SurfaceRef _cur_d(cur_c ? get_surface(cur_c->draw) : nullptr); |
Mathias Agopian | a4b2c04 | 2012-02-03 15:24:51 -0800 | [diff] [blame] | 593 | |
| 594 | { // scope for the lock |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 595 | std::lock_guard<std::mutex> _l(lock); |
Mathias Agopian | fb87e54 | 2012-01-30 18:20:52 -0800 | [diff] [blame] | 596 | if (c) { |
Mathias Agopian | a4b2c04 | 2012-02-03 15:24:51 -0800 | [diff] [blame] | 597 | result = c->cnx->egl.eglMakeCurrent( |
Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 598 | disp.dpy, impl_draw, impl_read, impl_ctx); |
Mathias Agopian | a4b2c04 | 2012-02-03 15:24:51 -0800 | [diff] [blame] | 599 | if (result == EGL_TRUE) { |
| 600 | c->onMakeCurrent(draw, read); |
| 601 | } |
| 602 | } else { |
| 603 | result = cur_c->cnx->egl.eglMakeCurrent( |
Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 604 | disp.dpy, impl_draw, impl_read, impl_ctx); |
Mathias Agopian | a4b2c04 | 2012-02-03 15:24:51 -0800 | [diff] [blame] | 605 | if (result == EGL_TRUE) { |
| 606 | cur_c->onLooseCurrent(); |
| 607 | } |
Mathias Agopian | fb87e54 | 2012-01-30 18:20:52 -0800 | [diff] [blame] | 608 | } |
| 609 | } |
Mathias Agopian | a4b2c04 | 2012-02-03 15:24:51 -0800 | [diff] [blame] | 610 | |
| 611 | if (result == EGL_TRUE) { |
| 612 | // This cannot be called with the lock held because it might end-up |
| 613 | // calling back into EGL (in particular when a surface is destroyed |
| 614 | // it calls ANativeWindow::disconnect |
| 615 | _cur_c.release(); |
| 616 | _cur_r.release(); |
| 617 | _cur_d.release(); |
| 618 | } |
| 619 | |
Mathias Agopian | fb87e54 | 2012-01-30 18:20:52 -0800 | [diff] [blame] | 620 | return result; |
| 621 | } |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 622 | |
Jesse Hall | c2e4122 | 2013-08-08 13:40:22 -0700 | [diff] [blame] | 623 | bool egl_display_t::haveExtension(const char* name, size_t nameLen) const { |
| 624 | if (!nameLen) { |
| 625 | nameLen = strlen(name); |
| 626 | } |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 627 | return findExtension(mExtensionString.c_str(), name, nameLen); |
Jesse Hall | c2e4122 | 2013-08-08 13:40:22 -0700 | [diff] [blame] | 628 | } |
| 629 | |
Jesse Hall | a0fef1c | 2012-04-17 12:02:26 -0700 | [diff] [blame] | 630 | // ---------------------------------------------------------------------------- |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 631 | }; // namespace android |
| 632 | // ---------------------------------------------------------------------------- |