gfx/skia/trunk/src/gpu/effects/Gr1DKernelEffect.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/src/gpu/effects/Gr1DKernelEffect.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,54 @@
     1.4 +/*
     1.5 + * Copyright 2012 Google Inc.
     1.6 + *
     1.7 + * Use of this source code is governed by a BSD-style license that can be
     1.8 + * found in the LICENSE file.
     1.9 + */
    1.10 +
    1.11 +#ifndef Gr1DKernelEffect_DEFINED
    1.12 +#define Gr1DKernelEffect_DEFINED
    1.13 +
    1.14 +#include "GrSingleTextureEffect.h"
    1.15 +#include "SkMatrix.h"
    1.16 +
    1.17 +/**
    1.18 + * Base class for 1D kernel effects. The kernel operates either in X or Y and
    1.19 + * has a pixel radius. The kernel is specified in the src texture's space
    1.20 + * and the kernel center is pinned to a texel's center. The radius specifies
    1.21 + * the number of texels on either side of the center texel in X or Y that are
    1.22 + * read. Since the center pixel is also read, the total width is one larger than
    1.23 + * two times the radius.
    1.24 + */
    1.25 +
    1.26 +class Gr1DKernelEffect : public GrSingleTextureEffect {
    1.27 +
    1.28 +public:
    1.29 +    enum Direction {
    1.30 +        kX_Direction,
    1.31 +        kY_Direction,
    1.32 +    };
    1.33 +
    1.34 +    Gr1DKernelEffect(GrTexture* texture,
    1.35 +                     Direction direction,
    1.36 +                     int radius)
    1.37 +        : GrSingleTextureEffect(texture, MakeDivByTextureWHMatrix(texture))
    1.38 +        , fDirection(direction)
    1.39 +        , fRadius(radius) {}
    1.40 +
    1.41 +    virtual ~Gr1DKernelEffect() {};
    1.42 +
    1.43 +    static int WidthFromRadius(int radius) { return 2 * radius + 1; }
    1.44 +
    1.45 +    int radius() const { return fRadius; }
    1.46 +    int width() const { return WidthFromRadius(fRadius); }
    1.47 +    Direction direction() const { return fDirection; }
    1.48 +
    1.49 +private:
    1.50 +
    1.51 +    Direction       fDirection;
    1.52 +    int             fRadius;
    1.53 +
    1.54 +    typedef GrSingleTextureEffect INHERITED;
    1.55 +};
    1.56 +
    1.57 +#endif

mercurial