Merge change 26270 into eclair
* changes: Fix GLSurfaceView to sync surfaceDestroyed with GL rendering thread
This commit is contained in:
@ -826,7 +826,7 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback
|
|||||||
return mEgl.eglGetError() != EGL11.EGL_CONTEXT_LOST;
|
return mEgl.eglGetError() != EGL11.EGL_CONTEXT_LOST;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void finish() {
|
public void destroySurface() {
|
||||||
if (mEglSurface != null) {
|
if (mEglSurface != null) {
|
||||||
mEgl.eglMakeCurrent(mEglDisplay, EGL10.EGL_NO_SURFACE,
|
mEgl.eglMakeCurrent(mEglDisplay, EGL10.EGL_NO_SURFACE,
|
||||||
EGL10.EGL_NO_SURFACE,
|
EGL10.EGL_NO_SURFACE,
|
||||||
@ -834,6 +834,9 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback
|
|||||||
mEgl.eglDestroySurface(mEglDisplay, mEglSurface);
|
mEgl.eglDestroySurface(mEglDisplay, mEglSurface);
|
||||||
mEglSurface = null;
|
mEglSurface = null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void finish() {
|
||||||
if (mEglContext != null) {
|
if (mEglContext != null) {
|
||||||
mEgl.eglDestroyContext(mEglDisplay, mEglContext);
|
mEgl.eglDestroyContext(mEglDisplay, mEglContext);
|
||||||
mEglContext = null;
|
mEglContext = null;
|
||||||
@ -919,10 +922,18 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback
|
|||||||
r.run();
|
r.run();
|
||||||
}
|
}
|
||||||
if (mPaused) {
|
if (mPaused) {
|
||||||
|
mEglHelper.destroySurface();
|
||||||
mEglHelper.finish();
|
mEglHelper.finish();
|
||||||
needStart = true;
|
needStart = true;
|
||||||
}
|
}
|
||||||
while (needToWait()) {
|
while (needToWait()) {
|
||||||
|
if (!mHasSurface) {
|
||||||
|
if (!mWaitingForSurface) {
|
||||||
|
mEglHelper.destroySurface();
|
||||||
|
mWaitingForSurface = true;
|
||||||
|
notify();
|
||||||
|
}
|
||||||
|
}
|
||||||
wait();
|
wait();
|
||||||
}
|
}
|
||||||
if (mDone) {
|
if (mDone) {
|
||||||
@ -933,6 +944,11 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback
|
|||||||
h = mHeight;
|
h = mHeight;
|
||||||
mSizeChanged = false;
|
mSizeChanged = false;
|
||||||
mRequestRender = false;
|
mRequestRender = false;
|
||||||
|
if (mHasSurface && mWaitingForSurface) {
|
||||||
|
changed = true;
|
||||||
|
mWaitingForSurface = false;
|
||||||
|
mRequestRender = true; // Forces a redraw for RENDERMODE_RENDER_WHEN_DIRTY
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (needStart) {
|
if (needStart) {
|
||||||
mEglHelper.start();
|
mEglHelper.start();
|
||||||
@ -966,6 +982,7 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback
|
|||||||
/*
|
/*
|
||||||
* clean-up everything...
|
* clean-up everything...
|
||||||
*/
|
*/
|
||||||
|
mEglHelper.destroySurface();
|
||||||
mEglHelper.finish();
|
mEglHelper.finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1021,6 +1038,13 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback
|
|||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
mHasSurface = false;
|
mHasSurface = false;
|
||||||
notify();
|
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 mDone;
|
||||||
private boolean mPaused;
|
private boolean mPaused;
|
||||||
private boolean mHasSurface;
|
private boolean mHasSurface;
|
||||||
|
private boolean mWaitingForSurface;
|
||||||
private int mWidth;
|
private int mWidth;
|
||||||
private int mHeight;
|
private int mHeight;
|
||||||
private int mRenderMode;
|
private int mRenderMode;
|
||||||
|
Reference in New Issue
Block a user