Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Side by Side Diff: src/gpu/effects/GrMatrixConvolutionEffect.h

Issue 379253003: Initial change to move 2D kernel to its own file (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: small cleanup Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
13 // A little bit less than the minimum # uniforms required by DX9SM2 (32).
14 // Allows for a 5x5 kernel (or 25x1, for that matter).
15 #define MAX_KERNEL_SIZE 25
16
17 class GrGLMatrixConvolutionEffect;
18
19 class GrMatrixConvolutionEffect : public GrSingleTextureEffect {
20 public:
21 /*! \enum TileMode */
22 enum TileMode {
23 kClamp_TileMode = 0, /*!< Clamp to the image's edge pixels. */
24 kRepeat_TileMode, /*!< Wrap around to the image's opposite edge. */
25 kClampToBlack_TileMode, /*!< Fill with transparent black. */
26 kMax_TileMode = kClampToBlack_TileMode
27 };
28
29 typedef GrMatrixConvolutionEffect::TileMode TileMode;
30 static GrEffect* Create(GrTexture* texture,
31 const SkIRect& bounds,
32 const SkISize& kernelSize,
33 const SkScalar* kernel,
34 SkScalar gain,
35 SkScalar bias,
36 const SkIPoint& kernelOffset,
37 TileMode tileMode,
38 bool convolveAlpha) {
39 return SkNEW_ARGS(GrMatrixConvolutionEffect, (texture,
40 bounds,
41 kernelSize,
42 kernel,
43 gain,
44 bias,
45 kernelOffset,
46 tileMode,
47 convolveAlpha));
48 }
49 virtual ~GrMatrixConvolutionEffect();
50
51 virtual void getConstantColorComponents(GrColor* color,
52 uint32_t* validFlags) const SK_OVERR IDE {
53 // TODO: Try to do better?
54 *validFlags = 0;
55 }
56
57 static const char* Name() { return "MatrixConvolution"; }
58 const SkIRect& bounds() const { return fBounds; }
59 const SkISize& kernelSize() const { return fKernelSize; }
60 const float* kernelOffset() const { return fKernelOffset; }
61 const float* kernel() const { return fKernel; }
62 float gain() const { return fGain; }
63 float bias() const { return fBias; }
64 TileMode tileMode() const { return fTileMode; }
65 bool convolveAlpha() const { return fConvolveAlpha; }
66
67 typedef GrGLMatrixConvolutionEffect GLEffect;
68
69 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
70
71 private:
72 GrMatrixConvolutionEffect(GrTexture*,
73 const SkIRect& bounds,
74 const SkISize& kernelSize,
75 const SkScalar* kernel,
76 SkScalar gain,
77 SkScalar bias,
78 const SkIPoint& kernelOffset,
79 TileMode tileMode,
80 bool convolveAlpha);
81
82 virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE;
83
84 SkIRect fBounds;
85 SkISize fKernelSize;
86 float *fKernel;
87 float fGain;
88 float fBias;
89 float fKernelOffset[2];
90 TileMode fTileMode;
91 bool fConvolveAlpha;
92
93 GR_DECLARE_EFFECT_TEST;
94
95 typedef GrSingleTextureEffect INHERITED;
96 };
97
98 #endif
OLDNEW
« no previous file with comments | « src/effects/SkMatrixConvolutionImageFilter.cpp ('k') | src/gpu/effects/GrMatrixConvolutionEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698