Bug 1592150 - Remove CurrentSurfaceInvalidRegion(). Callers now always just repaint the update region that they supplied. r=jrmuizel
authorMarkus Stange <mstange@themasta.com>
Tue, 19 Nov 2019 03:11:26 +0000
changeset 502545 1af8d457ec9937c9d59746905bbbd30e32ee57c4
parent 502544 ffcddfbaf321cb2f7ca87fe3ab68a1347b4328aa
child 502546 8ae9d7dc86f2e723b73d3b7cdc1cea4c821ad9f0
push id100900
push usermstange@themasta.com
push dateTue, 19 Nov 2019 03:41:47 +0000
treeherderautoland@8ae9d7dc86f2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1592150
milestone72.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 1592150 - Remove CurrentSurfaceInvalidRegion(). Callers now always just repaint the update region that they supplied. r=jrmuizel Differential Revision: https://phabricator.services.mozilla.com/D51761
gfx/layers/NativeLayer.h
gfx/layers/NativeLayerCA.h
gfx/layers/NativeLayerCA.mm
gfx/layers/basic/BasicCompositor.cpp
gfx/layers/opengl/CompositorOGL.cpp
gfx/layers/opengl/CompositorOGL.h
widget/cocoa/nsChildView.mm
--- a/gfx/layers/NativeLayer.h
+++ b/gfx/layers/NativeLayer.h
@@ -86,23 +86,23 @@ class NativeLayer {
   // Whether the surface contents are flipped vertically compared to this
   // layer's coordinate system. Can be set on any thread at any time.
   virtual void SetSurfaceIsFlipped(bool aIsFlipped) = 0;
   virtual bool SurfaceIsFlipped() = 0;
 
   // Returns a DrawTarget. The size of the DrawTarget will be the same as the
   // size of this layer. The caller should draw to that DrawTarget, then drop
   // its reference to the DrawTarget, and then call NotifySurfaceReady(). It can
-  // limit its drawing to CurrentSurfaceInvalidRegion() (which is in the
-  // DrawTarget's device space). After a call to NextSurface*, NextSurface* must
-  // not be called again until after NotifySurfaceReady has been called. Can be
-  // called on any thread. When used from multiple threads, callers need to make
-  // sure that they still only call NextSurface* and NotifySurfaceReady
-  // alternatingly and not in any other order.
-  // aUpdateRegion must not extend beyond the layer size.
+  // limit its drawing to aUpdateRegion (which is in the DrawTarget's device
+  // space). After a call to NextSurface*, NextSurface* must not be called again
+  // until after NotifySurfaceReady has been called. Can be called on any
+  // thread. When used from multiple threads, callers need to make sure that
+  // they still only call NextSurface* and NotifySurfaceReady alternatingly and
+  // not in any other order. aUpdateRegion must not extend beyond the layer
+  // size.
   virtual RefPtr<gfx::DrawTarget> NextSurfaceAsDrawTarget(
       const gfx::IntRegion& aUpdateRegion, gfx::BackendType aBackendType) = 0;
 
   // Set the GLContext to use for the MozFramebuffer that are returned from
   // NextSurfaceAsFramebuffer. If changed to a different value, all
   // MozFramebuffers tracked by this layer will be discarded.
   // It's a good idea to call SetGLContext(nullptr) before destroying this
   // layer so that GL resource destruction happens at a good time and on the
@@ -110,41 +110,32 @@ class NativeLayer {
   virtual void SetGLContext(gl::GLContext* aGLContext) = 0;
   virtual gl::GLContext* GetGLContext() = 0;
 
   // Must only be called if a non-null GLContext is set on this layer.
   // Returns a GLuint for a framebuffer that can be used for drawing to the
   // surface. The size of the framebuffer will be the same as the size of this
   // layer. If aNeedsDepth is true, the framebuffer is created with a depth
   // buffer. The caller should draw to the framebuffer, unbind it, and then call
-  // NotifySurfaceReady(). It can limit its drawing to
-  // CurrentSurfaceInvalidRegion() (which is in the framebuffer's device space,
-  // possibly "upside down" if SurfaceIsFlipped()). The framebuffer will be
-  // created using the GLContext that was set on this layer with a call to
-  // SetGLContext. The NativeLayer will keep a reference to the MozFramebuffer
-  // so that it can reuse the same MozFramebuffer whenever it uses the same
-  // underlying surface. Calling SetGLContext with a different context will
-  // release that reference. After a call to NextSurface*, NextSurface* must not
-  // be called again until after NotifySurfaceReady has been called. Can be
-  // called on any thread. When used from multiple threads, callers need to make
-  // sure that they still only call NextSurface and NotifySurfaceReady
-  // alternatingly and not in any other order.
+  // NotifySurfaceReady(). It can limit its drawing to aUpdateRegion (which is
+  // in the framebuffer's device space, possibly "upside down" if
+  // SurfaceIsFlipped()). The framebuffer will be created using the GLContext
+  // that was set on this layer with a call to SetGLContext. The NativeLayer
+  // will keep a reference to the MozFramebuffer so that it can reuse the same
+  // MozFramebuffer whenever it uses the same underlying surface. Calling
+  // SetGLContext with a different context will release that reference. After a
+  // call to NextSurface*, NextSurface* must not be called again until after
+  // NotifySurfaceReady has been called. Can be called on any thread. When used
+  // from multiple threads, callers need to make sure that they still only call
+  // NextSurface and NotifySurfaceReady alternatingly and not in any other
+  // order.
   // aUpdateRegion must not extend beyond the layer size.
   virtual Maybe<GLuint> NextSurfaceAsFramebuffer(
       const gfx::IntRegion& aUpdateRegion, bool aNeedsDepth) = 0;
 
-  // The invalid region of the surface that has been returned from the most
-  // recent call to NextSurface*. Newly-created surfaces are entirely invalid.
-  // For surfaces that have been used before, the invalid region is the union of
-  // all invalid regions that have been passed to NextSurface* since the last
-  // time that NotifySurfaceReady was called for this surface. Can only be
-  // called between calls to NextSurface* and NotifySurfaceReady. Can be called
-  // on any thread.
-  virtual gfx::IntRegion CurrentSurfaceInvalidRegion() = 0;
-
   // Indicates that the surface which has been returned from the most recent
   // call to NextSurface* is now finished being drawn to and can be displayed on
   // the screen. Resets the invalid region on the surface to the empty region.
   virtual void NotifySurfaceReady() = 0;
 
  protected:
   virtual ~NativeLayer() {}
 };
--- a/gfx/layers/NativeLayerCA.h
+++ b/gfx/layers/NativeLayerCA.h
@@ -91,17 +91,16 @@ class NativeLayerCA : public NativeLayer
   gfx::IntRect GetRect() override;
   RefPtr<gfx::DrawTarget> NextSurfaceAsDrawTarget(
       const gfx::IntRegion& aUpdateRegion,
       gfx::BackendType aBackendType) override;
   void SetGLContext(gl::GLContext* aGLContext) override;
   gl::GLContext* GetGLContext() override;
   Maybe<GLuint> NextSurfaceAsFramebuffer(const gfx::IntRegion& aUpdateRegion,
                                          bool aNeedsDepth) override;
-  gfx::IntRegion CurrentSurfaceInvalidRegion() override;
   void NotifySurfaceReady() override;
   bool IsOpaque() override;
   void SetClipRect(const Maybe<gfx::IntRect>& aClipRect) override;
   Maybe<gfx::IntRect> ClipRect() override;
   void SetSurfaceIsFlipped(bool aIsFlipped) override;
   bool SurfaceIsFlipped() override;
 
  protected:
--- a/gfx/layers/NativeLayerCA.mm
+++ b/gfx/layers/NativeLayerCA.mm
@@ -216,26 +216,16 @@ void NativeLayerCA::SetClipRect(const Ma
   }
 }
 
 Maybe<gfx::IntRect> NativeLayerCA::ClipRect() {
   MutexAutoLock lock(mMutex);
   return mClipRect;
 }
 
-IntRegion NativeLayerCA::CurrentSurfaceInvalidRegion() {
-  MutexAutoLock lock(mMutex);
-
-  MOZ_RELEASE_ASSERT(
-      mInProgressSurface,
-      "Only call currentSurfaceInvalidRegion after a call to NextSurface and before the call "
-      "to notifySurfaceIsReady.");
-  return mInProgressSurface->mInvalidRegion;
-}
-
 void NativeLayerCA::InvalidateRegionThroughoutSwapchain(const MutexAutoLock&,
                                                         const IntRegion& aRegion) {
   IntRegion r = aRegion;
   if (mInProgressSurface) {
     mInProgressSurface->mInvalidRegion.OrWith(r);
   }
   if (mReadySurface) {
     mReadySurface->mInvalidRegion.OrWith(r);
--- a/gfx/layers/basic/BasicCompositor.cpp
+++ b/gfx/layers/basic/BasicCompositor.cpp
@@ -1034,19 +1034,16 @@ Maybe<gfx::IntRect> BasicCompositor::Beg
   RefPtr<CompositingRenderTarget> target;
   aNativeLayer->SetSurfaceIsFlipped(false);
   IntRegion invalidRelativeToLayer = mInvalidRegion.MovedBy(-rect.TopLeft());
   RefPtr<DrawTarget> dt = aNativeLayer->NextSurfaceAsDrawTarget(
       invalidRelativeToLayer, BackendType::SKIA);
   if (!dt) {
     return Nothing();
   }
-  invalidRelativeToLayer = aNativeLayer->CurrentSurfaceInvalidRegion();
-  mInvalidRegion = invalidRelativeToLayer.MovedBy(rect.TopLeft());
-  MOZ_RELEASE_ASSERT(!mInvalidRegion.IsEmpty());
   mCurrentNativeLayer = aNativeLayer;
   IntRegion clearRegion;
   clearRegion.Sub(mInvalidRegion, aOpaqueRegion);
   // Set up a render target for drawing directly to dt.
   target = CreateRootRenderTarget(dt, rect, clearRegion);
 
   MOZ_RELEASE_ASSERT(target);
   SetRenderTarget(target);
--- a/gfx/layers/opengl/CompositorOGL.cpp
+++ b/gfx/layers/opengl/CompositorOGL.cpp
@@ -753,36 +753,33 @@ void CompositorOGL::ClearRect(const gfx:
   ScopedScissorRect autoScissorRect(mGLContext, aRect.X(), y, aRect.Width(),
                                     aRect.Height());
   mGLContext->fClearColor(0.0, 0.0, 0.0, 0.0);
   mGLContext->fClear(LOCAL_GL_COLOR_BUFFER_BIT | LOCAL_GL_DEPTH_BUFFER_BIT);
 }
 
 already_AddRefed<CompositingRenderTargetOGL>
 CompositorOGL::RenderTargetForNativeLayer(NativeLayer* aNativeLayer,
-                                          IntRegion& aInvalidRegion) {
+                                          const IntRegion& aInvalidRegion) {
   if (aInvalidRegion.IsEmpty()) {
     return nullptr;
   }
 
   aNativeLayer->SetSurfaceIsFlipped(true);
   aNativeLayer->SetGLContext(mGLContext);
 
   IntRect layerRect = aNativeLayer->GetRect();
   IntRegion invalidRelativeToLayer =
       aInvalidRegion.MovedBy(-layerRect.TopLeft());
   Maybe<GLuint> fbo =
       aNativeLayer->NextSurfaceAsFramebuffer(invalidRelativeToLayer, false);
   if (!fbo) {
     return nullptr;
   }
 
-  invalidRelativeToLayer = aNativeLayer->CurrentSurfaceInvalidRegion();
-  aInvalidRegion = invalidRelativeToLayer.MovedBy(layerRect.TopLeft());
-
   RefPtr<CompositingRenderTargetOGL> rt =
       CompositingRenderTargetOGL::CreateForExternallyOwnedFBO(
           this, *fbo, layerRect, IntPoint());
 
   // Clip the render target to the invalid rect. This conserves memory bandwidth
   // and power.
   IntRect invalidRect = aInvalidRegion.GetBounds();
   rt->SetClipRect(invalidRect == layerRect ? Nothing() : Some(invalidRect));
--- a/gfx/layers/opengl/CompositorOGL.h
+++ b/gfx/layers/opengl/CompositorOGL.h
@@ -140,21 +140,20 @@ class CompositorOGL final : public Compo
         LayersBackend::LAYERS_OPENGL, XRE_GetProcessType(), GetMaxTextureSize(),
         SupportsTextureDirectMapping(), false,
         mFBOTextureTarget == LOCAL_GL_TEXTURE_2D,
         SupportsPartialTextureUpdate());
     return result;
   }
 
   // Returns a render target for the native layer.
-  // aInvalidRegion will be mutated to include existing invalid areas in the
-  // layer. aInvalidRegion is in window coordinates, i.e. in the same space
-  // as aNativeLayer->GetRect().
+  // aInvalidRegion is in window coordinates, i.e. in the same space as
+  // aNativeLayer->GetPosition().
   already_AddRefed<CompositingRenderTargetOGL> RenderTargetForNativeLayer(
-      NativeLayer* aNativeLayer, gfx::IntRegion& aInvalidRegion);
+      NativeLayer* aNativeLayer, const gfx::IntRegion& aInvalidRegion);
 
   already_AddRefed<CompositingRenderTarget> CreateRenderTarget(
       const gfx::IntRect& aRect, SurfaceInitMode aInit) override;
 
   already_AddRefed<CompositingRenderTarget> CreateRenderTargetFromSource(
       const gfx::IntRect& aRect, const CompositingRenderTarget* aSource,
       const gfx::IntPoint& aSourcePoint) override;
 
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -1349,19 +1349,17 @@ void nsChildView::PaintWindowInContentLa
   EnsureContentLayerForMainThreadPainting();
   mContentLayer->SetSurfaceIsFlipped(false);
   RefPtr<DrawTarget> dt = mContentLayer->NextSurfaceAsDrawTarget(
       mContentLayerInvalidRegion.ToUnknownRegion(), gfx::BackendType::SKIA);
   if (!dt) {
     return;
   }
 
-  PaintWindowInDrawTarget(
-      dt, LayoutDeviceIntRegion::FromUnknownRegion(mContentLayer->CurrentSurfaceInvalidRegion()),
-      dt->GetSize());
+  PaintWindowInDrawTarget(dt, mContentLayerInvalidRegion, dt->GetSize());
   mContentLayer->NotifySurfaceReady();
   mContentLayerInvalidRegion.SetEmpty();
 }
 
 void nsChildView::HandleMainThreadCATransaction() {
   WillPaintWindow();
 
   if (GetLayerManager()->GetBackendType() == LayersBackend::LAYERS_BASIC) {