Bug 339548. Part 8: Create nsPoint::ToNearestPixels. r=dbaron

This commit is contained in:
Robert O'Callahan 2009-07-22 12:44:58 +12:00
parent 12c9748167
commit 94c4cbe089

View File

@ -40,6 +40,8 @@
#include "nsCoord.h"
struct nsIntPoint;
struct nsPoint {
nscoord x, y;
@ -79,6 +81,8 @@ struct nsPoint {
nsPoint operator-() const {
return nsPoint(-x, -y);
}
inline nsIntPoint ToNearestPixels(nscoord aAppUnitsPerPixel) const;
};
struct nsIntPoint {
@ -117,4 +121,11 @@ struct nsIntPoint {
void MoveTo(PRInt32 aX, PRInt32 aY) {x = aX; y = aY;}
};
inline nsIntPoint
nsPoint::ToNearestPixels(nscoord aAppUnitsPerPixel) const {
return nsIntPoint(
NSToIntRound(NSAppUnitsToFloatPixels(x, float(aAppUnitsPerPixel))),
NSToIntRound(NSAppUnitsToFloatPixels(y, float(aAppUnitsPerPixel))));
}
#endif /* NSPOINT_H */