Chromium Code Reviews| Index: src/core/SkBitmapProcState.cpp |
| diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp |
| index a8a9b03d9ad7e13e00eb991d005114040c957849..a1716e5b66cdf59eaa6191c04af343e5f9208a73 100644 |
| --- a/src/core/SkBitmapProcState.cpp |
| +++ b/src/core/SkBitmapProcState.cpp |
| @@ -96,7 +96,8 @@ static bool valid_for_filtering(unsigned dimension) { |
| void SkBitmapProcState::possiblyScaleImage() { |
| - if (fFilterQuality != kHQ_BitmapFilter) { |
| + if (fFilterLevel <= SkPaint::kLow_FilterLevel) { |
| + // none or low (bilerp) does not need to look any further |
| return; |
| } |
| @@ -106,7 +107,8 @@ void SkBitmapProcState::possiblyScaleImage() { |
| // the matrix is simple, and if we're doing high quality scaling. |
| // If so, do the bitmap scale here and remove the scaling component from the matrix. |
| - if (fInvMatrix.getType() <= (SkMatrix::kScale_Mask | SkMatrix::kTranslate_Mask) && |
| + if (SkPaint::kHigh_FilterLevel == fFilterLevel && |
|
humper
2013/07/19 18:20:26
This logic needs to be more sophisticated, because
reed1
2013/07/19 18:29:16
Not sure I agree. It may be more logical to have L
|
| + fInvMatrix.getType() <= (SkMatrix::kScale_Mask | SkMatrix::kTranslate_Mask) && |
| (fInvMatrix.getScaleX() < 1 || fInvMatrix.getScaleY() < 1) && |
| fOrigBitmap.config() == SkBitmap::kARGB_8888_Config) { |
| @@ -125,11 +127,12 @@ void SkBitmapProcState::possiblyScaleImage() { |
| // no need for any further filtering; we just did it! |
| - fFilterQuality = kNone_BitmapFilter; |
| + fFilterLevel = SkPaint::kNone_FilterLevel; |
| return; |
| } |
| + // If we get here, they are asking for a mipmap (if we're scaling down) |
|
humper
2013/07/19 18:20:26
Sort of -- the HQ downscaler isn't a mipmap. The
|
| if (!fOrigBitmap.hasMipMap()) { |
| // STEP 2: DOWNSAMPLE |
| @@ -155,7 +158,7 @@ void SkBitmapProcState::possiblyScaleImage() { |
| // Now that we've built the mipmaps and we know we're downsampling, |
| // downgrade to bilinear interpolation for the mip level. |
| - fFilterQuality = kBilerp_BitmapFilter; |
| + fFilterLevel = SkPaint::kLow_FilterLevel; |
| } |
| } |
| @@ -202,14 +205,7 @@ bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) { |
| // We may downgrade it later if we determine that we either don't need |
| // or can't provide as high a quality filtering as the user requested. |
| - fFilterQuality = kNone_BitmapFilter; |
| - if (paint.isFilterBitmap()) { |
| - if (paint.getFlags() & SkPaint::kHighQualityFilterBitmap_Flag) { |
| - fFilterQuality = kHQ_BitmapFilter; |
| - } else { |
| - fFilterQuality = kBilerp_BitmapFilter; |
| - } |
| - } |
| + fFilterLevel = paint.getFilterLevel(); |
| #ifndef SK_IGNORE_IMAGE_PRESCALE |
| // possiblyScaleImage will look to see if it can rescale the image as a |
| @@ -261,7 +257,7 @@ bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) { |
| trivialMatrix = (fInvMatrix.getType() & ~SkMatrix::kTranslate_Mask) == 0; |
| - if (kHQ_BitmapFilter == fFilterQuality) { |
| + if (SkPaint::kHigh_FilterLevel == fFilterLevel) { |
|
humper
2013/07/19 18:20:26
What about poor medium level
reed1
2013/07/19 18:29:16
again: depends on our (new) definition of what Med
|
| // If this is still set, that means we wanted HQ sampling |
| // but couldn't do it as a preprocess. Let's try to install |
| // the scanline version of the HQ sampler. If that process fails, |
| @@ -277,17 +273,17 @@ bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) { |
| fShaderProc32 = this->chooseBitmapFilterProc(); |
| if (!fShaderProc32) { |
| - fFilterQuality = kBilerp_BitmapFilter; |
| + fFilterLevel = SkPaint::kLow_FilterLevel; |
| } |
| } |
| - if (kBilerp_BitmapFilter == fFilterQuality) { |
| + if (SkPaint::kLow_FilterLevel == fFilterLevel) { |
| // Only try bilerp if the matrix is "interesting" and |
| // the image has a suitable size. |
| if (fInvType <= SkMatrix::kTranslate_Mask || |
| - !valid_for_filtering(fBitmap->width() | fBitmap->height())) { |
| - fFilterQuality = kNone_BitmapFilter; |
| + !valid_for_filtering(fBitmap->width() | fBitmap->height())) { |
| + fFilterLevel = SkPaint::kNone_FilterLevel; |
| } |
| } |
| @@ -305,7 +301,7 @@ bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) { |
| // still set to HQ by the time we get here, then we must have installed |
| // the shader proc above and can skip all this. |
| - if (fFilterQuality < kHQ_BitmapFilter) { |
| + if (fFilterLevel < SkPaint::kHigh_FilterLevel) { |
| int index = 0; |
| if (fAlphaScale < 256) { // note: this distinction is not used for D16 |
| @@ -314,7 +310,7 @@ bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) { |
| if (fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) { |
| index |= 2; |
| } |
| - if (fFilterQuality != kNone_BitmapFilter) { |
| + if (fFilterLevel > SkPaint::kNone_FilterLevel) { |
| index |= 4; |
| } |
| // bits 3,4,5 encoding the source bitmap format |
| @@ -445,7 +441,7 @@ static void Clamp_S32_D32_nofilter_trans_shaderproc(const SkBitmapProcState& s, |
| SkASSERT(((s.fInvType & ~SkMatrix::kTranslate_Mask)) == 0); |
| SkASSERT(s.fInvKy == 0); |
| SkASSERT(count > 0 && colors != NULL); |
| - SkASSERT(SkBitmapProcState::kNone_BitmapFilter == s.fFilterQuality); |
| + SkASSERT(SkPaint::kNone_FilterLevel == s.fFilterLevel); |
| const int maxX = s.fBitmap->width() - 1; |
| const int maxY = s.fBitmap->height() - 1; |
| @@ -519,7 +515,7 @@ static void Repeat_S32_D32_nofilter_trans_shaderproc(const SkBitmapProcState& s, |
| SkASSERT(((s.fInvType & ~SkMatrix::kTranslate_Mask)) == 0); |
| SkASSERT(s.fInvKy == 0); |
| SkASSERT(count > 0 && colors != NULL); |
| - SkASSERT(SkBitmapProcState::kNone_BitmapFilter == s.fFilterQuality); |
| + SkASSERT(SkPaint::kNone_FilterLevel == s.fFilterLevel); |
| const int stopX = s.fBitmap->width(); |
| const int stopY = s.fBitmap->height(); |
| @@ -565,7 +561,7 @@ static void S32_D32_constX_shaderproc(const SkBitmapProcState& s, |
| int iY1 SK_INIT_TO_AVOID_WARNING; |
| int iSubY SK_INIT_TO_AVOID_WARNING; |
| - if (s.fFilterQuality != SkBitmapProcState::kNone_BitmapFilter) { |
| + if (SkPaint::kNone_FilterLevel != s.fFilterLevel) { |
| SkBitmapProcState::MatrixProc mproc = s.getMatrixProc(); |
| uint32_t xy[2]; |
| @@ -646,7 +642,7 @@ static void S32_D32_constX_shaderproc(const SkBitmapProcState& s, |
| const SkPMColor* row0 = s.fBitmap->getAddr32(0, iY0); |
| SkPMColor color; |
| - if (s.fFilterQuality != SkBitmapProcState::kNone_BitmapFilter) { |
| + if (SkPaint::kNone_FilterLevel != s.fFilterLevel) { |
| const SkPMColor* row1 = s.fBitmap->getAddr32(0, iY1); |
| if (s.fAlphaScale < 256) { |
| @@ -702,7 +698,7 @@ SkBitmapProcState::ShaderProc32 SkBitmapProcState::chooseShaderProc32() { |
| static const unsigned kMask = SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask; |
| if (1 == fBitmap->width() && 0 == (fInvType & ~kMask)) { |
| - if (kNone_BitmapFilter == fFilterQuality && |
| + if (SkPaint::kNone_FilterLevel == fFilterLevel && |
| fInvType <= SkMatrix::kTranslate_Mask && |
| !this->setupForTranslate()) { |
| return DoNothing_shaderproc; |
| @@ -716,7 +712,7 @@ SkBitmapProcState::ShaderProc32 SkBitmapProcState::chooseShaderProc32() { |
| if (fInvType > SkMatrix::kTranslate_Mask) { |
| return NULL; |
| } |
| - if (fFilterQuality != kNone_BitmapFilter) { |
| + if (SkPaint::kNone_FilterLevel != fFilterLevel) { |
| return NULL; |
| } |
| @@ -812,9 +808,9 @@ void SkBitmapProcState::DebugMatrixProc(const SkBitmapProcState& state, |
| // scale -vs- affine |
| // filter -vs- nofilter |
| if (state.fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) { |
| - proc = state.fFilterQuality != kNone_BitmapFilter ? check_scale_filter : check_scale_nofilter; |
| + proc = state.fFilterLevel != SkPaint::kNone_FilterLevel ? check_scale_filter : check_scale_nofilter; |
| } else { |
| - proc = state.fFilterQuality != kNone_BitmapFilter ? check_affine_filter : check_affine_nofilter; |
| + proc = state.fFilterLevel != SkPaint::kNone_FilterLevel ? check_affine_filter : check_affine_nofilter; |
| } |
| proc(bitmapXY, count, state.fBitmap->width(), state.fBitmap->height()); |
| } |
| @@ -849,7 +845,7 @@ int SkBitmapProcState::maxCountForBufferSize(size_t bufferSize) const { |
| size >>= 2; |
| } |
| - if (fFilterQuality != kNone_BitmapFilter) { |
| + if (fFilterLevel != SkPaint::kNone_FilterLevel) { |
| size >>= 1; |
| } |