Loading opengl/libs/EGL/Loader.cpp +15 −13 Original line number Original line Diff line number Diff line Loading @@ -136,30 +136,24 @@ void* Loader::open(EGLNativeDisplayType display, int impl, egl_connection_t* cnx */ */ void* dso; void* dso; char path[PATH_MAX]; int index = int(display); int index = int(display); driver_t* hnd = 0; driver_t* hnd = 0; const char* const format = "/system/lib/egl/lib%s_%s.so"; char const* tag = getTag(index, impl); char const* tag = getTag(index, impl); if (tag) { if (tag) { snprintf(path, PATH_MAX, format, "GLES", tag); dso = load_driver("GLES", tag, cnx, EGL | GLESv1_CM | GLESv2); dso = load_driver(path, cnx, EGL | GLESv1_CM | GLESv2); if (dso) { if (dso) { hnd = new driver_t(dso); hnd = new driver_t(dso); } else { } else { // Always load EGL first // Always load EGL first snprintf(path, PATH_MAX, format, "EGL", tag); dso = load_driver("EGL", tag, cnx, EGL); dso = load_driver(path, cnx, EGL); if (dso) { if (dso) { hnd = new driver_t(dso); hnd = new driver_t(dso); // TODO: make this more automated // TODO: make this more automated snprintf(path, PATH_MAX, format, "GLESv1_CM", tag); hnd->set( load_driver("GLESv1_CM", tag, cnx, GLESv1_CM), GLESv1_CM ); hnd->set( load_driver(path, cnx, GLESv1_CM), GLESv1_CM ); snprintf(path, PATH_MAX, format, "GLESv2", tag); hnd->set( load_driver("GLESv2", tag, cnx, GLESv2), GLESv2 ); hnd->set( load_driver(path, cnx, GLESv2), GLESv2 ); } } } } } } Loading Loading @@ -222,13 +216,21 @@ void Loader::init_api(void* dso, } } } } void *Loader::load_driver(const char* driver_absolute_path, void *Loader::load_driver(const char* kind, const char *tag, egl_connection_t* cnx, uint32_t mask) egl_connection_t* cnx, uint32_t mask) { { char driver_absolute_path[PATH_MAX]; const char* const search1 = "/vendor/lib/egl/lib%s_%s.so"; const char* const search2 = "/system/lib/egl/lib%s_%s.so"; snprintf(driver_absolute_path, PATH_MAX, search1, kind, tag); if (access(driver_absolute_path, R_OK)) { snprintf(driver_absolute_path, PATH_MAX, search2, kind, tag); if (access(driver_absolute_path, R_OK)) { if (access(driver_absolute_path, R_OK)) { // this happens often, we don't want to log an error // this happens often, we don't want to log an error return 0; return 0; } } } void* dso = dlopen(driver_absolute_path, RTLD_NOW | RTLD_LOCAL); void* dso = dlopen(driver_absolute_path, RTLD_NOW | RTLD_LOCAL); if (dso == 0) { if (dso == 0) { Loading opengl/libs/EGL/Loader.h +1 −1 Original line number Original line Diff line number Diff line Loading @@ -74,7 +74,7 @@ public: private: private: Loader(); Loader(); void *load_driver(const char* driver, egl_connection_t* cnx, uint32_t mask); void *load_driver(const char* kind, const char *tag, egl_connection_t* cnx, uint32_t mask); static __attribute__((noinline)) static __attribute__((noinline)) void init_api(void* dso, void init_api(void* dso, Loading Loading
opengl/libs/EGL/Loader.cpp +15 −13 Original line number Original line Diff line number Diff line Loading @@ -136,30 +136,24 @@ void* Loader::open(EGLNativeDisplayType display, int impl, egl_connection_t* cnx */ */ void* dso; void* dso; char path[PATH_MAX]; int index = int(display); int index = int(display); driver_t* hnd = 0; driver_t* hnd = 0; const char* const format = "/system/lib/egl/lib%s_%s.so"; char const* tag = getTag(index, impl); char const* tag = getTag(index, impl); if (tag) { if (tag) { snprintf(path, PATH_MAX, format, "GLES", tag); dso = load_driver("GLES", tag, cnx, EGL | GLESv1_CM | GLESv2); dso = load_driver(path, cnx, EGL | GLESv1_CM | GLESv2); if (dso) { if (dso) { hnd = new driver_t(dso); hnd = new driver_t(dso); } else { } else { // Always load EGL first // Always load EGL first snprintf(path, PATH_MAX, format, "EGL", tag); dso = load_driver("EGL", tag, cnx, EGL); dso = load_driver(path, cnx, EGL); if (dso) { if (dso) { hnd = new driver_t(dso); hnd = new driver_t(dso); // TODO: make this more automated // TODO: make this more automated snprintf(path, PATH_MAX, format, "GLESv1_CM", tag); hnd->set( load_driver("GLESv1_CM", tag, cnx, GLESv1_CM), GLESv1_CM ); hnd->set( load_driver(path, cnx, GLESv1_CM), GLESv1_CM ); snprintf(path, PATH_MAX, format, "GLESv2", tag); hnd->set( load_driver("GLESv2", tag, cnx, GLESv2), GLESv2 ); hnd->set( load_driver(path, cnx, GLESv2), GLESv2 ); } } } } } } Loading Loading @@ -222,13 +216,21 @@ void Loader::init_api(void* dso, } } } } void *Loader::load_driver(const char* driver_absolute_path, void *Loader::load_driver(const char* kind, const char *tag, egl_connection_t* cnx, uint32_t mask) egl_connection_t* cnx, uint32_t mask) { { char driver_absolute_path[PATH_MAX]; const char* const search1 = "/vendor/lib/egl/lib%s_%s.so"; const char* const search2 = "/system/lib/egl/lib%s_%s.so"; snprintf(driver_absolute_path, PATH_MAX, search1, kind, tag); if (access(driver_absolute_path, R_OK)) { snprintf(driver_absolute_path, PATH_MAX, search2, kind, tag); if (access(driver_absolute_path, R_OK)) { if (access(driver_absolute_path, R_OK)) { // this happens often, we don't want to log an error // this happens often, we don't want to log an error return 0; return 0; } } } void* dso = dlopen(driver_absolute_path, RTLD_NOW | RTLD_LOCAL); void* dso = dlopen(driver_absolute_path, RTLD_NOW | RTLD_LOCAL); if (dso == 0) { if (dso == 0) { Loading
opengl/libs/EGL/Loader.h +1 −1 Original line number Original line Diff line number Diff line Loading @@ -74,7 +74,7 @@ public: private: private: Loader(); Loader(); void *load_driver(const char* driver, egl_connection_t* cnx, uint32_t mask); void *load_driver(const char* kind, const char *tag, egl_connection_t* cnx, uint32_t mask); static __attribute__((noinline)) static __attribute__((noinline)) void init_api(void* dso, void init_api(void* dso, Loading