Bug 1377090 - Move NudgeToInteger(double) into Tools.h for reuse. r?Bas
MozReview-Commit-ID: HJ5rmUfKOaG
--- a/gfx/2d/Tools.h
+++ b/gfx/2d/Tools.h
@@ -66,16 +66,24 @@ static inline void
NudgeToInteger(float *aVal, float aErr)
{
float r = floorf(*aVal + 0.5f);
if (FuzzyEqual(r, *aVal, aErr)) {
*aVal = r;
}
}
+static inline void
+NudgeToInteger(double *aVal)
+{
+ float f = float(*aVal);
+ NudgeToInteger(&f);
+ *aVal = f;
+}
+
static inline Float
Distance(Point aA, Point aB)
{
return hypotf(aB.x - aA.x, aB.y - aA.y);
}
static inline int
BytesPerPixel(SurfaceFormat aFormat)
--- a/gfx/thebes/gfxMatrix.cpp
+++ b/gfx/thebes/gfxMatrix.cpp
@@ -135,33 +135,25 @@ gfxMatrix::TransformBounds(const gfxRect
min_y = quad_y[i];
if (quad_y[i] > max_y)
max_y = quad_y[i];
}
return gfxRect(min_x, min_y, max_x - min_x, max_y - min_y);
}
-
-static void NudgeToInteger(double *aVal)
-{
- float f = float(*aVal);
- mozilla::gfx::NudgeToInteger(&f);
- *aVal = f;
-}
-
gfxMatrix&
gfxMatrix::NudgeToIntegers(void)
{
- NudgeToInteger(&_11);
- NudgeToInteger(&_21);
- NudgeToInteger(&_12);
- NudgeToInteger(&_22);
- NudgeToInteger(&_31);
- NudgeToInteger(&_32);
+ mozilla::gfx::NudgeToInteger(&_11);
+ mozilla::gfx::NudgeToInteger(&_21);
+ mozilla::gfx::NudgeToInteger(&_12);
+ mozilla::gfx::NudgeToInteger(&_22);
+ mozilla::gfx::NudgeToInteger(&_31);
+ mozilla::gfx::NudgeToInteger(&_32);
return *this;
}
mozilla::gfx::Matrix4x4
gfxMatrix::operator *(const mozilla::gfx::Matrix4x4& aMatrix) const
{
Matrix4x4 resultMatrix;