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

Commit 0f897d2f authored by Nicolas Capens's avatar Nicolas Capens
Browse files

Check GLES2 support using EGL instead of qemu.gles

Bug 25435727

Change-Id: I9b8816cc8bfc2567ac475888cd57f2b9e62dad4f
parent 9370f14a
Loading
Loading
Loading
Loading
+11 −8
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
#include <android_runtime/AndroidRuntime.h>

#include <cutils/properties.h>
#include <EGL/egl.h>

#include <SkBitmap.h>
#include <SkRegion.h>
@@ -146,15 +147,17 @@ static void android_view_DisplayListCanvas_drawLayer(JNIEnv* env, jobject clazz,
// ----------------------------------------------------------------------------

static jboolean android_view_DisplayListCanvas_isAvailable(JNIEnv* env, jobject clazz) {
    char prop[PROPERTY_VALUE_MAX];
    if (property_get("ro.kernel.qemu", prop, NULL) == 0) {
        // not in the emulator
        return JNI_TRUE;
    }
    // In the emulator this property will be set to 1 when hardware GLES is
    // enabled, 0 otherwise. On old emulator versions it will be undefined.
    property_get("ro.kernel.qemu.gles", prop, "0");
    return atoi(prop) == 1 ? JNI_TRUE : JNI_FALSE;
    static EGLint numES2Configs = -1;

    if (numES2Configs == -1) {
        EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
        EGLint major; EGLint minor;
        eglInitialize(display, &major, &minor);
        EGLint configAttribs[] = {EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_NONE};
        eglChooseConfig(display, configAttribs, NULL, 0, &numES2Configs);
    }

    return (numES2Configs > 0) ? JNI_TRUE : JNI_FALSE;
}

// ----------------------------------------------------------------------------