Bug 741166 - Restore waitForValidSurface, removed in error in bug 737949. r=ajuma

This commit is contained in:
Joe Drew 2012-04-02 15:43:21 -04:00
parent 75ebe79331
commit 0a3b5c87ab
5 changed files with 36 additions and 0 deletions

View File

@ -118,10 +118,12 @@ public class FlexibleGLSurfaceView extends SurfaceView implements SurfaceHolder.
/** Implementation of SurfaceHolder.Callback */
public synchronized void surfaceCreated(SurfaceHolder holder) {
mController.surfaceCreated();
}
/** Implementation of SurfaceHolder.Callback */
public synchronized void surfaceDestroyed(SurfaceHolder holder) {
mController.surfaceDestroyed();
if (mListener != null) {
mListener.compositionPauseRequested();
}

View File

@ -55,6 +55,7 @@ public class GLController {
private FlexibleGLSurfaceView mView;
private int mGLVersion;
private boolean mSurfaceValid;
private int mWidth, mHeight;
private EGL10 mEGL;
@ -79,6 +80,7 @@ public class GLController {
public GLController(FlexibleGLSurfaceView view) {
mView = view;
mGLVersion = 2;
mSurfaceValid = false;
}
public void setGLVersion(int version) {
@ -113,6 +115,16 @@ public class GLController {
return true;
}
public synchronized void waitForValidSurface() {
while (!mSurfaceValid) {
try {
wait();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
public synchronized int getWidth() {
return mWidth;
}
@ -121,6 +133,16 @@ public class GLController {
return mHeight;
}
synchronized void surfaceCreated() {
mSurfaceValid = true;
notifyAll();
}
synchronized void surfaceDestroyed() {
mSurfaceValid = false;
notifyAll();
}
synchronized void sizeChanged(int newWidth, int newHeight) {
mWidth = newWidth;
mHeight = newHeight;

View File

@ -1113,6 +1113,7 @@ AndroidBridge::RegisterCompositor()
EGLSurface
AndroidBridge::ProvideEGLSurface()
{
sController.WaitForValidSurface();
return sController.ProvideEGLSurface();
}

View File

@ -51,6 +51,7 @@ void AndroidEGLObject::Init(JNIEnv* aJEnv) {
}
jmethodID AndroidGLController::jSetGLVersionMethod = 0;
jmethodID AndroidGLController::jWaitForValidSurfaceMethod = 0;
jmethodID AndroidGLController::jProvideEGLSurfaceMethod = 0;
void
@ -61,6 +62,7 @@ AndroidGLController::Init(JNIEnv *aJEnv)
jSetGLVersionMethod = aJEnv->GetMethodID(jClass, "setGLVersion", "(I)V");
jProvideEGLSurfaceMethod = aJEnv->GetMethodID(jClass, "provideEGLSurface",
"()Ljavax/microedition/khronos/egl/EGLSurface;");
jWaitForValidSurfaceMethod = aJEnv->GetMethodID(jClass, "waitForValidSurface", "()V");
}
void
@ -85,3 +87,10 @@ AndroidGLController::ProvideEGLSurface()
jobject jObj = mJEnv->CallObjectMethod(mJObj, jProvideEGLSurfaceMethod);
return reinterpret_cast<EGLSurface>(mJEnv->GetIntField(jObj, jEGLSurfacePointerField));
}
void
AndroidGLController::WaitForValidSurface()
{
ASSERT_THREAD();
mJEnv->CallVoidMethod(mJObj, jWaitForValidSurfaceMethod);
}

View File

@ -58,9 +58,11 @@ public:
void Acquire(JNIEnv *aJEnv, jobject aJObj);
void SetGLVersion(int aVersion);
EGLSurface ProvideEGLSurface();
void WaitForValidSurface();
private:
static jmethodID jSetGLVersionMethod;
static jmethodID jWaitForValidSurfaceMethod;
static jmethodID jProvideEGLSurfaceMethod;
// the JNIEnv for the compositor thread