Bug 1491442 - Fold DoWidgetCleanup and DetachWidget into Compositor::Destroy. r=mattwoodrow
authorMarkus Stange <mstange@themasta.com>
Fri, 16 Aug 2019 01:09:48 +0000
changeset 488401 9dcce9060dac1eb0dd77b46433eb27d576311ca5
parent 488400 38705780d7f8cb91622359df841cf2549529c445
child 488402 82b63cd1a2d378c8ffd461b27b24a07d758be866
push id113908
push userccoroiu@mozilla.com
push dateFri, 16 Aug 2019 09:57:53 +0000
treeherdermozilla-inbound@83fad6abe38a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1491442
milestone70.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 1491442 - Fold DoWidgetCleanup and DetachWidget into Compositor::Destroy. r=mattwoodrow Differential Revision: https://phabricator.services.mozilla.com/D40867
gfx/layers/Compositor.cpp
gfx/layers/Compositor.h
gfx/layers/basic/BasicCompositor.cpp
gfx/layers/basic/BasicCompositor.h
gfx/layers/ipc/CompositorBridgeParent.cpp
gfx/layers/opengl/CompositorOGL.cpp
--- a/gfx/layers/Compositor.cpp
+++ b/gfx/layers/Compositor.cpp
@@ -71,20 +71,20 @@ Compositor::Compositor(widget::Composito
       mClearColor(0.0, 0.0, 0.0, 0.0),
       mDefaultClearColor(0.0, 0.0, 0.0, 0.0)
 #endif
 {
 }
 
 Compositor::~Compositor() { ReadUnlockTextures(); }
 
-// Called just before DetachWidget.
-void Compositor::DoWidgetCleanup() { mWidget->DoCompositorCleanup(); }
+void Compositor::Destroy() {
+  mWidget->DoCompositorCleanup();
+  mWidget = nullptr;
 
-void Compositor::Destroy() {
   TextureSourceProvider::Destroy();
   mIsDestroyed = true;
 }
 
 void Compositor::EndFrame() {
   ReadUnlockTextures();
   mLastCompositionEndTime = TimeStamp::Now();
 }
--- a/gfx/layers/Compositor.h
+++ b/gfx/layers/Compositor.h
@@ -185,19 +185,16 @@ class Compositor : public TextureSourceP
  public:
   explicit Compositor(widget::CompositorWidget* aWidget,
                       CompositorBridgeParent* aParent = nullptr);
 
   virtual bool Initialize(nsCString* const out_failureReason) = 0;
   void Destroy() override;
   bool IsDestroyed() const { return mIsDestroyed; }
 
-  virtual void DoWidgetCleanup();
-  virtual void DetachWidget() { mWidget = nullptr; }
-
   /**
    * Request a texture host identifier that may be used for creating textures
    * across process or thread boundaries that are compatible with this
    * compositor.
    */
   virtual TextureFactoryIdentifier GetTextureFactoryIdentifier() = 0;
 
   /**
--- a/gfx/layers/basic/BasicCompositor.cpp
+++ b/gfx/layers/basic/BasicCompositor.cpp
@@ -238,26 +238,25 @@ int32_t BasicCompositor::GetMaxTextureSi
 
 void BasicCompositingRenderTarget::BindRenderTarget() {
   if (mClearOnBind) {
     mDrawTarget->ClearRect(Rect(0, 0, mSize.width, mSize.height));
     mClearOnBind = false;
   }
 }
 
-void BasicCompositor::DetachWidget() {
-  if (mWidget) {
-    if (mIsPendingEndRemoteDrawing) {
-      // Force to end previous remote drawing.
-      TryToEndRemoteDrawing(/* aForceToEnd */ true);
-      MOZ_ASSERT(!mIsPendingEndRemoteDrawing);
-    }
-    mWidget->CleanupRemoteDrawing();
+void BasicCompositor::Destroy() {
+  if (mIsPendingEndRemoteDrawing) {
+    // Force to end previous remote drawing.
+    TryToEndRemoteDrawing(/* aForceToEnd */ true);
+    MOZ_ASSERT(!mIsPendingEndRemoteDrawing);
   }
-  Compositor::DetachWidget();
+  mWidget->CleanupRemoteDrawing();
+
+  Compositor::Destroy();
 }
 
 TextureFactoryIdentifier BasicCompositor::GetTextureFactoryIdentifier() {
   TextureFactoryIdentifier ident(LayersBackend::LAYERS_BASIC,
                                  XRE_GetProcessType(), GetMaxTextureSize());
   return ident;
 }
 
--- a/gfx/layers/basic/BasicCompositor.h
+++ b/gfx/layers/basic/BasicCompositor.h
@@ -47,17 +47,17 @@ class BasicCompositor : public Composito
  protected:
   virtual ~BasicCompositor();
 
  public:
   BasicCompositor* AsBasicCompositor() override { return this; }
 
   bool Initialize(nsCString* const out_failureReason) override;
 
-  void DetachWidget() override;
+  void Destroy() override;
 
   TextureFactoryIdentifier GetTextureFactoryIdentifier() override;
 
   already_AddRefed<CompositingRenderTarget> CreateRenderTarget(
       const gfx::IntRect& aRect, SurfaceInitMode aInit) override;
 
   already_AddRefed<CompositingRenderTarget> CreateRenderTargetFromSource(
       const gfx::IntRect& aRect, const CompositingRenderTarget* aSource,
--- a/gfx/layers/ipc/CompositorBridgeParent.cpp
+++ b/gfx/layers/ipc/CompositorBridgeParent.cpp
@@ -494,18 +494,16 @@ void CompositorBridgeParent::StopAndClea
     if (mAsyncImageManager) {
       mAsyncImageManager->Destroy();
       // WebRenderAPI should be already destructed
       mAsyncImageManager = nullptr;
     }
   }
 
   if (mCompositor) {
-    mCompositor->DoWidgetCleanup();
-    mCompositor->DetachWidget();
     mCompositor->Destroy();
     mCompositor = nullptr;
   }
 
   // This must be destroyed now since it accesses the widget.
   if (mCompositorScheduler) {
     mCompositorScheduler->Destroy();
     mCompositorScheduler = nullptr;
--- a/gfx/layers/opengl/CompositorOGL.cpp
+++ b/gfx/layers/opengl/CompositorOGL.cpp
@@ -207,17 +207,16 @@ CompositorOGL::CompositorOGL(CompositorB
   MOZ_COUNT_CTOR(CompositorOGL);
 }
 
 CompositorOGL::~CompositorOGL() {
 #ifdef XP_DARWIN
   TextureSync::UnregisterTextureSourceProvider(this);
 #endif
   MOZ_COUNT_DTOR(CompositorOGL);
-  Destroy();
 }
 
 already_AddRefed<mozilla::gl::GLContext> CompositorOGL::CreateContext() {
   RefPtr<GLContext> context;
 
   // Used by mock widget to create an offscreen context
   nsIWidget* widget = mWidget->RealWidget();
   void* widgetOpenGLContext =