Bug 1574745 - Respect render target clip during DrawGeometry culling and overdraw pixel counting. r=mattwoodrow
authorMarkus Stange <mstange@themasta.com>
Fri, 30 Aug 2019 19:51:37 +0000
changeset 551506 f988e453af006431e31402f70dafd9bf5ef5e563
parent 551505 dd092bce314d6c0292d54b50ce540cfcf9e435bf
child 551507 cc84a0e9d5ddde198422f4f11ab6bf85f631d5f0
push id11865
push userbtara@mozilla.com
push dateMon, 02 Sep 2019 08:54:37 +0000
treeherdermozilla-beta@37f59c4671b3 [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 - Respect render target clip during DrawGeometry culling and overdraw pixel counting. r=mattwoodrow Differential Revision: https://phabricator.services.mozilla.com/D43869
gfx/layers/opengl/CompositorOGL.cpp
--- a/gfx/layers/opengl/CompositorOGL.cpp
+++ b/gfx/layers/opengl/CompositorOGL.cpp
@@ -1285,21 +1285,25 @@ void CompositorOGL::DrawGeometry(const G
                                  const gfx::Rect& aVisibleRect) {
   MOZ_ASSERT(mFrameInProgress, "frame not started");
   MOZ_ASSERT(mCurrentRenderTarget, "No destination");
 
   MakeCurrent();
 
   IntPoint offset = mCurrentRenderTarget->GetOrigin();
   IntSize size = mCurrentRenderTarget->GetSize();
-  Rect renderBound(mCurrentRenderTarget->GetRect());
 
-  // Convert aClipRect into render target space.
+  // Convert aClipRect into render target space, and intersect it with the
+  // render target's clip.
   IntRect clipRect = aClipRect + mCurrentRenderTarget->GetClipSpaceOrigin();
-  renderBound.IntersectRect(renderBound, Rect(clipRect));
+  if (Maybe<IntRect> rtClip = mCurrentRenderTarget->GetClipRect()) {
+    clipRect = clipRect.Intersect(*rtClip);
+  }
+
+  Rect renderBound(mCurrentRenderTarget->GetRect().Intersect(clipRect));
 
   Rect destRect = aTransform.TransformAndClipBounds(aRect, renderBound);
 
   // 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.
@@ -1328,20 +1332,16 @@ void CompositorOGL::DrawGeometry(const G
     NS_ASSERTION(maskTransform.Is2D(),
                  "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));
   }
 
-  if (Maybe<IntRect> rtClip = mCurrentRenderTarget->GetClipRect()) {
-    clipRect = clipRect.Intersect(*rtClip);
-  }
-
   // Move clipRect into device space.
   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()) {