зеркало из https://github.com/mozilla/gecko-dev.git
Bug 586683 - Part 2a - Add ScaleRoundOut to nsIntRect/Region. r=joe a=blocking2.0
This commit is contained in:
Родитель
229086f86e
Коммит
76d5166e16
|
@ -328,3 +328,15 @@ PRBool nsIntRect::UnionRect(const nsIntRect &aRect1, const nsIntRect &aRect2)
|
||||||
return result;
|
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;}
|
PRInt32 YMost() const {return y + height;}
|
||||||
|
|
||||||
inline nsRect ToAppUnits(nscoord aAppUnitsPerPixel) const;
|
inline nsRect ToAppUnits(nscoord aAppUnitsPerPixel) const;
|
||||||
|
|
||||||
|
nsIntRect& ScaleRoundOut(float aXScale, float aYScale);
|
||||||
|
|
||||||
// Returns a special nsIntRect that's used in some places to signify
|
// Returns a special nsIntRect that's used in some places to signify
|
||||||
// "all available space".
|
// "all available space".
|
||||||
|
|
|
@ -1316,6 +1316,22 @@ nsRegion& nsRegion::ExtendForScaling (float aXMult, float aYMult)
|
||||||
*this = region;
|
*this = region;
|
||||||
return *this;
|
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
|
nsRegion nsRegion::ConvertAppUnitsRoundOut (PRInt32 aFromAPP, PRInt32 aToAPP) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -184,6 +184,7 @@ public:
|
||||||
// the region.
|
// the region.
|
||||||
nsRegion ConvertAppUnitsRoundOut (PRInt32 aFromAPP, PRInt32 aToAPP) const;
|
nsRegion ConvertAppUnitsRoundOut (PRInt32 aFromAPP, PRInt32 aToAPP) const;
|
||||||
nsRegion ConvertAppUnitsRoundIn (PRInt32 aFromAPP, PRInt32 aToAPP) const;
|
nsRegion ConvertAppUnitsRoundIn (PRInt32 aFromAPP, PRInt32 aToAPP) const;
|
||||||
|
nsRegion& ScaleRoundOut(float aXScale, float aYScale);
|
||||||
nsIntRegion ToOutsidePixels (nscoord aAppUnitsPerPixel) const;
|
nsIntRegion ToOutsidePixels (nscoord aAppUnitsPerPixel) const;
|
||||||
nsRegion& ExtendForScaling (float aXMult, float aYMult);
|
nsRegion& ExtendForScaling (float aXMult, float aYMult);
|
||||||
|
|
||||||
|
@ -438,6 +439,12 @@ public:
|
||||||
{
|
{
|
||||||
return FromRect (mImpl.GetLargestRectangle( ToRect(aContainingRect) ));
|
return FromRect (mImpl.GetLargestRectangle( ToRect(aContainingRect) ));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsIntRegion& ScaleRoundOut (float aXScale, float aYScale)
|
||||||
|
{
|
||||||
|
mImpl.ScaleRoundOut(aXScale, aYScale);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
nsIntRegion& ExtendForScaling (float aXMult, float aYMult)
|
nsIntRegion& ExtendForScaling (float aXMult, float aYMult)
|
||||||
{
|
{
|
||||||
|
|
Загрузка…
Ссылка в новой задаче