| 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 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 void getGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const over
ride; | 30 void getGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const over
ride; |
| 31 | 31 |
| 32 GrGLFragmentProcessor* createGLInstance() const override; | 32 GrGLFragmentProcessor* createGLInstance() const override; |
| 33 | 33 |
| 34 const GrTextureDomain& domain() const { return fDomain; } | 34 const GrTextureDomain& domain() const { return fDomain; } |
| 35 | 35 |
| 36 /** | 36 /** |
| 37 * Create a simple filter effect with custom bicubic coefficients and option
al domain. | 37 * Create a simple filter effect with custom bicubic coefficients and option
al domain. |
| 38 */ | 38 */ |
| 39 static GrFragmentProcessor* Create(GrTexture* tex, const SkScalar coefficien
ts[16], | 39 static GrFragmentProcessor* Create(GrProcessorDataManager* procDataManager,
GrTexture* tex, |
| 40 const SkRect* domain = NULL) { | 40 const SkScalar coefficients[16], |
| 41 const SkRect* domain = NULL) { |
| 41 if (NULL == domain) { | 42 if (NULL == domain) { |
| 42 static const SkShader::TileMode kTileModes[] = { SkShader::kClamp_Ti
leMode, | 43 static const SkShader::TileMode kTileModes[] = { SkShader::kClamp_Ti
leMode, |
| 43 SkShader::kClamp_Ti
leMode }; | 44 SkShader::kClamp_Ti
leMode }; |
| 44 return Create(tex, coefficients, GrCoordTransform::MakeDivByTextureW
HMatrix(tex), | 45 return Create(procDataManager, tex, coefficients, |
| 45 kTileModes); | 46 GrCoordTransform::MakeDivByTextureWHMatrix(tex), kTile
Modes); |
| 46 } else { | 47 } else { |
| 47 return SkNEW_ARGS(GrBicubicEffect, (tex, coefficients, | 48 return SkNEW_ARGS(GrBicubicEffect, (procDataManager, tex, coefficien
ts, |
| 48 GrCoordTransform::MakeDivByTextu
reWHMatrix(tex), | 49 GrCoordTransform::MakeDivByTextu
reWHMatrix(tex), |
| 49 *domain)); | 50 *domain)); |
| 50 } | 51 } |
| 51 } | 52 } |
| 52 | 53 |
| 53 /** | 54 /** |
| 54 * Create a Mitchell filter effect with specified texture matrix and x/y til
e modes. | 55 * Create a Mitchell filter effect with specified texture matrix and x/y til
e modes. |
| 55 */ | 56 */ |
| 56 static GrFragmentProcessor* Create(GrTexture* tex, const SkMatrix& matrix, | 57 static GrFragmentProcessor* Create(GrProcessorDataManager* procDataManager,
GrTexture* tex, |
| 57 SkShader::TileMode tileModes[2]) { | 58 const SkMatrix& matrix, |
| 58 return Create(tex, gMitchellCoefficients, matrix, tileModes); | 59 SkShader::TileMode tileModes[2]) { |
| 60 return Create(procDataManager, tex, gMitchellCoefficients, matrix, tileM
odes); |
| 59 } | 61 } |
| 60 | 62 |
| 61 /** | 63 /** |
| 62 * Create a filter effect with custom bicubic coefficients, the texture matr
ix, and the x/y | 64 * Create a filter effect with custom bicubic coefficients, the texture matr
ix, and the x/y |
| 63 * tilemodes. | 65 * tilemodes. |
| 64 */ | 66 */ |
| 65 static GrFragmentProcessor* Create(GrTexture* tex, const SkScalar coefficien
ts[16], | 67 static GrFragmentProcessor* Create(GrProcessorDataManager* procDataManager,
GrTexture* tex, |
| 66 const SkMatrix& matrix, | 68 const SkScalar coefficients[16], const Sk
Matrix& matrix, |
| 67 const SkShader::TileMode tileModes[2]) { | 69 const SkShader::TileMode tileModes[2]) { |
| 68 return SkNEW_ARGS(GrBicubicEffect, (tex, coefficients, matrix, tileModes
)); | 70 return SkNEW_ARGS(GrBicubicEffect, (procDataManager, tex, coefficients,
matrix, tileModes)); |
| 69 } | 71 } |
| 70 | 72 |
| 71 /** | 73 /** |
| 72 * Create a Mitchell filter effect with a texture matrix and a domain. | 74 * Create a Mitchell filter effect with a texture matrix and a domain. |
| 73 */ | 75 */ |
| 74 static GrFragmentProcessor* Create(GrTexture* tex, const SkMatrix& matrix, | 76 static GrFragmentProcessor* Create(GrProcessorDataManager* procDataManager,
GrTexture* tex, |
| 75 const SkRect& domain) { | 77 const SkMatrix& matrix, const SkRect& dom
ain) { |
| 76 return SkNEW_ARGS(GrBicubicEffect, (tex, gMitchellCoefficients, matrix,
domain)); | 78 return SkNEW_ARGS(GrBicubicEffect, (procDataManager, tex, gMitchellCoeff
icients, matrix, |
| 79 domain)); |
| 77 } | 80 } |
| 78 | 81 |
| 79 /** | 82 /** |
| 80 * Determines whether the bicubic effect should be used based on the transfo
rmation from the | 83 * Determines whether the bicubic effect should be used based on the transfo
rmation from the |
| 81 * local coords to the device. Returns true if the bicubic effect should be
used. filterMode | 84 * local coords to the device. Returns true if the bicubic effect should be
used. filterMode |
| 82 * is set to appropriate filtering mode to use regardless of the return resu
lt (e.g. when this | 85 * is set to appropriate filtering mode to use regardless of the return resu
lt (e.g. when this |
| 83 * returns false it may indicate that the best fallback is to use kMipMap, k
Bilerp, or | 86 * returns false it may indicate that the best fallback is to use kMipMap, k
Bilerp, or |
| 84 * kNearest). | 87 * kNearest). |
| 85 */ | 88 */ |
| 86 static bool ShouldUseBicubic(const SkMatrix& localCoordsToDevice, | 89 static bool ShouldUseBicubic(const SkMatrix& localCoordsToDevice, |
| 87 GrTextureParams::FilterMode* filterMode); | 90 GrTextureParams::FilterMode* filterMode); |
| 88 | 91 |
| 89 private: | 92 private: |
| 90 GrBicubicEffect(GrTexture*, const SkScalar coefficients[16], | 93 GrBicubicEffect(GrProcessorDataManager*, GrTexture*, const SkScalar coeffici
ents[16], |
| 91 const SkMatrix &matrix, const SkShader::TileMode tileModes[2
]); | 94 const SkMatrix &matrix, const SkShader::TileMode tileModes[2
]); |
| 92 GrBicubicEffect(GrTexture*, const SkScalar coefficients[16], | 95 GrBicubicEffect(GrProcessorDataManager*, GrTexture*, const SkScalar coeffici
ents[16], |
| 93 const SkMatrix &matrix, const SkRect& domain); | 96 const SkMatrix &matrix, const SkRect& domain); |
| 94 bool onIsEqual(const GrFragmentProcessor&) const override; | 97 bool onIsEqual(const GrFragmentProcessor&) const override; |
| 95 | 98 |
| 96 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; | 99 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; |
| 97 | 100 |
| 98 float fCoefficients[16]; | 101 float fCoefficients[16]; |
| 99 GrTextureDomain fDomain; | 102 GrTextureDomain fDomain; |
| 100 | 103 |
| 101 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 104 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
| 102 | 105 |
| 103 static const SkScalar gMitchellCoefficients[16]; | 106 static const SkScalar gMitchellCoefficients[16]; |
| 104 | 107 |
| 105 typedef GrSingleTextureEffect INHERITED; | 108 typedef GrSingleTextureEffect INHERITED; |
| 106 }; | 109 }; |
| 107 | 110 |
| 108 #endif | 111 #endif |
| OLD | NEW |