| 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 | 244 |
| 245 bool SkMipMap::extractLevel(SkScalar scale, Level* levelPtr) const { | 245 bool SkMipMap::extractLevel(SkScalar scale, Level* levelPtr) const { |
| 246 if (NULL == fLevels) { | 246 if (NULL == fLevels) { |
| 247 return false; | 247 return false; |
| 248 } | 248 } |
| 249 | 249 |
| 250 if (scale >= SK_Scalar1) { | 250 if (scale >= SK_Scalar1) { |
| 251 return false; | 251 return false; |
| 252 } | 252 } |
| 253 | 253 |
| 254 int level = compute_level(scale) >> 16; | 254 int level = SkFixedRoundToInt(compute_level(scale)); |
| 255 SkASSERT(level >= 0); | 255 SkASSERT(level >= 0); |
| 256 if (level <= 0) { | 256 if (level <= 0) { |
| 257 return false; | 257 return false; |
| 258 } | 258 } |
| 259 | 259 |
| 260 if (level > fCount) { | 260 if (level > fCount) { |
| 261 level = fCount; | 261 level = fCount; |
| 262 } | 262 } |
| 263 if (levelPtr) { | 263 if (levelPtr) { |
| 264 *levelPtr = fLevels[level - 1]; | 264 *levelPtr = fLevels[level - 1]; |
| 265 } | 265 } |
| 266 return true; | 266 return true; |
| 267 } | 267 } |
| OLD | NEW |