diff options
author | 2015-08-12 12:57:54 -0700 | |
---|---|---|
committer | 2015-08-12 12:57:54 -0700 | |
commit | 9bc3954fc1b6c3fb609cbb10d42f659b9d762eb0 (patch) | |
tree | 4b915a701b43217e08c3fa0ae551011c504a9542 /src/gpu/SkGr.cpp | |
parent | 33e00db73d5f1836481cf4053c64e4ed20537662 (diff) |
Refactor helper function for SkBitmapShader to GrFragmentProcessor
BUG=skia:
Review URL: https://codereview.chromium.org/1285283002
Diffstat (limited to 'src/gpu/SkGr.cpp')
-rw-r--r-- | src/gpu/SkGr.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp index 9aa79618a2..53f640b601 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; +} |