Bug 1574745 - Make DrawGeometry culling work more reliably. r=mattwoodrow
authorMarkus Stange <mstange@themasta.com>
Fri, 30 Aug 2019 19:51:45 +0000
changeset 554760 cc84a0e9d5ddde198422f4f11ab6bf85f631d5f0
parent 554759 f988e453af006431e31402f70dafd9bf5ef5e563
child 554761 6035e8ef4f82c1ab750f8fb0ca35c374c61ea9ed
push id2165
push userffxbld-merge
push dateMon, 14 Oct 2019 16:30:58 +0000
treeherdermozilla-release@0eae18af659f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1574745
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 1574745 - Make DrawGeometry culling work more reliably. r=mattwoodrow The call to TransformAndClipBounds already clips destRect to renderBounds. However, if the resulting rect was empty, the Inflate call would make it non-empty again. And now the decision whether we would cull would depend on the rect's position: Sometimes TransformAndClipBounds would place the empty rect at a position along an edge of renderBounds, and then the inflated-from-nothingness 2x2 rect would overlap renderBounds and we wouldn't cull. Differential Revision: https://phabricator.services.mozilla.com/D43870
gfx/layers/opengl/CompositorOGL.cpp
--- a/gfx/layers/opengl/CompositorOGL.cpp
+++ b/gfx/layers/opengl/CompositorOGL.cpp
@@ -1283,43 +1283,33 @@ void CompositorOGL::DrawGeometry(const G
                                  gfx::Float aOpacity,
                                  const gfx::Matrix4x4& aTransform,
                                  const gfx::Rect& aVisibleRect) {
   MOZ_ASSERT(mFrameInProgress, "frame not started");
   MOZ_ASSERT(mCurrentRenderTarget, "No destination");
 
   MakeCurrent();
 
-  IntPoint offset = mCurrentRenderTarget->GetOrigin();
-  IntSize size = mCurrentRenderTarget->GetSize();
-
   // Convert aClipRect into render target space, and intersect it with the
   // render target's clip.
   IntRect clipRect = aClipRect + mCurrentRenderTarget->GetClipSpaceOrigin();
   if (Maybe<IntRect> rtClip = mCurrentRenderTarget->GetClipRect()) {
     clipRect = clipRect.Intersect(*rtClip);
   }
 
-  Rect renderBound(mCurrentRenderTarget->GetRect().Intersect(clipRect));
-
-  Rect destRect = aTransform.TransformAndClipBounds(aRect, renderBound);
+  Rect destRect = aTransform.TransformAndClipBounds(
+      aRect, Rect(mCurrentRenderTarget->GetRect().Intersect(clipRect)));
+  if (destRect.IsEmpty()) {
+    return;
+  }
 
   // XXX: This doesn't handle 3D transforms. It also doesn't handled rotated
   //      quads. Fix me.
   mPixelsFilled += destRect.Area();
 
-  // Do a simple culling if this rect is out of target buffer.
-  // Inflate a small size to avoid some numerical imprecision issue.
-  destRect.Inflate(1, 1);
-  destRect.MoveBy(-offset);
-  renderBound = Rect(0, 0, size.width, size.height);
-  if (!renderBound.Intersects(destRect)) {
-    return;
-  }
-
   LayerScope::DrawBegin();
 
   EffectMask* effectMask;
   Rect maskBounds;
   if (aEffectChain.mSecondaryEffects[EffectTypes::MASK]) {
     effectMask = static_cast<EffectMask*>(
         aEffectChain.mSecondaryEffects[EffectTypes::MASK].get());
 
@@ -1333,16 +1323,17 @@ void CompositorOGL::DrawGeometry(const G
                  "How did we end up with a 3D transform here?!");
     maskBounds = Rect(Point(), Size(maskSize));
     maskBounds = maskTransform.As2D().TransformBounds(maskBounds);
 
     clipRect = clipRect.Intersect(RoundedOut(maskBounds));
   }
 
   // Move clipRect into device space.
+  IntPoint offset = mCurrentRenderTarget->GetOrigin();
   clipRect -= offset;
 
   // clipRect is in destination coordinate space (after all
   // transforms and offsets have been applied) so if our
   // drawing is going to be shifted by mRenderOffset then we need
   // to shift the clip rect by the same amount.
   if (!mTarget && mCurrentRenderTarget->IsWindow()) {
     clipRect.MoveBy(mRenderOffset.x + mSurfaceOrigin.x,