Bug 586683 - Part 2a - Add ScaleRoundOut to nsIntRect/Region. r=joe a=blocking2.0

This commit is contained in:
Matt Woodrow 2011-02-09 09:37:44 +13:00
Родитель 229086f86e
Коммит 76d5166e16
4 изменённых файлов: 37 добавлений и 0 удалений

Просмотреть файл

@ -328,3 +328,15 @@ PRBool nsIntRect::UnionRect(const nsIntRect &aRect1, const nsIntRect &aRect2)
return result;
}
// scale the rect but round to smallest containing rect
nsIntRect& nsIntRect::ScaleRoundOut(float aXScale, float aYScale)
{
nscoord right = NSToCoordCeil(float(XMost()) * aXScale);
nscoord bottom = NSToCoordCeil(float(YMost()) * aYScale);
x = NSToCoordFloor(float(x) * aXScale);
y = NSToCoordFloor(float(y) * aYScale);
width = (right - x);
height = (bottom - y);
return *this;
}

Просмотреть файл

@ -342,6 +342,8 @@ struct NS_GFX nsIntRect {
PRInt32 YMost() const {return y + height;}
inline nsRect ToAppUnits(nscoord aAppUnitsPerPixel) const;
nsIntRect& ScaleRoundOut(float aXScale, float aYScale);
// Returns a special nsIntRect that's used in some places to signify
// "all available space".

Просмотреть файл

@ -1316,6 +1316,22 @@ nsRegion& nsRegion::ExtendForScaling (float aXMult, float aYMult)
*this = region;
return *this;
}
nsRegion& nsRegion::ScaleRoundOut (float aXScale, float aYScale)
{
nsRegion region;
nsRegionRectIterator iter(*this);
for (;;) {
const nsRect* r = iter.Next();
if (!r)
break;
nsRect rect = *r;
rect.ScaleRoundOut(aXScale, aYScale);
region.Or(region, rect);
}
*this = region;
return *this;
}
nsRegion nsRegion::ConvertAppUnitsRoundOut (PRInt32 aFromAPP, PRInt32 aToAPP) const
{

Просмотреть файл

@ -184,6 +184,7 @@ public:
// the region.
nsRegion ConvertAppUnitsRoundOut (PRInt32 aFromAPP, PRInt32 aToAPP) const;
nsRegion ConvertAppUnitsRoundIn (PRInt32 aFromAPP, PRInt32 aToAPP) const;
nsRegion& ScaleRoundOut(float aXScale, float aYScale);
nsIntRegion ToOutsidePixels (nscoord aAppUnitsPerPixel) const;
nsRegion& ExtendForScaling (float aXMult, float aYMult);
@ -438,6 +439,12 @@ public:
{
return FromRect (mImpl.GetLargestRectangle( ToRect(aContainingRect) ));
}
nsIntRegion& ScaleRoundOut (float aXScale, float aYScale)
{
mImpl.ScaleRoundOut(aXScale, aYScale);
return *this;
}
nsIntRegion& ExtendForScaling (float aXMult, float aYMult)
{