OLD | NEW |
1 #include "GrBicubicEffect.h" | 1 #include "GrBicubicEffect.h" |
2 | 2 |
3 #define DS(x) SkDoubleToScalar(x) | 3 #define DS(x) SkDoubleToScalar(x) |
4 | 4 |
5 const SkScalar GrBicubicEffect::gMitchellCoefficients[16] = { | 5 const SkScalar GrBicubicEffect::gMitchellCoefficients[16] = { |
6 DS( 1.0 / 18.0), DS(-9.0 / 18.0), DS( 15.0 / 18.0), DS( -7.0 / 18.0), | 6 DS( 1.0 / 18.0), DS(-9.0 / 18.0), DS( 15.0 / 18.0), DS( -7.0 / 18.0), |
7 DS(16.0 / 18.0), DS( 0.0 / 18.0), DS(-36.0 / 18.0), DS( 21.0 / 18.0), | 7 DS(16.0 / 18.0), DS( 0.0 / 18.0), DS(-36.0 / 18.0), DS( 21.0 / 18.0), |
8 DS( 1.0 / 18.0), DS( 9.0 / 18.0), DS( 27.0 / 18.0), DS(-21.0 / 18.0), | 8 DS( 1.0 / 18.0), DS( 9.0 / 18.0), DS( 27.0 / 18.0), DS(-21.0 / 18.0), |
9 DS( 0.0 / 18.0), DS( 0.0 / 18.0), DS( -6.0 / 18.0), DS( 7.0 / 18.0), | 9 DS( 0.0 / 18.0), DS( 0.0 / 18.0), DS( -6.0 / 18.0), DS( 7.0 / 18.0), |
10 }; | 10 }; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 builder->fsCodeAppendf("\t%s = %s(%s, f.y, s0, s1, s2, s3);\n", outputColor,
cubicBlendName.c_str(), coeff); | 88 builder->fsCodeAppendf("\t%s = %s(%s, f.y, s0, s1, s2, s3);\n", outputColor,
cubicBlendName.c_str(), coeff); |
89 } | 89 } |
90 | 90 |
91 void GrGLBicubicEffect::setData(const GrGLUniformManager& uman, | 91 void GrGLBicubicEffect::setData(const GrGLUniformManager& uman, |
92 const GrDrawEffect& drawEffect) { | 92 const GrDrawEffect& drawEffect) { |
93 const GrBicubicEffect& effect = drawEffect.castEffect<GrBicubicEffect>(); | 93 const GrBicubicEffect& effect = drawEffect.castEffect<GrBicubicEffect>(); |
94 GrTexture& texture = *effect.texture(0); | 94 GrTexture& texture = *effect.texture(0); |
95 float imageIncrement[2]; | 95 float imageIncrement[2]; |
96 imageIncrement[0] = 1.0f / texture.width(); | 96 imageIncrement[0] = 1.0f / texture.width(); |
97 imageIncrement[1] = 1.0f / texture.height(); | 97 imageIncrement[1] = 1.0f / texture.height(); |
98 uman.set2fv(fImageIncrementUni, 0, 1, imageIncrement); | 98 uman.set2fv(fImageIncrementUni, 1, imageIncrement); |
99 uman.setMatrix4f(fCoefficientsUni, effect.coefficients()); | 99 uman.setMatrix4f(fCoefficientsUni, effect.coefficients()); |
100 } | 100 } |
101 | 101 |
102 GrBicubicEffect::GrBicubicEffect(GrTexture* texture, | 102 GrBicubicEffect::GrBicubicEffect(GrTexture* texture, |
103 const SkScalar coefficients[16]) | 103 const SkScalar coefficients[16]) |
104 : INHERITED(texture, MakeDivByTextureWHMatrix(texture)) { | 104 : INHERITED(texture, MakeDivByTextureWHMatrix(texture)) { |
105 for (int y = 0; y < 4; y++) { | 105 for (int y = 0; y < 4; y++) { |
106 for (int x = 0; x < 4; x++) { | 106 for (int x = 0; x < 4; x++) { |
107 // Convert from row-major scalars to column-major floats. | 107 // Convert from row-major scalars to column-major floats. |
108 fCoefficients[x * 4 + y] = SkScalarToFloat(coefficients[y * 4 + x]); | 108 fCoefficients[x * 4 + y] = SkScalarToFloat(coefficients[y * 4 + x]); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 const GrDrawTargetCaps&, | 152 const GrDrawTargetCaps&, |
153 GrTexture* textures[]) { | 153 GrTexture* textures[]) { |
154 int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx : | 154 int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx : |
155 GrEffectUnitTest::kAlphaTextureIdx; | 155 GrEffectUnitTest::kAlphaTextureIdx; |
156 SkScalar coefficients[16]; | 156 SkScalar coefficients[16]; |
157 for (int i = 0; i < 16; i++) { | 157 for (int i = 0; i < 16; i++) { |
158 coefficients[i] = random->nextSScalar1(); | 158 coefficients[i] = random->nextSScalar1(); |
159 } | 159 } |
160 return GrBicubicEffect::Create(textures[texIdx], coefficients); | 160 return GrBicubicEffect::Create(textures[texIdx], coefficients); |
161 } | 161 } |
OLD | NEW |