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

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

Issue 196413009: remove SK_SUPPORT_LEGACY_COPYTO_CONFIG (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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 } 377 }
377 SkDELETE(fBitmapFilter); 378 SkDELETE(fBitmapFilter);
378 } 379 }
379 380
380 bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) { 381 bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) {
381 SkASSERT(fOrigBitmap.width() && fOrigBitmap.height()); 382 SkASSERT(fOrigBitmap.width() && fOrigBitmap.height());
382 383
383 fBitmap = NULL; 384 fBitmap = NULL;
384 fInvMatrix = inv; 385 fInvMatrix = inv;
385 fFilterLevel = paint.getFilterLevel(); 386 fFilterLevel = paint.getFilterLevel();
387 // fFilterLevel = SkPaint::kMedium_FilterLevel;
386 388
387 SkASSERT(NULL == fScaledCacheID); 389 SkASSERT(NULL == fScaledCacheID);
388 390
389 // possiblyScaleImage will look to see if it can rescale the image as a 391 // possiblyScaleImage will look to see if it can rescale the image as a
390 // preprocess; either by scaling up to the target size, or by selecting 392 // preprocess; either by scaling up to the target size, or by selecting
391 // a nearby mipmap level. If it does, it will adjust the working 393 // a nearby mipmap level. If it does, it will adjust the working
392 // matrix as well as the working bitmap. It may also adjust the filter 394 // matrix as well as the working bitmap. It may also adjust the filter
393 // quality to avoid re-filtering an already perfectly scaled image. 395 // quality to avoid re-filtering an already perfectly scaled image.
394 if (!this->possiblyScaleImage()) { 396 if (!this->possiblyScaleImage()) {
395 if (!this->lockBaseBitmap()) { 397 if (!this->lockBaseBitmap()) {
396 return false; 398 return false;
397 } 399 }
398 } 400 }
399 // The above logic should have always assigned fBitmap, but in case it 401 // The above logic should have always assigned fBitmap, but in case it
400 // didn't, we check for that now... 402 // didn't, we check for that now...
401 // TODO(dominikg): Ask humper@ if we can just use an SkASSERT(fBitmap)? 403 // TODO(dominikg): Ask humper@ if we can just use an SkASSERT(fBitmap)?
402 if (NULL == fBitmap) { 404 if (NULL == fBitmap) {
403 return false; 405 return false;
404 } 406 }
405 407
408 // If we are "still" kMedium_FilterLeve, then then request was not fulfilled by possiblyScale,
409 // so we downgrade to kLow (so the rest of the sniffing code can assume that
410 if (SkPaint::kMedium_FilterLevel == fFilterLevel) {
411 fFilterLevel = SkPaint::kLow_FilterLevel;
412 }
413
406 bool trivialMatrix = (fInvMatrix.getType() & ~SkMatrix::kTranslate_Mask) == 0; 414 bool trivialMatrix = (fInvMatrix.getType() & ~SkMatrix::kTranslate_Mask) == 0;
407 bool clampClamp = SkShader::kClamp_TileMode == fTileModeX && 415 bool clampClamp = SkShader::kClamp_TileMode == fTileModeX &&
408 SkShader::kClamp_TileMode == fTileModeY; 416 SkShader::kClamp_TileMode == fTileModeY;
409 417
410 if (!(clampClamp || trivialMatrix)) { 418 if (!(clampClamp || trivialMatrix)) {
411 fInvMatrix.postIDiv(fOrigBitmap.width(), fOrigBitmap.height()); 419 fInvMatrix.postIDiv(fOrigBitmap.width(), fOrigBitmap.height());
412 } 420 }
413 421
414 // Now that all possible changes to the matrix have taken place, check 422 // 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 423 // 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 { 1044 } else {
1037 size >>= 2; 1045 size >>= 2;
1038 } 1046 }
1039 1047
1040 if (fFilterLevel != SkPaint::kNone_FilterLevel) { 1048 if (fFilterLevel != SkPaint::kNone_FilterLevel) {
1041 size >>= 1; 1049 size >>= 1;
1042 } 1050 }
1043 1051
1044 return size; 1052 return size;
1045 } 1053 }
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