diff --git a/gfx/layers/ipc/CompositorBridgeChild.cpp b/gfx/layers/ipc/CompositorBridgeChild.cpp index 7f6fb44ced0b..7740509259ff 100644 --- a/gfx/layers/ipc/CompositorBridgeChild.cpp +++ b/gfx/layers/ipc/CompositorBridgeChild.cpp @@ -135,7 +135,7 @@ void CompositorBridgeChild::Destroy() { // This must not be called from the destructor! - mTexturesWaitingRecycled.Clear(); + mTexturesWaitingRecycled.clear(); // Destroying the layer manager may cause all sorts of things to happen, so // let's make sure there is still a reference to keep this alive whatever @@ -898,25 +898,26 @@ CompositorBridgeChild::HoldUntilCompositableRefReleasedIfNecessary(TextureClient } aClient->SetLastFwdTransactionId(GetFwdTransactionId()); - mTexturesWaitingRecycled.Put(aClient->GetSerial(), aClient); + mTexturesWaitingRecycled.emplace(aClient->GetSerial(), aClient); } void CompositorBridgeChild::NotifyNotUsed(uint64_t aTextureId, uint64_t aFwdTransactionId) { - if (auto entry = mTexturesWaitingRecycled.Lookup(aTextureId)) { - if (aFwdTransactionId < entry.Data()->GetLastFwdTransactionId()) { + auto it = mTexturesWaitingRecycled.find(aTextureId); + if (it != mTexturesWaitingRecycled.end()) { + if (aFwdTransactionId < it->second->GetLastFwdTransactionId()) { // Released on host side, but client already requested newer use texture. return; } - entry.Remove(); + mTexturesWaitingRecycled.erase(it); } } void CompositorBridgeChild::CancelWaitForRecycle(uint64_t aTextureId) { - mTexturesWaitingRecycled.Remove(aTextureId); + mTexturesWaitingRecycled.erase(aTextureId); } TextureClientPool* diff --git a/gfx/layers/ipc/CompositorBridgeChild.h b/gfx/layers/ipc/CompositorBridgeChild.h index efece701ff00..c7d3bb7ed0fd 100644 --- a/gfx/layers/ipc/CompositorBridgeChild.h +++ b/gfx/layers/ipc/CompositorBridgeChild.h @@ -17,13 +17,14 @@ #include "mozilla/layers/PaintThread.h" // for PaintThread #include "mozilla/webrender/WebRenderTypes.h" #include "nsClassHashtable.h" // for nsClassHashtable -#include "nsRefPtrHashtable.h" #include "nsCOMPtr.h" // for nsCOMPtr #include "nsHashKeys.h" // for nsUint64HashKey #include "nsISupportsImpl.h" // for NS_INLINE_DECL_REFCOUNTING #include "ThreadSafeRefcountingWithMainThreadDestruction.h" #include "nsWeakReference.h" +#include + namespace mozilla { namespace dom { @@ -389,7 +390,7 @@ private: * Hold TextureClients refs until end of their usages on host side. * It defer calling of TextureClient recycle callback. */ - nsRefPtrHashtable mTexturesWaitingRecycled; + std::unordered_map> mTexturesWaitingRecycled; MessageLoop* mMessageLoop; diff --git a/gfx/layers/ipc/ImageBridgeChild.cpp b/gfx/layers/ipc/ImageBridgeChild.cpp index a68e2670ebdf..eb6b1b59465c 100644 --- a/gfx/layers/ipc/ImageBridgeChild.cpp +++ b/gfx/layers/ipc/ImageBridgeChild.cpp @@ -158,18 +158,19 @@ ImageBridgeChild::HoldUntilCompositableRefReleasedIfNecessary(TextureClient* aCl return; } aClient->SetLastFwdTransactionId(GetFwdTransactionId()); - mTexturesWaitingRecycled.Put(aClient->GetSerial(), aClient); + mTexturesWaitingRecycled.emplace(aClient->GetSerial(), aClient); } void ImageBridgeChild::NotifyNotUsed(uint64_t aTextureId, uint64_t aFwdTransactionId) { - if (auto entry = mTexturesWaitingRecycled.Lookup(aTextureId)) { - if (aFwdTransactionId < entry.Data()->GetLastFwdTransactionId()) { + auto it = mTexturesWaitingRecycled.find(aTextureId); + if (it != mTexturesWaitingRecycled.end()) { + if (aFwdTransactionId < it->second->GetLastFwdTransactionId()) { // Released on host side, but client already requested newer use texture. return; } - entry.Remove(); + mTexturesWaitingRecycled.erase(it); } } @@ -177,7 +178,7 @@ void ImageBridgeChild::CancelWaitForRecycle(uint64_t aTextureId) { MOZ_ASSERT(InImageBridgeChildThread()); - mTexturesWaitingRecycled.Remove(aTextureId); + mTexturesWaitingRecycled.erase(aTextureId); } // Singleton @@ -235,7 +236,7 @@ ImageBridgeChild::ActorDestroy(ActorDestroyReason aWhy) mDestroyed = true; { MutexAutoLock lock(mContainerMapLock); - mImageContainerListeners.Clear(); + mImageContainerListeners.clear(); } } @@ -287,7 +288,7 @@ ImageBridgeChild::~ImageBridgeChild() void ImageBridgeChild::MarkShutDown() { - mTexturesWaitingRecycled.Clear(); + mTexturesWaitingRecycled.clear(); mCanSend = false; } @@ -310,8 +311,8 @@ ImageBridgeChild::Connect(CompositableClient* aCompositable, // But offscreen canvas does not provide it. if (aImageContainer) { MutexAutoLock lock(mContainerMapLock); - MOZ_ASSERT(!mImageContainerListeners.Contains(id)); - mImageContainerListeners.Put(id, aImageContainer->GetImageContainerListener()); + MOZ_ASSERT(mImageContainerListeners.find(id) == mImageContainerListeners.end()); + mImageContainerListeners.emplace(id, aImageContainer->GetImageContainerListener()); } CompositableHandle handle(id); @@ -323,7 +324,7 @@ void ImageBridgeChild::ForgetImageContainer(const CompositableHandle& aHandle) { MutexAutoLock lock(mContainerMapLock); - mImageContainerListeners.Remove(aHandle.Value()); + mImageContainerListeners.erase(aHandle.Value()); } Thread* ImageBridgeChild::GetThread() const @@ -724,9 +725,8 @@ ImageBridgeChild::UpdateTextureFactoryIdentifier(const TextureFactoryIdentifier& nsTArray > listeners; { MutexAutoLock lock(mContainerMapLock); - for (auto iter = mImageContainerListeners.Iter(); !iter.Done(); iter.Next()) { - RefPtr& listener = iter.Data(); - listeners.AppendElement(listener); + for (const auto& entry : mImageContainerListeners) { + listeners.AppendElement(entry.second); } } // Drop ImageContainer's ImageClient whithout holding mContainerMapLock to avoid deadlock. @@ -1004,8 +1004,9 @@ ImageBridgeChild::RecvDidComposite(InfallibleTArray& RefPtr listener; { MutexAutoLock lock(mContainerMapLock); - if (auto entry = mImageContainerListeners.Lookup(n.compositable().Value())) { - listener = entry.Data(); + auto it = mImageContainerListeners.find(n.compositable().Value()); + if (it != mImageContainerListeners.end()) { + listener = it->second; } } if (listener) { @@ -1117,7 +1118,7 @@ ImageBridgeChild::ReleaseCompositable(const CompositableHandle& aHandle) { MutexAutoLock lock(mContainerMapLock); - mImageContainerListeners.Remove(aHandle.Value()); + mImageContainerListeners.erase(aHandle.Value()); } } diff --git a/gfx/layers/ipc/ImageBridgeChild.h b/gfx/layers/ipc/ImageBridgeChild.h index d368eecc98b9..84a638ee4cb6 100644 --- a/gfx/layers/ipc/ImageBridgeChild.h +++ b/gfx/layers/ipc/ImageBridgeChild.h @@ -9,6 +9,8 @@ #include // for size_t #include // for uint32_t, uint64_t +#include + #include "mozilla/Attributes.h" // for override #include "mozilla/Atomics.h" #include "mozilla/RefPtr.h" // for already_AddRefed @@ -21,7 +23,6 @@ #include "mozilla/webrender/WebRenderTypes.h" #include "nsIObserver.h" #include "nsRegion.h" // for nsIntRegion -#include "nsRefPtrHashtable.h" #include "mozilla/gfx/Rect.h" #include "mozilla/ReentrantMonitor.h" // for ReentrantMonitor, etc @@ -395,13 +396,13 @@ private: * Hold TextureClients refs until end of their usages on host side. * It defer calling of TextureClient recycle callback. */ - nsRefPtrHashtable mTexturesWaitingRecycled; + std::unordered_map> mTexturesWaitingRecycled; /** * Mapping from async compositable IDs to image containers. */ Mutex mContainerMapLock; - nsRefPtrHashtable mImageContainerListeners; + std::unordered_map> mImageContainerListeners; #if defined(XP_WIN) /** diff --git a/gfx/webrender_bindings/RenderThread.h b/gfx/webrender_bindings/RenderThread.h index d94bfce55b31..35b32490ee3f 100644 --- a/gfx/webrender_bindings/RenderThread.h +++ b/gfx/webrender_bindings/RenderThread.h @@ -12,7 +12,6 @@ #include "base/thread.h" // for Thread #include "base/message_loop.h" #include "nsISupportsImpl.h" -#include "nsRefPtrHashtable.h" #include "ThreadSafeRefcountingWithMainThreadDestruction.h" #include "mozilla/Mutex.h" #include "mozilla/webrender/webrender_ffi.h"