Don't convert to floating point and back when we don't need to. b=326040 r+sr=roc

This commit is contained in:
dbaron%dbaron.org 2006-02-07 06:05:00 +00:00
Родитель 0feb30852f
Коммит 391b30756c
1 изменённых файлов: 26 добавлений и 4 удалений

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

@ -2805,6 +2805,28 @@ nsCSSRendering::PaintBackground(nsPresContext* aPresContext,
aBorder, aPadding, aUsePrintSettings, aBGClipRect);
}
inline nscoord IntDivFloor(nscoord aDividend, nscoord aDivisor)
{
NS_PRECONDITION(aDivisor > 0,
"this function only works for positive divisors");
// ANSI C, ISO 9899:1999 section 6.5.5 defines integer division as
// truncation of the result towards zero. Earlier C standards, as
// well as the C++ standards (1998 and 2003) do not, but we depend
// on it elsewhere.
return (aDividend < 0 ? (aDividend - aDivisor + 1) : aDividend) / aDivisor;
}
inline nscoord IntDivCeil(nscoord aDividend, nscoord aDivisor)
{
NS_PRECONDITION(aDivisor > 0,
"this function only works for positive divisors");
// ANSI C, ISO 9899:1999 section 6.5.5 defines integer division as
// truncation of the result towards zero. Earlier C standards, as
// well as the C++ standards (1998 and 2003) do not, but we depend
// on it elsewhere.
return (aDividend > 0 ? (aDividend + aDivisor - 1) : aDividend) / aDivisor;
}
/**
* Return the largest 'v' such that v = aTileOffset + N*aTileSize, for some
* integer N, and v <= aDirtyStart.
@ -2813,8 +2835,8 @@ static nscoord
FindTileStart(nscoord aDirtyStart, nscoord aTileOffset, nscoord aTileSize)
{
// Find largest integer N such that aTileOffset + N*aTileSize <= aDirtyStart
PRInt32 n = NSToIntFloor((aDirtyStart*1.0f - aTileOffset)/aTileSize);
return aTileOffset + n*aTileSize;
return aTileOffset +
IntDivFloor(aDirtyStart - aTileOffset, aTileSize) * aTileSize;
}
/**
@ -2825,8 +2847,8 @@ static nscoord
FindTileEnd(nscoord aDirtyEnd, nscoord aTileOffset, nscoord aTileSize)
{
// Find smallest integer N such that aTileOffset + N*aTileSize >= aDirtyEnd
PRInt32 n = NSToIntCeil((aDirtyEnd*1.0f - aTileOffset)/aTileSize);
return aTileOffset + n*aTileSize;
return aTileOffset +
IntDivCeil(aDirtyEnd - aTileOffset, aTileSize) * aTileSize;
}
void