| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkMipMap.h" | 8 #include "SkMipMap.h" |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 | 327 |
| 328 if (scale >= SK_Scalar1 || scale <= 0 || !SkScalarIsFinite(scale)) { | 328 if (scale >= SK_Scalar1 || scale <= 0 || !SkScalarIsFinite(scale)) { |
| 329 return false; | 329 return false; |
| 330 } | 330 } |
| 331 | 331 |
| 332 SkScalar L = -SkScalarLog2(scale); | 332 SkScalar L = -SkScalarLog2(scale); |
| 333 if (!SkScalarIsFinite(L)) { | 333 if (!SkScalarIsFinite(L)) { |
| 334 return false; | 334 return false; |
| 335 } | 335 } |
| 336 SkASSERT(L >= 0); | 336 SkASSERT(L >= 0); |
| 337 int level = SkScalarRoundToInt(L); | 337 // int rndLevel = SkScalarRoundToInt(L); |
| 338 // SkDebugf("mipmap scale=%g L=%g level=%d\n", scale, L, level); | 338 int level = SkScalarFloorToInt(L); |
| 339 // SkDebugf("mipmap scale=%g L=%g level=%d rndLevel=%d\n", scale, L, level, r
ndLevel); |
| 339 | 340 |
| 340 SkASSERT(level >= 0); | 341 SkASSERT(level >= 0); |
| 341 if (level <= 0) { | 342 if (level <= 0) { |
| 342 return false; | 343 return false; |
| 343 } | 344 } |
| 344 | 345 |
| 345 if (level > fCount) { | 346 if (level > fCount) { |
| 346 level = fCount; | 347 level = fCount; |
| 347 } | 348 } |
| 348 if (levelPtr) { | 349 if (levelPtr) { |
| 349 *levelPtr = fLevels[level - 1]; | 350 *levelPtr = fLevels[level - 1]; |
| 350 } | 351 } |
| 351 return true; | 352 return true; |
| 352 } | 353 } |
| OLD | NEW |