Chromium Code Reviews| Index: src/core/SkBitmapProcState.cpp |
| diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp |
| index 7c37a154d2013ef857fb9620471b2a51c393ee81..ca7dbb0485ad3badc2c8aab798969bf7fd97c582 100644 |
| --- a/src/core/SkBitmapProcState.cpp |
| +++ b/src/core/SkBitmapProcState.cpp |
| @@ -36,7 +36,7 @@ extern void Clamp_S32_opaque_D32_nofilter_DX_shaderproc(const void*, int, int, u |
| #include "SkBitmapProcState_filter.h" |
| #include "SkBitmapProcState_procs.h" |
| -SkBitmapProcState::SkBitmapProcState(const SkBitmapProvider& provider, |
| +SkBitmapProcInfo::SkBitmapProcInfo(const SkBitmapProvider& provider, |
|
herb_g
2016/03/02 16:00:18
Line up params and below.
reed1
2016/03/02 16:28:27
Done.
|
| SkShader::TileMode tmx, SkShader::TileMode tmy) |
| : fProvider(provider) |
| , fBMState(nullptr) |
| @@ -45,7 +45,7 @@ SkBitmapProcState::SkBitmapProcState(const SkBitmapProvider& provider, |
| fTileModeY = tmy; |
| } |
| -SkBitmapProcState::SkBitmapProcState(const SkBitmap& bm, |
| +SkBitmapProcInfo::SkBitmapProcInfo(const SkBitmap& bm, |
| SkShader::TileMode tmx, SkShader::TileMode tmy) |
| : fProvider(SkBitmapProvider(bm)) |
| , fBMState(nullptr) |
| @@ -54,7 +54,7 @@ SkBitmapProcState::SkBitmapProcState(const SkBitmap& bm, |
| fTileModeY = tmy; |
| } |
| -SkBitmapProcState::~SkBitmapProcState() { |
| +SkBitmapProcInfo::~SkBitmapProcInfo() { |
| SkInPlaceDeleteCheck(fBMState, fBMStateStorage.get()); |
| } |
| @@ -118,23 +118,14 @@ static bool valid_for_filtering(unsigned dimension) { |
| return (dimension & ~0x3FFF) == 0; |
| } |
| -/* |
| - * Analyze filter-quality and matrix, and decide how to implement that. |
| - * |
| - * In general, we cascade down the request level [ High ... None ] |
| - * - for a given level, if we can fulfill it, fine, else |
| - * - else we downgrade to the next lower level and try again. |
| - * We can always fulfill requests for Low and None |
| - * - sometimes we will "ignore" Low and give None, but this is likely a legacy perf hack |
| - * and may be removed. |
| - */ |
| -bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) { |
| +bool SkBitmapProcInfo::init(const SkMatrix& inv, const SkPaint& paint) { |
| + const int origW = fProvider.info().width(); |
| + const int origH = fProvider.info().height(); |
| + |
| fPixmap.reset(); |
| fInvMatrix = inv; |
| fFilterLevel = paint.getFilterQuality(); |
| - const int origW = fProvider.info().width(); |
| - const int origH = fProvider.info().height(); |
| bool allow_ignore_fractional_translate = true; // historical default |
| if (kMedium_SkFilterQuality == fFilterLevel) { |
| allow_ignore_fractional_translate = false; |
| @@ -149,9 +140,10 @@ bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) { |
| } |
| fPixmap = fBMState->pixmap(); |
| fInvMatrix = fBMState->invMatrix(); |
| + fPaintColor = paint.getColor(); |
| fFilterLevel = fBMState->quality(); |
| SkASSERT(fPixmap.addr()); |
| - |
| + |
| bool trivialMatrix = (fInvMatrix.getType() & ~SkMatrix::kTranslate_Mask) == 0; |
| bool clampClamp = SkShader::kClamp_TileMode == fTileModeX && |
| SkShader::kClamp_TileMode == fTileModeY; |
| @@ -179,30 +171,14 @@ bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) { |
| SkMatrix forward; |
| if (fInvMatrix.invert(&forward)) { |
| if ((clampClamp && allow_ignore_fractional_translate) |
| - ? just_trans_clamp(forward, fPixmap) |
| - : just_trans_general(forward)) { |
| + ? just_trans_clamp(forward, fPixmap) |
| + : just_trans_general(forward)) { |
| fInvMatrix.setTranslate(-forward.getTranslateX(), -forward.getTranslateY()); |
| } |
| } |
| } |
| - fInvProc = fInvMatrix.getMapXYProc(); |
| - fInvType = fInvMatrix.getType(); |
| - fInvSx = SkScalarToFixed(fInvMatrix.getScaleX()); |
| - fInvSxFractionalInt = SkScalarToFractionalInt(fInvMatrix.getScaleX()); |
| - fInvKy = SkScalarToFixed(fInvMatrix.getSkewY()); |
| - fInvKyFractionalInt = SkScalarToFractionalInt(fInvMatrix.getSkewY()); |
| - |
| - fAlphaScale = SkAlpha255To256(paint.getAlpha()); |
| - |
| - fShaderProc32 = nullptr; |
| - fShaderProc16 = nullptr; |
| - fSampleProc32 = nullptr; |
| - |
| - // recompute the triviality of the matrix here because we may have |
| - // changed it! |
| - |
| - trivialMatrix = (fInvMatrix.getType() & ~SkMatrix::kTranslate_Mask) == 0; |
| + fInvType = fInvMatrix.getType(); |
| // If our target pixmap is the same as the original, then we revert back to legacy behavior |
| // and allow the code to ignore fractional translate. |
| @@ -224,12 +200,41 @@ bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) { |
| fFilterLevel = kNone_SkFilterQuality; |
| } |
| } |
| + |
| + return true; |
| +} |
| + |
| +/* |
| + * Analyze filter-quality and matrix, and decide how to implement that. |
| + * |
| + * In general, we cascade down the request level [ High ... None ] |
| + * - for a given level, if we can fulfill it, fine, else |
| + * - else we downgrade to the next lower level and try again. |
| + * We can always fulfill requests for Low and None |
| + * - sometimes we will "ignore" Low and give None, but this is likely a legacy perf hack |
| + * and may be removed. |
| + */ |
| +bool SkBitmapProcState::chooseProcs() { |
| + fInvProc = fInvMatrix.getMapXYProc(); |
| + fInvSx = SkScalarToFixed(fInvMatrix.getScaleX()); |
|
herb_g
2016/03/02 16:00:18
Align =?
reed1
2016/03/02 16:28:27
Done.
|
| + fInvSxFractionalInt = SkScalarToFractionalInt(fInvMatrix.getScaleX()); |
| + fInvKy = SkScalarToFixed(fInvMatrix.getSkewY()); |
| + fInvKyFractionalInt = SkScalarToFractionalInt(fInvMatrix.getSkewY()); |
| + |
| + fAlphaScale = SkAlpha255To256(SkColorGetA(fPaintColor)); |
| + |
| + fShaderProc32 = nullptr; |
| + fShaderProc16 = nullptr; |
| + fSampleProc32 = nullptr; |
| + |
| + const bool trivialMatrix = (fInvMatrix.getType() & ~SkMatrix::kTranslate_Mask) == 0; |
| + const bool clampClamp = SkShader::kClamp_TileMode == fTileModeX && |
| + SkShader::kClamp_TileMode == fTileModeY; |
| - return this->chooseScanlineProcs(trivialMatrix, clampClamp, paint); |
| + return this->chooseScanlineProcs(trivialMatrix, clampClamp); |
| } |
| -bool SkBitmapProcState::chooseScanlineProcs(bool trivialMatrix, bool clampClamp, |
| - const SkPaint& paint) { |
| +bool SkBitmapProcState::chooseScanlineProcs(bool trivialMatrix, bool clampClamp) { |
| fMatrixProc = this->chooseMatrixProc(trivialMatrix); |
| // TODO(dominikg): SkASSERT(fMatrixProc) instead? chooseMatrixProc never returns nullptr. |
| if (nullptr == fMatrixProc) { |
| @@ -281,11 +286,11 @@ bool SkBitmapProcState::chooseScanlineProcs(bool trivialMatrix, bool clampClamp, |
| break; |
| case kAlpha_8_SkColorType: |
| index |= 32; |
| - fPaintPMColor = SkPreMultiplyColor(paint.getColor()); |
| + fPaintPMColor = SkPreMultiplyColor(fPaintColor); |
| break; |
| case kGray_8_SkColorType: |
| index |= 40; |
| - fPaintPMColor = SkPreMultiplyColor(paint.getColor()); |
| + fPaintPMColor = SkPreMultiplyColor(fPaintColor); |
| break; |
| default: |
| // TODO(dominikg): Should we ever get here? SkASSERT(false) instead? |