| 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/GrGLFragmentProcessor.h" | 13 #include "gl/GrGLFragmentProcessor.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 const char* name() const override { return "Bicubic"; } | 28 const char* name() const override { return "Bicubic"; } |
| 29 | 29 |
| 30 void getGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const over
ride; | |
| 31 | |
| 32 GrGLFragmentProcessor* createGLInstance() const override; | 30 GrGLFragmentProcessor* createGLInstance() const override; |
| 33 | 31 |
| 34 const GrTextureDomain& domain() const { return fDomain; } | 32 const GrTextureDomain& domain() const { return fDomain; } |
| 35 | 33 |
| 36 /** | 34 /** |
| 37 * Create a simple filter effect with custom bicubic coefficients and option
al domain. | 35 * Create a simple filter effect with custom bicubic coefficients and option
al domain. |
| 38 */ | 36 */ |
| 39 static GrFragmentProcessor* Create(GrProcessorDataManager* procDataManager,
GrTexture* tex, | 37 static GrFragmentProcessor* Create(GrProcessorDataManager* procDataManager,
GrTexture* tex, |
| 40 const SkScalar coefficients[16], | 38 const SkScalar coefficients[16], |
| 41 const SkRect* domain = NULL) { | 39 const SkRect* domain = NULL) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 * kNearest). | 85 * kNearest). |
| 88 */ | 86 */ |
| 89 static bool ShouldUseBicubic(const SkMatrix& localCoordsToDevice, | 87 static bool ShouldUseBicubic(const SkMatrix& localCoordsToDevice, |
| 90 GrTextureParams::FilterMode* filterMode); | 88 GrTextureParams::FilterMode* filterMode); |
| 91 | 89 |
| 92 private: | 90 private: |
| 93 GrBicubicEffect(GrProcessorDataManager*, GrTexture*, const SkScalar coeffici
ents[16], | 91 GrBicubicEffect(GrProcessorDataManager*, GrTexture*, const SkScalar coeffici
ents[16], |
| 94 const SkMatrix &matrix, const SkShader::TileMode tileModes[2
]); | 92 const SkMatrix &matrix, const SkShader::TileMode tileModes[2
]); |
| 95 GrBicubicEffect(GrProcessorDataManager*, GrTexture*, const SkScalar coeffici
ents[16], | 93 GrBicubicEffect(GrProcessorDataManager*, GrTexture*, const SkScalar coeffici
ents[16], |
| 96 const SkMatrix &matrix, const SkRect& domain); | 94 const SkMatrix &matrix, const SkRect& domain); |
| 95 |
| 96 void onGetGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const ov
erride; |
| 97 |
| 97 bool onIsEqual(const GrFragmentProcessor&) const override; | 98 bool onIsEqual(const GrFragmentProcessor&) const override; |
| 98 | 99 |
| 99 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; | 100 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; |
| 100 | 101 |
| 101 float fCoefficients[16]; | 102 float fCoefficients[16]; |
| 102 GrTextureDomain fDomain; | 103 GrTextureDomain fDomain; |
| 103 | 104 |
| 104 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 105 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
| 105 | 106 |
| 106 static const SkScalar gMitchellCoefficients[16]; | 107 static const SkScalar gMitchellCoefficients[16]; |
| 107 | 108 |
| 108 typedef GrSingleTextureEffect INHERITED; | 109 typedef GrSingleTextureEffect INHERITED; |
| 109 }; | 110 }; |
| 110 | 111 |
| 111 #endif | 112 #endif |
| OLD | NEW |