diff --git a/gfx/thebes/gfxUtils.cpp b/gfx/thebes/gfxUtils.cpp index a15ca26a265..a294f96719b 100644 --- a/gfx/thebes/gfxUtils.cpp +++ b/gfx/thebes/gfxUtils.cpp @@ -434,9 +434,10 @@ gfxUtils::ImageFormatToDepth(gfxASurface::gfxImageFormat aFormat) } return 0; } + static void -ClipToRegionInternal(gfxContext* aContext, const nsIntRegion& aRegion, - PRBool aSnap) +PathFromRegionInternal(gfxContext* aContext, const nsIntRegion& aRegion, + PRBool aSnap) { aContext->NewPath(); nsIntRegionRectIterator iter(aRegion); @@ -444,6 +445,13 @@ ClipToRegionInternal(gfxContext* aContext, const nsIntRegion& aRegion, while ((r = iter.Next()) != nsnull) { aContext->Rectangle(gfxRect(r->x, r->y, r->width, r->height), aSnap); } +} + +static void +ClipToRegionInternal(gfxContext* aContext, const nsIntRegion& aRegion, + PRBool aSnap) +{ + PathFromRegionInternal(aContext, aRegion, aSnap); aContext->Clip(); } @@ -459,6 +467,19 @@ gfxUtils::ClipToRegionSnapped(gfxContext* aContext, const nsIntRegion& aRegion) ClipToRegionInternal(aContext, aRegion, PR_TRUE); } +/*static*/ void +gfxUtils::PathFromRegion(gfxContext* aContext, const nsIntRegion& aRegion) +{ + PathFromRegionInternal(aContext, aRegion, PR_FALSE); +} + +/*static*/ void +gfxUtils::PathFromRegionSnapped(gfxContext* aContext, const nsIntRegion& aRegion) +{ + PathFromRegionInternal(aContext, aRegion, PR_TRUE); +} + + PRBool gfxUtils::GfxRectToIntRect(const gfxRect& aIn, nsIntRect* aOut) { diff --git a/gfx/thebes/gfxUtils.h b/gfx/thebes/gfxUtils.h index 68b2facdd6d..f241a926027 100644 --- a/gfx/thebes/gfxUtils.h +++ b/gfx/thebes/gfxUtils.h @@ -96,6 +96,16 @@ public: */ static void ClipToRegionSnapped(gfxContext* aContext, const nsIntRegion& aRegion); + /** + * Create a path consisting of rectangles in |aRegion|. + */ + static void PathFromRegion(gfxContext* aContext, const nsIntRegion& aRegion); + + /** + * Create a path consisting of rectangles in |aRegion|, snapping the rectangles. + */ + static void PathFromRegionSnapped(gfxContext* aContext, const nsIntRegion& aRegion); + /* * Convert image format to depth value */