Loading libs/graphicsenv/GraphicsEnv.cpp +4 −60 Original line number Original line Diff line number Diff line Loading @@ -433,61 +433,24 @@ bool GraphicsEnv::shouldUseAngle() { return (mUseAngle == YES) ? true : false; return (mUseAngle == YES) ? true : false; } } bool GraphicsEnv::angleIsSystemDriver() { // Make sure we are init'ed if (mAngleAppName.empty()) { ALOGV("App name is empty. setAngleInfo() has not been called to enable ANGLE."); return false; } return (mAngleIsSystemDriver == YES) ? true : false; } bool GraphicsEnv::shouldForceLegacyDriver() { // Make sure we are init'ed if (mAngleAppName.empty()) { ALOGV("App name is empty. setAngleInfo() has not been called to enable ANGLE."); return false; } return (mAngleIsSystemDriver == YES && mUseAngle == NO) ? true : false; } std::string GraphicsEnv::getLegacySuffix() { return mLegacyDriverSuffix; } void GraphicsEnv::updateUseAngle() { void GraphicsEnv::updateUseAngle() { mUseAngle = NO; const char* ANGLE_PREFER_ANGLE = "angle"; const char* ANGLE_PREFER_ANGLE = "angle"; const char* ANGLE_PREFER_LEGACY = "legacy"; // The following is a deprecated version of "legacy" const char* ANGLE_PREFER_NATIVE = "native"; const char* ANGLE_PREFER_NATIVE = "native"; mUseAngle = NO; mUseAngle = NO; if (mAngleDeveloperOptIn == ANGLE_PREFER_ANGLE) { if (mAngleDeveloperOptIn == ANGLE_PREFER_ANGLE) { ALOGI("Using ANGLE, the %s GLES driver for package '%s'", ALOGV("User set \"Developer Options\" to force the use of ANGLE"); mAngleIsSystemDriver == YES ? "system" : "optional", mAngleAppName.c_str()); mUseAngle = YES; mUseAngle = YES; } else if (mAngleDeveloperOptIn == ANGLE_PREFER_LEGACY || } else if (mAngleDeveloperOptIn == ANGLE_PREFER_NATIVE) { mAngleDeveloperOptIn == ANGLE_PREFER_NATIVE) { ALOGV("User set \"Developer Options\" to force the use of Native"); ALOGI("Using the (%s) Legacy GLES driver for package '%s'", mAngleIsSystemDriver == YES ? "optional" : "system", mAngleAppName.c_str()); } else { } else { ALOGV("User set invalid \"Developer Options\": '%s'", mAngleDeveloperOptIn.c_str()); ALOGV("User set invalid \"Developer Options\": '%s'", mAngleDeveloperOptIn.c_str()); } } } } void GraphicsEnv::setAngleInfo(const std::string path, const std::string appName, void GraphicsEnv::setAngleInfo(const std::string path, const std::string appName, const bool angleIsSystemDriver, const std::string developerOptIn, const std::string developerOptIn, const std::vector<std::string> eglFeatures) { const std::vector<std::string> eglFeatures) { // Set whether ANGLE is the system driver: mAngleIsSystemDriver = angleIsSystemDriver ? YES : NO; // Note: Given the current logic and lack of the old rules file processing, // there seems to be little chance that mUseAngle != UNKNOWN. Leave this // for now, even though it seems outdated. 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 @@ -508,25 +471,6 @@ void GraphicsEnv::setAngleInfo(const std::string path, const std::string appName updateUseAngle(); updateUseAngle(); } } void GraphicsEnv::setLegacyDriverInfo(const std::string appName, const bool angleIsSystemDriver, const std::string legacyDriverName) { ALOGV("setting legacy app name to '%s'", appName.c_str()); mAngleAppName = appName; // Force the use of the legacy driver instead of ANGLE const char* ANGLE_PREFER_LEGACY = "legacy"; mAngleDeveloperOptIn = ANGLE_PREFER_LEGACY; ALOGV("setting ANGLE application opt-in to 'legacy'"); // Set whether ANGLE is the system driver: mAngleIsSystemDriver = angleIsSystemDriver ? YES : NO; mLegacyDriverSuffix = legacyDriverName; // Update the current status of whether we should use ANGLE or not updateUseAngle(); } void GraphicsEnv::setLayerPaths(NativeLoaderNamespace* appNamespace, const std::string layerPaths) { void GraphicsEnv::setLayerPaths(NativeLoaderNamespace* appNamespace, const std::string layerPaths) { if (mLayerPaths.empty()) { if (mLayerPaths.empty()) { mLayerPaths = layerPaths; mLayerPaths = layerPaths; Loading libs/graphicsenv/include/graphicsenv/GraphicsEnv.h +1 −16 Original line number Original line Diff line number Diff line Loading @@ -100,28 +100,17 @@ public: bool shouldUseAngle(std::string appName); bool shouldUseAngle(std::string appName); // Check if this app process should use ANGLE. // Check if this app process should use ANGLE. bool shouldUseAngle(); bool shouldUseAngle(); // If ANGLE is the system GLES driver bool angleIsSystemDriver(); // If should use legacy driver instead of a system ANGLE driver bool shouldForceLegacyDriver(); // Set a search path for loading ANGLE libraries. The path is a list of // Set a search path for loading ANGLE libraries. The path is a list of // directories separated by ':'. A directory can be contained in a zip file // directories separated by ':'. A directory can be contained in a zip file // (libraries must be stored uncompressed and page aligned); such elements // (libraries must be stored uncompressed and page aligned); such elements // 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, void setAngleInfo(const std::string path, const std::string appName, std::string devOptIn, const bool angleIsSystemDriver, std::string devOptIn, const std::vector<std::string> eglFeatures); const std::vector<std::string> eglFeatures); // Set the state so that the legacy driver will be used, and in case ANGLE // is the system driver, provide the name of the legacy driver. void setLegacyDriverInfo(const std::string appName, const bool angleIsSystemDriver, const std::string legacyDriverName); // 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. std::string& getAngleAppName(); std::string& getAngleAppName(); // Get the legacy driver's suffix name. std::string getLegacySuffix(); const std::vector<std::string>& getAngleEglFeatures(); const std::vector<std::string>& getAngleEglFeatures(); Loading Loading @@ -178,10 +167,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 is System Driver flag. UseAngle mAngleIsSystemDriver = UNKNOWN; // Legacy driver name to use when ANGLE is the system driver. std::string mLegacyDriverSuffix; // Use ANGLE flag. // Use ANGLE flag. UseAngle mUseAngle = UNKNOWN; UseAngle mUseAngle = UNKNOWN; // Vulkan debug layers libs. // Vulkan debug layers libs. Loading opengl/libs/EGL/Loader.cpp +11 −13 Original line number Original line Diff line number Diff line Loading @@ -139,7 +139,8 @@ static void* load_wrapper(const char* path) { static const char* DRIVER_SUFFIX_PROPERTY = "ro.hardware.egl"; static const char* DRIVER_SUFFIX_PROPERTY = "ro.hardware.egl"; static const char* HAL_SUBNAME_KEY_PROPERTIES[2] = { static const char* HAL_SUBNAME_KEY_PROPERTIES[3] = { "persist.graphics.egl", DRIVER_SUFFIX_PROPERTY, DRIVER_SUFFIX_PROPERTY, "ro.board.platform", "ro.board.platform", }; }; Loading Loading @@ -208,8 +209,7 @@ void* Loader::open(egl_connection_t* cnx) ATRACE_CALL(); ATRACE_CALL(); const nsecs_t openTime = systemTime(); const nsecs_t openTime = systemTime(); if (!android::GraphicsEnv::getInstance().angleIsSystemDriver() && if (should_unload_system_driver(cnx)) { should_unload_system_driver(cnx)) { unload_system_driver(cnx); unload_system_driver(cnx); } } Loading @@ -218,12 +218,8 @@ void* Loader::open(egl_connection_t* cnx) return cnx->dso; return cnx->dso; } } // Firstly, try to load ANGLE driver, unless we know that we shouldn't. // Firstly, try to load ANGLE driver. bool shouldForceLegacyDriver = android::GraphicsEnv::getInstance().shouldForceLegacyDriver(); driver_t* hnd = attempt_to_load_angle(cnx); driver_t* hnd = nullptr; if (!shouldForceLegacyDriver) { hnd = attempt_to_load_angle(cnx); } if (!hnd) { if (!hnd) { // Secondly, try to load from driver apk. // Secondly, try to load from driver apk. Loading Loading @@ -285,8 +281,10 @@ void* Loader::open(egl_connection_t* cnx) } } LOG_ALWAYS_FATAL_IF(!hnd, LOG_ALWAYS_FATAL_IF(!hnd, "couldn't find an OpenGL ES implementation, make sure you set %s or %s", "couldn't find an OpenGL ES implementation, make sure one of %s, %s and %s " HAL_SUBNAME_KEY_PROPERTIES[0], HAL_SUBNAME_KEY_PROPERTIES[1]); "is set", HAL_SUBNAME_KEY_PROPERTIES[0], HAL_SUBNAME_KEY_PROPERTIES[1], HAL_SUBNAME_KEY_PROPERTIES[2]); if (!cnx->libEgl) { if (!cnx->libEgl) { cnx->libEgl = load_wrapper(EGL_WRAPPER_DIR "/libEGL.so"); cnx->libEgl = load_wrapper(EGL_WRAPPER_DIR "/libEGL.so"); Loading Loading
libs/graphicsenv/GraphicsEnv.cpp +4 −60 Original line number Original line Diff line number Diff line Loading @@ -433,61 +433,24 @@ bool GraphicsEnv::shouldUseAngle() { return (mUseAngle == YES) ? true : false; return (mUseAngle == YES) ? true : false; } } bool GraphicsEnv::angleIsSystemDriver() { // Make sure we are init'ed if (mAngleAppName.empty()) { ALOGV("App name is empty. setAngleInfo() has not been called to enable ANGLE."); return false; } return (mAngleIsSystemDriver == YES) ? true : false; } bool GraphicsEnv::shouldForceLegacyDriver() { // Make sure we are init'ed if (mAngleAppName.empty()) { ALOGV("App name is empty. setAngleInfo() has not been called to enable ANGLE."); return false; } return (mAngleIsSystemDriver == YES && mUseAngle == NO) ? true : false; } std::string GraphicsEnv::getLegacySuffix() { return mLegacyDriverSuffix; } void GraphicsEnv::updateUseAngle() { void GraphicsEnv::updateUseAngle() { mUseAngle = NO; const char* ANGLE_PREFER_ANGLE = "angle"; const char* ANGLE_PREFER_ANGLE = "angle"; const char* ANGLE_PREFER_LEGACY = "legacy"; // The following is a deprecated version of "legacy" const char* ANGLE_PREFER_NATIVE = "native"; const char* ANGLE_PREFER_NATIVE = "native"; mUseAngle = NO; mUseAngle = NO; if (mAngleDeveloperOptIn == ANGLE_PREFER_ANGLE) { if (mAngleDeveloperOptIn == ANGLE_PREFER_ANGLE) { ALOGI("Using ANGLE, the %s GLES driver for package '%s'", ALOGV("User set \"Developer Options\" to force the use of ANGLE"); mAngleIsSystemDriver == YES ? "system" : "optional", mAngleAppName.c_str()); mUseAngle = YES; mUseAngle = YES; } else if (mAngleDeveloperOptIn == ANGLE_PREFER_LEGACY || } else if (mAngleDeveloperOptIn == ANGLE_PREFER_NATIVE) { mAngleDeveloperOptIn == ANGLE_PREFER_NATIVE) { ALOGV("User set \"Developer Options\" to force the use of Native"); ALOGI("Using the (%s) Legacy GLES driver for package '%s'", mAngleIsSystemDriver == YES ? "optional" : "system", mAngleAppName.c_str()); } else { } else { ALOGV("User set invalid \"Developer Options\": '%s'", mAngleDeveloperOptIn.c_str()); ALOGV("User set invalid \"Developer Options\": '%s'", mAngleDeveloperOptIn.c_str()); } } } } void GraphicsEnv::setAngleInfo(const std::string path, const std::string appName, void GraphicsEnv::setAngleInfo(const std::string path, const std::string appName, const bool angleIsSystemDriver, const std::string developerOptIn, const std::string developerOptIn, const std::vector<std::string> eglFeatures) { const std::vector<std::string> eglFeatures) { // Set whether ANGLE is the system driver: mAngleIsSystemDriver = angleIsSystemDriver ? YES : NO; // Note: Given the current logic and lack of the old rules file processing, // there seems to be little chance that mUseAngle != UNKNOWN. Leave this // for now, even though it seems outdated. 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 @@ -508,25 +471,6 @@ void GraphicsEnv::setAngleInfo(const std::string path, const std::string appName updateUseAngle(); updateUseAngle(); } } void GraphicsEnv::setLegacyDriverInfo(const std::string appName, const bool angleIsSystemDriver, const std::string legacyDriverName) { ALOGV("setting legacy app name to '%s'", appName.c_str()); mAngleAppName = appName; // Force the use of the legacy driver instead of ANGLE const char* ANGLE_PREFER_LEGACY = "legacy"; mAngleDeveloperOptIn = ANGLE_PREFER_LEGACY; ALOGV("setting ANGLE application opt-in to 'legacy'"); // Set whether ANGLE is the system driver: mAngleIsSystemDriver = angleIsSystemDriver ? YES : NO; mLegacyDriverSuffix = legacyDriverName; // Update the current status of whether we should use ANGLE or not updateUseAngle(); } void GraphicsEnv::setLayerPaths(NativeLoaderNamespace* appNamespace, const std::string layerPaths) { void GraphicsEnv::setLayerPaths(NativeLoaderNamespace* appNamespace, const std::string layerPaths) { if (mLayerPaths.empty()) { if (mLayerPaths.empty()) { mLayerPaths = layerPaths; mLayerPaths = layerPaths; Loading
libs/graphicsenv/include/graphicsenv/GraphicsEnv.h +1 −16 Original line number Original line Diff line number Diff line Loading @@ -100,28 +100,17 @@ public: bool shouldUseAngle(std::string appName); bool shouldUseAngle(std::string appName); // Check if this app process should use ANGLE. // Check if this app process should use ANGLE. bool shouldUseAngle(); bool shouldUseAngle(); // If ANGLE is the system GLES driver bool angleIsSystemDriver(); // If should use legacy driver instead of a system ANGLE driver bool shouldForceLegacyDriver(); // Set a search path for loading ANGLE libraries. The path is a list of // Set a search path for loading ANGLE libraries. The path is a list of // directories separated by ':'. A directory can be contained in a zip file // directories separated by ':'. A directory can be contained in a zip file // (libraries must be stored uncompressed and page aligned); such elements // (libraries must be stored uncompressed and page aligned); such elements // 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, void setAngleInfo(const std::string path, const std::string appName, std::string devOptIn, const bool angleIsSystemDriver, std::string devOptIn, const std::vector<std::string> eglFeatures); const std::vector<std::string> eglFeatures); // Set the state so that the legacy driver will be used, and in case ANGLE // is the system driver, provide the name of the legacy driver. void setLegacyDriverInfo(const std::string appName, const bool angleIsSystemDriver, const std::string legacyDriverName); // 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. std::string& getAngleAppName(); std::string& getAngleAppName(); // Get the legacy driver's suffix name. std::string getLegacySuffix(); const std::vector<std::string>& getAngleEglFeatures(); const std::vector<std::string>& getAngleEglFeatures(); Loading Loading @@ -178,10 +167,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 is System Driver flag. UseAngle mAngleIsSystemDriver = UNKNOWN; // Legacy driver name to use when ANGLE is the system driver. std::string mLegacyDriverSuffix; // Use ANGLE flag. // Use ANGLE flag. UseAngle mUseAngle = UNKNOWN; UseAngle mUseAngle = UNKNOWN; // Vulkan debug layers libs. // Vulkan debug layers libs. Loading
opengl/libs/EGL/Loader.cpp +11 −13 Original line number Original line Diff line number Diff line Loading @@ -139,7 +139,8 @@ static void* load_wrapper(const char* path) { static const char* DRIVER_SUFFIX_PROPERTY = "ro.hardware.egl"; static const char* DRIVER_SUFFIX_PROPERTY = "ro.hardware.egl"; static const char* HAL_SUBNAME_KEY_PROPERTIES[2] = { static const char* HAL_SUBNAME_KEY_PROPERTIES[3] = { "persist.graphics.egl", DRIVER_SUFFIX_PROPERTY, DRIVER_SUFFIX_PROPERTY, "ro.board.platform", "ro.board.platform", }; }; Loading Loading @@ -208,8 +209,7 @@ void* Loader::open(egl_connection_t* cnx) ATRACE_CALL(); ATRACE_CALL(); const nsecs_t openTime = systemTime(); const nsecs_t openTime = systemTime(); if (!android::GraphicsEnv::getInstance().angleIsSystemDriver() && if (should_unload_system_driver(cnx)) { should_unload_system_driver(cnx)) { unload_system_driver(cnx); unload_system_driver(cnx); } } Loading @@ -218,12 +218,8 @@ void* Loader::open(egl_connection_t* cnx) return cnx->dso; return cnx->dso; } } // Firstly, try to load ANGLE driver, unless we know that we shouldn't. // Firstly, try to load ANGLE driver. bool shouldForceLegacyDriver = android::GraphicsEnv::getInstance().shouldForceLegacyDriver(); driver_t* hnd = attempt_to_load_angle(cnx); driver_t* hnd = nullptr; if (!shouldForceLegacyDriver) { hnd = attempt_to_load_angle(cnx); } if (!hnd) { if (!hnd) { // Secondly, try to load from driver apk. // Secondly, try to load from driver apk. Loading Loading @@ -285,8 +281,10 @@ void* Loader::open(egl_connection_t* cnx) } } LOG_ALWAYS_FATAL_IF(!hnd, LOG_ALWAYS_FATAL_IF(!hnd, "couldn't find an OpenGL ES implementation, make sure you set %s or %s", "couldn't find an OpenGL ES implementation, make sure one of %s, %s and %s " HAL_SUBNAME_KEY_PROPERTIES[0], HAL_SUBNAME_KEY_PROPERTIES[1]); "is set", HAL_SUBNAME_KEY_PROPERTIES[0], HAL_SUBNAME_KEY_PROPERTIES[1], HAL_SUBNAME_KEY_PROPERTIES[2]); if (!cnx->libEgl) { if (!cnx->libEgl) { cnx->libEgl = load_wrapper(EGL_WRAPPER_DIR "/libEGL.so"); cnx->libEgl = load_wrapper(EGL_WRAPPER_DIR "/libEGL.so"); Loading