Loading libs/graphicsenv/GraphicsEnv.cpp +15 −10 Original line number Diff line number Diff line Loading @@ -402,7 +402,7 @@ bool GraphicsEnv::shouldUseAngle() { return mShouldUseAngle; } void GraphicsEnv::setAngleInfo(const std::string& path, const bool useSystemAngle, void GraphicsEnv::setAngleInfo(const std::string& path, const bool shouldUseSystemAngle, const std::string& packageName, const std::vector<std::string> eglFeatures) { if (mShouldUseAngle) { Loading @@ -420,7 +420,7 @@ void GraphicsEnv::setAngleInfo(const std::string& path, const bool useSystemAngl ALOGV("setting app package name to '%s'", packageName.c_str()); mPackageName = std::move(packageName); mShouldUseAngle = true; mUseSystemAngle = useSystemAngle; mShouldUseSystemAngle = shouldUseSystemAngle; } void GraphicsEnv::setLayerPaths(NativeLoaderNamespace* appNamespace, Loading Loading @@ -571,7 +571,7 @@ android_namespace_t* GraphicsEnv::getAngleNamespace() { return mAngleNamespace; } if (mAnglePath.empty() && !mUseSystemAngle) { if (mAnglePath.empty() && !mShouldUseSystemAngle) { ALOGV("mAnglePath is empty and not using system ANGLE, abort creating ANGLE namespace"); return nullptr; } Loading @@ -589,18 +589,19 @@ android_namespace_t* GraphicsEnv::getAngleNamespace() { // are properly inherited. mAngleNamespace = android_create_namespace("ANGLE", mUseSystemAngle ? defaultLibraryPaths mShouldUseSystemAngle ? defaultLibraryPaths : mAnglePath.c_str(), // ld_library_path mUseSystemAngle ? defaultLibraryPaths mShouldUseSystemAngle ? defaultLibraryPaths : mAnglePath.c_str(), // default_library_path ANDROID_NAMESPACE_TYPE_SHARED_ISOLATED, nullptr, // permitted_when_isolated_path mUseSystemAngle ? android_get_exported_namespace("sphal") mShouldUseSystemAngle ? android_get_exported_namespace("sphal") : nullptr); // parent ALOGD_IF(!mAngleNamespace, "Could not create ANGLE namespace from default"); if (!mUseSystemAngle) { if (!mShouldUseSystemAngle) { return mAngleNamespace; } Loading @@ -625,4 +626,8 @@ void GraphicsEnv::nativeToggleAngleAsSystemDriver(bool enabled) { gpuService->toggleAngleAsSystemDriver(enabled); } bool GraphicsEnv::shouldUseSystemAngle() { return mShouldUseSystemAngle; } } // namespace android libs/graphicsenv/include/graphicsenv/GraphicsEnv.h +2 −1 Original line number Diff line number Diff line Loading @@ -117,6 +117,7 @@ public: const std::vector<std::string>& getAngleEglFeatures(); // Set the persist.graphics.egl system property value. void nativeToggleAngleAsSystemDriver(bool enabled); bool shouldUseSystemAngle(); /* * Apis for debug layer Loading Loading @@ -173,7 +174,7 @@ private: // Whether ANGLE should be used. bool mShouldUseAngle = false; // Whether loader should load system ANGLE. bool mUseSystemAngle = false; bool mShouldUseSystemAngle = false; // ANGLE namespace. android_namespace_t* mAngleNamespace = nullptr; Loading opengl/libs/EGL/Loader.cpp +15 −10 Original line number Diff line number Diff line Loading @@ -161,8 +161,13 @@ static bool should_unload_system_driver(egl_connection_t* cnx) { // Return true if ANGLE namespace is set. android_namespace_t* ns = android::GraphicsEnv::getInstance().getAngleNamespace(); if (ns) { // Unless the default GLES driver is ANGLE and the process should use system ANGLE, since // the intended GLES driver is already loaded. // This should be updated in a later patch that cleans up namespaces if (!(cnx->angleLoaded && android::GraphicsEnv::getInstance().shouldUseSystemAngle())) { return true; } } // Return true if updated driver namespace is set. ns = android::GraphicsEnv::getInstance().getDriverNamespace(); Loading Loading @@ -206,17 +211,17 @@ void Loader::unload_system_driver(egl_connection_t* cnx) { do_android_unload_sphal_library(hnd->dso[0]); } cnx->dso = nullptr; cnx->angleLoaded = false; } cnx->systemDriverUnloaded = true; } void* Loader::open(egl_connection_t* cnx) { void* Loader::open(egl_connection_t* cnx) { ATRACE_CALL(); const nsecs_t openTime = systemTime(); if (should_unload_system_driver(cnx)) { if (cnx->dso && should_unload_system_driver(cnx)) { unload_system_driver(cnx); } Loading @@ -225,8 +230,12 @@ void* Loader::open(egl_connection_t* cnx) return cnx->dso; } // Firstly, try to load ANGLE driver. driver_t* hnd = attempt_to_load_angle(cnx); driver_t* hnd = nullptr; // Firstly, try to load ANGLE driver, if ANGLE should be loaded and fail, abort. if (android::GraphicsEnv::getInstance().shouldUseAngle()) { hnd = attempt_to_load_angle(cnx); LOG_ALWAYS_FATAL_IF(!hnd, "Failed to load ANGLE."); } if (!hnd) { // Secondly, try to load from driver apk. Loading Loading @@ -541,10 +550,6 @@ static void* load_updated_driver(const char* kind, android_namespace_t* ns) { Loader::driver_t* Loader::attempt_to_load_angle(egl_connection_t* cnx) { ATRACE_CALL(); if (!android::GraphicsEnv::getInstance().shouldUseAngle()) { return nullptr; } android_namespace_t* ns = android::GraphicsEnv::getInstance().getAngleNamespace(); if (!ns) { return nullptr; Loading Loading
libs/graphicsenv/GraphicsEnv.cpp +15 −10 Original line number Diff line number Diff line Loading @@ -402,7 +402,7 @@ bool GraphicsEnv::shouldUseAngle() { return mShouldUseAngle; } void GraphicsEnv::setAngleInfo(const std::string& path, const bool useSystemAngle, void GraphicsEnv::setAngleInfo(const std::string& path, const bool shouldUseSystemAngle, const std::string& packageName, const std::vector<std::string> eglFeatures) { if (mShouldUseAngle) { Loading @@ -420,7 +420,7 @@ void GraphicsEnv::setAngleInfo(const std::string& path, const bool useSystemAngl ALOGV("setting app package name to '%s'", packageName.c_str()); mPackageName = std::move(packageName); mShouldUseAngle = true; mUseSystemAngle = useSystemAngle; mShouldUseSystemAngle = shouldUseSystemAngle; } void GraphicsEnv::setLayerPaths(NativeLoaderNamespace* appNamespace, Loading Loading @@ -571,7 +571,7 @@ android_namespace_t* GraphicsEnv::getAngleNamespace() { return mAngleNamespace; } if (mAnglePath.empty() && !mUseSystemAngle) { if (mAnglePath.empty() && !mShouldUseSystemAngle) { ALOGV("mAnglePath is empty and not using system ANGLE, abort creating ANGLE namespace"); return nullptr; } Loading @@ -589,18 +589,19 @@ android_namespace_t* GraphicsEnv::getAngleNamespace() { // are properly inherited. mAngleNamespace = android_create_namespace("ANGLE", mUseSystemAngle ? defaultLibraryPaths mShouldUseSystemAngle ? defaultLibraryPaths : mAnglePath.c_str(), // ld_library_path mUseSystemAngle ? defaultLibraryPaths mShouldUseSystemAngle ? defaultLibraryPaths : mAnglePath.c_str(), // default_library_path ANDROID_NAMESPACE_TYPE_SHARED_ISOLATED, nullptr, // permitted_when_isolated_path mUseSystemAngle ? android_get_exported_namespace("sphal") mShouldUseSystemAngle ? android_get_exported_namespace("sphal") : nullptr); // parent ALOGD_IF(!mAngleNamespace, "Could not create ANGLE namespace from default"); if (!mUseSystemAngle) { if (!mShouldUseSystemAngle) { return mAngleNamespace; } Loading @@ -625,4 +626,8 @@ void GraphicsEnv::nativeToggleAngleAsSystemDriver(bool enabled) { gpuService->toggleAngleAsSystemDriver(enabled); } bool GraphicsEnv::shouldUseSystemAngle() { return mShouldUseSystemAngle; } } // namespace android
libs/graphicsenv/include/graphicsenv/GraphicsEnv.h +2 −1 Original line number Diff line number Diff line Loading @@ -117,6 +117,7 @@ public: const std::vector<std::string>& getAngleEglFeatures(); // Set the persist.graphics.egl system property value. void nativeToggleAngleAsSystemDriver(bool enabled); bool shouldUseSystemAngle(); /* * Apis for debug layer Loading Loading @@ -173,7 +174,7 @@ private: // Whether ANGLE should be used. bool mShouldUseAngle = false; // Whether loader should load system ANGLE. bool mUseSystemAngle = false; bool mShouldUseSystemAngle = false; // ANGLE namespace. android_namespace_t* mAngleNamespace = nullptr; Loading
opengl/libs/EGL/Loader.cpp +15 −10 Original line number Diff line number Diff line Loading @@ -161,8 +161,13 @@ static bool should_unload_system_driver(egl_connection_t* cnx) { // Return true if ANGLE namespace is set. android_namespace_t* ns = android::GraphicsEnv::getInstance().getAngleNamespace(); if (ns) { // Unless the default GLES driver is ANGLE and the process should use system ANGLE, since // the intended GLES driver is already loaded. // This should be updated in a later patch that cleans up namespaces if (!(cnx->angleLoaded && android::GraphicsEnv::getInstance().shouldUseSystemAngle())) { return true; } } // Return true if updated driver namespace is set. ns = android::GraphicsEnv::getInstance().getDriverNamespace(); Loading Loading @@ -206,17 +211,17 @@ void Loader::unload_system_driver(egl_connection_t* cnx) { do_android_unload_sphal_library(hnd->dso[0]); } cnx->dso = nullptr; cnx->angleLoaded = false; } cnx->systemDriverUnloaded = true; } void* Loader::open(egl_connection_t* cnx) { void* Loader::open(egl_connection_t* cnx) { ATRACE_CALL(); const nsecs_t openTime = systemTime(); if (should_unload_system_driver(cnx)) { if (cnx->dso && should_unload_system_driver(cnx)) { unload_system_driver(cnx); } Loading @@ -225,8 +230,12 @@ void* Loader::open(egl_connection_t* cnx) return cnx->dso; } // Firstly, try to load ANGLE driver. driver_t* hnd = attempt_to_load_angle(cnx); driver_t* hnd = nullptr; // Firstly, try to load ANGLE driver, if ANGLE should be loaded and fail, abort. if (android::GraphicsEnv::getInstance().shouldUseAngle()) { hnd = attempt_to_load_angle(cnx); LOG_ALWAYS_FATAL_IF(!hnd, "Failed to load ANGLE."); } if (!hnd) { // Secondly, try to load from driver apk. Loading Loading @@ -541,10 +550,6 @@ static void* load_updated_driver(const char* kind, android_namespace_t* ns) { Loader::driver_t* Loader::attempt_to_load_angle(egl_connection_t* cnx) { ATRACE_CALL(); if (!android::GraphicsEnv::getInstance().shouldUseAngle()) { return nullptr; } android_namespace_t* ns = android::GraphicsEnv::getInstance().getAngleNamespace(); if (!ns) { return nullptr; Loading