Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: src/core/SkMipMap.cpp

Issue 1697423002: Use geometric mean when selecting a mipmap scale (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698