humper@google.com | 3aad3b0 | 2013-09-04 19:23:53 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef GrBicubicTextureEffect_DEFINED |
| 9 | #define GrBicubicTextureEffect_DEFINED |
| 10 | |
| 11 | #include "GrSingleTextureEffect.h" |
| 12 | #include "GrDrawEffect.h" |
| 13 | #include "gl/GrGLEffect.h" |
humper@google.com | 3aad3b0 | 2013-09-04 19:23:53 +0000 | [diff] [blame] | 14 | #include "GrTBackendEffectFactory.h" |
| 15 | |
| 16 | class GrGLBicubicEffect; |
| 17 | |
| 18 | class GrBicubicEffect : public GrSingleTextureEffect { |
| 19 | public: |
| 20 | virtual ~GrBicubicEffect(); |
| 21 | |
| 22 | static const char* Name() { return "Bicubic"; } |
| 23 | const float* coefficients() const { return fCoefficients; } |
| 24 | |
| 25 | typedef GrGLBicubicEffect GLEffect; |
| 26 | |
| 27 | virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; |
| 28 | virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE; |
| 29 | |
| 30 | static GrEffectRef* Create(GrTexture* tex, const SkScalar coefficients[16]) { |
| 31 | AutoEffectUnref effect(SkNEW_ARGS(GrBicubicEffect, (tex, coefficients))); |
| 32 | return CreateEffectRef(effect); |
| 33 | } |
| 34 | |
skia.committer@gmail.com | c3723db | 2013-09-05 07:01:19 +0000 | [diff] [blame] | 35 | static GrEffectRef* Create(GrTexture* tex, const SkScalar coefficients[16], |
humper@google.com | 3aad3b0 | 2013-09-04 19:23:53 +0000 | [diff] [blame] | 36 | const SkMatrix& matrix, |
| 37 | const GrTextureParams& p, |
bsalomon@google.com | 77af680 | 2013-10-02 13:04:56 +0000 | [diff] [blame] | 38 | GrCoordSet coordSet = kLocal_GrCoordSet) { |
| 39 | AutoEffectUnref effect(SkNEW_ARGS(GrBicubicEffect, (tex, coefficients, matrix, p, coordSet))); |
humper@google.com | 3aad3b0 | 2013-09-04 19:23:53 +0000 | [diff] [blame] | 40 | return CreateEffectRef(effect); |
| 41 | } |
| 42 | |
| 43 | static GrEffectRef* Create(GrTexture* tex) { |
| 44 | return Create(tex, gMitchellCoefficients); |
| 45 | } |
| 46 | |
skia.committer@gmail.com | c3723db | 2013-09-05 07:01:19 +0000 | [diff] [blame] | 47 | static GrEffectRef* Create(GrTexture* tex, |
humper@google.com | 3aad3b0 | 2013-09-04 19:23:53 +0000 | [diff] [blame] | 48 | const SkMatrix& matrix, |
| 49 | const GrTextureParams& p, |
bsalomon@google.com | 77af680 | 2013-10-02 13:04:56 +0000 | [diff] [blame] | 50 | GrCoordSet coordSet = kLocal_GrCoordSet) { |
| 51 | return Create(tex, gMitchellCoefficients, matrix, p, coordSet); |
humper@google.com | 3aad3b0 | 2013-09-04 19:23:53 +0000 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | private: |
| 55 | GrBicubicEffect(GrTexture*, const SkScalar coefficients[16]); |
skia.committer@gmail.com | c3723db | 2013-09-05 07:01:19 +0000 | [diff] [blame] | 56 | GrBicubicEffect(GrTexture*, const SkScalar coefficients[16], |
bsalomon@google.com | 77af680 | 2013-10-02 13:04:56 +0000 | [diff] [blame] | 57 | const SkMatrix &matrix, const GrTextureParams &p, GrCoordSet coordSet); |
humper@google.com | 3aad3b0 | 2013-09-04 19:23:53 +0000 | [diff] [blame] | 58 | virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE; |
| 59 | float fCoefficients[16]; |
| 60 | |
| 61 | GR_DECLARE_EFFECT_TEST; |
skia.committer@gmail.com | c3723db | 2013-09-05 07:01:19 +0000 | [diff] [blame] | 62 | |
humper@google.com | 3aad3b0 | 2013-09-04 19:23:53 +0000 | [diff] [blame] | 63 | static const SkScalar gMitchellCoefficients[16]; |
| 64 | |
| 65 | typedef GrSingleTextureEffect INHERITED; |
| 66 | }; |
| 67 | |
| 68 | #endif |