mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-11 01:57:00 +00:00
Bug 586683 - Part 2a - Add ScaleRoundOut to nsIntRect/Region. r=joe a=blocking2.0
This commit is contained in:
parent
229086f86e
commit
76d5166e16
@ -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)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user