Bug 1356119 - Skip Flush to old context after device reset; r?dvander draft
authorKevin Chen <kechen@mozilla.com>
Thu, 13 Apr 2017 14:13:31 +0800
changeset 561754 6089bd3259e19c268f396111803abe1e98a2d4be
parent 561690 aca6b2a5a2ab3338436c9e819dc2244a022b6425
child 562675 132500a7f5ec5b6582af0cc941cf28f555ae470e
child 562676 fbb26f6c0af4664fdf295df1c211577410453d22
push id53849
push userbmo:kechen@mozilla.com
push dateThu, 13 Apr 2017 06:14:39 +0000
reviewersdvander
bugs1356119
milestone55.0a1
Bug 1356119 - Skip Flush to old context after device reset; r?dvander MozReview-Commit-ID: 1ogI2m9hTp6
gfx/layers/Compositor.h
gfx/layers/composite/LayerManagerComposite.cpp
gfx/layers/d3d11/CompositorD3D11.cpp
gfx/layers/d3d11/CompositorD3D11.h
--- a/gfx/layers/Compositor.h
+++ b/gfx/layers/Compositor.h
@@ -413,17 +413,17 @@ public:
 
   /**
    * Flush the current frame to the screen and tidy up.
    *
    * Derived class overriding this should call Compositor::EndFrame.
    */
   virtual void EndFrame();
 
-  virtual void CancelFrame() { ReadUnlockTextures(); }
+  virtual void CancelFrame(bool aNeedFlush = true) { ReadUnlockTextures(); }
 
   virtual void SetDispAcquireFence(Layer* aLayer);
 
   /**
    * Whether textures created by this compositor can receive partial updates.
    */
   virtual bool SupportsPartialTextureUpdate() = 0;
 
--- a/gfx/layers/composite/LayerManagerComposite.cpp
+++ b/gfx/layers/composite/LayerManagerComposite.cpp
@@ -1364,17 +1364,17 @@ LayerManagerComposite::AutoAddMaskEffect
 
   mCompositable->RemoveMaskEffect();
 }
 
 void
 LayerManagerComposite::ChangeCompositor(Compositor* aNewCompositor)
 {
   if (mCompositor) {
-    mCompositor->CancelFrame();
+    mCompositor->CancelFrame(false);
   }
   mCompositor = aNewCompositor;
   mTwoPassTmpTarget = nullptr;
 }
 
 LayerComposite::LayerComposite(LayerManagerComposite *aManager)
   : HostLayer(aManager)
   , mCompositeManager(aManager)
--- a/gfx/layers/d3d11/CompositorD3D11.cpp
+++ b/gfx/layers/d3d11/CompositorD3D11.cpp
@@ -1529,22 +1529,24 @@ CompositorD3D11::Present()
   } else {
     mBackBufferInvalid.SetEmpty();
   }
 
   mDisableSequenceForNextFrame = false;
 }
 
 void
-CompositorD3D11::CancelFrame()
+CompositorD3D11::CancelFrame(bool aNeedFlush)
 {
   ReadUnlockTextures();
   // Flush the context, otherwise the driver might hold some resources alive
   // until the next flush or present.
-  mContext->Flush();
+  if (aNeedFlush) {
+    mContext->Flush();
+  }
 }
 
 void
 CompositorD3D11::PrepareViewport(const gfx::IntSize& aSize)
 {
   // This view matrix translates coordinates from 0..width and 0..height to
   // -1..1 on the X axis, and -1..1 on the Y axis (flips the Y coordinate)
   Matrix viewMatrix = Matrix::Translation(-1.0, 1.0);
--- a/gfx/layers/d3d11/CompositorD3D11.h
+++ b/gfx/layers/d3d11/CompositorD3D11.h
@@ -114,17 +114,17 @@ public:
 
   void NormalDrawingDone() override;
 
   /**
    * Flush the current frame to the screen.
    */
   virtual void EndFrame() override;
 
-  virtual void CancelFrame() override;
+  virtual void CancelFrame(bool aNeedFlush = true) override;
 
   /**
    * Setup the viewport and projection matrix for rendering
    * to a window of the given dimensions.
    */
   virtual void PrepareViewport(const gfx::IntSize& aSize);
   virtual void PrepareViewport(const gfx::IntSize& aSize, const gfx::Matrix4x4& aProjection,
                                float aZNear, float aZFar);