aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
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 /src
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 'src')
-rw-r--r--src/core/SkMipMap.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/core/SkMipMap.cpp b/src/core/SkMipMap.cpp
index 83164b1526..2dad6d9c57 100644
--- a/src/core/SkMipMap.cpp
+++ b/src/core/SkMipMap.cpp
@@ -225,8 +225,7 @@ SkMipMap* SkMipMap::Build(const SkBitmap& src, SkDiscardableFactoryProc fact) {
///////////////////////////////////////////////////////////////////////////////
-//static int gCounter;
-
+#ifdef SK_SUPPORT_LEGACY_MIPLEVELCHOICE
static SkFixed compute_level(SkScalar scale) {
SkScalar inv = SkScalarAbs(SkScalarInvert(scale));
if (inv > 32767) { // Watch out for SkFixed overflow.
@@ -241,17 +240,29 @@ static SkFixed compute_level(SkScalar scale) {
SkASSERT(clz >= 1 && clz <= 15);
return SkIntToFixed(15 - clz) + ((unsigned)(s << (clz + 1)) >> 16);
}
+#endif
bool SkMipMap::extractLevel(SkScalar scale, Level* levelPtr) const {
if (NULL == fLevels) {
return false;
}
- if (scale >= SK_Scalar1) {
+ if (scale >= SK_Scalar1 || scale <= 0 || !SkScalarIsFinite(scale)) {
return false;
}
+#ifdef SK_SUPPORT_LEGACY_MIPLEVELCHOICE
int level = compute_level(scale) >> 16;
+#else
+ SkScalar L = -SkScalarLog2(scale);
+ if (!SkScalarIsFinite(L)) {
+ return false;
+ }
+ SkASSERT(L >= 0);
+ int level = SkScalarRoundToInt(L);
+// SkDebugf("mipmap scale=%g L=%g level=%d\n", scale, L, level);
+#endif
+
SkASSERT(level >= 0);
if (level <= 0) {
return false;