Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Unified Diff: src/core/SkBitmapProcState.cpp

Issue 18721006: fix trivial matrix computation (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkBitmapProcState.h ('k') | src/core/SkBitmapProcState_matrix.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkBitmapProcState.cpp
diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp
index a2c7f990c2d9b19fe5ee238de9eae68757a62c3b..a8a9b03d9ad7e13e00eb991d005114040c957849 100644
--- a/src/core/SkBitmapProcState.cpp
+++ b/src/core/SkBitmapProcState.cpp
@@ -90,220 +90,346 @@ static bool valid_for_filtering(unsigned dimension) {
return (dimension & ~0x3FFF) == 0;
}
+// TODO -- we may want to pass the clip into this function so we only scale
+// the portion of the image that we're going to need. This will complicate
+// the interface to the cache, but might be well worth it.
+
+void SkBitmapProcState::possiblyScaleImage() {
+
+ if (fFilterQuality != kHQ_BitmapFilter) {
+ return;
+ }
+
+ // STEP 1: UPSAMPLE?
+
+ // Check to see if the transformation matrix is scaling up, and if
+ // 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) &&
+ (fInvMatrix.getScaleX() < 1 || fInvMatrix.getScaleY() < 1) &&
+ fOrigBitmap.config() == SkBitmap::kARGB_8888_Config) {
+
+ // All the criteria are met; let's make a new bitmap.
+ fScaledBitmap.setConfig(SkBitmap::kARGB_8888_Config,
+ (int)(fOrigBitmap.width() / fInvMatrix.getScaleX()),
+ (int)(fOrigBitmap.height() / fInvMatrix.getScaleY()));
+ fScaledBitmap.allocPixels();
+ fOrigBitmap.scale(&fScaledBitmap);
+ fBitmap = &fScaledBitmap;
+
+ // set the inv matrix type to translate-only;
+
+ fInvMatrix.setTranslate( 1/fInvMatrix.getScaleX() * fInvMatrix.getTranslateX(),
+ 1/fInvMatrix.getScaleY() * fInvMatrix.getTranslateY() );
+
+ // no need for any further filtering; we just did it!
+
+ fFilterQuality = kNone_BitmapFilter;
+
+ return;
+ }
+
+ if (!fOrigBitmap.hasMipMap()) {
+
+ // STEP 2: DOWNSAMPLE
+
+ // Check to see if the transformation matrix is scaling *down*.
+ // If so, automatically build mipmaps.
+
+ SkPoint v1, v2;
+
+ // conservatively estimate if the matrix is scaling down by seeing
+ // what its upper left 2x2 portion does to two unit vectors.
+
+ v1.fX = fInvMatrix.getScaleX();
+ v1.fY = fInvMatrix.getSkewY();
+
+ v2.fX = fInvMatrix.getSkewX();
+ v2.fY = fInvMatrix.getScaleY();
+
+ if (v1.fX * v1.fX + v1.fY * v1.fY > 1 ||
+ v2.fX * v2.fX + v2.fY * v2.fY > 1) {
+ fOrigBitmap.buildMipMap();
+
+ // Now that we've built the mipmaps and we know we're downsampling,
+ // downgrade to bilinear interpolation for the mip level.
+
+ fFilterQuality = kBilerp_BitmapFilter;
+ }
+ }
+
+ if (fOrigBitmap.hasMipMap()) {
+
+ // STEP 3: We've got mipmaps, let's choose the closest level as our render
+ // source and adjust the matrix accordingly.
+
+ int shift = fOrigBitmap.extractMipLevel(&fScaledBitmap,
+ SkScalarToFixed(fInvMatrix.getScaleX()),
+ SkScalarToFixed(fInvMatrix.getSkewY()));
+
+ if (shift > 0) {
+ SkScalar scale = SkFixedToScalar(SK_Fixed1 >> shift);
+ fInvMatrix.postScale(scale, scale);
+ fBitmap = &fScaledBitmap;
+ }
+ }
+}
+
+void SkBitmapProcState::endContext() {
+ SkDELETE(fBitmapFilter);
+ fBitmapFilter = NULL;
+ fScaledBitmap.reset();
+}
+
bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) {
if (fOrigBitmap.width() == 0 || fOrigBitmap.height() == 0) {
return false;
}
- const SkMatrix* m;
- bool trivial_matrix = (inv.getType() & ~SkMatrix::kTranslate_Mask) == 0;
- bool clamp_clamp = SkShader::kClamp_TileMode == fTileModeX &&
+ bool trivialMatrix = (inv.getType() & ~SkMatrix::kTranslate_Mask) == 0;
+ bool clampClamp = SkShader::kClamp_TileMode == fTileModeX &&
SkShader::kClamp_TileMode == fTileModeY;
- if (clamp_clamp || trivial_matrix) {
- m = &inv;
- } else {
- fUnitInvMatrix = inv;
- fUnitInvMatrix.postIDiv(fOrigBitmap.width(), fOrigBitmap.height());
- m = &fUnitInvMatrix;
+ fInvMatrix = inv;
+ if (!(clampClamp || trivialMatrix)) {
+ fInvMatrix.postIDiv(fOrigBitmap.width(), fOrigBitmap.height());
}
fBitmap = &fOrigBitmap;
- if (fOrigBitmap.hasMipMap()) {
- int shift = fOrigBitmap.extractMipLevel(&fMipBitmap,
- SkScalarToFixed(m->getScaleX()),
- SkScalarToFixed(m->getSkewY()));
- if (shift > 0) {
- if (m != &fUnitInvMatrix) {
- fUnitInvMatrix = *m;
- m = &fUnitInvMatrix;
- }
+ // initialize our filter quality to the one requested by the caller.
+ // 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.
- SkScalar scale = SkFixedToScalar(SK_Fixed1 >> shift);
- fUnitInvMatrix.postScale(scale, scale);
-
- // now point here instead of fOrigBitmap
- fBitmap = &fMipBitmap;
+ fFilterQuality = kNone_BitmapFilter;
+ if (paint.isFilterBitmap()) {
+ if (paint.getFlags() & SkPaint::kHighQualityFilterBitmap_Flag) {
+ fFilterQuality = kHQ_BitmapFilter;
+ } else {
+ fFilterQuality = kBilerp_BitmapFilter;
}
}
- // wack our matrix to exactly no-scale, if we're really close to begin with
- if (matrix_only_scale_translate(*m)) {
+#ifndef SK_IGNORE_IMAGE_PRESCALE
+ // possiblyScaleImage will look to see if it can rescale the image as a
+ // preprocess; either by scaling up to the target size, or by selecting
+ // a nearby mipmap level. If it does, it will adjust the working
+ // matrix as well as the working bitmap. It may also adjust the filter
+ // quality to avoid re-filtering an already perfectly scaled image.
+
+ this->possiblyScaleImage();
+#endif
+
+ // Now that all possible changes to the matrix have taken place, check
+ // to see if we're really close to a no-scale matrix. If so, explicitly
+ // set it to be so. Subsequent code may inspect this matrix to choose
+ // a faster path in this case.
+
+ // This code will only execute if the matrix has some scale component;
+ // if it's already pure translate then we won't do this inversion.
+
+ if (matrix_only_scale_translate(fInvMatrix)) {
SkMatrix forward;
- if (m->invert(&forward)) {
- if (clamp_clamp ? just_trans_clamp(forward, *fBitmap)
+ if (fInvMatrix.invert(&forward)) {
+ if (clampClamp ? just_trans_clamp(forward, *fBitmap)
: just_trans_general(forward)) {
SkScalar tx = -SkScalarRoundToScalar(forward.getTranslateX());
SkScalar ty = -SkScalarRoundToScalar(forward.getTranslateY());
- fUnitInvMatrix.setTranslate(tx, ty);
- m = &fUnitInvMatrix;
- // now the following code will sniff m, and decide to take the
- // fast case (since m is purely translate).
+ fInvMatrix.setTranslate(tx, ty);
+
}
}
}
- // Below this point, we should never refer to the inv parameter, since we
- // may be using a munged version for "our" inverse.
-
- fInvMatrix = m;
- fInvProc = m->getMapXYProc();
- fInvType = m->getType();
- fInvSx = SkScalarToFixed(m->getScaleX());
- fInvSxFractionalInt = SkScalarToFractionalInt(m->getScaleX());
- fInvKy = SkScalarToFixed(m->getSkewY());
- fInvKyFractionalInt = SkScalarToFractionalInt(m->getSkewY());
+ 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());
- // pick-up filtering from the paint, but only if the matrix is
- // more complex than identity/translate (i.e. no need to pay the cost
- // of filtering if we're not scaled etc.).
- // note: we explicitly check inv, since m might be scaled due to unitinv
- // trickery, but we don't want to see that for this test
- fDoFilter = paint.isFilterBitmap() &&
- (fInvType > SkMatrix::kTranslate_Mask &&
- valid_for_filtering(fBitmap->width() | fBitmap->height()));
-
fShaderProc32 = NULL;
fShaderProc16 = NULL;
fSampleProc32 = NULL;
fSampleProc16 = NULL;
- fMatrixProc = this->chooseMatrixProc(trivial_matrix);
+ // recompute the triviality of the matrix here because we may have
+ // changed it!
+
+ trivialMatrix = (fInvMatrix.getType() & ~SkMatrix::kTranslate_Mask) == 0;
+
+ if (kHQ_BitmapFilter == fFilterQuality) {
+ // 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,
+ // downgrade to bilerp.
+
+ // NOTE: Might need to be careful here in the future when we want
+ // to have the platform proc have a shot at this; it's possible that
+ // the chooseBitmapFilterProc will fail to install a shader but a
+ // platform-specific one might succeed, so it might be premature here
+ // to fall back to bilerp. This needs thought.
+
+ SkASSERT(fInvType > SkMatrix::kTranslate_Mask);
+
+ fShaderProc32 = this->chooseBitmapFilterProc();
+ if (!fShaderProc32) {
+ fFilterQuality = kBilerp_BitmapFilter;
+ }
+ }
+
+ if (kBilerp_BitmapFilter == fFilterQuality) {
+ // 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;
+ }
+ }
+
+ // At this point, we know exactly what kind of sampling the per-scanline
+ // shader will perform.
+
+ fMatrixProc = this->chooseMatrixProc(trivialMatrix);
if (NULL == fMatrixProc) {
return false;
}
///////////////////////////////////////////////////////////////////////
- int index = 0;
- if (fAlphaScale < 256) { // note: this distinction is not used for D16
- index |= 1;
- }
- if (fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) {
- index |= 2;
- }
- if (fDoFilter) {
- index |= 4;
- }
- // bits 3,4,5 encoding the source bitmap format
- switch (fBitmap->config()) {
- case SkBitmap::kARGB_8888_Config:
- index |= 0;
- break;
- case SkBitmap::kRGB_565_Config:
- index |= 8;
- break;
- case SkBitmap::kIndex8_Config:
- index |= 16;
- break;
- case SkBitmap::kARGB_4444_Config:
- index |= 24;
- break;
- case SkBitmap::kA8_Config:
- index |= 32;
- fPaintPMColor = SkPreMultiplyColor(paint.getColor());
- break;
- default:
- return false;
- }
+ // No need to do this if we're doing HQ sampling; if filter quality is
+ // 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 !SK_ARM_NEON_IS_ALWAYS
- static const SampleProc32 gSkBitmapProcStateSample32[] = {
- S32_opaque_D32_nofilter_DXDY,
- S32_alpha_D32_nofilter_DXDY,
- S32_opaque_D32_nofilter_DX,
- S32_alpha_D32_nofilter_DX,
- S32_opaque_D32_filter_DXDY,
- S32_alpha_D32_filter_DXDY,
- S32_opaque_D32_filter_DX,
- S32_alpha_D32_filter_DX,
-
- S16_opaque_D32_nofilter_DXDY,
- S16_alpha_D32_nofilter_DXDY,
- S16_opaque_D32_nofilter_DX,
- S16_alpha_D32_nofilter_DX,
- S16_opaque_D32_filter_DXDY,
- S16_alpha_D32_filter_DXDY,
- S16_opaque_D32_filter_DX,
- S16_alpha_D32_filter_DX,
-
- SI8_opaque_D32_nofilter_DXDY,
- SI8_alpha_D32_nofilter_DXDY,
- SI8_opaque_D32_nofilter_DX,
- SI8_alpha_D32_nofilter_DX,
- SI8_opaque_D32_filter_DXDY,
- SI8_alpha_D32_filter_DXDY,
- SI8_opaque_D32_filter_DX,
- SI8_alpha_D32_filter_DX,
-
- S4444_opaque_D32_nofilter_DXDY,
- S4444_alpha_D32_nofilter_DXDY,
- S4444_opaque_D32_nofilter_DX,
- S4444_alpha_D32_nofilter_DX,
- S4444_opaque_D32_filter_DXDY,
- S4444_alpha_D32_filter_DXDY,
- S4444_opaque_D32_filter_DX,
- S4444_alpha_D32_filter_DX,
-
- // A8 treats alpha/opaque the same (equally efficient)
- SA8_alpha_D32_nofilter_DXDY,
- SA8_alpha_D32_nofilter_DXDY,
- SA8_alpha_D32_nofilter_DX,
- SA8_alpha_D32_nofilter_DX,
- SA8_alpha_D32_filter_DXDY,
- SA8_alpha_D32_filter_DXDY,
- SA8_alpha_D32_filter_DX,
- SA8_alpha_D32_filter_DX
- };
-
- static const SampleProc16 gSkBitmapProcStateSample16[] = {
- S32_D16_nofilter_DXDY,
- S32_D16_nofilter_DX,
- S32_D16_filter_DXDY,
- S32_D16_filter_DX,
-
- S16_D16_nofilter_DXDY,
- S16_D16_nofilter_DX,
- S16_D16_filter_DXDY,
- S16_D16_filter_DX,
-
- SI8_D16_nofilter_DXDY,
- SI8_D16_nofilter_DX,
- SI8_D16_filter_DXDY,
- SI8_D16_filter_DX,
-
- // Don't support 4444 -> 565
- NULL, NULL, NULL, NULL,
- // Don't support A8 -> 565
- NULL, NULL, NULL, NULL
- };
-#endif
+ if (fFilterQuality < kHQ_BitmapFilter) {
- fSampleProc32 = SK_ARM_NEON_WRAP(gSkBitmapProcStateSample32)[index];
- index >>= 1; // shift away any opaque/alpha distinction
- fSampleProc16 = SK_ARM_NEON_WRAP(gSkBitmapProcStateSample16)[index];
-
- // our special-case shaderprocs
- if (SK_ARM_NEON_WRAP(S16_D16_filter_DX) == fSampleProc16) {
- if (clamp_clamp) {
- fShaderProc16 = SK_ARM_NEON_WRAP(Clamp_S16_D16_filter_DX_shaderproc);
- } else if (SkShader::kRepeat_TileMode == fTileModeX &&
- SkShader::kRepeat_TileMode == fTileModeY) {
- fShaderProc16 = SK_ARM_NEON_WRAP(Repeat_S16_D16_filter_DX_shaderproc);
+ int index = 0;
+ if (fAlphaScale < 256) { // note: this distinction is not used for D16
+ index |= 1;
+ }
+ if (fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) {
+ index |= 2;
+ }
+ if (fFilterQuality != kNone_BitmapFilter) {
+ index |= 4;
+ }
+ // bits 3,4,5 encoding the source bitmap format
+ switch (fBitmap->config()) {
+ case SkBitmap::kARGB_8888_Config:
+ index |= 0;
+ break;
+ case SkBitmap::kRGB_565_Config:
+ index |= 8;
+ break;
+ case SkBitmap::kIndex8_Config:
+ index |= 16;
+ break;
+ case SkBitmap::kARGB_4444_Config:
+ index |= 24;
+ break;
+ case SkBitmap::kA8_Config:
+ index |= 32;
+ fPaintPMColor = SkPreMultiplyColor(paint.getColor());
+ break;
+ default:
+ return false;
}
- } else if (SK_ARM_NEON_WRAP(SI8_opaque_D32_filter_DX) == fSampleProc32 && clamp_clamp) {
- fShaderProc32 = SK_ARM_NEON_WRAP(Clamp_SI8_opaque_D32_filter_DX_shaderproc);
- }
- if (NULL == fShaderProc32) {
- fShaderProc32 = this->chooseShaderProc32();
- }
+ #if !SK_ARM_NEON_IS_ALWAYS
+ static const SampleProc32 gSkBitmapProcStateSample32[] = {
+ S32_opaque_D32_nofilter_DXDY,
+ S32_alpha_D32_nofilter_DXDY,
+ S32_opaque_D32_nofilter_DX,
+ S32_alpha_D32_nofilter_DX,
+ S32_opaque_D32_filter_DXDY,
+ S32_alpha_D32_filter_DXDY,
+ S32_opaque_D32_filter_DX,
+ S32_alpha_D32_filter_DX,
+
+ S16_opaque_D32_nofilter_DXDY,
+ S16_alpha_D32_nofilter_DXDY,
+ S16_opaque_D32_nofilter_DX,
+ S16_alpha_D32_nofilter_DX,
+ S16_opaque_D32_filter_DXDY,
+ S16_alpha_D32_filter_DXDY,
+ S16_opaque_D32_filter_DX,
+ S16_alpha_D32_filter_DX,
+
+ SI8_opaque_D32_nofilter_DXDY,
+ SI8_alpha_D32_nofilter_DXDY,
+ SI8_opaque_D32_nofilter_DX,
+ SI8_alpha_D32_nofilter_DX,
+ SI8_opaque_D32_filter_DXDY,
+ SI8_alpha_D32_filter_DXDY,
+ SI8_opaque_D32_filter_DX,
+ SI8_alpha_D32_filter_DX,
+
+ S4444_opaque_D32_nofilter_DXDY,
+ S4444_alpha_D32_nofilter_DXDY,
+ S4444_opaque_D32_nofilter_DX,
+ S4444_alpha_D32_nofilter_DX,
+ S4444_opaque_D32_filter_DXDY,
+ S4444_alpha_D32_filter_DXDY,
+ S4444_opaque_D32_filter_DX,
+ S4444_alpha_D32_filter_DX,
+
+ // A8 treats alpha/opaque the same (equally efficient)
+ SA8_alpha_D32_nofilter_DXDY,
+ SA8_alpha_D32_nofilter_DXDY,
+ SA8_alpha_D32_nofilter_DX,
+ SA8_alpha_D32_nofilter_DX,
+ SA8_alpha_D32_filter_DXDY,
+ SA8_alpha_D32_filter_DXDY,
+ SA8_alpha_D32_filter_DX,
+ SA8_alpha_D32_filter_DX
+ };
+
+ static const SampleProc16 gSkBitmapProcStateSample16[] = {
+ S32_D16_nofilter_DXDY,
+ S32_D16_nofilter_DX,
+ S32_D16_filter_DXDY,
+ S32_D16_filter_DX,
+
+ S16_D16_nofilter_DXDY,
+ S16_D16_nofilter_DX,
+ S16_D16_filter_DXDY,
+ S16_D16_filter_DX,
+
+ SI8_D16_nofilter_DXDY,
+ SI8_D16_nofilter_DX,
+ SI8_D16_filter_DXDY,
+ SI8_D16_filter_DX,
+
+ // Don't support 4444 -> 565
+ NULL, NULL, NULL, NULL,
+ // Don't support A8 -> 565
+ NULL, NULL, NULL, NULL
+ };
+ #endif
+
+ fSampleProc32 = SK_ARM_NEON_WRAP(gSkBitmapProcStateSample32)[index];
+ index >>= 1; // shift away any opaque/alpha distinction
+ fSampleProc16 = SK_ARM_NEON_WRAP(gSkBitmapProcStateSample16)[index];
+
+ // our special-case shaderprocs
+ if (SK_ARM_NEON_WRAP(S16_D16_filter_DX) == fSampleProc16) {
+ if (clampClamp) {
+ fShaderProc16 = SK_ARM_NEON_WRAP(Clamp_S16_D16_filter_DX_shaderproc);
+ } else if (SkShader::kRepeat_TileMode == fTileModeX &&
+ SkShader::kRepeat_TileMode == fTileModeY) {
+ fShaderProc16 = SK_ARM_NEON_WRAP(Repeat_S16_D16_filter_DX_shaderproc);
+ }
+ } else if (SK_ARM_NEON_WRAP(SI8_opaque_D32_filter_DX) == fSampleProc32 && clampClamp) {
+ fShaderProc32 = SK_ARM_NEON_WRAP(Clamp_SI8_opaque_D32_filter_DX_shaderproc);
+ }
- if (NULL == fShaderProc32) {
- fShaderProc32 = this->chooseBitmapFilterProc(paint);
+ if (NULL == fShaderProc32) {
+ fShaderProc32 = this->chooseShaderProc32();
+ }
}
// see if our platform has any accelerated overrides
@@ -319,7 +445,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(!s.fDoFilter);
+ SkASSERT(SkBitmapProcState::kNone_BitmapFilter == s.fFilterQuality);
const int maxX = s.fBitmap->width() - 1;
const int maxY = s.fBitmap->height() - 1;
@@ -328,7 +454,7 @@ static void Clamp_S32_D32_nofilter_trans_shaderproc(const SkBitmapProcState& s,
#ifdef SK_DEBUG
{
SkPoint pt;
- s.fInvProc(*s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf,
+ s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf,
SkIntToScalar(y) + SK_ScalarHalf, &pt);
int iy2 = SkClampMax(SkScalarFloorToInt(pt.fY), maxY);
int ix2 = SkScalarFloorToInt(pt.fX);
@@ -393,7 +519,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(!s.fDoFilter);
+ SkASSERT(SkBitmapProcState::kNone_BitmapFilter == s.fFilterQuality);
const int stopX = s.fBitmap->width();
const int stopY = s.fBitmap->height();
@@ -402,7 +528,7 @@ static void Repeat_S32_D32_nofilter_trans_shaderproc(const SkBitmapProcState& s,
#ifdef SK_DEBUG
{
SkPoint pt;
- s.fInvProc(*s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf,
+ s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf,
SkIntToScalar(y) + SK_ScalarHalf, &pt);
int iy2 = sk_int_mod(SkScalarFloorToInt(pt.fY), stopY);
int ix2 = SkScalarFloorToInt(pt.fX);
@@ -439,7 +565,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.fDoFilter) {
+ if (s.fFilterQuality != SkBitmapProcState::kNone_BitmapFilter) {
SkBitmapProcState::MatrixProc mproc = s.getMatrixProc();
uint32_t xy[2];
@@ -453,7 +579,7 @@ static void S32_D32_constX_shaderproc(const SkBitmapProcState& s,
if (s.fInvType > SkMatrix::kTranslate_Mask) {
SkPoint pt;
- s.fInvProc(*s.fInvMatrix,
+ s.fInvProc(s.fInvMatrix,
SkIntToScalar(x) + SK_ScalarHalf,
SkIntToScalar(y) + SK_ScalarHalf,
&pt);
@@ -488,7 +614,7 @@ static void S32_D32_constX_shaderproc(const SkBitmapProcState& s,
#ifdef SK_DEBUG
{
SkPoint pt;
- s.fInvProc(*s.fInvMatrix,
+ s.fInvProc(s.fInvMatrix,
SkIntToScalar(x) + SK_ScalarHalf,
SkIntToScalar(y) + SK_ScalarHalf,
&pt);
@@ -520,7 +646,7 @@ static void S32_D32_constX_shaderproc(const SkBitmapProcState& s,
const SkPMColor* row0 = s.fBitmap->getAddr32(0, iY0);
SkPMColor color;
- if (s.fDoFilter) {
+ if (s.fFilterQuality != SkBitmapProcState::kNone_BitmapFilter) {
const SkPMColor* row1 = s.fBitmap->getAddr32(0, iY1);
if (s.fAlphaScale < 256) {
@@ -547,7 +673,7 @@ static void DoNothing_shaderproc(const SkBitmapProcState&, int x, int y,
bool SkBitmapProcState::setupForTranslate() {
SkPoint pt;
- fInvProc(*fInvMatrix, SK_ScalarHalf, SK_ScalarHalf, &pt);
+ fInvProc(fInvMatrix, SK_ScalarHalf, SK_ScalarHalf, &pt);
/*
* if the translate is larger than our ints, we can get random results, or
@@ -576,7 +702,9 @@ SkBitmapProcState::ShaderProc32 SkBitmapProcState::chooseShaderProc32() {
static const unsigned kMask = SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask;
if (1 == fBitmap->width() && 0 == (fInvType & ~kMask)) {
- if (!fDoFilter && fInvType <= SkMatrix::kTranslate_Mask && !this->setupForTranslate()) {
+ if (kNone_BitmapFilter == fFilterQuality &&
+ fInvType <= SkMatrix::kTranslate_Mask &&
+ !this->setupForTranslate()) {
return DoNothing_shaderproc;
}
return S32_D32_constX_shaderproc;
@@ -588,7 +716,7 @@ SkBitmapProcState::ShaderProc32 SkBitmapProcState::chooseShaderProc32() {
if (fInvType > SkMatrix::kTranslate_Mask) {
return NULL;
}
- if (fDoFilter) {
+ if (fFilterQuality != kNone_BitmapFilter) {
return NULL;
}
@@ -684,9 +812,9 @@ void SkBitmapProcState::DebugMatrixProc(const SkBitmapProcState& state,
// scale -vs- affine
// filter -vs- nofilter
if (state.fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) {
- proc = state.fDoFilter ? check_scale_filter : check_scale_nofilter;
+ proc = state.fFilterQuality != kNone_BitmapFilter ? check_scale_filter : check_scale_nofilter;
} else {
- proc = state.fDoFilter ? check_affine_filter : check_affine_nofilter;
+ proc = state.fFilterQuality != kNone_BitmapFilter ? check_affine_filter : check_affine_nofilter;
}
proc(bitmapXY, count, state.fBitmap->width(), state.fBitmap->height());
}
@@ -721,7 +849,7 @@ int SkBitmapProcState::maxCountForBufferSize(size_t bufferSize) const {
size >>= 2;
}
- if (fDoFilter) {
+ if (fFilterQuality != kNone_BitmapFilter) {
size >>= 1;
}
« no previous file with comments | « src/core/SkBitmapProcState.h ('k') | src/core/SkBitmapProcState_matrix.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698