aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/core/SkFixed.h22
-rw-r--r--include/core/SkScalar.h36
2 files changed, 38 insertions, 20 deletions
diff --git a/include/core/SkFixed.h b/include/core/SkFixed.h
index 649ee23cb0..625074fe65 100644
--- a/include/core/SkFixed.h
+++ b/include/core/SkFixed.h
@@ -96,17 +96,23 @@ inline SkFixed SkFixedFraction(SkFixed x)
/** Converts a SkFract to a SkFixed
*/
#define SkFractToFixed(x) ((x) >> 14)
-/** Round a SkFixed to an integer
-*/
-#define SkFixedRound(x) (((x) + SK_FixedHalf) >> 16)
-#define SkFixedCeil(x) (((x) + SK_Fixed1 - 1) >> 16)
-#define SkFixedFloor(x) ((x) >> 16)
+
+#define SkFixedRoundToInt(x) (((x) + SK_FixedHalf) >> 16)
+#define SkFixedCeilToInt(x) (((x) + SK_Fixed1 - 1) >> 16)
+#define SkFixedFloorToInt(x) ((x) >> 16)
+
+#define SkFixedRoundToFixed(x) (((x) + SK_FixedHalf) & 0xFFFF0000)
+#define SkFixedCeilToFixed(x) (((x) + SK_Fixed1 - 1) & 0xFFFF0000)
+#define SkFixedFloorToFixed(x) ((x) & 0xFFFF0000)
+
+// DEPRECATED
+#define SkFixedFloor(x) SkFixedFloorToInt(x)
+#define SkFixedCeil(x) SkFixedCeilToInt(x)
+#define SkFixedRound(x) SkFixedRoundToInt(x)
+
#define SkFixedAbs(x) SkAbs32(x)
#define SkFixedAve(a, b) (((a) + (b)) >> 1)
-// The same as SkIntToFixed(SkFixedFloor(x))
-#define SkFixedFloorToFixed(x) ((x) & ~0xFFFF)
-
SkFixed SkFixedMul_portable(SkFixed, SkFixed);
SkFract SkFractMul_portable(SkFract, SkFract);
inline SkFixed SkFixedSquare_portable(SkFixed value)
diff --git a/include/core/SkScalar.h b/include/core/SkScalar.h
index 5a5bda715d..e4f82ea22c 100644
--- a/include/core/SkScalar.h
+++ b/include/core/SkScalar.h
@@ -116,15 +116,15 @@
/** SkScalarFraction(x) returns the signed fractional part of the argument
*/
#define SkScalarFraction(x) sk_float_mod(x, 1.0f)
- /** Rounds the SkScalar to the nearest integer value
- */
- #define SkScalarRound(x) sk_float_round2int(x)
- /** Returns the smallest integer that is >= the specified SkScalar
- */
- #define SkScalarCeil(x) sk_float_ceil2int(x)
- /** Returns the largest integer that is <= the specified SkScalar
- */
- #define SkScalarFloor(x) sk_float_floor2int(x)
+
+ #define SkScalarFloorToScalar(x) sk_float_floor(x)
+ #define SkScalarCeilToScalar(x) sk_float_ceil(x)
+ #define SkScalarRoundToScalar(x) sk_float_round(x)
+
+ #define SkScalarFloorToInt(x) sk_float_floor2int(x)
+ #define SkScalarCeilToInt(x) sk_float_ceil2int(x)
+ #define SkScalarRoundToInt(x) sk_float_round2int(x)
+
/** Returns the absolute value of the specified SkScalar
*/
#define SkScalarAbs(x) sk_float_abs(x)
@@ -230,9 +230,15 @@
#define SkDoubleToScalar(n) SkDoubleToFixed(n)
#endif
#define SkScalarFraction(x) SkFixedFraction(x)
- #define SkScalarRound(x) SkFixedRound(x)
- #define SkScalarCeil(x) SkFixedCeil(x)
- #define SkScalarFloor(x) SkFixedFloor(x)
+
+ #define SkScalarFloorToScalar(x) SkFixedFloorToFixed(x)
+ #define SkScalarCeilToScalar(x) SkFixedCeilToFixed(x)
+ #define SkScalarRoundToScalar(x) SkFixedRoundToFixed(x)
+
+ #define SkScalarFloorToInt(x) SkFixedFloorToInt(x)
+ #define SkScalarCeilToInt(x) SkFixedCeilToInt(x)
+ #define SkScalarRoundToInt(x) SkFixedRoundToInt(x)
+
#define SkScalarAbs(x) SkFixedAbs(x)
#define SkScalarCopySign(x, y) SkCopySign32(x, y)
#define SkScalarClampMax(x, max) SkClampMax(x, max)
@@ -277,6 +283,12 @@
}
#endif
+// DEPRECATED : use ToInt or ToScalar variant
+#define SkScalarFloor(x) SkScalarFloorToInt(x)
+#define SkScalarCeil(x) SkScalarCeilToInt(x)
+#define SkScalarRound(x) SkScalarRoundToInt(x)
+
+
#define SK_ScalarNearlyZero (SK_Scalar1 / (1 << 12))
/* <= is slower than < for floats, so we use < for our tolerance test