| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef GrBicubicTextureEffect_DEFINED | 8 #ifndef GrBicubicTextureEffect_DEFINED |
| 9 #define GrBicubicTextureEffect_DEFINED | 9 #define GrBicubicTextureEffect_DEFINED |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 typedef GrGLBicubicEffect GLEffect; | 30 typedef GrGLBicubicEffect GLEffect; |
| 31 | 31 |
| 32 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; | 32 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; |
| 33 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags
) const SK_OVERRIDE; | 33 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags
) const SK_OVERRIDE; |
| 34 | 34 |
| 35 const GrTextureDomain& domain() const { return fDomain; } | 35 const GrTextureDomain& domain() const { return fDomain; } |
| 36 | 36 |
| 37 /** | 37 /** |
| 38 * Create a simple filter effect with custom bicubic coefficients and option
al domain. | 38 * Create a simple filter effect with custom bicubic coefficients and option
al domain. |
| 39 */ | 39 */ |
| 40 static GrEffectRef* Create(GrTexture* tex, const SkScalar coefficients[16], | 40 static GrEffect* Create(GrTexture* tex, const SkScalar coefficients[16], |
| 41 const SkRect* domain = NULL) { | 41 const SkRect* domain = NULL) { |
| 42 if (NULL == domain) { | 42 if (NULL == domain) { |
| 43 static const SkShader::TileMode kTileModes[] = { SkShader::kClamp_Ti
leMode, | 43 static const SkShader::TileMode kTileModes[] = { SkShader::kClamp_Ti
leMode, |
| 44 SkShader::kClamp_Ti
leMode }; | 44 SkShader::kClamp_Ti
leMode }; |
| 45 return Create(tex, coefficients, MakeDivByTextureWHMatrix(tex), kTil
eModes); | 45 return Create(tex, coefficients, MakeDivByTextureWHMatrix(tex), kTil
eModes); |
| 46 } else { | 46 } else { |
| 47 return SkNEW_ARGS(GrBicubicEffect, (tex, coefficients, | 47 return SkNEW_ARGS(GrBicubicEffect, (tex, coefficients, |
| 48 MakeDivByTextureWHMatrix(tex), *
domain)); | 48 MakeDivByTextureWHMatrix(tex), *
domain)); |
| 49 } | 49 } |
| 50 } | 50 } |
| 51 | 51 |
| 52 /** | 52 /** |
| 53 * Create a Mitchell filter effect with specified texture matrix and x/y til
e modes. | 53 * Create a Mitchell filter effect with specified texture matrix and x/y til
e modes. |
| 54 */ | 54 */ |
| 55 static GrEffectRef* Create(GrTexture* tex, const SkMatrix& matrix, | 55 static GrEffect* Create(GrTexture* tex, const SkMatrix& matrix, |
| 56 SkShader::TileMode tileModes[2]) { | 56 SkShader::TileMode tileModes[2]) { |
| 57 return Create(tex, gMitchellCoefficients, matrix, tileModes); | 57 return Create(tex, gMitchellCoefficients, matrix, tileModes); |
| 58 } | 58 } |
| 59 | 59 |
| 60 /** | 60 /** |
| 61 * Create a filter effect with custom bicubic coefficients, the texture matr
ix, and the x/y | 61 * Create a filter effect with custom bicubic coefficients, the texture matr
ix, and the x/y |
| 62 * tilemodes. | 62 * tilemodes. |
| 63 */ | 63 */ |
| 64 static GrEffectRef* Create(GrTexture* tex, const SkScalar coefficients[16], | 64 static GrEffect* Create(GrTexture* tex, const SkScalar coefficients[16], |
| 65 const SkMatrix& matrix, const SkShader::TileMode
tileModes[2]) { | 65 const SkMatrix& matrix, const SkShader::TileMode til
eModes[2]) { |
| 66 return SkNEW_ARGS(GrBicubicEffect, (tex, coefficients, matrix, tileModes
)); | 66 return SkNEW_ARGS(GrBicubicEffect, (tex, coefficients, matrix, tileModes
)); |
| 67 } | 67 } |
| 68 | 68 |
| 69 /** | 69 /** |
| 70 * Create a Mitchell filter effect with a texture matrix and a domain. | 70 * Create a Mitchell filter effect with a texture matrix and a domain. |
| 71 */ | 71 */ |
| 72 static GrEffectRef* Create(GrTexture* tex, const SkMatrix& matrix, const SkR
ect& domain) { | 72 static GrEffect* Create(GrTexture* tex, const SkMatrix& matrix, const SkRect
& domain) { |
| 73 return SkNEW_ARGS(GrBicubicEffect, (tex, gMitchellCoefficients, matrix,
domain)); | 73 return SkNEW_ARGS(GrBicubicEffect, (tex, gMitchellCoefficients, matrix,
domain)); |
| 74 } | 74 } |
| 75 | 75 |
| 76 /** | 76 /** |
| 77 * Determines whether the bicubic effect should be used based on the transfo
rmation from the | 77 * Determines whether the bicubic effect should be used based on the transfo
rmation from the |
| 78 * local coords to the device. Returns true if the bicubic effect should be
used. filterMode | 78 * local coords to the device. Returns true if the bicubic effect should be
used. filterMode |
| 79 * is set to appropriate filtering mode to use regardless of the return resu
lt (e.g. when this | 79 * is set to appropriate filtering mode to use regardless of the return resu
lt (e.g. when this |
| 80 * returns false it may indicate that the best fallback is to use kMipMap, k
Bilerp, or | 80 * returns false it may indicate that the best fallback is to use kMipMap, k
Bilerp, or |
| 81 * kNearest). | 81 * kNearest). |
| 82 */ | 82 */ |
| (...skipping 11 matching lines...) Expand all Loading... |
| 94 GrTextureDomain fDomain; | 94 GrTextureDomain fDomain; |
| 95 | 95 |
| 96 GR_DECLARE_EFFECT_TEST; | 96 GR_DECLARE_EFFECT_TEST; |
| 97 | 97 |
| 98 static const SkScalar gMitchellCoefficients[16]; | 98 static const SkScalar gMitchellCoefficients[16]; |
| 99 | 99 |
| 100 typedef GrSingleTextureEffect INHERITED; | 100 typedef GrSingleTextureEffect INHERITED; |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 #endif | 103 #endif |
| OLD | NEW |