gfx/skia/trunk/include/effects/SkDisplacementMapEffect.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/include/effects/SkDisplacementMapEffect.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,75 @@
     1.4 +/*
     1.5 + * Copyright 2013 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 SkDisplacementMapEffect_DEFINED
    1.12 +#define SkDisplacementMapEffect_DEFINED
    1.13 +
    1.14 +#include "SkImageFilter.h"
    1.15 +#include "SkBitmap.h"
    1.16 +
    1.17 +class SK_API SkDisplacementMapEffect : public SkImageFilter {
    1.18 +public:
    1.19 +    enum ChannelSelectorType {
    1.20 +        kUnknown_ChannelSelectorType,
    1.21 +        kR_ChannelSelectorType,
    1.22 +        kG_ChannelSelectorType,
    1.23 +        kB_ChannelSelectorType,
    1.24 +        kA_ChannelSelectorType
    1.25 +    };
    1.26 +
    1.27 +    ~SkDisplacementMapEffect();
    1.28 +
    1.29 +    static SkDisplacementMapEffect* Create(ChannelSelectorType xChannelSelector,
    1.30 +                                           ChannelSelectorType yChannelSelector,
    1.31 +                                           SkScalar scale, SkImageFilter* displacement,
    1.32 +                                           SkImageFilter* color = NULL,
    1.33 +                                           const CropRect* cropRect = NULL) {
    1.34 +        return SkNEW_ARGS(SkDisplacementMapEffect, (xChannelSelector, yChannelSelector, scale,
    1.35 +                                                    displacement, color, cropRect));
    1.36 +    }
    1.37 +
    1.38 +    SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDisplacementMapEffect)
    1.39 +
    1.40 +    virtual bool onFilterImage(Proxy* proxy,
    1.41 +                               const SkBitmap& src,
    1.42 +                               const Context& ctx,
    1.43 +                               SkBitmap* dst,
    1.44 +                               SkIPoint* offset) const SK_OVERRIDE;
    1.45 +    virtual void computeFastBounds(const SkRect& src, SkRect* dst) const SK_OVERRIDE;
    1.46 +
    1.47 +    virtual bool onFilterBounds(const SkIRect& src, const SkMatrix&,
    1.48 +                                SkIRect* dst) const SK_OVERRIDE;
    1.49 +
    1.50 +#if SK_SUPPORT_GPU
    1.51 +    virtual bool canFilterImageGPU() const SK_OVERRIDE { return true; }
    1.52 +    virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx,
    1.53 +                                SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE;
    1.54 +#endif
    1.55 +
    1.56 +protected:
    1.57 +    explicit SkDisplacementMapEffect(SkReadBuffer& buffer);
    1.58 +    virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
    1.59 +
    1.60 +#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
    1.61 +public:
    1.62 +#endif
    1.63 +    SkDisplacementMapEffect(ChannelSelectorType xChannelSelector,
    1.64 +                            ChannelSelectorType yChannelSelector,
    1.65 +                            SkScalar scale, SkImageFilter* displacement,
    1.66 +                            SkImageFilter* color = NULL,
    1.67 +                            const CropRect* cropRect = NULL);
    1.68 +
    1.69 +private:
    1.70 +    ChannelSelectorType fXChannelSelector;
    1.71 +    ChannelSelectorType fYChannelSelector;
    1.72 +    SkScalar fScale;
    1.73 +    typedef SkImageFilter INHERITED;
    1.74 +    const SkImageFilter* getDisplacementInput() const { return getInput(0); }
    1.75 +    const SkImageFilter* getColorInput() const { return getInput(1); }
    1.76 +};
    1.77 +
    1.78 +#endif

mercurial