Bug 759162 - Part 2: Make CompositorParent::ScheduleResumeOnCompositorThread block until the compositor resumes. r=bgirard

This commit is contained in:
Ali Juma 2012-05-29 13:49:03 -04:00
parent 272f08ff30
commit b802df3029
2 changed files with 13 additions and 0 deletions

View File

@ -38,6 +38,7 @@ CompositorParent::CompositorParent(nsIWidget* aWidget, MessageLoop* aMsgLoop,
, mRenderToEGLSurface(aRenderToEGLSurface)
, mEGLSurfaceSize(aSurfaceWidth, aSurfaceHeight)
, mPauseCompositionMonitor("PauseCompositionMonitor")
, mResumeCompositionMonitor("ResumeCompositionMonitor")
{
MOZ_COUNT_CTOR(CompositorParent);
}
@ -133,11 +134,17 @@ CompositorParent::ResumeComposition()
{
NS_ABORT_IF_FALSE(CompositorThreadID() == PlatformThread::CurrentId(),
"ResumeComposition() can only be called on the compositor thread");
mozilla::MonitorAutoLock lock(mResumeCompositionMonitor);
mPaused = false;
#ifdef MOZ_WIDGET_ANDROID
static_cast<LayerManagerOGL*>(mLayerManager.get())->gl()->RenewSurface();
#endif
// if anyone's waiting to make sure that composition really got resumed, tell them
lock.NotifyAll();
}
void
@ -179,9 +186,14 @@ CompositorParent::SchedulePauseOnCompositorThread()
void
CompositorParent::ScheduleResumeOnCompositorThread(int width, int height)
{
mozilla::MonitorAutoLock lock(mResumeCompositionMonitor);
CancelableTask *resumeTask =
NewRunnableMethod(this, &CompositorParent::ResumeCompositionAndResize, width, height);
CompositorLoop()->PostTask(FROM_HERE, resumeTask);
// Wait until the resume has actually been processed by the compositor thread
lock.Wait();
}
void

View File

@ -144,6 +144,7 @@ private:
nsIntSize mEGLSurfaceSize;
mozilla::Monitor mPauseCompositionMonitor;
mozilla::Monitor mResumeCompositionMonitor;
DISALLOW_EVIL_CONSTRUCTORS(CompositorParent);
};