Bug 633282 - Add ToNearestPixels to nsRegion. r=roc.

This commit is contained in:
Jim Mathies 2011-05-13 11:40:46 -05:00
parent 02f8ccf86e
commit 2a4de6175a
2 changed files with 18 additions and 2 deletions

View File

@ -1363,18 +1363,32 @@ nsRegion nsRegion::ConvertAppUnitsRoundIn (PRInt32 aFromAPP, PRInt32 aToAPP) con
return region;
}
nsIntRegion nsRegion::ToOutsidePixels (nscoord aAppUnitsPerPixel) const
nsIntRegion nsRegion::ToPixels (nscoord aAppUnitsPerPixel, bool aOutsidePixels) const
{
nsIntRegion result;
nsRegionRectIterator rgnIter(*this);
const nsRect* currentRect;
while ((currentRect = rgnIter.Next())) {
nsIntRect deviceRect = currentRect->ToOutsidePixels(aAppUnitsPerPixel);
nsIntRect deviceRect;
if (aOutsidePixels)
deviceRect = currentRect->ToOutsidePixels(aAppUnitsPerPixel);
else
deviceRect = currentRect->ToNearestPixels(aAppUnitsPerPixel);
result.Or(result, deviceRect);
}
return result;
}
nsIntRegion nsRegion::ToOutsidePixels (nscoord aAppUnitsPerPixel) const
{
return ToPixels(aAppUnitsPerPixel, true);
}
nsIntRegion nsRegion::ToNearestPixels (nscoord aAppUnitsPerPixel) const
{
return ToPixels(aAppUnitsPerPixel, false);
}
// A cell's "value" is a pair consisting of
// a) the area of the subrectangle it corresponds to, if it's in
// aContainingRect and in the region, 0 otherwise

View File

@ -186,6 +186,7 @@ public:
nsRegion ConvertAppUnitsRoundIn (PRInt32 aFromAPP, PRInt32 aToAPP) const;
nsRegion& ScaleRoundOut(float aXScale, float aYScale);
nsIntRegion ToOutsidePixels (nscoord aAppUnitsPerPixel) const;
nsIntRegion ToNearestPixels (nscoord aAppUnitsPerPixel) const;
nsRegion& ExtendForScaling (float aXMult, float aYMult);
/**
@ -262,6 +263,7 @@ private:
void MoveInto (nsRegion& aDestRegion, const RgnRect* aStartRect);
void MoveInto (nsRegion& aDestRegion)
{ MoveInto (aDestRegion, mRectListHead.next); }
nsIntRegion ToPixels(nscoord aAppUnitsPerPixel, bool aOutsidePixels) const;
};