Bug 1041695 - Make ShadowLayersForwarder::RemoveTexture run on worker thread, as required by TextureClient::Finalize. r=nical

--HG--
extra : rebase_source : 5498e78ba405c0b2e75063b3d7bda7d1cead4669
This commit is contained in:
David Parks 2014-07-30 23:44:31 -07:00
Родитель 687f61d5f9
Коммит 955ab1eae9
2 изменённых файлов: 35 добавлений и 1 удалений

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

@ -33,6 +33,7 @@
#include "nsSize.h" // for nsIntSize
#include "nsTArray.h" // for nsAutoTArray, nsTArray, etc
#include "nsXULAppAPI.h" // for XRE_GetProcessType, etc
#include "mozilla/ReentrantMonitor.h"
struct nsIntPoint;
@ -473,11 +474,42 @@ ShadowLayerForwarder::RemoveTextureFromCompositableAsync(AsyncTransactionTracker
aAsyncTransactionTracker);
}
bool
ShadowLayerForwarder::InWorkerThread()
{
return GetMessageLoop()->id() == MessageLoop::current()->id();
}
static void RemoveTextureWorker(TextureClient* aTexture, ReentrantMonitor* aBarrier, bool* aDone)
{
aTexture->ForceRemove();
ReentrantMonitorAutoEnter autoMon(*aBarrier);
*aDone = true;
aBarrier->NotifyAll();
}
void
ShadowLayerForwarder::RemoveTexture(TextureClient* aTexture)
{
MOZ_ASSERT(aTexture);
aTexture->ForceRemove();
if (InWorkerThread()) {
aTexture->ForceRemove();
return;
}
ReentrantMonitor barrier("ShadowLayerForwarder::RemoveTexture Lock");
ReentrantMonitorAutoEnter autoMon(barrier);
bool done = false;
GetMessageLoop()->PostTask(
FROM_HERE,
NewRunnableFunction(&RemoveTextureWorker, aTexture, &barrier, &done));
// Wait until the TextureClient has been ForceRemoved on the worker thread
while (!done) {
barrier.Wait();
}
}
bool

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

@ -393,6 +393,8 @@ protected:
void CheckSurfaceDescriptor(const SurfaceDescriptor* aDescriptor) const {}
#endif
bool InWorkerThread();
RefPtr<LayerTransactionChild> mShadowManager;
private: