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