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

Commit 9745fae7 authored by Romain Guy's avatar Romain Guy
Browse files

Fallback to software rendering when eglMakeCurrent fails.

Bug #3200621

Change-Id: Id8a455e64a1af23840752124b49c070c00e5e2a6
parent 67f27952
Loading
Loading
Loading
Loading
+15 −11
Original line number Diff line number Diff line
@@ -184,7 +184,7 @@ public abstract class HardwareRenderer {
    }

    /**
     * Indicates whether hardware acceleration is currently request but not
     * Indicates whether hardware acceleration is currently requested but not
     * necessarily enabled yet.
     * 
     * @return True to request hardware acceleration, false otherwise.
@@ -275,17 +275,20 @@ public abstract class HardwareRenderer {
                if (error != EGL10.EGL_SUCCESS) {
                    // something bad has happened revert to
                    // normal rendering.
                    fallback(error != EGL11.EGL_CONTEXT_LOST);
                    Log.w(LOG_TAG, "EGL error: " + getEGLErrorString(error));
                }
            }
        }

        private void fallback(boolean fallback) {
            destroy(true);
                    if (error != EGL11.EGL_CONTEXT_LOST) {
            if (fallback) {
                // we'll try again if it was context lost
                setRequested(false);
                    } else {
                Log.w(LOG_TAG, "Mountain View, we've had a problem here. " 
                        + "Switching back to software rendering.");
            }
                    Log.w(LOG_TAG, "EGL error: " + getEGLErrorString(error));
                }
            }
        }

        @Override
@@ -509,8 +512,9 @@ public abstract class HardwareRenderer {
            if (sEgl.eglGetCurrentContext() != sEglContext ||
                    sEgl.eglGetCurrentSurface(EGL10.EGL_DRAW) != mEglSurface) {
                if (!sEgl.eglMakeCurrent(sEglDisplay, mEglSurface, mEglSurface, sEglContext)) {
                    throw new RuntimeException("eglMakeCurrent failed "
                            + getEGLErrorString(sEgl.eglGetError()));
                    fallback(true);
                    Log.e(LOG_TAG, "eglMakeCurrent failed " +
                            getEGLErrorString(sEgl.eglGetError()));
                }
            }
        }