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 SkSVGFeMorphology_DEFINED 9 #define SkSVGFeMorphology_DEFINED 10 11 #include "include/core/SkRefCnt.h" 12 #include "modules/svg/include/SkSVGFe.h" 13 #include "modules/svg/include/SkSVGNode.h" 14 #include "modules/svg/include/SkSVGTypes.h" 15 16 #include <vector> 17 18 class SkImageFilter; 19 class SkSVGFilterContext; 20 class SkSVGRenderContext; 21 22 class SkSVGFeMorphology : public SkSVGFe { 23 public: 24 struct Radius { 25 SkSVGNumberType fX; 26 SkSVGNumberType fY; 27 }; 28 29 enum class Operator { 30 kErode, 31 kDilate, 32 }; 33 Make()34 static sk_sp<SkSVGFeMorphology> Make() { 35 return sk_sp<SkSVGFeMorphology>(new SkSVGFeMorphology()); 36 } 37 38 SVG_ATTR(Operator, Operator, Operator::kErode) 39 SVG_ATTR(Radius , Radius , Radius({0, 0})) 40 41 protected: 42 sk_sp<SkImageFilter> onMakeImageFilter(const SkSVGRenderContext&, 43 const SkSVGFilterContext&) const override; 44 getInputs()45 std::vector<SkSVGFeInputType> getInputs() const override { return {this->getIn()}; } 46 47 bool parseAndSetAttribute(const char*, const char*) override; 48 49 private: SkSVGFeMorphology()50 SkSVGFeMorphology() : INHERITED(SkSVGTag::kFeMorphology) {} 51 52 using INHERITED = SkSVGFe; 53 }; 54 55 #endif // SkSVGFeMorphology_DEFINED 56