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

Commit c6133285 authored by Romain Guy's avatar Romain Guy
Browse files

Fix native crash when enabling hardware acceleration.

This change also prevents hardware acceleration when the ViewRoot is in the
system process. This causes problem in EGL intialization because of having
both a SurfaceControl and a Surface. This is not needed and better to leave
it off anyway (so that preview windows don't get unnecessary hw acceleration.)

Change-Id: I1cc55d7fb9a4c1a9c4c59f11f49d3e44de78acef
parent 0889adde
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -259,11 +259,17 @@ public final class ViewRoot extends Handler implements ViewParent, View.AttachIn
        mViewConfiguration = ViewConfiguration.get(context);
        mDensity = context.getResources().getDisplayMetrics().densityDpi;

        // Only enable hardware acceleration if we are not in the system process
        // The window manager creates ViewRoots to display animated preview windows
        // of launching apps and we don't want those to be hardware accelerated
        if (Process.myUid() != Process.SYSTEM_UID) {
            // Try to enable hardware acceleration if requested
        if ((context.getApplicationInfo().flags & ApplicationInfo.FLAG_HARDWARE_ACCELERATED) != 0) {
            if ((context.getApplicationInfo().flags &
                    ApplicationInfo.FLAG_HARDWARE_ACCELERATED) != 0) {
                mHwRenderer = HardwareRenderer.createGlRenderer(1);
            }
        }
    }

    // For debug only
    /*
+2 −0
Original line number Diff line number Diff line
@@ -114,6 +114,7 @@ extern int register_android_graphics_Xfermode(JNIEnv* env);
extern int register_android_graphics_PixelFormat(JNIEnv* env);
extern int register_com_android_internal_graphics_NativeUtils(JNIEnv *env);
extern int register_android_view_Display(JNIEnv* env);
extern int register_android_view_HardwareRenderer(JNIEnv* env);
extern int register_android_view_Surface(JNIEnv* env);
extern int register_android_view_ViewRoot(JNIEnv* env);
extern int register_android_database_CursorWindow(JNIEnv* env);
@@ -1207,6 +1208,7 @@ static const RegJNIRec gRegJNI[] = {
    REG_JNI(register_android_nio_utils),
    REG_JNI(register_android_graphics_PixelFormat),
    REG_JNI(register_android_graphics_Graphics),
    REG_JNI(register_android_view_HardwareRenderer),
    REG_JNI(register_android_view_Surface),
    REG_JNI(register_android_view_ViewRoot),
    REG_JNI(register_com_google_android_gles_jni_EGLImpl),