author | Andrew Osmond <aosmond@mozilla.com> |
Tue, 17 Apr 2018 17:57:39 -0400 | |
changeset 414187 | 10424496394b06514993cd78c6521ef100795ebf |
parent 414186 | 393b0712839a81d77e5b1a67dcb34d59e0c28c36 |
child 414188 | 73615fe67ab6424c9334f95c39a74fc224977993 |
push id | 33861 |
push user | ccoroiu@mozilla.com |
push date | Wed, 18 Apr 2018 10:50:38 +0000 |
treeherder | mozilla-central@4af4ae0aee55 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | aosmond |
bugs | 1453801 |
milestone | 61.0a1 |
backs out | 2efe54944e8cb91f1198d0c55ccb440de5b37997 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/gfx/layers/SourceSurfaceSharedData.h +++ b/gfx/layers/SourceSurfaceSharedData.h @@ -77,28 +77,40 @@ public: aMappedSurface->mData = GetData(); aMappedSurface->mStride = mStride; return true; } void Unmap() override { } + bool AddConsumer() + { + return ++mConsumers == 1; + } + + bool RemoveConsumer() + { + MOZ_ASSERT(mConsumers > 0); + return --mConsumers == 0; + } + private: size_t GetDataLength() const { return static_cast<size_t>(mStride) * mSize.height; } size_t GetAlignedDataLength() const { return mozilla::ipc::SharedMemory::PageAlignedSize(GetDataLength()); } int32_t mStride; + uint32_t mConsumers; IntSize mSize; RefPtr<SharedMemoryBasic> mBuf; SurfaceFormat mFormat; base::ProcessId mCreatorPid; }; /** * This class is used to wrap shared (as in process) data buffers used by a
--- a/gfx/layers/ipc/SharedSurfacesParent.cpp +++ b/gfx/layers/ipc/SharedSurfacesParent.cpp @@ -49,32 +49,54 @@ SharedSurfacesParent::Get(const wr::Exte return nullptr; } RefPtr<SourceSurfaceSharedDataWrapper> surface; sInstance->mSurfaces.Get(wr::AsUint64(aId), getter_AddRefs(surface)); 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 SharedSurfacesParent::AddSameProcess(const wr::ExternalImageId& aId, SourceSurfaceSharedData* aSurface) { MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(NS_IsMainThread()); @@ -166,10 +188,18 @@ SharedSurfacesParent::Add(const wr::Exte RefPtr<wr::RenderSharedSurfaceTextureHost> texture = new wr::RenderSharedSurfaceTextureHost(surface); wr::RenderThread::Get()->RegisterExternalImage(id, texture.forget()); 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
--- a/gfx/layers/ipc/SharedSurfacesParent.h +++ b/gfx/layers/ipc/SharedSurfacesParent.h @@ -30,19 +30,26 @@ namespace layers { class SharedSurfacesChild; class SharedSurfacesParent final { 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); static void Remove(const wr::ExternalImageId& aId); static void DestroyProcess(base::ProcessId aPid);
--- a/gfx/webrender_bindings/RenderThread.cpp +++ b/gfx/webrender_bindings/RenderThread.cpp @@ -95,19 +95,16 @@ RenderThread::ShutDown() #endif } void RenderThread::ShutDownTask(layers::SynchronousTask* aTask) { layers::AutoCompleteTask complete(aTask); MOZ_ASSERT(IsInRenderThread()); - - MutexAutoLock lock(mRenderTextureMapLock); - mRenderTextures.Clear(); } // static MessageLoop* RenderThread::Loop() { return sRenderThread ? sRenderThread->mThread->message_loop() : nullptr; }