Flutter Engine
The Flutter Engine
SkSVGFeMorphology.cpp
Go to the documentation of this file.
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
14
15bool SkSVGFeMorphology::parseAndSetAttribute(const char* name, const char* value) {
17 this->setOperator(SkSVGAttributeParser::parse<SkSVGFeMorphology::Operator>(
18 "operator", name, value)) ||
19 this->setRadius(SkSVGAttributeParser::parse<SkSVGFeMorphology::Radius>(
20 "radius", name, value));
21}
22
24 const SkSVGFilterContext& fctx) const {
25 const SkRect cropRect = this->resolveFilterSubregion(ctx, fctx);
26 const SkSVGColorspace colorspace = this->resolveColorspace(ctx, fctx);
27 sk_sp<SkImageFilter> input = fctx.resolveInput(ctx, this->getIn(), colorspace);
28
29 const auto r = SkV2{fRadius.fX, fRadius.fY}
31 switch (fOperator) {
33 return SkImageFilters::Erode(r.x, r.y, input, cropRect);
35 return SkImageFilters::Dilate(r.x, r.y, input, cropRect);
36 }
37
39}
40
41template <>
42bool SkSVGAttributeParser::parse<SkSVGFeMorphology::Operator>(SkSVGFeMorphology::Operator* op) {
43 static constexpr std::tuple<const char*, SkSVGFeMorphology::Operator> gMap[] = {
46 };
47
48 return this->parseEnumMap(gMap, op) && this->parseEOSToken();
49}
50
51template <>
52bool SkSVGAttributeParser::parse<SkSVGFeMorphology::Radius>(SkSVGFeMorphology::Radius* radius) {
53 std::vector<SkSVGNumberType> values;
54 if (!this->parse(&values)) {
55 return false;
56 }
57
58 radius->fX = values[0];
59 radius->fY = values.size() > 1 ? values[1] : values[0];
60 return true;
61}
#define SkUNREACHABLE
Definition: SkAssert.h:135
SkSVGColorspace
Definition: SkSVGTypes.h:719
static sk_sp< SkImageFilter > Erode(SkScalar radiusX, SkScalar radiusY, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Dilate(SkScalar radiusX, SkScalar radiusY, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
bool parseAndSetAttribute(const char *, const char *) override
sk_sp< SkImageFilter > onMakeImageFilter(const SkSVGRenderContext &, const SkSVGFilterContext &) const override
SkRect resolveFilterSubregion(const SkSVGRenderContext &, const SkSVGFilterContext &) const
Definition: SkSVGFe.cpp:54
bool parseAndSetAttribute(const char *, const char *) override
Definition: SkSVGFe.cpp:93
virtual SkSVGColorspace resolveColorspace(const SkSVGRenderContext &, const SkSVGFilterContext &) const
Definition: SkSVGFe.cpp:84
sk_sp< SkImageFilter > resolveInput(const SkSVGRenderContext &, const SkSVGFeInputType &) const
const SkSVGObjectBoundingBoxUnits & primitiveUnits() const
OBBTransform transformForCurrentOBB(SkSVGObjectBoundingBoxUnits) const
uint8_t value
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32
def parse(repo_root, recipes_cfg_path)
Definition: recipes.py:56
float fX
x-axis value
Definition: SkPoint_impl.h:164
float fY
y-axis value
Definition: SkPoint_impl.h:165
Definition: SkM44.h:19