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

Commit 9aa8ef74 authored by Jesse Hall's avatar Jesse Hall Committed by Android Git Automerger
Browse files

am 1887af43: Merge "Allow 16-bit color EGLConfigs" into jb-mr1-dev

* commit '1887af43':
  Allow 16-bit color EGLConfigs
parents 278b3016 1887af43
Loading
Loading
Loading
Loading
+27 −11
Original line number Original line Diff line number Diff line
@@ -268,25 +268,41 @@ EGLConfig SurfaceFlinger::selectEGLConfig(EGLDisplay display, EGLint nativeVisua


    EGLint attribs[] = {
    EGLint attribs[] = {
            EGL_SURFACE_TYPE,           EGL_WINDOW_BIT,
            EGL_SURFACE_TYPE,           EGL_WINDOW_BIT,
            // The rest of the attributes must be in this order and at the end
            // of the list; we rely on that for fallback searches below.
            EGL_RED_SIZE,               8,
            EGL_RED_SIZE,               8,
            EGL_GREEN_SIZE,             8,
            EGL_GREEN_SIZE,             8,
            EGL_BLUE_SIZE,              8,
            EGL_BLUE_SIZE,              8,
            // EGL_RECORDABLE_ANDROID must be last so that we can retry
            // without it easily (see below)
            EGL_RECORDABLE_ANDROID,     EGL_TRUE,
            EGL_RECORDABLE_ANDROID,     EGL_TRUE,
            EGL_NONE
            EGL_NONE
    };
    };
    err = selectConfigForPixelFormat(display, attribs, nativeVisualId, &config);
    err = selectConfigForPixelFormat(display, attribs, nativeVisualId, &config);
    if (err) {
    if (!err)
        goto success;

    // maybe we failed because of EGL_RECORDABLE_ANDROID
    // maybe we failed because of EGL_RECORDABLE_ANDROID
        ALOGW("couldn't find an EGLConfig with EGL_RECORDABLE_ANDROID");
    ALOGW("no suitable EGLConfig found, trying without EGL_RECORDABLE_ANDROID");
    attribs[NELEM(attribs) - 3] = EGL_NONE;
    attribs[NELEM(attribs) - 3] = EGL_NONE;
    err = selectConfigForPixelFormat(display, attribs, nativeVisualId, &config);
    err = selectConfigForPixelFormat(display, attribs, nativeVisualId, &config);
    }
    if (!err)
    ALOGE_IF(err, "couldn't find an EGLConfig matching the screen format");
        goto success;
    if (eglGetConfigAttrib(display, config, EGL_CONFIG_CAVEAT, &dummy) == EGL_TRUE) {

    // allow less than 24-bit color; the non-gpu-accelerated emulator only
    // supports 16-bit color
    ALOGW("no suitable EGLConfig found, trying with 16-bit color allowed");
    attribs[NELEM(attribs) - 9] = EGL_NONE;
    err = selectConfigForPixelFormat(display, attribs, nativeVisualId, &config);
    if (!err)
        goto success;

    // this EGL is too lame for Android
    ALOGE("no suitable EGLConfig found, giving up");

    return 0;

success:
    if (eglGetConfigAttrib(display, config, EGL_CONFIG_CAVEAT, &dummy))
        ALOGW_IF(dummy == EGL_SLOW_CONFIG, "EGL_SLOW_CONFIG selected!");
        ALOGW_IF(dummy == EGL_SLOW_CONFIG, "EGL_SLOW_CONFIG selected!");
    }
    return config;
    return config;
}
}