mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 344206. Fix unit coversion Ceil/Floor functions to use floor() and ceil() because the current scheme is nonsense. r=vlad
This commit is contained in:
parent
0a6715fc94
commit
b3e499d2c6
@ -145,7 +145,7 @@ void nsTransform2D :: TransformNoXLateCoord(nscoord *ptX, nscoord *ptY) const
|
||||
|
||||
inline PRIntn NSToIntNFloor(float aValue)
|
||||
{
|
||||
return ((0.0f <= aValue) ? PRIntn(aValue) : PRIntn(aValue - CEIL_CONST_FLOAT));
|
||||
return PRIntn(floor(aValue));
|
||||
}
|
||||
|
||||
void nsTransform2D :: ScaleXCoords(const nscoord* aSrc,
|
||||
|
@ -42,42 +42,28 @@
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
|
||||
#ifndef FLT_EPSILON
|
||||
// Not an ANSI compiler... oh, well. Use an IEEE value.
|
||||
#define FLT_EPSILON 1.19209290e-7f
|
||||
#endif
|
||||
/// handy constants
|
||||
#define TWIPS_PER_POINT_INT 20
|
||||
#define TWIPS_PER_POINT_FLOAT 20.0f
|
||||
#define ROUND_CONST_FLOAT 0.5f
|
||||
#define CEIL_CONST_FLOAT (1.0f - 0.5f*FLT_EPSILON)
|
||||
|
||||
|
||||
/*
|
||||
* Coord Rounding Functions
|
||||
*/
|
||||
inline nscoord NSToCoordFloor(float aValue)
|
||||
{
|
||||
#ifdef NS_COORD_IS_FLOAT
|
||||
return floorf(aValue);
|
||||
#else
|
||||
return ((0.0f <= aValue) ? nscoord(aValue) : nscoord(aValue - CEIL_CONST_FLOAT));
|
||||
#endif
|
||||
return nscoord(floor(aValue));
|
||||
}
|
||||
|
||||
inline nscoord NSToCoordCeil(float aValue)
|
||||
{
|
||||
#ifdef NS_COORD_IS_FLOAT
|
||||
return ceilf(aValue);
|
||||
#else
|
||||
return ((0.0f <= aValue) ? nscoord(aValue + CEIL_CONST_FLOAT) : nscoord(aValue));
|
||||
#endif
|
||||
return nscoord(ceil(aValue));
|
||||
}
|
||||
|
||||
inline nscoord NSToCoordRound(float aValue)
|
||||
{
|
||||
#ifdef NS_COORD_IS_FLOAT
|
||||
return floorf(aValue + ROUND_CONST_FLOAT);
|
||||
return float(floor(aValue + ROUND_CONST_FLOAT));
|
||||
#else
|
||||
return ((0.0f <= aValue) ? nscoord(aValue + ROUND_CONST_FLOAT) : nscoord(aValue - ROUND_CONST_FLOAT));
|
||||
#endif
|
||||
@ -88,12 +74,12 @@ inline nscoord NSToCoordRound(float aValue)
|
||||
*/
|
||||
inline PRInt32 NSToIntFloor(float aValue)
|
||||
{
|
||||
return ((0.0f <= aValue) ? PRInt32(aValue) : PRInt32(aValue - CEIL_CONST_FLOAT));
|
||||
return PRInt32(floor(aValue));
|
||||
}
|
||||
|
||||
inline PRInt32 NSToIntCeil(float aValue)
|
||||
{
|
||||
return ((0.0f <= aValue) ? PRInt32(aValue + CEIL_CONST_FLOAT) : PRInt32(aValue));
|
||||
return PRInt32(ceil(aValue));
|
||||
}
|
||||
|
||||
inline PRInt32 NSToIntRound(float aValue)
|
||||
|
Loading…
Reference in New Issue
Block a user