Bug 1654211 - Hold WeakPtr to PresistentBufferProvider in BorrowedSourceSurface. r=nical, a=tjr
authorJeff Gilbert <jgilbert@mozilla.com>
Tue, 25 Aug 2020 15:36:11 +0000
changeset 610567 4b90dac4c40b61e2f4c3c2a4a04bbc3000aaef0c
parent 610566 90bd2b87148e2c63219a3a9b18bc93b6de5ae3fe
child 610568 19000ae951c47d173607cbec969b31f9abb07890
push id13645
push userryanvm@gmail.com
push dateFri, 28 Aug 2020 15:19:44 +0000
treeherdermozilla-beta@38a2fecc2ba1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical, tjr
bugs1654211
milestone81.0
Bug 1654211 - Hold WeakPtr to PresistentBufferProvider in BorrowedSourceSurface. r=nical, a=tjr Differential Revision: https://phabricator.services.mozilla.com/D88071
gfx/layers/CanvasRenderer.h
gfx/layers/PersistentBufferProvider.h
--- a/gfx/layers/CanvasRenderer.h
+++ b/gfx/layers/CanvasRenderer.h
@@ -90,17 +90,17 @@ struct CanvasRendererData final {
 //                                          ^
 //                                          |
 //                           +-------------+--------------+
 //                           |WebRenderCanvasRendererAsync|
 //                           +----------------------------+
 
 class BorrowedSourceSurface final {
  public:
-  PersistentBufferProvider* const mReturnTo;
+  const WeakPtr<PersistentBufferProvider> mReturnTo;
   const RefPtr<gfx::SourceSurface> mSurf;  /// non-null
 
   BorrowedSourceSurface(PersistentBufferProvider*, RefPtr<gfx::SourceSurface>);
   ~BorrowedSourceSurface();
 };
 
 // -
 
--- a/gfx/layers/PersistentBufferProvider.h
+++ b/gfx/layers/PersistentBufferProvider.h
@@ -9,16 +9,17 @@
 
 #include "mozilla/Assertions.h"  // for MOZ_ASSERT, etc
 #include "mozilla/RefPtr.h"      // for RefPtr, already_AddRefed, etc
 #include "mozilla/layers/KnowsCompositor.h"
 #include "mozilla/layers/LayersTypes.h"
 #include "mozilla/RefCounted.h"
 #include "mozilla/gfx/Types.h"
 #include "mozilla/Vector.h"
+#include "mozilla/WeakPtr.h"
 
 namespace mozilla {
 
 namespace gfx {
 class SourceSurface;
 class DrawTarget;
 }  // namespace gfx
 
@@ -29,17 +30,18 @@ class TextureClient;
 
 /**
  * A PersistentBufferProvider is for users which require the temporary use of
  * a DrawTarget to draw into. When they're done drawing they return the
  * DrawTarget, when they later need to continue drawing they get a DrawTarget
  * from the provider again, the provider will guarantee the contents of the
  * previously returned DrawTarget is persisted into the one newly returned.
  */
-class PersistentBufferProvider : public RefCounted<PersistentBufferProvider> {
+class PersistentBufferProvider : public RefCounted<PersistentBufferProvider>,
+                                 public SupportsWeakPtr {
  public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PersistentBufferProvider)
 
   virtual ~PersistentBufferProvider() = default;
 
   virtual LayersBackend GetType() { return LayersBackend::LAYERS_NONE; }
 
   /**