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 |
(...skipping 13 matching lines...) Expand all Loading... |
24 virtual ~GrBicubicEffect(); | 24 virtual ~GrBicubicEffect(); |
25 | 25 |
26 static const char* Name() { return "Bicubic"; } | 26 static const char* Name() { return "Bicubic"; } |
27 const float* coefficients() const { return fCoefficients; } | 27 const float* coefficients() const { return fCoefficients; } |
28 | 28 |
29 typedef GrGLBicubicEffect GLEffect; | 29 typedef GrGLBicubicEffect GLEffect; |
30 | 30 |
31 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; | 31 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; |
32 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags
) const SK_OVERRIDE; | 32 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags
) const SK_OVERRIDE; |
33 | 33 |
34 static GrEffectRef* Create(GrTexture* tex, const SkScalar coefficients[16])
{ | 34 /** |
35 AutoEffectUnref effect(SkNEW_ARGS(GrBicubicEffect, (tex, coefficients)))
; | 35 * Create a simple Mitchell filter effect. |
36 return CreateEffectRef(effect); | 36 */ |
37 } | |
38 | |
39 static GrEffectRef* Create(GrTexture* tex, const SkScalar coefficients[16], | |
40 const SkMatrix& matrix, | |
41 const GrTextureParams& p, | |
42 GrCoordSet coordSet = kLocal_GrCoordSet) { | |
43 AutoEffectUnref effect(SkNEW_ARGS(GrBicubicEffect, (tex, coefficients, m
atrix, p, coordSet))); | |
44 return CreateEffectRef(effect); | |
45 } | |
46 | |
47 static GrEffectRef* Create(GrTexture* tex) { | 37 static GrEffectRef* Create(GrTexture* tex) { |
48 return Create(tex, gMitchellCoefficients); | 38 return Create(tex, gMitchellCoefficients); |
49 } | 39 } |
50 | 40 |
| 41 /** |
| 42 * Create a simple filter effect with custom bicubic coefficients. |
| 43 */ |
| 44 static GrEffectRef* Create(GrTexture* tex, const SkScalar coefficients[16])
{ |
| 45 const SkShader::TileMode tm[] = { SkShader::kClamp_TileMode, SkShader::k
Clamp_TileMode }; |
| 46 return Create(tex, coefficients, MakeDivByTextureWHMatrix(tex), tm); |
| 47 } |
| 48 |
| 49 /** |
| 50 * Create a Mitchell filter effect with specified texture matrix and x/y til
e modes. |
| 51 */ |
51 static GrEffectRef* Create(GrTexture* tex, | 52 static GrEffectRef* Create(GrTexture* tex, |
52 const SkMatrix& matrix, | 53 const SkMatrix& matrix, |
53 const GrTextureParams& p, | 54 SkShader::TileMode tileModes[2]) { |
54 GrCoordSet coordSet = kLocal_GrCoordSet) { | 55 return Create(tex, gMitchellCoefficients, matrix, tileModes); |
55 return Create(tex, gMitchellCoefficients, matrix, p, coordSet); | 56 } |
| 57 |
| 58 /** |
| 59 * The most general Create method. This allows specification of the bicubic
coefficients, the |
| 60 * texture matrix, and the x/y tilemodes. |
| 61 */ |
| 62 static GrEffectRef* Create(GrTexture* tex, const SkScalar coefficients[16], |
| 63 const SkMatrix& matrix, |
| 64 const SkShader::TileMode tileModes[2]) { |
| 65 AutoEffectUnref effect(SkNEW_ARGS(GrBicubicEffect, (tex, coefficients, m
atrix, tileModes))); |
| 66 return CreateEffectRef(effect); |
56 } | 67 } |
57 | 68 |
58 private: | 69 private: |
59 GrBicubicEffect(GrTexture*, const SkScalar coefficients[16]); | |
60 GrBicubicEffect(GrTexture*, const SkScalar coefficients[16], | 70 GrBicubicEffect(GrTexture*, const SkScalar coefficients[16], |
61 const SkMatrix &matrix, const GrTextureParams &p, GrCoordSet
coordSet); | 71 const SkMatrix &matrix, const SkShader::TileMode tileModes[2
]); |
62 virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE; | 72 virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE; |
63 float fCoefficients[16]; | 73 float fCoefficients[16]; |
64 | 74 |
65 GR_DECLARE_EFFECT_TEST; | 75 GR_DECLARE_EFFECT_TEST; |
66 | 76 |
67 static const SkScalar gMitchellCoefficients[16]; | 77 static const SkScalar gMitchellCoefficients[16]; |
68 | 78 |
69 typedef GrSingleTextureEffect INHERITED; | 79 typedef GrSingleTextureEffect INHERITED; |
70 }; | 80 }; |
71 | 81 |
72 #endif | 82 #endif |
OLD | NEW |