Index: src/gpu/SkGr.cpp |
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp |
index 9aa79618a2dd04f9bd597e97e53b8a5c89b747e6..53f640b6013f87c84d8f6286ec69beb7e96cb4dc 100644 |
--- a/src/gpu/SkGr.cpp |
+++ b/src/gpu/SkGr.cpp |
@@ -21,6 +21,7 @@ |
#include "SkResourceCache.h" |
#include "SkTextureCompressor.h" |
#include "SkYUVPlanesCache.h" |
+#include "effects/GrBicubicEffect.h" |
#include "effects/GrDitherEffect.h" |
#include "effects/GrPorterDuffXferProcessor.h" |
#include "effects/GrYUVtoRGBEffect.h" |
@@ -835,3 +836,45 @@ void GrWrapTextureInBitmap(GrTexture* src, int w, int h, bool isOpaque, SkBitmap |
dst->setInfo(info); |
dst->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, src)))->unref(); |
} |
+ |
+GrTextureParams::FilterMode GrSkFilterQualityToGrFilterMode(SkFilterQuality paintFilterQuality, |
+ const SkMatrix& viewM, |
+ const SkMatrix& localM, |
+ bool* doBicubic) { |
+ *doBicubic = false; |
+ GrTextureParams::FilterMode textureFilterMode; |
+ switch (paintFilterQuality) { |
+ case kNone_SkFilterQuality: |
+ textureFilterMode = GrTextureParams::kNone_FilterMode; |
+ break; |
+ case kLow_SkFilterQuality: |
+ textureFilterMode = GrTextureParams::kBilerp_FilterMode; |
+ break; |
+ case kMedium_SkFilterQuality: { |
+ SkMatrix matrix; |
+ matrix.setConcat(viewM, localM); |
+ if (matrix.getMinScale() < SK_Scalar1) { |
+ textureFilterMode = GrTextureParams::kMipMap_FilterMode; |
+ } else { |
+ // Don't trigger MIP level generation unnecessarily. |
+ textureFilterMode = GrTextureParams::kBilerp_FilterMode; |
+ } |
+ break; |
+ } |
+ case kHigh_SkFilterQuality: { |
+ SkMatrix matrix; |
+ matrix.setConcat(viewM, localM); |
+ *doBicubic = GrBicubicEffect::ShouldUseBicubic(matrix, &textureFilterMode); |
+ break; |
+ } |
+ default: |
+ SkErrorInternals::SetError( kInvalidPaint_SkError, |
+ "Sorry, I don't understand the filtering " |
+ "mode you asked for. Falling back to " |
+ "MIPMaps."); |
+ textureFilterMode = GrTextureParams::kMipMap_FilterMode; |
+ break; |
+ |
+ } |
+ return textureFilterMode; |
+} |