Merge change 26270 into eclair

* changes:
  Fix GLSurfaceView to sync surfaceDestroyed with GL rendering thread
This commit is contained in:
Android (Google) Code Review
2009-09-21 19:00:37 -04:00

View File

@ -826,7 +826,7 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback
return mEgl.eglGetError() != EGL11.EGL_CONTEXT_LOST;
}
public void finish() {
public void destroySurface() {
if (mEglSurface != null) {
mEgl.eglMakeCurrent(mEglDisplay, EGL10.EGL_NO_SURFACE,
EGL10.EGL_NO_SURFACE,
@ -834,6 +834,9 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback
mEgl.eglDestroySurface(mEglDisplay, mEglSurface);
mEglSurface = null;
}
}
public void finish() {
if (mEglContext != null) {
mEgl.eglDestroyContext(mEglDisplay, mEglContext);
mEglContext = null;
@ -919,10 +922,18 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback
r.run();
}
if (mPaused) {
mEglHelper.destroySurface();
mEglHelper.finish();
needStart = true;
}
while (needToWait()) {
if (!mHasSurface) {
if (!mWaitingForSurface) {
mEglHelper.destroySurface();
mWaitingForSurface = true;
notify();
}
}
wait();
}
if (mDone) {
@ -933,6 +944,11 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback
h = mHeight;
mSizeChanged = false;
mRequestRender = false;
if (mHasSurface && mWaitingForSurface) {
changed = true;
mWaitingForSurface = false;
mRequestRender = true; // Forces a redraw for RENDERMODE_RENDER_WHEN_DIRTY
}
}
if (needStart) {
mEglHelper.start();
@ -966,6 +982,7 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback
/*
* clean-up everything...
*/
mEglHelper.destroySurface();
mEglHelper.finish();
}
@ -1021,6 +1038,13 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback
synchronized(this) {
mHasSurface = false;
notify();
while(!mWaitingForSurface) {
try {
wait();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
}
}
@ -1083,6 +1107,7 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback
private boolean mDone;
private boolean mPaused;
private boolean mHasSurface;
private boolean mWaitingForSurface;
private int mWidth;
private int mHeight;
private int mRenderMode;