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_MIPMAP_SCALE |
329 // Use the smallest scale to match the GPU impl. | 331 // Use the smallest scale to match the GPU impl. |
330 const SkScalar scale = SkTMin(scaleSize.width(), scaleSize.height()); | 332 const SkScalar scale = SkTMin(scaleSize.width(), scaleSize.height()); |
| 333 #else |
| 334 // Ideally we'd pick the smaller scale, to match Ganesh. But ignoring one o
f the |
| 335 // scales can produce some atrocious results, so for now we use the geometri
c mean. |
| 336 // (https://bugs.chromium.org/p/skia/issues/detail?id=4863) |
| 337 const SkScalar scale = SkScalarSqrt(scaleSize.width() * scaleSize.height()); |
| 338 #endif |
331 | 339 |
332 if (scale >= SK_Scalar1 || scale <= 0 || !SkScalarIsFinite(scale)) { | 340 if (scale >= SK_Scalar1 || scale <= 0 || !SkScalarIsFinite(scale)) { |
333 return false; | 341 return false; |
334 } | 342 } |
335 | 343 |
336 SkScalar L = -SkScalarLog2(scale); | 344 SkScalar L = -SkScalarLog2(scale); |
337 if (!SkScalarIsFinite(L)) { | 345 if (!SkScalarIsFinite(L)) { |
338 return false; | 346 return false; |
339 } | 347 } |
340 SkASSERT(L >= 0); | 348 SkASSERT(L >= 0); |
(...skipping 23 matching lines...) Expand all Loading... |
364 return nullptr; | 372 return nullptr; |
365 } | 373 } |
366 const SkPixmap& srcPixmap = srcUnlocker.pixmap(); | 374 const SkPixmap& srcPixmap = srcUnlocker.pixmap(); |
367 // Try to catch where we might have returned nullptr for src crbug.com/49281
8 | 375 // Try to catch where we might have returned nullptr for src crbug.com/49281
8 |
368 if (nullptr == srcPixmap.addr()) { | 376 if (nullptr == srcPixmap.addr()) { |
369 sk_throw(); | 377 sk_throw(); |
370 } | 378 } |
371 return Build(srcPixmap, fact); | 379 return Build(srcPixmap, fact); |
372 } | 380 } |
373 | 381 |
OLD | NEW |