Loading libs/graphicsenv/GraphicsEnv.cpp +3 −104 Original line number Original line Diff line number Diff line Loading @@ -343,80 +343,6 @@ void* GraphicsEnv::loadLibrary(std::string name) { return nullptr; return nullptr; } } bool GraphicsEnv::checkAngleRules(void* so) { auto manufacturer = base::GetProperty("ro.product.manufacturer", "UNSET"); auto model = base::GetProperty("ro.product.model", "UNSET"); auto ANGLEGetFeatureSupportUtilAPIVersion = (fpANGLEGetFeatureSupportUtilAPIVersion)dlsym(so, "ANGLEGetFeatureSupportUtilAPIVersion"); if (!ANGLEGetFeatureSupportUtilAPIVersion) { ALOGW("Cannot find ANGLEGetFeatureSupportUtilAPIVersion function"); return false; } // Negotiate the interface version by requesting most recent known to the platform unsigned int versionToUse = CURRENT_ANGLE_API_VERSION; if (!(ANGLEGetFeatureSupportUtilAPIVersion)(&versionToUse)) { ALOGW("Cannot use ANGLE feature-support library, it is older than supported by EGL, " "requested version %u", versionToUse); return false; } // Add and remove versions below as needed bool useAngle = false; switch (versionToUse) { case 2: { ALOGV("Using version %d of ANGLE feature-support library", versionToUse); void* rulesHandle = nullptr; int rulesVersion = 0; void* systemInfoHandle = nullptr; // Get the symbols for the feature-support-utility library: #define GET_SYMBOL(symbol) \ fp##symbol symbol = (fp##symbol)dlsym(so, #symbol); \ if (!symbol) { \ ALOGW("Cannot find " #symbol " in ANGLE feature-support library"); \ break; \ } GET_SYMBOL(ANGLEAndroidParseRulesString); GET_SYMBOL(ANGLEGetSystemInfo); GET_SYMBOL(ANGLEAddDeviceInfoToSystemInfo); GET_SYMBOL(ANGLEShouldBeUsedForApplication); GET_SYMBOL(ANGLEFreeRulesHandle); GET_SYMBOL(ANGLEFreeSystemInfoHandle); // Parse the rules, obtain the SystemInfo, and evaluate the // application against the rules: if (!(ANGLEAndroidParseRulesString)(mRulesBuffer.data(), &rulesHandle, &rulesVersion)) { ALOGW("ANGLE feature-support library cannot parse rules file"); break; } if (!(ANGLEGetSystemInfo)(&systemInfoHandle)) { ALOGW("ANGLE feature-support library cannot obtain SystemInfo"); break; } if (!(ANGLEAddDeviceInfoToSystemInfo)(manufacturer.c_str(), model.c_str(), systemInfoHandle)) { ALOGW("ANGLE feature-support library cannot add device info to SystemInfo"); break; } useAngle = (ANGLEShouldBeUsedForApplication)(rulesHandle, rulesVersion, systemInfoHandle, mAngleAppName.c_str()); (ANGLEFreeRulesHandle)(rulesHandle); (ANGLEFreeSystemInfoHandle)(systemInfoHandle); } break; default: ALOGW("Version %u of ANGLE feature-support library is NOT supported.", versionToUse); } ALOGV("Close temporarily-loaded ANGLE opt-in/out logic"); return useAngle; } bool GraphicsEnv::shouldUseAngle(std::string appName) { bool GraphicsEnv::shouldUseAngle(std::string appName) { if (appName != mAngleAppName) { if (appName != mAngleAppName) { // Make sure we are checking the app we were init'ed for // Make sure we are checking the app we were init'ed for Loading Loading @@ -444,31 +370,20 @@ void GraphicsEnv::updateUseAngle() { const char* ANGLE_PREFER_ANGLE = "angle"; const char* ANGLE_PREFER_ANGLE = "angle"; const char* ANGLE_PREFER_NATIVE = "native"; const char* ANGLE_PREFER_NATIVE = "native"; mUseAngle = NO; if (mAngleDeveloperOptIn == ANGLE_PREFER_ANGLE) { if (mAngleDeveloperOptIn == ANGLE_PREFER_ANGLE) { ALOGV("User set \"Developer Options\" to force the use of ANGLE"); ALOGV("User set \"Developer Options\" to force the use of ANGLE"); mUseAngle = YES; mUseAngle = YES; } else if (mAngleDeveloperOptIn == ANGLE_PREFER_NATIVE) { } else if (mAngleDeveloperOptIn == ANGLE_PREFER_NATIVE) { ALOGV("User set \"Developer Options\" to force the use of Native"); ALOGV("User set \"Developer Options\" to force the use of Native"); mUseAngle = NO; } else { } else { // The "Developer Options" value wasn't set to force the use of ANGLE. Need to temporarily ALOGV("User set invalid \"Developer Options\": '%s'", mAngleDeveloperOptIn.c_str()); // 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) ? YES : NO; dlclose(featureSo); featureSo = nullptr; } else { ALOGV("Could not load the ANGLE opt-in/out logic, cannot use ANGLE."); } } } } } void GraphicsEnv::setAngleInfo(const std::string path, const std::string appName, void GraphicsEnv::setAngleInfo(const std::string path, const std::string appName, const std::string developerOptIn, const std::string developerOptIn, const std::vector<std::string> eglFeatures, const int rulesFd, const std::vector<std::string> eglFeatures) { const long rulesOffset, const long rulesLength) { if (mUseAngle != UNKNOWN) { if (mUseAngle != UNKNOWN) { // We've already figured out an answer for this app, so just return. // 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(), ALOGV("Already evaluated the rules file for '%s': use ANGLE = %s", appName.c_str(), Loading @@ -485,22 +400,6 @@ void GraphicsEnv::setAngleInfo(const std::string path, const std::string appName ALOGV("setting ANGLE application opt-in to '%s'", developerOptIn.c_str()); ALOGV("setting ANGLE application opt-in to '%s'", developerOptIn.c_str()); mAngleDeveloperOptIn = developerOptIn; mAngleDeveloperOptIn = developerOptIn; lseek(rulesFd, rulesOffset, SEEK_SET); mRulesBuffer = std::vector<char>(rulesLength + 1); ssize_t numBytesRead = read(rulesFd, mRulesBuffer.data(), rulesLength); if (numBytesRead < 0) { ALOGE("Cannot read rules file: numBytesRead = %zd", numBytesRead); numBytesRead = 0; } else if (numBytesRead == 0) { ALOGW("Empty rules file"); } if (numBytesRead != rulesLength) { ALOGW("Did not read all of the necessary bytes from the rules file." "expected: %ld, got: %zd", rulesLength, numBytesRead); } mRulesBuffer[numBytesRead] = '\0'; // Update the current status of whether we should use ANGLE or not // Update the current status of whether we should use ANGLE or not updateUseAngle(); updateUseAngle(); } } Loading libs/graphicsenv/include/graphicsenv/GraphicsEnv.h +1 −6 Original line number Original line Diff line number Diff line Loading @@ -97,8 +97,7 @@ public: // in the search path must have a '!' after the zip filename, e.g. // in the search path must have a '!' after the zip filename, e.g. // /system/app/ANGLEPrebuilt/ANGLEPrebuilt.apk!/lib/arm64-v8a // /system/app/ANGLEPrebuilt/ANGLEPrebuilt.apk!/lib/arm64-v8a void setAngleInfo(const std::string path, const std::string appName, std::string devOptIn, void setAngleInfo(const std::string path, const std::string appName, std::string devOptIn, const std::vector<std::string> eglFeatures, const int rulesFd, const std::vector<std::string> eglFeatures); const long rulesOffset, const long rulesLength); // Get the ANGLE driver namespace. // Get the ANGLE driver namespace. android_namespace_t* getAngleNamespace(); android_namespace_t* getAngleNamespace(); // Get the app name for ANGLE debug message. // Get the app name for ANGLE debug message. Loading Loading @@ -129,8 +128,6 @@ private: // Load requested ANGLE library. // Load requested ANGLE library. void* loadLibrary(std::string name); void* loadLibrary(std::string name); // Check ANGLE support with the rules. bool checkAngleRules(void* so); // Update whether ANGLE should be used. // Update whether ANGLE should be used. void updateUseAngle(); void updateUseAngle(); // Link updatable driver namespace with llndk and vndk-sp libs. // Link updatable driver namespace with llndk and vndk-sp libs. Loading Loading @@ -159,8 +156,6 @@ private: std::string mAngleDeveloperOptIn; std::string mAngleDeveloperOptIn; // ANGLE EGL features; // ANGLE EGL features; std::vector<std::string> mAngleEglFeatures; std::vector<std::string> mAngleEglFeatures; // ANGLE rules. std::vector<char> mRulesBuffer; // Use ANGLE flag. // Use ANGLE flag. UseAngle mUseAngle = UNKNOWN; UseAngle mUseAngle = UNKNOWN; // Vulkan debug layers libs. // Vulkan debug layers libs. Loading Loading
libs/graphicsenv/GraphicsEnv.cpp +3 −104 Original line number Original line Diff line number Diff line Loading @@ -343,80 +343,6 @@ void* GraphicsEnv::loadLibrary(std::string name) { return nullptr; return nullptr; } } bool GraphicsEnv::checkAngleRules(void* so) { auto manufacturer = base::GetProperty("ro.product.manufacturer", "UNSET"); auto model = base::GetProperty("ro.product.model", "UNSET"); auto ANGLEGetFeatureSupportUtilAPIVersion = (fpANGLEGetFeatureSupportUtilAPIVersion)dlsym(so, "ANGLEGetFeatureSupportUtilAPIVersion"); if (!ANGLEGetFeatureSupportUtilAPIVersion) { ALOGW("Cannot find ANGLEGetFeatureSupportUtilAPIVersion function"); return false; } // Negotiate the interface version by requesting most recent known to the platform unsigned int versionToUse = CURRENT_ANGLE_API_VERSION; if (!(ANGLEGetFeatureSupportUtilAPIVersion)(&versionToUse)) { ALOGW("Cannot use ANGLE feature-support library, it is older than supported by EGL, " "requested version %u", versionToUse); return false; } // Add and remove versions below as needed bool useAngle = false; switch (versionToUse) { case 2: { ALOGV("Using version %d of ANGLE feature-support library", versionToUse); void* rulesHandle = nullptr; int rulesVersion = 0; void* systemInfoHandle = nullptr; // Get the symbols for the feature-support-utility library: #define GET_SYMBOL(symbol) \ fp##symbol symbol = (fp##symbol)dlsym(so, #symbol); \ if (!symbol) { \ ALOGW("Cannot find " #symbol " in ANGLE feature-support library"); \ break; \ } GET_SYMBOL(ANGLEAndroidParseRulesString); GET_SYMBOL(ANGLEGetSystemInfo); GET_SYMBOL(ANGLEAddDeviceInfoToSystemInfo); GET_SYMBOL(ANGLEShouldBeUsedForApplication); GET_SYMBOL(ANGLEFreeRulesHandle); GET_SYMBOL(ANGLEFreeSystemInfoHandle); // Parse the rules, obtain the SystemInfo, and evaluate the // application against the rules: if (!(ANGLEAndroidParseRulesString)(mRulesBuffer.data(), &rulesHandle, &rulesVersion)) { ALOGW("ANGLE feature-support library cannot parse rules file"); break; } if (!(ANGLEGetSystemInfo)(&systemInfoHandle)) { ALOGW("ANGLE feature-support library cannot obtain SystemInfo"); break; } if (!(ANGLEAddDeviceInfoToSystemInfo)(manufacturer.c_str(), model.c_str(), systemInfoHandle)) { ALOGW("ANGLE feature-support library cannot add device info to SystemInfo"); break; } useAngle = (ANGLEShouldBeUsedForApplication)(rulesHandle, rulesVersion, systemInfoHandle, mAngleAppName.c_str()); (ANGLEFreeRulesHandle)(rulesHandle); (ANGLEFreeSystemInfoHandle)(systemInfoHandle); } break; default: ALOGW("Version %u of ANGLE feature-support library is NOT supported.", versionToUse); } ALOGV("Close temporarily-loaded ANGLE opt-in/out logic"); return useAngle; } bool GraphicsEnv::shouldUseAngle(std::string appName) { bool GraphicsEnv::shouldUseAngle(std::string appName) { if (appName != mAngleAppName) { if (appName != mAngleAppName) { // Make sure we are checking the app we were init'ed for // Make sure we are checking the app we were init'ed for Loading Loading @@ -444,31 +370,20 @@ void GraphicsEnv::updateUseAngle() { const char* ANGLE_PREFER_ANGLE = "angle"; const char* ANGLE_PREFER_ANGLE = "angle"; const char* ANGLE_PREFER_NATIVE = "native"; const char* ANGLE_PREFER_NATIVE = "native"; mUseAngle = NO; if (mAngleDeveloperOptIn == ANGLE_PREFER_ANGLE) { if (mAngleDeveloperOptIn == ANGLE_PREFER_ANGLE) { ALOGV("User set \"Developer Options\" to force the use of ANGLE"); ALOGV("User set \"Developer Options\" to force the use of ANGLE"); mUseAngle = YES; mUseAngle = YES; } else if (mAngleDeveloperOptIn == ANGLE_PREFER_NATIVE) { } else if (mAngleDeveloperOptIn == ANGLE_PREFER_NATIVE) { ALOGV("User set \"Developer Options\" to force the use of Native"); ALOGV("User set \"Developer Options\" to force the use of Native"); mUseAngle = NO; } else { } else { // The "Developer Options" value wasn't set to force the use of ANGLE. Need to temporarily ALOGV("User set invalid \"Developer Options\": '%s'", mAngleDeveloperOptIn.c_str()); // 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) ? YES : NO; dlclose(featureSo); featureSo = nullptr; } else { ALOGV("Could not load the ANGLE opt-in/out logic, cannot use ANGLE."); } } } } } void GraphicsEnv::setAngleInfo(const std::string path, const std::string appName, void GraphicsEnv::setAngleInfo(const std::string path, const std::string appName, const std::string developerOptIn, const std::string developerOptIn, const std::vector<std::string> eglFeatures, const int rulesFd, const std::vector<std::string> eglFeatures) { const long rulesOffset, const long rulesLength) { if (mUseAngle != UNKNOWN) { if (mUseAngle != UNKNOWN) { // We've already figured out an answer for this app, so just return. // 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(), ALOGV("Already evaluated the rules file for '%s': use ANGLE = %s", appName.c_str(), Loading @@ -485,22 +400,6 @@ void GraphicsEnv::setAngleInfo(const std::string path, const std::string appName ALOGV("setting ANGLE application opt-in to '%s'", developerOptIn.c_str()); ALOGV("setting ANGLE application opt-in to '%s'", developerOptIn.c_str()); mAngleDeveloperOptIn = developerOptIn; mAngleDeveloperOptIn = developerOptIn; lseek(rulesFd, rulesOffset, SEEK_SET); mRulesBuffer = std::vector<char>(rulesLength + 1); ssize_t numBytesRead = read(rulesFd, mRulesBuffer.data(), rulesLength); if (numBytesRead < 0) { ALOGE("Cannot read rules file: numBytesRead = %zd", numBytesRead); numBytesRead = 0; } else if (numBytesRead == 0) { ALOGW("Empty rules file"); } if (numBytesRead != rulesLength) { ALOGW("Did not read all of the necessary bytes from the rules file." "expected: %ld, got: %zd", rulesLength, numBytesRead); } mRulesBuffer[numBytesRead] = '\0'; // Update the current status of whether we should use ANGLE or not // Update the current status of whether we should use ANGLE or not updateUseAngle(); updateUseAngle(); } } Loading
libs/graphicsenv/include/graphicsenv/GraphicsEnv.h +1 −6 Original line number Original line Diff line number Diff line Loading @@ -97,8 +97,7 @@ public: // in the search path must have a '!' after the zip filename, e.g. // in the search path must have a '!' after the zip filename, e.g. // /system/app/ANGLEPrebuilt/ANGLEPrebuilt.apk!/lib/arm64-v8a // /system/app/ANGLEPrebuilt/ANGLEPrebuilt.apk!/lib/arm64-v8a void setAngleInfo(const std::string path, const std::string appName, std::string devOptIn, void setAngleInfo(const std::string path, const std::string appName, std::string devOptIn, const std::vector<std::string> eglFeatures, const int rulesFd, const std::vector<std::string> eglFeatures); const long rulesOffset, const long rulesLength); // Get the ANGLE driver namespace. // Get the ANGLE driver namespace. android_namespace_t* getAngleNamespace(); android_namespace_t* getAngleNamespace(); // Get the app name for ANGLE debug message. // Get the app name for ANGLE debug message. Loading Loading @@ -129,8 +128,6 @@ private: // Load requested ANGLE library. // Load requested ANGLE library. void* loadLibrary(std::string name); void* loadLibrary(std::string name); // Check ANGLE support with the rules. bool checkAngleRules(void* so); // Update whether ANGLE should be used. // Update whether ANGLE should be used. void updateUseAngle(); void updateUseAngle(); // Link updatable driver namespace with llndk and vndk-sp libs. // Link updatable driver namespace with llndk and vndk-sp libs. Loading Loading @@ -159,8 +156,6 @@ private: std::string mAngleDeveloperOptIn; std::string mAngleDeveloperOptIn; // ANGLE EGL features; // ANGLE EGL features; std::vector<std::string> mAngleEglFeatures; std::vector<std::string> mAngleEglFeatures; // ANGLE rules. std::vector<char> mRulesBuffer; // Use ANGLE flag. // Use ANGLE flag. UseAngle mUseAngle = UNKNOWN; UseAngle mUseAngle = UNKNOWN; // Vulkan debug layers libs. // Vulkan debug layers libs. Loading