Refactor ANGLE Platform support
Migrate almost all angle-platform specific code out of egl_display.cpp
to egl_angle_platform.cpp. This isolates use of angle "Platform.h" code
to only egl_angle_platform.cpp. I also removed the class wrapper for
static platform functions as it added no benefit.
Also syncing up latest Platform.h from ANGLE.
Test: build and flash device, run app w/ ANGLE enabled, systrace
Change-Id: I257deb28ee41aa6b3258a373aaa481f71968315f
diff --git a/opengl/libs/EGL/egl_display.cpp b/opengl/libs/EGL/egl_display.cpp
index a065973..4433af0 100644
--- a/opengl/libs/EGL/egl_display.cpp
+++ b/opengl/libs/EGL/egl_display.cpp
@@ -164,43 +164,6 @@
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;
@@ -228,7 +191,7 @@
if (dpy == EGL_NO_DISPLAY) {
ALOGE("eglGetPlatformDisplay failed!");
} else {
- if (!initializeAnglePlatform(dpy)) {
+ if (!angle::initializeAnglePlatform(dpy)) {
ALOGE("initializeAnglePlatform failed!");
}
}
@@ -505,8 +468,8 @@
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,