Bug 1430700 - Implement WebRenderFallbackData::ClearCachedResources() r=nical
authorsotaro <sotaro.ikeda.g@gmail.com>
Thu, 18 Jan 2018 10:36:56 +0900
changeset 454053 524088f8b35cbdf4fb5f64c8dca083fb36f4ec35
parent 454052 7d463ab1b36b77e34c6b0ea7910552038b4cb063
child 454058 09d0f66b1eee218419cd244c16bfc99449fb3711
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs1430700
milestone59.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 1430700 - Implement WebRenderFallbackData::ClearCachedResources() r=nical
gfx/layers/wr/WebRenderUserData.cpp
gfx/layers/wr/WebRenderUserData.h
--- a/gfx/layers/wr/WebRenderUserData.cpp
+++ b/gfx/layers/wr/WebRenderUserData.cpp
@@ -52,17 +52,17 @@ WebRenderUserData::WrBridge() const
 WebRenderImageData::WebRenderImageData(WebRenderLayerManager* aWRManager, nsDisplayItem* aItem)
   : WebRenderUserData(aWRManager, aItem)
   , mOwnsKey(false)
 {
 }
 
 WebRenderImageData::~WebRenderImageData()
 {
-  ClearCachedResources();
+  DoClearCachedResources();
 }
 
 void
 WebRenderImageData::ClearImageKey()
 {
   if (mKey) {
     // If we don't own the key, then the owner is responsible for discarding the
     // key when appropriate.
@@ -72,16 +72,22 @@ WebRenderImageData::ClearImageKey()
     mKey.reset();
   }
   mOwnsKey = false;
 }
 
 void
 WebRenderImageData::ClearCachedResources()
 {
+  DoClearCachedResources();
+}
+
+void
+WebRenderImageData::DoClearCachedResources()
+{
   ClearImageKey();
 
   if (mExternalImageId) {
     WrBridge()->DeallocExternalImageId(mExternalImageId.ref());
     mExternalImageId.reset();
   }
 
   if (mPipelineId) {
@@ -254,16 +260,24 @@ WebRenderFallbackData::WebRenderFallback
   , mInvalid(false)
 {
 }
 
 WebRenderFallbackData::~WebRenderFallbackData()
 {
 }
 
+void
+WebRenderFallbackData::ClearCachedResources()
+{
+  WebRenderImageData::ClearCachedResources();
+  mBasicLayerManager = nullptr;
+  mInvalid = true;
+}
+
 nsDisplayItemGeometry*
 WebRenderFallbackData::GetGeometry()
 {
   return mGeometry.get();
 }
 
 void
 WebRenderFallbackData::SetGeometry(nsAutoPtr<nsDisplayItemGeometry> aGeometry)
@@ -291,22 +305,28 @@ WebRenderAnimationData::~WebRenderAnimat
 
 WebRenderCanvasData::WebRenderCanvasData(WebRenderLayerManager* aWRManager, nsDisplayItem* aItem)
   : WebRenderUserData(aWRManager, aItem)
 {
 }
 
 WebRenderCanvasData::~WebRenderCanvasData()
 {
-  ClearCachedResources();
+  DoClearCachedResources();
 }
 
 void
 WebRenderCanvasData::ClearCachedResources()
 {
+  DoClearCachedResources();
+}
+
+void
+WebRenderCanvasData::DoClearCachedResources()
+{
   if (mCanvasRenderer) {
     mCanvasRenderer->ClearCachedResources();
   }
 }
 
 void
 WebRenderCanvasData::ClearCanvasRenderer()
 {
--- a/gfx/layers/wr/WebRenderUserData.h
+++ b/gfx/layers/wr/WebRenderUserData.h
@@ -99,16 +99,17 @@ public:
                                          const wr::MixBlendMode& aMixBlendMode,
                                          bool aIsBackfaceVisible);
 
   void CreateImageClientIfNeeded();
   void ClearCachedResources() override;
 protected:
   void ClearImageKey();
   void CreateExternalImageIfNeeded();
+  void DoClearCachedResources();
 
   wr::MaybeExternalImageId mExternalImageId;
   Maybe<wr::ImageKey> mKey;
   RefPtr<ImageClient> mImageClient;
   Maybe<wr::PipelineId> mPipelineId;
   RefPtr<ImageContainer> mContainer;
   bool mOwnsKey;
 };
@@ -117,16 +118,17 @@ class WebRenderFallbackData : public Web
 {
 public:
   explicit WebRenderFallbackData(WebRenderLayerManager* aWRManager, nsDisplayItem* aItem);
   virtual ~WebRenderFallbackData();
 
   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<nsDisplayItemGeometry> aGeometry);
   nsRect GetBounds() { return mBounds; }
   void SetBounds(const nsRect& aRect) { mBounds = aRect; }
   void SetInvalid(bool aInvalid) { mInvalid = aInvalid; }
   void SetScale(gfx::Size aScale) { mScale = aScale; }
   gfx::Size GetScale() { return mScale; }
   bool IsInvalid() { return mInvalid; }
@@ -163,15 +165,17 @@ public:
   virtual UserDataType GetType() override { return UserDataType::eCanvas; }
   static UserDataType Type() { return UserDataType::eCanvas; }
 
   void ClearCanvasRenderer();
   WebRenderCanvasRendererAsync* GetCanvasRenderer();
   WebRenderCanvasRendererAsync* CreateCanvasRenderer();
   void ClearCachedResources() override;
 protected:
+  void DoClearCachedResources();
+
   UniquePtr<WebRenderCanvasRendererAsync> mCanvasRenderer;
 };
 
 } // namespace layers
 } // namespace mozilla
 
 #endif /* GFX_WEBRENDERUSERDATA_H */