Refactor ANGLE usage code.
Previously when ANGLE is the default system driver, the ro.hardware.egl
points to ANGLE. This is fine if ANGLE is the only system drvier.
However, we would like to make ANGLE coexist with the native GLES
drivers and allow a global switch. Hence this patch refactors the
majority of the ANGLE selection logic. Loading ANGLE in the form of an
apk as well as using ANGLE as a game mode intervention should remain
functional.
Bug: b/270994705
Test: atest CtsAngleIntegrationHostTestCases
Change-Id: I31a6a5dda04a1ffaeed101e58368ad4b4ad0d54e
diff --git a/opengl/libs/EGL/Loader.cpp b/opengl/libs/EGL/Loader.cpp
index 415e8ea..2c3ce16 100644
--- a/opengl/libs/EGL/Loader.cpp
+++ b/opengl/libs/EGL/Loader.cpp
@@ -139,9 +139,10 @@
static const char* DRIVER_SUFFIX_PROPERTY = "ro.hardware.egl";
-static const char* HAL_SUBNAME_KEY_PROPERTIES[2] = {
- DRIVER_SUFFIX_PROPERTY,
- "ro.board.platform",
+static const char* HAL_SUBNAME_KEY_PROPERTIES[3] = {
+ "persist.graphics.egl",
+ DRIVER_SUFFIX_PROPERTY,
+ "ro.board.platform",
};
static bool should_unload_system_driver(egl_connection_t* cnx) {
@@ -208,8 +209,7 @@
ATRACE_CALL();
const nsecs_t openTime = systemTime();
- if (!android::GraphicsEnv::getInstance().angleIsSystemDriver() &&
- should_unload_system_driver(cnx)) {
+ if (should_unload_system_driver(cnx)) {
unload_system_driver(cnx);
}
@@ -218,12 +218,8 @@
return cnx->dso;
}
- // Firstly, try to load ANGLE driver, unless we know that we shouldn't.
- bool shouldForceLegacyDriver = android::GraphicsEnv::getInstance().shouldForceLegacyDriver();
- driver_t* hnd = nullptr;
- if (!shouldForceLegacyDriver) {
- hnd = attempt_to_load_angle(cnx);
- }
+ // Firstly, try to load ANGLE driver.
+ driver_t* hnd = attempt_to_load_angle(cnx);
if (!hnd) {
// Secondly, try to load from driver apk.
@@ -285,8 +281,10 @@
}
LOG_ALWAYS_FATAL_IF(!hnd,
- "couldn't find an OpenGL ES implementation, make sure you set %s or %s",
- HAL_SUBNAME_KEY_PROPERTIES[0], HAL_SUBNAME_KEY_PROPERTIES[1]);
+ "couldn't find an OpenGL ES implementation, make sure one of %s, %s and %s "
+ "is set",
+ HAL_SUBNAME_KEY_PROPERTIES[0], HAL_SUBNAME_KEY_PROPERTIES[1],
+ HAL_SUBNAME_KEY_PROPERTIES[2]);
if (!cnx->libEgl) {
cnx->libEgl = load_wrapper(EGL_WRAPPER_DIR "/libEGL.so");