| 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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 // a nearby mipmap level. If it does, it will adjust the working | 391 // 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 | 392 // matrix as well as the working bitmap. It may also adjust the filter |
| 393 // quality to avoid re-filtering an already perfectly scaled image. | 393 // quality to avoid re-filtering an already perfectly scaled image. |
| 394 if (!this->possiblyScaleImage()) { | 394 if (!this->possiblyScaleImage()) { |
| 395 if (!this->lockBaseBitmap()) { | 395 if (!this->lockBaseBitmap()) { |
| 396 return false; | 396 return false; |
| 397 } | 397 } |
| 398 } | 398 } |
| 399 // The above logic should have always assigned fBitmap, but in case it | 399 // The above logic should have always assigned fBitmap, but in case it |
| 400 // didn't, we check for that now... | 400 // didn't, we check for that now... |
| 401 // TODO(dominikg): Ask humper@ if we can just use an SkASSERT(fBitmap)? | |
| 402 if (NULL == fBitmap) { | 401 if (NULL == fBitmap) { |
| 403 return false; | 402 return false; |
| 404 } | 403 } |
| 405 | 404 |
| 406 bool trivialMatrix = (fInvMatrix.getType() & ~SkMatrix::kTranslate_Mask) ==
0; | 405 bool trivialMatrix = (fInvMatrix.getType() & ~SkMatrix::kTranslate_Mask) ==
0; |
| 407 bool clampClamp = SkShader::kClamp_TileMode == fTileModeX && | 406 bool clampClamp = SkShader::kClamp_TileMode == fTileModeX && |
| 408 SkShader::kClamp_TileMode == fTileModeY; | 407 SkShader::kClamp_TileMode == fTileModeY; |
| 409 | 408 |
| 410 if (!(clampClamp || trivialMatrix)) { | 409 if (!(clampClamp || trivialMatrix)) { |
| 411 fInvMatrix.postIDiv(fOrigBitmap.width(), fOrigBitmap.height()); | 410 fInvMatrix.postIDiv(fOrigBitmap.width(), fOrigBitmap.height()); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 if (fInvType <= SkMatrix::kTranslate_Mask || | 473 if (fInvType <= SkMatrix::kTranslate_Mask || |
| 475 !valid_for_filtering(fBitmap->width() | fBitmap->height())) { | 474 !valid_for_filtering(fBitmap->width() | fBitmap->height())) { |
| 476 fFilterLevel = SkPaint::kNone_FilterLevel; | 475 fFilterLevel = SkPaint::kNone_FilterLevel; |
| 477 } | 476 } |
| 478 } | 477 } |
| 479 | 478 |
| 480 // At this point, we know exactly what kind of sampling the per-scanline | 479 // At this point, we know exactly what kind of sampling the per-scanline |
| 481 // shader will perform. | 480 // shader will perform. |
| 482 | 481 |
| 483 fMatrixProc = this->chooseMatrixProc(trivialMatrix); | 482 fMatrixProc = this->chooseMatrixProc(trivialMatrix); |
| 484 // TODO(dominikg): SkASSERT(fMatrixProc) instead? chooseMatrixProc never ret
urns NULL. | |
| 485 if (NULL == fMatrixProc) { | 483 if (NULL == fMatrixProc) { |
| 486 return false; | 484 return false; |
| 487 } | 485 } |
| 488 | 486 |
| 489 /////////////////////////////////////////////////////////////////////// | 487 /////////////////////////////////////////////////////////////////////// |
| 490 | 488 |
| 491 // No need to do this if we're doing HQ sampling; if filter quality is | 489 // No need to do this if we're doing HQ sampling; if filter quality is |
| 492 // still set to HQ by the time we get here, then we must have installed | 490 // still set to HQ by the time we get here, then we must have installed |
| 493 // the shader procs above and can skip all this. | 491 // the shader procs above and can skip all this. |
| 494 | 492 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 516 index |= 16; | 514 index |= 16; |
| 517 break; | 515 break; |
| 518 case SkBitmap::kARGB_4444_Config: | 516 case SkBitmap::kARGB_4444_Config: |
| 519 index |= 24; | 517 index |= 24; |
| 520 break; | 518 break; |
| 521 case SkBitmap::kA8_Config: | 519 case SkBitmap::kA8_Config: |
| 522 index |= 32; | 520 index |= 32; |
| 523 fPaintPMColor = SkPreMultiplyColor(paint.getColor()); | 521 fPaintPMColor = SkPreMultiplyColor(paint.getColor()); |
| 524 break; | 522 break; |
| 525 default: | 523 default: |
| 526 // TODO(dominikg): Should we ever get here? SkASSERT(false) inst
ead? | |
| 527 return false; | 524 return false; |
| 528 } | 525 } |
| 529 | 526 |
| 530 #if !SK_ARM_NEON_IS_ALWAYS | 527 #if !SK_ARM_NEON_IS_ALWAYS |
| 531 static const SampleProc32 gSkBitmapProcStateSample32[] = { | 528 static const SampleProc32 gSkBitmapProcStateSample32[] = { |
| 532 S32_opaque_D32_nofilter_DXDY, | 529 S32_opaque_D32_nofilter_DXDY, |
| 533 S32_alpha_D32_nofilter_DXDY, | 530 S32_alpha_D32_nofilter_DXDY, |
| 534 S32_opaque_D32_nofilter_DX, | 531 S32_opaque_D32_nofilter_DX, |
| 535 S32_alpha_D32_nofilter_DX, | 532 S32_alpha_D32_nofilter_DX, |
| 536 S32_opaque_D32_filter_DXDY, | 533 S32_opaque_D32_filter_DXDY, |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1036 } else { | 1033 } else { |
| 1037 size >>= 2; | 1034 size >>= 2; |
| 1038 } | 1035 } |
| 1039 | 1036 |
| 1040 if (fFilterLevel != SkPaint::kNone_FilterLevel) { | 1037 if (fFilterLevel != SkPaint::kNone_FilterLevel) { |
| 1041 size >>= 1; | 1038 size >>= 1; |
| 1042 } | 1039 } |
| 1043 | 1040 |
| 1044 return size; | 1041 return size; |
| 1045 } | 1042 } |
| OLD | NEW |