зеркало из https://github.com/mozilla/gecko-dev.git
Bug 826300 - Don't block on waiting for a valid surface when trying to resume the compositor; allow resuming to fail gracefully. r=snorp,BenWa
This commit is contained in:
Родитель
1456be1c38
Коммит
8249f30f23
|
@ -520,7 +520,10 @@ public:
|
|||
EGL_NO_CONTEXT);
|
||||
if (!mSurface) {
|
||||
#ifdef MOZ_ANDROID_OMTC
|
||||
mSurface = mozilla::AndroidBridge::Bridge()->ProvideEGLSurface();
|
||||
mSurface = mozilla::AndroidBridge::Bridge()->ProvideEGLSurface(false);
|
||||
if (!mSurface) {
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
EGLConfig config;
|
||||
CreateConfig(&config);
|
||||
|
@ -2191,7 +2194,7 @@ GLContextProviderEGL::CreateForWindow(nsIWidget *aWidget)
|
|||
|
||||
#ifdef MOZ_ANDROID_OMTC
|
||||
mozilla::AndroidBridge::Bridge()->RegisterCompositor();
|
||||
EGLSurface surface = mozilla::AndroidBridge::Bridge()->ProvideEGLSurface();
|
||||
EGLSurface surface = mozilla::AndroidBridge::Bridge()->ProvideEGLSurface(true);
|
||||
#else
|
||||
EGLSurface surface = CreateSurfaceForWindow(aWidget, config);
|
||||
#endif
|
||||
|
|
|
@ -346,12 +346,17 @@ CompositorParent::ResumeComposition()
|
|||
|
||||
MonitorAutoLock lock(mResumeCompositionMonitor);
|
||||
|
||||
mPaused = false;
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
static_cast<LayerManagerOGL*>(mLayerManager.get())->gl()->RenewSurface();
|
||||
if (!static_cast<LayerManagerOGL*>(mLayerManager.get())->gl()->RenewSurface()) {
|
||||
// We can't get a surface. This could be because the activity changed between
|
||||
// the time resume was scheduled and now.
|
||||
__android_log_print(ANDROID_LOG_INFO, "CompositorParent", "Unable to renew compositor surface; remaining in paused state");
|
||||
lock.NotifyAll();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
mPaused = false;
|
||||
Composite();
|
||||
|
||||
// if anyone's waiting to make sure that composition really got resumed, tell them
|
||||
|
@ -402,7 +407,7 @@ CompositorParent::SchedulePauseOnCompositorThread()
|
|||
lock.Wait();
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
CompositorParent::ScheduleResumeOnCompositorThread(int width, int height)
|
||||
{
|
||||
MonitorAutoLock lock(mResumeCompositionMonitor);
|
||||
|
@ -413,6 +418,8 @@ CompositorParent::ScheduleResumeOnCompositorThread(int width, int height)
|
|||
|
||||
// Wait until the resume has actually been processed by the compositor thread
|
||||
lock.Wait();
|
||||
|
||||
return !mPaused;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -85,7 +85,11 @@ public:
|
|||
// Can be called from any thread
|
||||
void ScheduleRenderOnCompositorThread();
|
||||
void SchedulePauseOnCompositorThread();
|
||||
void ScheduleResumeOnCompositorThread(int width, int height);
|
||||
/**
|
||||
* Returns true if a surface was obtained and the resume succeeded; false
|
||||
* otherwise.
|
||||
*/
|
||||
bool ScheduleResumeOnCompositorThread(int width, int height);
|
||||
|
||||
virtual void ScheduleComposition();
|
||||
void NotifyShadowTreeTransaction();
|
||||
|
|
|
@ -127,6 +127,12 @@ public class GLController {
|
|||
* caller assumes ownership of the surface once it is returned.
|
||||
* This function is invoked by JNI */
|
||||
private EGLSurface provideEGLSurface() {
|
||||
synchronized (this) {
|
||||
if (!mSurfaceValid) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (mEGL == null) {
|
||||
initEGL();
|
||||
}
|
||||
|
|
|
@ -1205,9 +1205,11 @@ AndroidBridge::RegisterCompositor(JNIEnv *env, bool resetting)
|
|||
}
|
||||
|
||||
EGLSurface
|
||||
AndroidBridge::ProvideEGLSurface()
|
||||
AndroidBridge::ProvideEGLSurface(bool waitUntilValid)
|
||||
{
|
||||
sController.WaitForValidSurface();
|
||||
if (waitUntilValid) {
|
||||
sController.WaitForValidSurface();
|
||||
}
|
||||
return sController.ProvideEGLSurface();
|
||||
}
|
||||
|
||||
|
|
|
@ -261,7 +261,7 @@ public:
|
|||
|
||||
// Switch Java to composite with the Gecko Compositor thread
|
||||
void RegisterCompositor(JNIEnv* env = NULL, bool resetting = false);
|
||||
EGLSurface ProvideEGLSurface();
|
||||
EGLSurface ProvideEGLSurface(bool waitUntilValid);
|
||||
|
||||
bool GetStaticStringField(const char *classID, const char *field, nsAString &result, JNIEnv* env = nullptr);
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ AndroidGLController::ProvideEGLSurface()
|
|||
ASSERT_THREAD();
|
||||
AutoLocalJNIFrame jniFrame(mJEnv);
|
||||
jobject jObj = mJEnv->CallObjectMethod(mJObj, jProvideEGLSurfaceMethod);
|
||||
if (jniFrame.CheckForException())
|
||||
if (jniFrame.CheckForException() || !jObj)
|
||||
return NULL;
|
||||
|
||||
return reinterpret_cast<EGLSurface>(mJEnv->GetIntField(jObj, jEGLSurfacePointerField));
|
||||
|
|
|
@ -940,8 +940,9 @@ nsWindow::OnGlobalAndroidEvent(AndroidGeckoEvent *ae)
|
|||
// Since we might have prevented one or more draw events from
|
||||
// occurring while the compositor was paused, we need to schedule
|
||||
// a draw event now.
|
||||
sCompositorPaused = false;
|
||||
win->RedrawAll();
|
||||
if (!sCompositorPaused) {
|
||||
win->RedrawAll();
|
||||
}
|
||||
break;
|
||||
|
||||
case AndroidGeckoEvent::GECKO_EVENT_SYNC:
|
||||
|
@ -2312,8 +2313,8 @@ nsWindow::SchedulePauseComposition()
|
|||
void
|
||||
nsWindow::ScheduleResumeComposition(int width, int height)
|
||||
{
|
||||
if (sCompositorParent) {
|
||||
sCompositorParent->ScheduleResumeOnCompositorThread(width, height);
|
||||
if (sCompositorParent && sCompositorParent->ScheduleResumeOnCompositorThread(width, height)) {
|
||||
sCompositorPaused = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче