aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2015-08-12 12:57:54 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-08-12 12:57:54 -0700
commit9bc3954fc1b6c3fb609cbb10d42f659b9d762eb0 (patch)
tree4b915a701b43217e08c3fa0ae551011c504a9542 /src/core
parent33e00db73d5f1836481cf4053c64e4ed20537662 (diff)
Refactor helper function for SkBitmapShader to GrFragmentProcessor
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkBitmapProcShader.cpp43
1 files changed, 6 insertions, 37 deletions
diff --git a/src/core/SkBitmapProcShader.cpp b/src/core/SkBitmapProcShader.cpp
index 5a33af55ba..9086072f98 100644
--- a/src/core/SkBitmapProcShader.cpp
+++ b/src/core/SkBitmapProcShader.cpp
@@ -349,8 +349,8 @@ void SkBitmapProcShader::toString(SkString* str) const {
#if SK_SUPPORT_GPU
#include "GrTextureAccess.h"
-#include "effects/GrSimpleTextureEffect.h"
#include "SkGr.h"
+#include "effects/GrSimpleTextureEffect.h"
bool SkBitmapProcShader::asFragmentProcessor(GrContext* context, const SkPaint& paint,
const SkMatrix& viewM,
@@ -382,41 +382,10 @@ bool SkBitmapProcShader::asFragmentProcessor(GrContext* context, const SkPaint&
// we check the matrix scale factors to determine how to interpret the filter quality setting.
// This completely ignores the complexity of the drawVertices case where explicit local coords
// are provided by the caller.
- bool useBicubic = false;
- GrTextureParams::FilterMode textureFilterMode;
- switch(paint.getFilterQuality()) {
- case kNone_SkFilterQuality:
- textureFilterMode = GrTextureParams::kNone_FilterMode;
- break;
- case kLow_SkFilterQuality:
- textureFilterMode = GrTextureParams::kBilerp_FilterMode;
- break;
- case kMedium_SkFilterQuality: {
- SkMatrix matrix;
- matrix.setConcat(viewM, this->getLocalMatrix());
- 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, this->getLocalMatrix());
- useBicubic = 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;
-
- }
+ bool doBicubic;
+ GrTextureParams::FilterMode textureFilterMode =
+ GrSkFilterQualityToGrFilterMode(paint.getFilterQuality(), viewM, this->getLocalMatrix(),
+ &doBicubic);
GrTextureParams params(tm, textureFilterMode);
SkAutoTUnref<GrTexture> texture(GrRefCachedBitmapTexture(context, fRawBitmap, &params));
@@ -430,7 +399,7 @@ bool SkBitmapProcShader::asFragmentProcessor(GrContext* context, const SkPaint&
SkColor2GrColor(paint.getColor()) :
SkColor2GrColorJustAlpha(paint.getColor());
- if (useBicubic) {
+ if (doBicubic) {
*fp = GrBicubicEffect::Create(procDataManager, texture, matrix, tm);
} else {
*fp = GrSimpleTextureEffect::Create(procDataManager, texture, matrix, params);