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