Bug 627273, part 2: Add some gfx path helpers. sr=roc

This commit is contained in:
Chris Jones 2011-01-26 00:26:37 -06:00
parent c7c39d08c5
commit 567d1f2540
2 changed files with 33 additions and 2 deletions

View File

@ -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)
{

View File

@ -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
*/