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

Commit 7eeb0eb6 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes from topic "gpuprio" into pi-dev

* changes:
  Add ThreadedRendererCompat for Launcher use
  Add ability to change context priority of RT GL context
parents c5fdecaa e4428857
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -190,6 +190,10 @@ public final class ThreadedRenderer {
     */
    public static final String DEBUG_FPS_DIVISOR = "debug.hwui.fps_divisor";

    public static int EGL_CONTEXT_PRIORITY_HIGH_IMG = 0x3101;
    public static int EGL_CONTEXT_PRIORITY_MEDIUM_IMG = 0x3102;
    public static int EGL_CONTEXT_PRIORITY_LOW_IMG = 0x3103;

    static {
        // Try to check OpenGL support early if possible.
        isAvailable();
@@ -1140,6 +1144,16 @@ public final class ThreadedRenderer {
        nHackySetRTAnimationsEnabled(divisor <= 1);
    }

    /**
     * Changes the OpenGL context priority if IMG_context_priority extension is available. Must be
     * called before any OpenGL context is created.
     *
     * @param priority The priority to use. Must be one of EGL_CONTEXT_PRIORITY_* values.
     */
    public static void setContextPriority(int priority) {
        nSetContextPriority(priority);
    }

    /** Not actually public - internal use only. This doc to make lint happy */
    public static native void disableVsync();

@@ -1213,4 +1227,5 @@ public final class ThreadedRenderer {
    private static native void nHackySetRTAnimationsEnabled(boolean enabled);
    private static native void nSetDebuggingEnabled(boolean enabled);
    private static native void nSetIsolatedProcess(boolean enabled);
    private static native void nSetContextPriority(int priority);
}
+5 −0
Original line number Diff line number Diff line
@@ -992,6 +992,10 @@ static void android_view_ThreadedRenderer_setIsolatedProcess(JNIEnv*, jclass, jb
    Properties::isolatedProcess = isolated;
}

static void android_view_ThreadedRenderer_setContextPriority(JNIEnv*, jclass,
        jint contextPriority) {
    Properties::contextPriority = contextPriority;
}

// ----------------------------------------------------------------------------
// FrameMetricsObserver
@@ -1103,6 +1107,7 @@ static const JNINativeMethod gMethods[] = {
            (void*)android_view_ThreadedRenderer_hackySetRTAnimationsEnabled },
    { "nSetDebuggingEnabled", "(Z)V", (void*)android_view_ThreadedRenderer_setDebuggingEnabled },
    { "nSetIsolatedProcess", "(Z)V", (void*)android_view_ThreadedRenderer_setIsolatedProcess },
    { "nSetContextPriority", "(I)V", (void*)android_view_ThreadedRenderer_setContextPriority },
};

static JavaVM* mJvm = nullptr;
+2 −0
Original line number Diff line number Diff line
@@ -65,6 +65,8 @@ bool Properties::runningInEmulator = false;
bool Properties::debuggingEnabled = false;
bool Properties::isolatedProcess = false;

int Properties::contextPriority = 0;

static int property_get_int(const char* key, int defaultValue) {
    char buf[PROPERTY_VALUE_MAX] = {
            '\0',
+2 −0
Original line number Diff line number Diff line
@@ -271,6 +271,8 @@ public:
    ANDROID_API static bool debuggingEnabled;
    ANDROID_API static bool isolatedProcess;

    ANDROID_API static int contextPriority;

private:
    static ProfileType sProfileType;
    static bool sDisableProfileBars;
+12 −2
Original line number Diff line number Diff line
@@ -82,6 +82,7 @@ static struct {
    bool pixelFormatFloat = false;
    bool glColorSpace = false;
    bool scRGB = false;
    bool contextPriority = false;
} EglExtensions;

EglManager::EglManager(RenderThread& thread)
@@ -168,6 +169,7 @@ void EglManager::initExtensions() {
#else
    EglExtensions.scRGB = extensions.has("EGL_EXT_gl_colorspace_scrgb");
#endif
    EglExtensions.contextPriority = extensions.has("EGL_IMG_context_priority");
}

bool EglManager::hasEglContext() {
@@ -247,10 +249,18 @@ void EglManager::loadConfigs() {
}

void EglManager::createContext() {
    EGLint attribs[] = {EGL_CONTEXT_CLIENT_VERSION, GLES_VERSION, EGL_NONE};
    std::vector<EGLint> contextAttributes;
    contextAttributes.reserve(5);
    contextAttributes.push_back(EGL_CONTEXT_CLIENT_VERSION);
    contextAttributes.push_back(GLES_VERSION);
    if (Properties::contextPriority != 0 && EglExtensions.contextPriority) {
        contextAttributes.push_back(EGL_CONTEXT_PRIORITY_LEVEL_IMG);
        contextAttributes.push_back(Properties::contextPriority);
    }
    contextAttributes.push_back(EGL_NONE);
    mEglContext = eglCreateContext(
            mEglDisplay, EglExtensions.noConfigContext ? ((EGLConfig) nullptr) : mEglConfig,
            EGL_NO_CONTEXT, attribs);
            EGL_NO_CONTEXT, contextAttributes.data());
    LOG_ALWAYS_FATAL_IF(mEglContext == EGL_NO_CONTEXT, "Failed to create context, error = %s",
                        eglErrorString());
}
Loading