| 1 |
/* |
| 2 |
* Copyright 2020 Google Inc. |
| 3 |
* |
| 4 |
* Use of this source code is governed by a BSD-style license that can be |
| 5 |
* found in the LICENSE file. |
| 6 |
*/ |
| 7 |
|
| 8 |
#ifndef SkSVGFeDisplacementMap_DEFINED |
| 9 |
#define SkSVGFeDisplacementMap_DEFINED |
| 10 |
|
| 11 |
#include "include/core/SkColor.h" |
| 12 |
#include "include/core/SkRefCnt.h" |
| 13 |
#include "include/private/base/SkAPI.h" |
| 14 |
#include "modules/svg/include/SkSVGFe.h" |
| 15 |
#include "modules/svg/include/SkSVGNode.h" |
| 16 |
#include "modules/svg/include/SkSVGTypes.h" |
| 17 |
|
| 18 |
#include <vector> |
| 19 |
|
| 20 |
class SkImageFilter; |
| 21 |
class SkSVGFilterContext; |
| 22 |
class SkSVGRenderContext; |
| 23 |
|
| 24 |
class SK_API SkSVGFeDisplacementMap : public SkSVGFe { |
| 25 |
public: |
| 26 |
using ChannelSelector = SkColorChannel; |
| 27 |
|
| 28 |
static sk_sp<SkSVGFeDisplacementMap> Make() { |
| 29 |
return sk_sp<SkSVGFeDisplacementMap>(new SkSVGFeDisplacementMap()); |
| 30 |
} |
| 31 |
|
| 32 |
SkSVGColorspace resolveColorspace(const SkSVGRenderContext&, |
| 33 |
const SkSVGFilterContext&) const final; |
| 34 |
|
| 35 |
SVG_ATTR(In2 , SkSVGFeInputType, SkSVGFeInputType()) |
| 36 |
SVG_ATTR(XChannelSelector, ChannelSelector , ChannelSelector::kA) |
| 37 |
SVG_ATTR(YChannelSelector, ChannelSelector , ChannelSelector::kA) |
| 38 |
SVG_ATTR(Scale , SkSVGNumberType , SkSVGNumberType(0)) |
| 39 |
|
| 40 |
protected: |
| 41 |
sk_sp<SkImageFilter> onMakeImageFilter(const SkSVGRenderContext&, |
| 42 |
const SkSVGFilterContext&) const override; |
| 43 |
|
| 44 |
std::vector<SkSVGFeInputType> getInputs() const override { |
| 45 |
return {this->getIn(), this->getIn2()}; |
| 46 |
} |
| 47 |
|
| 48 |
bool parseAndSetAttribute(const char*, const char*) override; |
| 49 |
|
| 50 |
private: |
| 51 |
SkSVGFeDisplacementMap() : INHERITED(SkSVGTag::kFeDisplacementMap) {} |
| 52 |
|
| 53 |
using INHERITED = SkSVGFe; |
| 54 |
}; |
| 55 |
|
| 56 |
#endif // SkSVGFeDisplacementMap_DEFINED |