diff options
author | 2015-01-16 07:18:10 -0800 | |
---|---|---|
committer | 2015-01-16 07:18:10 -0800 | |
commit | 15fd47f8a07615a7f5d78581aee4c80ff9f17fd9 (patch) | |
tree | 705f38c1a3f53b5a6d0e6e02defdac7df9246978 /include/core | |
parent | 45fa447460f70ec21d22cf4e1531490acfd3c578 (diff) |
use log2(scale) to compute mip level
BUG=skia:
Review URL: https://codereview.chromium.org/849333002
Diffstat (limited to 'include/core')
-rw-r--r-- | include/core/SkFloatingPoint.h | 10 | ||||
-rw-r--r-- | include/core/SkScalar.h | 2 |
2 files changed, 12 insertions, 0 deletions
diff --git a/include/core/SkFloatingPoint.h b/include/core/SkFloatingPoint.h index 1003b80b4f..9fb343261b 100644 --- a/include/core/SkFloatingPoint.h +++ b/include/core/SkFloatingPoint.h @@ -91,6 +91,16 @@ static inline float sk_float_copysign(float x, float y) { #define sk_float_log(x) logf(x) #endif +// can't find log2f on android, but maybe that just a tool bug? +#ifdef SK_BUILD_FOR_ANDROID + static inline float sk_float_log2(float x) { + const double inv_ln_2 = 1.44269504088896; + return (float)(log(x) * inv_ln_2); + } +#else + #define sk_float_log2(x) log2f(x) +#endif + #ifdef SK_BUILD_FOR_WIN #define sk_float_isfinite(x) _finite(x) #define sk_float_isnan(x) _isnan(x) diff --git a/include/core/SkScalar.h b/include/core/SkScalar.h index 94c3ce15c0..e8c7a7fb65 100644 --- a/include/core/SkScalar.h +++ b/include/core/SkScalar.h @@ -58,6 +58,7 @@ typedef float SkScalar; #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) +#define SkScalarLog2(x) (float)sk_float_log2(x) #else // SK_SCALAR_IS_DOUBLE @@ -100,6 +101,7 @@ typedef double SkScalar; #define SkScalarATan2(y, x) atan2(y,x) #define SkScalarExp(x) exp(x) #define SkScalarLog(x) log(x) +#define SkScalarLog2(x) log2(x) #endif |