Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright 2014 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 GrMatrixConvolutionEffect_DEFINED | |
| 9 #define GrMatrixConvolutionEffect_DEFINED | |
| 10 | |
| 11 #include "GrSingleTextureEffect.h" | |
| 12 #include "../effects/SkMatrixConvolutionImageFilter.h" | |
|
bsalomon
2014/07/11 13:07:41
Hmm... we like the effects code to be optional so
| |
| 13 | |
| 14 class GrGLMatrixConvolutionEffect; | |
| 15 | |
| 16 // A little bit less than the minimum # uniforms required by DX9SM2 (32). | |
| 17 // Allows for a 5x5 kernel (or 25x1, for that matter). | |
| 18 #define MAX_KERNEL_SIZE 25 | |
| 19 | |
| 20 class GrMatrixConvolutionEffect : public GrSingleTextureEffect { | |
| 21 public: | |
| 22 typedef SkMatrixConvolutionImageFilter::TileMode TileMode; | |
| 23 static GrEffect* Create(GrTexture* texture, | |
| 24 const SkIRect& bounds, | |
| 25 const SkISize& kernelSize, | |
| 26 const SkScalar* kernel, | |
| 27 SkScalar gain, | |
| 28 SkScalar bias, | |
| 29 const SkIPoint& kernelOffset, | |
| 30 TileMode tileMode, | |
| 31 bool convolveAlpha) { | |
| 32 return SkNEW_ARGS(GrMatrixConvolutionEffect, (texture, | |
| 33 bounds, | |
| 34 kernelSize, | |
| 35 kernel, | |
| 36 gain, | |
| 37 bias, | |
| 38 kernelOffset, | |
| 39 tileMode, | |
| 40 convolveAlpha)); | |
| 41 } | |
| 42 virtual ~GrMatrixConvolutionEffect(); | |
| 43 | |
| 44 virtual void getConstantColorComponents(GrColor* color, | |
| 45 uint32_t* validFlags) const SK_OVERR IDE { | |
| 46 // TODO: Try to do better? | |
| 47 *validFlags = 0; | |
| 48 } | |
| 49 | |
| 50 static const char* Name() { return "MatrixConvolution"; } | |
| 51 const SkIRect& bounds() const { return fBounds; } | |
| 52 const SkISize& kernelSize() const { return fKernelSize; } | |
| 53 const float* kernelOffset() const { return fKernelOffset; } | |
| 54 const float* kernel() const { return fKernel; } | |
| 55 float gain() const { return fGain; } | |
| 56 float bias() const { return fBias; } | |
| 57 TileMode tileMode() const { return fTileMode; } | |
| 58 bool convolveAlpha() const { return fConvolveAlpha; } | |
| 59 | |
| 60 typedef GrGLMatrixConvolutionEffect GLEffect; | |
| 61 | |
| 62 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; | |
| 63 | |
| 64 private: | |
| 65 GrMatrixConvolutionEffect(GrTexture*, | |
| 66 const SkIRect& bounds, | |
| 67 const SkISize& kernelSize, | |
| 68 const SkScalar* kernel, | |
| 69 SkScalar gain, | |
| 70 SkScalar bias, | |
| 71 const SkIPoint& kernelOffset, | |
| 72 TileMode tileMode, | |
| 73 bool convolveAlpha); | |
| 74 | |
| 75 virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE; | |
| 76 | |
| 77 SkIRect fBounds; | |
| 78 SkISize fKernelSize; | |
| 79 float *fKernel; | |
| 80 float fGain; | |
| 81 float fBias; | |
| 82 float fKernelOffset[2]; | |
| 83 TileMode fTileMode; | |
| 84 bool fConvolveAlpha; | |
| 85 | |
| 86 GR_DECLARE_EFFECT_TEST; | |
| 87 | |
| 88 typedef GrSingleTextureEffect INHERITED; | |
| 89 }; | |
| 90 | |
| 91 #endif | |
| OLD | NEW |