| 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 |
| 11 #include "GrSingleTextureEffect.h" | 11 #include "GrSingleTextureEffect.h" |
| 12 #include "GrDrawEffect.h" | 12 #include "GrDrawEffect.h" |
| 13 #include "gl/GrGLEffect.h" | 13 #include "gl/GrGLEffect.h" |
| 14 #include "gl/GrGLEffectMatrix.h" | |
| 15 #include "GrTBackendEffectFactory.h" | 14 #include "GrTBackendEffectFactory.h" |
| 16 | 15 |
| 17 class GrGLBicubicEffect; | 16 class GrGLBicubicEffect; |
| 18 | 17 |
| 19 class GrBicubicEffect : public GrSingleTextureEffect { | 18 class GrBicubicEffect : public GrSingleTextureEffect { |
| 20 public: | 19 public: |
| 21 virtual ~GrBicubicEffect(); | 20 virtual ~GrBicubicEffect(); |
| 22 | 21 |
| 23 static const char* Name() { return "Bicubic"; } | 22 static const char* Name() { return "Bicubic"; } |
| 24 const float* coefficients() const { return fCoefficients; } | 23 const float* coefficients() const { return fCoefficients; } |
| 25 | 24 |
| 26 typedef GrGLBicubicEffect GLEffect; | 25 typedef GrGLBicubicEffect GLEffect; |
| 27 | 26 |
| 28 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; | 27 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; |
| 29 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags
) const SK_OVERRIDE; | 28 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags
) const SK_OVERRIDE; |
| 30 | 29 |
| 31 static GrEffectRef* Create(GrTexture* tex, const SkScalar coefficients[16])
{ | 30 static GrEffectRef* Create(GrTexture* tex, const SkScalar coefficients[16])
{ |
| 32 AutoEffectUnref effect(SkNEW_ARGS(GrBicubicEffect, (tex, coefficients)))
; | 31 AutoEffectUnref effect(SkNEW_ARGS(GrBicubicEffect, (tex, coefficients)))
; |
| 33 return CreateEffectRef(effect); | 32 return CreateEffectRef(effect); |
| 34 } | 33 } |
| 35 | 34 |
| 36 static GrEffectRef* Create(GrTexture* tex, const SkScalar coefficients[16], | 35 static GrEffectRef* Create(GrTexture* tex, const SkScalar coefficients[16], |
| 37 const SkMatrix& matrix, | 36 const SkMatrix& matrix, |
| 38 const GrTextureParams& p, | 37 const GrTextureParams& p, |
| 39 CoordsType coordsType = kLocal_CoordsType) { | 38 GrCoordSet coordSet = kLocal_GrCoordSet) { |
| 40 AutoEffectUnref effect(SkNEW_ARGS(GrBicubicEffect, (tex, coefficients, m
atrix, p, coordsType))); | 39 AutoEffectUnref effect(SkNEW_ARGS(GrBicubicEffect, (tex, coefficients, m
atrix, p, coordSet))); |
| 41 return CreateEffectRef(effect); | 40 return CreateEffectRef(effect); |
| 42 } | 41 } |
| 43 | 42 |
| 44 static GrEffectRef* Create(GrTexture* tex) { | 43 static GrEffectRef* Create(GrTexture* tex) { |
| 45 return Create(tex, gMitchellCoefficients); | 44 return Create(tex, gMitchellCoefficients); |
| 46 } | 45 } |
| 47 | 46 |
| 48 static GrEffectRef* Create(GrTexture* tex, | 47 static GrEffectRef* Create(GrTexture* tex, |
| 49 const SkMatrix& matrix, | 48 const SkMatrix& matrix, |
| 50 const GrTextureParams& p, | 49 const GrTextureParams& p, |
| 51 CoordsType coordsType = kLocal_CoordsType) { | 50 GrCoordSet coordSet = kLocal_GrCoordSet) { |
| 52 return Create(tex, gMitchellCoefficients, matrix, p, coordsType); | 51 return Create(tex, gMitchellCoefficients, matrix, p, coordSet); |
| 53 } | 52 } |
| 54 | 53 |
| 55 private: | 54 private: |
| 56 GrBicubicEffect(GrTexture*, const SkScalar coefficients[16]); | 55 GrBicubicEffect(GrTexture*, const SkScalar coefficients[16]); |
| 57 GrBicubicEffect(GrTexture*, const SkScalar coefficients[16], | 56 GrBicubicEffect(GrTexture*, const SkScalar coefficients[16], |
| 58 const SkMatrix &matrix, const GrTextureParams &p, CoordsType
coordsType); | 57 const SkMatrix &matrix, const GrTextureParams &p, GrCoordSet
coordSet); |
| 59 virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE; | 58 virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE; |
| 60 float fCoefficients[16]; | 59 float fCoefficients[16]; |
| 61 | 60 |
| 62 GR_DECLARE_EFFECT_TEST; | 61 GR_DECLARE_EFFECT_TEST; |
| 63 | 62 |
| 64 static const SkScalar gMitchellCoefficients[16]; | 63 static const SkScalar gMitchellCoefficients[16]; |
| 65 | 64 |
| 66 typedef GrSingleTextureEffect INHERITED; | 65 typedef GrSingleTextureEffect INHERITED; |
| 67 }; | 66 }; |
| 68 | 67 |
| 69 #endif | 68 #endif |
| OLD | NEW |