Loading opengl/java/android/opengl/GLSurfaceView.java +46 −32 Original line number Diff line number Diff line Loading @@ -971,17 +971,9 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback * accesses EGL. */ try { try { sGLThreadManager.start(this); } catch (InterruptedException e) { return; } guardedRun(); } catch (InterruptedException e) { // fall thru and exit normally } finally { try { sGLThreadManager.end(this); } finally { synchronized(this) { if (LOG_THREADS) { Loading @@ -992,12 +984,28 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback } } } private void startEgl() throws InterruptedException { if (! mHaveEgl) { mHaveEgl = true; sGLThreadManager.start(this); mEglHelper.start(); } } private void stopEgl() { if (mHaveEgl) { mHaveEgl = false; mEglHelper.destroySurface(); mEglHelper.finish(); sGLThreadManager.end(this); } } private void guardedRun() throws InterruptedException { mEglHelper = new EglHelper(); try { mEglHelper.start(); startEgl(); GL10 gl = null; boolean tellRendererSurfaceCreated = true; Loading @@ -1021,20 +1029,30 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback r.run(); } if (mPaused) { mEglHelper.destroySurface(); mEglHelper.finish(); stopEgl(); needStart = true; } while (needToWait()) { if (LOG_THREADS) { Log.i("GLThread", "needToWait tid=" + getId()); } while(true) { if (!mHasSurface) { if (!mWaitingForSurface) { mEglHelper.destroySurface(); stopEgl(); mWaitingForSurface = true; notifyAll(); } } else { boolean shouldHaveEgl = sGLThreadManager.shouldHaveEgl(this); if (mHaveEgl && (!shouldHaveEgl)) { stopEgl(); } else if ((!mHaveEgl) && shouldHaveEgl) { startEgl(); needStart = true; } } if (!needToWait()) { break; } if (LOG_THREADS) { Log.i("GLThread", "needToWait tid=" + getId()); } wait(); } Loading @@ -1053,7 +1071,7 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback } } if (needStart) { mEglHelper.start(); startEgl(); tellRendererSurfaceCreated = true; changed = true; } Loading Loading @@ -1084,21 +1102,16 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback /* * clean-up everything... */ mEglHelper.destroySurface(); mEglHelper.finish(); stopEgl(); } } private boolean needToWait() { if (sGLThreadManager.shouldQuit(this)) { mDone = true; notifyAll(); } if (mDone) { return false; } if (mPaused || (! mHasSurface)) { if (mPaused || (! mHasSurface) || (! mHaveEgl)) { return true; } Loading Loading @@ -1223,6 +1236,7 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback private boolean mPaused; private boolean mHasSurface; private boolean mWaitingForSurface; private boolean mHaveEgl; private int mWidth; private int mHeight; private int mRenderMode; Loading Loading @@ -1273,9 +1287,9 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback } static class GLThreadManager { public boolean shouldQuit(GLThread thread) { public boolean shouldHaveEgl(GLThread thread) { synchronized(this) { return thread != mMostRecentGLThread; return thread == mMostRecentGLThread || mMostRecentGLThread == null; } } public void start(GLThread thread) throws InterruptedException { Loading Loading
opengl/java/android/opengl/GLSurfaceView.java +46 −32 Original line number Diff line number Diff line Loading @@ -971,17 +971,9 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback * accesses EGL. */ try { try { sGLThreadManager.start(this); } catch (InterruptedException e) { return; } guardedRun(); } catch (InterruptedException e) { // fall thru and exit normally } finally { try { sGLThreadManager.end(this); } finally { synchronized(this) { if (LOG_THREADS) { Loading @@ -992,12 +984,28 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback } } } private void startEgl() throws InterruptedException { if (! mHaveEgl) { mHaveEgl = true; sGLThreadManager.start(this); mEglHelper.start(); } } private void stopEgl() { if (mHaveEgl) { mHaveEgl = false; mEglHelper.destroySurface(); mEglHelper.finish(); sGLThreadManager.end(this); } } private void guardedRun() throws InterruptedException { mEglHelper = new EglHelper(); try { mEglHelper.start(); startEgl(); GL10 gl = null; boolean tellRendererSurfaceCreated = true; Loading @@ -1021,20 +1029,30 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback r.run(); } if (mPaused) { mEglHelper.destroySurface(); mEglHelper.finish(); stopEgl(); needStart = true; } while (needToWait()) { if (LOG_THREADS) { Log.i("GLThread", "needToWait tid=" + getId()); } while(true) { if (!mHasSurface) { if (!mWaitingForSurface) { mEglHelper.destroySurface(); stopEgl(); mWaitingForSurface = true; notifyAll(); } } else { boolean shouldHaveEgl = sGLThreadManager.shouldHaveEgl(this); if (mHaveEgl && (!shouldHaveEgl)) { stopEgl(); } else if ((!mHaveEgl) && shouldHaveEgl) { startEgl(); needStart = true; } } if (!needToWait()) { break; } if (LOG_THREADS) { Log.i("GLThread", "needToWait tid=" + getId()); } wait(); } Loading @@ -1053,7 +1071,7 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback } } if (needStart) { mEglHelper.start(); startEgl(); tellRendererSurfaceCreated = true; changed = true; } Loading Loading @@ -1084,21 +1102,16 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback /* * clean-up everything... */ mEglHelper.destroySurface(); mEglHelper.finish(); stopEgl(); } } private boolean needToWait() { if (sGLThreadManager.shouldQuit(this)) { mDone = true; notifyAll(); } if (mDone) { return false; } if (mPaused || (! mHasSurface)) { if (mPaused || (! mHasSurface) || (! mHaveEgl)) { return true; } Loading Loading @@ -1223,6 +1236,7 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback private boolean mPaused; private boolean mHasSurface; private boolean mWaitingForSurface; private boolean mHaveEgl; private int mWidth; private int mHeight; private int mRenderMode; Loading Loading @@ -1273,9 +1287,9 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback } static class GLThreadManager { public boolean shouldQuit(GLThread thread) { public boolean shouldHaveEgl(GLThread thread) { synchronized(this) { return thread != mMostRecentGLThread; return thread == mMostRecentGLThread || mMostRecentGLThread == null; } } public void start(GLThread thread) throws InterruptedException { Loading