aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/gpu/GrTextureAccess.h4
-rw-r--r--src/core/SkBitmapProcShader.cpp2
-rw-r--r--src/gpu/SkGpuDevice.cpp4
-rw-r--r--src/gpu/effects/GrBicubicEffect.cpp17
-rw-r--r--src/gpu/effects/GrBicubicEffect.h44
5 files changed, 35 insertions, 36 deletions
diff --git a/include/gpu/GrTextureAccess.h b/include/gpu/GrTextureAccess.h
index 059800f05b..87b8d827cd 100644
--- a/include/gpu/GrTextureAccess.h
+++ b/include/gpu/GrTextureAccess.h
@@ -36,7 +36,7 @@ public:
this->reset(tileXAndY, filterMode);
}
- GrTextureParams(SkShader::TileMode tileModes[2], FilterMode filterMode) {
+ GrTextureParams(const SkShader::TileMode tileModes[2], FilterMode filterMode) {
this->reset(tileModes, filterMode);
}
@@ -60,7 +60,7 @@ public:
fFilterMode = filterMode;
}
- void reset(SkShader::TileMode tileModes[2], FilterMode filterMode) {
+ void reset(const SkShader::TileMode tileModes[2], FilterMode filterMode) {
fTileModes[0] = tileModes[0];
fTileModes[1] = tileModes[1];
fFilterMode = filterMode;
diff --git a/src/core/SkBitmapProcShader.cpp b/src/core/SkBitmapProcShader.cpp
index fcfcdbf035..bb16119276 100644
--- a/src/core/SkBitmapProcShader.cpp
+++ b/src/core/SkBitmapProcShader.cpp
@@ -419,7 +419,7 @@ GrEffectRef* SkBitmapProcShader::asNewEffect(GrContext* context, const SkPaint&
GrEffectRef* effect = NULL;
if (paintFilterLevel == SkPaint::kHigh_FilterLevel) {
- effect = GrBicubicEffect::Create(texture, matrix, params);
+ effect = GrBicubicEffect::Create(texture, matrix, tm);
} else {
effect = GrSimpleTextureEffect::Create(texture, matrix, params);
}
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index f45572bb96..ce02f2c55f 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1426,7 +1426,9 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap,
GrTextureDomain::kClamp_Mode,
params.filterMode()));
} else if (bicubic) {
- effect.reset(GrBicubicEffect::Create(texture, SkMatrix::I(), params));
+ SkASSERT(GrTextureParams::kNone_FilterMode == params.filterMode());
+ SkShader::TileMode tileModes[2] = { params.getTileModeX(), params.getTileModeY() };
+ effect.reset(GrBicubicEffect::Create(texture, SkMatrix::I(), tileModes));
} else {
effect.reset(GrSimpleTextureEffect::Create(texture, SkMatrix::I(), params));
}
diff --git a/src/gpu/effects/GrBicubicEffect.cpp b/src/gpu/effects/GrBicubicEffect.cpp
index cd013cbc15..a6e08f20b5 100644
--- a/src/gpu/effects/GrBicubicEffect.cpp
+++ b/src/gpu/effects/GrBicubicEffect.cpp
@@ -106,23 +106,10 @@ void GrGLBicubicEffect::setData(const GrGLUniformManager& uman,
}
GrBicubicEffect::GrBicubicEffect(GrTexture* texture,
- const SkScalar coefficients[16])
- : INHERITED(texture, MakeDivByTextureWHMatrix(texture)) {
- for (int y = 0; y < 4; y++) {
- for (int x = 0; x < 4; x++) {
- // Convert from row-major scalars to column-major floats.
- fCoefficients[x * 4 + y] = SkScalarToFloat(coefficients[y * 4 + x]);
- }
- }
- this->setWillNotUseInputColor();
-}
-
-GrBicubicEffect::GrBicubicEffect(GrTexture* texture,
const SkScalar coefficients[16],
const SkMatrix &matrix,
- const GrTextureParams &params,
- GrCoordSet coordSet)
- : INHERITED(texture, matrix, params, coordSet) {
+ const SkShader::TileMode tileModes[2])
+ : INHERITED(texture, matrix, GrTextureParams(tileModes, GrTextureParams::kNone_FilterMode)) {
for (int y = 0; y < 4; y++) {
for (int x = 0; x < 4; x++) {
// Convert from row-major scalars to column-major floats.
diff --git a/src/gpu/effects/GrBicubicEffect.h b/src/gpu/effects/GrBicubicEffect.h
index d8c431a4a1..85bec771b4 100644
--- a/src/gpu/effects/GrBicubicEffect.h
+++ b/src/gpu/effects/GrBicubicEffect.h
@@ -31,34 +31,44 @@ public:
virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE;
- static GrEffectRef* Create(GrTexture* tex, const SkScalar coefficients[16]) {
- AutoEffectUnref effect(SkNEW_ARGS(GrBicubicEffect, (tex, coefficients)));
- return CreateEffectRef(effect);
+ /**
+ * Create a simple Mitchell filter effect.
+ */
+ static GrEffectRef* Create(GrTexture* tex) {
+ return Create(tex, gMitchellCoefficients);
}
- static GrEffectRef* Create(GrTexture* tex, const SkScalar coefficients[16],
- const SkMatrix& matrix,
- const GrTextureParams& p,
- GrCoordSet coordSet = kLocal_GrCoordSet) {
- AutoEffectUnref effect(SkNEW_ARGS(GrBicubicEffect, (tex, coefficients, matrix, p, coordSet)));
- return CreateEffectRef(effect);
+ /**
+ * Create a simple filter effect with custom bicubic coefficients.
+ */
+ static GrEffectRef* Create(GrTexture* tex, const SkScalar coefficients[16]) {
+ const SkShader::TileMode tm[] = { SkShader::kClamp_TileMode, SkShader::kClamp_TileMode };
+ return Create(tex, coefficients, MakeDivByTextureWHMatrix(tex), tm);
}
- static GrEffectRef* Create(GrTexture* tex) {
- return Create(tex, gMitchellCoefficients);
+ /**
+ * Create a Mitchell filter effect with specified texture matrix and x/y tile modes.
+ */
+ static GrEffectRef* Create(GrTexture* tex,
+ const SkMatrix& matrix,
+ SkShader::TileMode tileModes[2]) {
+ return Create(tex, gMitchellCoefficients, matrix, tileModes);
}
- static GrEffectRef* Create(GrTexture* tex,
+ /**
+ * The most general Create method. This allows specification of the bicubic coefficients, the
+ * texture matrix, and the x/y tilemodes.
+ */
+ static GrEffectRef* Create(GrTexture* tex, const SkScalar coefficients[16],
const SkMatrix& matrix,
- const GrTextureParams& p,
- GrCoordSet coordSet = kLocal_GrCoordSet) {
- return Create(tex, gMitchellCoefficients, matrix, p, coordSet);
+ const SkShader::TileMode tileModes[2]) {
+ AutoEffectUnref effect(SkNEW_ARGS(GrBicubicEffect, (tex, coefficients, matrix, tileModes)));
+ return CreateEffectRef(effect);
}
private:
- GrBicubicEffect(GrTexture*, const SkScalar coefficients[16]);
GrBicubicEffect(GrTexture*, const SkScalar coefficients[16],
- const SkMatrix &matrix, const GrTextureParams &p, GrCoordSet coordSet);
+ const SkMatrix &matrix, const SkShader::TileMode tileModes[2]);
virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE;
float fCoefficients[16];