4fee323522
This should let getTypeName() and serialization work even when deserialization factories haven't been registered. I've made getTypeName() pure virtual like getFactory(), and moved all the overrides into SK_FLATTENABLE_HOOKS, cleaning up all the various ways we've done it before. All the subclasses override getTypeName() and getFactory() privately, so there should be no need to document them? Change-Id: I723cb20099d250c2f2a10be266e3aacc6a061937 Reviewed-on: https://skia-review.googlesource.com/c/163543 Reviewed-by: Cary Clark <caryclark@google.com> Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Klein <mtklein@google.com>
64 lines
2.3 KiB
C++
64 lines
2.3 KiB
C++
/*
|
|
* Copyright 2013 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#ifndef SkDisplacementMapEffect_DEFINED
|
|
#define SkDisplacementMapEffect_DEFINED
|
|
|
|
#include "SkImageFilter.h"
|
|
|
|
class SK_API SkDisplacementMapEffect : public SkImageFilter {
|
|
public:
|
|
enum ChannelSelectorType {
|
|
kUnknown_ChannelSelectorType,
|
|
kR_ChannelSelectorType,
|
|
kG_ChannelSelectorType,
|
|
kB_ChannelSelectorType,
|
|
kA_ChannelSelectorType,
|
|
|
|
kLast_ChannelSelectorType = kA_ChannelSelectorType
|
|
};
|
|
|
|
~SkDisplacementMapEffect() override;
|
|
|
|
static sk_sp<SkImageFilter> Make(ChannelSelectorType xChannelSelector,
|
|
ChannelSelectorType yChannelSelector,
|
|
SkScalar scale,
|
|
sk_sp<SkImageFilter> displacement,
|
|
sk_sp<SkImageFilter> color,
|
|
const CropRect* cropRect = nullptr);
|
|
|
|
SkRect computeFastBounds(const SkRect& src) const override;
|
|
|
|
virtual SkIRect onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
|
|
MapDirection, const SkIRect* inputRect) const override;
|
|
sk_sp<SkImageFilter> onMakeColorSpace(SkColorSpaceXformer*) const override;
|
|
SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix& ctm,
|
|
MapDirection, const SkIRect* inputRect) const override;
|
|
|
|
protected:
|
|
sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
|
|
SkIPoint* offset) const override;
|
|
|
|
SkDisplacementMapEffect(ChannelSelectorType xChannelSelector,
|
|
ChannelSelectorType yChannelSelector,
|
|
SkScalar scale, sk_sp<SkImageFilter> inputs[2],
|
|
const CropRect* cropRect);
|
|
void flatten(SkWriteBuffer&) const override;
|
|
|
|
private:
|
|
SK_FLATTENABLE_HOOKS(SkDisplacementMapEffect)
|
|
|
|
ChannelSelectorType fXChannelSelector;
|
|
ChannelSelectorType fYChannelSelector;
|
|
SkScalar fScale;
|
|
typedef SkImageFilter INHERITED;
|
|
const SkImageFilter* getDisplacementInput() const { return getInput(0); }
|
|
const SkImageFilter* getColorInput() const { return getInput(1); }
|
|
};
|
|
|
|
#endif
|