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

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

Issue 1131613002: use floor for mip-level choice (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 327
328 if (scale >= SK_Scalar1 || scale <= 0 || !SkScalarIsFinite(scale)) { 328 if (scale >= SK_Scalar1 || scale <= 0 || !SkScalarIsFinite(scale)) {
329 return false; 329 return false;
330 } 330 }
331 331
332 SkScalar L = -SkScalarLog2(scale); 332 SkScalar L = -SkScalarLog2(scale);
333 if (!SkScalarIsFinite(L)) { 333 if (!SkScalarIsFinite(L)) {
334 return false; 334 return false;
335 } 335 }
336 SkASSERT(L >= 0); 336 SkASSERT(L >= 0);
337 #ifdef SK_SUPPORT_LEGACY_ROUND_MIPMAP_LEVEL_CHOICE
337 int level = SkScalarRoundToInt(L); 338 int level = SkScalarRoundToInt(L);
338 // SkDebugf("mipmap scale=%g L=%g level=%d\n", scale, L, level); 339 #else
340 // int rndLevel = SkScalarRoundToInt(L);
341 int level = SkScalarFloorToInt(L);
342 #endif
343 // SkDebugf("mipmap scale=%g L=%g level=%d rndLevel=%d\n", scale, L, level, r ndLevel);
339 344
340 SkASSERT(level >= 0); 345 SkASSERT(level >= 0);
341 if (level <= 0) { 346 if (level <= 0) {
342 return false; 347 return false;
343 } 348 }
344 349
345 if (level > fCount) { 350 if (level > fCount) {
346 level = fCount; 351 level = fCount;
347 } 352 }
348 if (levelPtr) { 353 if (levelPtr) {
349 *levelPtr = fLevels[level - 1]; 354 *levelPtr = fLevels[level - 1];
350 } 355 }
351 return true; 356 return true;
352 } 357 }
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