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 | |
Courtney Goeltzenleuchter | 4adf75b | 2018-10-11 13:09:40 -0600 | [diff] [blame] | 123 | EGLDisplay egl_display_t::getFromNativeDisplay(EGLNativeDisplayType disp, |
| 124 | const EGLAttrib* attrib_list) { |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 125 | if (uintptr_t(disp) >= NUM_DISPLAYS) |
Yi Kong | 48a6cd2 | 2018-07-18 10:07:09 -0700 | [diff] [blame] | 126 | return nullptr; |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 127 | |
Courtney Goeltzenleuchter | 4adf75b | 2018-10-11 13:09:40 -0600 | [diff] [blame] | 128 | return sDisplay[uintptr_t(disp)].getPlatformDisplay(disp, attrib_list); |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 129 | } |
| 130 | |
Courtney Goeltzenleuchter | b91b989 | 2018-10-23 16:28:00 -0600 | [diff] [blame] | 131 | static bool addAnglePlatformAttributes(egl_connection_t* const cnx, |
Courtney Goeltzenleuchter | 555f1df | 2018-09-25 14:34:29 -0600 | [diff] [blame] | 132 | std::vector<EGLAttrib>& attrs) { |
| 133 | intptr_t vendorEGL = (intptr_t)cnx->vendorEGL; |
| 134 | |
Courtney Goeltzenleuchter | 555f1df | 2018-09-25 14:34:29 -0600 | [diff] [blame] | 135 | attrs.reserve(4 * 2); |
| 136 | |
| 137 | attrs.push_back(EGL_PLATFORM_ANGLE_TYPE_ANGLE); |
| 138 | attrs.push_back(cnx->angleBackend); |
| 139 | |
| 140 | switch (cnx->angleBackend) { |
| 141 | case EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE: |
| 142 | ALOGV("%s: Requesting Vulkan ANGLE back-end", __FUNCTION__); |
Courtney Goeltzenleuchter | b91b989 | 2018-10-23 16:28:00 -0600 | [diff] [blame] | 143 | char prop[PROPERTY_VALUE_MAX]; |
Courtney Goeltzenleuchter | 555f1df | 2018-09-25 14:34:29 -0600 | [diff] [blame] | 144 | property_get("debug.angle.validation", prop, "0"); |
| 145 | attrs.push_back(EGL_PLATFORM_ANGLE_DEBUG_LAYERS_ENABLED_ANGLE); |
| 146 | attrs.push_back(atoi(prop)); |
| 147 | break; |
| 148 | case EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE: |
| 149 | ALOGV("%s: Requesting Default ANGLE back-end", __FUNCTION__); |
| 150 | break; |
| 151 | case EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE: |
| 152 | ALOGV("%s: Requesting OpenGL ES ANGLE back-end", __FUNCTION__); |
| 153 | // NOTE: This is only valid if the backend is OpenGL |
| 154 | attrs.push_back(EGL_PLATFORM_ANGLE_EGL_HANDLE_ANGLE); |
| 155 | attrs.push_back(vendorEGL); |
| 156 | break; |
| 157 | default: |
| 158 | ALOGV("%s: Requesting Unknown (%d) ANGLE back-end", __FUNCTION__, cnx->angleBackend); |
| 159 | break; |
| 160 | } |
| 161 | attrs.push_back(EGL_PLATFORM_ANGLE_CONTEXT_VIRTUALIZATION_ANGLE); |
| 162 | attrs.push_back(EGL_FALSE); |
Courtney Goeltzenleuchter | 4adf75b | 2018-10-11 13:09:40 -0600 | [diff] [blame] | 163 | |
| 164 | return true; |
Courtney Goeltzenleuchter | 555f1df | 2018-09-25 14:34:29 -0600 | [diff] [blame] | 165 | } |
| 166 | |
Courtney Goeltzenleuchter | 4adf75b | 2018-10-11 13:09:40 -0600 | [diff] [blame] | 167 | static EGLDisplay getPlatformDisplayAngle(EGLNativeDisplayType display, egl_connection_t* const cnx, |
| 168 | const EGLAttrib* attrib_list, EGLint* error) { |
Cody Northrop | 1f00e17 | 2018-04-02 11:23:31 -0600 | [diff] [blame] | 169 | EGLDisplay dpy = EGL_NO_DISPLAY; |
Courtney Goeltzenleuchter | 4adf75b | 2018-10-11 13:09:40 -0600 | [diff] [blame] | 170 | *error = EGL_NONE; |
Cody Northrop | 1f00e17 | 2018-04-02 11:23:31 -0600 | [diff] [blame] | 171 | |
Courtney Goeltzenleuchter | 4adf75b | 2018-10-11 13:09:40 -0600 | [diff] [blame] | 172 | if (cnx->egl.eglGetPlatformDisplay) { |
Courtney Goeltzenleuchter | 555f1df | 2018-09-25 14:34:29 -0600 | [diff] [blame] | 173 | std::vector<EGLAttrib> attrs; |
Courtney Goeltzenleuchter | 4adf75b | 2018-10-11 13:09:40 -0600 | [diff] [blame] | 174 | if (attrib_list) { |
| 175 | for (const EGLAttrib* attr = attrib_list; *attr != EGL_NONE; attr += 2) { |
| 176 | attrs.push_back(attr[0]); |
| 177 | attrs.push_back(attr[1]); |
| 178 | } |
| 179 | } |
| 180 | |
Courtney Goeltzenleuchter | b91b989 | 2018-10-23 16:28:00 -0600 | [diff] [blame] | 181 | if (!addAnglePlatformAttributes(cnx, attrs)) { |
Courtney Goeltzenleuchter | 4adf75b | 2018-10-11 13:09:40 -0600 | [diff] [blame] | 182 | ALOGE("eglGetDisplay(%p) failed: Mismatch display request", display); |
| 183 | *error = EGL_BAD_PARAMETER; |
| 184 | return EGL_NO_DISPLAY; |
| 185 | } |
Courtney Goeltzenleuchter | 555f1df | 2018-09-25 14:34:29 -0600 | [diff] [blame] | 186 | attrs.push_back(EGL_NONE); |
Cody Northrop | 1f00e17 | 2018-04-02 11:23:31 -0600 | [diff] [blame] | 187 | |
Courtney Goeltzenleuchter | 4adf75b | 2018-10-11 13:09:40 -0600 | [diff] [blame] | 188 | dpy = cnx->egl.eglGetPlatformDisplay(EGL_PLATFORM_ANGLE_ANGLE, |
| 189 | reinterpret_cast<void*>(EGL_DEFAULT_DISPLAY), |
| 190 | attrs.data()); |
Courtney Goeltzenleuchter | 555f1df | 2018-09-25 14:34:29 -0600 | [diff] [blame] | 191 | if (dpy == EGL_NO_DISPLAY) { |
| 192 | ALOGE("eglGetPlatformDisplay failed!"); |
Tobin Ehlis | 96a184d | 2018-07-18 16:14:07 -0600 | [diff] [blame] | 193 | } else { |
Tobin Ehlis | 75ce477 | 2018-11-20 09:48:47 -0700 | [diff] [blame] | 194 | if (!angle::initializeAnglePlatform(dpy)) { |
Tobin Ehlis | 96a184d | 2018-07-18 16:14:07 -0600 | [diff] [blame] | 195 | ALOGE("initializeAnglePlatform failed!"); |
| 196 | } |
Courtney Goeltzenleuchter | 555f1df | 2018-09-25 14:34:29 -0600 | [diff] [blame] | 197 | } |
Cody Northrop | 1f00e17 | 2018-04-02 11:23:31 -0600 | [diff] [blame] | 198 | } else { |
| 199 | ALOGE("eglGetDisplay(%p) failed: Unable to look up eglGetPlatformDisplay from ANGLE", |
| 200 | display); |
| 201 | } |
| 202 | |
| 203 | return dpy; |
| 204 | } |
| 205 | |
Courtney Goeltzenleuchter | 4adf75b | 2018-10-11 13:09:40 -0600 | [diff] [blame] | 206 | EGLDisplay egl_display_t::getPlatformDisplay(EGLNativeDisplayType display, |
| 207 | const EGLAttrib* attrib_list) { |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 208 | std::lock_guard<std::mutex> _l(lock); |
Jesse Hall | 1508ae6 | 2017-01-19 17:43:26 -0800 | [diff] [blame] | 209 | ATRACE_CALL(); |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 210 | |
| 211 | // get our driver loader |
| 212 | Loader& loader(Loader::getInstance()); |
| 213 | |
Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 214 | egl_connection_t* const cnx = &gEGLImpl; |
| 215 | if (cnx->dso && disp.dpy == EGL_NO_DISPLAY) { |
Cody Northrop | 1f00e17 | 2018-04-02 11:23:31 -0600 | [diff] [blame] | 216 | EGLDisplay dpy = EGL_NO_DISPLAY; |
| 217 | |
| 218 | if (cnx->useAngle) { |
Courtney Goeltzenleuchter | 4adf75b | 2018-10-11 13:09:40 -0600 | [diff] [blame] | 219 | EGLint error; |
| 220 | dpy = getPlatformDisplayAngle(display, cnx, attrib_list, &error); |
| 221 | if (error != EGL_NONE) { |
| 222 | return setError(error, dpy); |
| 223 | } |
Courtney Goeltzenleuchter | 555f1df | 2018-09-25 14:34:29 -0600 | [diff] [blame] | 224 | } |
| 225 | if (dpy == EGL_NO_DISPLAY) { |
Courtney Goeltzenleuchter | 4adf75b | 2018-10-11 13:09:40 -0600 | [diff] [blame] | 226 | // NOTE: eglGetPlatformDisplay with a empty attribute list |
| 227 | // behaves the same as eglGetDisplay |
| 228 | if (cnx->egl.eglGetPlatformDisplay) { |
| 229 | dpy = cnx->egl.eglGetPlatformDisplay(EGL_PLATFORM_ANDROID_KHR, display, |
| 230 | attrib_list); |
Ben Lin | e17f69b | 2018-11-05 16:49:28 -0800 | [diff] [blame] | 231 | } |
| 232 | |
| 233 | // It is possible that eglGetPlatformDisplay does not have a |
| 234 | // working implementation for Android platform; in that case, |
| 235 | // one last fallback to eglGetDisplay |
| 236 | if(dpy == EGL_NO_DISPLAY) { |
Courtney Goeltzenleuchter | 4adf75b | 2018-10-11 13:09:40 -0600 | [diff] [blame] | 237 | if (attrib_list) { |
| 238 | ALOGW("getPlatformDisplay: unexpected attribute list, attributes ignored"); |
| 239 | } |
| 240 | dpy = cnx->egl.eglGetDisplay(display); |
| 241 | } |
Cody Northrop | 1f00e17 | 2018-04-02 11:23:31 -0600 | [diff] [blame] | 242 | } |
| 243 | |
Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 244 | disp.dpy = dpy; |
| 245 | if (dpy == EGL_NO_DISPLAY) { |
Courtney Goeltzenleuchter | ee768c2 | 2018-10-25 11:43:52 -0600 | [diff] [blame] | 246 | loader.close(cnx); |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 247 | } |
| 248 | } |
| 249 | |
| 250 | return EGLDisplay(uintptr_t(display) + 1U); |
| 251 | } |
| 252 | |
| 253 | EGLBoolean egl_display_t::initialize(EGLint *major, EGLint *minor) { |
| 254 | |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 255 | { // scope for refLock |
| 256 | std::unique_lock<std::mutex> _l(refLock); |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 257 | refs++; |
| 258 | if (refs > 1) { |
Courtney Goeltzenleuchter | 4adf75b | 2018-10-11 13:09:40 -0600 | [diff] [blame] | 259 | // We don't know what to report until we know what the |
| 260 | // driver supports. Make sure we are initialized before |
| 261 | // returning the version info. |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 262 | while(!eglIsInitialized) { |
| 263 | refCond.wait(_l); |
| 264 | } |
Courtney Goeltzenleuchter | 4adf75b | 2018-10-11 13:09:40 -0600 | [diff] [blame] | 265 | egl_connection_t* const cnx = &gEGLImpl; |
| 266 | |
| 267 | // TODO: If device doesn't provide 1.4 or 1.5 then we'll be |
| 268 | // changing the behavior from the past where we always advertise |
| 269 | // version 1.4. May need to check that revision is valid |
| 270 | // before using cnx->major & cnx->minor |
| 271 | if (major != nullptr) *major = cnx->major; |
| 272 | if (minor != nullptr) *minor = cnx->minor; |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 273 | return EGL_TRUE; |
| 274 | } |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 275 | while(eglIsInitialized) { |
| 276 | refCond.wait(_l); |
| 277 | } |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 278 | } |
| 279 | |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 280 | { // scope for lock |
| 281 | std::lock_guard<std::mutex> _l(lock); |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 282 | |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 283 | setGLHooksThreadSpecific(&gHooksNoContext); |
| 284 | |
| 285 | // initialize each EGL and |
| 286 | // build our own extension string first, based on the extension we know |
| 287 | // and the extension supported by our client implementation |
| 288 | |
| 289 | egl_connection_t* const cnx = &gEGLImpl; |
| 290 | cnx->major = -1; |
| 291 | cnx->minor = -1; |
| 292 | if (cnx->dso) { |
| 293 | EGLDisplay idpy = disp.dpy; |
| 294 | if (cnx->egl.eglInitialize(idpy, &cnx->major, &cnx->minor)) { |
| 295 | //ALOGD("initialized dpy=%p, ver=%d.%d, cnx=%p", |
| 296 | // idpy, cnx->major, cnx->minor, cnx); |
| 297 | |
| 298 | // display is now initialized |
| 299 | disp.state = egl_display_t::INITIALIZED; |
| 300 | |
| 301 | // get the query-strings for this display for each implementation |
| 302 | disp.queryString.vendor = cnx->egl.eglQueryString(idpy, |
| 303 | EGL_VENDOR); |
| 304 | disp.queryString.version = cnx->egl.eglQueryString(idpy, |
| 305 | EGL_VERSION); |
| 306 | disp.queryString.extensions = cnx->egl.eglQueryString(idpy, |
| 307 | EGL_EXTENSIONS); |
| 308 | disp.queryString.clientApi = cnx->egl.eglQueryString(idpy, |
| 309 | EGL_CLIENT_APIS); |
| 310 | |
| 311 | } else { |
| 312 | ALOGW("eglInitialize(%p) failed (%s)", idpy, |
| 313 | egl_tls_t::egl_strerror(cnx->egl.eglGetError())); |
| 314 | } |
| 315 | } |
| 316 | |
Sean Callanan | ad9061c | 2019-03-12 14:07:23 -0700 | [diff] [blame] | 317 | if (cnx->minor == 5) { |
| 318 | // full list in egl_entries.in |
| 319 | if (!cnx->egl.eglCreateImage || |
| 320 | !cnx->egl.eglDestroyImage || |
| 321 | !cnx->egl.eglGetPlatformDisplay || |
| 322 | !cnx->egl.eglCreatePlatformWindowSurface || |
| 323 | !cnx->egl.eglCreatePlatformPixmapSurface || |
| 324 | !cnx->egl.eglCreateSync || |
| 325 | !cnx->egl.eglDestroySync || |
| 326 | !cnx->egl.eglClientWaitSync || |
| 327 | !cnx->egl.eglGetSyncAttrib || |
| 328 | !cnx->egl.eglWaitSync) { |
| 329 | ALOGE("Driver indicates EGL 1.5 support, but does not have " |
| 330 | "a critical API"); |
| 331 | cnx->minor = 4; |
| 332 | } |
| 333 | } |
| 334 | |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 335 | // the query strings are per-display |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 336 | mVendorString = sVendorString; |
Courtney Goeltzenleuchter | 015ed67 | 2018-07-27 13:43:23 -0600 | [diff] [blame] | 337 | mVersionString.clear(); |
| 338 | cnx->driverVersion = EGL_MAKE_VERSION(1, 4, 0); |
Courtney Goeltzenleuchter | f5b5c41 | 2019-04-10 17:36:19 -0600 | [diff] [blame] | 339 | mVersionString = sVersionString14; |
Courtney Goeltzenleuchter | 015ed67 | 2018-07-27 13:43:23 -0600 | [diff] [blame] | 340 | if ((cnx->major == 1) && (cnx->minor == 5)) { |
| 341 | mVersionString = sVersionString15; |
| 342 | cnx->driverVersion = EGL_MAKE_VERSION(1, 5, 0); |
Courtney Goeltzenleuchter | 015ed67 | 2018-07-27 13:43:23 -0600 | [diff] [blame] | 343 | } |
| 344 | if (mVersionString.empty()) { |
| 345 | ALOGW("Unexpected driver version: %d.%d, want 1.4 or 1.5", cnx->major, cnx->minor); |
| 346 | mVersionString = sVersionString14; |
| 347 | } |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 348 | mClientApiString = sClientApiString; |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 349 | |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 350 | mExtensionString = gBuiltinExtensionString; |
Courtney Goeltzenleuchter | e5d6f99 | 2017-07-07 14:55:40 -0600 | [diff] [blame] | 351 | |
Krzysztof Kosiński | f2fc4e9 | 2018-04-18 16:29:49 -0700 | [diff] [blame] | 352 | hasColorSpaceSupport = findExtension(disp.queryString.extensions, "EGL_KHR_gl_colorspace"); |
| 353 | |
| 354 | // Note: CDD requires that devices supporting wide color and/or HDR color also support |
| 355 | // the EGL_KHR_gl_colorspace extension. |
Courtney Goeltzenleuchter | e5d6f99 | 2017-07-07 14:55:40 -0600 | [diff] [blame] | 356 | bool wideColorBoardConfig = |
| 357 | getBool<ISurfaceFlingerConfigs, &ISurfaceFlingerConfigs::hasWideColorDisplay>( |
| 358 | false); |
| 359 | |
| 360 | // Add wide-color extensions if device can support wide-color |
Krzysztof Kosiński | f2fc4e9 | 2018-04-18 16:29:49 -0700 | [diff] [blame] | 361 | if (wideColorBoardConfig && hasColorSpaceSupport) { |
Courtney Goeltzenleuchter | e5d6f99 | 2017-07-07 14:55:40 -0600 | [diff] [blame] | 362 | mExtensionString.append( |
| 363 | "EGL_EXT_gl_colorspace_scrgb EGL_EXT_gl_colorspace_scrgb_linear " |
Peiyong Lin | e0ff377 | 2018-12-08 22:23:20 -0800 | [diff] [blame] | 364 | "EGL_EXT_gl_colorspace_display_p3_linear EGL_EXT_gl_colorspace_display_p3 " |
| 365 | "EGL_EXT_gl_colorspace_display_p3_passthrough "); |
Courtney Goeltzenleuchter | e5d6f99 | 2017-07-07 14:55:40 -0600 | [diff] [blame] | 366 | } |
| 367 | |
Courtney Goeltzenleuchter | 12ffe09 | 2017-11-16 14:27:48 -0700 | [diff] [blame] | 368 | bool hasHdrBoardConfig = |
| 369 | getBool<ISurfaceFlingerConfigs, &ISurfaceFlingerConfigs::hasHDRDisplay>(false); |
| 370 | |
Krzysztof Kosiński | f2fc4e9 | 2018-04-18 16:29:49 -0700 | [diff] [blame] | 371 | if (hasHdrBoardConfig && hasColorSpaceSupport) { |
Courtney Goeltzenleuchter | 12ffe09 | 2017-11-16 14:27:48 -0700 | [diff] [blame] | 372 | // hasHDRBoardConfig indicates the system is capable of supporting HDR content. |
| 373 | // Typically that means there is an HDR capable display attached, but could be |
| 374 | // support for attaching an HDR display. In either case, advertise support for |
| 375 | // HDR color spaces. |
| 376 | mExtensionString.append( |
| 377 | "EGL_EXT_gl_colorspace_bt2020_linear EGL_EXT_gl_colorspace_bt2020_pq "); |
| 378 | } |
| 379 | |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 380 | char const* start = gExtensionString; |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 381 | do { |
Nicolas Capens | ecc0c9a | 2015-10-30 12:55:21 -0400 | [diff] [blame] | 382 | // length of the extension name |
| 383 | size_t len = strcspn(start, " "); |
| 384 | if (len) { |
| 385 | // NOTE: we could avoid the copy if we had strnstr. |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 386 | const std::string ext(start, len); |
| 387 | if (findExtension(disp.queryString.extensions, ext.c_str(), len)) { |
Nicolas Capens | ecc0c9a | 2015-10-30 12:55:21 -0400 | [diff] [blame] | 388 | mExtensionString.append(ext + " "); |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 389 | } |
Nicolas Capens | ecc0c9a | 2015-10-30 12:55:21 -0400 | [diff] [blame] | 390 | // advance to the next extension name, skipping the space. |
| 391 | start += len; |
| 392 | start += (*start == ' ') ? 1 : 0; |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 393 | } |
Nicolas Capens | ecc0c9a | 2015-10-30 12:55:21 -0400 | [diff] [blame] | 394 | } while (*start != '\0'); |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 395 | |
| 396 | egl_cache_t::get()->initialize(this); |
| 397 | |
| 398 | char value[PROPERTY_VALUE_MAX]; |
| 399 | property_get("debug.egl.finish", value, "0"); |
| 400 | if (atoi(value)) { |
| 401 | finishOnSwap = true; |
| 402 | } |
| 403 | |
| 404 | property_get("debug.egl.traceGpuCompletion", value, "0"); |
| 405 | if (atoi(value)) { |
| 406 | traceGpuCompletion = true; |
| 407 | } |
| 408 | |
Courtney Goeltzenleuchter | 4adf75b | 2018-10-11 13:09:40 -0600 | [diff] [blame] | 409 | // TODO: If device doesn't provide 1.4 or 1.5 then we'll be |
| 410 | // changing the behavior from the past where we always advertise |
| 411 | // version 1.4. May need to check that revision is valid |
| 412 | // before using cnx->major & cnx->minor |
| 413 | if (major != nullptr) *major = cnx->major; |
| 414 | if (minor != nullptr) *minor = cnx->minor; |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 415 | } |
| 416 | |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 417 | { // scope for refLock |
| 418 | std::unique_lock<std::mutex> _l(refLock); |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 419 | eglIsInitialized = true; |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 420 | refCond.notify_all(); |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 421 | } |
| 422 | |
Mathias Agopian | 7773c43 | 2012-02-13 20:06:08 -0800 | [diff] [blame] | 423 | return EGL_TRUE; |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 424 | } |
| 425 | |
| 426 | EGLBoolean egl_display_t::terminate() { |
| 427 | |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 428 | { // scope for refLock |
| 429 | std::unique_lock<std::mutex> _rl(refLock); |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 430 | if (refs == 0) { |
| 431 | /* |
| 432 | * From the EGL spec (3.2): |
| 433 | * "Termination of a display that has already been terminated, |
| 434 | * (...), is allowed, but the only effect of such a call is |
| 435 | * to return EGL_TRUE (...) |
| 436 | */ |
| 437 | return EGL_TRUE; |
| 438 | } |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 439 | |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 440 | // this is specific to Android, display termination is ref-counted. |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 441 | refs--; |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 442 | if (refs > 0) { |
| 443 | return EGL_TRUE; |
| 444 | } |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 445 | } |
| 446 | |
| 447 | EGLBoolean res = EGL_FALSE; |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 448 | |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 449 | { // scope for lock |
| 450 | std::lock_guard<std::mutex> _l(lock); |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 451 | |
| 452 | egl_connection_t* const cnx = &gEGLImpl; |
| 453 | if (cnx->dso && disp.state == egl_display_t::INITIALIZED) { |
Tobin Ehlis | 96a184d | 2018-07-18 16:14:07 -0600 | [diff] [blame] | 454 | // If we're using ANGLE reset any custom DisplayPlatform |
Tobin Ehlis | 75ce477 | 2018-11-20 09:48:47 -0700 | [diff] [blame] | 455 | if (cnx->useAngle) { |
| 456 | angle::resetAnglePlatform(disp.dpy); |
Tobin Ehlis | 96a184d | 2018-07-18 16:14:07 -0600 | [diff] [blame] | 457 | } |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 458 | if (cnx->egl.eglTerminate(disp.dpy) == EGL_FALSE) { |
| 459 | ALOGW("eglTerminate(%p) failed (%s)", disp.dpy, |
| 460 | egl_tls_t::egl_strerror(cnx->egl.eglGetError())); |
| 461 | } |
| 462 | // REVISIT: it's unclear what to do if eglTerminate() fails |
| 463 | disp.state = egl_display_t::TERMINATED; |
| 464 | res = EGL_TRUE; |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 465 | } |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 466 | |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 467 | // Reset the extension string since it will be regenerated if we get |
| 468 | // reinitialized. |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 469 | mExtensionString.clear(); |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 470 | |
| 471 | // Mark all objects remaining in the list as terminated, unless |
| 472 | // there are no reference to them, it which case, we're free to |
| 473 | // delete them. |
| 474 | size_t count = objects.size(); |
Dan Albert | eacd31f | 2016-02-02 15:08:34 -0800 | [diff] [blame] | 475 | ALOGW_IF(count, "eglTerminate() called w/ %zu objects remaining", count); |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 476 | for (auto o : objects) { |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 477 | o->destroy(); |
| 478 | } |
| 479 | |
| 480 | // this marks all object handles are "terminated" |
| 481 | objects.clear(); |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 482 | } |
| 483 | |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 484 | { // scope for refLock |
| 485 | std::unique_lock<std::mutex> _rl(refLock); |
Michael Lentine | 54466bc | 2015-01-27 09:01:03 -0800 | [diff] [blame] | 486 | eglIsInitialized = false; |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 487 | refCond.notify_all(); |
Mathias Agopian | 5b287a6 | 2011-05-16 18:58:55 -0700 | [diff] [blame] | 488 | } |
| 489 | |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 490 | return res; |
| 491 | } |
| 492 | |
Mathias Agopian | fb87e54 | 2012-01-30 18:20:52 -0800 | [diff] [blame] | 493 | void egl_display_t::loseCurrent(egl_context_t * cur_c) |
| 494 | { |
| 495 | if (cur_c) { |
Mathias Agopian | a4b2c04 | 2012-02-03 15:24:51 -0800 | [diff] [blame] | 496 | egl_display_t* display = cur_c->getDisplay(); |
| 497 | if (display) { |
| 498 | display->loseCurrentImpl(cur_c); |
| 499 | } |
| 500 | } |
| 501 | } |
Mathias Agopian | fb87e54 | 2012-01-30 18:20:52 -0800 | [diff] [blame] | 502 | |
Mathias Agopian | a4b2c04 | 2012-02-03 15:24:51 -0800 | [diff] [blame] | 503 | void egl_display_t::loseCurrentImpl(egl_context_t * cur_c) |
| 504 | { |
| 505 | // by construction, these are either 0 or valid (possibly terminated) |
| 506 | // it should be impossible for these to be invalid |
| 507 | ContextRef _cur_c(cur_c); |
Yi Kong | 48a6cd2 | 2018-07-18 10:07:09 -0700 | [diff] [blame] | 508 | SurfaceRef _cur_r(cur_c ? get_surface(cur_c->read) : nullptr); |
| 509 | SurfaceRef _cur_d(cur_c ? get_surface(cur_c->draw) : nullptr); |
Mathias Agopian | fb87e54 | 2012-01-30 18:20:52 -0800 | [diff] [blame] | 510 | |
Mathias Agopian | a4b2c04 | 2012-02-03 15:24:51 -0800 | [diff] [blame] | 511 | { // scope for the lock |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 512 | std::lock_guard<std::mutex> _l(lock); |
Mathias Agopian | fb87e54 | 2012-01-30 18:20:52 -0800 | [diff] [blame] | 513 | cur_c->onLooseCurrent(); |
| 514 | |
Mathias Agopian | fb87e54 | 2012-01-30 18:20:52 -0800 | [diff] [blame] | 515 | } |
Mathias Agopian | a4b2c04 | 2012-02-03 15:24:51 -0800 | [diff] [blame] | 516 | |
| 517 | // This cannot be called with the lock held because it might end-up |
| 518 | // calling back into EGL (in particular when a surface is destroyed |
| 519 | // it calls ANativeWindow::disconnect |
| 520 | _cur_c.release(); |
| 521 | _cur_r.release(); |
| 522 | _cur_d.release(); |
Mathias Agopian | fb87e54 | 2012-01-30 18:20:52 -0800 | [diff] [blame] | 523 | } |
| 524 | |
| 525 | 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] | 526 | EGLSurface draw, EGLSurface read, EGLContext /*ctx*/, |
Mathias Agopian | fb87e54 | 2012-01-30 18:20:52 -0800 | [diff] [blame] | 527 | EGLSurface impl_draw, EGLSurface impl_read, EGLContext impl_ctx) |
| 528 | { |
Mathias Agopian | fb87e54 | 2012-01-30 18:20:52 -0800 | [diff] [blame] | 529 | EGLBoolean result; |
Mathias Agopian | a4b2c04 | 2012-02-03 15:24:51 -0800 | [diff] [blame] | 530 | |
| 531 | // by construction, these are either 0 or valid (possibly terminated) |
| 532 | // it should be impossible for these to be invalid |
| 533 | ContextRef _cur_c(cur_c); |
Yi Kong | 48a6cd2 | 2018-07-18 10:07:09 -0700 | [diff] [blame] | 534 | SurfaceRef _cur_r(cur_c ? get_surface(cur_c->read) : nullptr); |
| 535 | SurfaceRef _cur_d(cur_c ? get_surface(cur_c->draw) : nullptr); |
Mathias Agopian | a4b2c04 | 2012-02-03 15:24:51 -0800 | [diff] [blame] | 536 | |
| 537 | { // scope for the lock |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 538 | std::lock_guard<std::mutex> _l(lock); |
Mathias Agopian | fb87e54 | 2012-01-30 18:20:52 -0800 | [diff] [blame] | 539 | if (c) { |
Mathias Agopian | a4b2c04 | 2012-02-03 15:24:51 -0800 | [diff] [blame] | 540 | result = c->cnx->egl.eglMakeCurrent( |
Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 541 | disp.dpy, impl_draw, impl_read, impl_ctx); |
Mathias Agopian | a4b2c04 | 2012-02-03 15:24:51 -0800 | [diff] [blame] | 542 | if (result == EGL_TRUE) { |
| 543 | c->onMakeCurrent(draw, read); |
| 544 | } |
| 545 | } else { |
| 546 | result = cur_c->cnx->egl.eglMakeCurrent( |
Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 547 | disp.dpy, impl_draw, impl_read, impl_ctx); |
Mathias Agopian | a4b2c04 | 2012-02-03 15:24:51 -0800 | [diff] [blame] | 548 | if (result == EGL_TRUE) { |
| 549 | cur_c->onLooseCurrent(); |
| 550 | } |
Mathias Agopian | fb87e54 | 2012-01-30 18:20:52 -0800 | [diff] [blame] | 551 | } |
| 552 | } |
Mathias Agopian | a4b2c04 | 2012-02-03 15:24:51 -0800 | [diff] [blame] | 553 | |
| 554 | if (result == EGL_TRUE) { |
| 555 | // This cannot be called with the lock held because it might end-up |
| 556 | // calling back into EGL (in particular when a surface is destroyed |
| 557 | // it calls ANativeWindow::disconnect |
| 558 | _cur_c.release(); |
| 559 | _cur_r.release(); |
| 560 | _cur_d.release(); |
| 561 | } |
| 562 | |
Mathias Agopian | fb87e54 | 2012-01-30 18:20:52 -0800 | [diff] [blame] | 563 | return result; |
| 564 | } |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 565 | |
Jesse Hall | c2e4122 | 2013-08-08 13:40:22 -0700 | [diff] [blame] | 566 | bool egl_display_t::haveExtension(const char* name, size_t nameLen) const { |
| 567 | if (!nameLen) { |
| 568 | nameLen = strlen(name); |
| 569 | } |
Mathias Agopian | 6542143 | 2017-03-08 11:49:05 -0800 | [diff] [blame] | 570 | return findExtension(mExtensionString.c_str(), name, nameLen); |
Jesse Hall | c2e4122 | 2013-08-08 13:40:22 -0700 | [diff] [blame] | 571 | } |
| 572 | |
Jesse Hall | a0fef1c | 2012-04-17 12:02:26 -0700 | [diff] [blame] | 573 | // ---------------------------------------------------------------------------- |
Mathias Agopian | 518ec11 | 2011-05-13 16:21:08 -0700 | [diff] [blame] | 574 | }; // namespace android |
| 575 | // ---------------------------------------------------------------------------- |