diff --git a/gfx/layers/wr/WebRenderCommandBuilder.cpp b/gfx/layers/wr/WebRenderCommandBuilder.cpp index 25aa4e79ed7b..178138fe38ef 100644 --- a/gfx/layers/wr/WebRenderCommandBuilder.cpp +++ b/gfx/layers/wr/WebRenderCommandBuilder.cpp @@ -1070,10 +1070,7 @@ void WebRenderCommandBuilder::Destroy() { mLastCanvasDatas.Clear(); - RemoveUnusedAndResetWebRenderUserData(); - // UserDatas should only be in the used state during a call to WebRenderCommandBuilder::BuildWebRenderCommands - // The should always be false upon return from BuildWebRenderCommands(). - MOZ_RELEASE_ASSERT(mWebRenderUserDatas.Count() == 0); + ClearCachedResources(); } void @@ -1830,10 +1827,10 @@ WebRenderCommandBuilder::RemoveUnusedAndResetWebRenderUserData() void WebRenderCommandBuilder::ClearCachedResources() { - for (auto iter = mWebRenderUserDatas.Iter(); !iter.Done(); iter.Next()) { - WebRenderUserData* data = iter.Get()->GetKey(); - data->ClearCachedResources(); - } + RemoveUnusedAndResetWebRenderUserData(); + // UserDatas should only be in the used state during a call to WebRenderCommandBuilder::BuildWebRenderCommands + // The should always be false upon return from BuildWebRenderCommands(). + MOZ_RELEASE_ASSERT(mWebRenderUserDatas.Count() == 0); } diff --git a/gfx/layers/wr/WebRenderUserData.cpp b/gfx/layers/wr/WebRenderUserData.cpp index 1bdb36b5dca3..ffa8b3634d81 100644 --- a/gfx/layers/wr/WebRenderUserData.cpp +++ b/gfx/layers/wr/WebRenderUserData.cpp @@ -67,7 +67,15 @@ WebRenderImageData::WebRenderImageData(WebRenderLayerManager* aWRManager, nsDisp WebRenderImageData::~WebRenderImageData() { - DoClearCachedResources(); + ClearImageKey(); + + if (mExternalImageId) { + WrBridge()->DeallocExternalImageId(mExternalImageId.ref()); + } + + if (mPipelineId) { + WrBridge()->RemovePipelineIdForCompositable(mPipelineId.ref()); + } } void @@ -84,32 +92,6 @@ WebRenderImageData::ClearImageKey() mOwnsKey = false; } -void -WebRenderImageData::ClearCachedResources() -{ - DoClearCachedResources(); -} - -void -WebRenderImageData::DoClearCachedResources() -{ - ClearImageKey(); - - if (mExternalImageId) { - WrBridge()->DeallocExternalImageId(mExternalImageId.ref()); - mExternalImageId.reset(); - } - - if (mPipelineId) { - WrBridge()->RemovePipelineIdForCompositable(mPipelineId.ref()); - mPipelineId.reset(); - } - - if (mImageClient) { - mImageClient = nullptr; - } -} - Maybe WebRenderImageData::UpdateImageKey(ImageContainer* aContainer, wr::IpcResourceUpdateQueue& aResources, @@ -275,14 +257,6 @@ WebRenderFallbackData::~WebRenderFallbackData() { } -void -WebRenderFallbackData::ClearCachedResources() -{ - WebRenderImageData::ClearCachedResources(); - mBasicLayerManager = nullptr; - mInvalid = true; -} - nsDisplayItemGeometry* WebRenderFallbackData::GetGeometry() { @@ -319,18 +293,6 @@ WebRenderCanvasData::WebRenderCanvasData(WebRenderLayerManager* aWRManager, nsDi } WebRenderCanvasData::~WebRenderCanvasData() -{ - DoClearCachedResources(); -} - -void -WebRenderCanvasData::ClearCachedResources() -{ - DoClearCachedResources(); -} - -void -WebRenderCanvasData::DoClearCachedResources() { if (mCanvasRenderer) { mCanvasRenderer->ClearCachedResources(); diff --git a/gfx/layers/wr/WebRenderUserData.h b/gfx/layers/wr/WebRenderUserData.h index 40e910674a3f..ae9986de2861 100644 --- a/gfx/layers/wr/WebRenderUserData.h +++ b/gfx/layers/wr/WebRenderUserData.h @@ -62,7 +62,6 @@ public: nsIFrame* GetFrame() { return mFrame; } uint32_t GetDisplayItemKey() { return mDisplayItemKey; } void RemoveFromTable(); - virtual void ClearCachedResources() {}; virtual nsDisplayItemGeometry* GetGeometry() { return nullptr; } protected: virtual ~WebRenderUserData(); @@ -126,7 +125,6 @@ public: bool aIsBackfaceVisible); void CreateImageClientIfNeeded(); - void ClearCachedResources() override; bool IsAsync() { @@ -136,7 +134,6 @@ public: protected: void ClearImageKey(); void CreateExternalImageIfNeeded(); - void DoClearCachedResources(); wr::MaybeExternalImageId mExternalImageId; Maybe mKey; @@ -155,7 +152,6 @@ public: virtual WebRenderFallbackData* AsFallbackData() override { return this; } virtual UserDataType GetType() override { return UserDataType::eFallback; } static UserDataType Type() { return UserDataType::eFallback; } - void ClearCachedResources() override; nsDisplayItemGeometry* GetGeometry() override; void SetGeometry(nsAutoPtr aGeometry); nsRect GetBounds() { return mBounds; } @@ -200,9 +196,7 @@ public: void ClearCanvasRenderer(); WebRenderCanvasRendererAsync* GetCanvasRenderer(); WebRenderCanvasRendererAsync* CreateCanvasRenderer(); - void ClearCachedResources() override; protected: - void DoClearCachedResources(); UniquePtr mCanvasRenderer; };