aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core
diff options
context:
space:
mode:
authorGravatar reed <reed@chromium.org>2015-01-16 08:35:09 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-01-16 08:35:09 -0800
commit7729e56a29a44bd47c69c8dc3247421595940acc (patch)
tree7c7cb76c100e227cdc336120997c05632ba7137c /include/core
parentafe3005be3392e43bc51eb7eb2017eefaed85ad1 (diff)
use log2(scale) to compute mip level
now w/ expanded suppressions This reverts commit b50ced703030dfbda4fc3ef5e6ec9a52fc0405f8. BUG=skia: TBR= NOTRY=True NOTREECHECKS=True Review URL: https://codereview.chromium.org/856723003
Diffstat (limited to 'include/core')
-rw-r--r--include/core/SkFloatingPoint.h10
-rw-r--r--include/core/SkScalar.h2
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