this->reset(tileXAndY, filterMode);
}
- GrTextureParams(SkShader::TileMode tileModes[2], FilterMode filterMode) {
+ GrTextureParams(const SkShader::TileMode tileModes[2], FilterMode filterMode) {
this->reset(tileModes, filterMode);
}
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;
}
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 ¶ms,
- 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.
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];