diff options
author | 2013-08-14 11:43:52 +0000 | |
---|---|---|
committer | 2013-08-14 11:43:52 +0000 | |
commit | 73ab2965363713f9a0ccec3666724a60329e6ea3 (patch) | |
tree | 962e9fa0a9884c00ec2b858026c1b9c4ac9e4905 /include/core/SkFixed.h | |
parent | 2dc8b96230c99cd460c02fdb69b036905d072216 (diff) |
ARM Skia NEON patches - 04 - Clean SkFixed / SkLONGLONG
It removes SkLONGLONG and uses int64_t to implement the SkFixed
operations for which a SkLONGLONG version existed. It also
removes the 32 bit version that are being replaced.
BUG=
R=djsollen@google.com, reed@google.com
Author: kevin.petit.arm@gmail.com
Review URL: https://chromiumcodereview.appspot.com/18539004
git-svn-id: http://skia.googlecode.com/svn/trunk@10705 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core/SkFixed.h')
-rw-r--r-- | include/core/SkFixed.h | 57 |
1 files changed, 19 insertions, 38 deletions
diff --git a/include/core/SkFixed.h b/include/core/SkFixed.h index acfbe9af95..a4a515d30a 100644 --- a/include/core/SkFixed.h +++ b/include/core/SkFixed.h @@ -120,20 +120,6 @@ inline SkFixed SkFixedFraction(SkFixed x) #define SkFixedAbs(x) SkAbs32(x) #define SkFixedAve(a, b) (((a) + (b)) >> 1) -SkFixed SkFixedMul_portable(SkFixed, SkFixed); -SkFract SkFractMul_portable(SkFract, SkFract); -inline SkFixed SkFixedSquare_portable(SkFixed value) -{ - uint32_t a = SkAbs32(value); - uint32_t ah = a >> 16; - uint32_t al = a & 0xFFFF; - SkFixed result = ah * a + al * ah + (al * al >> 16); - if (result >= 0) - return result; - else // Overflow. - return SK_FixedMax; -} - #define SkFixedDiv(numer, denom) SkDivBits(numer, denom, 16) SkFixed SkFixedDivInt(int32_t numer, int32_t denom); SkFixed SkFixedMod(SkFixed numer, SkFixed denom); @@ -169,27 +155,28 @@ inline bool SkFixedNearlyZero(SkFixed x, SkFixed tolerance = SK_FixedNearlyZero) return SkAbs32(x) < tolerance; } +inline SkFixed SkFixedMul_longlong(SkFixed a, SkFixed b) +{ + return (SkFixed)((int64_t)a * b >> 16); +} + +inline SkFract SkFractMul_longlong(SkFract a, SkFract b) +{ + return (SkFract)((int64_t)a * b >> 30); +} + +inline SkFixed SkFixedSquare_longlong(SkFixed value) +{ + return (SkFixed)((int64_t)value * value >> 16); +} + +#define SkFixedMul(a,b) SkFixedMul_longlong(a,b) +#define SkFractMul(a,b) SkFractMul_longlong(a,b) +#define SkFixedSquare(a) SkFixedSquare_longlong(a) + ////////////////////////////////////////////////////////////////////////////////////////////////////// // Now look for ASM overrides for our portable versions (should consider putting this in its own file) -#ifdef SkLONGLONG - inline SkFixed SkFixedMul_longlong(SkFixed a, SkFixed b) - { - return (SkFixed)((SkLONGLONG)a * b >> 16); - } - inline SkFract SkFractMul_longlong(SkFract a, SkFract b) - { - return (SkFract)((SkLONGLONG)a * b >> 30); - } - inline SkFixed SkFixedSquare_longlong(SkFixed value) - { - return (SkFixed)((SkLONGLONG)value * value >> 16); - } - #define SkFixedMul(a,b) SkFixedMul_longlong(a,b) - #define SkFractMul(a,b) SkFractMul_longlong(a,b) - #define SkFixedSquare(a) SkFixedSquare_longlong(a) -#endif - #if defined(SK_CPU_ARM) /* This guy does not handle NaN or other obscurities, but is faster than than (int)(x*65536) @@ -262,12 +249,6 @@ inline bool SkFixedNearlyZero(SkFixed x, SkFixed tolerance = SK_FixedNearlyZero) #ifndef SkFixedSquare #define SkFixedSquare(x) SkFixedSquare_portable(x) #endif -#ifndef SkFixedMul - #define SkFixedMul(x, y) SkFixedMul_portable(x, y) -#endif -#ifndef SkFractMul - #define SkFractMul(x, y) SkFractMul_portable(x, y) -#endif #ifndef SkFixedMulAdd #define SkFixedMulAdd(x, y, a) (SkFixedMul(x, y) + (a)) #endif |