blob: 172460f72ec01e2c77e3b2051a65bd8c27dac146 [file] [log] [blame]
Tyler Denniston4c89481be2021-01-20 09:41:22 -05001/*
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
14class SkSVGFeMorphology : public SkSVGFe {
15public:
16 struct Radius {
17 SkSVGNumberType fX;
18 SkSVGNumberType fY;
19 };
20
21 enum class Operator {
22 kErode,
23 kDilate,
24 };
25
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
33protected:
34 sk_sp<SkImageFilter> onMakeImageFilter(const SkSVGRenderContext&,
35 const SkSVGFilterContext&) const override;
36
37 std::vector<SkSVGFeInputType> getInputs() const override { return {this->getIn()}; }
38
39 bool parseAndSetAttribute(const char*, const char*) override;
40
41private:
42 SkSVGFeMorphology() : INHERITED(SkSVGTag::kFeMorphology) {}
43
44 using INHERITED = SkSVGFe;
45};
46
47#endif // SkSVGFeMorphology_DEFINED