Bug 1453801 - Remove unused consumer tracking code from SourceSurfaceSharedDataWrapper. r=jrmuizel
authorAndrew Osmond <aosmond@mozilla.com>
Fri, 13 Apr 2018 15:24:32 -0400
changeset 413223 2efe54944e8cb91f1198d0c55ccb440de5b37997
parent 413222 a6f674d433fce89a550c232351885b6f93fe606a
child 413224 9fbb232ef1f16e423f55a8b0082f1dca58df1081
push id102123
push useraosmond@gmail.com
push dateFri, 13 Apr 2018 19:24:45 +0000
treeherdermozilla-inbound@2efe54944e8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1453801
milestone61.0a1
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
Bug 1453801 - Remove unused consumer tracking code from SourceSurfaceSharedDataWrapper. r=jrmuizel
gfx/layers/SourceSurfaceSharedData.h
gfx/layers/ipc/SharedSurfacesParent.cpp
gfx/layers/ipc/SharedSurfacesParent.h
gfx/webrender_bindings/RenderThread.cpp
--- a/gfx/layers/SourceSurfaceSharedData.h
+++ b/gfx/layers/SourceSurfaceSharedData.h
@@ -77,40 +77,28 @@ 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,54 +49,32 @@ SharedSurfacesParent::Get(const wr::Exte
     return nullptr;
   }
 
   RefPtr<SourceSurfaceSharedDataWrapper> surface;
   sInstance->mSurfaces.Get(wr::AsUint64(aId), getter_AddRefs(surface));
   return surface.forget();
 }
 
-/* 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)
+/* static */ void
+SharedSurfacesParent::Remove(const wr::ExternalImageId& aId)
 {
   //MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
   if (!sInstance) {
-    return false;
+    return;
   }
 
   uint64_t id = wr::AsUint64(aId);
   RefPtr<SourceSurfaceSharedDataWrapper> surface;
   sInstance->mSurfaces.Get(wr::AsUint64(aId), getter_AddRefs(surface));
   if (!surface) {
-    return false;
+    return;
   }
 
-  if (surface->RemoveConsumer()) {
-    sInstance->mSurfaces.Remove(id);
-  }
-
-  return true;
+  sInstance->mSurfaces.Remove(id);
 }
 
 /* static */ void
 SharedSurfacesParent::AddSameProcess(const wr::ExternalImageId& aId,
                                      SourceSurfaceSharedData* aSurface)
 {
   MOZ_ASSERT(XRE_IsParentProcess());
   MOZ_ASSERT(NS_IsMainThread());
@@ -188,18 +166,10 @@ 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,26 +30,19 @@ 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,16 +95,19 @@ 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;
 }