| 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 }; |
| 11 | 11 |
| 12 | 12 |
| 13 class GrGLBicubicEffect : public GrGLEffect { | 13 class GrGLBicubicEffect : public GrGLEffect { |
| 14 public: | 14 public: |
| 15 GrGLBicubicEffect(const GrBackendEffectFactory& factory, | 15 GrGLBicubicEffect(const GrBackendEffectFactory& factory, |
| 16 const GrDrawEffect&); | 16 const GrDrawEffect&); |
| 17 virtual void emitCode(GrGLShaderBuilder*, | 17 virtual void emitCode(GrGLShaderBuilder*, |
| 18 const GrDrawEffect&, | 18 const GrDrawEffect&, |
| 19 EffectKey, | 19 EffectKey, |
| 20 const char* outputColor, | 20 const char* outputColor, |
| 21 const char* inputColor, | 21 const GrGLSLExpr4& inputColor, |
| 22 const TransformedCoordsArray&, | 22 const TransformedCoordsArray&, |
| 23 const TextureSamplerArray&) SK_OVERRIDE; | 23 const TextureSamplerArray&) SK_OVERRIDE; |
| 24 | 24 |
| 25 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVER
RIDE; | 25 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVER
RIDE; |
| 26 | 26 |
| 27 private: | 27 private: |
| 28 typedef GrGLUniformManager::UniformHandle UniformHandle; | 28 typedef GrGLUniformManager::UniformHandle UniformHandle; |
| 29 | 29 |
| 30 UniformHandle fCoefficientsUni; | 30 UniformHandle fCoefficientsUni; |
| 31 UniformHandle fImageIncrementUni; | 31 UniformHandle fImageIncrementUni; |
| 32 | 32 |
| 33 typedef GrGLEffect INHERITED; | 33 typedef GrGLEffect INHERITED; |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 GrGLBicubicEffect::GrGLBicubicEffect(const GrBackendEffectFactory& factory, cons
t GrDrawEffect&) | 36 GrGLBicubicEffect::GrGLBicubicEffect(const GrBackendEffectFactory& factory, cons
t GrDrawEffect&) |
| 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 GrGLSLExpr4& inputColor, |
| 45 const TransformedCoordsArray& coords, | 45 const TransformedCoordsArray& coords, |
| 46 const TextureSamplerArray& samplers) { | 46 const TextureSamplerArray& samplers) { |
| 47 sk_ignore_unused_variable(inputColor); | 47 sk_ignore_unused_variable(inputColor); |
| 48 | 48 |
| 49 SkString coords2D = builder->ensureFSCoords2D(coords, 0); | 49 SkString coords2D = builder->ensureFSCoords2D(coords, 0); |
| 50 fCoefficientsUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibili
ty, | 50 fCoefficientsUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibili
ty, |
| 51 kMat44f_GrSLType, "Coefficients"); | 51 kMat44f_GrSLType, "Coefficients"); |
| 52 fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibi
lity, | 52 fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibi
lity, |
| 53 kVec2f_GrSLType, "ImageIncrement"); | 53 kVec2f_GrSLType, "ImageIncrement"); |
| 54 | 54 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 const GrDrawTargetCaps&, | 150 const GrDrawTargetCaps&, |
| 151 GrTexture* textures[]) { | 151 GrTexture* textures[]) { |
| 152 int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx : | 152 int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx : |
| 153 GrEffectUnitTest::kAlphaTextureIdx; | 153 GrEffectUnitTest::kAlphaTextureIdx; |
| 154 SkScalar coefficients[16]; | 154 SkScalar coefficients[16]; |
| 155 for (int i = 0; i < 16; i++) { | 155 for (int i = 0; i < 16; i++) { |
| 156 coefficients[i] = random->nextSScalar1(); | 156 coefficients[i] = random->nextSScalar1(); |
| 157 } | 157 } |
| 158 return GrBicubicEffect::Create(textures[texIdx], coefficients); | 158 return GrBicubicEffect::Create(textures[texIdx], coefficients); |
| 159 } | 159 } |
| OLD | NEW |