Bug 1060588 - Use PushClipRect when possible in ClipToRegionInternal. r=jrmuizel, a=lmandel
authorBas Schouten <bschouten@mozilla.com>
Sun, 14 Sep 2014 23:51:30 +0200
changeset 225745 6609fd74488b
parent 225744 eb43a2c05eb3
child 225746 2418d9e17dd0
push id3999
push userryanvm@gmail.com
push date2014-10-20 16:11 +0000
treeherdermozilla-beta@2418d9e17dd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel, lmandel
bugs1060588
milestone34.0
Bug 1060588 - Use PushClipRect when possible in ClipToRegionInternal. r=jrmuizel, a=lmandel
gfx/thebes/gfxUtils.cpp
--- a/gfx/thebes/gfxUtils.cpp
+++ b/gfx/thebes/gfxUtils.cpp
@@ -698,16 +698,22 @@ PathFromRegionInternal(DrawTarget* aTarg
   RefPtr<Path> path = pb->Finish();
   return path;
 }
 
 static void
 ClipToRegionInternal(DrawTarget* aTarget, const nsIntRegion& aRegion,
                      bool aSnap)
 {
+  if (!aRegion.IsComplex()) {
+    nsIntRect rect = aRegion.GetBounds();
+    aTarget->PushClipRect(Rect(rect.x, rect.y, rect.width, rect.height));
+    return;
+  }
+
   RefPtr<Path> path = PathFromRegionInternal(aTarget, aRegion, aSnap);
   aTarget->PushClip(path);
 }
 
 /*static*/ void
 gfxUtils::ClipToRegion(gfxContext* aContext, const nsIntRegion& aRegion)
 {
   ClipToRegionInternal(aContext, aRegion, false);