blob: b1ca13d1484c367b03581cc77f115ca03b4ced8b [file] [log] [blame]
Jesse Hall94cdba92013-07-11 09:40:35 -07001/*
Mathias Agopiande586972009-05-28 17:39:03 -07002 ** Copyright 2007, The Android Open Source Project
3 **
Jesse Hall94cdba92013-07-11 09:40:35 -07004 ** 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 Agopiande586972009-05-28 17:39:03 -07007 **
Jesse Hall94cdba92013-07-11 09:40:35 -07008 ** http://www.apache.org/licenses/LICENSE-2.0
Mathias Agopiande586972009-05-28 17:39:03 -07009 **
Jesse Hall94cdba92013-07-11 09:40:35 -070010 ** 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 Agopiande586972009-05-28 17:39:03 -070014 ** limitations under the License.
15 */
16
Jesse Hall7a8d83e2016-12-20 15:24:28 -080017//#define LOG_NDEBUG 0
Jesse Hall1508ae62017-01-19 17:43:26 -080018#define ATRACE_TAG ATRACE_TAG_GRAPHICS
Jesse Hall7a8d83e2016-12-20 15:24:28 -080019
20#include <array>
Mathias Agopiande586972009-05-28 17:39:03 -070021#include <ctype.h>
Mathias Agopian99381422013-04-23 20:52:29 +020022#include <dirent.h>
Mark Salyzyna5e161b2016-09-29 08:08:05 -070023#include <dlfcn.h>
24#include <errno.h>
25#include <limits.h>
26#include <stdio.h>
27#include <stdlib.h>
28#include <string.h>
Mathias Agopiande586972009-05-28 17:39:03 -070029
Jesse Hall7a8d83e2016-12-20 15:24:28 -080030#include <android/dlext.h>
David 'Digit' Turner80b30c22011-08-26 17:38:47 +020031#include <cutils/properties.h>
Mark Salyzyn7823e122016-09-29 08:08:05 -070032#include <log/log.h>
Jesse Hall1508ae62017-01-19 17:43:26 -080033#include <utils/Trace.h>
Mathias Agopian991d2542017-02-06 13:51:32 -080034#include <ui/GraphicsEnv.h>
Mathias Agopiande586972009-05-28 17:39:03 -070035
36#include <EGL/egl.h>
37
Mathias Agopian1cadb252011-05-23 17:26:14 -070038#include "egldefs.h"
Mathias Agopian1cadb252011-05-23 17:26:14 -070039#include "Loader.h"
Mathias Agopiande586972009-05-28 17:39:03 -070040
41// ----------------------------------------------------------------------------
42namespace android {
43// ----------------------------------------------------------------------------
44
45
46/*
Mathias Agopian99381422013-04-23 20:52:29 +020047 * EGL userspace drivers must be provided either:
48 * - as a single library:
49 * /vendor/lib/egl/libGLES.so
50 *
51 * - as separate libraries:
52 * /vendor/lib/egl/libEGL.so
53 * /vendor/lib/egl/libGLESv1_CM.so
54 * /vendor/lib/egl/libGLESv2.so
55 *
56 * The software renderer for the emulator must be provided as a single
57 * library at:
58 *
59 * /system/lib/egl/libGLES_android.so
60 *
61 *
62 * For backward compatibility and to facilitate the transition to
63 * this new naming scheme, the loader will additionally look for:
Jesse Hall94cdba92013-07-11 09:40:35 -070064 *
Mathias Agopian99381422013-04-23 20:52:29 +020065 * /{vendor|system}/lib/egl/lib{GLES | [EGL|GLESv1_CM|GLESv2]}_*.so
Jesse Hall94cdba92013-07-11 09:40:35 -070066 *
Mathias Agopiande586972009-05-28 17:39:03 -070067 */
68
69ANDROID_SINGLETON_STATIC_INSTANCE( Loader )
70
David 'Digit' Turner80b30c22011-08-26 17:38:47 +020071/* This function is called to check whether we run inside the emulator,
72 * and if this is the case whether GLES GPU emulation is supported.
73 *
74 * Returned values are:
75 * -1 -> not running inside the emulator
76 * 0 -> running inside the emulator, but GPU emulation not supported
77 * 1 -> running inside the emulator, GPU emulation is supported
Nicolas Capens776951f2015-11-06 10:10:21 -050078 * through the "emulation" host-side OpenGL ES implementation.
79 * 2 -> running inside the emulator, GPU emulation is supported
80 * through a guest-side vendor driver's OpenGL ES implementation.
David 'Digit' Turner80b30c22011-08-26 17:38:47 +020081 */
82static int
83checkGlesEmulationStatus(void)
84{
85 /* We're going to check for the following kernel parameters:
86 *
87 * qemu=1 -> tells us that we run inside the emulator
88 * android.qemu.gles=<number> -> tells us the GLES GPU emulation status
89 *
90 * Note that we will return <number> if we find it. This let us support
91 * more additionnal emulation modes in the future.
92 */
93 char prop[PROPERTY_VALUE_MAX];
94 int result = -1;
95
96 /* First, check for qemu=1 */
97 property_get("ro.kernel.qemu",prop,"0");
98 if (atoi(prop) != 1)
99 return -1;
100
101 /* We are in the emulator, get GPU status value */
bohu69e5b1a2016-02-19 17:15:20 -0800102 property_get("qemu.gles",prop,"0");
David 'Digit' Turner80b30c22011-08-26 17:38:47 +0200103 return atoi(prop);
104}
105
Jesse Hall1508ae62017-01-19 17:43:26 -0800106static void* do_dlopen(const char* path, int mode) {
107 ATRACE_CALL();
108 return dlopen(path, mode);
109}
110
Mathias Agopiande586972009-05-28 17:39:03 -0700111// ----------------------------------------------------------------------------
112
Jesse Hall94cdba92013-07-11 09:40:35 -0700113Loader::driver_t::driver_t(void* gles)
Mathias Agopiande586972009-05-28 17:39:03 -0700114{
115 dso[0] = gles;
116 for (size_t i=1 ; i<NELEM(dso) ; i++)
117 dso[i] = 0;
118}
119
Jesse Hall94cdba92013-07-11 09:40:35 -0700120Loader::driver_t::~driver_t()
Mathias Agopiande586972009-05-28 17:39:03 -0700121{
122 for (size_t i=0 ; i<NELEM(dso) ; i++) {
123 if (dso[i]) {
124 dlclose(dso[i]);
125 dso[i] = 0;
126 }
127 }
128}
129
130status_t Loader::driver_t::set(void* hnd, int32_t api)
131{
132 switch (api) {
133 case EGL:
134 dso[0] = hnd;
135 break;
136 case GLESv1_CM:
137 dso[1] = hnd;
138 break;
139 case GLESv2:
140 dso[2] = hnd;
141 break;
142 default:
143 return BAD_INDEX;
144 }
145 return NO_ERROR;
146}
147
148// ----------------------------------------------------------------------------
149
Mathias Agopiande586972009-05-28 17:39:03 -0700150Loader::Loader()
Mathias Agopian991d2542017-02-06 13:51:32 -0800151 : getProcAddress(NULL)
Jesse Hall7a8d83e2016-12-20 15:24:28 -0800152{
Mathias Agopiande586972009-05-28 17:39:03 -0700153}
154
Mathias Agopian99381422013-04-23 20:52:29 +0200155Loader::~Loader() {
Mathias Agopiande586972009-05-28 17:39:03 -0700156}
157
Jesse Hallc07b5202013-07-04 12:08:16 -0700158static void* load_wrapper(const char* path) {
Jesse Hall1508ae62017-01-19 17:43:26 -0800159 void* so = do_dlopen(path, RTLD_NOW | RTLD_LOCAL);
Jesse Hallc07b5202013-07-04 12:08:16 -0700160 ALOGE_IF(!so, "dlopen(\"%s\") failed: %s", path, dlerror());
161 return so;
162}
163
Evgenii Stepanovc2466e62015-07-08 15:49:52 -0700164#ifndef EGL_WRAPPER_DIR
165#if defined(__LP64__)
166#define EGL_WRAPPER_DIR "/system/lib64"
167#else
168#define EGL_WRAPPER_DIR "/system/lib"
169#endif
170#endif
171
bohu69e5b1a2016-02-19 17:15:20 -0800172static void setEmulatorGlesValue(void) {
173 char prop[PROPERTY_VALUE_MAX];
174 property_get("ro.kernel.qemu", prop, "0");
175 if (atoi(prop) != 1) return;
176
177 property_get("ro.kernel.qemu.gles",prop,"0");
178 if (atoi(prop) == 1) {
179 ALOGD("Emulator has host GPU support, qemu.gles is set to 1.");
180 property_set("qemu.gles", "1");
181 return;
182 }
183
184 // for now, checking the following
185 // directory is good enough for emulator system images
186 const char* vendor_lib_path =
187#if defined(__LP64__)
188 "/vendor/lib64/egl";
189#else
190 "/vendor/lib/egl";
191#endif
192
193 const bool has_vendor_lib = (access(vendor_lib_path, R_OK) == 0);
194 if (has_vendor_lib) {
195 ALOGD("Emulator has vendor provided software renderer, qemu.gles is set to 2.");
196 property_set("qemu.gles", "2");
197 } else {
198 ALOGD("Emulator without GPU support detected. "
199 "Fallback to legacy software renderer, qemu.gles is set to 0.");
200 property_set("qemu.gles", "0");
201 }
202}
203
Mathias Agopianada798b2012-02-13 17:09:30 -0800204void* Loader::open(egl_connection_t* cnx)
Mathias Agopiande586972009-05-28 17:39:03 -0700205{
Jesse Hall1508ae62017-01-19 17:43:26 -0800206 ATRACE_CALL();
207
Mathias Agopiande586972009-05-28 17:39:03 -0700208 void* dso;
Mathias Agopiande586972009-05-28 17:39:03 -0700209 driver_t* hnd = 0;
Jesse Hall94cdba92013-07-11 09:40:35 -0700210
bohu69e5b1a2016-02-19 17:15:20 -0800211 setEmulatorGlesValue();
212
Mathias Agopian99381422013-04-23 20:52:29 +0200213 dso = load_driver("GLES", cnx, EGL | GLESv1_CM | GLESv2);
214 if (dso) {
215 hnd = new driver_t(dso);
216 } else {
217 // Always load EGL first
218 dso = load_driver("EGL", cnx, EGL);
Mathias Agopiande586972009-05-28 17:39:03 -0700219 if (dso) {
220 hnd = new driver_t(dso);
Mathias Agopian99381422013-04-23 20:52:29 +0200221 hnd->set( load_driver("GLESv1_CM", cnx, GLESv1_CM), GLESv1_CM );
222 hnd->set( load_driver("GLESv2", cnx, GLESv2), GLESv2 );
Mathias Agopiande586972009-05-28 17:39:03 -0700223 }
224 }
225
Mathias Agopian99381422013-04-23 20:52:29 +0200226 LOG_ALWAYS_FATAL_IF(!hnd, "couldn't find an OpenGL ES implementation");
Jesse Hallc07b5202013-07-04 12:08:16 -0700227
Evgenii Stepanovc2466e62015-07-08 15:49:52 -0700228 cnx->libEgl = load_wrapper(EGL_WRAPPER_DIR "/libEGL.so");
229 cnx->libGles2 = load_wrapper(EGL_WRAPPER_DIR "/libGLESv2.so");
230 cnx->libGles1 = load_wrapper(EGL_WRAPPER_DIR "/libGLESv1_CM.so");
231
Michael Chockc0ec5e22014-01-27 08:14:33 -0800232 LOG_ALWAYS_FATAL_IF(!cnx->libEgl,
233 "couldn't load system EGL wrapper libraries");
234
Jesse Hallc07b5202013-07-04 12:08:16 -0700235 LOG_ALWAYS_FATAL_IF(!cnx->libGles2 || !cnx->libGles1,
236 "couldn't load system OpenGL ES wrapper libraries");
237
Mathias Agopiande586972009-05-28 17:39:03 -0700238 return (void*)hnd;
239}
240
241status_t Loader::close(void* driver)
242{
243 driver_t* hnd = (driver_t*)driver;
244 delete hnd;
245 return NO_ERROR;
246}
247
Jesse Hall94cdba92013-07-11 09:40:35 -0700248void Loader::init_api(void* dso,
249 char const * const * api,
250 __eglMustCastToProperFunctionPointerType* curr,
251 getProcAddressType getProcAddress)
Mathias Agopiande586972009-05-28 17:39:03 -0700252{
Jesse Hall1508ae62017-01-19 17:43:26 -0800253 ATRACE_CALL();
254
Mathias Agopian7773c432012-02-13 20:06:08 -0800255 const ssize_t SIZE = 256;
Mathias Agopian0ad71a92011-05-11 20:37:47 -0700256 char scrap[SIZE];
Mathias Agopiande586972009-05-28 17:39:03 -0700257 while (*api) {
258 char const * name = *api;
Jesse Hall94cdba92013-07-11 09:40:35 -0700259 __eglMustCastToProperFunctionPointerType f =
Mathias Agopiande586972009-05-28 17:39:03 -0700260 (__eglMustCastToProperFunctionPointerType)dlsym(dso, name);
261 if (f == NULL) {
262 // couldn't find the entry-point, use eglGetProcAddress()
263 f = getProcAddress(name);
264 }
265 if (f == NULL) {
266 // Try without the OES postfix
267 ssize_t index = ssize_t(strlen(name)) - 3;
Mathias Agopian0ad71a92011-05-11 20:37:47 -0700268 if ((index>0 && (index<SIZE-1)) && (!strcmp(name+index, "OES"))) {
Mathias Agopiande586972009-05-28 17:39:03 -0700269 strncpy(scrap, name, index);
270 scrap[index] = 0;
271 f = (__eglMustCastToProperFunctionPointerType)dlsym(dso, scrap);
Steve Block9d453682011-12-20 16:23:08 +0000272 //ALOGD_IF(f, "found <%s> instead", scrap);
Mathias Agopiande586972009-05-28 17:39:03 -0700273 }
274 }
275 if (f == NULL) {
276 // Try with the OES postfix
Mathias Agopian0ad71a92011-05-11 20:37:47 -0700277 ssize_t index = ssize_t(strlen(name)) - 3;
278 if (index>0 && strcmp(name+index, "OES")) {
279 snprintf(scrap, SIZE, "%sOES", name);
Mathias Agopiande586972009-05-28 17:39:03 -0700280 f = (__eglMustCastToProperFunctionPointerType)dlsym(dso, scrap);
Steve Block9d453682011-12-20 16:23:08 +0000281 //ALOGD_IF(f, "found <%s> instead", scrap);
Mathias Agopiande586972009-05-28 17:39:03 -0700282 }
283 }
284 if (f == NULL) {
Steve Block9d453682011-12-20 16:23:08 +0000285 //ALOGD("%s", name);
Mathias Agopiande586972009-05-28 17:39:03 -0700286 f = (__eglMustCastToProperFunctionPointerType)gl_unimplemented;
Mathias Agopian48d438d2012-01-28 21:44:00 -0800287
288 /*
289 * GL_EXT_debug_label is special, we always report it as
290 * supported, it's handled by GLES_trace. If GLES_trace is not
291 * enabled, then these are no-ops.
292 */
293 if (!strcmp(name, "glInsertEventMarkerEXT")) {
294 f = (__eglMustCastToProperFunctionPointerType)gl_noop;
295 } else if (!strcmp(name, "glPushGroupMarkerEXT")) {
296 f = (__eglMustCastToProperFunctionPointerType)gl_noop;
297 } else if (!strcmp(name, "glPopGroupMarkerEXT")) {
298 f = (__eglMustCastToProperFunctionPointerType)gl_noop;
299 }
Mathias Agopiande586972009-05-28 17:39:03 -0700300 }
301 *curr++ = f;
302 api++;
303 }
304}
305
Jesse Hall7a8d83e2016-12-20 15:24:28 -0800306static void* load_system_driver(const char* kind) {
Jesse Hall1508ae62017-01-19 17:43:26 -0800307 ATRACE_CALL();
Mathias Agopian99381422013-04-23 20:52:29 +0200308 class MatchFile {
309 public:
310 static String8 find(const char* kind) {
311 String8 result;
Nicolas Capens776951f2015-11-06 10:10:21 -0500312 int emulationStatus = checkGlesEmulationStatus();
313 switch (emulationStatus) {
314 case 0:
Nicolas Capens776951f2015-11-06 10:10:21 -0500315#if defined(__LP64__)
316 result.setTo("/system/lib64/egl/libGLES_android.so");
317#else
318 result.setTo("/system/lib/egl/libGLES_android.so");
319#endif
320 return result;
321 case 1:
322 // Use host-side OpenGL through the "emulation" library
323#if defined(__LP64__)
324 result.appendFormat("/system/lib64/egl/lib%s_emulation.so", kind);
325#else
326 result.appendFormat("/system/lib/egl/lib%s_emulation.so", kind);
327#endif
328 return result;
329 default:
330 // Not in emulator, or use other guest-side implementation
331 break;
332 }
333
Mathias Agopian99381422013-04-23 20:52:29 +0200334 String8 pattern;
335 pattern.appendFormat("lib%s", kind);
336 const char* const searchPaths[] = {
Dan Willemsen8edb8f52014-02-16 10:23:54 -0800337#if defined(__LP64__)
338 "/vendor/lib64/egl",
339 "/system/lib64/egl"
340#else
Mathias Agopian99381422013-04-23 20:52:29 +0200341 "/vendor/lib/egl",
342 "/system/lib/egl"
Dan Willemsen8edb8f52014-02-16 10:23:54 -0800343#endif
Mathias Agopian99381422013-04-23 20:52:29 +0200344 };
Brian Swetland2b9e4f62010-09-20 12:58:15 -0700345
Mathias Agopian99381422013-04-23 20:52:29 +0200346 // first, we search for the exact name of the GLES userspace
347 // driver in both locations.
348 // i.e.:
349 // libGLES.so, or:
350 // libEGL.so, libGLESv1_CM.so, libGLESv2.so
351
352 for (size_t i=0 ; i<NELEM(searchPaths) ; i++) {
353 if (find(result, pattern, searchPaths[i], true)) {
354 return result;
355 }
356 }
357
358 // for compatibility with the old "egl.cfg" naming convention
359 // we look for files that match:
360 // libGLES_*.so, or:
361 // libEGL_*.so, libGLESv1_CM_*.so, libGLESv2_*.so
362
363 pattern.append("_");
364 for (size_t i=0 ; i<NELEM(searchPaths) ; i++) {
365 if (find(result, pattern, searchPaths[i], false)) {
366 return result;
367 }
368 }
369
370 // we didn't find the driver. gah.
371 result.clear();
372 return result;
Brian Swetland2b9e4f62010-09-20 12:58:15 -0700373 }
Mathias Agopian99381422013-04-23 20:52:29 +0200374
375 private:
376 static bool find(String8& result,
377 const String8& pattern, const char* const search, bool exact) {
Mathias Agopian99381422013-04-23 20:52:29 +0200378 if (exact) {
379 String8 absolutePath;
380 absolutePath.appendFormat("%s/%s.so", search, pattern.string());
381 if (!access(absolutePath.string(), R_OK)) {
382 result = absolutePath;
383 return true;
384 }
385 return false;
386 }
387
388 DIR* d = opendir(search);
389 if (d != NULL) {
390 struct dirent cur;
391 struct dirent* e;
392 while (readdir_r(d, &cur, &e) == 0 && e) {
393 if (e->d_type == DT_DIR) {
394 continue;
395 }
396 if (!strcmp(e->d_name, "libGLES_android.so")) {
397 // always skip the software renderer
398 continue;
399 }
400 if (strstr(e->d_name, pattern.string()) == e->d_name) {
401 if (!strcmp(e->d_name + strlen(e->d_name) - 3, ".so")) {
402 result.clear();
403 result.appendFormat("%s/%s", search, e->d_name);
404 closedir(d);
405 return true;
406 }
407 }
408 }
409 closedir(d);
410 }
411 return false;
412 }
413 };
414
415
416 String8 absolutePath = MatchFile::find(kind);
417 if (absolutePath.isEmpty()) {
418 // this happens often, we don't want to log an error
419 return 0;
Mathias Agopian8c173842009-09-20 16:01:02 -0700420 }
Mathias Agopian99381422013-04-23 20:52:29 +0200421 const char* const driver_absolute_path = absolutePath.string();
Mathias Agopiande586972009-05-28 17:39:03 -0700422
Jesse Hall1508ae62017-01-19 17:43:26 -0800423 void* dso = do_dlopen(driver_absolute_path, RTLD_NOW | RTLD_LOCAL);
Mathias Agopian8c173842009-09-20 16:01:02 -0700424 if (dso == 0) {
425 const char* err = dlerror();
Steve Blocke6f43dd2012-01-06 19:20:56 +0000426 ALOGE("load_driver(%s): %s", driver_absolute_path, err?err:"unknown");
Mathias Agopian8c173842009-09-20 16:01:02 -0700427 return 0;
428 }
429
Steve Block9d453682011-12-20 16:23:08 +0000430 ALOGD("loaded %s", driver_absolute_path);
Mathias Agopianbaca89c2009-08-20 19:09:34 -0700431
Jesse Hall7a8d83e2016-12-20 15:24:28 -0800432 return dso;
433}
434
Jesse Hall1508ae62017-01-19 17:43:26 -0800435static void* do_android_dlopen_ext(const char* path, int mode, const android_dlextinfo* info) {
436 ATRACE_CALL();
437 return android_dlopen_ext(path, mode, info);
438}
439
Jesse Hall7a8d83e2016-12-20 15:24:28 -0800440static const std::array<const char*, 2> HAL_SUBNAME_KEY_PROPERTIES = {{
441 "ro.hardware.egl",
442 "ro.board.platform",
443}};
444
445static void* load_updated_driver(const char* kind, android_namespace_t* ns) {
Jesse Hall1508ae62017-01-19 17:43:26 -0800446 ATRACE_CALL();
Jesse Hall7a8d83e2016-12-20 15:24:28 -0800447 const android_dlextinfo dlextinfo = {
448 .flags = ANDROID_DLEXT_USE_NAMESPACE,
449 .library_namespace = ns,
450 };
451 void* so = nullptr;
452 char prop[PROPERTY_VALUE_MAX + 1];
453 for (auto key : HAL_SUBNAME_KEY_PROPERTIES) {
454 if (property_get(key, prop, nullptr) > 0) {
455 String8 name;
456 name.appendFormat("lib%s_%s.so", kind, prop);
Jesse Hall1508ae62017-01-19 17:43:26 -0800457 so = do_android_dlopen_ext(name.string(), RTLD_LOCAL | RTLD_NOW,
Jesse Hall7a8d83e2016-12-20 15:24:28 -0800458 &dlextinfo);
459 if (so)
460 return so;
461 }
462 }
463 return nullptr;
464}
465
466void *Loader::load_driver(const char* kind,
467 egl_connection_t* cnx, uint32_t mask)
468{
Jesse Hall1508ae62017-01-19 17:43:26 -0800469 ATRACE_CALL();
470
Jesse Hall7a8d83e2016-12-20 15:24:28 -0800471 void* dso = nullptr;
Mathias Agopian991d2542017-02-06 13:51:32 -0800472 android_namespace_t* ns = android_getDriverNamespace();
473 if (ns) {
474 dso = load_updated_driver(kind, ns);
Jesse Hall7a8d83e2016-12-20 15:24:28 -0800475 }
476 if (!dso) {
477 dso = load_system_driver(kind);
478 if (!dso)
479 return NULL;
480 }
481
Mathias Agopiande586972009-05-28 17:39:03 -0700482 if (mask & EGL) {
483 getProcAddress = (getProcAddressType)dlsym(dso, "eglGetProcAddress");
484
Jesse Hall94cdba92013-07-11 09:40:35 -0700485 ALOGE_IF(!getProcAddress,
Jesse Hall7a8d83e2016-12-20 15:24:28 -0800486 "can't find eglGetProcAddress() in EGL driver library");
Mathias Agopiande586972009-05-28 17:39:03 -0700487
Mathias Agopian618fa102009-10-14 02:06:37 -0700488 egl_t* egl = &cnx->egl;
Mathias Agopiande586972009-05-28 17:39:03 -0700489 __eglMustCastToProperFunctionPointerType* curr =
490 (__eglMustCastToProperFunctionPointerType*)egl;
491 char const * const * api = egl_names;
492 while (*api) {
493 char const * name = *api;
Jesse Hall94cdba92013-07-11 09:40:35 -0700494 __eglMustCastToProperFunctionPointerType f =
Mathias Agopiande586972009-05-28 17:39:03 -0700495 (__eglMustCastToProperFunctionPointerType)dlsym(dso, name);
496 if (f == NULL) {
497 // couldn't find the entry-point, use eglGetProcAddress()
498 f = getProcAddress(name);
499 if (f == NULL) {
500 f = (__eglMustCastToProperFunctionPointerType)0;
501 }
502 }
503 *curr++ = f;
504 api++;
505 }
506 }
Jesse Hall94cdba92013-07-11 09:40:35 -0700507
Mathias Agopiande586972009-05-28 17:39:03 -0700508 if (mask & GLESv1_CM) {
Mathias Agopian618fa102009-10-14 02:06:37 -0700509 init_api(dso, gl_names,
510 (__eglMustCastToProperFunctionPointerType*)
Mathias Agopian7773c432012-02-13 20:06:08 -0800511 &cnx->hooks[egl_connection_t::GLESv1_INDEX]->gl,
Mathias Agopian618fa102009-10-14 02:06:37 -0700512 getProcAddress);
Mathias Agopiande586972009-05-28 17:39:03 -0700513 }
514
515 if (mask & GLESv2) {
Mathias Agopian618fa102009-10-14 02:06:37 -0700516 init_api(dso, gl_names,
517 (__eglMustCastToProperFunctionPointerType*)
Mathias Agopian7773c432012-02-13 20:06:08 -0800518 &cnx->hooks[egl_connection_t::GLESv2_INDEX]->gl,
Mathias Agopiande586972009-05-28 17:39:03 -0700519 getProcAddress);
520 }
Jesse Hall94cdba92013-07-11 09:40:35 -0700521
Mathias Agopiande586972009-05-28 17:39:03 -0700522 return dso;
523}
524
525// ----------------------------------------------------------------------------
526}; // namespace android
527// ----------------------------------------------------------------------------