Bug 1122722 - Clean up asserts for compositor threads. r=nical

This commit is contained in:
Milan Sreckovic 2015-01-27 15:52:44 -05:00
Родитель dd9a80adbd
Коммит bad8bf235d
2 изменённых файлов: 17 добавлений и 8 удалений

Просмотреть файл

@ -22,30 +22,32 @@ namespace layers {
/* static */ LayersBackend
Compositor::GetBackend()
{
AssertOnCompositorThread();
if (sBackend != LayersBackend::LAYERS_NONE) {
AssertOnCompositorThread();
}
return sBackend;
}
/* static */ void
Compositor::SetBackend(LayersBackend backend)
{
if (!gIsGtest && sBackend != LayersBackend::LAYERS_NONE && sBackend != backend) {
if (!gIsGtest && sBackend != backend &&
sBackend != LayersBackend::LAYERS_NONE &&
backend != LayersBackend::LAYERS_NONE) {
// Assert this once we figure out bug 972891.
//MOZ_CRASH("Trying to use more than one OMTC compositor.");
#ifdef XP_MACOSX
printf("ERROR: Changing compositor from %u to %u.\n",
unsigned(sBackend), unsigned(backend));
gfxWarning() << "Changing compositor from " << unsigned(sBackend) << " to " << unsigned(backend);
#endif
}
sBackend = backend;
}
/* static */ void
Compositor::AssertOnCompositorThread()
{
MOZ_ASSERT(CompositorParent::CompositorLoop() ==
MessageLoop::current(),
MOZ_ASSERT(!CompositorParent::CompositorLoop() ||
CompositorParent::CompositorLoop() == MessageLoop::current(),
"Can only call this from the compositor thread!");
}

Просмотреть файл

@ -270,6 +270,7 @@ CompositorVsyncObserver::SetNeedsComposite(bool aNeedsComposite)
mSetNeedsCompositeTask = NewRunnableMethod(this,
&CompositorVsyncObserver::SetNeedsComposite,
aNeedsComposite);
MOZ_ASSERT(CompositorParent::CompositorLoop());
CompositorParent::CompositorLoop()->PostTask(FROM_HERE, mSetNeedsCompositeTask);
return;
} else {
@ -295,6 +296,7 @@ CompositorVsyncObserver::NotifyVsync(TimeStamp aVsyncTimestamp)
mCurrentCompositeTask = NewRunnableMethod(this,
&CompositorVsyncObserver::Composite,
aVsyncTimestamp);
MOZ_ASSERT(CompositorParent::CompositorLoop());
CompositorParent::CompositorLoop()->PostTask(FROM_HERE, mCurrentCompositeTask);
}
return true;
@ -415,6 +417,7 @@ CompositorParent::CompositorParent(nsIWidget* aWidget,
// FIXME: This holds on the the fact that right now the only thing that
// can destroy this instance is initialized on the compositor thread after
// this task has been processed.
MOZ_ASSERT(CompositorLoop());
CompositorLoop()->PostTask(FROM_HERE, NewRunnableFunction(&AddCompositor,
this, &mCompositorID));
@ -646,6 +649,7 @@ void
CompositorParent::ScheduleRenderOnCompositorThread()
{
CancelableTask *renderTask = NewRunnableMethod(this, &CompositorParent::ScheduleComposition);
MOZ_ASSERT(CompositorLoop());
CompositorLoop()->PostTask(FROM_HERE, renderTask);
}
@ -742,6 +746,7 @@ CompositorParent::SchedulePauseOnCompositorThread()
CancelableTask *pauseTask = NewRunnableMethod(this,
&CompositorParent::PauseComposition);
MOZ_ASSERT(CompositorLoop());
CompositorLoop()->PostTask(FROM_HERE, pauseTask);
// Wait until the pause has actually been processed by the compositor thread
@ -755,6 +760,7 @@ CompositorParent::ScheduleResumeOnCompositorThread(int width, int height)
CancelableTask *resumeTask =
NewRunnableMethod(this, &CompositorParent::ResumeCompositionAndResize, width, height);
MOZ_ASSERT(CompositorLoop());
CompositorLoop()->PostTask(FROM_HERE, resumeTask);
// Wait until the resume has actually been processed by the compositor thread
@ -1329,6 +1335,7 @@ CompositorParent::DeallocateLayerTreeId(uint64_t aId)
// Here main thread notifies compositor to remove an element from
// sIndirectLayerTrees. This removed element might be queried soon.
// Checking the elements of sIndirectLayerTrees exist or not before using.
MOZ_ASSERT(CompositorLoop());
CompositorLoop()->PostTask(FROM_HERE,
NewRunnableFunction(&EraseLayerState, aId));
}