Backed out changeset 2efe54944e8c (bug 1453801) for linux64-qr awsy failures. r=aosmond

This commit is contained in:
Andrew Osmond 2018-04-17 17:57:39 -04:00
parent cbe4d558de
commit 69c328a7f6
4 changed files with 54 additions and 8 deletions

View File

@ -82,6 +82,17 @@ public:
void Unmap() override
{ }
bool AddConsumer()
{
return ++mConsumers == 1;
}
bool RemoveConsumer()
{
MOZ_ASSERT(mConsumers > 0);
return --mConsumers == 0;
}
private:
size_t GetDataLength() const
{
@ -94,6 +105,7 @@ private:
}
int32_t mStride;
uint32_t mConsumers;
IntSize mSize;
RefPtr<SharedMemoryBasic> mBuf;
SurfaceFormat mFormat;

View File

@ -54,22 +54,44 @@ SharedSurfacesParent::Get(const wr::ExternalImageId& aId)
return surface.forget();
}
/* static */ void
SharedSurfacesParent::Remove(const wr::ExternalImageId& aId)
/* static */ already_AddRefed<DataSourceSurface>
SharedSurfacesParent::Acquire(const wr::ExternalImageId& aId)
{
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
if (!sInstance) {
return nullptr;
}
RefPtr<SourceSurfaceSharedDataWrapper> surface;
sInstance->mSurfaces.Get(wr::AsUint64(aId), getter_AddRefs(surface));
if (surface) {
DebugOnly<bool> rv = surface->AddConsumer();
MOZ_ASSERT(!rv);
}
return surface.forget();
}
/* static */ bool
SharedSurfacesParent::Release(const wr::ExternalImageId& aId)
{
//MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
if (!sInstance) {
return;
return false;
}
uint64_t id = wr::AsUint64(aId);
RefPtr<SourceSurfaceSharedDataWrapper> surface;
sInstance->mSurfaces.Get(wr::AsUint64(aId), getter_AddRefs(surface));
if (!surface) {
return;
return false;
}
sInstance->mSurfaces.Remove(id);
if (surface->RemoveConsumer()) {
sInstance->mSurfaces.Remove(id);
}
return true;
}
/* static */ void
@ -171,5 +193,13 @@ SharedSurfacesParent::Add(const wr::ExternalImageId& aId,
sInstance->mSurfaces.Put(id, surface.forget());
}
/* static */ void
SharedSurfacesParent::Remove(const wr::ExternalImageId& aId)
{
//MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
DebugOnly<bool> rv = Release(aId);
MOZ_ASSERT(rv);
}
} // namespace layers
} // namespace mozilla

View File

@ -35,9 +35,16 @@ public:
static void Initialize();
static void Shutdown();
// Get without increasing the consumer count.
static already_AddRefed<gfx::DataSourceSurface>
Get(const wr::ExternalImageId& aId);
// Get but also increase the consumer count. Must call Release after finished.
static already_AddRefed<gfx::DataSourceSurface>
Acquire(const wr::ExternalImageId& aId);
static bool Release(const wr::ExternalImageId& aId);
static void Add(const wr::ExternalImageId& aId,
const SurfaceDescriptorShared& aDesc,
base::ProcessId aPid);

View File

@ -100,9 +100,6 @@ RenderThread::ShutDownTask(layers::SynchronousTask* aTask)
{
layers::AutoCompleteTask complete(aTask);
MOZ_ASSERT(IsInRenderThread());
MutexAutoLock lock(mRenderTextureMapLock);
mRenderTextures.Clear();
}
// static