Reverse dependency between SkScalar.h and SkFixed.h.
The following are unused in Chromium, Android, Mozilla, and Google3:
- SkFixedToScalar
- SkScalarToFixed
The following are additionally unused in Skia:
- SkStrAppendFixed
- SkWriteBuffer::writeFixed
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1841123002
Review URL: https://codereview.chromium.org/1841123002
diff --git a/bench/InterpBench.cpp b/bench/InterpBench.cpp
index b95f57d..f259b83 100644
--- a/bench/InterpBench.cpp
+++ b/bench/InterpBench.cpp
@@ -7,6 +7,7 @@
#include "Benchmark.h"
#include "SkColorPriv.h"
+#include "SkFixed.h"
#include "SkMatrix.h"
#include "SkPaint.h"
#include "SkRandom.h"
diff --git a/bench/MathBench.cpp b/bench/MathBench.cpp
index fb35a8a..77ba2f0 100644
--- a/bench/MathBench.cpp
+++ b/bench/MathBench.cpp
@@ -7,6 +7,7 @@
#include "Benchmark.h"
#include "SkColorPriv.h"
+#include "SkFixed.h"
#include "SkMatrix.h"
#include "SkPaint.h"
#include "SkRandom.h"
diff --git a/include/core/SkScalar.h b/include/core/SkScalar.h
index 47c74bc..b2d966c 100644
--- a/include/core/SkScalar.h
+++ b/include/core/SkScalar.h
@@ -8,7 +8,6 @@
#ifndef SkScalar_DEFINED
#define SkScalar_DEFINED
-#include "../private/SkFixed.h"
#include "../private/SkFloatingPoint.h"
// TODO: move this sort of check into SkPostConfig.h
@@ -32,9 +31,6 @@
#define SK_ScalarNegativeInfinity SK_FloatNegativeInfinity
#define SK_ScalarNaN SK_FloatNaN
-#define SkFixedToScalar(x) SkFixedToFloat(x)
-#define SkScalarToFixed(x) SkFloatToFixed(x)
-
#define SkScalarFloorToScalar(x) sk_float_floor(x)
#define SkScalarCeilToScalar(x) sk_float_ceil(x)
#define SkScalarRoundToScalar(x) sk_float_floor((x) + 0.5f)
@@ -75,9 +71,6 @@
#define SK_ScalarNegativeInfinity SK_DoubleNegativeInfinity
#define SK_ScalarNaN SK_DoubleNaN
-#define SkFixedToScalar(x) SkFixedToDouble(x)
-#define SkScalarToFixed(x) SkDoubleToFixed(x)
-
#define SkScalarFloorToScalar(x) floor(x)
#define SkScalarCeilToScalar(x) ceil(x)
#define SkScalarRoundToScalar(x) floor((x) + 0.5)
diff --git a/include/core/SkString.h b/include/core/SkString.h
index 1c3ee3a..4a2d91f 100644
--- a/include/core/SkString.h
+++ b/include/core/SkString.h
@@ -111,7 +111,6 @@
#define SkStrAppendScalar SkStrAppendFloat
char* SkStrAppendFloat(char buffer[], float);
-char* SkStrAppendFixed(char buffer[], SkFixed);
/** \class SkString
diff --git a/include/core/SkWriteBuffer.h b/include/core/SkWriteBuffer.h
index 6e9d043..3ae82d0 100644
--- a/include/core/SkWriteBuffer.h
+++ b/include/core/SkWriteBuffer.h
@@ -51,7 +51,6 @@
void writeByteArray(const void* data, size_t size);
void writeDataAsByteArray(SkData* data) { this->writeByteArray(data->data(), data->size()); }
void writeBool(bool value);
- void writeFixed(SkFixed value);
void writeScalar(SkScalar value);
void writeScalarArray(const SkScalar* value, uint32_t count);
void writeInt(int32_t value);
diff --git a/include/private/SkFixed.h b/include/private/SkFixed.h
index b504f2f..56821d4 100644
--- a/include/private/SkFixed.h
+++ b/include/private/SkFixed.h
@@ -8,6 +8,7 @@
#ifndef SkFixed_DEFINED
#define SkFixed_DEFINED
+#include "SkScalar.h"
#include "SkTypes.h"
/** \file SkFixed.h
@@ -142,6 +143,20 @@
///////////////////////////////////////////////////////////////////////////////
+#if SK_SCALAR_IS_FLOAT
+
+#define SkFixedToScalar(x) SkFixedToFloat(x)
+#define SkScalarToFixed(x) SkFloatToFixed(x)
+
+#else // SK_SCALAR_IS_DOUBLE
+
+#define SkFixedToScalar(x) SkFixedToDouble(x)
+#define SkScalarToFixed(x) SkDoubleToFixed(x)
+
+#endif
+
+///////////////////////////////////////////////////////////////////////////////
+
typedef int64_t SkFixed3232; // 32.32
#define SkIntToFixed3232(x) (SkLeftShift((SkFixed3232)(x), 32))
diff --git a/include/utils/SkRandom.h b/include/utils/SkRandom.h
index ecaedaf..7b56631 100644
--- a/include/utils/SkRandom.h
+++ b/include/utils/SkRandom.h
@@ -8,6 +8,7 @@
#ifndef SkRandom_DEFINED
#define SkRandom_DEFINED
+#include "../private/SkFixed.h"
#include "SkScalar.h"
/** \class SkRandom
diff --git a/samplecode/SamplePath.cpp b/samplecode/SamplePath.cpp
index 12cc402..8baa359 100644
--- a/samplecode/SamplePath.cpp
+++ b/samplecode/SamplePath.cpp
@@ -53,17 +53,6 @@
SkParsePath::FromSVGString(str, &path);
{
-#ifdef SK_BUILD_FOR_WIN
- // windows doesn't have strtof
- float x = (float)strtod("9.94099e+07", nullptr);
-#else
- float x = strtof("9.94099e+07", nullptr);
-#endif
- int ix = (int)x;
- int fx = (int)(x * 65536);
- int ffx = SkScalarToFixed(x);
- SkDebugf("%g %x %x %x\n", x, ix, fx, ffx);
-
SkRect r = path.getBounds();
SkIRect ir;
r.round(&ir);
diff --git a/src/core/SkFDot6.h b/src/core/SkFDot6.h
index 82138ac..726aa2e 100644
--- a/src/core/SkFDot6.h
+++ b/src/core/SkFDot6.h
@@ -9,6 +9,7 @@
#ifndef SkFDot6_DEFINED
#define SkFDot6_DEFINED
+#include "SkFixed.h"
#include "SkScalar.h"
#include "SkMath.h"
diff --git a/src/core/SkFontDescriptor.h b/src/core/SkFontDescriptor.h
index cfdc571..9b87365 100644
--- a/src/core/SkFontDescriptor.h
+++ b/src/core/SkFontDescriptor.h
@@ -8,6 +8,7 @@
#ifndef SkFontDescriptor_DEFINED
#define SkFontDescriptor_DEFINED
+#include "SkFixed.h"
#include "SkStream.h"
#include "SkString.h"
#include "SkTypeface.h"
diff --git a/src/core/SkLinearBitmapPipeline_sample.h b/src/core/SkLinearBitmapPipeline_sample.h
index d63509d..9393224 100644
--- a/src/core/SkLinearBitmapPipeline_sample.h
+++ b/src/core/SkLinearBitmapPipeline_sample.h
@@ -8,6 +8,7 @@
#ifndef SkLinearBitmapPipeline_sampler_DEFINED
#define SkLinearBitmapPipeline_sampler_DEFINED
+#include "SkFixed.h"
#include "SkLinearBitmapPipeline_core.h"
#include <array>
#include <tuple>
diff --git a/src/core/SkMath.cpp b/src/core/SkMath.cpp
index af93d7e..8a9737b 100644
--- a/src/core/SkMath.cpp
+++ b/src/core/SkMath.cpp
@@ -6,6 +6,7 @@
*/
#include "SkMathPriv.h"
+#include "SkFixed.h"
#include "SkFloatBits.h"
#include "SkFloatingPoint.h"
#include "SkScalar.h"
diff --git a/src/core/SkPerspIter.h b/src/core/SkPerspIter.h
index 3a00971..c0a9083 100644
--- a/src/core/SkPerspIter.h
+++ b/src/core/SkPerspIter.h
@@ -9,6 +9,7 @@
#ifndef SkPerspIter_DEFINED
#define SkPerspIter_DEFINED
+#include "SkFixed.h"
#include "SkMatrix.h"
class SkPerspIter {
diff --git a/src/core/SkReadBuffer.cpp b/src/core/SkReadBuffer.cpp
index f220b5a..abd4631 100644
--- a/src/core/SkReadBuffer.cpp
+++ b/src/core/SkReadBuffer.cpp
@@ -90,10 +90,6 @@
return fReader.readInt();
}
-SkFixed SkReadBuffer::readFixed() {
- return fReader.readS32();
-}
-
int32_t SkReadBuffer::readInt() {
return fReader.readInt();
}
diff --git a/src/core/SkReadBuffer.h b/src/core/SkReadBuffer.h
index 7b12194..e77d1ad 100644
--- a/src/core/SkReadBuffer.h
+++ b/src/core/SkReadBuffer.h
@@ -105,7 +105,6 @@
// primitives
virtual bool readBool();
virtual SkColor readColor();
- virtual SkFixed readFixed();
virtual int32_t readInt();
virtual SkScalar readScalar();
virtual uint32_t readUInt();
diff --git a/src/core/SkScan.h b/src/core/SkScan.h
index f944320..4aa8e44 100644
--- a/src/core/SkScan.h
+++ b/src/core/SkScan.h
@@ -9,6 +9,7 @@
#ifndef SkScan_DEFINED
#define SkScan_DEFINED
+#include "SkFixed.h"
#include "SkRect.h"
class SkRasterClip;
diff --git a/src/core/SkString.cpp b/src/core/SkString.cpp
index 2e2c0e7..24b1b8f 100644
--- a/src/core/SkString.cpp
+++ b/src/core/SkString.cpp
@@ -7,7 +7,6 @@
#include "SkAtomics.h"
-#include "SkFixed.h"
#include "SkString.h"
#include "SkUtils.h"
#include <stdarg.h>
@@ -143,44 +142,6 @@
return string + len;
}
-char* SkStrAppendFixed(char string[], SkFixed x) {
- SkDEBUGCODE(char* start = string;)
- if (x < 0) {
- *string++ = '-';
- x = -x;
- }
-
- unsigned frac = x & 0xFFFF;
- x >>= 16;
- if (frac == 0xFFFF) {
- // need to do this to "round up", since 65535/65536 is closer to 1 than to .9999
- x += 1;
- frac = 0;
- }
- string = SkStrAppendS32(string, x);
-
- // now handle the fractional part (if any)
- if (frac) {
- static const uint16_t gTens[] = { 1000, 100, 10, 1 };
- const uint16_t* tens = gTens;
-
- x = SkFixedRoundToInt(frac * 10000);
- SkASSERT(x <= 10000);
- if (x == 10000) {
- x -= 1;
- }
- *string++ = '.';
- do {
- unsigned powerOfTen = *tens++;
- *string++ = SkToU8('0' + x / powerOfTen);
- x %= powerOfTen;
- } while (x != 0);
- }
-
- SkASSERT(string - start <= SkStrAppendScalar_MaxSize);
- return string;
-}
-
///////////////////////////////////////////////////////////////////////////////
// the 3 values are [length] [refcnt] [terminating zero data]
diff --git a/src/core/SkValidatingReadBuffer.cpp b/src/core/SkValidatingReadBuffer.cpp
index ad4b6c4..52006f2 100644
--- a/src/core/SkValidatingReadBuffer.cpp
+++ b/src/core/SkValidatingReadBuffer.cpp
@@ -66,10 +66,6 @@
return this->readInt();
}
-SkFixed SkValidatingReadBuffer::readFixed() {
- return this->readInt();
-}
-
int32_t SkValidatingReadBuffer::readInt() {
const size_t inc = sizeof(int32_t);
this->validate(IsPtrAlign4(fReader.peek()) && fReader.isAvailable(inc));
diff --git a/src/core/SkValidatingReadBuffer.h b/src/core/SkValidatingReadBuffer.h
index bcdcba5..7fb203b 100644
--- a/src/core/SkValidatingReadBuffer.h
+++ b/src/core/SkValidatingReadBuffer.h
@@ -28,7 +28,6 @@
// primitives
bool readBool() override;
SkColor readColor() override;
- SkFixed readFixed() override;
int32_t readInt() override;
SkScalar readScalar() override;
uint32_t readUInt() override;
diff --git a/src/core/SkWriteBuffer.cpp b/src/core/SkWriteBuffer.cpp
index 6baea37..c33a7ae 100644
--- a/src/core/SkWriteBuffer.cpp
+++ b/src/core/SkWriteBuffer.cpp
@@ -47,10 +47,6 @@
fWriter.writeBool(value);
}
-void SkWriteBuffer::writeFixed(SkFixed value) {
- fWriter.write32(value);
-}
-
void SkWriteBuffer::writeScalar(SkScalar value) {
fWriter.writeScalar(value);
}
diff --git a/src/effects/GrCircleBlurFragmentProcessor.cpp b/src/effects/GrCircleBlurFragmentProcessor.cpp
index afab4b4..291dafc 100644
--- a/src/effects/GrCircleBlurFragmentProcessor.cpp
+++ b/src/effects/GrCircleBlurFragmentProcessor.cpp
@@ -18,6 +18,8 @@
#include "glsl/GrGLSLProgramDataManager.h"
#include "glsl/GrGLSLUniformHandler.h"
+#include "SkFixed.h"
+
class GrGLCircleBlurFragmentProcessor : public GrGLSLFragmentProcessor {
public:
void emitCode(EmitArgs&) override;
diff --git a/src/effects/SkDiscretePathEffect.cpp b/src/effects/SkDiscretePathEffect.cpp
index 5d5fc65..4525c1e 100644
--- a/src/effects/SkDiscretePathEffect.cpp
+++ b/src/effects/SkDiscretePathEffect.cpp
@@ -7,10 +7,11 @@
#include "SkDiscretePathEffect.h"
-#include "SkReadBuffer.h"
-#include "SkWriteBuffer.h"
+#include "SkFixed.h"
#include "SkPathMeasure.h"
+#include "SkReadBuffer.h"
#include "SkStrokeRec.h"
+#include "SkWriteBuffer.h"
sk_sp<SkPathEffect> SkDiscretePathEffect::Make(SkScalar segLength, SkScalar deviation,
uint32_t seedAssist) {
diff --git a/src/effects/SkEmbossMask.cpp b/src/effects/SkEmbossMask.cpp
index 310addf..7079d65 100644
--- a/src/effects/SkEmbossMask.cpp
+++ b/src/effects/SkEmbossMask.cpp
@@ -7,6 +7,7 @@
#include "SkEmbossMask.h"
+#include "SkFixed.h"
#include "SkMath.h"
static inline int nonzero_to_one(int x) {
diff --git a/src/effects/SkTableMaskFilter.cpp b/src/effects/SkTableMaskFilter.cpp
index d834652..a3b4038 100644
--- a/src/effects/SkTableMaskFilter.cpp
+++ b/src/effects/SkTableMaskFilter.cpp
@@ -6,10 +6,11 @@
*/
-#include "SkTableMaskFilter.h"
+#include "SkFixed.h"
#include "SkReadBuffer.h"
-#include "SkWriteBuffer.h"
#include "SkString.h"
+#include "SkTableMaskFilter.h"
+#include "SkWriteBuffer.h"
SkTableMaskFilter::SkTableMaskFilter() {
for (int i = 0; i < 256; i++) {
diff --git a/src/fonts/SkTestScalerContext.h b/src/fonts/SkTestScalerContext.h
index fe5c8d6..4af9bf3 100644
--- a/src/fonts/SkTestScalerContext.h
+++ b/src/fonts/SkTestScalerContext.h
@@ -8,6 +8,7 @@
#ifndef SkTestScalerContext_DEFINED
#define SkTestScalerContext_DEFINED
+#include "SkFixed.h"
#include "SkPaint.h"
#include "SkPath.h"
#include "SkRefCnt.h"
diff --git a/src/gpu/GrGlyph.h b/src/gpu/GrGlyph.h
index fb998a4..5e611ce 100644
--- a/src/gpu/GrGlyph.h
+++ b/src/gpu/GrGlyph.h
@@ -13,6 +13,7 @@
#include "GrTypes.h"
#include "SkChecksum.h"
+#include "SkFixed.h"
#include "SkPath.h"
class GrPlot;
diff --git a/src/ports/SkFontMgr_android_parser.cpp b/src/ports/SkFontMgr_android_parser.cpp
index dbc1dee..2424283 100644
--- a/src/ports/SkFontMgr_android_parser.cpp
+++ b/src/ports/SkFontMgr_android_parser.cpp
@@ -7,6 +7,7 @@
// Despite the name and location, this is portable code.
+#include "SkFixed.h"
#include "SkFontMgr.h"
#include "SkFontMgr_android_parser.h"
#include "SkStream.h"
diff --git a/src/utils/SkInterpolator.cpp b/src/utils/SkInterpolator.cpp
index c867587..d3c0b26 100644
--- a/src/utils/SkInterpolator.cpp
+++ b/src/utils/SkInterpolator.cpp
@@ -6,6 +6,7 @@
*/
+#include "SkFixed.h"
#include "SkInterpolator.h"
#include "SkMath.h"
#include "SkTSearch.h"
diff --git a/tests/FontMgrAndroidParserTest.cpp b/tests/FontMgrAndroidParserTest.cpp
index 5f6ff06..92dbd95 100644
--- a/tests/FontMgrAndroidParserTest.cpp
+++ b/tests/FontMgrAndroidParserTest.cpp
@@ -7,6 +7,7 @@
#include "Resources.h"
#include "SkCommandLineFlags.h"
+#include "SkFixed.h"
#include "SkFontMgr_android_parser.h"
#include "Test.h"
diff --git a/tests/MathTest.cpp b/tests/MathTest.cpp
index 5bc2d0e..580cd94 100644
--- a/tests/MathTest.cpp
+++ b/tests/MathTest.cpp
@@ -7,6 +7,7 @@
#include "SkColorPriv.h"
#include "SkEndian.h"
+#include "SkFixed.h"
#include "SkFloatBits.h"
#include "SkFloatingPoint.h"
#include "SkHalf.h"