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

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

Issue 1686563002: Relocate anisotropic mipmap logic to SkMipMap::extractLevel() (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 | « src/core/SkMipMap.h ('k') | tests/MipMapTest.cpp » ('j') | 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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 srcPM = dstPM; 313 srcPM = dstPM;
314 addr += height * rowBytes; 314 addr += height * rowBytes;
315 } 315 }
316 SkASSERT(addr == baseAddr + size); 316 SkASSERT(addr == baseAddr + size);
317 317
318 return mipmap; 318 return mipmap;
319 } 319 }
320 320
321 /////////////////////////////////////////////////////////////////////////////// 321 ///////////////////////////////////////////////////////////////////////////////
322 322
323 bool SkMipMap::extractLevel(SkScalar scale, 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);
329 // Use the smallest scale to match the GPU impl.
330 const SkScalar scale = SkTMin(scaleSize.width(), scaleSize.height());
331
328 if (scale >= SK_Scalar1 || scale <= 0 || !SkScalarIsFinite(scale)) { 332 if (scale >= SK_Scalar1 || scale <= 0 || !SkScalarIsFinite(scale)) {
329 return false; 333 return false;
330 } 334 }
331 335
332 SkScalar L = -SkScalarLog2(scale); 336 SkScalar L = -SkScalarLog2(scale);
333 if (!SkScalarIsFinite(L)) { 337 if (!SkScalarIsFinite(L)) {
334 return false; 338 return false;
335 } 339 }
336 SkASSERT(L >= 0); 340 SkASSERT(L >= 0);
337 // int rndLevel = SkScalarRoundToInt(L); 341 // int rndLevel = SkScalarRoundToInt(L);
(...skipping 22 matching lines...) Expand all
360 return nullptr; 364 return nullptr;
361 } 365 }
362 const SkPixmap& srcPixmap = srcUnlocker.pixmap(); 366 const SkPixmap& srcPixmap = srcUnlocker.pixmap();
363 // Try to catch where we might have returned nullptr for src crbug.com/49281 8 367 // Try to catch where we might have returned nullptr for src crbug.com/49281 8
364 if (nullptr == srcPixmap.addr()) { 368 if (nullptr == srcPixmap.addr()) {
365 sk_throw(); 369 sk_throw();
366 } 370 }
367 return Build(srcPixmap, fact); 371 return Build(srcPixmap, fact);
368 } 372 }
369 373
OLDNEW
« no previous file with comments | « src/core/SkMipMap.h ('k') | tests/MipMapTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698