| 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 26 matching lines...) Expand all Loading... |
| 37 : INHERITED(factory) { | 37 : INHERITED(factory) { |
| 38 } | 38 } |
| 39 | 39 |
| 40 void GrGLBicubicEffect::emitCode(GrGLShaderBuilder* builder, | 40 void GrGLBicubicEffect::emitCode(GrGLShaderBuilder* builder, |
| 41 const GrDrawEffect&, | 41 const GrDrawEffect&, |
| 42 EffectKey key, | 42 EffectKey key, |
| 43 const char* outputColor, | 43 const char* outputColor, |
| 44 const char* inputColor, | 44 const char* inputColor, |
| 45 const TransformedCoordsArray& coords, | 45 const TransformedCoordsArray& coords, |
| 46 const TextureSamplerArray& samplers) { | 46 const TextureSamplerArray& samplers) { |
| 47 sk_ignore_unused_variable(inputColor); |
| 48 |
| 47 SkString coords2D = builder->ensureFSCoords2D(coords, 0); | 49 SkString coords2D = builder->ensureFSCoords2D(coords, 0); |
| 48 fCoefficientsUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibili
ty, | 50 fCoefficientsUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibili
ty, |
| 49 kMat44f_GrSLType, "Coefficients"); | 51 kMat44f_GrSLType, "Coefficients"); |
| 50 fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibi
lity, | 52 fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibi
lity, |
| 51 kVec2f_GrSLType, "ImageIncrement"); | 53 kVec2f_GrSLType, "ImageIncrement"); |
| 52 | 54 |
| 53 const char* imgInc = builder->getUniformCStr(fImageIncrementUni); | 55 const char* imgInc = builder->getUniformCStr(fImageIncrementUni); |
| 54 const char* coeff = builder->getUniformCStr(fCoefficientsUni); | 56 const char* coeff = builder->getUniformCStr(fCoefficientsUni); |
| 55 | 57 |
| 56 SkString cubicBlendName; | 58 SkString cubicBlendName; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 101 |
| 100 GrBicubicEffect::GrBicubicEffect(GrTexture* texture, | 102 GrBicubicEffect::GrBicubicEffect(GrTexture* texture, |
| 101 const SkScalar coefficients[16]) | 103 const SkScalar coefficients[16]) |
| 102 : INHERITED(texture, MakeDivByTextureWHMatrix(texture)) { | 104 : INHERITED(texture, MakeDivByTextureWHMatrix(texture)) { |
| 103 for (int y = 0; y < 4; y++) { | 105 for (int y = 0; y < 4; y++) { |
| 104 for (int x = 0; x < 4; x++) { | 106 for (int x = 0; x < 4; x++) { |
| 105 // Convert from row-major scalars to column-major floats. | 107 // Convert from row-major scalars to column-major floats. |
| 106 fCoefficients[x * 4 + y] = SkScalarToFloat(coefficients[y * 4 + x]); | 108 fCoefficients[x * 4 + y] = SkScalarToFloat(coefficients[y * 4 + x]); |
| 107 } | 109 } |
| 108 } | 110 } |
| 111 this->setWillNotUseInputColor(); |
| 109 } | 112 } |
| 110 | 113 |
| 111 GrBicubicEffect::GrBicubicEffect(GrTexture* texture, | 114 GrBicubicEffect::GrBicubicEffect(GrTexture* texture, |
| 112 const SkScalar coefficients[16], | 115 const SkScalar coefficients[16], |
| 113 const SkMatrix &matrix, | 116 const SkMatrix &matrix, |
| 114 const GrTextureParams ¶ms, | 117 const GrTextureParams ¶ms, |
| 115 GrCoordSet coordSet) | 118 GrCoordSet coordSet) |
| 116 : INHERITED(texture, MakeDivByTextureWHMatrix(texture), params, coordSet) { | 119 : INHERITED(texture, MakeDivByTextureWHMatrix(texture), params, coordSet) { |
| 117 for (int y = 0; y < 4; y++) { | 120 for (int y = 0; y < 4; y++) { |
| 118 for (int x = 0; x < 4; x++) { | 121 for (int x = 0; x < 4; x++) { |
| 119 // Convert from row-major scalars to column-major floats. | 122 // Convert from row-major scalars to column-major floats. |
| 120 fCoefficients[x * 4 + y] = SkScalarToFloat(coefficients[y * 4 + x]); | 123 fCoefficients[x * 4 + y] = SkScalarToFloat(coefficients[y * 4 + x]); |
| 121 } | 124 } |
| 122 } | 125 } |
| 126 this->setWillNotUseInputColor(); |
| 123 } | 127 } |
| 124 | 128 |
| 125 GrBicubicEffect::~GrBicubicEffect() { | 129 GrBicubicEffect::~GrBicubicEffect() { |
| 126 } | 130 } |
| 127 | 131 |
| 128 const GrBackendEffectFactory& GrBicubicEffect::getFactory() const { | 132 const GrBackendEffectFactory& GrBicubicEffect::getFactory() const { |
| 129 return GrTBackendEffectFactory<GrBicubicEffect>::getInstance(); | 133 return GrTBackendEffectFactory<GrBicubicEffect>::getInstance(); |
| 130 } | 134 } |
| 131 | 135 |
| 132 bool GrBicubicEffect::onIsEqual(const GrEffect& sBase) const { | 136 bool GrBicubicEffect::onIsEqual(const GrEffect& sBase) const { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 148 const GrDrawTargetCaps&, | 152 const GrDrawTargetCaps&, |
| 149 GrTexture* textures[]) { | 153 GrTexture* textures[]) { |
| 150 int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx : | 154 int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx : |
| 151 GrEffectUnitTest::kAlphaTextureIdx; | 155 GrEffectUnitTest::kAlphaTextureIdx; |
| 152 SkScalar coefficients[16]; | 156 SkScalar coefficients[16]; |
| 153 for (int i = 0; i < 16; i++) { | 157 for (int i = 0; i < 16; i++) { |
| 154 coefficients[i] = random->nextSScalar1(); | 158 coefficients[i] = random->nextSScalar1(); |
| 155 } | 159 } |
| 156 return GrBicubicEffect::Create(textures[texIdx], coefficients); | 160 return GrBicubicEffect::Create(textures[texIdx], coefficients); |
| 157 } | 161 } |
| OLD | NEW |