From 012de1a3a65b7cbff427ba921fb2fc2b004916ff Mon Sep 17 00:00:00 2001 From: Markus Stange Date: Tue, 12 Nov 2019 19:50:26 +0000 Subject: [PATCH] Bug 1594950 - Remove unused SurfaceRegistry API. r=jrmuizel Differential Revision: https://phabricator.services.mozilla.com/D51758 --HG-- extra : moz-landing-system : lando --- gfx/layers/NativeLayerCA.h | 38 --------------------------------- gfx/layers/NativeLayerCA.mm | 42 ------------------------------------- 2 files changed, 80 deletions(-) diff --git a/gfx/layers/NativeLayerCA.h b/gfx/layers/NativeLayerCA.h index 581af7827b93..0bcf5332ee6f 100644 --- a/gfx/layers/NativeLayerCA.h +++ b/gfx/layers/NativeLayerCA.h @@ -34,17 +34,6 @@ class MozFramebuffer; namespace layers { -class IOSurfaceRegistry { - public: - NS_INLINE_DECL_THREADSAFE_REFCOUNTING(IOSurfaceRegistry) - - virtual void RegisterSurface(CFTypeRefPtr aSurface) = 0; - virtual void UnregisterSurface(CFTypeRefPtr aSurface) = 0; - - protected: - virtual ~IOSurfaceRegistry() {} -}; - // NativeLayerRootCA is the CoreAnimation implementation of the NativeLayerRoot // interface. A NativeLayerRootCA is created by the widget around an existing // CALayer with a call to CreateForCALayer. @@ -91,13 +80,6 @@ class NativeLayerRootCA : public NativeLayerRoot { // finished, NotifySurfaceReady marks the surface as ready. This surface is // committed to the layer during the next call to ApplyChanges(). // The swap chain keeps track of invalid areas within the surfaces. -// -// Creation and destruction of IOSurface objects is broadcast to an optional -// "surface registry" so that associated objects such as framebuffer objects -// don't need to be recreated on every frame: Instead, the surface registry can -// maintain one object per IOSurface in this layer's swap chain, and those -// objects will be reused in different frames as the layer cycles through the -// surfaces in its swap chain. class NativeLayerCA : public NativeLayer { public: virtual NativeLayerCA* AsNativeLayerCA() override { return this; } @@ -122,24 +104,6 @@ class NativeLayerCA : public NativeLayer { void SetSurfaceIsFlipped(bool aIsFlipped) override; bool SurfaceIsFlipped() override; - // Consumers may provide an object that implements the IOSurfaceRegistry - // interface. - // The registry's methods, Register/UnregisterSurface, will be called - // synchronously during calls to NextSurface(), SetSurfaceRegistry(), and the - // NativeLayer destructor, on the thread that those things happen to run on. - // If this layer already owns surfaces when SetSurfaceRegistry gets called - // with a non-null surface registry, those surfaces will immediately - // (synchronously) be registered with that registry. If the current surface - // registry is unset (via a call to SetSurfaceRegistry with a different value, - // such as null), and the NativeLayer still owns surfaces, then those surfaces - // will immediately be unregistered. - // Since NativeLayer objects are reference counted and can be used from - // different threads, it is recommended to call SetSurfaceRegistry(nullptr) - // before destroying the NativeLayer so that the UnregisterSurface calls - // happen at a deterministic time and on the right thread. - void SetSurfaceRegistry(RefPtr aSurfaceRegistry); - RefPtr GetSurfaceRegistry(); - protected: friend class NativeLayerRootCA; @@ -181,8 +145,6 @@ class NativeLayerCA : public NativeLayer { // Controls access to all fields of this class. Mutex mMutex; - RefPtr mSurfaceRegistry; // can be null - // Each IOSurface is initially created inside NextSurface. // The surface stays alive until the recycling mechanism in NextSurface // determines it is no longer needed (because the swap chain has grown too diff --git a/gfx/layers/NativeLayerCA.mm b/gfx/layers/NativeLayerCA.mm index e35c526ee89d..e088b35d017e 100644 --- a/gfx/layers/NativeLayerCA.mm +++ b/gfx/layers/NativeLayerCA.mm @@ -139,8 +139,6 @@ NativeLayerCA::NativeLayerCA(const IntSize& aSize, bool aIsOpaque) : mMutex("NativeLayerCA"), mSize(aSize), mIsOpaque(aIsOpaque) {} NativeLayerCA::~NativeLayerCA() { - SetSurfaceRegistry(nullptr); // or maybe MOZ_RELEASE_ASSERT(!mSurfaceRegistry) would be better? - if (mInProgressLockedIOSurface) { mInProgressLockedIOSurface->Unlock(false); mInProgressLockedIOSurface = nullptr; @@ -156,40 +154,6 @@ NativeLayerCA::~NativeLayerCA() { [mWrappingCALayer release]; } -void NativeLayerCA::SetSurfaceRegistry(RefPtr aSurfaceRegistry) { - MutexAutoLock lock(mMutex); - - if (mSurfaceRegistry) { - for (auto surf : mSurfaces) { - mSurfaceRegistry->UnregisterSurface(surf.mSurface); - } - if (mInProgressSurface) { - mSurfaceRegistry->UnregisterSurface(mInProgressSurface->mSurface); - } - if (mReadySurface) { - mSurfaceRegistry->UnregisterSurface(mReadySurface->mSurface); - } - } - mSurfaceRegistry = aSurfaceRegistry; - if (mSurfaceRegistry) { - for (auto surf : mSurfaces) { - mSurfaceRegistry->RegisterSurface(surf.mSurface); - } - if (mInProgressSurface) { - mSurfaceRegistry->RegisterSurface(mInProgressSurface->mSurface); - } - if (mReadySurface) { - mSurfaceRegistry->RegisterSurface(mReadySurface->mSurface); - } - } -} - -RefPtr NativeLayerCA::GetSurfaceRegistry() { - MutexAutoLock lock(mMutex); - - return mSurfaceRegistry; -} - void NativeLayerCA::SetSurfaceIsFlipped(bool aIsFlipped) { MutexAutoLock lock(mMutex); @@ -315,17 +279,11 @@ CFTypeRefPtr NativeLayerCA::NextSurface(const MutexAutoLock& aLock NSLog(@"NextSurface returning nullptr because IOSurfaceCreate failed to create the surface."); return nullptr; } - if (mSurfaceRegistry) { - mSurfaceRegistry->RegisterSurface(newSurf); - } surf = Some(SurfaceWithInvalidRegion{newSurf, IntRect({}, mSize)}); } // Delete all other unused surfaces. for (auto unusedSurf : unusedSurfaces) { - if (mSurfaceRegistry) { - mSurfaceRegistry->UnregisterSurface(unusedSurf.mSurface); - } mFramebuffers.erase(unusedSurf.mSurface); } unusedSurfaces.clear();