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 #ifdef SK_SUPPORT_LEGACY_ROUND_MIPMAP_LEVEL_CHOICE |
337 int level = SkScalarRoundToInt(L); | 338 int level = SkScalarRoundToInt(L); |
338 // SkDebugf("mipmap scale=%g L=%g level=%d\n", scale, L, level); | 339 #else |
| 340 // int rndLevel = SkScalarRoundToInt(L); |
| 341 int level = SkScalarFloorToInt(L); |
| 342 #endif |
| 343 // SkDebugf("mipmap scale=%g L=%g level=%d rndLevel=%d\n", scale, L, level, r
ndLevel); |
339 | 344 |
340 SkASSERT(level >= 0); | 345 SkASSERT(level >= 0); |
341 if (level <= 0) { | 346 if (level <= 0) { |
342 return false; | 347 return false; |
343 } | 348 } |
344 | 349 |
345 if (level > fCount) { | 350 if (level > fCount) { |
346 level = fCount; | 351 level = fCount; |
347 } | 352 } |
348 if (levelPtr) { | 353 if (levelPtr) { |
349 *levelPtr = fLevels[level - 1]; | 354 *levelPtr = fLevels[level - 1]; |
350 } | 355 } |
351 return true; | 356 return true; |
352 } | 357 } |
OLD | NEW |