Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d41ef257 authored by Courtney Goeltzenleuchter's avatar Courtney Goeltzenleuchter
Browse files

Pass more ANGLE info from runtime

In order to facilitate ANGLE selection logic in the backend, we need to
start sending more information from GraphicsEnvironment.  This includes
the application name, whether the developer opted in, and the list can
be expanded.  We also have to send the ANGLE namespace unconditionally
in case the application opts in programmatically.

Bug: 80239516
Test: Manual build, booted clean, ensured developer opt-in still works.
Change-Id: I3b8f99942999de6a3188d2e61355dcd244f9191e
(cherry picked from commit 6a88da6463f019ad1e3aea184e6ac6f5264fae50)
parent 48de5423
Loading
Loading
Loading
Loading
+30 −4
Original line number Diff line number Diff line
@@ -56,16 +56,27 @@ void GraphicsEnv::setDriverPath(const std::string path) {
    mDriverPath = path;
}

void GraphicsEnv::setAnglePath(const std::string path) {
void GraphicsEnv::setAngleInfo(const std::string path, const std::string appName,
                               bool developerOptIn) {
    if (!mAnglePath.empty()) {
        ALOGV("ignoring attempt to change ANGLE path from '%s' to '%s'", mAnglePath.c_str(),
              path.c_str());
        return;
    }
    } else {
        ALOGV("setting ANGLE path to '%s'", path.c_str());
        mAnglePath = path;
    }

    if (!mAngleAppName.empty()) {
        ALOGV("ignoring attempt to change ANGLE app name from '%s' to '%s'", mAngleAppName.c_str(),
              appName.c_str());
    } else {
        ALOGV("setting ANGLE app name to '%s'", appName.c_str());
        mAngleAppName = appName;
    }

    mAngleDeveloperOptIn = developerOptIn;
}

void GraphicsEnv::setLayerPaths(NativeLoaderNamespace* appNamespace, const std::string layerPaths) {
    if (mLayerPaths.empty()) {
        mLayerPaths = layerPaths;
@@ -80,6 +91,15 @@ NativeLoaderNamespace* GraphicsEnv::getAppNamespace() {
    return mAppNamespace;
}

const char* GraphicsEnv::getAngleAppName() {
    if (mAngleAppName.empty()) return nullptr;
    return mAngleAppName.c_str();
}

bool GraphicsEnv::getAngleDeveloperOptIn() {
    return mAngleDeveloperOptIn;
}

const std::string GraphicsEnv::getLayerPaths(){
    return mLayerPaths;
}
@@ -139,4 +159,10 @@ android_namespace_t* android_getDriverNamespace() {
android_namespace_t* android_getAngleNamespace() {
    return android::GraphicsEnv::getInstance().getAngleNamespace();
}
const char* android_getAngleAppName() {
    return android::GraphicsEnv::getInstance().getAngleAppName();
}
bool android_getAngleDeveloperOptIn() {
    return android::GraphicsEnv::getInstance().getAngleDeveloperOptIn();
}
}
+11 −3
Original line number Diff line number Diff line
@@ -42,8 +42,10 @@ public:
    // (libraries must be stored uncompressed and page aligned); such elements
    // in the search path must have a '!' after the zip filename, e.g.
    //     /system/app/ANGLEPrebuilt/ANGLEPrebuilt.apk!/lib/arm64-v8a
    void setAnglePath(const std::string path);
    void setAngleInfo(const std::string path, const std::string appName, const bool optIn);
    android_namespace_t* getAngleNamespace();
    const char* getAngleAppName();
    bool getAngleDeveloperOptIn();

    void setLayerPaths(NativeLoaderNamespace* appNamespace, const std::string layerPaths);
    NativeLoaderNamespace* getAppNamespace();
@@ -57,6 +59,8 @@ private:
    GraphicsEnv() = default;
    std::string mDriverPath;
    std::string mAnglePath;
    std::string mAngleAppName;
    bool mAngleDeveloperOptIn;
    std::string mDebugLayers;
    std::string mLayerPaths;
    android_namespace_t* mDriverNamespace = nullptr;
@@ -77,7 +81,11 @@ private:
 *  - the EGLsyncKHR synchronization in BufferQueue, which is deprecated and
 *    will be removed soon.
 */
extern "C" android_namespace_t* android_getDriverNamespace();
extern "C" android_namespace_t* android_getAngleNamespace();
extern "C" {
android_namespace_t* android_getDriverNamespace();
android_namespace_t* android_getAngleNamespace();
const char* android_getAngleAppName();
bool android_getAngleDeveloperOptIn();
}

#endif // ANDROID_UI_GRAPHICS_ENV_H
+13 −5
Original line number Diff line number Diff line
@@ -475,7 +475,7 @@ static void* load_angle_from_namespace(const char* kind, android_namespace_t* ns
    return nullptr;
}

static void* load_angle(const char* kind, android_namespace_t* ns, egl_connection_t* cnx) {
static void* load_angle(const char* kind, egl_connection_t* cnx) {
    // Only attempt to load ANGLE libs
    if (strcmp(kind, "EGL") != 0 && strcmp(kind, "GLESv2") != 0 && strcmp(kind, "GLESv1_CM") != 0)
        return nullptr;
@@ -483,11 +483,20 @@ static void* load_angle(const char* kind, android_namespace_t* ns, egl_connectio
    void* so = nullptr;
    std::string name;

    android_namespace_t* ns = android_getAngleNamespace();
    const char* app_name = android_getAngleAppName();
    bool developer_opt_in = android_getAngleDeveloperOptIn();

    if (ns) {
        // If we got a namespce for ANGLE, check any other conditions
        // before loading from it.
        if (developer_opt_in) {
            so = load_angle_from_namespace(kind, ns);
        }
    }

    if (so) {
        ALOGD("Loaded ANGLE libraries for %s", app_name ? app_name : "nullptr");
        cnx->useAngle = true;
        // Find and load vendor libEGL for ANGLE
        if (!cnx->vendorEGL) {
@@ -530,11 +539,10 @@ void *Loader::load_driver(const char* kind,
    ATRACE_CALL();

    void* dso = nullptr;
    android_namespace_t* ns = android_getAngleNamespace();
    dso = load_angle(kind, ns, cnx);
    dso = load_angle(kind, cnx);
#ifndef __ANDROID_VNDK__
    if (!dso) {
        ns = android_getDriverNamespace();
        android_namespace_t* ns = android_getDriverNamespace();
        if (ns) {
            dso = load_updated_driver(kind, ns);
        }