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 "GrTextureDomain.h" | 12 #include "GrTextureDomain.h" |
13 #include "gl/GrGLProcessor.h" | 13 #include "gl/GrGLProcessor.h" |
14 | 14 |
15 class GrGLBicubicEffect; | 15 class GrGLBicubicEffect; |
16 class GrInvariantOutput; | 16 class GrInvariantOutput; |
17 | 17 |
18 class GrBicubicEffect : public GrSingleTextureEffect { | 18 class GrBicubicEffect : public GrSingleTextureEffect { |
19 public: | 19 public: |
20 enum { | 20 enum { |
21 kFilterTexelPad = 2, // Given a src rect in texels to be filtered, this
number of | 21 kFilterTexelPad = 2, // Given a src rect in texels to be filtered, this
number of |
22 // surrounding texels are needed by the kernel in x
and y. | 22 // surrounding texels are needed by the kernel in x
and y. |
23 }; | 23 }; |
24 virtual ~GrBicubicEffect(); | 24 virtual ~GrBicubicEffect(); |
25 | 25 |
26 const float* coefficients() const { return fCoefficients; } | 26 const float* coefficients() const { return fCoefficients; } |
27 | 27 |
28 virtual const char* name() const SK_OVERRIDE { return "Bicubic"; } | 28 const char* name() const SK_OVERRIDE { return "Bicubic"; } |
29 | 29 |
30 virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) cons
t SK_OVERRIDE; | 30 void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVE
RRIDE; |
31 | 31 |
32 virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE; | 32 GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE; |
33 | 33 |
34 const GrTextureDomain& domain() const { return fDomain; } | 34 const GrTextureDomain& domain() const { return fDomain; } |
35 | 35 |
36 /** | 36 /** |
37 * Create a simple filter effect with custom bicubic coefficients and option
al domain. | 37 * Create a simple filter effect with custom bicubic coefficients and option
al domain. |
38 */ | 38 */ |
39 static GrFragmentProcessor* Create(GrTexture* tex, const SkScalar coefficien
ts[16], | 39 static GrFragmentProcessor* Create(GrTexture* tex, const SkScalar coefficien
ts[16], |
40 const SkRect* domain = NULL) { | 40 const SkRect* domain = NULL) { |
41 if (NULL == domain) { | 41 if (NULL == domain) { |
42 static const SkShader::TileMode kTileModes[] = { SkShader::kClamp_Ti
leMode, | 42 static const SkShader::TileMode kTileModes[] = { SkShader::kClamp_Ti
leMode, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 * kNearest). | 84 * kNearest). |
85 */ | 85 */ |
86 static bool ShouldUseBicubic(const SkMatrix& localCoordsToDevice, | 86 static bool ShouldUseBicubic(const SkMatrix& localCoordsToDevice, |
87 GrTextureParams::FilterMode* filterMode); | 87 GrTextureParams::FilterMode* filterMode); |
88 | 88 |
89 private: | 89 private: |
90 GrBicubicEffect(GrTexture*, const SkScalar coefficients[16], | 90 GrBicubicEffect(GrTexture*, const SkScalar coefficients[16], |
91 const SkMatrix &matrix, const SkShader::TileMode tileModes[2
]); | 91 const SkMatrix &matrix, const SkShader::TileMode tileModes[2
]); |
92 GrBicubicEffect(GrTexture*, const SkScalar coefficients[16], | 92 GrBicubicEffect(GrTexture*, const SkScalar coefficients[16], |
93 const SkMatrix &matrix, const SkRect& domain); | 93 const SkMatrix &matrix, const SkRect& domain); |
94 virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE; | 94 bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE; |
95 | 95 |
96 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVE
RRIDE; | 96 void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE; |
97 | 97 |
98 float fCoefficients[16]; | 98 float fCoefficients[16]; |
99 GrTextureDomain fDomain; | 99 GrTextureDomain fDomain; |
100 | 100 |
101 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 101 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
102 | 102 |
103 static const SkScalar gMitchellCoefficients[16]; | 103 static const SkScalar gMitchellCoefficients[16]; |
104 | 104 |
105 typedef GrSingleTextureEffect INHERITED; | 105 typedef GrSingleTextureEffect INHERITED; |
106 }; | 106 }; |
107 | 107 |
108 #endif | 108 #endif |
OLD | NEW |