OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkBitmapCache.h" | 8 #include "SkBitmapCache.h" |
9 #include "SkBitmapProcState.h" | 9 #include "SkBitmapProcState.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 */ | 475 */ |
476 bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) { | 476 bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) { |
477 if (!valid_for_drawing(fOrigBitmap)) { | 477 if (!valid_for_drawing(fOrigBitmap)) { |
478 return false; | 478 return false; |
479 } | 479 } |
480 | 480 |
481 fBitmap = NULL; | 481 fBitmap = NULL; |
482 fInvMatrix = inv; | 482 fInvMatrix = inv; |
483 fFilterLevel = paint.getFilterLevel(); | 483 fFilterLevel = paint.getFilterLevel(); |
484 | 484 |
485 #ifdef SK_SUPPORT_LEGACY_HQ_SCALING | |
486 // possiblyScaleImage will look to see if it can rescale the image as a | |
487 // preprocess; either by scaling up to the target size, or by selecting | |
488 // a nearby mipmap level. If it does, it will adjust the working | |
489 // matrix as well as the working bitmap. It may also adjust the filter | |
490 // quality to avoid re-filtering an already perfectly scaled image. | |
491 if (!this->possiblyScaleImage()) { | |
492 if (!this->lockBaseBitmap()) { | |
493 return false; | |
494 } | |
495 } | |
496 // The above logic should have always assigned fBitmap, but in case it | |
497 // didn't, we check for that now... | |
498 // TODO(dominikg): Ask humper@ if we can just use an SkASSERT(fBitmap)? | |
499 if (NULL == fBitmap) { | |
500 return false; | |
501 } | |
502 | |
503 // If we are "still" kMedium_FilterLevel, then the request was not fulfilled
by possiblyScale, | |
504 // so we downgrade to kLow (so the rest of the sniffing code can assume that
) | |
505 if (SkPaint::kMedium_FilterLevel == fFilterLevel) { | |
506 fFilterLevel = SkPaint::kLow_FilterLevel; | |
507 } | |
508 #else | |
509 if (SkPaint::kHigh_FilterLevel == fFilterLevel) { | 485 if (SkPaint::kHigh_FilterLevel == fFilterLevel) { |
510 this->processHQRequest(); | 486 this->processHQRequest(); |
511 } | 487 } |
512 SkASSERT(fFilterLevel < SkPaint::kHigh_FilterLevel); | 488 SkASSERT(fFilterLevel < SkPaint::kHigh_FilterLevel); |
513 | 489 |
514 if (SkPaint::kMedium_FilterLevel == fFilterLevel) { | 490 if (SkPaint::kMedium_FilterLevel == fFilterLevel) { |
515 this->processMediumRequest(); | 491 this->processMediumRequest(); |
516 } | 492 } |
517 SkASSERT(fFilterLevel < SkPaint::kMedium_FilterLevel); | 493 SkASSERT(fFilterLevel < SkPaint::kMedium_FilterLevel); |
518 | 494 |
519 if (NULL == fBitmap) { | 495 if (NULL == fBitmap) { |
520 if (!this->lockBaseBitmap()) { | 496 if (!this->lockBaseBitmap()) { |
521 return false; | 497 return false; |
522 } | 498 } |
523 } | 499 } |
524 SkASSERT(fBitmap); | 500 SkASSERT(fBitmap); |
525 #endif | |
526 | 501 |
527 bool trivialMatrix = (fInvMatrix.getType() & ~SkMatrix::kTranslate_Mask) ==
0; | 502 bool trivialMatrix = (fInvMatrix.getType() & ~SkMatrix::kTranslate_Mask) ==
0; |
528 bool clampClamp = SkShader::kClamp_TileMode == fTileModeX && | 503 bool clampClamp = SkShader::kClamp_TileMode == fTileModeX && |
529 SkShader::kClamp_TileMode == fTileModeY; | 504 SkShader::kClamp_TileMode == fTileModeY; |
530 | 505 |
531 // Most of the scanline procs deal with "unit" texture coordinates, as this | 506 // Most of the scanline procs deal with "unit" texture coordinates, as this |
532 // makes it easy to perform tiling modes (repeat = (x & 0xFFFF)). To generat
e | 507 // makes it easy to perform tiling modes (repeat = (x & 0xFFFF)). To generat
e |
533 // those, we divide the matrix by its dimensions here. | 508 // those, we divide the matrix by its dimensions here. |
534 // | 509 // |
535 // We don't do this if we're either trivial (can ignore the matrix) or clamp
ing | 510 // We don't do this if we're either trivial (can ignore the matrix) or clamp
ing |
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1235 fx += dx; | 1210 fx += dx; |
1236 } | 1211 } |
1237 } else { | 1212 } else { |
1238 for (int i = 0; i < count; ++i) { | 1213 for (int i = 0; i < count; ++i) { |
1239 dst[i] = src[SkClampMax(SkFractionalIntToInt(fx), maxX)]; | 1214 dst[i] = src[SkClampMax(SkFractionalIntToInt(fx), maxX)]; |
1240 fx += dx; | 1215 fx += dx; |
1241 } | 1216 } |
1242 } | 1217 } |
1243 } | 1218 } |
1244 | 1219 |
OLD | NEW |