Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Unified Diff: include/core/SkFixed.h

Issue 113873008: remove unused SkFixed and SkFract functions (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: include/core/SkFixed.h
diff --git a/include/core/SkFixed.h b/include/core/SkFixed.h
index ea5e44c39388f1b6b29f972080a9424a253d8a2d..580d94b9ca2f813fa3bde204db59e20dbf273cea 100644
--- a/include/core/SkFixed.h
+++ b/include/core/SkFixed.h
@@ -55,16 +55,6 @@ typedef int32_t SkFixed;
#define SkFixedToDouble(x) ((x) * 1.5258789e-5)
#define SkDoubleToFixed(x) ((SkFixed)((x) * SK_Fixed1))
-/** 32 bit signed integer used to represent fractions values with 30 bits to the right of the decimal point
-*/
-typedef int32_t SkFract;
-#define SK_Fract1 (1 << 30)
-#define Sk_FracHalf (1 << 29)
-#define SK_FractPIOver180 (0x11DF46A)
-
-#define SkFractToFloat(x) ((float)(x) * 0.00000000093132257f)
-#define SkFloatToFract(x) ((SkFract)((x) * SK_Fract1))
-
/** Converts an integer to a SkFixed, asserting that the result does not overflow
a 32 bit signed integer
*/
@@ -79,31 +69,6 @@ typedef int32_t SkFract;
#define SkIntToFixed(n) (SkFixed)((n) << 16)
#endif
-/** Converts a SkFixed to a SkFract, asserting that the result does not overflow
- a 32 bit signed integer
-*/
-#ifdef SK_DEBUG
- inline SkFract SkFixedToFract(SkFixed x)
- {
- SkASSERT(x >= (-2 << 16) && x <= (2 << 16) - 1);
- return x << 14;
- }
-#else
- #define SkFixedToFract(x) ((x) << 14)
-#endif
-
-/** Returns the signed fraction of a SkFixed
-*/
-inline SkFixed SkFixedFraction(SkFixed x)
-{
- SkFixed mask = x >> 31 << 16;
- return (x & 0xFFFF) | mask;
-}
-
-/** Converts a SkFract to a SkFixed
-*/
-#define SkFractToFixed(x) ((x) >> 14)
-
#define SkFixedRoundToInt(x) (((x) + SK_FixedHalf) >> 16)
#define SkFixedCeilToInt(x) (((x) + SK_Fixed1 - 1) >> 16)
#define SkFixedFloorToInt(x) ((x) >> 16)
@@ -121,7 +86,6 @@ inline SkFixed SkFixedFraction(SkFixed 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);
@@ -135,39 +99,18 @@ inline SkFixed SkFixedSquare_portable(SkFixed value)
}
#define SkFixedDiv(numer, denom) SkDivBits(numer, denom, 16)
-SkFixed SkFixedDivInt(int32_t numer, int32_t denom);
-SkFixed SkFixedMod(SkFixed numer, SkFixed denom);
-#define SkFixedInvert(n) SkDivBits(SK_Fixed1, n, 16)
-SkFixed SkFixedFastInvert(SkFixed n);
-#define SkFixedSqrt(n) SkSqrtBits(n, 23)
-SkFixed SkFixedMean(SkFixed a, SkFixed b); //*< returns sqrt(x*y)
-int SkFixedMulCommon(SkFixed, int , int bias); // internal used by SkFixedMulFloor, SkFixedMulCeil, SkFixedMulRound
-#define SkFractDiv(numer, denom) SkDivBits(numer, denom, 30)
-#define SkFractSqrt(n) SkSqrtBits(n, 30)
+///////////////////////////////////////////////////////////////////////////////
+// TODO: move fixed sin/cos into SkCosineMapper, as that is the only caller
+// or rewrite SkCosineMapper to not use it at all
SkFixed SkFixedSinCos(SkFixed radians, SkFixed* cosValueOrNull);
#define SkFixedSin(radians) SkFixedSinCos(radians, NULL)
-inline SkFixed SkFixedCos(SkFixed radians)
-{
+static inline SkFixed SkFixedCos(SkFixed radians) {
SkFixed cosValue;
(void)SkFixedSinCos(radians, &cosValue);
return cosValue;
}
-SkFixed SkFixedTan(SkFixed radians);
-SkFixed SkFixedASin(SkFixed);
-SkFixed SkFixedACos(SkFixed);
-SkFixed SkFixedATan2(SkFixed y, SkFixed x);
-SkFixed SkFixedExp(SkFixed);
-SkFixed SkFixedLog(SkFixed);
-
-#define SK_FixedNearlyZero (SK_Fixed1 >> 12)
-
-inline bool SkFixedNearlyZero(SkFixed x, SkFixed tolerance = SK_FixedNearlyZero)
-{
- SkASSERT(tolerance > 0);
- return SkAbs32(x) < tolerance;
-}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Now look for ASM overrides for our portable versions (should consider putting this in its own file)
@@ -177,16 +120,11 @@ inline bool SkFixedNearlyZero(SkFixed x, SkFixed tolerance = SK_FixedNearlyZero)
{
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
@@ -223,54 +161,16 @@ inline bool SkFixedNearlyZero(SkFixed x, SkFixed tolerance = SK_FixedNearlyZero)
);
return x;
}
- inline SkFixed SkFixedMulAdd_arm(SkFixed x, SkFixed y, SkFixed a)
- {
- int32_t t;
- asm("smull %0, %3, %1, %4 \n"
- "add %0, %2, %0, lsr #16 \n"
- "add %0, %0, %3, lsl #16 \n"
- : "=r"(x), "=&r"(y), "=&r"(a), "=r"(t)
- : "%r"(x), "1"(y), "2"(a)
- :
- );
- return x;
- }
- inline SkFixed SkFractMul_arm(SkFixed x, SkFixed y)
- {
- int32_t t;
- asm("smull %0, %2, %1, %3 \n"
- "mov %0, %0, lsr #30 \n"
- "orr %0, %0, %2, lsl #2 \n"
- : "=r"(x), "=&r"(y), "=r"(t)
- : "r"(x), "1"(y)
- :
- );
- return x;
- }
#undef SkFixedMul
- #undef SkFractMul
#define SkFixedMul(x, y) SkFixedMul_arm(x, y)
- #define SkFractMul(x, y) SkFractMul_arm(x, y)
- #define SkFixedMulAdd(x, y, a) SkFixedMulAdd_arm(x, y, a)
#undef SkFloatToFixed
#define SkFloatToFixed(x) SkFloatToFixed_arm(x)
#endif
-/////////////////////// Now define our macros to the portable versions if they weren't overridden
-
-#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
///////////////////////////////////////////////////////////////////////////////

Powered by Google App Engine
This is Rietveld 408576698