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