Bug 1239137 - Return early from BasicCompositor::DrawQuad if transformBounds is empty. r?mattwoodrow draft
authorMarkus Stange <mstange@themasta.com>
Wed, 13 Jan 2016 00:13:20 +0100
changeset 321157 6749f7053f122fa29166c958750b165711ead634
parent 321156 df2c9d3246c7a7dd89734ea0437b6cd2c80bf51c
child 512856 a5a8a96692cb89bdf851fa53cfd0b48534908fee
push id9331
push usermstange@themasta.com
push dateTue, 12 Jan 2016 23:13:50 +0000
reviewersmattwoodrow
bugs1239137
milestone46.0a1
Bug 1239137 - Return early from BasicCompositor::DrawQuad if transformBounds is empty. r?mattwoodrow
gfx/layers/basic/BasicCompositor.cpp
--- a/gfx/layers/basic/BasicCompositor.cpp
+++ b/gfx/layers/basic/BasicCompositor.cpp
@@ -347,17 +347,16 @@ BasicCompositor::DrawQuad(const gfx::Rec
                           const gfx::Rect& aVisibleRect)
 {
   RefPtr<DrawTarget> buffer = mRenderTarget->mDrawTarget;
 
   // For 2D drawing, |dest| and |buffer| are the same surface. For 3D drawing,
   // |dest| is a temporary surface.
   RefPtr<DrawTarget> dest = buffer;
 
-  buffer->PushClipRect(aClipRect);
   AutoRestoreTransform autoRestoreTransform(dest);
 
   Matrix newTransform;
   Rect transformBounds;
   Matrix4x4 new3DTransform;
   IntPoint offset = mRenderTarget->GetOrigin();
 
   if (aTransform.Is2D()) {
@@ -370,24 +369,30 @@ BasicCompositor::DrawQuad(const gfx::Rec
     }
 
     dest->SetTransform(Matrix::Translation(-aRect.x, -aRect.y));
 
     // Get the bounds post-transform.
     transformBounds = aTransform.TransformAndClipBounds(aRect, Rect(offset.x, offset.y, buffer->GetSize().width, buffer->GetSize().height));
     transformBounds.RoundOut();
 
+    if (transformBounds.IsEmpty()) {
+      return;
+    }
+
     // Propagate the coordinate offset to our 2D draw target.
     newTransform = Matrix::Translation(transformBounds.x, transformBounds.y);
 
     // When we apply the 3D transformation, we do it against a temporary
     // surface, so undo the coordinate offset.
     new3DTransform = Matrix4x4::Translation(aRect.x, aRect.y, 0) * aTransform;
   }
 
+  buffer->PushClipRect(aClipRect);
+
   newTransform.PostTranslate(-offset.x, -offset.y);
   buffer->SetTransform(newTransform);
 
   RefPtr<SourceSurface> sourceMask;
   Matrix maskTransform;
   if (aEffectChain.mSecondaryEffects[EffectTypes::MASK]) {
     EffectMask *effectMask = static_cast<EffectMask*>(aEffectChain.mSecondaryEffects[EffectTypes::MASK].get());
     sourceMask = effectMask->mMaskTexture->AsSourceBasic()->GetSurface(dest);