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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
319 } | 319 } |
320 | 320 |
321 /////////////////////////////////////////////////////////////////////////////// | 321 /////////////////////////////////////////////////////////////////////////////// |
322 | 322 |
323 bool SkMipMap::extractLevel(const SkSize& scaleSize, Level* levelPtr) const { | 323 bool SkMipMap::extractLevel(const SkSize& scaleSize, Level* levelPtr) const { |
324 if (nullptr == fLevels) { | 324 if (nullptr == fLevels) { |
325 return false; | 325 return false; |
326 } | 326 } |
327 | 327 |
328 SkASSERT(scaleSize.width() >= 0 && scaleSize.height() >= 0); | 328 SkASSERT(scaleSize.width() >= 0 && scaleSize.height() >= 0); |
329 | |
330 #ifndef SK_SUPPORT_LEGACY_ANISOTROPIC_MIPMAPS | |
331 const SkScalar kMaxScaleRatio = 0.25f; | |
332 if (SkScalarAbs(scaleSize.width() / scaleSize.height() - 1) > kMaxScaleRatio ) { | |
reed1
2016/02/16 16:41:31
- The minus-1 is a little confusing
I would have
| |
333 // Mipmaps produce bad results for extremely anisotropic scales | |
334 // (https://bugs.chromium.org/p/skia/issues/detail?id=4863). Fall back t o lerp. | |
335 return false; | |
336 } | |
337 #endif | |
338 | |
329 // Use the smallest scale to match the GPU impl. | 339 // Use the smallest scale to match the GPU impl. |
330 const SkScalar scale = SkTMin(scaleSize.width(), scaleSize.height()); | 340 const SkScalar scale = SkTMin(scaleSize.width(), scaleSize.height()); |
331 | 341 |
332 if (scale >= SK_Scalar1 || scale <= 0 || !SkScalarIsFinite(scale)) { | 342 if (scale >= SK_Scalar1 || scale <= 0 || !SkScalarIsFinite(scale)) { |
333 return false; | 343 return false; |
334 } | 344 } |
335 | 345 |
336 SkScalar L = -SkScalarLog2(scale); | 346 SkScalar L = -SkScalarLog2(scale); |
337 if (!SkScalarIsFinite(L)) { | 347 if (!SkScalarIsFinite(L)) { |
338 return false; | 348 return false; |
(...skipping 25 matching lines...) Expand all Loading... | |
364 return nullptr; | 374 return nullptr; |
365 } | 375 } |
366 const SkPixmap& srcPixmap = srcUnlocker.pixmap(); | 376 const SkPixmap& srcPixmap = srcUnlocker.pixmap(); |
367 // Try to catch where we might have returned nullptr for src crbug.com/49281 8 | 377 // Try to catch where we might have returned nullptr for src crbug.com/49281 8 |
368 if (nullptr == srcPixmap.addr()) { | 378 if (nullptr == srcPixmap.addr()) { |
369 sk_throw(); | 379 sk_throw(); |
370 } | 380 } |
371 return Build(srcPixmap, fact); | 381 return Build(srcPixmap, fact); |
372 } | 382 } |
373 | 383 |
OLD | NEW |