aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--bench/MorphologyBench.cpp4
-rw-r--r--bench/benchmain.cpp6
-rw-r--r--experimental/SkSetPoly3To3_A.cpp29
-rw-r--r--gm/blurs.cpp10
-rw-r--r--gyp/SampleApp.gyp1
-rw-r--r--include/config/SkUserConfig.h8
-rw-r--r--include/core/SkFixed.h6
-rw-r--r--include/core/SkFloatBits.h9
-rw-r--r--include/core/SkMatrix.h19
-rw-r--r--include/core/SkPostConfig.h6
-rw-r--r--include/core/SkPreConfig.h6
-rw-r--r--include/core/SkRect.h8
-rw-r--r--include/core/SkScalar.h386
-rw-r--r--include/core/SkString.h6
-rw-r--r--include/utils/SkCamera.h15
-rw-r--r--samplecode/SampleCircle.cpp2
-rw-r--r--samplecode/SampleOverflow.cpp108
-rw-r--r--src/animator/SkDisplayMath.cpp11
-rw-r--r--src/animator/SkDrawColor.cpp4
-rw-r--r--src/animator/SkDrawGradient.cpp8
-rw-r--r--src/animator/SkScript.cpp5
-rw-r--r--src/animator/SkScriptTokenizer.cpp5
-rw-r--r--src/core/SkCanvas.cpp18
-rw-r--r--src/core/SkCubicClipper.cpp8
-rw-r--r--src/core/SkEdge.cpp30
-rw-r--r--src/core/SkEdge.h8
-rw-r--r--src/core/SkFDot6.h9
-rw-r--r--src/core/SkFlattenableBuffers.cpp3
-rw-r--r--src/core/SkGeometry.cpp129
-rw-r--r--src/core/SkLineClipper.cpp14
-rw-r--r--src/core/SkMath.cpp10
-rw-r--r--src/core/SkMatrix.cpp209
-rw-r--r--src/core/SkPaint.cpp18
-rw-r--r--src/core/SkPathMeasure.cpp5
-rw-r--r--src/core/SkPicture.cpp4
-rw-r--r--src/core/SkRect.cpp30
-rw-r--r--src/core/SkScan.cpp8
-rw-r--r--src/core/SkScan.h22
-rw-r--r--src/core/SkScan_AntiPath.cpp7
-rw-r--r--src/core/SkScan_Antihair.cpp10
-rw-r--r--src/core/SkScan_Hairline.cpp2
-rw-r--r--src/core/SkStrokerPriv.cpp6
-rw-r--r--src/effects/SkArithmeticMode.cpp13
-rw-r--r--src/effects/gradients/SkSweepGradient.cpp227
-rw-r--r--src/gpu/GrAAHairLinePathRenderer.cpp9
-rw-r--r--src/gpu/GrPathUtils.cpp3
-rw-r--r--src/gpu/gl/GrGLPath.cpp3
-rw-r--r--src/gpu/gl/GrGLUniformManager.cpp1
-rw-r--r--src/pdf/SkPDFTypes.cpp10
-rw-r--r--src/ports/SkHarfBuzzFont.cpp5
-rw-r--r--src/utils/SkCamera.cpp48
-rw-r--r--src/utils/SkInterpolator.cpp4
-rw-r--r--src/utils/SkParse.cpp45
-rw-r--r--src/utils/SkParsePath.cpp5
-rw-r--r--src/xml/SkJSDisplayable.cpp8
-rw-r--r--src/xml/SkXMLWriter.cpp2
-rw-r--r--tests/DrawBitmapRectTest.cpp2
-rw-r--r--tests/DrawPathTest.cpp8
-rw-r--r--tests/InfRectTest.cpp7
-rw-r--r--tests/MathTest.cpp37
-rw-r--r--tests/Matrix44Test.cpp7
-rw-r--r--tests/MatrixTest.cpp27
-rw-r--r--tests/PDFPrimitivesTest.cpp2
-rw-r--r--tests/PathMeasureTest.cpp6
-rw-r--r--tests/PathTest.cpp2
-rw-r--r--tests/ScalarTest.cpp2
-rw-r--r--tests/StringTest.cpp2
-rw-r--r--tests/WritePixelsTest.cpp2
-rw-r--r--tests/skia_test.cpp5
69 files changed, 249 insertions, 1455 deletions
diff --git a/bench/MorphologyBench.cpp b/bench/MorphologyBench.cpp
index 63171c2c12..97f3b88284 100644
--- a/bench/MorphologyBench.cpp
+++ b/bench/MorphologyBench.cpp
@@ -84,9 +84,6 @@ private:
typedef SkBenchmark INHERITED;
};
-// Fixed point can be 100x slower than float on these tests, causing
-// bench to timeout.
-#ifndef SK_SCALAR_IS_FIXED
DEF_BENCH( return new MorphologyBench(SMALL, kErode_MT); )
DEF_BENCH( return new MorphologyBench(SMALL, kDilate_MT); )
@@ -97,4 +94,3 @@ DEF_BENCH( return new MorphologyBench(REAL, kErode_MT); )
DEF_BENCH( return new MorphologyBench(REAL, kDilate_MT); )
DEF_BENCH( return new MorphologyBench(0, kErode_MT); )
-#endif
diff --git a/bench/benchmain.cpp b/bench/benchmain.cpp
index 092a577c61..695ac7eba6 100644
--- a/bench/benchmain.cpp
+++ b/bench/benchmain.cpp
@@ -407,12 +407,6 @@ int tool_main(int argc, char** argv) {
writer.option("scale", SkStringPrintf("%d", FLAGS_scale).c_str());
writer.option("clip", SkStringPrintf("%d", FLAGS_clip).c_str());
-#if defined(SK_SCALAR_IS_FIXED)
- writer.option("scalar", "fixed");
-#else
- writer.option("scalar", "float");
-#endif
-
#if defined(SK_BUILD_FOR_WIN32)
writer.option("system", "WIN32");
#elif defined(SK_BUILD_FOR_MAC)
diff --git a/experimental/SkSetPoly3To3_A.cpp b/experimental/SkSetPoly3To3_A.cpp
index 9eb6b33c0d..18777a77b5 100644
--- a/experimental/SkSetPoly3To3_A.cpp
+++ b/experimental/SkSetPoly3To3_A.cpp
@@ -10,29 +10,14 @@
// FIXME: needs to be in a header
bool SkSetPoly3To3_A(SkMatrix* matrix, const SkPoint src[3], const SkPoint dst[3]);
-#ifdef SK_SCALAR_IS_FIXED
- typedef int64_t SkDScalar;
-
- static SkScalar SkDScalar_toScalar(SkDScalar value) {
- SkDScalar result = (value + (1 << 15)) >> 16;
- int top = result >> 31;
- SkASSERT(top == 0 || top == -1);
- return (SkScalar)result;
- }
- static SkScalar divide(SkDScalar numer, SkDScalar denom) {
- denom >>= 16;
- return numer / denom;
- }
-#else
- typedef double SkDScalar;
+typedef double SkDScalar;
- static SkScalar SkDScalar_toScalar(SkDScalar value) {
- return static_cast<float>(value);
- }
- static SkScalar divide(SkDScalar numer, SkDScalar denom) {
- return static_cast<float>(numer / denom);
- }
-#endif
+static SkScalar SkDScalar_toScalar(SkDScalar value) {
+ return static_cast<float>(value);
+}
+static SkScalar divide(SkDScalar numer, SkDScalar denom) {
+ return static_cast<float>(numer / denom);
+}
static SkDScalar SkDScalar_setMul(SkScalar a, SkScalar b) {
return (SkDScalar) ((SkDScalar) a * b);
diff --git a/gm/blurs.cpp b/gm/blurs.cpp
index f3808d27c9..c2a1c170c7 100644
--- a/gm/blurs.cpp
+++ b/gm/blurs.cpp
@@ -18,16 +18,6 @@ public:
}
protected:
-#ifdef SK_SCALAR_IS_FIXED
- virtual uint32_t onGetFlags() const SK_OVERRIDE {
- // SkCanvas::drawCircle, used by this test, performs a quick reject.
- // The large size given to the device used by SkGPipeCanvas means that
- // the device clip will not be set properly and circles will be
- // rejected when in FIXED.
- return this->INHERITED::onGetFlags() | GM::kSkipPipe_Flag;
- }
-#endif
-
virtual SkString onShortName() {
return SkString("blurs");
}
diff --git a/gyp/SampleApp.gyp b/gyp/SampleApp.gyp
index 16a5c303e5..b43d149236 100644
--- a/gyp/SampleApp.gyp
+++ b/gyp/SampleApp.gyp
@@ -90,7 +90,6 @@
'../samplecode/SampleMipMap.cpp',
'../samplecode/SampleMovie.cpp',
'../samplecode/SampleOvalTest.cpp',
- '../samplecode/SampleOverflow.cpp',
'../samplecode/SamplePatch.cpp',
'../samplecode/SamplePath.cpp',
'../samplecode/SamplePathClip.cpp',
diff --git a/include/config/SkUserConfig.h b/include/config/SkUserConfig.h
index 5cd381d74c..72994e4060 100644
--- a/include/config/SkUserConfig.h
+++ b/include/config/SkUserConfig.h
@@ -37,14 +37,6 @@
///////////////////////////////////////////////////////////////////////////////
-/* Scalars (the fractional value type in skia) can be implemented either as
- floats or 16.16 integers (fixed). Exactly one of these two symbols must be
- defined.
-*/
-//#define SK_SCALAR_IS_FLOAT
-//#define SK_SCALAR_IS_FIXED
-
-
/* Skia has lots of debug-only code. Often this is just null checks or other
parameter checking, but sometimes it can be quite intrusive (e.g. check that
each 32bit pixel is in premultiplied form). This code can be very useful
diff --git a/include/core/SkFixed.h b/include/core/SkFixed.h
index 95a32a43b1..ea5e44c393 100644
--- a/include/core/SkFixed.h
+++ b/include/core/SkFixed.h
@@ -282,10 +282,6 @@ typedef int64_t SkFixed48;
#define SkFixed48ToFixed(x) ((SkFixed)((x) >> 32))
#define SkFloatToFixed48(x) ((SkFixed48)((x) * (65536.0f * 65536.0f * 65536.0f)))
-#ifdef SK_SCALAR_IS_FLOAT
- #define SkScalarToFixed48(x) SkFloatToFixed48(x)
-#else
- #define SkScalarToFixed48(x) SkFixedToFixed48(x)
-#endif
+#define SkScalarToFixed48(x) SkFloatToFixed48(x)
#endif
diff --git a/include/core/SkFloatBits.h b/include/core/SkFloatBits.h
index a1196caca7..552e712f53 100644
--- a/include/core/SkFloatBits.h
+++ b/include/core/SkFloatBits.h
@@ -127,12 +127,7 @@ static inline int32_t SkFloatToIntCeil(float x) {
// Scalar wrappers for float-bit routines
-#ifdef SK_SCALAR_IS_FLOAT
- #define SkScalarAs2sCompliment(x) SkFloatAs2sCompliment(x)
- #define Sk2sComplimentAsScalar(x) Sk2sComplimentAsFloat(x)
-#else
- #define SkScalarAs2sCompliment(x) (x)
- #define Sk2sComplimentAsScalar(x) (x)
-#endif
+#define SkScalarAs2sCompliment(x) SkFloatAs2sCompliment(x)
+#define Sk2sComplimentAsScalar(x) Sk2sComplimentAsFloat(x)
#endif
diff --git a/include/core/SkMatrix.h b/include/core/SkMatrix.h
index d7726f6d4d..9bbbc1745b 100644
--- a/include/core/SkMatrix.h
+++ b/include/core/SkMatrix.h
@@ -14,15 +14,10 @@
class SkString;
-#ifdef SK_SCALAR_IS_FLOAT
- typedef SkScalar SkPersp;
- #define SkScalarToPersp(x) (x)
- #define SkPerspToScalar(x) (x)
-#else
- typedef SkFract SkPersp;
- #define SkScalarToPersp(x) SkFixedToFract(x)
- #define SkPerspToScalar(x) SkFractToFixed(x)
-#endif
+// TODO: can we remove these 3 (need to check chrome/android)
+typedef SkScalar SkPersp;
+#define SkScalarToPersp(x) (x)
+#define SkPerspToScalar(x) (x)
/** \class SkMatrix
@@ -543,13 +538,7 @@ public:
return 0 == memcmp(fMat, m.fMat, sizeof(fMat));
}
-#ifdef SK_SCALAR_IS_FIXED
- friend bool operator==(const SkMatrix& a, const SkMatrix& b) {
- return a.cheapEqualTo(b);
- }
-#else
friend bool operator==(const SkMatrix& a, const SkMatrix& b);
-#endif
friend bool operator!=(const SkMatrix& a, const SkMatrix& b) {
return !(a == b);
}
diff --git a/include/core/SkPostConfig.h b/include/core/SkPostConfig.h
index 395ece89f1..0d904ea51c 100644
--- a/include/core/SkPostConfig.h
+++ b/include/core/SkPostConfig.h
@@ -22,12 +22,6 @@
# error "can't have unittests without debug"
#endif
-#if defined(SK_SCALAR_IS_FIXED) && defined(SK_SCALAR_IS_FLOAT)
-# error "cannot define both SK_SCALAR_IS_FIXED and SK_SCALAR_IS_FLOAT"
-#elif !defined(SK_SCALAR_IS_FIXED) && !defined(SK_SCALAR_IS_FLOAT)
-# define SK_SCALAR_IS_FLOAT
-#endif
-
/**
* Matrix calculations may be float or double.
* The default is double, as that is faster given our impl uses doubles
diff --git a/include/core/SkPreConfig.h b/include/core/SkPreConfig.h
index ab995d7aa8..2aa4d822e0 100644
--- a/include/core/SkPreConfig.h
+++ b/include/core/SkPreConfig.h
@@ -91,12 +91,6 @@
//////////////////////////////////////////////////////////////////////
-#if !defined(SK_SCALAR_IS_FLOAT) && !defined(SK_SCALAR_IS_FIXED)
- #define SK_SCALAR_IS_FLOAT
-#endif
-
-//////////////////////////////////////////////////////////////////////
-
#if !defined(SK_CPU_BENDIAN) && !defined(SK_CPU_LENDIAN)
#if defined (__ppc__) || defined(__PPC__) || defined(__ppc64__) \
|| defined(__PPC64__)
diff --git a/include/core/SkRect.h b/include/core/SkRect.h
index 8bfa57a8f9..0a5439cdfc 100644
--- a/include/core/SkRect.h
+++ b/include/core/SkRect.h
@@ -436,7 +436,6 @@ struct SK_API SkRect {
* returns false.
*/
bool isFinite() const {
-#ifdef SK_SCALAR_IS_FLOAT
float accum = 0;
accum *= fLeft;
accum *= fTop;
@@ -449,13 +448,6 @@ struct SK_API SkRect {
// value==value will be true iff value is not NaN
// TODO: is it faster to say !accum or accum==accum?
return accum == accum;
-#else
- // use bit-or for speed, since we don't care about short-circuting the
- // tests, and we expect the common case will be that we need to check all.
- int isNaN = (SK_FixedNaN == fLeft) | (SK_FixedNaN == fTop) |
- (SK_FixedNaN == fRight) | (SK_FixedNaN == fBottom);
- return !isNaN;
-#endif
}
SkScalar x() const { return fLeft; }
diff --git a/include/core/SkScalar.h b/include/core/SkScalar.h
index cc1cf99ac8..23e28cdc14 100644
--- a/include/core/SkScalar.h
+++ b/include/core/SkScalar.h
@@ -1,4 +1,3 @@
-
/*
* Copyright 2006 The Android Open Source Project
*
@@ -6,260 +5,167 @@
* found in the LICENSE file.
*/
-
#ifndef SkScalar_DEFINED
#define SkScalar_DEFINED
#include "SkFixed.h"
#include "SkFloatingPoint.h"
-/** \file SkScalar.h
+typedef float SkScalar;
- Types and macros for the data type SkScalar. This is the fractional numeric type
- that, depending on the compile-time flag SK_SCALAR_IS_FLOAT, may be implemented
- either as an IEEE float, or as a 16.16 SkFixed. The macros in this file are written
- to allow the calling code to manipulate SkScalar values without knowing which representation
- is in effect.
+/** SK_Scalar1 is defined to be 1.0 represented as an SkScalar
*/
+#define SK_Scalar1 (1.0f)
+/** SK_Scalar1 is defined to be 1/2 represented as an SkScalar
+*/
+#define SK_ScalarHalf (0.5f)
+/** SK_ScalarInfinity is defined to be infinity as an SkScalar
+*/
+#define SK_ScalarInfinity SK_FloatInfinity
+/** SK_ScalarNegativeInfinity is defined to be negative infinity as an SkScalar
+*/
+#define SK_ScalarNegativeInfinity SK_FloatNegativeInfinity
+/** SK_ScalarMax is defined to be the largest value representable as an SkScalar
+*/
+#define SK_ScalarMax (3.402823466e+38f)
+/** SK_ScalarMin is defined to be the smallest value representable as an SkScalar
+*/
+#define SK_ScalarMin (-SK_ScalarMax)
+/** SK_ScalarNaN is defined to be 'Not a Number' as an SkScalar
+*/
+#define SK_ScalarNaN SK_FloatNaN
+/** SkScalarIsNaN(n) returns true if argument is not a number
+*/
+static inline bool SkScalarIsNaN(float x) { return x != x; }
+
+/** Returns true if x is not NaN and not infinite */
+static inline bool SkScalarIsFinite(float x) {
+ // We rely on the following behavior of infinities and nans
+ // 0 * finite --> 0
+ // 0 * infinity --> NaN
+ // 0 * NaN --> NaN
+ float prod = x * 0;
+ // At this point, prod will either be NaN or 0
+ // Therefore we can return (prod == prod) or (0 == prod).
+ return prod == prod;
+}
-#ifdef SK_SCALAR_IS_FLOAT
-
- /** SkScalar is our type for fractional values and coordinates. Depending on
- compile configurations, it is either represented as an IEEE float, or
- as a 16.16 fixed point integer.
- */
- typedef float SkScalar;
-
- /** SK_Scalar1 is defined to be 1.0 represented as an SkScalar
- */
- #define SK_Scalar1 (1.0f)
- /** SK_Scalar1 is defined to be 1/2 represented as an SkScalar
- */
- #define SK_ScalarHalf (0.5f)
- /** SK_ScalarInfinity is defined to be infinity as an SkScalar
- */
- #define SK_ScalarInfinity SK_FloatInfinity
- /** SK_ScalarNegativeInfinity is defined to be negative infinity as an SkScalar
- */
- #define SK_ScalarNegativeInfinity SK_FloatNegativeInfinity
- /** SK_ScalarMax is defined to be the largest value representable as an SkScalar
- */
- #define SK_ScalarMax (3.402823466e+38f)
- /** SK_ScalarMin is defined to be the smallest value representable as an SkScalar
- */
- #define SK_ScalarMin (-SK_ScalarMax)
- /** SK_ScalarNaN is defined to be 'Not a Number' as an SkScalar
- */
- #define SK_ScalarNaN SK_FloatNaN
- /** SkScalarIsNaN(n) returns true if argument is not a number
- */
- static inline bool SkScalarIsNaN(float x) { return x != x; }
-
- /** Returns true if x is not NaN and not infinite */
- static inline bool SkScalarIsFinite(float x) {
- // We rely on the following behavior of infinities and nans
- // 0 * finite --> 0
- // 0 * infinity --> NaN
- // 0 * NaN --> NaN
- float prod = x * 0;
- // At this point, prod will either be NaN or 0
- // Therefore we can return (prod == prod) or (0 == prod).
- return prod == prod;
- }
-
- /** SkIntToScalar(n) returns its integer argument as an SkScalar
- */
- #define SkIntToScalar(n) ((float)(n))
- /** SkFixedToScalar(n) returns its SkFixed argument as an SkScalar
- */
- #define SkFixedToScalar(x) SkFixedToFloat(x)
- /** SkScalarToFixed(n) returns its SkScalar argument as an SkFixed
- */
- #define SkScalarToFixed(x) SkFloatToFixed(x)
-
- #define SkScalarToFloat(n) (n)
-#ifndef SK_SCALAR_TO_FLOAT_EXCLUDED
- #define SkFloatToScalar(n) (n)
-#endif
-
- #define SkScalarToDouble(n) (double)(n)
- #define SkDoubleToScalar(n) (float)(n)
-
- /** SkScalarFraction(x) returns the signed fractional part of the argument
- */
- #define SkScalarFraction(x) sk_float_mod(x, 1.0f)
-
- #define SkScalarFloorToScalar(x) sk_float_floor(x)
- #define SkScalarCeilToScalar(x) sk_float_ceil(x)
- #define SkScalarRoundToScalar(x) sk_float_floor((x) + 0.5f)
-
- #define SkScalarFloorToInt(x) sk_float_floor2int(x)
- #define SkScalarCeilToInt(x) sk_float_ceil2int(x)
- #define SkScalarRoundToInt(x) sk_float_round2int(x)
- #define SkScalarTruncToInt(x) static_cast<int>(x)
-
- /** Returns the absolute value of the specified SkScalar
- */
- #define SkScalarAbs(x) sk_float_abs(x)
- /** Return x with the sign of y
- */
- #define SkScalarCopySign(x, y) sk_float_copysign(x, y)
- /** Returns the value pinned between 0 and max inclusive
- */
- inline SkScalar SkScalarClampMax(SkScalar x, SkScalar max) {
- return x < 0 ? 0 : x > max ? max : x;
- }
- /** Returns the value pinned between min and max inclusive
- */
- inline SkScalar SkScalarPin(SkScalar x, SkScalar min, SkScalar max) {
- return x < min ? min : x > max ? max : x;
- }
- /** Returns the specified SkScalar squared (x*x)
- */
- inline SkScalar SkScalarSquare(SkScalar x) { return x * x; }
- /** Returns the product of two SkScalars
- */
- #define SkScalarMul(a, b) ((float)(a) * (b))
- /** Returns the product of two SkScalars plus a third SkScalar
- */
- #define SkScalarMulAdd(a, b, c) ((float)(a) * (b) + (c))
- /** Returns the product of a SkScalar and an int rounded to the nearest integer value
- */
- #define SkScalarMulRound(a, b) SkScalarRound((float)(a) * (b))
- /** Returns the product of a SkScalar and an int promoted to the next larger int
- */
- #define SkScalarMulCeil(a, b) SkScalarCeil((float)(a) * (b))
- /** Returns the product of a SkScalar and an int truncated to the next smaller int
- */
- #define SkScalarMulFloor(a, b) SkScalarFloor((float)(a) * (b))
- /** Returns the quotient of two SkScalars (a/b)
- */
- #define SkScalarDiv(a, b) ((float)(a) / (b))
- /** Returns the mod of two SkScalars (a mod b)
- */
- #define SkScalarMod(x,y) sk_float_mod(x,y)
- /** Returns the product of the first two arguments, divided by the third argument
- */
- #define SkScalarMulDiv(a, b, c) ((float)(a) * (b) / (c))
- /** Returns the multiplicative inverse of the SkScalar (1/x)
- */
- #define SkScalarInvert(x) (SK_Scalar1 / (x))
- #define SkScalarFastInvert(x) (SK_Scalar1 / (x))
- /** Returns the square root of the SkScalar
- */
- #define SkScalarSqrt(x) sk_float_sqrt(x)
- /** Returns b to the e
- */
- #define SkScalarPow(b, e) sk_float_pow(b, e)
- /** Returns the average of two SkScalars (a+b)/2
- */
- #define SkScalarAve(a, b) (((a) + (b)) * 0.5f)
- /** Returns the geometric mean of two SkScalars
- */
- #define SkScalarMean(a, b) sk_float_sqrt((float)(a) * (b))
- /** Returns one half of the specified SkScalar
- */
- #define SkScalarHalf(a) ((a) * 0.5f)
-
- #define SK_ScalarSqrt2 1.41421356f
- #define SK_ScalarPI 3.14159265f
- #define SK_ScalarTanPIOver8 0.414213562f
- #define SK_ScalarRoot2Over2 0.707106781f
-
- #define SkDegreesToRadians(degrees) ((degrees) * (SK_ScalarPI / 180))
- float SkScalarSinCos(SkScalar radians, SkScalar* cosValue);
- #define SkScalarSin(radians) (float)sk_float_sin(radians)
- #define SkScalarCos(radians) (float)sk_float_cos(radians)
- #define SkScalarTan(radians) (float)sk_float_tan(radians)
- #define SkScalarASin(val) (float)sk_float_asin(val)
- #define SkScalarACos(val) (float)sk_float_acos(val)
- #define SkScalarATan2(y, x) (float)sk_float_atan2(y,x)
- #define SkScalarExp(x) (float)sk_float_exp(x)
- #define SkScalarLog(x) (float)sk_float_log(x)
-
- inline SkScalar SkMaxScalar(SkScalar a, SkScalar b) { return a > b ? a : b; }
- inline SkScalar SkMinScalar(SkScalar a, SkScalar b) { return a < b ? a : b; }
-
- static inline bool SkScalarIsInt(SkScalar x) {
- return x == (float)(int)x;
- }
-#else
- typedef SkFixed SkScalar;
-
- #define SK_Scalar1 SK_Fixed1
- #define SK_ScalarHalf SK_FixedHalf
- #define SK_ScalarInfinity SK_FixedMax
- #define SK_ScalarNegativeInfinity SK_FixedMin
- #define SK_ScalarMax SK_FixedMax
- #define SK_ScalarMin SK_FixedMin
- #define SK_ScalarNaN SK_FixedNaN
- #define SkScalarIsNaN(x) ((x) == SK_FixedNaN)
- #define SkScalarIsFinite(x) ((x) != SK_FixedNaN)
+/** SkIntToScalar(n) returns its integer argument as an SkScalar
+*/
+#define SkIntToScalar(n) ((float)(n))
+/** SkFixedToScalar(n) returns its SkFixed argument as an SkScalar
+*/
+#define SkFixedToScalar(x) SkFixedToFloat(x)
+/** SkScalarToFixed(n) returns its SkScalar argument as an SkFixed
+*/
+#define SkScalarToFixed(x) SkFloatToFixed(x)
- #define SkIntToScalar(n) SkIntToFixed(n)
- #define SkFixedToScalar(x) (x)
- #define SkScalarToFixed(x) (x)
- #define SkScalarToFloat(n) SkFixedToFloat(n)
+#define SkScalarToFloat(n) (n)
#ifndef SK_SCALAR_TO_FLOAT_EXCLUDED
- #define SkFloatToScalar(n) SkFloatToFixed(n)
+#define SkFloatToScalar(n) (n)
#endif
- #define SkScalarToDouble(n) SkFixedToDouble(n)
- #define SkDoubleToScalar(n) SkDoubleToFixed(n)
- #define SkScalarFraction(x) SkFixedFraction(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 SkScalarTruncToInt(x) (((x) < 0) ? SkScalarCeilToInt(x) : SkScalarFloorToInt(x))
+#define SkScalarToDouble(n) (double)(n)
+#define SkDoubleToScalar(n) (float)(n)
- #define SkScalarAbs(x) SkFixedAbs(x)
- #define SkScalarCopySign(x, y) SkCopySign32(x, y)
- #define SkScalarClampMax(x, max) SkClampMax(x, max)
- #define SkScalarPin(x, min, max) SkPin32(x, min, max)
- #define SkScalarSquare(x) SkFixedSquare(x)
- #define SkScalarMul(a, b) SkFixedMul(a, b)
- #define SkScalarMulAdd(a, b, c) SkFixedMulAdd(a, b, c)
- #define SkScalarMulRound(a, b) SkFixedMulCommon(a, b, SK_FixedHalf)
- #define SkScalarMulCeil(a, b) SkFixedMulCommon(a, b, SK_Fixed1 - 1)
- #define SkScalarMulFloor(a, b) SkFixedMulCommon(a, b, 0)
- #define SkScalarDiv(a, b) SkFixedDiv(a, b)
- #define SkScalarMod(a, b) SkFixedMod(a, b)
- #define SkScalarMulDiv(a, b, c) SkMulDiv(a, b, c)
- #define SkScalarInvert(x) SkFixedInvert(x)
- #define SkScalarFastInvert(x) SkFixedFastInvert(x)
- #define SkScalarSqrt(x) SkFixedSqrt(x)
- #define SkScalarAve(a, b) SkFixedAve(a, b)
- #define SkScalarMean(a, b) SkFixedMean(a, b)
- #define SkScalarHalf(a) ((a) >> 1)
-
- #define SK_ScalarSqrt2 SK_FixedSqrt2
- #define SK_ScalarPI SK_FixedPI
- #define SK_ScalarTanPIOver8 SK_FixedTanPIOver8
- #define SK_ScalarRoot2Over2 SK_FixedRoot2Over2
+/** SkScalarFraction(x) returns the signed fractional part of the argument
+*/
+#define SkScalarFraction(x) sk_float_mod(x, 1.0f)
- #define SkDegreesToRadians(degrees) SkFractMul(degrees, SK_FractPIOver180)
- #define SkScalarSinCos(radians, cosPtr) SkFixedSinCos(radians, cosPtr)
- #define SkScalarSin(radians) SkFixedSin(radians)
- #define SkScalarCos(radians) SkFixedCos(radians)
- #define SkScalarTan(val) SkFixedTan(val)
- #define SkScalarASin(val) SkFixedASin(val)
- #define SkScalarACos(val) SkFixedACos(val)
- #define SkScalarATan2(y, x) SkFixedATan2(y,x)
- #define SkScalarExp(x) SkFixedExp(x)
- #define SkScalarLog(x) SkFixedLog(x)
+#define SkScalarFloorToScalar(x) sk_float_floor(x)
+#define SkScalarCeilToScalar(x) sk_float_ceil(x)
+#define SkScalarRoundToScalar(x) sk_float_floor((x) + 0.5f)
- #define SkMaxScalar(a, b) SkMax32(a, b)
- #define SkMinScalar(a, b) SkMin32(a, b)
+#define SkScalarFloorToInt(x) sk_float_floor2int(x)
+#define SkScalarCeilToInt(x) sk_float_ceil2int(x)
+#define SkScalarRoundToInt(x) sk_float_round2int(x)
+#define SkScalarTruncToInt(x) static_cast<int>(x)
- static inline bool SkScalarIsInt(SkFixed x) {
- return 0 == (x & 0xffff);
- }
-#endif
+/** Returns the absolute value of the specified SkScalar
+*/
+#define SkScalarAbs(x) sk_float_abs(x)
+/** Return x with the sign of y
+ */
+#define SkScalarCopySign(x, y) sk_float_copysign(x, y)
+/** Returns the value pinned between 0 and max inclusive
+*/
+inline SkScalar SkScalarClampMax(SkScalar x, SkScalar max) {
+ return x < 0 ? 0 : x > max ? max : x;
+}
+/** Returns the value pinned between min and max inclusive
+*/
+inline SkScalar SkScalarPin(SkScalar x, SkScalar min, SkScalar max) {
+ return x < min ? min : x > max ? max : x;
+}
+/** Returns the specified SkScalar squared (x*x)
+*/
+inline SkScalar SkScalarSquare(SkScalar x) { return x * x; }
+/** Returns the product of two SkScalars
+*/
+#define SkScalarMul(a, b) ((float)(a) * (b))
+/** Returns the product of two SkScalars plus a third SkScalar
+*/
+#define SkScalarMulAdd(a, b, c) ((float)(a) * (b) + (c))
+/** Returns the product of a SkScalar and an int rounded to the nearest integer value
+*/
+#define SkScalarMulRound(a, b) SkScalarRound((float)(a) * (b))
+/** Returns the product of a SkScalar and an int promoted to the next larger int
+*/
+#define SkScalarMulCeil(a, b) SkScalarCeil((float)(a) * (b))
+/** Returns the product of a SkScalar and an int truncated to the next smaller int
+*/
+#define SkScalarMulFloor(a, b) SkScalarFloor((float)(a) * (b))
+/** Returns the quotient of two SkScalars (a/b)
+*/
+#define SkScalarDiv(a, b) ((float)(a) / (b))
+/** Returns the mod of two SkScalars (a mod b)
+*/
+#define SkScalarMod(x,y) sk_float_mod(x,y)
+/** Returns the product of the first two arguments, divided by the third argument
+*/
+#define SkScalarMulDiv(a, b, c) ((float)(a) * (b) / (c))
+/** Returns the multiplicative inverse of the SkScalar (1/x)
+*/
+#define SkScalarInvert(x) (SK_Scalar1 / (x))
+#define SkScalarFastInvert(x) (SK_Scalar1 / (x))
+/** Returns the square root of the SkScalar
+*/
+#define SkScalarSqrt(x) sk_float_sqrt(x)
+/** Returns b to the e
+*/
+#define SkScalarPow(b, e) sk_float_pow(b, e)
+/** Returns the average of two SkScalars (a+b)/2
+*/
+#define SkScalarAve(a, b) (((a) + (b)) * 0.5f)
+/** Returns the geometric mean of two SkScalars
+*/
+#define SkScalarMean(a, b) sk_float_sqrt((float)(a) * (b))
+/** Returns one half of the specified SkScalar
+*/
+#define SkScalarHalf(a) ((a) * 0.5f)
+
+#define SK_ScalarSqrt2 1.41421356f
+#define SK_ScalarPI 3.14159265f
+#define SK_ScalarTanPIOver8 0.414213562f
+#define SK_ScalarRoot2Over2 0.707106781f
+
+#define SkDegreesToRadians(degrees) ((degrees) * (SK_ScalarPI / 180))
+float SkScalarSinCos(SkScalar radians, SkScalar* cosValue);
+#define SkScalarSin(radians) (float)sk_float_sin(radians)
+#define SkScalarCos(radians) (float)sk_float_cos(radians)
+#define SkScalarTan(radians) (float)sk_float_tan(radians)
+#define SkScalarASin(val) (float)sk_float_asin(val)
+#define SkScalarACos(val) (float)sk_float_acos(val)
+#define SkScalarATan2(y, x) (float)sk_float_atan2(y,x)
+#define SkScalarExp(x) (float)sk_float_exp(x)
+#define SkScalarLog(x) (float)sk_float_log(x)
+
+inline SkScalar SkMaxScalar(SkScalar a, SkScalar b) { return a > b ? a : b; }
+inline SkScalar SkMinScalar(SkScalar a, SkScalar b) { return a < b ? a : b; }
+
+static inline bool SkScalarIsInt(SkScalar x) {
+ return x == (float)(int)x;
+}
// DEPRECATED : use ToInt or ToScalar variant
#define SkScalarFloor(x) SkScalarFloorToInt(x)
@@ -329,7 +235,6 @@ SkScalar SkScalarInterpFunc(SkScalar searchKey, const SkScalar keys[],
* Helper to compare an array of scalars.
*/
static inline bool SkScalarsEqual(const SkScalar a[], const SkScalar b[], int n) {
-#ifdef SK_SCALAR_IS_FLOAT
SkASSERT(n >= 0);
for (int i = 0; i < n; ++i) {
if (a[i] != b[i]) {
@@ -337,9 +242,6 @@ static inline bool SkScalarsEqual(const SkScalar a[], const SkScalar b[], int n)
}
}
return true;
-#else
- return 0 == memcmp(a, b, n * sizeof(SkScalar));
-#endif
}
#endif
diff --git a/include/core/SkString.h b/include/core/SkString.h
index ce87312f12..bc06cb0aba 100644
--- a/include/core/SkString.h
+++ b/include/core/SkString.h
@@ -86,11 +86,7 @@ char* SkStrAppendS64(char buffer[], int64_t, int minDigits);
* Thus if the caller wants to add a 0 at the end, buffer must be at least
* SkStrAppendScalar_MaxSize + 1 bytes large.
*/
-#ifdef SK_SCALAR_IS_FLOAT
- #define SkStrAppendScalar SkStrAppendFloat
-#else
- #define SkStrAppendScalar SkStrAppendFixed
-#endif
+#define SkStrAppendScalar SkStrAppendFloat
char* SkStrAppendFloat(char buffer[], float);
char* SkStrAppendFixed(char buffer[], SkFixed);
diff --git a/include/utils/SkCamera.h b/include/utils/SkCamera.h
index eafacbcd7d..ad74c81d2f 100644
--- a/include/utils/SkCamera.h
+++ b/include/utils/SkCamera.h
@@ -19,17 +19,10 @@
class SkCanvas;
-#ifdef SK_SCALAR_IS_FIXED
- typedef SkFract SkUnitScalar;
- #define SK_UnitScalar1 SK_Fract1
- #define SkUnitScalarMul(a, b) SkFractMul(a, b)
- #define SkUnitScalarDiv(a, b) SkFractDiv(a, b)
-#else
- typedef float SkUnitScalar;
- #define SK_UnitScalar1 SK_Scalar1
- #define SkUnitScalarMul(a, b) SkScalarMul(a, b)
- #define SkUnitScalarDiv(a, b) SkScalarDiv(a, b)
-#endif
+typedef float SkUnitScalar;
+#define SK_UnitScalar1 SK_Scalar1
+#define SkUnitScalarMul(a, b) SkScalarMul(a, b)
+#define SkUnitScalarDiv(a, b) SkScalarDiv(a, b)
struct SkUnit3D {
SkUnitScalar fX, fY, fZ;
diff --git a/samplecode/SampleCircle.cpp b/samplecode/SampleCircle.cpp
index 87ca4872e1..b101a1f257 100644
--- a/samplecode/SampleCircle.cpp
+++ b/samplecode/SampleCircle.cpp
@@ -16,12 +16,10 @@
// reconstruct the edges of the circle.
// see bug# 1504910
static void test_circlebounds(SkCanvas*) {
-#ifdef SK_SCALAR_IS_FLOAT
SkRect r = { 1.39999998f, 1, 21.3999996f, 21 };
SkPath p;
p.addOval(r);
SkASSERT(r == p.getBounds());
-#endif
}
class CircleView : public SampleView {
diff --git a/samplecode/SampleOverflow.cpp b/samplecode/SampleOverflow.cpp
deleted file mode 100644
index 35adbf3509..0000000000
--- a/samplecode/SampleOverflow.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-
-/*
- * Copyright 2011 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#include "SampleCode.h"
-#include "SkView.h"
-#include "SkCanvas.h"
-#include "SkDevice.h"
-#include "SkPaint.h"
-
-static void DrawRoundRect() {
-#ifdef SK_SCALAR_IS_FIXED
- bool ret = false;
- SkPaint paint;
- SkBitmap bitmap;
- SkMatrix matrix;
- matrix.reset();
-
- bitmap.setConfig(SkBitmap::kARGB_8888_Config, 1370, 812);
- bitmap.allocPixels();
-
- SkCanvas canvas(bitmap);
-
- // set up clipper
- SkRect skclip;
- skclip.set(SkIntToFixed(284), SkIntToFixed(40), SkIntToFixed(1370), SkIntToFixed(708));
-
- ret = canvas.clipRect(skclip);
- SkASSERT(ret);
-
- matrix.set(SkMatrix::kMTransX, SkFloatToFixed(-1153.28));
- matrix.set(SkMatrix::kMTransY, SkFloatToFixed(1180.50));
-
- matrix.set(SkMatrix::kMScaleX, SkFloatToFixed(0.177171));
- matrix.set(SkMatrix::kMScaleY, SkFloatToFixed(0.177043));
-
- matrix.set(SkMatrix::kMSkewX, SkFloatToFixed(0.126968));
- matrix.set(SkMatrix::kMSkewY, SkFloatToFixed(-0.126876));
-
- matrix.set(SkMatrix::kMPersp0, SkFloatToFixed(0.0));
- matrix.set(SkMatrix::kMPersp1, SkFloatToFixed(0.0));
-
- ret = canvas.concat(matrix);
-
- paint.setAntiAlias(true);
- paint.setColor(0xb2202020);
- paint.setStyle(SkPaint::kStroke_Style);
- paint.setStrokeWidth(SkFloatToFixed(68.13));
-
- SkRect r;
- r.set(SkFloatToFixed(-313.714417), SkFloatToFixed(-4.826389), SkFloatToFixed(18014.447266), SkFloatToFixed(1858.154541));
- canvas.drawRoundRect(r, SkFloatToFixed(91.756363), SkFloatToFixed(91.756363), paint);
-#endif
-}
-
-#ifdef SK_SCALAR_IS_FLOATx // FIXME: unclear when if ever this can be enabled
-static bool HitTestPath(const SkPath& path, SkScalar x, SkScalar y) {
- SkRegion rgn, clip;
-
- int ix = SkScalarFloor(x);
- int iy = SkScalarFloor(y);
-
- clip.setRect(ix, iy, ix + 1, iy + 1);
-
- bool contains = rgn.setPath(path, clip);
- return contains;
-}
-#endif
-
-static void TestOverflowHitTest() {
- SkPath path;
-
-#ifdef SK_SCALAR_IS_FLOATx // FIXME: unclear when if ever this can be enabled
- path.addCircle(0, 0, 70000, SkPath::kCCW_Direction);
- SkASSERT(HitTestPath(path, 40000, 40000));
-#endif
-}
-
-class OverflowView : public SampleView {
-public:
- OverflowView() {}
-
-protected:
- // overrides from SkEventSink
- virtual bool onQuery(SkEvent* evt) {
- if (SampleCode::TitleQ(*evt)) {
- SampleCode::TitleR(evt, "Circles");
- return true;
- }
- return this->INHERITED::onQuery(evt);
- }
-
- virtual void onDrawContent(SkCanvas* canvas) {
- DrawRoundRect();
- TestOverflowHitTest();
- }
-
-private:
- typedef SampleView INHERITED;
-};
-
-//////////////////////////////////////////////////////////////////////////////
-
-static SkView* MyFactory() { return new OverflowView; }
-static SkViewRegister reg(MyFactory);
diff --git a/src/animator/SkDisplayMath.cpp b/src/animator/SkDisplayMath.cpp
index bdf377b302..ac2ba8bf24 100644
--- a/src/animator/SkDisplayMath.cpp
+++ b/src/animator/SkDisplayMath.cpp
@@ -21,7 +21,6 @@ enum SkDisplayMath_Properties {
};
const SkScalar SkDisplayMath::gConstants[] = {
-#ifdef SK_SCALAR_IS_FLOAT
2.718281828f, // E
2.302585093f, // LN10
0.693147181f, // LN2
@@ -30,16 +29,6 @@ const SkScalar SkDisplayMath::gConstants[] = {
3.141592654f, // PI
0.707106781f, // SQRT1_2
1.414213562f // SQRT2
-#else
- 0x2B7E1, // E
- 0x24D76, // LN10
- 0xB172, // LN2
- 0x6F2E, // LOG10E
- 0x17154, // LOG2E
- 0x3243F, // PI
- 0xB505, // SQRT1_2
- 0x16A0A // SQRT2
-#endif
};
enum SkDisplayMath_Functions {
diff --git a/src/animator/SkDrawColor.cpp b/src/animator/SkDrawColor.cpp
index b6bc261d71..00c429b5a1 100644
--- a/src/animator/SkDrawColor.cpp
+++ b/src/animator/SkDrawColor.cpp
@@ -226,11 +226,7 @@ bool SkDrawColor::setProperty(int index, SkScriptValue& value) {
switch (index) {
case SK_PROPERTY(alpha):
uint8_t alpha;
- #ifdef SK_SCALAR_IS_FLOAT
alpha = scalar == SK_Scalar1 ? 255 : SkToU8((U8CPU) (scalar * 256));
- #else
- alpha = SkToU8((scalar - (scalar >= SK_ScalarHalf)) >> 8);
- #endif
color = SkColorSetARGB(alpha, SkColorGetR(color),
SkColorGetG(color), SkColorGetB(color));
break;
diff --git a/src/animator/SkDrawGradient.cpp b/src/animator/SkDrawGradient.cpp
index 44086e4269..1b158f23c1 100644
--- a/src/animator/SkDrawGradient.cpp
+++ b/src/animator/SkDrawGradient.cpp
@@ -14,20 +14,12 @@
#include "SkUnitMapper.h"
static SkScalar SkUnitToScalar(U16CPU x) {
-#ifdef SK_SCALAR_IS_FLOAT
return x / 65535.0f;
-#else
- return x + (x >> 8);
-#endif
}
static U16CPU SkScalarToUnit(SkScalar x) {
SkScalar pin = SkScalarPin(x, 0, SK_Scalar1);
-#ifdef SK_SCALAR_IS_FLOAT
return (int) (pin * 65535.0f);
-#else
- return pin - (pin >= 32768);
-#endif
}
class SkDrawGradientUnitMapper : public SkUnitMapper {
diff --git a/src/animator/SkScript.cpp b/src/animator/SkScript.cpp
index 934b0abe1a..bf55cb574a 100644
--- a/src/animator/SkScript.cpp
+++ b/src/animator/SkScript.cpp
@@ -1650,13 +1650,8 @@ bool SkScriptEngine::ValueToString(SkScriptValue value, SkString* string) {
#define DEF_STRING_ANSWER NULL
#define testInt(expression) { #expression, SkType_Int, expression, DEF_SCALAR_ANSWER, DEF_STRING_ANSWER }
-#ifdef SK_SCALAR_IS_FLOAT
#define testScalar(expression) { #expression, SkType_Float, 0, (float) expression, DEF_STRING_ANSWER }
#define testRemainder(exp1, exp2) { #exp1 "%" #exp2, SkType_Float, 0, sk_float_mod(exp1, exp2), DEF_STRING_ANSWER }
-#else
- #define testScalar(expression) { #expression, SkType_Float, 0, (int) ((expression) * 65536.0f), DEF_STRING_ANSWER }
- #define testRemainder(exp1, exp2) { #exp1 "%" #exp2, SkType_Float, 0, (int) (sk_float_mod(exp1, exp2) * 65536.0f), DEF_STRING_ANSWER }
-#endif
#define testTrue(expression) { #expression, SkType_Int, 1, DEF_SCALAR_ANSWER, DEF_STRING_ANSWER }
#define testFalse(expression) { #expression, SkType_Int, 0, DEF_SCALAR_ANSWER, DEF_STRING_ANSWER }
diff --git a/src/animator/SkScriptTokenizer.cpp b/src/animator/SkScriptTokenizer.cpp
index 42954a7706..24084453f6 100644
--- a/src/animator/SkScriptTokenizer.cpp
+++ b/src/animator/SkScriptTokenizer.cpp
@@ -1274,13 +1274,8 @@ bool SkScriptEngine2::ValueToString(const SkScriptValue2& value, SkString* strin
#if defined(SK_SUPPORT_UNITTEST)
#define testInt(expression) { #expression, SkOperand2::kS32, expression, 0, NULL }
-#ifdef SK_SCALAR_IS_FLOAT
#define testScalar(expression) { #expression, SkOperand2::kScalar, 0, (float) (expression), NULL }
#define testRemainder(exp1, exp2) { #exp1 "%" #exp2, SkOperand2::kScalar, 0, fmodf((float) exp1, (float) exp2), NULL }
-#else
-#define testScalar(expression) { #expression, SkOperand2::kScalar, 0, (int) ((expression) * 65536.0f), NULL }
-#define testRemainder(exp1, exp2) { #exp1 "%" #exp2, SkOperand2::kScalar, 0, (int) (fmod(exp1, exp2) * 65536.0f), NULL }
-#endif
#define testTrue(expression) { #expression, SkOperand2::kS32, 1, 0, NULL }
#define testFalse(expression) { #expression, SkOperand2::kS32, 0, 0, NULL }
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index feeba758fa..dfaf65dd98 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -1457,13 +1457,6 @@ bool SkCanvas::quickReject(const SkPath& path) const {
}
static inline int pinIntForScalar(int x) {
-#ifdef SK_SCALAR_IS_FIXED
- if (x < SK_MinS16) {
- x = SK_MinS16;
- } else if (x > SK_MaxS16) {
- x = SK_MaxS16;
- }
-#endif
return x;
}
@@ -1487,15 +1480,8 @@ bool SkCanvas::getClipBounds(SkRect* bounds) const {
// adjust it outwards in case we are antialiasing
const int inset = 1;
- // SkRect::iset() will correctly assert if we pass a value out of range
- // (when SkScalar==fixed), so we pin to legal values. This does not
- // really returnt the correct answer, but its the best we can do given
- // that we've promised to return SkRect (even though we support devices
- // that can be larger than 32K in width or height).
- r.iset(pinIntForScalar(ibounds.fLeft - inset),
- pinIntForScalar(ibounds.fTop - inset),
- pinIntForScalar(ibounds.fRight + inset),
- pinIntForScalar(ibounds.fBottom + inset));
+ r.iset(ibounds.fLeft - inset, ibounds.fTop - inset,
+ ibounds.fRight + inset, ibounds.fBottom + inset);
inverse.mapRect(bounds, r);
}
return true;
diff --git a/src/core/SkCubicClipper.cpp b/src/core/SkCubicClipper.cpp
index aed681b9f3..81ef18de7a 100644
--- a/src/core/SkCubicClipper.cpp
+++ b/src/core/SkCubicClipper.cpp
@@ -31,11 +31,7 @@ static bool chopMonoCubicAtY(SkPoint pts[4], SkScalar y, SkScalar* t) {
// Initial guess.
// TODO(turk): Check for zero denominator? Shouldn't happen unless the curve
// is not only monotonic but degenerate.
-#ifdef SK_SCALAR_IS_FLOAT
SkScalar t1 = ycrv[0] / (ycrv[0] - ycrv[3]);
-#else // !SK_SCALAR_IS_FLOAT
- SkScalar t1 = SkDivBits(ycrv[0], ycrv[0] - ycrv[3], 16);
-#endif // !SK_SCALAR_IS_FLOAT
// Newton's iterations.
const SkScalar tol = SK_Scalar1 / 16384; // This leaves 2 fixed noise bits.
@@ -53,11 +49,7 @@ static bool chopMonoCubicAtY(SkPoint pts[4], SkScalar y, SkScalar* t) {
SkScalar y0123 = SkScalarInterp(y012, y123, t0);
SkScalar yder = (y123 - y012) * 3;
// TODO(turk): check for yder==0: horizontal.
-#ifdef SK_SCALAR_IS_FLOAT
t1 -= y0123 / yder;
-#else // !SK_SCALAR_IS_FLOAT
- t1 -= SkDivBits(y0123, yder, 16);
-#endif // !SK_SCALAR_IS_FLOAT
converged = SkScalarAbs(t1 - t0) <= tol; // NaN-safe
++iters;
} while (!converged && (iters < maxiters));
diff --git a/src/core/SkEdge.cpp b/src/core/SkEdge.cpp
index 8904ca727b..9ce255843f 100644
--- a/src/core/SkEdge.cpp
+++ b/src/core/SkEdge.cpp
@@ -36,19 +36,11 @@ int SkEdge::setLine(const SkPoint& p0, const SkPoint& p1, const SkIRect* clip,
SkFDot6 x0, y0, x1, y1;
{
-#ifdef SK_SCALAR_IS_FLOAT
float scale = float(1 << (shift + 6));
x0 = int(p0.fX * scale);
y0 = int(p0.fY * scale);
x1 = int(p1.fX * scale);
y1 = int(p1.fY * scale);
-#else
- shift = 10 - shift;
- x0 = p0.fX >> shift;
- y0 = p0.fY >> shift;
- x1 = p1.fX >> shift;
- y1 = p1.fY >> shift;
-#endif
}
int winding = 1;
@@ -179,7 +171,6 @@ int SkQuadraticEdge::setQuadratic(const SkPoint pts[3], int shift)
SkFDot6 x0, y0, x1, y1, x2, y2;
{
-#ifdef SK_SCALAR_IS_FLOAT
float scale = float(1 << (shift + 6));
x0 = int(pts[0].fX * scale);
y0 = int(pts[0].fY * scale);
@@ -187,15 +178,6 @@ int SkQuadraticEdge::setQuadratic(const SkPoint pts[3], int shift)
y1 = int(pts[1].fY * scale);
x2 = int(pts[2].fX * scale);
y2 = int(pts[2].fY * scale);
-#else
- shift = 10 - shift;
- x0 = pts[0].fX >> shift;
- y0 = pts[0].fY >> shift;
- x1 = pts[1].fX >> shift;
- y1 = pts[1].fY >> shift;
- x2 = pts[2].fX >> shift;
- y2 = pts[2].fY >> shift;
-#endif
}
int winding = 1;
@@ -339,7 +321,6 @@ int SkCubicEdge::setCubic(const SkPoint pts[4], const SkIRect* clip, int shift)
SkFDot6 x0, y0, x1, y1, x2, y2, x3, y3;
{
-#ifdef SK_SCALAR_IS_FLOAT
float scale = float(1 << (shift + 6));
x0 = int(pts[0].fX * scale);
y0 = int(pts[0].fY * scale);
@@ -349,17 +330,6 @@ int SkCubicEdge::setCubic(const SkPoint pts[4], const SkIRect* clip, int shift)
y2 = int(pts[2].fY * scale);
x3 = int(pts[3].fX * scale);
y3 = int(pts[3].fY * scale);
-#else
- shift = 10 - shift;
- x0 = pts[0].fX >> shift;
- y0 = pts[0].fY >> shift;
- x1 = pts[1].fX >> shift;
- y1 = pts[1].fY >> shift;
- x2 = pts[2].fX >> shift;
- y2 = pts[2].fY >> shift;
- x3 = pts[3].fX >> shift;
- y3 = pts[3].fY >> shift;
-#endif
}
int winding = 1;
diff --git a/src/core/SkEdge.h b/src/core/SkEdge.h
index ea7c84f78d..091223631f 100644
--- a/src/core/SkEdge.h
+++ b/src/core/SkEdge.h
@@ -89,19 +89,11 @@ int SkEdge::setLine(const SkPoint& p0, const SkPoint& p1, int shift) {
SkFDot6 x0, y0, x1, y1;
{
-#ifdef SK_SCALAR_IS_FLOAT
float scale = float(1 << (shift + 6));
x0 = int(p0.fX * scale);
y0 = int(p0.fY * scale);
x1 = int(p1.fX * scale);
y1 = int(p1.fY * scale);
-#else
- shift = 10 - shift;
- x0 = p0.fX >> shift;
- y0 = p0.fY >> shift;
- x1 = p1.fX >> shift;
- y1 = p1.fY >> shift;
-#endif
}
int winding = 1;
diff --git a/src/core/SkFDot6.h b/src/core/SkFDot6.h
index afb369e9b2..5a0ec57f59 100644
--- a/src/core/SkFDot6.h
+++ b/src/core/SkFDot6.h
@@ -39,13 +39,8 @@ inline SkFixed SkFDot6ToFixed(SkFDot6 x) {
return x << 10;
}
-#ifdef SK_SCALAR_IS_FLOAT
- #define SkScalarToFDot6(x) (SkFDot6)((x) * 64)
- #define SkFDot6ToScalar(x) ((SkScalar)(x) * 0.015625f)
-#else
- #define SkScalarToFDot6(x) ((x) >> 10)
- #define SkFDot6ToScalar(x) ((x) << 10)
-#endif
+#define SkScalarToFDot6(x) (SkFDot6)((x) * 64)
+#define SkFDot6ToScalar(x) ((SkScalar)(x) * 0.015625f)
inline SkFixed SkFDot6Div(SkFDot6 a, SkFDot6 b) {
SkASSERT(b != 0);
diff --git a/src/core/SkFlattenableBuffers.cpp b/src/core/SkFlattenableBuffers.cpp
index 9da4dd9ee4..fc38529ef7 100644
--- a/src/core/SkFlattenableBuffers.cpp
+++ b/src/core/SkFlattenableBuffers.cpp
@@ -24,9 +24,8 @@ SkFlattenableReadBuffer::SkFlattenableReadBuffer() {
// Set default values. These should be explicitly set by our client
// via setFlags() if the buffer came from serialization.
fFlags = 0;
-#ifdef SK_SCALAR_IS_FLOAT
+ // TODO: remove this flag, since we're always floats (now)
fFlags |= kScalarIsFloat_Flag;
-#endif
if (8 == sizeof(void*)) {
fFlags |= kPtrIs64Bit_Flag;
}
diff --git a/src/core/SkGeometry.cpp b/src/core/SkGeometry.cpp
index f07ca2a101..6295202764 100644
--- a/src/core/SkGeometry.cpp
+++ b/src/core/SkGeometry.cpp
@@ -68,32 +68,18 @@ bool SkXRayCrossesLine(const SkXRay& pt, const SkPoint pts[2], bool* ambiguous)
involving integer multiplies by 2 or 3, but fewer calls to SkScalarMul.
May also introduce overflow of fixed when we compute our setup.
*/
-#ifdef SK_SCALAR_IS_FIXED
- #define DIRECT_EVAL_OF_POLYNOMIALS
-#endif
+// #define DIRECT_EVAL_OF_POLYNOMIALS
////////////////////////////////////////////////////////////////////////
-#ifdef SK_SCALAR_IS_FIXED
- static int is_not_monotonic(int a, int b, int c, int d)
- {
- return (((a - b) | (b - c) | (c - d)) & ((b - a) | (c - b) | (d - c))) >> 31;
- }
-
- static int is_not_monotonic(int a, int b, int c)
- {
- return (((a - b) | (b - c)) & ((b - a) | (c - b))) >> 31;
- }
-#else
- static int is_not_monotonic(float a, float b, float c)
- {
- float ab = a - b;
- float bc = b - c;
- if (ab < 0)
- bc = -bc;
- return ab == 0 || bc < 0;
+static int is_not_monotonic(float a, float b, float c) {
+ float ab = a - b;
+ float bc = b - c;
+ if (ab < 0) {
+ bc = -bc;
}
-#endif
+ return ab == 0 || bc < 0;
+}
////////////////////////////////////////////////////////////////////////
@@ -141,23 +127,11 @@ int SkFindUnitQuadRoots(SkScalar A, SkScalar B, SkScalar C, SkScalar roots[2])
SkScalar* r = roots;
-#ifdef SK_SCALAR_IS_FLOAT
float R = B*B - 4*A*C;
if (R < 0 || SkScalarIsNaN(R)) { // complex roots
return 0;
}
R = sk_float_sqrt(R);
-#else
- Sk64 RR, tmp;
-
- RR.setMul(B,B);
- tmp.setMul(A,C);
- tmp.shiftLeft(2);
- RR.sub(tmp);
- if (RR.isNeg())
- return 0;
- SkFixed R = RR.getSqrt();
-#endif
SkScalar Q = (B < 0) ? -(B-R)/2 : -(B+R)/2;
r += valid_unit_divide(Q, A, r);
@@ -172,25 +146,8 @@ int SkFindUnitQuadRoots(SkScalar A, SkScalar B, SkScalar C, SkScalar roots[2])
return (int)(r - roots);
}
-#ifdef SK_SCALAR_IS_FIXED
-/** Trim A/B/C down so that they are all <= 32bits
- and then call SkFindUnitQuadRoots()
-*/
-static int Sk64FindFixedQuadRoots(const Sk64& A, const Sk64& B, const Sk64& C, SkFixed roots[2])
-{
- int na = A.shiftToMake32();
- int nb = B.shiftToMake32();
- int nc = C.shiftToMake32();
-
- int shift = SkMax32(na, SkMax32(nb, nc));
- SkASSERT(shift >= 0);
-
- return SkFindUnitQuadRoots(A.getShiftRight(shift), B.getShiftRight(shift), C.getShiftRight(shift), roots);
-}
-#endif
-
-/////////////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
static SkScalar eval_quad(const SkScalar src[], SkScalar t)
{
@@ -297,11 +254,7 @@ int SkFindQuadExtrema(SkScalar a, SkScalar b, SkScalar c, SkScalar tValue[1])
/* At + B == 0
t = -B / A
*/
-#ifdef SK_SCALAR_IS_FIXED
- return is_not_monotonic(a, b, c) && valid_unit_divide(a - b, a - b - b + c, tValue);
-#else
return valid_unit_divide(a - b, a - b - b + c, tValue);
-#endif
}
static inline void flatten_double_quad_extrema(SkScalar coords[14])
@@ -401,31 +354,7 @@ float SkFindQuadMaxCurvature(const SkPoint src[3]) {
SkScalar By = src[0].fY - src[1].fY - src[1].fY + src[2].fY;
SkScalar t = 0; // 0 means don't chop
-#ifdef SK_SCALAR_IS_FLOAT
(void)valid_unit_divide(-(Ax * Bx + Ay * By), Bx * Bx + By * By, &t);
-#else
- // !!! should I use SkFloat here? seems like it
- Sk64 numer, denom, tmp;
-
- numer.setMul(Ax, -Bx);
- tmp.setMul(Ay, -By);
- numer.add(tmp);
-
- if (numer.isPos()) // do nothing if numer <= 0
- {
- denom.setMul(Bx, Bx);
- tmp.setMul(By, By);
- denom.add(tmp);
- SkASSERT(!denom.isNeg());
- if (numer < denom)
- {
- t = numer.getFixedDiv(denom);
- SkASSERT(t >= 0 && t <= SK_Fixed1); // assert that we're numerically stable (ha!)
- if ((unsigned)t >= SK_Fixed1) // runtime check for numerical stability
- t = 0; // ignore the chop
- }
- }
-#endif
return t;
}
@@ -441,11 +370,7 @@ int SkChopQuadAtMaxCurvature(const SkPoint src[3], SkPoint dst[5])
}
}
-#ifdef SK_SCALAR_IS_FLOAT
- #define SK_ScalarTwoThirds (0.666666666f)
-#else
- #define SK_ScalarTwoThirds ((SkFixed)(43691))
-#endif
+#define SK_ScalarTwoThirds (0.666666666f)
void SkConvertQuadToCubic(const SkPoint src[3], SkPoint dst[4]) {
const SkScalar scale = SK_ScalarTwoThirds;
@@ -553,11 +478,6 @@ void SkEvalCubicAt(const SkPoint src[4], SkScalar t, SkPoint* loc, SkVector* tan
*/
int SkFindCubicExtrema(SkScalar a, SkScalar b, SkScalar c, SkScalar d, SkScalar tValues[2])
{
-#ifdef SK_SCALAR_IS_FIXED
- if (!is_not_monotonic(a, b, c, d))
- return 0;
-#endif
-
// we divide A,B,C by 3 to simplify
SkScalar A = d - a + 3*(b - c);
SkScalar B = 2*(a - b - b + c);
@@ -747,29 +667,8 @@ int SkFindCubicInflections(const SkPoint src[4], SkScalar tValues[])
SkScalar By = src[2].fY - 2 * src[1].fY + src[0].fY;
SkScalar Cx = src[3].fX + 3 * (src[1].fX - src[2].fX) - src[0].fX;
SkScalar Cy = src[3].fY + 3 * (src[1].fY - src[2].fY) - src[0].fY;
- int count;
-
-#ifdef SK_SCALAR_IS_FLOAT
- count = SkFindUnitQuadRoots(Bx*Cy - By*Cx, Ax*Cy - Ay*Cx, Ax*By - Ay*Bx, tValues);
-#else
- Sk64 A, B, C, tmp;
-
- A.setMul(Bx, Cy);
- tmp.setMul(By, Cx);
- A.sub(tmp);
-
- B.setMul(Ax, Cy);
- tmp.setMul(Ay, Cx);
- B.sub(tmp);
- C.setMul(Ax, By);
- tmp.setMul(Ay, Bx);
- C.sub(tmp);
-
- count = Sk64FindFixedQuadRoots(A, B, C, tValues);
-#endif
-
- return count;
+ return SkFindUnitQuadRoots(Bx*Cy - By*Cx, Ax*Cy - Ay*Cx, Ax*By - Ay*Bx, tValues);
}
int SkChopCubicAtInflections(const SkPoint src[], SkPoint dst[10])
@@ -891,10 +790,6 @@ static void test_collaps_duplicates() {
}
#endif
-#if defined _WIN32 && _MSC_VER >= 1300 && defined SK_SCALAR_IS_FIXED // disable warning : unreachable code if building fixed point for windows desktop
-#pragma warning ( disable : 4702 )
-#endif
-
static SkScalar SkScalarCubeRoot(SkScalar x) {
return sk_float_pow(x, 0.3333333f);
}
diff --git a/src/core/SkLineClipper.cpp b/src/core/SkLineClipper.cpp
index 911cd974da..634de0d1e7 100644
--- a/src/core/SkLineClipper.cpp
+++ b/src/core/SkLineClipper.cpp
@@ -28,7 +28,6 @@ static SkScalar sect_with_horizontal(const SkPoint src[2], SkScalar Y) {
if (SkScalarNearlyZero(dy)) {
return SkScalarAve(src[0].fX, src[1].fX);
} else {
-#ifdef SK_SCALAR_IS_FLOAT
// need the extra precision so we don't compute a value that exceeds
// our original limits
double X0 = src[0].fX;
@@ -41,10 +40,6 @@ static SkScalar sect_with_horizontal(const SkPoint src[2], SkScalar Y) {
// when the doubles were added and subtracted, so we have to pin the
// answer :(
return (float)pin_unsorted(result, X0, X1);
-#else
- return src[0].fX + SkScalarMulDiv(Y - src[0].fY, src[1].fX - src[0].fX,
- dy);
-#endif
}
}
@@ -54,7 +49,6 @@ static SkScalar sect_with_vertical(const SkPoint src[2], SkScalar X) {
if (SkScalarNearlyZero(dx)) {
return SkScalarAve(src[0].fY, src[1].fY);
} else {
-#ifdef SK_SCALAR_IS_FLOAT
// need the extra precision so we don't compute a value that exceeds
// our original limits
double X0 = src[0].fX;
@@ -63,10 +57,6 @@ static SkScalar sect_with_vertical(const SkPoint src[2], SkScalar X) {
double Y1 = src[1].fY;
double result = Y0 + ((double)X - X0) * (Y1 - Y0) / (X1 - X0);
return (float)result;
-#else
- return src[0].fY + SkScalarMulDiv(X - src[0].fX, src[1].fY - src[0].fY,
- dx);
-#endif
}
}
@@ -167,7 +157,6 @@ static bool is_between_unsorted(SkScalar value,
}
#endif
-#ifdef SK_SCALAR_IS_FLOAT
#ifdef SK_DEBUG
// This is an example of why we need to pin the result computed in
// sect_with_horizontal. If we didn't explicitly pin, is_between_unsorted would
@@ -182,11 +171,9 @@ static void sect_with_horizontal_test_for_pin_results() {
SkASSERT(is_between_unsorted(x, pts[0].fX, pts[1].fX));
}
#endif
-#endif
int SkLineClipper::ClipLine(const SkPoint pts[], const SkRect& clip,
SkPoint lines[]) {
-#ifdef SK_SCALAR_IS_FLOAT
#ifdef SK_DEBUG
{
static bool gOnce;
@@ -196,7 +183,6 @@ int SkLineClipper::ClipLine(const SkPoint pts[], const SkRect& clip,
}
}
#endif
-#endif
int index0, index1;
diff --git a/src/core/SkMath.cpp b/src/core/SkMath.cpp
index 2693e5c13c..f1ba3a3a0c 100644
--- a/src/core/SkMath.cpp
+++ b/src/core/SkMath.cpp
@@ -12,11 +12,9 @@
#include "Sk64.h"
#include "SkScalar.h"
-#ifdef SK_SCALAR_IS_FLOAT
- const uint32_t gIEEENotANumber = 0x7FFFFFFF;
- const uint32_t gIEEEInfinity = 0x7F800000;
- const uint32_t gIEEENegativeInfinity = 0xFF800000;
-#endif
+const uint32_t gIEEENotANumber = 0x7FFFFFFF;
+const uint32_t gIEEEInfinity = 0x7F800000;
+const uint32_t gIEEENegativeInfinity = 0xFF800000;
#define sub_shift(zeros, x, n) \
zeros -= n; \
@@ -376,7 +374,6 @@ SkFixed SkFixedMean(SkFixed a, SkFixed b) {
///////////////////////////////////////////////////////////////////////////////
-#ifdef SK_SCALAR_IS_FLOAT
float SkScalarSinCos(float radians, float* cosValue) {
float sinValue = sk_float_sin(radians);
@@ -392,7 +389,6 @@ float SkScalarSinCos(float radians, float* cosValue) {
}
return sinValue;
}
-#endif
#define INTERP_SINTABLE
#define BUILD_TABLE_AT_RUNTIMEx
diff --git a/src/core/SkMatrix.cpp b/src/core/SkMatrix.cpp
index fd6290fdd6..4493fababb 100644
--- a/src/core/SkMatrix.cpp
+++ b/src/core/SkMatrix.cpp
@@ -11,15 +11,11 @@
#include "SkOnce.h"
#include "SkString.h"
-#ifdef SK_SCALAR_IS_FLOAT
- #define kMatrix22Elem SK_Scalar1
+#define kMatrix22Elem SK_Scalar1
- static inline float SkDoubleToFloat(double x) {
- return static_cast<float>(x);
- }
-#else
- #define kMatrix22Elem SK_Fract1
-#endif
+static inline float SkDoubleToFloat(double x) {
+ return static_cast<float>(x);
+}
/* [scale-x skew-x trans-x] [X] [X']
[skew-y scale-y trans-y] * [Y] = [Y']
@@ -45,13 +41,7 @@ enum {
kRectStaysRect_Shift
};
-#ifdef SK_SCALAR_IS_FLOAT
- static const int32_t kScalar1Int = 0x3f800000;
-#else
- #define scalarAsInt(x) (x)
- static const int32_t kScalar1Int = (1 << 16);
- static const int32_t kPersp1Int = (1 << 30);
-#endif
+static const int32_t kScalar1Int = 0x3f800000;
uint8_t SkMatrix::computePerspectiveTypeMask() const {
// Benchmarking suggests that replacing this set of SkScalarAs2sCompliment
@@ -133,8 +123,6 @@ uint8_t SkMatrix::computeTypeMask() const {
///////////////////////////////////////////////////////////////////////////////
-#ifdef SK_SCALAR_IS_FLOAT
-
bool operator==(const SkMatrix& a, const SkMatrix& b) {
const SkScalar* SK_RESTRICT ma = a.fMat;
const SkScalar* SK_RESTRICT mb = b.fMat;
@@ -144,8 +132,6 @@ bool operator==(const SkMatrix& a, const SkMatrix& b) {
ma[6] == mb[6] && ma[7] == mb[7] && ma[8] == mb[8];
}
-#endif
-
///////////////////////////////////////////////////////////////////////////////
// helper function to determine if upper-left 2x2 of matrix is degenerate
@@ -612,71 +598,22 @@ 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 = SkDoubleToFloat((double)a * b + (double)c * d);
- return true;
- }
-
- static inline bool rowcol3(const float row[], const float col[],
+static inline int fixmuladdmul(float a, float b, float c, float d,
float* result) {
- *result = row[0] * col[0] + row[1] * col[3] + row[2] * col[6];
- return true;
- }
-
- static inline int negifaddoverflows(float& result, float a, float b) {
- result = a + b;
- return 0;
- }
-#else
- static inline bool fixmuladdmul(SkFixed a, SkFixed b, SkFixed c, SkFixed d,
- SkFixed* result) {
- Sk64 tmp1, tmp2;
- tmp1.setMul(a, b);
- tmp2.setMul(c, d);
- tmp1.add(tmp2);
- if (tmp1.isFixed()) {
- *result = tmp1.getFixed();
- return true;
- }
- return false;
- }
-
- static inline SkFixed fracmuladdmul(SkFixed a, SkFract b, SkFixed c,
- SkFract d) {
- Sk64 tmp1, tmp2;
- tmp1.setMul(a, b);
- tmp2.setMul(c, d);
- tmp1.add(tmp2);
- return tmp1.getFract();
- }
-
- static inline bool rowcol3(const SkFixed row[], const SkFixed col[],
- SkFixed* result) {
- Sk64 tmp1, tmp2;
-
- tmp1.setMul(row[0], col[0]); // N * fixed
- tmp2.setMul(row[1], col[3]); // N * fixed
- tmp1.add(tmp2);
-
- tmp2.setMul(row[2], col[6]); // N * fract
- tmp2.roundRight(14); // make it fixed
- tmp1.add(tmp2);
+ *result = SkDoubleToFloat((double)a * b + (double)c * d);
+ return true;
+}
- if (tmp1.isFixed()) {
- *result = tmp1.getFixed();
- return true;
- }
- return false;
- }
+static inline bool rowcol3(const float row[], const float col[],
+ float* result) {
+ *result = row[0] * col[0] + row[1] * col[3] + row[2] * col[6];
+ return true;
+}
- static inline int negifaddoverflows(SkFixed& result, SkFixed a, SkFixed b) {
- SkFixed c = a + b;
- result = c;
- return (c ^ a) & (c ^ b);
- }
-#endif
+static inline int negifaddoverflows(float& result, float a, float b) {
+ result = a + b;
+ return 0;
+}
static void normalize_perspective(SkScalar mat[9]) {
if (SkScalarAbs(mat[SkMatrix::kMPersp2]) > kMatrix22Elem) {
@@ -793,88 +730,38 @@ bool SkMatrix::postConcat(const SkMatrix& mat) {
precision may be most important (here and matrix concat). Hence to avoid
bitmap blitting artifacts when walking the inverse, we use doubles for
the intermediate math, even though we know that is more expensive.
- The fixed counter part is us using Sk64 for temp calculations.
*/
-#ifdef SK_SCALAR_IS_FLOAT
- typedef double SkDetScalar;
- #define SkPerspMul(a, b) SkScalarMul(a, b)
- #define SkScalarMulShift(a, b, s) SkDoubleToFloat((a) * (b))
- static double sk_inv_determinant(const float mat[9], int isPerspective,
- int* /* (only used in Fixed case) */) {
- double det;
-
- if (isPerspective) {
- det = mat[SkMatrix::kMScaleX] * ((double)mat[SkMatrix::kMScaleY] * mat[SkMatrix::kMPersp2] - (double)mat[SkMatrix::kMTransY] * mat[SkMatrix::kMPersp1]) +
- mat[SkMatrix::kMSkewX] * ((double)mat[SkMatrix::kMTransY] * mat[SkMatrix::kMPersp0] - (double)mat[SkMatrix::kMSkewY] * mat[SkMatrix::kMPersp2]) +
- mat[SkMatrix::kMTransX] * ((double)mat[SkMatrix::kMSkewY] * mat[SkMatrix::kMPersp1] - (double)mat[SkMatrix::kMScaleY] * mat[SkMatrix::kMPersp0]);
- } else {
- det = (double)mat[SkMatrix::kMScaleX] * mat[SkMatrix::kMScaleY] - (double)mat[SkMatrix::kMSkewX] * mat[SkMatrix::kMSkewY];
- }
-
- // Since the determinant is on the order of the cube of the matrix members,
- // compare to the cube of the default nearly-zero constant (although an
- // estimate of the condition number would be better if it wasn't so expensive).
- if (SkScalarNearlyZero((float)det, SK_ScalarNearlyZero * SK_ScalarNearlyZero * SK_ScalarNearlyZero)) {
- return 0;
- }
- return 1.0 / det;
- }
- // 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.
- static float inline mul_diff_scale(double a, double b, double c, double d,
- double scale) {
- return SkDoubleToFloat((a * b - c * d) * scale);
+typedef double SkDetScalar;
+#define SkPerspMul(a, b) SkScalarMul(a, b)
+#define SkScalarMulShift(a, b, s) SkDoubleToFloat((a) * (b))
+static double sk_inv_determinant(const float mat[9], int isPerspective,
+ int* /* (only used in Fixed case) */) {
+ double det;
+
+ if (isPerspective) {
+ det = mat[SkMatrix::kMScaleX] * ((double)mat[SkMatrix::kMScaleY] * mat[SkMatrix::kMPersp2] - (double)mat[SkMatrix::kMTransY] * mat[SkMatrix::kMPersp1]) +
+ mat[SkMatrix::kMSkewX] * ((double)mat[SkMatrix::kMTransY] * mat[SkMatrix::kMPersp0] - (double)mat[SkMatrix::kMSkewY] * mat[SkMatrix::kMPersp2]) +
+ mat[SkMatrix::kMTransX] * ((double)mat[SkMatrix::kMSkewY] * mat[SkMatrix::kMPersp1] - (double)mat[SkMatrix::kMScaleY] * mat[SkMatrix::kMPersp0]);
+ } else {
+ det = (double)mat[SkMatrix::kMScaleX] * mat[SkMatrix::kMScaleY] - (double)mat[SkMatrix::kMSkewX] * mat[SkMatrix::kMSkewY];
}
-#else
- typedef SkFixed SkDetScalar;
- #define SkPerspMul(a, b) SkFractMul(a, b)
- #define SkScalarMulShift(a, b, s) SkMulShift(a, b, s)
- static void set_muladdmul(Sk64* dst, int32_t a, int32_t b, int32_t c,
- int32_t d) {
- Sk64 tmp;
- dst->setMul(a, b);
- tmp.setMul(c, d);
- dst->add(tmp);
- }
-
- static SkFixed sk_inv_determinant(const SkFixed mat[9], int isPerspective,
- int* shift) {
- Sk64 tmp1, tmp2;
-
- if (isPerspective) {
- tmp1.setMul(mat[SkMatrix::kMScaleX], fracmuladdmul(mat[SkMatrix::kMScaleY], mat[SkMatrix::kMPersp2], -mat[SkMatrix::kMTransY], mat[SkMatrix::kMPersp1]));
- tmp2.setMul(mat[SkMatrix::kMSkewX], fracmuladdmul(mat[SkMatrix::kMTransY], mat[SkMatrix::kMPersp0], -mat[SkMatrix::kMSkewY], mat[SkMatrix::kMPersp2]));
- tmp1.add(tmp2);
- tmp2.setMul(mat[SkMatrix::kMTransX], fracmuladdmul(mat[SkMatrix::kMSkewY], mat[SkMatrix::kMPersp1], -mat[SkMatrix::kMScaleY], mat[SkMatrix::kMPersp0]));
- tmp1.add(tmp2);
- } else {
- tmp1.setMul(mat[SkMatrix::kMScaleX], mat[SkMatrix::kMScaleY]);
- tmp2.setMul(mat[SkMatrix::kMSkewX], mat[SkMatrix::kMSkewY]);
- tmp1.sub(tmp2);
- }
-
- int s = tmp1.getClzAbs();
- *shift = s;
-
- SkFixed denom;
- if (s <= 32) {
- denom = tmp1.getShiftRight(33 - s);
- } else {
- denom = (int32_t)tmp1.fLo << (s - 33);
- }
- if (denom == 0) {
- return 0;
- }
- /** This could perhaps be a special fractdiv function, since both of its
- arguments are known to have bit 31 clear and bit 30 set (when they
- are made positive), thus eliminating the need for calling clz()
- */
- return SkFractDiv(SK_Fract1, denom);
+ // Since the determinant is on the order of the cube of the matrix members,
+ // compare to the cube of the default nearly-zero constant (although an
+ // estimate of the condition number would be better if it wasn't so expensive).
+ if (SkScalarNearlyZero((float)det, SK_ScalarNearlyZero * SK_ScalarNearlyZero * SK_ScalarNearlyZero)) {
+ return 0;
}
-#endif
+ return 1.0 / det;
+}
+// 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.
+static float inline mul_diff_scale(double a, double b, double c, double d,
+ double scale) {
+ return SkDoubleToFloat((a * b - c * d) * scale);
+}
void SkMatrix::SetAffineIdentity(SkScalar affine[6]) {
affine[kAScaleX] = SK_Scalar1;
@@ -1955,14 +1842,8 @@ void SkMatrix::dump() const {
void SkMatrix::toString(SkString* str) const {
str->appendf("[%8.4f %8.4f %8.4f][%8.4f %8.4f %8.4f][%8.4f %8.4f %8.4f]",
-#ifdef SK_SCALAR_IS_FLOAT
fMat[0], fMat[1], fMat[2], fMat[3], fMat[4], fMat[5],
fMat[6], fMat[7], fMat[8]);
-#else
- SkFixedToFloat(fMat[0]), SkFixedToFloat(fMat[1]), SkFixedToFloat(fMat[2]),
- SkFixedToFloat(fMat[3]), SkFixedToFloat(fMat[4]), SkFixedToFloat(fMat[5]),
- SkFractToFloat(fMat[6]), SkFractToFloat(fMat[7]), SkFractToFloat(fMat[8]));
-#endif
}
#endif
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp
index 91a76e151f..94ffa8d31b 100644
--- a/src/core/SkPaint.cpp
+++ b/src/core/SkPaint.cpp
@@ -1010,16 +1010,9 @@ static void set_bounds(const SkGlyph& g, SkRect* bounds) {
// we don't overflow along the way
typedef int64_t Sk48Dot16;
-#ifdef SK_SCALAR_IS_FLOAT
- static inline float Sk48Dot16ToScalar(Sk48Dot16 x) {
- return (float) (x * 1.5258789e-5); // x * (1 / 65536.0f)
- }
-#else
- static inline SkFixed Sk48Dot16ToScalar(Sk48Dot16 x) {
- // just return the low 32bits
- return static_cast<SkFixed>(x);
- }
-#endif
+static inline float Sk48Dot16ToScalar(Sk48Dot16 x) {
+ return (float) (x * 1.5258789e-5); // x * (1 / 65536.0f)
+}
static void join_bounds_x(const SkGlyph& g, SkRect* bounds, Sk48Dot16 dx) {
SkScalar sx = Sk48Dot16ToScalar(dx);
@@ -1556,13 +1549,8 @@ static bool tooBigForLCD(const SkScalerContext::Rec& rec) {
* typically returns the same looking resuts for tiny changes in the matrix.
*/
static SkScalar sk_relax(SkScalar x) {
-#ifdef SK_SCALAR_IS_FLOAT
int n = sk_float_round2int(x * 1024);
return n / 1024.0f;
-#else
- // round to the nearest 10 fractional bits
- return (x + (1 << 5)) & ~(1024 - 1);
-#endif
}
void SkScalerContext::MakeRec(const SkPaint& paint,
diff --git a/src/core/SkPathMeasure.cpp b/src/core/SkPathMeasure.cpp
index c519f93dce..48f7571c07 100644
--- a/src/core/SkPathMeasure.cpp
+++ b/src/core/SkPathMeasure.cpp
@@ -23,12 +23,7 @@ enum {
static inline SkScalar tValue2Scalar(int t) {
SkASSERT((unsigned)t <= kMaxTValue);
-
-#ifdef SK_SCALAR_IS_FLOAT
return t * 3.05185e-5f; // t / 32767
-#else
- return (t + (t >> 14)) << 1;
-#endif
}
SkScalar SkPathMeasure::Segment::getScalarT() const {
diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp
index 2b9b9e934c..15eb137525 100644
--- a/src/core/SkPicture.cpp
+++ b/src/core/SkPicture.cpp
@@ -338,9 +338,9 @@ void SkPicture::serialize(SkWStream* stream, EncodeBitmap encoder) const {
info.fWidth = fWidth;
info.fHeight = fHeight;
info.fFlags = SkPictInfo::kCrossProcess_Flag;
-#ifdef SK_SCALAR_IS_FLOAT
+ // TODO: remove this flag, since we're always float (now)
info.fFlags |= SkPictInfo::kScalarIsFloat_Flag;
-#endif
+
if (8 == sizeof(void*)) {
info.fFlags |= SkPictInfo::kPtrIs64Bit_Flag;
}
diff --git a/src/core/SkRect.cpp b/src/core/SkRect.cpp
index 97de0a6a4a..bb51ede757 100644
--- a/src/core/SkRect.cpp
+++ b/src/core/SkRect.cpp
@@ -55,21 +55,6 @@ void SkRect::toQuad(SkPoint quad[4]) const {
quad[3].set(fLeft, fBottom);
}
-#ifdef SK_SCALAR_IS_FLOAT
- #define SkFLOATCODE(code) code
-#else
- #define SkFLOATCODE(code)
-#endif
-
-// For float compares (at least on x86, by removing the else from the min/max
-// computation, we get MAXSS and MINSS instructions, and no branches.
-// Fixed point has no such opportunity (afaik), so we leave the else in that case
-#ifdef SK_SCALAR_IS_FLOAT
- #define MINMAX_ELSE
-#else
- #define MINMAX_ELSE else
-#endif
-
bool SkRect::setBoundsCheck(const SkPoint pts[], int count) {
SkASSERT((pts && count > 0) || count == 0);
@@ -85,17 +70,22 @@ bool SkRect::setBoundsCheck(const SkPoint pts[], int count) {
// If all of the points are finite, accum should stay 0. If we encounter
// a NaN or infinity, then accum should become NaN.
- SkFLOATCODE(float accum = 0;)
- SkFLOATCODE(accum *= l; accum *= t;)
+ float accum = 0;
+ accum *= l; accum *= t;
for (int i = 1; i < count; i++) {
SkScalar x = pts[i].fX;
SkScalar y = pts[i].fY;
- SkFLOATCODE(accum *= x; accum *= y;)
+ accum *= x; accum *= y;
+
+ // we use if instead of if/else, so we can generate min/max
+ // float instructions (at least on SSE)
+ if (x < l) l = x;
+ if (x > r) r = x;
- if (x < l) l = x; MINMAX_ELSE if (x > r) r = x;
- if (y < t) t = y; MINMAX_ELSE if (y > b) b = y;
+ if (y < t) t = y;
+ if (y > b) b = y;
}
SkASSERT(!accum || !SkScalarIsFinite(accum));
diff --git a/src/core/SkScan.cpp b/src/core/SkScan.cpp
index 44968bd9ec..b21dd6bf9c 100644
--- a/src/core/SkScan.cpp
+++ b/src/core/SkScan.cpp
@@ -53,8 +53,6 @@ void SkScan::FillXRect(const SkXRect& xr, const SkRegion* clip,
SkScan::FillIRect(r, clip, blitter);
}
-#ifdef SK_SCALAR_IS_FLOAT
-
void SkScan::FillRect(const SkRect& r, const SkRegion* clip,
SkBlitter* blitter) {
SkIRect ir;
@@ -63,8 +61,6 @@ void SkScan::FillRect(const SkRect& r, const SkRegion* clip,
SkScan::FillIRect(ir, clip, blitter);
}
-#endif
-
///////////////////////////////////////////////////////////////////////////////
void SkScan::FillIRect(const SkIRect& r, const SkRasterClip& clip,
@@ -97,8 +93,6 @@ void SkScan::FillXRect(const SkXRect& xr, const SkRasterClip& clip,
FillXRect(xr, &wrapper.getRgn(), wrapper.getBlitter());
}
-#ifdef SK_SCALAR_IS_FLOAT
-
void SkScan::FillRect(const SkRect& r, const SkRasterClip& clip,
SkBlitter* blitter) {
if (clip.isEmpty() || r.isEmpty()) {
@@ -113,5 +107,3 @@ void SkScan::FillRect(const SkRect& r, const SkRasterClip& clip,
SkAAClipBlitterWrapper wrapper(clip, blitter);
FillRect(r, &wrapper.getRgn(), wrapper.getBlitter());
}
-
-#endif
diff --git a/src/core/SkScan.h b/src/core/SkScan.h
index 5989435d29..0780e332a3 100644
--- a/src/core/SkScan.h
+++ b/src/core/SkScan.h
@@ -31,19 +31,8 @@ public:
static void FillIRect(const SkIRect&, const SkRasterClip&, SkBlitter*);
static void FillXRect(const SkXRect&, const SkRasterClip&, SkBlitter*);
-#ifdef SK_SCALAR_IS_FIXED
- static void FillRect(const SkRect& rect, const SkRasterClip& clip,
- SkBlitter* blitter) {
- SkScan::FillXRect(*(const SkXRect*)&rect, clip, blitter);
- }
- static void AntiFillRect(const SkRect& rect, const SkRasterClip& clip,
- SkBlitter* blitter) {
- SkScan::AntiFillXRect(*(const SkXRect*)&rect, clip, blitter);
- }
-#else
static void FillRect(const SkRect&, const SkRasterClip&, SkBlitter*);
static void AntiFillRect(const SkRect&, const SkRasterClip&, SkBlitter*);
-#endif
static void AntiFillXRect(const SkXRect&, const SkRasterClip&, SkBlitter*);
static void FillPath(const SkPath&, const SkRasterClip&, SkBlitter*);
static void AntiFillPath(const SkPath&, const SkRasterClip&, SkBlitter*);
@@ -67,19 +56,8 @@ private:
static void FillIRect(const SkIRect&, const SkRegion* clip, SkBlitter*);
static void FillXRect(const SkXRect&, const SkRegion* clip, SkBlitter*);
-#ifdef SK_SCALAR_IS_FIXED
- static void FillRect(const SkRect& rect, const SkRegion* clip,
- SkBlitter* blitter) {
- SkScan::FillXRect(*(const SkXRect*)&rect, clip, blitter);
- }
- static void AntiFillRect(const SkRect& rect, const SkRegion* clip,
- SkBlitter* blitter) {
- SkScan::AntiFillXRect(*(const SkXRect*)&rect, clip, blitter);
- }
-#else
static void FillRect(const SkRect&, const SkRegion* clip, SkBlitter*);
static void AntiFillRect(const SkRect&, const SkRegion* clip, SkBlitter*);
-#endif
static void AntiFillXRect(const SkXRect&, const SkRegion*, SkBlitter*);
static void FillPath(const SkPath&, const SkRegion& clip, SkBlitter*);
static void AntiFillPath(const SkPath&, const SkRegion& clip, SkBlitter*,
diff --git a/src/core/SkScan_AntiPath.cpp b/src/core/SkScan_AntiPath.cpp
index 0d2152c7c1..e5c67a958a 100644
--- a/src/core/SkScan_AntiPath.cpp
+++ b/src/core/SkScan_AntiPath.cpp
@@ -589,13 +589,8 @@ static int rect_overflows_short_shift(SkIRect rect, int shift) {
}
static bool safeRoundOut(const SkRect& src, SkIRect* dst, int32_t maxInt) {
-#ifdef SK_SCALAR_IS_FIXED
- // the max-int (shifted) is exactly what we want to compare against, to know
- // if we can survive shifting our fixed-point coordinates
- const SkFixed maxScalar = maxInt;
-#else
const SkScalar maxScalar = SkIntToScalar(maxInt);
-#endif
+
if (fitsInsideLimit(src, maxScalar)) {
src.roundOut(dst);
return true;
diff --git a/src/core/SkScan_Antihair.cpp b/src/core/SkScan_Antihair.cpp
index a6a0869f22..175f085f91 100644
--- a/src/core/SkScan_Antihair.cpp
+++ b/src/core/SkScan_Antihair.cpp
@@ -602,7 +602,6 @@ void SkScan::AntiHairLineRgn(const SkPoint& pt0, const SkPoint& pt1,
SkPoint pts[2] = { pt0, pt1 };
-#ifdef SK_SCALAR_IS_FLOAT
// We have to pre-clip the line to fit in a SkFixed, so we just chop
// the line. TODO find a way to actually draw beyond that range.
{
@@ -613,7 +612,6 @@ void SkScan::AntiHairLineRgn(const SkPoint& pt0, const SkPoint& pt1,
return;
}
}
-#endif
if (clip) {
SkRect clipBounds;
@@ -828,8 +826,6 @@ void SkScan::AntiFillXRect(const SkXRect& xr, const SkRasterClip& clip,
}
}
-#ifdef SK_SCALAR_IS_FLOAT
-
/* This guy takes a float-rect, but with the key improvement that it has
already been clipped, so we know that it is safe to convert it into a
XRect (fixedpoint), as it won't overflow.
@@ -888,8 +884,6 @@ void SkScan::AntiFillRect(const SkRect& r, const SkRasterClip& clip,
}
}
-#endif // SK_SCALAR_IS_FLOAT
-
///////////////////////////////////////////////////////////////////////////////
#define SkAlphaMulRound(a, b) SkMulDiv255Round(a, b)
@@ -902,11 +896,7 @@ static void fillcheckrect(int L, int T, int R, int B, SkBlitter* blitter) {
}
static inline FDot8 SkScalarToFDot8(SkScalar x) {
-#ifdef SK_SCALAR_IS_FLOAT
return (int)(x * 256);
-#else
- return x >> 8;
-#endif
}
static inline int FDot8Floor(FDot8 x) {
diff --git a/src/core/SkScan_Hairline.cpp b/src/core/SkScan_Hairline.cpp
index f440d32613..3b0f152a4f 100644
--- a/src/core/SkScan_Hairline.cpp
+++ b/src/core/SkScan_Hairline.cpp
@@ -47,7 +47,6 @@ void SkScan::HairLineRgn(const SkPoint& pt0, const SkPoint& pt1,
SkIRect clipR, ptsR;
SkPoint pts[2] = { pt0, pt1 };
-#ifdef SK_SCALAR_IS_FLOAT
// We have to pre-clip the line to fit in a SkFixed, so we just chop
// the line. TODO find a way to actually draw beyond that range.
{
@@ -58,7 +57,6 @@ void SkScan::HairLineRgn(const SkPoint& pt0, const SkPoint& pt1,
return;
}
}
-#endif
if (clip) {
// Perform a clip in scalar space, so we catch huge values which might
diff --git a/src/core/SkStrokerPriv.cpp b/src/core/SkStrokerPriv.cpp
index 269ebd3dbd..ad9c0c4d6f 100644
--- a/src/core/SkStrokerPriv.cpp
+++ b/src/core/SkStrokerPriv.cpp
@@ -153,11 +153,7 @@ static void RoundJoiner(SkPath* outer, SkPath* inner, const SkVector& beforeUnit
}
}
-#ifdef SK_SCALAR_IS_FLOAT
- #define kOneOverSqrt2 (0.707106781f)
-#else
- #define kOneOverSqrt2 (46341)
-#endif
+#define kOneOverSqrt2 (0.707106781f)
static void MiterJoiner(SkPath* outer, SkPath* inner, const SkVector& beforeUnitNormal,
const SkPoint& pivot, const SkVector& afterUnitNormal,
diff --git a/src/effects/SkArithmeticMode.cpp b/src/effects/SkArithmeticMode.cpp
index 2cec1536fe..93d708a98b 100644
--- a/src/effects/SkArithmeticMode.cpp
+++ b/src/effects/SkArithmeticMode.cpp
@@ -184,25 +184,12 @@ void SkArithmeticMode_scalar::toString(SkString* str) const {
///////////////////////////////////////////////////////////////////////////////
static bool fitsInBits(SkScalar x, int bits) {
-#ifdef SK_SCALAR_IS_FIXED
- x = SkAbs32(x);
- x += 1 << 7;
- x >>= 8;
- return x < (1 << (bits - 1));
-#else
return SkScalarAbs(x) < (1 << (bits - 1));
-#endif
}
#if 0 // UNUSED
static int32_t toDot8(SkScalar x) {
-#ifdef SK_SCALAR_IS_FIXED
- x += 1 << 7;
- x >>= 8;
- return x;
-#else
return (int32_t)(x * 256);
-#endif
}
#endif
diff --git a/src/effects/gradients/SkSweepGradient.cpp b/src/effects/gradients/SkSweepGradient.cpp
index c38205b844..d60d8b6050 100644
--- a/src/effects/gradients/SkSweepGradient.cpp
+++ b/src/effects/gradients/SkSweepGradient.cpp
@@ -52,178 +52,7 @@ void SkSweepGradient::flatten(SkFlattenableWriteBuffer& buffer) const {
buffer.writePoint(fCenter);
}
-#ifndef SK_SCALAR_IS_FLOAT
-#ifdef COMPUTE_SWEEP_TABLE
-#define PI 3.14159265
-static bool gSweepTableReady;
-static uint8_t gSweepTable[65];
-
-/* Our table stores precomputed values for atan: [0...1] -> [0..PI/4]
- We scale the results to [0..32]
-*/
-static const uint8_t* build_sweep_table() {
- if (!gSweepTableReady) {
- const int N = 65;
- const double DENOM = N - 1;
-
- for (int i = 0; i < N; i++)
- {
- double arg = i / DENOM;
- double v = atan(arg);
- int iv = (int)round(v * DENOM * 2 / PI);
-// printf("[%d] atan(%g) = %g %d\n", i, arg, v, iv);
- printf("%d, ", iv);
- gSweepTable[i] = iv;
- }
- gSweepTableReady = true;
- }
- return gSweepTable;
-}
-#else
-static const uint8_t gSweepTable[] = {
- 0, 1, 1, 2, 3, 3, 4, 4, 5, 6, 6, 7, 8, 8, 9, 9,
- 10, 11, 11, 12, 12, 13, 13, 14, 15, 15, 16, 16, 17, 17, 18, 18,
- 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 25, 26,
- 26, 27, 27, 27, 28, 28, 29, 29, 29, 30, 30, 30, 31, 31, 31, 32,
- 32
-};
-static const uint8_t* build_sweep_table() { return gSweepTable; }
-#endif
-#endif
-
-// divide numer/denom, with a bias of 6bits. Assumes numer <= denom
-// and denom != 0. Since our table is 6bits big (+1), this is a nice fit.
-// Same as (but faster than) SkFixedDiv(numer, denom) >> 10
-
-//unsigned div_64(int numer, int denom);
-#ifndef SK_SCALAR_IS_FLOAT
-static unsigned div_64(int numer, int denom) {
- SkASSERT(numer <= denom);
- SkASSERT(numer > 0);
- SkASSERT(denom > 0);
-
- int nbits = SkCLZ(numer);
- int dbits = SkCLZ(denom);
- int bits = 6 - nbits + dbits;
- SkASSERT(bits <= 6);
-
- if (bits < 0) { // detect underflow
- return 0;
- }
-
- denom <<= dbits - 1;
- numer <<= nbits - 1;
-
- unsigned result = 0;
-
- // do the first one
- if ((numer -= denom) >= 0) {
- result = 1;
- } else {
- numer += denom;
- }
-
- // Now fall into our switch statement if there are more bits to compute
- if (bits > 0) {
- // make room for the rest of the answer bits
- result <<= bits;
- switch (bits) {
- case 6:
- if ((numer = (numer << 1) - denom) >= 0)
- result |= 32;
- else
- numer += denom;
- case 5:
- if ((numer = (numer << 1) - denom) >= 0)
- result |= 16;
- else
- numer += denom;
- case 4:
- if ((numer = (numer << 1) - denom) >= 0)
- result |= 8;
- else
- numer += denom;
- case 3:
- if ((numer = (numer << 1) - denom) >= 0)
- result |= 4;
- else
- numer += denom;
- case 2:
- if ((numer = (numer << 1) - denom) >= 0)
- result |= 2;
- else
- numer += denom;
- case 1:
- default: // not strictly need, but makes GCC make better ARM code
- if ((numer = (numer << 1) - denom) >= 0)
- result |= 1;
- else
- numer += denom;
- }
- }
- return result;
-}
-#endif
-
-// Given x,y in the first quadrant, return 0..63 for the angle [0..90]
-#ifndef SK_SCALAR_IS_FLOAT
-static unsigned atan_0_90(SkFixed y, SkFixed x) {
-#ifdef SK_DEBUG
- {
- static bool gOnce;
- if (!gOnce) {
- gOnce = true;
- SkASSERT(div_64(55, 55) == 64);
- SkASSERT(div_64(128, 256) == 32);
- SkASSERT(div_64(2326528, 4685824) == 31);
- SkASSERT(div_64(753664, 5210112) == 9);
- SkASSERT(div_64(229376, 4882432) == 3);
- SkASSERT(div_64(2, 64) == 2);
- SkASSERT(div_64(1, 64) == 1);
- // test that we handle underflow correctly
- SkASSERT(div_64(12345, 0x54321234) == 0);
- }
- }
-#endif
-
- SkASSERT(y > 0 && x > 0);
- const uint8_t* table = build_sweep_table();
-
- unsigned result;
- bool swap = (x < y);
- if (swap) {
- // first part of the atan(v) = PI/2 - atan(1/v) identity
- // since our div_64 and table want v <= 1, where v = y/x
- SkTSwap<SkFixed>(x, y);
- }
-
- result = div_64(y, x);
-
-#ifdef SK_DEBUG
- {
- unsigned result2 = SkDivBits(y, x, 6);
- SkASSERT(result2 == result ||
- (result == 1 && result2 == 0));
- }
-#endif
-
- SkASSERT(result < SK_ARRAY_COUNT(gSweepTable));
- result = table[result];
-
- if (swap) {
- // complete the atan(v) = PI/2 - atan(1/v) identity
- result = 64 - result;
- // pin to 63
- result -= result >> 6;
- }
-
- SkASSERT(result <= 63);
- return result;
-}
-#endif
-
// returns angle in a circle [0..2PI) -> [0..255]
-#ifdef SK_SCALAR_IS_FLOAT
static unsigned SkATan2_255(float y, float x) {
// static const float g255Over2PI = 255 / (2 * SK_ScalarPI);
static const float g255Over2PI = 40.584510488433314f;
@@ -239,62 +68,6 @@ static unsigned SkATan2_255(float y, float x) {
SkASSERT(ir >= 0 && ir <= 255);
return ir;
}
-#else
-static unsigned SkATan2_255(SkFixed y, SkFixed x) {
- if (x == 0) {
- if (y == 0) {
- return 0;
- }
- return y < 0 ? 192 : 64;
- }
- if (y == 0) {
- return x < 0 ? 128 : 0;
- }
-
- /* Find the right quadrant for x,y
- Since atan_0_90 only handles the first quadrant, we rotate x,y
- appropriately before calling it, and then add the right amount
- to account for the real quadrant.
- quadrant 0 : add 0 | x > 0 && y > 0
- quadrant 1 : add 64 (90 degrees) | x < 0 && y > 0
- quadrant 2 : add 128 (180 degrees) | x < 0 && y < 0
- quadrant 3 : add 192 (270 degrees) | x > 0 && y < 0
-
- map x<0 to (1 << 6)
- map y<0 to (3 << 6)
- add = map_x ^ map_y
- */
- int xsign = x >> 31;
- int ysign = y >> 31;
- int add = ((-xsign) ^ (ysign & 3)) << 6;
-
-#ifdef SK_DEBUG
- if (0 == add)
- SkASSERT(x > 0 && y > 0);
- else if (64 == add)
- SkASSERT(x < 0 && y > 0);
- else if (128 == add)
- SkASSERT(x < 0 && y < 0);
- else if (192 == add)
- SkASSERT(x > 0 && y < 0);
- else
- SkDEBUGFAIL("bad value for add");
-#endif
-
- /* This ^ trick makes x, y positive, and the swap<> handles quadrants
- where we need to rotate x,y by 90 or -90
- */
- x = (x ^ xsign) - xsign;
- y = (y ^ ysign) - ysign;
- if (add & 64) { // quads 1 or 3 need to swap x,y
- SkTSwap<SkFixed>(x, y);
- }
-
- unsigned result = add + atan_0_90(y, x);
- SkASSERT(result < 256);
- return result;
-}
-#endif
void SkSweepGradient::shadeSpan(int x, int y, SkPMColor* SK_RESTRICT dstC,
int count) {
diff --git a/src/gpu/GrAAHairLinePathRenderer.cpp b/src/gpu/GrAAHairLinePathRenderer.cpp
index 2b5428c47d..830f513e6c 100644
--- a/src/gpu/GrAAHairLinePathRenderer.cpp
+++ b/src/gpu/GrAAHairLinePathRenderer.cpp
@@ -300,19 +300,10 @@ int num_quad_subdivs(const SkPoint p[3]) {
// = log4(d*d/tol*tol)/2
// = log2(d*d/tol*tol)
-#ifdef SK_SCALAR_IS_FLOAT
// +1 since we're ignoring the mantissa contribution.
int log = get_float_exp(dsqd/(gSubdivTol*gSubdivTol)) + 1;
log = GrMin(GrMax(0, log), kMaxSub);
return log;
-#else
- SkScalar log = SkScalarLog(
- SkScalarDiv(dsqd,
- SkScalarMul(gSubdivTol, gSubdivTol)));
- static const SkScalar conv = SkScalarInvert(SkScalarLog(2));
- log = SkScalarMul(log, conv);
- return GrMin(GrMax(0, SkScalarCeilToInt(log)),kMaxSub);
-#endif
}
}
diff --git a/src/gpu/GrPathUtils.cpp b/src/gpu/GrPathUtils.cpp
index e2b1ac7634..8b06daf2b6 100644
--- a/src/gpu/GrPathUtils.cpp
+++ b/src/gpu/GrPathUtils.cpp
@@ -187,9 +187,6 @@ int GrPathUtils::worstCasePointCount(const SkPath& path, int* subpaths,
}
void GrPathUtils::QuadUVMatrix::set(const GrPoint qPts[3]) {
-#ifndef SK_SCALAR_IS_FLOAT
- GrCrash("Expected scalar is float.");
-#endif
SkMatrix m;
// We want M such that M * xy_pt = uv_pt
// We know M * control_pts = [0 1/2 1]
diff --git a/src/gpu/gl/GrGLPath.cpp b/src/gpu/gl/GrGLPath.cpp
index a749e410bd..514c8c738c 100644
--- a/src/gpu/gl/GrGLPath.cpp
+++ b/src/gpu/gl/GrGLPath.cpp
@@ -87,9 +87,6 @@ static const bool kIsWrapped = false; // The constructor creates the GL path obj
GrGLPath::GrGLPath(GrGpuGL* gpu, const SkPath& path, const SkStrokeRec& stroke)
: INHERITED(gpu, kIsWrapped, path, stroke) {
-#ifndef SK_SCALAR_IS_FLOAT
- GrCrash("Assumes scalar is float.");
-#endif
SkASSERT(!path.isEmpty());
GL_CALL_RET(fPathID, GenPaths(1));
diff --git a/src/gpu/gl/GrGLUniformManager.cpp b/src/gpu/gl/GrGLUniformManager.cpp
index 2d0b48a2be..674118b749 100644
--- a/src/gpu/gl/GrGLUniformManager.cpp
+++ b/src/gpu/gl/GrGLUniformManager.cpp
@@ -233,7 +233,6 @@ void GrGLUniformManager::setMatrix4fv(UniformHandle u,
}
void GrGLUniformManager::setSkMatrix(UniformHandle u, const SkMatrix& matrix) const {
-// GR_STATIC_ASSERT(SK_SCALAR_IS_FLOAT);
GrGLfloat mt[] = {
matrix.get(SkMatrix::kMScaleX),
matrix.get(SkMatrix::kMSkewY),
diff --git a/src/pdf/SkPDFTypes.cpp b/src/pdf/SkPDFTypes.cpp
index 55871c507d..aafad79c44 100644
--- a/src/pdf/SkPDFTypes.cpp
+++ b/src/pdf/SkPDFTypes.cpp
@@ -140,12 +140,6 @@ void SkPDFScalar::Append(SkScalar value, SkWStream* stream) {
// When using floats that are outside the whole value range, we can use
// integers instead.
-
-#if defined(SK_SCALAR_IS_FIXED)
- stream->writeScalarAsText(value);
- return;
-#endif // SK_SCALAR_IS_FIXED
-
#if !defined(SK_ALLOW_LARGE_PDF_SCALARS)
if (value > 32767 || value < -32767) {
stream->writeDecAsText(SkScalarRound(value));
@@ -158,7 +152,7 @@ void SkPDFScalar::Append(SkScalar value, SkWStream* stream) {
return;
#endif // !SK_ALLOW_LARGE_PDF_SCALARS
-#if defined(SK_SCALAR_IS_FLOAT) && defined(SK_ALLOW_LARGE_PDF_SCALARS)
+#if defined(SK_ALLOW_LARGE_PDF_SCALARS)
// Floats have 24bits of significance, so anything outside that range is
// no more precise than an int. (Plus PDF doesn't support scientific
// notation, so this clamps to SK_Max/MinS32).
@@ -185,7 +179,7 @@ void SkPDFScalar::Append(SkScalar value, SkWStream* stream) {
}
stream->writeText(buffer);
return;
-#endif // SK_SCALAR_IS_FLOAT && SK_ALLOW_LARGE_PDF_SCALARS
+#endif // SK_ALLOW_LARGE_PDF_SCALARS
}
SkPDFString::SkPDFString(const char value[])
diff --git a/src/ports/SkHarfBuzzFont.cpp b/src/ports/SkHarfBuzzFont.cpp
index 8f483f5d2f..95b9e445a0 100644
--- a/src/ports/SkHarfBuzzFont.cpp
+++ b/src/ports/SkHarfBuzzFont.cpp
@@ -14,12 +14,7 @@
// HB_Fixed is a 26.6 fixed point format.
static inline HB_Fixed SkScalarToHarfbuzzFixed(SkScalar value) {
-#ifdef SK_SCALAR_IS_FLOAT
return static_cast<HB_Fixed>(value * 64);
-#else
- // convert .16 to .6
- return value >> (16 - 6);
-#endif
}
static HB_Bool stringToGlyphs(HB_Font hbFont, const HB_UChar16* characters,
diff --git a/src/utils/SkCamera.cpp b/src/utils/SkCamera.cpp
index f5b51d5259..2e2031e386 100644
--- a/src/utils/SkCamera.cpp
+++ b/src/utils/SkCamera.cpp
@@ -12,7 +12,6 @@
static SkScalar SkScalarDotDiv(int count, const SkScalar a[], int step_a,
const SkScalar b[], int step_b,
SkScalar denom) {
-#ifdef SK_SCALAR_IS_FLOAT
float prod = 0;
for (int i = 0; i < count; i++) {
prod += a[0] * b[0];
@@ -20,24 +19,10 @@ static SkScalar SkScalarDotDiv(int count, const SkScalar a[], int step_a,
b += step_b;
}
return prod / denom;
-#else
- Sk64 prod, tmp;
-
- prod.set(0);
- for (int i = 0; i < count; i++) {
- tmp.setMul(a[0], b[0]);
- prod.add(tmp);
- a += step_a;
- b += step_b;
- }
- prod.div(denom, Sk64::kRound_DivOption);
- return prod.get32();
-#endif
}
static SkScalar SkScalarDot(int count, const SkScalar a[], int step_a,
const SkScalar b[], int step_b) {
-#ifdef SK_SCALAR_IS_FLOAT
float prod = 0;
for (int i = 0; i < count; i++) {
prod += a[0] * b[0];
@@ -45,24 +30,11 @@ static SkScalar SkScalarDot(int count, const SkScalar a[], int step_a,
b += step_b;
}
return prod;
-#else
- Sk64 prod, tmp;
-
- prod.set(0);
- for (int i = 0; i < count; i++) {
- tmp.setMul(a[0], b[0]);
- prod.add(tmp);
- a += step_a;
- b += step_b;
- }
- return prod.getFixed();
-#endif
}
///////////////////////////////////////////////////////////////////////////////
SkUnitScalar SkPoint3D::normalize(SkUnit3D* unit) const {
-#ifdef SK_SCALAR_IS_FLOAT
float mag = sk_float_sqrt(fX*fX + fY*fY + fZ*fZ);
if (mag) {
float scale = 1.0f / mag;
@@ -72,26 +44,6 @@ SkUnitScalar SkPoint3D::normalize(SkUnit3D* unit) const {
} else {
unit->fX = unit->fY = unit->fZ = 0;
}
-#else
- Sk64 tmp1, tmp2;
-
- tmp1.setMul(fX, fX);
- tmp2.setMul(fY, fY);
- tmp1.add(tmp2);
- tmp2.setMul(fZ, fZ);
- tmp1.add(tmp2);
-
- SkFixed mag = tmp1.getSqrt();
- if (mag) {
- // what if mag < SK_Fixed1 ??? we will underflow the fixdiv
- SkFixed scale = SkFixedDiv(SK_Fract1, mag);
- unit->fX = SkFixedMul(fX, scale);
- unit->fY = SkFixedMul(fY, scale);
- unit->fZ = SkFixedMul(fZ, scale);
- } else {
- unit->fX = unit->fY = unit->fZ = 0;
- }
-#endif
return mag;
}
diff --git a/src/utils/SkInterpolator.cpp b/src/utils/SkInterpolator.cpp
index 2853b0703a..595e46402d 100644
--- a/src/utils/SkInterpolator.cpp
+++ b/src/utils/SkInterpolator.cpp
@@ -155,11 +155,7 @@ void SkInterpolator::reset(int elemCount, int frameCount) {
#define SK_Fixed2Third (SK_Fixed1*2/3)
static const SkScalar gIdentityBlend[4] = {
-#ifdef SK_SCALAR_IS_FLOAT
0.33333333f, 0.33333333f, 0.66666667f, 0.66666667f
-#else
- SK_Fixed1Third, SK_Fixed1Third, SK_Fixed2Third, SK_Fixed2Third
-#endif
};
bool SkInterpolator::setKeyFrame(int index, SkMSec time,
diff --git a/src/utils/SkParse.cpp b/src/utils/SkParse.cpp
index 9609ddc568..f6e2a438e8 100644
--- a/src/utils/SkParse.cpp
+++ b/src/utils/SkParse.cpp
@@ -201,7 +201,7 @@ const char* SkParse::FindMSec(const char str[], SkMSec* value)
const char* SkParse::FindScalar(const char str[], SkScalar* value) {
SkASSERT(str);
str = skip_ws(str);
-#ifdef SK_SCALAR_IS_FLOAT
+
char* stop;
float v = (float)strtod(str, &stop);
if (str == stop) {
@@ -211,49 +211,6 @@ const char* SkParse::FindScalar(const char str[], SkScalar* value) {
*value = v;
}
return stop;
-#else
- int sign = 0;
- if (*str == '-')
- {
- sign = -1;
- str += 1;
- }
-
- if (!is_digit(*str) && *str != '.')
- return NULL;
-
- int n = 0;
- while (is_digit(*str))
- {
- n = 10*n + *str - '0';
- if (n > 0x7FFF)
- return NULL;
- str += 1;
- }
- n <<= 16;
-
- if (*str == '.')
- {
- static const int gFractions[] = { (1 << 24) / 10, (1 << 24) / 100, (1 << 24) / 1000,
- (1 << 24) / 10000, (1 << 24) / 100000 };
- str += 1;
- int d = 0;
- const int* fraction = gFractions;
- const int* end = &fraction[SK_ARRAY_COUNT(gFractions)];
- while (is_digit(*str) && fraction < end)
- d += (*str++ - '0') * *fraction++;
- d += 0x80; // round
- n += d >> 8;
- }
- while (is_digit(*str))
- str += 1;
- if (value)
- {
- n = (n ^ sign) - sign; // apply the sign
- *value = SkFixedToScalar(n);
- }
-#endif
- return str;
}
const char* SkParse::FindScalars(const char str[], SkScalar value[], int count)
diff --git a/src/utils/SkParsePath.cpp b/src/utils/SkParsePath.cpp
index 4c9923f49f..1a3c87f31d 100644
--- a/src/utils/SkParsePath.cpp
+++ b/src/utils/SkParsePath.cpp
@@ -188,7 +188,6 @@ bool SkParsePath::FromSVGString(const char data[], SkPath* result) {
#include "SkStream.h"
static void write_scalar(SkWStream* stream, SkScalar value) {
-#ifdef SK_SCALAR_IS_FLOAT
char buffer[64];
#ifdef SK_BUILD_FOR_WIN32
int len = _snprintf(buffer, sizeof(buffer), "%g", value);
@@ -196,10 +195,6 @@ static void write_scalar(SkWStream* stream, SkScalar value) {
int len = snprintf(buffer, sizeof(buffer), "%g", value);
#endif
char* stop = buffer + len;
-#else
- char buffer[SkStrAppendScalar_MaxSize];
- char* stop = SkStrAppendScalar(buffer, value);
-#endif
stream->write(buffer, stop - buffer);
}
diff --git a/src/xml/SkJSDisplayable.cpp b/src/xml/SkJSDisplayable.cpp
index 502779743f..02a0501672 100644
--- a/src/xml/SkJSDisplayable.cpp
+++ b/src/xml/SkJSDisplayable.cpp
@@ -277,11 +277,7 @@ JSBool SkJSDisplayable::GetProperty(JSContext *cx, JSObject *obj, jsval id,
if (SkScalarFraction(scalar) == 0)
*vp = INT_TO_JSVAL(SkScalarFloor(scalar));
else
-#ifdef SK_SCALAR_IS_FLOAT
*vp = DOUBLE_TO_JSVAL(scalar);
-#else
- *vp = DOUBLE_TO_JSVAL(scalar / 65536.0f );
-#endif
break;
case SkType_String:
str = JS_NewStringCopyN(cx, string->c_str(), string->size());
@@ -323,11 +319,7 @@ JSBool SkJSDisplayable::SetProperty(JSContext *cx, JSObject *obj, jsval id, jsva
scalar = SkIntToScalar(JSVAL_TO_INT(value));
else {
SkASSERT(JSVAL_IS_DOUBLE(value));
-#ifdef SK_SCALAR_IS_FLOAT
scalar = (float) *(double*) JSVAL_TO_DOUBLE(value);
-#else
- scalar = (SkFixed) (*(double*)JSVAL_TO_DOUBLE(value) * 65536.0);
-#endif
}
break;
case SkType_String:
diff --git a/src/xml/SkXMLWriter.cpp b/src/xml/SkXMLWriter.cpp
index 2ff47eae66..ec351b728b 100644
--- a/src/xml/SkXMLWriter.cpp
+++ b/src/xml/SkXMLWriter.cpp
@@ -309,9 +309,7 @@ void SkXMLStreamWriter::UnitTest()
w.addAttribute("hello", "world");
w.addS32Attribute("dec", 42);
w.addHexAttribute("hex", 0x42, 3);
-#ifdef SK_SCALAR_IS_FLOAT
w.addScalarAttribute("scalar", -4.2f);
-#endif
w.startElement("elem1");
w.endElement();
w.startElement("elem1");
diff --git a/tests/DrawBitmapRectTest.cpp b/tests/DrawBitmapRectTest.cpp
index f2e4837c63..c8718489c4 100644
--- a/tests/DrawBitmapRectTest.cpp
+++ b/tests/DrawBitmapRectTest.cpp
@@ -241,7 +241,6 @@ static void test_wacky_bitmapshader(skiatest::Reporter* reporter,
* memory allocation limit).
*/
static void test_giantrepeat_crbug118018(skiatest::Reporter* reporter) {
-#ifdef SK_SCALAR_IS_FLOAT
static const struct {
int fWidth;
int fHeight;
@@ -258,7 +257,6 @@ static void test_giantrepeat_crbug118018(skiatest::Reporter* reporter) {
gTests[i].fWidth, gTests[i].fHeight,
gTests[i].fExpectedToDraw);
}
-#endif
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/tests/DrawPathTest.cpp b/tests/DrawPathTest.cpp
index 9a49adfff4..8c77ffe031 100644
--- a/tests/DrawPathTest.cpp
+++ b/tests/DrawPathTest.cpp
@@ -181,7 +181,6 @@ static void test_inversepathwithclip() {
}
static void test_bug533() {
-#ifdef SK_SCALAR_IS_FLOAT
/*
http://code.google.com/p/skia/issues/detail?id=533
This particular test/bug only applies to the float case, where the
@@ -196,7 +195,6 @@ static void test_bug533() {
SkAutoTUnref<SkCanvas> canvas(new_canvas(640, 480));
canvas.get()->drawPath(path, paint);
-#endif
}
static void test_crbug_140642() {
@@ -215,14 +213,11 @@ static void test_crbug_140642() {
stroke-dashoffset="-248.135982067">
*/
-#ifdef SK_SCALAR_IS_FLOAT
const SkScalar vals[] = { 27734, 35660, 2157846850.0f, 247 };
SkDashPathEffect dontAssert(vals, 4, -248.135982067f);
-#endif
}
static void test_crbug_124652() {
-#ifdef SK_SCALAR_IS_FLOAT
/*
http://code.google.com/p/chromium/issues/detail?id=124652
This particular test/bug only applies to the float case, where
@@ -231,11 +226,9 @@ static void test_crbug_124652() {
SkScalar intervals[2] = {837099584, 33450};
SkAutoTUnref<SkDashPathEffect> dash(
new SkDashPathEffect(intervals, 2, -10, false));
-#endif
}
static void test_bigcubic() {
-#ifdef SK_SCALAR_IS_FLOAT
SkPath path;
path.moveTo(64, 3);
path.cubicTo(-329936, -100000000, -329936, 100000000, 1153, 330003);
@@ -245,7 +238,6 @@ static void test_bigcubic() {
SkAutoTUnref<SkCanvas> canvas(new_canvas(640, 480));
canvas.get()->drawPath(path, paint);
-#endif
}
// we used to assert if the bounds of the device (clip) was larger than 32K
diff --git a/tests/InfRectTest.cpp b/tests/InfRectTest.cpp
index 3d964bdccf..674cf5b802 100644
--- a/tests/InfRectTest.cpp
+++ b/tests/InfRectTest.cpp
@@ -10,11 +10,9 @@
#include "SkRandom.h"
#include "SkRect.h"
-#ifdef SK_SCALAR_IS_FLOAT
static float make_zero() {
return sk_float_sin(0);
}
-#endif
struct RectCenter {
SkIRect fRect;
@@ -59,14 +57,9 @@ static void check_invalid(skiatest::Reporter* reporter,
// Tests that isFinite() will reject any rect with +/-inf values
// as one of its coordinates.
DEF_TEST(InfRect, reporter) {
-#ifdef SK_SCALAR_IS_FLOAT
float inf = 1 / make_zero(); // infinity
float nan = inf * 0;
SkASSERT(!(nan == nan));
-#else
- SkFixed inf = SK_FixedNaN;
- SkFixed nan = SK_FixedNaN;
-#endif
SkScalar small = SkIntToScalar(10);
SkScalar big = SkIntToScalar(100);
diff --git a/tests/MathTest.cpp b/tests/MathTest.cpp
index 22680c13e6..d6649542c2 100644
--- a/tests/MathTest.cpp
+++ b/tests/MathTest.cpp
@@ -328,14 +328,11 @@ static void unittest_fastfloat(skiatest::Reporter* reporter) {
}
}
-#ifdef SK_SCALAR_IS_FLOAT
static float make_zero() {
return sk_float_sin(0);
}
-#endif
static void unittest_isfinite(skiatest::Reporter* reporter) {
-#ifdef SK_SCALAR_IS_FLOAT
float nan = sk_float_asin(2);
float inf = 1.0f / make_zero();
float big = 3.40282e+038f;
@@ -344,10 +341,6 @@ static void unittest_isfinite(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, !SkScalarIsNaN(-inf));
REPORTER_ASSERT(reporter, !SkScalarIsFinite(inf));
REPORTER_ASSERT(reporter, !SkScalarIsFinite(-inf));
-#else
- SkFixed nan = SK_FixedNaN;
- SkFixed big = SK_FixedMax;
-#endif
REPORTER_ASSERT(reporter, SkScalarIsNaN(nan));
REPORTER_ASSERT(reporter, !SkScalarIsNaN(big));
@@ -607,37 +600,7 @@ DEF_TEST(Math, reporter) {
REPORTER_ASSERT(reporter, xr == check || xr == check-1);
}
-#if !defined(SK_SCALAR_IS_FLOAT)
- {
- SkFixed s, c;
- s = SkFixedSinCos(0, &c);
- REPORTER_ASSERT(reporter, s == 0);
- REPORTER_ASSERT(reporter, c == SK_Fixed1);
- }
-
- int maxDiff = 0;
- for (i = 0; i < 1000; i++) {
- SkFixed rads = rand.nextS() >> 10;
- double frads = SkFixedToFloat(rads);
-
- SkFixed s, c;
- s = SkScalarSinCos(rads, &c);
-
- double fs = sin(frads);
- double fc = cos(frads);
-
- SkFixed is = SkFloatToFixed(fs);
- SkFixed ic = SkFloatToFixed(fc);
-
- maxDiff = SkMax32(maxDiff, SkAbs32(is - s));
- maxDiff = SkMax32(maxDiff, SkAbs32(ic - c));
- }
- SkDebugf("SinCos: maximum error = %d\n", maxDiff);
-#endif
-
-#ifdef SK_SCALAR_IS_FLOAT
test_blend(reporter);
-#endif
if (false) test_floor(reporter);
diff --git a/tests/Matrix44Test.cpp b/tests/Matrix44Test.cpp
index afd2762a7a..8fd84d858c 100644
--- a/tests/Matrix44Test.cpp
+++ b/tests/Matrix44Test.cpp
@@ -24,14 +24,7 @@ static bool nearly_equal_mscalar(SkMScalar a, SkMScalar b) {
}
static bool nearly_equal_scalar(SkScalar a, SkScalar b) {
- // Note that we get more compounded error for multiple operations when
- // SK_SCALAR_IS_FIXED.
-#ifdef SK_SCALAR_IS_FLOAT
const SkScalar tolerance = SK_Scalar1 / 200000;
-#else
- const SkScalar tolerance = SK_Scalar1 / 1024;
-#endif
-
return SkScalarAbs(a - b) <= tolerance;
}
diff --git a/tests/MatrixTest.cpp b/tests/MatrixTest.cpp
index a6d4edabc0..d0fff54c95 100644
--- a/tests/MatrixTest.cpp
+++ b/tests/MatrixTest.cpp
@@ -13,14 +13,7 @@
#include "SkRandom.h"
static bool nearly_equal_scalar(SkScalar a, SkScalar b) {
- // Note that we get more compounded error for multiple operations when
- // SK_SCALAR_IS_FIXED.
-#ifdef SK_SCALAR_IS_FLOAT
const SkScalar tolerance = SK_Scalar1 / 200000;
-#else
- const SkScalar tolerance = SK_Scalar1 / 1024;
-#endif
-
return SkScalarAbs(a - b) <= tolerance;
}
@@ -40,7 +33,6 @@ static bool are_equal(skiatest::Reporter* reporter,
bool equal = a == b;
bool cheapEqual = a.cheapEqualTo(b);
if (equal != cheapEqual) {
-#ifdef SK_SCALAR_IS_FLOAT
if (equal) {
bool foundZeroSignDiff = false;
for (int i = 0; i < 9; ++i) {
@@ -70,9 +62,6 @@ static bool are_equal(skiatest::Reporter* reporter,
}
REPORTER_ASSERT(reporter, foundNaN);
}
-#else
- REPORTER_ASSERT(reporter, false);
-#endif
}
return equal;
}
@@ -299,16 +288,6 @@ static void test_matrix_is_similarity(skiatest::Reporter* reporter) {
mat.setPerspY(SkScalarToPersp(SK_Scalar1 / 2));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
-#ifdef SK_SCALAR_IS_FLOAT
- /* We bypass the following tests for SK_SCALAR_IS_FIXED build.
- * The long discussion can be found in this issue:
- * http://codereview.appspot.com/5999050/
- * In short, we haven't found a perfect way to fix the precision
- * issue, i.e. the way we use tolerance in isSimilarityTransformation
- * is incorrect. The situation becomes worse in fixed build, so
- * we disabled rotation related tests for fixed build.
- */
-
// rotate
for (int angle = 0; angle < 360; ++angle) {
mat.reset();
@@ -340,7 +319,6 @@ static void test_matrix_is_similarity(skiatest::Reporter* reporter) {
mat.setRotate(SkIntToScalar(30));
mat.postScale(SkIntToScalar(3), SkIntToScalar(2));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
-#endif
// all zero
mat.setAll(0, 0, 0, 0, 0, 0, 0, 0, 0);
@@ -800,12 +778,7 @@ DEF_TEST(Matrix, reporter) {
mat.reset();
mat.set(SkMatrix::kMSkewX, SK_ScalarNaN);
mat2.set(SkMatrix::kMSkewX, SK_ScalarNaN);
- // fixed pt doesn't have the property that NaN does not equal itself.
-#ifdef SK_SCALAR_IS_FIXED
- REPORTER_ASSERT(reporter, are_equal(reporter, mat, mat2));
-#else
REPORTER_ASSERT(reporter, !are_equal(reporter, mat, mat2));
-#endif
test_matrix_min_max_stretch(reporter);
test_matrix_is_similarity(reporter);
diff --git a/tests/PDFPrimitivesTest.cpp b/tests/PDFPrimitivesTest.cpp
index 9b9569d367..5f0750d77a 100644
--- a/tests/PDFPrimitivesTest.cpp
+++ b/tests/PDFPrimitivesTest.cpp
@@ -353,7 +353,6 @@ DEF_TEST(PDFPrimitives, reporter) {
SkAutoTUnref<SkPDFScalar> realHalf(new SkPDFScalar(SK_ScalarHalf));
SimpleCheckObjectOutput(reporter, realHalf.get(), "0.5");
-#if defined(SK_SCALAR_IS_FLOAT)
SkAutoTUnref<SkPDFScalar> bigScalar(new SkPDFScalar(110999.75f));
#if !defined(SK_ALLOW_LARGE_PDF_SCALARS)
SimpleCheckObjectOutput(reporter, bigScalar.get(), "111000");
@@ -366,7 +365,6 @@ DEF_TEST(PDFPrimitives, reporter) {
SkAutoTUnref<SkPDFScalar> smallestScalar(new SkPDFScalar(1.0/65536));
SimpleCheckObjectOutput(reporter, smallestScalar.get(), "0.00001526");
#endif
-#endif
SkAutoTUnref<SkPDFString> stringSimple(
new SkPDFString("test ) string ( foo"));
diff --git a/tests/PathMeasureTest.cpp b/tests/PathMeasureTest.cpp
index 5c92ca1686..2d7b64ec36 100644
--- a/tests/PathMeasureTest.cpp
+++ b/tests/PathMeasureTest.cpp
@@ -10,7 +10,6 @@
#include "SkPathMeasure.h"
static void test_small_segment3() {
-#ifdef SK_SCALAR_IS_FLOAT
SkPath path;
const SkPoint pts[] = {
{ 0, 0 },
@@ -25,11 +24,9 @@ static void test_small_segment3() {
SkPathMeasure meas(path, false);
meas.getLength();
-#endif
}
static void test_small_segment2() {
-#ifdef SK_SCALAR_IS_FLOAT
SkPath path;
const SkPoint pts[] = {
{ 0, 0 },
@@ -43,11 +40,9 @@ static void test_small_segment2() {
}
SkPathMeasure meas(path, false);
meas.getLength();
-#endif
}
static void test_small_segment() {
-#ifdef SK_SCALAR_IS_FLOAT
SkPath path;
const SkPoint pts[] = {
{ 100000, 100000},
@@ -77,7 +72,6 @@ static void test_small_segment() {
because distance >>> d.
*/
meas.getLength();
-#endif
}
DEF_TEST(PathMeasure, reporter) {
diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp
index b33ef97eae..3f07ae04bc 100644
--- a/tests/PathTest.cpp
+++ b/tests/PathTest.cpp
@@ -830,7 +830,6 @@ static void test_direction(skiatest::Reporter* reporter) {
path.addCircle(0, 0, SkIntToScalar(2), SkPath::kCCW_Direction);
check_direction(reporter, path, SkPath::kCCW_Direction);
-#ifdef SK_SCALAR_IS_FLOAT
// triangle with one point really far from the origin.
path.reset();
// the first point is roughly 1.05e10, 1.05e10
@@ -838,7 +837,6 @@ static void test_direction(skiatest::Reporter* reporter) {
path.lineTo(110 * SK_Scalar1, -10 * SK_Scalar1);
path.lineTo(-10 * SK_Scalar1, 60 * SK_Scalar1);
check_direction(reporter, path, SkPath::kCCW_Direction);
-#endif
path.reset();
path.conicTo(20, 0, 20, 20, 0.5f);
diff --git a/tests/ScalarTest.cpp b/tests/ScalarTest.cpp
index 47d3226343..eb52b8adf3 100644
--- a/tests/ScalarTest.cpp
+++ b/tests/ScalarTest.cpp
@@ -20,7 +20,6 @@ struct PointSet {
};
static void test_isRectFinite(skiatest::Reporter* reporter) {
-#ifdef SK_SCALAR_IS_FLOAT
static const SkPoint gF0[] = {
{ 0, 0 }, { 1, 1 }
};
@@ -61,7 +60,6 @@ static void test_isRectFinite(skiatest::Reporter* reporter) {
bool rectIsFinite = !r.isEmpty();
REPORTER_ASSERT(reporter, gSets[i].fIsFinite == rectIsFinite);
}
-#endif
}
static bool isFinite_int(float x) {
diff --git a/tests/StringTest.cpp b/tests/StringTest.cpp
index 04e04704ab..ceb4df5308 100644
--- a/tests/StringTest.cpp
+++ b/tests/StringTest.cpp
@@ -157,7 +157,6 @@ DEF_TEST(String, reporter) {
{ SK_Scalar1, "1" },
{ -SK_Scalar1, "-1" },
{ SK_Scalar1/2, "0.5" },
-#ifdef SK_SCALAR_IS_FLOAT
#ifdef SK_BUILD_FOR_WIN
{ 3.4028234e38f, "3.4028235e+038" },
{ -3.4028234e38f, "-3.4028235e+038" },
@@ -165,7 +164,6 @@ DEF_TEST(String, reporter) {
{ 3.4028234e38f, "3.4028235e+38" },
{ -3.4028234e38f, "-3.4028235e+38" },
#endif
-#endif
};
for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); i++) {
a.reset();
diff --git a/tests/WritePixelsTest.cpp b/tests/WritePixelsTest.cpp
index 95cae6a8c8..c7f77a7fb2 100644
--- a/tests/WritePixelsTest.cpp
+++ b/tests/WritePixelsTest.cpp
@@ -297,7 +297,7 @@ struct CanvasConfig {
static const CanvasConfig gCanvasConfigs[] = {
{kRaster_DevType, true},
{kRaster_DevType, false},
-#if SK_SUPPORT_GPU && defined(SK_SCALAR_IS_FLOAT)
+#if SK_SUPPORT_GPU
{kGpu_BottomLeft_DevType, true}, // row bytes has no meaning on gpu devices
{kGpu_TopLeft_DevType, true}, // row bytes has no meaning on gpu devices
#endif
diff --git a/tests/skia_test.cpp b/tests/skia_test.cpp
index 3d2955975e..a1d4bf799b 100644
--- a/tests/skia_test.cpp
+++ b/tests/skia_test.cpp
@@ -196,11 +196,6 @@ int tool_main(int argc, char** argv) {
#else
header.append(" SK_RELEASE");
#endif
-#ifdef SK_SCALAR_IS_FIXED
- header.append(" SK_SCALAR_IS_FIXED");
-#else
- header.append(" SK_SCALAR_IS_FLOAT");
-#endif
header.appendf(" skia_arch_width=%d", (int)sizeof(void*) * 8);
SkDebugf("%s\n", header.c_str());
}