| OLD | NEW |
| 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 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 // shader will perform. | 474 // shader will perform. |
| 475 | 475 |
| 476 fMatrixProc = this->chooseMatrixProc(trivialMatrix); | 476 fMatrixProc = this->chooseMatrixProc(trivialMatrix); |
| 477 // TODO(dominikg): SkASSERT(fMatrixProc) instead? chooseMatrixProc never ret
urns NULL. | 477 // TODO(dominikg): SkASSERT(fMatrixProc) instead? chooseMatrixProc never ret
urns NULL. |
| 478 if (NULL == fMatrixProc) { | 478 if (NULL == fMatrixProc) { |
| 479 return false; | 479 return false; |
| 480 } | 480 } |
| 481 | 481 |
| 482 /////////////////////////////////////////////////////////////////////// | 482 /////////////////////////////////////////////////////////////////////// |
| 483 | 483 |
| 484 const SkAlphaType at = fBitmap->alphaType(); |
| 485 |
| 484 // No need to do this if we're doing HQ sampling; if filter quality is | 486 // No need to do this if we're doing HQ sampling; if filter quality is |
| 485 // still set to HQ by the time we get here, then we must have installed | 487 // still set to HQ by the time we get here, then we must have installed |
| 486 // the shader procs above and can skip all this. | 488 // the shader procs above and can skip all this. |
| 487 | 489 |
| 488 if (fFilterLevel < SkPaint::kHigh_FilterLevel) { | 490 if (fFilterLevel < SkPaint::kHigh_FilterLevel) { |
| 489 | 491 |
| 490 int index = 0; | 492 int index = 0; |
| 491 if (fAlphaScale < 256) { // note: this distinction is not used for D16 | 493 if (fAlphaScale < 256) { // note: this distinction is not used for D16 |
| 492 index |= 1; | 494 index |= 1; |
| 493 } | 495 } |
| 494 if (fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) { | 496 if (fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) { |
| 495 index |= 2; | 497 index |= 2; |
| 496 } | 498 } |
| 497 if (fFilterLevel > SkPaint::kNone_FilterLevel) { | 499 if (fFilterLevel > SkPaint::kNone_FilterLevel) { |
| 498 index |= 4; | 500 index |= 4; |
| 499 } | 501 } |
| 500 // bits 3,4,5 encoding the source bitmap format | 502 // bits 3,4,5 encoding the source bitmap format |
| 501 switch (fBitmap->colorType()) { | 503 switch (fBitmap->colorType()) { |
| 502 case kN32_SkColorType: | 504 case kN32_SkColorType: |
| 505 if (kPremul_SkAlphaType != at && kOpaque_SkAlphaType != at) { |
| 506 return false; |
| 507 } |
| 503 index |= 0; | 508 index |= 0; |
| 504 break; | 509 break; |
| 505 case kRGB_565_SkColorType: | 510 case kRGB_565_SkColorType: |
| 506 index |= 8; | 511 index |= 8; |
| 507 break; | 512 break; |
| 508 case kIndex_8_SkColorType: | 513 case kIndex_8_SkColorType: |
| 514 if (kPremul_SkAlphaType != at && kOpaque_SkAlphaType != at) { |
| 515 return false; |
| 516 } |
| 509 index |= 16; | 517 index |= 16; |
| 510 break; | 518 break; |
| 511 case kARGB_4444_SkColorType: | 519 case kARGB_4444_SkColorType: |
| 520 if (kPremul_SkAlphaType != at && kOpaque_SkAlphaType != at) { |
| 521 return false; |
| 522 } |
| 512 index |= 24; | 523 index |= 24; |
| 513 break; | 524 break; |
| 514 case kAlpha_8_SkColorType: | 525 case kAlpha_8_SkColorType: |
| 515 index |= 32; | 526 index |= 32; |
| 516 fPaintPMColor = SkPreMultiplyColor(paint.getColor()); | 527 fPaintPMColor = SkPreMultiplyColor(paint.getColor()); |
| 517 break; | 528 break; |
| 518 default: | 529 default: |
| 519 // TODO(dominikg): Should we ever get here? SkASSERT(false) inst
ead? | 530 // TODO(dominikg): Should we ever get here? SkASSERT(false) inst
ead? |
| 520 return false; | 531 return false; |
| 521 } | 532 } |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1029 } else { | 1040 } else { |
| 1030 size >>= 2; | 1041 size >>= 2; |
| 1031 } | 1042 } |
| 1032 | 1043 |
| 1033 if (fFilterLevel != SkPaint::kNone_FilterLevel) { | 1044 if (fFilterLevel != SkPaint::kNone_FilterLevel) { |
| 1034 size >>= 1; | 1045 size >>= 1; |
| 1035 } | 1046 } |
| 1036 | 1047 |
| 1037 return size; | 1048 return size; |
| 1038 } | 1049 } |
| OLD | NEW |