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

Commit 4a2221ec authored by Jack Palevich's avatar Jack Palevich
Browse files

Fix inverted release-EGLContext-on-pause logic.

This works around a bug in the
"Q3Dimension MSM7500" driver. That driver only
supports a single active EGLContext, so we must
release and restore the EGLContext when pausing
and unpausing.

Unfortunately the test for deciding whether to
release the context was inverted. We were
releasing the context on every device besides
the MSM7500 devices, which was a performance
drain, and we were not releasing the context on
the MSM7500, which meant the underlying driver
bug was not worked around.

Now we release the EGL context when pausing only
on the devices that have the bug.
parent 931bf89d
Loading
Loading
Loading
Loading
+18 −5
Original line number Diff line number Diff line
@@ -149,6 +149,7 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback
    private final static boolean LOG_THREADS = false;
    private final static boolean LOG_SURFACE = false;
    private final static boolean LOG_RENDERER = false;
    private final static boolean LOG_RENDERER_DRAW_FRAME = false;
    // Work-around for bug 2263168
    private final static boolean DRAW_TWICE_AFTER_SIZE_CHANGED = true;
    /**
@@ -1209,15 +1210,18 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback
                    }

                    if (createEglSurface) {
                        if (LOG_SURFACE) {
                            Log.w("GLThread", "egl createSurface");
                        }
                        gl = (GL10) mEglHelper.createSurface(getHolder());
                        sGLThreadManager.checkGLDriver(gl);
                        if (LOG_RENDERER) {
                            Log.w("GLThread", "onSurfaceCreated");
                        }
                        createEglSurface = false;
                    }

                    if (createEglContext) {
                        if (LOG_RENDERER) {
                            Log.w("GLThread", "onSurfaceCreated");
                        }
                        mRenderer.onSurfaceCreated(gl, mEglHelper.mEglConfig);
                        createEglContext = false;
                    }
@@ -1230,7 +1234,7 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback
                        sizeChanged = false;
                    }

                    if (LOG_RENDERER) {
                    if (LOG_RENDERER_DRAW_FRAME) {
                        Log.w("GLThread", "onDrawFrame");
                    }
                    mRenderer.onDrawFrame(gl);
@@ -1438,6 +1442,7 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback
    }

    private static class GLThreadManager {
        private static String TAG = "GLThreadManager";

        public synchronized void threadExiting(GLThread thread) {
            if (LOG_THREADS) {
@@ -1483,7 +1488,7 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback

        public synchronized boolean shouldReleaseEGLContextWhenPausing() {
            checkGLESVersion();
            return mMultipleGLESContextsAllowed;
            return !mMultipleGLESContextsAllowed;
        }

        public synchronized void checkGLDriver(GL10 gl) {
@@ -1493,6 +1498,10 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback
                    String renderer = gl.glGetString(GL10.GL_RENDERER);
                    mMultipleGLESContextsAllowed =
                        ! renderer.startsWith(kMSM7K_RENDERER_PREFIX);
                    if (LOG_SURFACE) {
                        Log.w(TAG, "checkGLDriver renderer = \"" + renderer + "\" multipleContextsAllowed = "
                            + mMultipleGLESContextsAllowed);
                    }
                    notifyAll();
                }
                mGLESDriverCheckComplete = true;
@@ -1507,6 +1516,10 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback
                if (mGLESVersion >= kGLES_20) {
                    mMultipleGLESContextsAllowed = true;
                }
                if (LOG_SURFACE) {
                    Log.w(TAG, "checkGLESVersion mGLESVersion =" +
                            " " + mGLESVersion + " mMultipleGLESContextsAllowed = " + mMultipleGLESContextsAllowed);
                }
                mGLESVersionCheckComplete = true;
            }
        }