michael@0: /* michael@0: * Copyright 2012 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: #ifndef Gr1DKernelEffect_DEFINED michael@0: #define Gr1DKernelEffect_DEFINED michael@0: michael@0: #include "GrSingleTextureEffect.h" michael@0: #include "SkMatrix.h" michael@0: michael@0: /** michael@0: * Base class for 1D kernel effects. The kernel operates either in X or Y and michael@0: * has a pixel radius. The kernel is specified in the src texture's space michael@0: * and the kernel center is pinned to a texel's center. The radius specifies michael@0: * the number of texels on either side of the center texel in X or Y that are michael@0: * read. Since the center pixel is also read, the total width is one larger than michael@0: * two times the radius. michael@0: */ michael@0: michael@0: class Gr1DKernelEffect : public GrSingleTextureEffect { michael@0: michael@0: public: michael@0: enum Direction { michael@0: kX_Direction, michael@0: kY_Direction, michael@0: }; michael@0: michael@0: Gr1DKernelEffect(GrTexture* texture, michael@0: Direction direction, michael@0: int radius) michael@0: : GrSingleTextureEffect(texture, MakeDivByTextureWHMatrix(texture)) michael@0: , fDirection(direction) michael@0: , fRadius(radius) {} michael@0: michael@0: virtual ~Gr1DKernelEffect() {}; michael@0: michael@0: static int WidthFromRadius(int radius) { return 2 * radius + 1; } michael@0: michael@0: int radius() const { return fRadius; } michael@0: int width() const { return WidthFromRadius(fRadius); } michael@0: Direction direction() const { return fDirection; } michael@0: michael@0: private: michael@0: michael@0: Direction fDirection; michael@0: int fRadius; michael@0: michael@0: typedef GrSingleTextureEffect INHERITED; michael@0: }; michael@0: michael@0: #endif