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

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

Issue 240633003: add some asserts for mipmaps, and cleanup fFilterLevel if mipping failed (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
« 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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "SkBitmapProcState.h" 8 #include "SkBitmapProcState.h"
9 #include "SkColorPriv.h" 9 #include "SkColorPriv.h"
10 #include "SkFilterProc.h" 10 #include "SkFilterProc.h"
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 const SkMipMap* mip = NULL; 256 const SkMipMap* mip = NULL;
257 257
258 SkASSERT(NULL == fScaledCacheID); 258 SkASSERT(NULL == fScaledCacheID);
259 fScaledCacheID = SkScaledImageCache::FindAndLockMip(fOrigBitmap, &mip); 259 fScaledCacheID = SkScaledImageCache::FindAndLockMip(fOrigBitmap, &mip);
260 if (!fScaledCacheID) { 260 if (!fScaledCacheID) {
261 SkASSERT(NULL == mip); 261 SkASSERT(NULL == mip);
262 mip = SkMipMap::Build(fOrigBitmap); 262 mip = SkMipMap::Build(fOrigBitmap);
263 if (mip) { 263 if (mip) {
264 fScaledCacheID = SkScaledImageCache::AddAndLockMip(fOrigBitmap, 264 fScaledCacheID = SkScaledImageCache::AddAndLockMip(fOrigBitmap,
265 mip); 265 mip);
266 SkASSERT(mip->getRefCnt() > 1);
266 mip->unref(); // the cache took a ref 267 mip->unref(); // the cache took a ref
267 SkASSERT(fScaledCacheID); 268 SkASSERT(fScaledCacheID);
268 } 269 }
269 } else { 270 } else {
270 SkASSERT(mip); 271 SkASSERT(mip);
271 } 272 }
272 273
273 if (mip) { 274 if (mip) {
274 SkScalar levelScale = SkScalarInvert(SkScalarSqrt(scaleSqd)); 275 SkScalar levelScale = SkScalarInvert(SkScalarSqrt(scaleSqd));
275 SkMipMap::Level level; 276 SkMipMap::Level level;
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 return false; 397 return false;
397 } 398 }
398 } 399 }
399 // The above logic should have always assigned fBitmap, but in case it 400 // The above logic should have always assigned fBitmap, but in case it
400 // didn't, we check for that now... 401 // didn't, we check for that now...
401 // TODO(dominikg): Ask humper@ if we can just use an SkASSERT(fBitmap)? 402 // TODO(dominikg): Ask humper@ if we can just use an SkASSERT(fBitmap)?
402 if (NULL == fBitmap) { 403 if (NULL == fBitmap) {
403 return false; 404 return false;
404 } 405 }
405 406
407 // If we are "still" kMedium_FilterLevel, then the request was not fulfilled by possiblyScale,
408 // so we downgrade to kLow (so the rest of the sniffing code can assume that )
409 if (SkPaint::kMedium_FilterLevel == fFilterLevel) {
410 fFilterLevel = SkPaint::kLow_FilterLevel;
411 }
412
406 bool trivialMatrix = (fInvMatrix.getType() & ~SkMatrix::kTranslate_Mask) == 0; 413 bool trivialMatrix = (fInvMatrix.getType() & ~SkMatrix::kTranslate_Mask) == 0;
407 bool clampClamp = SkShader::kClamp_TileMode == fTileModeX && 414 bool clampClamp = SkShader::kClamp_TileMode == fTileModeX &&
408 SkShader::kClamp_TileMode == fTileModeY; 415 SkShader::kClamp_TileMode == fTileModeY;
409 416
410 if (!(clampClamp || trivialMatrix)) { 417 if (!(clampClamp || trivialMatrix)) {
411 fInvMatrix.postIDiv(fOrigBitmap.width(), fOrigBitmap.height()); 418 fInvMatrix.postIDiv(fOrigBitmap.width(), fOrigBitmap.height());
412 } 419 }
413 420
414 // Now that all possible changes to the matrix have taken place, check 421 // Now that all possible changes to the matrix have taken place, check
415 // to see if we're really close to a no-scale matrix. If so, explicitly 422 // to see if we're really close to a no-scale matrix. If so, explicitly
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 } else { 1043 } else {
1037 size >>= 2; 1044 size >>= 2;
1038 } 1045 }
1039 1046
1040 if (fFilterLevel != SkPaint::kNone_FilterLevel) { 1047 if (fFilterLevel != SkPaint::kNone_FilterLevel) {
1041 size >>= 1; 1048 size >>= 1;
1042 } 1049 }
1043 1050
1044 return size; 1051 return size;
1045 } 1052 }
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