ANGLE In Use Dialog Box
When ANGLE is enabled for an app, show a dialog box to the user to
indicate that ANGLE is in use. This is useful because there are
not (or at least shouldn't be) any visual indication that a different
OpenGL driver is in use.
Bug: 120489005
Test: atest CtsAngleIntegrationHostTestCases
Test: Load an app with ANGLE enabled and verify dialog box is shown.
Test: Load an app without ANGLE and verify dialog box is not shown.
Change-Id: I5d667707841458b4ef63c9f4a5bc07e30cb7c786
diff --git a/libs/graphicsenv/GraphicsEnv.cpp b/libs/graphicsenv/GraphicsEnv.cpp
index c20d54b..3b42f80 100644
--- a/libs/graphicsenv/GraphicsEnv.cpp
+++ b/libs/graphicsenv/GraphicsEnv.cpp
@@ -316,28 +316,28 @@
return false;
}
- return mUseAngle;
+ return (mUseAngle == YES) ? true : false;
}
void GraphicsEnv::updateUseAngle() {
- mUseAngle = false;
+ mUseAngle = NO;
const char* ANGLE_PREFER_ANGLE = "angle";
const char* ANGLE_PREFER_NATIVE = "native";
if (mAngleDeveloperOptIn == ANGLE_PREFER_ANGLE) {
ALOGV("User set \"Developer Options\" to force the use of ANGLE");
- mUseAngle = true;
+ mUseAngle = YES;
} else if (mAngleDeveloperOptIn == ANGLE_PREFER_NATIVE) {
ALOGV("User set \"Developer Options\" to force the use of Native");
- mUseAngle = false;
+ mUseAngle = NO;
} else {
// The "Developer Options" value wasn't set to force the use of ANGLE. Need to temporarily
// load ANGLE and call the updatable opt-in/out logic:
void* featureSo = loadLibrary("feature_support");
if (featureSo) {
ALOGV("loaded ANGLE's opt-in/out logic from namespace");
- mUseAngle = checkAngleRules(featureSo);
+ mUseAngle = checkAngleRules(featureSo) ? YES : NO;
dlclose(featureSo);
featureSo = nullptr;
} else {
@@ -349,6 +349,13 @@
void GraphicsEnv::setAngleInfo(const std::string path, const std::string appName,
const std::string developerOptIn, const int rulesFd,
const long rulesOffset, const long rulesLength) {
+ if (mUseAngle != UNKNOWN) {
+ // We've already figured out an answer for this app, so just return.
+ ALOGV("Already evaluated the rules file for '%s': use ANGLE = %s", appName.c_str(),
+ (mUseAngle == YES) ? "true" : "false");
+ return;
+ }
+
ALOGV("setting ANGLE path to '%s'", path.c_str());
mAnglePath = path;
ALOGV("setting ANGLE app name to '%s'", appName.c_str());
diff --git a/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h b/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h
index d4edfa0..6e74e7c 100644
--- a/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h
+++ b/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h
@@ -74,6 +74,8 @@
const std::string& getDebugLayersGLES();
private:
+ enum UseAngle { UNKNOWN, YES, NO };
+
void* loadLibrary(std::string name);
bool checkAngleRules(void* so);
void updateUseAngle();
@@ -85,7 +87,7 @@
std::string mAngleAppName;
std::string mAngleDeveloperOptIn;
std::vector<char> mRulesBuffer;
- bool mUseAngle;
+ UseAngle mUseAngle = UNKNOWN;
std::string mDebugLayers;
std::string mDebugLayersGLES;
std::string mLayerPaths;