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

Commit f8d47b88 authored by Romain Guy's avatar Romain Guy Committed by Android (Google) Code Review
Browse files

Merge "Fallback to software rendering when eglMakeCurrent fails. Bug #3200621"

parents 02b93914 9745fae7
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()));
                }
            }
        }