Bug 604090 - Notify java wrapper when we're ready to take events, r=blassey a=blocking-fennec

This commit is contained in:
Michael Wu
2010-10-25 20:10:07 -07:00
parent f79f8f2c1d
commit f7b6c55e54
6 changed files with 23 additions and 22 deletions

View File

@@ -136,8 +136,6 @@ class GeckoAppShell
// Tell Gecko where the target surface view is for rendering // Tell Gecko where the target surface view is for rendering
GeckoAppShell.setSurfaceView(GeckoApp.surfaceView); GeckoAppShell.setSurfaceView(GeckoApp.surfaceView);
sGeckoRunning = true;
// First argument is the .apk path // First argument is the .apk path
String combinedArgs = apkPath + " -omnijar " + apkPath; String combinedArgs = apkPath + " -omnijar " + apkPath;
if (args != null) if (args != null)
@@ -146,10 +144,6 @@ class GeckoAppShell
combinedArgs += " " + url; combinedArgs += " " + url;
// and go // and go
GeckoAppShell.nativeRun(combinedArgs); GeckoAppShell.nativeRun(combinedArgs);
if (gPendingResize != null) {
notifyGeckoOfEvent(gPendingResize);
gPendingResize = null;
}
} }
private static GeckoEvent mLastDrawEvent; private static GeckoEvent mLastDrawEvent;
@@ -337,6 +331,15 @@ class GeckoAppShell
} }
} }
static void onAppShellReady()
{
sGeckoRunning = true;
if (gPendingResize != null) {
notifyGeckoOfEvent(gPendingResize);
gPendingResize = null;
}
}
static void onXreExit() { static void onXreExit() {
sGeckoRunning = false; sGeckoRunning = false;
Log.i("GeckoAppJava", "XRE exited"); Log.i("GeckoAppJava", "XRE exited");

View File

@@ -123,8 +123,6 @@ class GeckoSurfaceView
GeckoAppShell.scheduleRedraw(); GeckoAppShell.scheduleRedraw();
mSurfaceNeedsRedraw = false; mSurfaceNeedsRedraw = false;
} }
mSurfaceChanged = true;
} finally { } finally {
mSurfaceLock.unlock(); mSurfaceLock.unlock();
} }
@@ -192,8 +190,6 @@ class GeckoSurfaceView
Log.e("GeckoAppJava", "endDrawing with false mSurfaceValid"); Log.e("GeckoAppJava", "endDrawing with false mSurfaceValid");
return; return;
} }
} catch (java.lang.IllegalArgumentException ex) {
mSurfaceChanged = true;
} finally { } finally {
mInDrawing = false; mInDrawing = false;
@@ -288,10 +284,6 @@ class GeckoSurfaceView
// Do we need to force a redraw on surfaceChanged? // Do we need to force a redraw on surfaceChanged?
boolean mSurfaceNeedsRedraw; boolean mSurfaceNeedsRedraw;
// Has this surface been changed? (That is,
// do we need to recreate buffers?)
boolean mSurfaceChanged;
// Are we actively between beginDrawing/endDrawing? // Are we actively between beginDrawing/endDrawing?
boolean mInDrawing; boolean mInDrawing;

View File

@@ -103,6 +103,7 @@ AndroidBridge::Init(JNIEnv *jEnv,
jEnableLocation = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "enableLocation", "(Z)V"); jEnableLocation = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "enableLocation", "(Z)V");
jReturnIMEQueryResult = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "returnIMEQueryResult", "(Ljava/lang/String;II)V"); jReturnIMEQueryResult = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "returnIMEQueryResult", "(Ljava/lang/String;II)V");
jScheduleRestart = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "scheduleRestart", "()V"); jScheduleRestart = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "scheduleRestart", "()V");
jNotifyAppShellReady = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "onAppShellReady", "()V");
jNotifyXreExit = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "onXreExit", "()V"); jNotifyXreExit = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "onXreExit", "()V");
jGetHandlersForMimeType = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "getHandlersForMimeType", "(Ljava/lang/String;Ljava/lang/String;)[Ljava/lang/String;"); jGetHandlersForMimeType = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "getHandlersForMimeType", "(Ljava/lang/String;Ljava/lang/String;)[Ljava/lang/String;");
jGetHandlersForProtocol = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "getHandlersForProtocol", "(Ljava/lang/String;Ljava/lang/String;)[Ljava/lang/String;"); jGetHandlersForProtocol = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "getHandlersForProtocol", "(Ljava/lang/String;Ljava/lang/String;)[Ljava/lang/String;");
@@ -248,6 +249,12 @@ AndroidBridge::ReturnIMEQueryResult(const PRUnichar *aResult, PRUint32 aLen,
jReturnIMEQueryResult, args); jReturnIMEQueryResult, args);
} }
void
AndroidBridge::NotifyAppShellReady()
{
mJNIEnv->CallStaticVoidMethod(mGeckoAppShellClass, jNotifyAppShellReady);
}
void void
AndroidBridge::ScheduleRestart() AndroidBridge::ScheduleRestart()
{ {

View File

@@ -115,6 +115,8 @@ public:
void ReturnIMEQueryResult(const PRUnichar *aResult, PRUint32 aLen, int aSelStart, int aSelLen); void ReturnIMEQueryResult(const PRUnichar *aResult, PRUint32 aLen, int aSelStart, int aSelLen);
void NotifyAppShellReady();
void NotifyXreExit(); void NotifyXreExit();
void ScheduleRestart(); void ScheduleRestart();
@@ -217,6 +219,7 @@ protected:
jmethodID jEnableAccelerometer; jmethodID jEnableAccelerometer;
jmethodID jEnableLocation; jmethodID jEnableLocation;
jmethodID jReturnIMEQueryResult; jmethodID jReturnIMEQueryResult;
jmethodID jNotifyAppShellReady;
jmethodID jNotifyXreExit; jmethodID jNotifyXreExit;
jmethodID jScheduleRestart; jmethodID jScheduleRestart;
jmethodID jGetOutstandingDrawEvents; jmethodID jGetOutstandingDrawEvents;

View File

@@ -81,8 +81,6 @@ Java_org_mozilla_gecko_GeckoAppShell_notifyGeckoOfEvent(JNIEnv *jenv, jclass jc,
// poke the appshell // poke the appshell
if (nsAppShell::gAppShell) if (nsAppShell::gAppShell)
nsAppShell::gAppShell->PostEvent(new AndroidGeckoEvent(jenv, event)); nsAppShell::gAppShell->PostEvent(new AndroidGeckoEvent(jenv, event));
else if (!nsAppShell::gEarlyEvent)
nsAppShell::gEarlyEvent = new AndroidGeckoEvent(jenv, event);
} }
NS_EXPORT void JNICALL NS_EXPORT void JNICALL

View File

@@ -74,7 +74,6 @@ nsAccelerometerSystem *gAccel = nsnull;
nsIGeolocationUpdate *gLocationCallback = nsnull; nsIGeolocationUpdate *gLocationCallback = nsnull;
nsAppShell *nsAppShell::gAppShell = nsnull; nsAppShell *nsAppShell::gAppShell = nsnull;
AndroidGeckoEvent *nsAppShell::gEarlyEvent = nsnull;
nsAppShell::nsAppShell() nsAppShell::nsAppShell()
: mQueueLock(nsnull), : mQueueLock(nsnull),
@@ -83,10 +82,6 @@ nsAppShell::nsAppShell()
mNumDraws(0) mNumDraws(0)
{ {
gAppShell = this; gAppShell = this;
if (gEarlyEvent) {
mEventQueue.AppendElement(gEarlyEvent);
gEarlyEvent = nsnull;
}
} }
nsAppShell::~nsAppShell() nsAppShell::~nsAppShell()
@@ -116,7 +111,10 @@ nsAppShell::Init()
mObserversHash.Init(); mObserversHash.Init();
return nsBaseAppShell::Init(); nsresult rv = nsBaseAppShell::Init();
if (AndroidBridge::Bridge())
AndroidBridge::Bridge()->NotifyAppShellReady();
return rv;
} }