aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-12-17 16:44:46 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-12-17 16:44:46 +0000
commit8f4d2306fa866a26f9448048ff63f692b2ba43aa (patch)
tree7a48d817cb5220f87e81781320b002eead2495a0 /src
parenta34b638b909f58dd7c66546a0f49923112f7f785 (diff)
remove SK_SCALAR_IS_[FLOAT,FIXED] and assume floats
To keep the CL (slightly) managable, this does not make any changes to existing macros (e.g. SkScalarMul). Just tackling #ifdef constructs this time around. BUG= R=bsalomon@google.com, caryclark@google.com Review URL: https://codereview.chromium.org/117053002 git-svn-id: http://skia.googlecode.com/svn/trunk@12712 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-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
39 files changed, 85 insertions, 881 deletions
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");