diff options
author | 2017-02-02 13:12:23 +0000 | |
---|---|---|
committer | 2017-02-02 13:12:36 +0000 | |
commit | 8233fc82b00763d37a7b0db7890b15c7d58939d4 (patch) | |
tree | 1c99b01a5d268d78ccc79d89943581a405d0de2c | |
parent | 2722549410ca6d349af439c1454391e70fd1c0e6 (diff) |
Revert "SkScalar: delete code thqat doesn't compile."
This reverts commit 565da18f6e4a0f04dc836ce9d35f31bee31644f7.
Reason for revert: breaking android roll:
https://googleplex-android-review.git.corp.google.com/#/c/1853481/-1..1
Some code in Android references SK_SCALAR_IS_FLOAT:
https://cs.corp.google.com/android/frameworks/base/core/jni/android/graphics/Interpolator.cpp?q=frameworks/base/core/jni/android/graphics/Interpolator.cpp&sq=package:android&l=30
Original change's description:
> SkScalar: delete code thqat doesn't compile.
>
> Change-Id: I8a5c404d6151fca79af5c5a98d4b44924c0ade52
> Reviewed-on: https://skia-review.googlesource.com/7882
> Reviewed-by: Mike Reed <reed@google.com>
> Commit-Queue: Hal Canary <halcanary@google.com>
>
TBR=halcanary@google.com,reed@google.com,reviews@skia.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Change-Id: I4df06c4593abaa3ac3877b270a41aec7a9c3fc8f
Reviewed-on: https://skia-review.googlesource.com/7888
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
-rw-r--r-- | include/core/SkScalar.h | 50 | ||||
-rw-r--r-- | include/private/SkFixed.h | 9 | ||||
-rw-r--r-- | src/gpu/gl/GrGLPath.cpp | 2 |
3 files changed, 60 insertions, 1 deletions
diff --git a/include/core/SkScalar.h b/include/core/SkScalar.h index 16e885850e..922840fd1a 100644 --- a/include/core/SkScalar.h +++ b/include/core/SkScalar.h @@ -10,6 +10,14 @@ #include "../private/SkFloatingPoint.h" +// TODO: move this sort of check into SkPostConfig.h +#define SK_SCALAR_IS_DOUBLE 0 +#undef SK_SCALAR_IS_FLOAT +#define SK_SCALAR_IS_FLOAT 1 + + +#if SK_SCALAR_IS_FLOAT + typedef float SkScalar; #define SK_Scalar1 1.0f @@ -48,6 +56,48 @@ typedef float SkScalar; #define SkScalarLog(x) (float)sk_float_log(x) #define SkScalarLog2(x) (float)sk_float_log2(x) +#else // SK_SCALAR_IS_DOUBLE + +typedef double SkScalar; + +#define SK_Scalar1 1.0 +#define SK_ScalarHalf 0.5 +#define SK_ScalarSqrt2 1.414213562373095 +#define SK_ScalarPI 3.141592653589793 +#define SK_ScalarTanPIOver8 0.4142135623731 +#define SK_ScalarRoot2Over2 0.70710678118655 +#define SK_ScalarMax 1.7976931348623157+308 +#define SK_ScalarInfinity SK_DoubleInfinity +#define SK_ScalarNegativeInfinity SK_DoubleNegativeInfinity +#define SK_ScalarNaN SK_DoubleNaN + +#define SkScalarFloorToScalar(x) floor(x) +#define SkScalarCeilToScalar(x) ceil(x) +#define SkScalarRoundToScalar(x) floor((x) + 0.5) +#define SkScalarTruncToScalar(x) trunc(x) + +#define SkScalarFloorToInt(x) (int)floor(x) +#define SkScalarCeilToInt(x) (int)ceil(x) +#define SkScalarRoundToInt(x) (int)floor((x) + 0.5) + +#define SkScalarAbs(x) abs(x) +#define SkScalarCopySign(x, y) copysign(x, y) +#define SkScalarMod(x, y) fmod(x,y) +#define SkScalarSqrt(x) sqrt(x) +#define SkScalarPow(b, e) pow(b, e) + +#define SkScalarSin(radians) sin(radians) +#define SkScalarCos(radians) cos(radians) +#define SkScalarTan(radians) tan(radians) +#define SkScalarASin(val) asin(val) +#define SkScalarACos(val) acos(val) +#define SkScalarATan2(y, x) atan2(y,x) +#define SkScalarExp(x) exp(x) +#define SkScalarLog(x) log(x) +#define SkScalarLog2(x) log2(x) + +#endif + ////////////////////////////////////////////////////////////////////////////////////////////////// #define SkIntToScalar(x) static_cast<SkScalar>(x) diff --git a/include/private/SkFixed.h b/include/private/SkFixed.h index 2ef8fff0bb..07ac9d2306 100644 --- a/include/private/SkFixed.h +++ b/include/private/SkFixed.h @@ -138,9 +138,18 @@ inline SkFixed SkFixedMul_longlong(SkFixed a, SkFixed b) { /////////////////////////////////////////////////////////////////////////////// +#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 diff --git a/src/gpu/gl/GrGLPath.cpp b/src/gpu/gl/GrGLPath.cpp index f7e6bd16de..05460187ef 100644 --- a/src/gpu/gl/GrGLPath.cpp +++ b/src/gpu/gl/GrGLPath.cpp @@ -218,7 +218,7 @@ void GrGLPath::InitPathObjectPathData(GrGLGpu* gpu, const SkPath& skPath) { SkASSERT(!skPath.isEmpty()); -#if 1 // SK_SCALAR_IS_FLOAT +#ifdef SK_SCALAR_IS_FLOAT // This branch does type punning, converting SkPoint* to GrGLfloat*. if ((skPath.getSegmentMasks() & SkPath::kConic_SegmentMask) == 0) { int verbCnt = skPath.countVerbs(); |