Loading opengl/libs/EGL/egl_angle_platform.cpp +73 −20 Original line number Diff line number Diff line Loading @@ -16,28 +16,29 @@ #if defined(__ANDROID__) #include <cutils/properties.h> #include "Loader.h" #include "egl_angle_platform.h" #include <time.h> #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" #include <EGL/Platform.h> #pragma GCC diagnostic pop #include <android/dlext.h> #include <dlfcn.h> #include <graphicsenv/GraphicsEnv.h> #include <time.h> #include <log/log.h> namespace angle { GetDisplayPlatformFunc AnglePlatformImpl::angleGetDisplayPlatform = nullptr; ResetDisplayPlatformFunc AnglePlatformImpl::angleResetDisplayPlatform = nullptr; // Initialize start time time_t AnglePlatformImpl::startTime = time(nullptr); static GetDisplayPlatformFunc angleGetDisplayPlatform = nullptr; static ResetDisplayPlatformFunc angleResetDisplayPlatform = nullptr; void AnglePlatformImpl::assignAnglePlatformMethods(PlatformMethods* platformMethods) { platformMethods->addTraceEvent = addTraceEvent; platformMethods->getTraceCategoryEnabledFlag = getTraceCategoryEnabledFlag; platformMethods->monotonicallyIncreasingTime = monotonicallyIncreasingTime; platformMethods->logError = logError; platformMethods->logWarning = logWarning; platformMethods->logInfo = logInfo; } static time_t startTime = time(nullptr); const unsigned char* AnglePlatformImpl::getTraceCategoryEnabledFlag(PlatformMethods* /*platform*/, static const unsigned char* getTraceCategoryEnabledFlag(PlatformMethods* /*platform*/, const char* /*categoryName*/) { // Returning ptr to 'g' (non-zero) to ALWAYS enable tracing initially. // This ptr is what will be passed into "category_group_enabled" of addTraceEvent Loading @@ -45,23 +46,23 @@ const unsigned char* AnglePlatformImpl::getTraceCategoryEnabledFlag(PlatformMeth return &traceEnabled; } double AnglePlatformImpl::monotonicallyIncreasingTime(PlatformMethods* /*platform*/) { static double monotonicallyIncreasingTime(PlatformMethods* /*platform*/) { return difftime(time(nullptr), startTime); } void AnglePlatformImpl::logError(PlatformMethods* /*platform*/, const char* errorMessage) { static void logError(PlatformMethods* /*platform*/, const char* errorMessage) { ALOGE("ANGLE Error:%s", errorMessage); } void AnglePlatformImpl::logWarning(PlatformMethods* /*platform*/, const char* warningMessage) { static void logWarning(PlatformMethods* /*platform*/, const char* warningMessage) { ALOGW("ANGLE Warn:%s", warningMessage); } void AnglePlatformImpl::logInfo(PlatformMethods* /*platform*/, const char* infoMessage) { static void logInfo(PlatformMethods* /*platform*/, const char* infoMessage) { ALOGD("ANGLE Info:%s", infoMessage); } TraceEventHandle AnglePlatformImpl::addTraceEvent( static TraceEventHandle addTraceEvent( PlatformMethods* /**platform*/, char phase, const unsigned char* /*category_group_enabled*/, const char* name, unsigned long long /*id*/, double /*timestamp*/, int /*num_args*/, const char** /*arg_names*/, const unsigned char* /*arg_types*/, Loading @@ -88,6 +89,58 @@ TraceEventHandle AnglePlatformImpl::addTraceEvent( return result; } static void assignAnglePlatformMethods(PlatformMethods* platformMethods) { platformMethods->addTraceEvent = addTraceEvent; platformMethods->getTraceCategoryEnabledFlag = getTraceCategoryEnabledFlag; platformMethods->monotonicallyIncreasingTime = monotonicallyIncreasingTime; platformMethods->logError = logError; platformMethods->logWarning = logWarning; platformMethods->logInfo = logInfo; } // Initialize function ptrs for ANGLE PlatformMethods struct, used for systrace bool initializeAnglePlatform(EGLDisplay dpy) { // Since we're inside libEGL, use dlsym to lookup fptr for ANGLEGetDisplayPlatform android_namespace_t* ns = android::GraphicsEnv::getInstance().getAngleNamespace(); const android_dlextinfo dlextinfo = { .flags = ANDROID_DLEXT_USE_NAMESPACE, .library_namespace = ns, }; void* so = android_dlopen_ext("libEGL_angle.so", RTLD_LOCAL | RTLD_NOW, &dlextinfo); angleGetDisplayPlatform = reinterpret_cast<GetDisplayPlatformFunc>(dlsym(so, "ANGLEGetDisplayPlatform")); if (!angleGetDisplayPlatform) { ALOGE("dlsym lookup of ANGLEGetDisplayPlatform in libEGL_angle failed!"); return false; } angleResetDisplayPlatform = reinterpret_cast<ResetDisplayPlatformFunc>( eglGetProcAddress("ANGLEResetDisplayPlatform")); PlatformMethods* platformMethods = nullptr; if (!((angleGetDisplayPlatform)(dpy, g_PlatformMethodNames, g_NumPlatformMethods, nullptr, &platformMethods))) { ALOGE("ANGLEGetDisplayPlatform call failed!"); return false; } if (platformMethods) { assignAnglePlatformMethods(platformMethods); } else { ALOGE("In initializeAnglePlatform() platformMethods struct ptr is NULL. Not assigning " "tracing function ptrs!"); } return true; } void resetAnglePlatform(EGLDisplay dpy) { if (angleResetDisplayPlatform) { angleResetDisplayPlatform(dpy); } } }; // namespace angle #endif // __ANDROID__ opengl/libs/EGL/egl_angle_platform.h +3 −28 Original line number Diff line number Diff line Loading @@ -18,40 +18,15 @@ #if defined(__ANDROID__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" #include <EGL/Platform.h> #pragma GCC diagnostic pop #include "egldefs.h" #define ATRACE_TAG ATRACE_TAG_GRAPHICS #include "egl_trace.h" namespace angle { class AnglePlatformImpl { public: static void assignAnglePlatformMethods(PlatformMethods* platformMethods); static GetDisplayPlatformFunc angleGetDisplayPlatform; static ResetDisplayPlatformFunc angleResetDisplayPlatform; private: static time_t startTime; static const unsigned char* getTraceCategoryEnabledFlag(PlatformMethods* /*platform*/, const char* /*categoryName*/); static double monotonicallyIncreasingTime(PlatformMethods* /*platform*/); static void logError(PlatformMethods* /*platform*/, const char* errorMessage); static void logWarning(PlatformMethods* /*platform*/, const char* warningMessage); static void logInfo(PlatformMethods* /*platform*/, const char* infoMessage); static TraceEventHandle addTraceEvent(PlatformMethods* /**platform*/, char phase, const unsigned char* /*category_group_enabled*/, const char* name, unsigned long long /*id*/, double /*timestamp*/, int /*num_args*/, const char** /*arg_names*/, const unsigned char* /*arg_types*/, const unsigned long long* /*arg_values*/, unsigned char /*flags*/); }; bool initializeAnglePlatform(EGLDisplay dpy); void resetAnglePlatform(EGLDisplay dpy); }; // namespace angle Loading opengl/libs/EGL/egl_display.cpp +3 −40 Original line number Diff line number Diff line Loading @@ -164,43 +164,6 @@ static bool addAnglePlatformAttributes(egl_connection_t* const cnx, return true; } // Initialize function ptrs for ANGLE PlatformMethods struct, used for systrace bool initializeAnglePlatform(EGLDisplay dpy) { // Since we're inside libEGL, use dlsym to lookup fptr for ANGLEGetDisplayPlatform android_namespace_t* ns = android::GraphicsEnv::getInstance().getAngleNamespace(); const android_dlextinfo dlextinfo = { .flags = ANDROID_DLEXT_USE_NAMESPACE, .library_namespace = ns, }; void* so = android_dlopen_ext("libEGL_angle.so", RTLD_LOCAL | RTLD_NOW, &dlextinfo); angle::AnglePlatformImpl::angleGetDisplayPlatform = reinterpret_cast<angle::GetDisplayPlatformFunc>(dlsym(so, "ANGLEGetDisplayPlatform")); if (!angle::AnglePlatformImpl::angleGetDisplayPlatform) { ALOGE("dlsym lookup of ANGLEGetDisplayPlatform in libEGL_angle failed!"); return false; } angle::AnglePlatformImpl::angleResetDisplayPlatform = reinterpret_cast<angle::ResetDisplayPlatformFunc>( eglGetProcAddress("ANGLEResetDisplayPlatform")); angle::PlatformMethods* platformMethods = nullptr; if (!((angle::AnglePlatformImpl::angleGetDisplayPlatform)(dpy, angle::g_PlatformMethodNames, angle::g_NumPlatformMethods, nullptr, &platformMethods))) { ALOGE("ANGLEGetDisplayPlatform call failed!"); return false; } if (platformMethods) { angle::AnglePlatformImpl::assignAnglePlatformMethods(platformMethods); } else { ALOGE("In initializeAnglePlatform() platformMethods struct ptr is NULL. Not assigning " "tracing function ptrs!"); } return true; } static EGLDisplay getPlatformDisplayAngle(EGLNativeDisplayType display, egl_connection_t* const cnx, const EGLAttrib* attrib_list, EGLint* error) { EGLDisplay dpy = EGL_NO_DISPLAY; Loading Loading @@ -228,7 +191,7 @@ static EGLDisplay getPlatformDisplayAngle(EGLNativeDisplayType display, egl_conn if (dpy == EGL_NO_DISPLAY) { ALOGE("eglGetPlatformDisplay failed!"); } else { if (!initializeAnglePlatform(dpy)) { if (!angle::initializeAnglePlatform(dpy)) { ALOGE("initializeAnglePlatform failed!"); } } Loading Loading @@ -505,8 +468,8 @@ EGLBoolean egl_display_t::terminate() { egl_connection_t* const cnx = &gEGLImpl; if (cnx->dso && disp.state == egl_display_t::INITIALIZED) { // If we're using ANGLE reset any custom DisplayPlatform if (cnx->useAngle && angle::AnglePlatformImpl::angleResetDisplayPlatform) { (angle::AnglePlatformImpl::angleResetDisplayPlatform)(disp.dpy); if (cnx->useAngle) { angle::resetAnglePlatform(disp.dpy); } if (cnx->egl.eglTerminate(disp.dpy) == EGL_FALSE) { ALOGW("eglTerminate(%p) failed (%s)", disp.dpy, Loading Loading
opengl/libs/EGL/egl_angle_platform.cpp +73 −20 Original line number Diff line number Diff line Loading @@ -16,28 +16,29 @@ #if defined(__ANDROID__) #include <cutils/properties.h> #include "Loader.h" #include "egl_angle_platform.h" #include <time.h> #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" #include <EGL/Platform.h> #pragma GCC diagnostic pop #include <android/dlext.h> #include <dlfcn.h> #include <graphicsenv/GraphicsEnv.h> #include <time.h> #include <log/log.h> namespace angle { GetDisplayPlatformFunc AnglePlatformImpl::angleGetDisplayPlatform = nullptr; ResetDisplayPlatformFunc AnglePlatformImpl::angleResetDisplayPlatform = nullptr; // Initialize start time time_t AnglePlatformImpl::startTime = time(nullptr); static GetDisplayPlatformFunc angleGetDisplayPlatform = nullptr; static ResetDisplayPlatformFunc angleResetDisplayPlatform = nullptr; void AnglePlatformImpl::assignAnglePlatformMethods(PlatformMethods* platformMethods) { platformMethods->addTraceEvent = addTraceEvent; platformMethods->getTraceCategoryEnabledFlag = getTraceCategoryEnabledFlag; platformMethods->monotonicallyIncreasingTime = monotonicallyIncreasingTime; platformMethods->logError = logError; platformMethods->logWarning = logWarning; platformMethods->logInfo = logInfo; } static time_t startTime = time(nullptr); const unsigned char* AnglePlatformImpl::getTraceCategoryEnabledFlag(PlatformMethods* /*platform*/, static const unsigned char* getTraceCategoryEnabledFlag(PlatformMethods* /*platform*/, const char* /*categoryName*/) { // Returning ptr to 'g' (non-zero) to ALWAYS enable tracing initially. // This ptr is what will be passed into "category_group_enabled" of addTraceEvent Loading @@ -45,23 +46,23 @@ const unsigned char* AnglePlatformImpl::getTraceCategoryEnabledFlag(PlatformMeth return &traceEnabled; } double AnglePlatformImpl::monotonicallyIncreasingTime(PlatformMethods* /*platform*/) { static double monotonicallyIncreasingTime(PlatformMethods* /*platform*/) { return difftime(time(nullptr), startTime); } void AnglePlatformImpl::logError(PlatformMethods* /*platform*/, const char* errorMessage) { static void logError(PlatformMethods* /*platform*/, const char* errorMessage) { ALOGE("ANGLE Error:%s", errorMessage); } void AnglePlatformImpl::logWarning(PlatformMethods* /*platform*/, const char* warningMessage) { static void logWarning(PlatformMethods* /*platform*/, const char* warningMessage) { ALOGW("ANGLE Warn:%s", warningMessage); } void AnglePlatformImpl::logInfo(PlatformMethods* /*platform*/, const char* infoMessage) { static void logInfo(PlatformMethods* /*platform*/, const char* infoMessage) { ALOGD("ANGLE Info:%s", infoMessage); } TraceEventHandle AnglePlatformImpl::addTraceEvent( static TraceEventHandle addTraceEvent( PlatformMethods* /**platform*/, char phase, const unsigned char* /*category_group_enabled*/, const char* name, unsigned long long /*id*/, double /*timestamp*/, int /*num_args*/, const char** /*arg_names*/, const unsigned char* /*arg_types*/, Loading @@ -88,6 +89,58 @@ TraceEventHandle AnglePlatformImpl::addTraceEvent( return result; } static void assignAnglePlatformMethods(PlatformMethods* platformMethods) { platformMethods->addTraceEvent = addTraceEvent; platformMethods->getTraceCategoryEnabledFlag = getTraceCategoryEnabledFlag; platformMethods->monotonicallyIncreasingTime = monotonicallyIncreasingTime; platformMethods->logError = logError; platformMethods->logWarning = logWarning; platformMethods->logInfo = logInfo; } // Initialize function ptrs for ANGLE PlatformMethods struct, used for systrace bool initializeAnglePlatform(EGLDisplay dpy) { // Since we're inside libEGL, use dlsym to lookup fptr for ANGLEGetDisplayPlatform android_namespace_t* ns = android::GraphicsEnv::getInstance().getAngleNamespace(); const android_dlextinfo dlextinfo = { .flags = ANDROID_DLEXT_USE_NAMESPACE, .library_namespace = ns, }; void* so = android_dlopen_ext("libEGL_angle.so", RTLD_LOCAL | RTLD_NOW, &dlextinfo); angleGetDisplayPlatform = reinterpret_cast<GetDisplayPlatformFunc>(dlsym(so, "ANGLEGetDisplayPlatform")); if (!angleGetDisplayPlatform) { ALOGE("dlsym lookup of ANGLEGetDisplayPlatform in libEGL_angle failed!"); return false; } angleResetDisplayPlatform = reinterpret_cast<ResetDisplayPlatformFunc>( eglGetProcAddress("ANGLEResetDisplayPlatform")); PlatformMethods* platformMethods = nullptr; if (!((angleGetDisplayPlatform)(dpy, g_PlatformMethodNames, g_NumPlatformMethods, nullptr, &platformMethods))) { ALOGE("ANGLEGetDisplayPlatform call failed!"); return false; } if (platformMethods) { assignAnglePlatformMethods(platformMethods); } else { ALOGE("In initializeAnglePlatform() platformMethods struct ptr is NULL. Not assigning " "tracing function ptrs!"); } return true; } void resetAnglePlatform(EGLDisplay dpy) { if (angleResetDisplayPlatform) { angleResetDisplayPlatform(dpy); } } }; // namespace angle #endif // __ANDROID__
opengl/libs/EGL/egl_angle_platform.h +3 −28 Original line number Diff line number Diff line Loading @@ -18,40 +18,15 @@ #if defined(__ANDROID__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" #include <EGL/Platform.h> #pragma GCC diagnostic pop #include "egldefs.h" #define ATRACE_TAG ATRACE_TAG_GRAPHICS #include "egl_trace.h" namespace angle { class AnglePlatformImpl { public: static void assignAnglePlatformMethods(PlatformMethods* platformMethods); static GetDisplayPlatformFunc angleGetDisplayPlatform; static ResetDisplayPlatformFunc angleResetDisplayPlatform; private: static time_t startTime; static const unsigned char* getTraceCategoryEnabledFlag(PlatformMethods* /*platform*/, const char* /*categoryName*/); static double monotonicallyIncreasingTime(PlatformMethods* /*platform*/); static void logError(PlatformMethods* /*platform*/, const char* errorMessage); static void logWarning(PlatformMethods* /*platform*/, const char* warningMessage); static void logInfo(PlatformMethods* /*platform*/, const char* infoMessage); static TraceEventHandle addTraceEvent(PlatformMethods* /**platform*/, char phase, const unsigned char* /*category_group_enabled*/, const char* name, unsigned long long /*id*/, double /*timestamp*/, int /*num_args*/, const char** /*arg_names*/, const unsigned char* /*arg_types*/, const unsigned long long* /*arg_values*/, unsigned char /*flags*/); }; bool initializeAnglePlatform(EGLDisplay dpy); void resetAnglePlatform(EGLDisplay dpy); }; // namespace angle Loading
opengl/libs/EGL/egl_display.cpp +3 −40 Original line number Diff line number Diff line Loading @@ -164,43 +164,6 @@ static bool addAnglePlatformAttributes(egl_connection_t* const cnx, return true; } // Initialize function ptrs for ANGLE PlatformMethods struct, used for systrace bool initializeAnglePlatform(EGLDisplay dpy) { // Since we're inside libEGL, use dlsym to lookup fptr for ANGLEGetDisplayPlatform android_namespace_t* ns = android::GraphicsEnv::getInstance().getAngleNamespace(); const android_dlextinfo dlextinfo = { .flags = ANDROID_DLEXT_USE_NAMESPACE, .library_namespace = ns, }; void* so = android_dlopen_ext("libEGL_angle.so", RTLD_LOCAL | RTLD_NOW, &dlextinfo); angle::AnglePlatformImpl::angleGetDisplayPlatform = reinterpret_cast<angle::GetDisplayPlatformFunc>(dlsym(so, "ANGLEGetDisplayPlatform")); if (!angle::AnglePlatformImpl::angleGetDisplayPlatform) { ALOGE("dlsym lookup of ANGLEGetDisplayPlatform in libEGL_angle failed!"); return false; } angle::AnglePlatformImpl::angleResetDisplayPlatform = reinterpret_cast<angle::ResetDisplayPlatformFunc>( eglGetProcAddress("ANGLEResetDisplayPlatform")); angle::PlatformMethods* platformMethods = nullptr; if (!((angle::AnglePlatformImpl::angleGetDisplayPlatform)(dpy, angle::g_PlatformMethodNames, angle::g_NumPlatformMethods, nullptr, &platformMethods))) { ALOGE("ANGLEGetDisplayPlatform call failed!"); return false; } if (platformMethods) { angle::AnglePlatformImpl::assignAnglePlatformMethods(platformMethods); } else { ALOGE("In initializeAnglePlatform() platformMethods struct ptr is NULL. Not assigning " "tracing function ptrs!"); } return true; } static EGLDisplay getPlatformDisplayAngle(EGLNativeDisplayType display, egl_connection_t* const cnx, const EGLAttrib* attrib_list, EGLint* error) { EGLDisplay dpy = EGL_NO_DISPLAY; Loading Loading @@ -228,7 +191,7 @@ static EGLDisplay getPlatformDisplayAngle(EGLNativeDisplayType display, egl_conn if (dpy == EGL_NO_DISPLAY) { ALOGE("eglGetPlatformDisplay failed!"); } else { if (!initializeAnglePlatform(dpy)) { if (!angle::initializeAnglePlatform(dpy)) { ALOGE("initializeAnglePlatform failed!"); } } Loading Loading @@ -505,8 +468,8 @@ EGLBoolean egl_display_t::terminate() { egl_connection_t* const cnx = &gEGLImpl; if (cnx->dso && disp.state == egl_display_t::INITIALIZED) { // If we're using ANGLE reset any custom DisplayPlatform if (cnx->useAngle && angle::AnglePlatformImpl::angleResetDisplayPlatform) { (angle::AnglePlatformImpl::angleResetDisplayPlatform)(disp.dpy); if (cnx->useAngle) { angle::resetAnglePlatform(disp.dpy); } if (cnx->egl.eglTerminate(disp.dpy) == EGL_FALSE) { ALOGW("eglTerminate(%p) failed (%s)", disp.dpy, Loading