From 5f2c6517be46900f67b38c2002e7112403b4943f Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Tue, 22 Oct 2013 12:11:30 +0200 Subject: [PATCH] Bug 928727 - Share code for getting the user-space clip bounds in DrawTargetCairo. r=jrmuizel --- gfx/2d/DrawTargetCairo.cpp | 21 ++++++++++----------- gfx/2d/DrawTargetCairo.h | 2 ++ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/gfx/2d/DrawTargetCairo.cpp b/gfx/2d/DrawTargetCairo.cpp index 44a5a0cf8dbd..213de9514ddc 100644 --- a/gfx/2d/DrawTargetCairo.cpp +++ b/gfx/2d/DrawTargetCairo.cpp @@ -512,13 +512,10 @@ DrawTargetCairo::DrawSurface(SourceSurface *aSurface, cairo_set_antialias(mContext, GfxAntialiasToCairoAntialias(aOptions.mAntialiasMode)); - double clipX1, clipY1, clipX2, clipY2; - cairo_clip_extents(mContext, &clipX1, &clipY1, &clipX2, &clipY2); - Rect clip(clipX1, clipY1, clipX2 - clipX1, clipY2 - clipY1); // Narrowing of doubles to floats // If the destination rect covers the entire clipped area, then unbounded and bounded // operations are identical, and we don't need to push a group. bool needsGroup = !IsOperatorBoundByMask(aOptions.mCompositionOp) && - !aDest.Contains(clip); + !aDest.Contains(GetUserSpaceClip()); cairo_translate(mContext, aDest.X(), aDest.Y()); @@ -682,13 +679,7 @@ DrawTargetCairo::FillRect(const Rect &aRect, bool pathBoundsClip = false; - double cexts[4]; - cairo_clip_extents(mContext, &cexts[0], &cexts[1], &cexts[2], &cexts[3]); - Rect clipRect(cexts[0], cexts[1], cexts[2] - cexts[0], cexts[3] - cexts[1]); - double pexts[4]; - cairo_path_extents(mContext, &pexts[0], &pexts[1], &pexts[2], &pexts[3]); - Rect pathRect(pexts[0], pexts[1], pexts[2] - pexts[0], pexts[3] - pexts[1]); - if (pathRect.Contains(clipRect)) { + if (aRect.Contains(GetUserSpaceClip())) { pathBoundsClip = true; } @@ -1192,6 +1183,14 @@ DrawTargetCairo::SetTransform(const Matrix& aTransform) cairo_set_matrix(mContext, &mat); } +Rect +DrawTargetCairo::GetUserSpaceClip() +{ + double clipX1, clipY1, clipX2, clipY2; + cairo_clip_extents(mContext, &clipX1, &clipY1, &clipX2, &clipY2); + return Rect(clipX1, clipY1, clipX2 - clipX1, clipY2 - clipY1); // Narrowing of doubles to floats +} + cairo_t* BorrowedCairoContext::BorrowCairoContextFromDrawTarget(DrawTarget* aDT) { diff --git a/gfx/2d/DrawTargetCairo.h b/gfx/2d/DrawTargetCairo.h index f23b6241dcef..22a006fe27fc 100644 --- a/gfx/2d/DrawTargetCairo.h +++ b/gfx/2d/DrawTargetCairo.h @@ -172,6 +172,8 @@ private: // methods const IntRect& aSource, const IntPoint& aDest); + Rect GetUserSpaceClip(); + // Call before you make any changes to the backing surface with which this // context is associated. Pass the path you're going to be using if you have // one.