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