diff options
author | reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2009-09-18 13:38:43 +0000 |
---|---|---|
committer | reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2009-09-18 13:38:43 +0000 |
commit | ab7ac026d25fcb6e10c042e933f03e5f806c9097 (patch) | |
tree | 3db169b18364ba75b376ab261e5c6ff9051a5952 /src | |
parent | 0b9e2dbf2f51ac41439db2052cf80704d60932f4 (diff) |
more float/double precision tweaks
git-svn-id: http://skia.googlecode.com/svn/trunk@355 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkMatrix.cpp | 43 |
1 files changed, 5 insertions, 38 deletions
diff --git a/src/core/SkMatrix.cpp b/src/core/SkMatrix.cpp index 65e09bf8a1..f7d6ca030b 100644 --- a/src/core/SkMatrix.cpp +++ b/src/core/SkMatrix.cpp @@ -23,6 +23,10 @@ #ifdef SK_SCALAR_IS_FLOAT #define kMatrix22Elem SK_Scalar1 + + static inline float SkDoubleToFloat(double x) { + return static_cast<float>(x); + } #else #define kMatrix22Elem SK_Fract1 #endif @@ -455,13 +459,7 @@ bool SkMatrix::setRectToRect(const SkRect& src, const SkRect& dst, #ifdef SK_SCALAR_IS_FLOAT static inline int fixmuladdmul(float a, float b, float c, float d, float* result) { - *result = a * b + c * d; - return true; - } - - static inline int fixmuladdmulshiftmul(float a, float b, float c, float d, - int /*shift not used*/, float scale, float* result) { - *result = (a * b + c * d) * scale; + *result = SkDoubleToFloat((double)a * b + (double)c * d); return true; } @@ -489,34 +487,6 @@ bool SkMatrix::setRectToRect(const SkRect& src, const SkRect& dst, return false; } - static inline bool fixmuladdmulshiftmul(SkFixed a, SkFixed b, SkFixed c, - SkFixed d, int shift, SkFixed scale, SkFixed* result) { - Sk64 tmp1, tmp2; - tmp1.setMul(a, b); - tmp2.setMul(c, d); - tmp1.add(tmp2); - - int32_t hi = SkAbs32(tmp1.fHi); - int afterShift = 16; - if (hi >> 15) { - int clz = 17 - SkCLZ(hi); - SkASSERT(clz > 0 && clz <= 16); - afterShift -= clz; - shift += clz; - } - - tmp1.roundRight(shift + 16); - SkASSERT(tmp1.is32()); - - tmp1.setMul(tmp1.get32(), scale); - tmp1.roundRight(afterShift); - if (tmp1.is32()) { - *result = tmp1.get32(); - return true; - } - return false; - } - static inline SkFixed fracmuladdmul(SkFixed a, SkFract b, SkFixed c, SkFract d) { Sk64 tmp1, tmp2; @@ -690,9 +660,6 @@ bool SkMatrix::postConcat(const SkMatrix& mat) { } return 1.0 / det; } - static inline float SkDoubleToFloat(double x) { - return static_cast<float>(x); - } // we declar a,b,c,d to all be doubles, because we want to perform // double-precision muls and subtract, even though the original values are // from the matrix, which are floats. |