Bug 1060588: Use PushClipRect when possible in ClipToRegionInternal. r=jrmuizel
authorBas Schouten <bschouten@mozilla.com>
Sun, 14 Sep 2014 23:51:30 +0200
changeset 205256 7861be6bf0390ad3dfe4accc0a36a8e5ba345e78
parent 205255 3706401f8cc93082d68cc55db3a04a59086ba988
child 205257 340c37065b0cf632c3dbc0255a379cb6f047a196
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersjrmuizel
bugs1060588
milestone35.0a1
Bug 1060588: Use PushClipRect when possible in ClipToRegionInternal. r=jrmuizel
gfx/thebes/gfxUtils.cpp
--- a/gfx/thebes/gfxUtils.cpp
+++ b/gfx/thebes/gfxUtils.cpp
@@ -704,16 +704,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);