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 23 matching lines...) Expand all Loading... |
34 */ | 34 */ |
35 static GrFragmentProcessor* Create(GrProcessorDataManager* procDataManager,
GrTexture* tex, | 35 static GrFragmentProcessor* Create(GrProcessorDataManager* procDataManager,
GrTexture* tex, |
36 const SkScalar coefficients[16], | 36 const SkScalar coefficients[16], |
37 const SkRect* domain = NULL) { | 37 const SkRect* domain = NULL) { |
38 if (NULL == domain) { | 38 if (NULL == domain) { |
39 static const SkShader::TileMode kTileModes[] = { SkShader::kClamp_Ti
leMode, | 39 static const SkShader::TileMode kTileModes[] = { SkShader::kClamp_Ti
leMode, |
40 SkShader::kClamp_Ti
leMode }; | 40 SkShader::kClamp_Ti
leMode }; |
41 return Create(procDataManager, tex, coefficients, | 41 return Create(procDataManager, tex, coefficients, |
42 GrCoordTransform::MakeDivByTextureWHMatrix(tex), kTile
Modes); | 42 GrCoordTransform::MakeDivByTextureWHMatrix(tex), kTile
Modes); |
43 } else { | 43 } else { |
44 return SkNEW_ARGS(GrBicubicEffect, (procDataManager, tex, coefficien
ts, | 44 return new GrBicubicEffect(procDataManager, tex, coefficients, |
45 GrCoordTransform::MakeDivByTextu
reWHMatrix(tex), | 45 GrCoordTransform::MakeDivByTextureWHMatri
x(tex), *domain); |
46 *domain)); | |
47 } | 46 } |
48 } | 47 } |
49 | 48 |
50 /** | 49 /** |
51 * Create a Mitchell filter effect with specified texture matrix and x/y til
e modes. | 50 * Create a Mitchell filter effect with specified texture matrix and x/y til
e modes. |
52 */ | 51 */ |
53 static GrFragmentProcessor* Create(GrProcessorDataManager* procDataManager,
GrTexture* tex, | 52 static GrFragmentProcessor* Create(GrProcessorDataManager* procDataManager,
GrTexture* tex, |
54 const SkMatrix& matrix, | 53 const SkMatrix& matrix, |
55 SkShader::TileMode tileModes[2]) { | 54 SkShader::TileMode tileModes[2]) { |
56 return Create(procDataManager, tex, gMitchellCoefficients, matrix, tileM
odes); | 55 return Create(procDataManager, tex, gMitchellCoefficients, matrix, tileM
odes); |
57 } | 56 } |
58 | 57 |
59 /** | 58 /** |
60 * Create a filter effect with custom bicubic coefficients, the texture matr
ix, and the x/y | 59 * Create a filter effect with custom bicubic coefficients, the texture matr
ix, and the x/y |
61 * tilemodes. | 60 * tilemodes. |
62 */ | 61 */ |
63 static GrFragmentProcessor* Create(GrProcessorDataManager* procDataManager,
GrTexture* tex, | 62 static GrFragmentProcessor* Create(GrProcessorDataManager* procDataManager,
GrTexture* tex, |
64 const SkScalar coefficients[16], const Sk
Matrix& matrix, | 63 const SkScalar coefficients[16], const Sk
Matrix& matrix, |
65 const SkShader::TileMode tileModes[2]) { | 64 const SkShader::TileMode tileModes[2]) { |
66 return SkNEW_ARGS(GrBicubicEffect, (procDataManager, tex, coefficients,
matrix, tileModes)); | 65 return new GrBicubicEffect(procDataManager, tex, coefficients, matrix, t
ileModes); |
67 } | 66 } |
68 | 67 |
69 /** | 68 /** |
70 * Create a Mitchell filter effect with a texture matrix and a domain. | 69 * Create a Mitchell filter effect with a texture matrix and a domain. |
71 */ | 70 */ |
72 static GrFragmentProcessor* Create(GrProcessorDataManager* procDataManager,
GrTexture* tex, | 71 static GrFragmentProcessor* Create(GrProcessorDataManager* procDataManager,
GrTexture* tex, |
73 const SkMatrix& matrix, const SkRect& dom
ain) { | 72 const SkMatrix& matrix, const SkRect& dom
ain) { |
74 return SkNEW_ARGS(GrBicubicEffect, (procDataManager, tex, gMitchellCoeff
icients, matrix, | 73 return new GrBicubicEffect(procDataManager, tex, gMitchellCoefficients,
matrix, domain); |
75 domain)); | |
76 } | 74 } |
77 | 75 |
78 /** | 76 /** |
79 * 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 |
80 * 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 |
81 * 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 |
82 * 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 |
83 * kNearest). | 81 * kNearest). |
84 */ | 82 */ |
85 static bool ShouldUseBicubic(const SkMatrix& localCoordsToDevice, | 83 static bool ShouldUseBicubic(const SkMatrix& localCoordsToDevice, |
(...skipping 17 matching lines...) Expand all Loading... |
103 GrTextureDomain fDomain; | 101 GrTextureDomain fDomain; |
104 | 102 |
105 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 103 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
106 | 104 |
107 static const SkScalar gMitchellCoefficients[16]; | 105 static const SkScalar gMitchellCoefficients[16]; |
108 | 106 |
109 typedef GrSingleTextureEffect INHERITED; | 107 typedef GrSingleTextureEffect INHERITED; |
110 }; | 108 }; |
111 | 109 |
112 #endif | 110 #endif |
OLD | NEW |