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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/effects/SkMatrixConvolutionImageFilter.cpp ('k') | src/gpu/effects/GrMatrixConvolutionEffect.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/effects/GrMatrixConvolutionEffect.h
diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.h b/src/gpu/effects/GrMatrixConvolutionEffect.h
new file mode 100644
index 0000000000000000000000000000000000000000..6fdd85b7c74d5de862dc097fdc7b65024f281592
--- /dev/null
+++ b/src/gpu/effects/GrMatrixConvolutionEffect.h
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrMatrixConvolutionEffect_DEFINED
+#define GrMatrixConvolutionEffect_DEFINED
+
+#include "GrSingleTextureEffect.h"
+
+// A little bit less than the minimum # uniforms required by DX9SM2 (32).
+// Allows for a 5x5 kernel (or 25x1, for that matter).
+#define MAX_KERNEL_SIZE 25
+
+class GrGLMatrixConvolutionEffect;
+
+class GrMatrixConvolutionEffect : public GrSingleTextureEffect {
+public:
+ /*! \enum TileMode */
+ enum TileMode {
+ kClamp_TileMode = 0, /*!< Clamp to the image's edge pixels. */
+ kRepeat_TileMode, /*!< Wrap around to the image's opposite edge. */
+ kClampToBlack_TileMode, /*!< Fill with transparent black. */
+ kMax_TileMode = kClampToBlack_TileMode
+ };
+
+ typedef GrMatrixConvolutionEffect::TileMode TileMode;
+ static GrEffect* Create(GrTexture* texture,
+ const SkIRect& bounds,
+ const SkISize& kernelSize,
+ const SkScalar* kernel,
+ SkScalar gain,
+ SkScalar bias,
+ const SkIPoint& kernelOffset,
+ TileMode tileMode,
+ bool convolveAlpha) {
+ return SkNEW_ARGS(GrMatrixConvolutionEffect, (texture,
+ bounds,
+ kernelSize,
+ kernel,
+ gain,
+ bias,
+ kernelOffset,
+ tileMode,
+ convolveAlpha));
+ }
+ virtual ~GrMatrixConvolutionEffect();
+
+ virtual void getConstantColorComponents(GrColor* color,
+ uint32_t* validFlags) const SK_OVERRIDE {
+ // TODO: Try to do better?
+ *validFlags = 0;
+ }
+
+ static const char* Name() { return "MatrixConvolution"; }
+ const SkIRect& bounds() const { return fBounds; }
+ const SkISize& kernelSize() const { return fKernelSize; }
+ const float* kernelOffset() const { return fKernelOffset; }
+ const float* kernel() const { return fKernel; }
+ float gain() const { return fGain; }
+ float bias() const { return fBias; }
+ TileMode tileMode() const { return fTileMode; }
+ bool convolveAlpha() const { return fConvolveAlpha; }
+
+ typedef GrGLMatrixConvolutionEffect GLEffect;
+
+ virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
+
+private:
+ GrMatrixConvolutionEffect(GrTexture*,
+ const SkIRect& bounds,
+ const SkISize& kernelSize,
+ const SkScalar* kernel,
+ SkScalar gain,
+ SkScalar bias,
+ const SkIPoint& kernelOffset,
+ TileMode tileMode,
+ bool convolveAlpha);
+
+ virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE;
+
+ SkIRect fBounds;
+ SkISize fKernelSize;
+ float *fKernel;
+ float fGain;
+ float fBias;
+ float fKernelOffset[2];
+ TileMode fTileMode;
+ bool fConvolveAlpha;
+
+ GR_DECLARE_EFFECT_TEST;
+
+ typedef GrSingleTextureEffect INHERITED;
+};
+
+#endif
« 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