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

Commit 1e0c1cc1 authored by Tim Van Patten's avatar Tim Van Patten Committed by Android (Google) Code Review
Browse files

Merge "Update ANGLE Developer Options"

parents 616aca2f a2a60a00
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -135,8 +135,8 @@ void GraphicsEnv::setDriverPath(const std::string path) {
}

void GraphicsEnv::setAngleInfo(const std::string path, const std::string appName,
                               bool developerOptIn, const int rulesFd, const long rulesOffset,
                               const long rulesLength) {
                               const std::string developerOptIn, const int rulesFd,
                               const long rulesOffset, const long rulesLength) {
    if (!mAnglePath.empty()) {
        ALOGV("ignoring attempt to change ANGLE path from '%s' to '%s'", mAnglePath.c_str(),
              path.c_str());
@@ -153,7 +153,13 @@ void GraphicsEnv::setAngleInfo(const std::string path, const std::string appName
        mAngleAppName = appName;
    }

    if (!mAngleDeveloperOptIn.empty()) {
        ALOGV("ignoring attempt to change ANGLE application opt-in from '%s' to '%s'",
              mAngleDeveloperOptIn.c_str(), developerOptIn.c_str());
    } else {
        ALOGV("setting ANGLE application opt-in to '%s'", developerOptIn.c_str());
        mAngleDeveloperOptIn = developerOptIn;
    }

    ALOGV("setting ANGLE rules file descriptor to '%i'", rulesFd);
    mAngleRulesFd = rulesFd;
@@ -182,8 +188,8 @@ const char* GraphicsEnv::getAngleAppName() {
    return mAngleAppName.c_str();
}

bool GraphicsEnv::getAngleDeveloperOptIn() {
    return mAngleDeveloperOptIn;
const char* GraphicsEnv::getAngleDeveloperOptIn() {
    return mAngleDeveloperOptIn.c_str();
}

int GraphicsEnv::getAngleRulesFd() {
+3 −3
Original line number Diff line number Diff line
@@ -44,12 +44,12 @@ 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 setAngleInfo(const std::string path, const std::string appName, bool devOptIn,
    void setAngleInfo(const std::string path, const std::string appName, std::string devOptIn,
                      const int rulesFd, const long rulesOffset, const long rulesLength);
    android_namespace_t* getAngleNamespace();
    const char* getAngleAppName();
    const char* getAngleAppPref();
    bool getAngleDeveloperOptIn();
    const char* getAngleDeveloperOptIn();
    int getAngleRulesFd();
    long getAngleRulesOffset();
    long getAngleRulesLength();
@@ -69,7 +69,7 @@ private:
    std::string mDriverPath;
    std::string mAnglePath;
    std::string mAngleAppName;
    bool mAngleDeveloperOptIn;
    std::string mAngleDeveloperOptIn;
    int mAngleRulesFd;
    long mAngleRulesOffset;
    long mAngleRulesLength;
+23 −2
Original line number Diff line number Diff line
@@ -41,6 +41,12 @@
extern "C" {
  android_namespace_t* android_get_exported_namespace(const char*);

  typedef enum ANGLEPreference {
      ANGLE_PREFER_DEFAULT = 0,
      ANGLE_PREFER_NATIVE = 1,
      ANGLE_PREFER_ANGLE = 2,
  } ANGLEPreference;

  // TODO(ianelliott@): Get the following from an ANGLE header:
  // Version-1 API:
  typedef bool (*fpANGLEGetUtilityAPI)(unsigned int* versionToUse);
@@ -524,6 +530,17 @@ static void* load_angle_from_namespace(const char* kind, android_namespace_t* ns
    return nullptr;
}

static ANGLEPreference getAngleDevOption(const char* devOption) {
    if (devOption == nullptr)
        return ANGLE_PREFER_DEFAULT;

    if (strcmp(devOption, "angle") == 0) {
        return ANGLE_PREFER_ANGLE;
    } else if (strcmp(devOption, "native") == 0) {
        return ANGLE_PREFER_NATIVE;
    }
    return ANGLE_PREFER_DEFAULT;
}

static bool check_angle_rules(void* so, const char* app_name) {
    bool use_angle = false;
@@ -646,15 +663,19 @@ static void* load_angle(const char* kind, android_namespace_t* ns, egl_connectio
    char prop[PROPERTY_VALUE_MAX];

    const char* app_name = android::GraphicsEnv::getInstance().getAngleAppName();
    bool developer_opt_in = android::GraphicsEnv::getInstance().getAngleDeveloperOptIn();
    const char* developer_opt_in = android::GraphicsEnv::getInstance().getAngleDeveloperOptIn();

    // Determine whether or not to use ANGLE:
    bool use_angle = developer_opt_in;
    ANGLEPreference developer_option = getAngleDevOption(developer_opt_in);
    bool use_angle = (developer_option == ANGLE_PREFER_ANGLE);

    if (use_angle) {
        ALOGV("User set \"Developer Options\" to force the use of ANGLE");
    } else if (cnx->angleDecided) {
        use_angle = cnx->useAngle;
    } else if (developer_option == ANGLE_PREFER_NATIVE) {
        ALOGV("User set \"Developer Options\" to force the use of Native");
        use_angle = false;
    } 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: