Flutter Engine
The Flutter Engine
SkSVGFe.h
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
8#ifndef SkSVGFe_DEFINED
9#define SkSVGFe_DEFINED
10
11#include <vector>
12
14
15class SkImageFilter;
17
19public:
20 static bool IsFilterEffect(const sk_sp<SkSVGNode>& node) {
21 switch (node->tag()) {
36 return true;
37 default:
38 return false;
39 }
40 }
41
42 sk_sp<SkImageFilter> makeImageFilter(const SkSVGRenderContext& ctx,
43 const SkSVGFilterContext& fctx) const;
44
45 // https://www.w3.org/TR/SVG11/filters.html#FilterPrimitiveSubRegion
46 SkRect resolveFilterSubregion(const SkSVGRenderContext&, const SkSVGFilterContext&) const;
47
48 /**
49 * Resolves the colorspace within which this filter effect should be applied.
50 * Spec: https://www.w3.org/TR/SVG11/painting.html#ColorInterpolationProperties
51 * 'color-interpolation-filters' property.
52 */
53 virtual SkSVGColorspace resolveColorspace(const SkSVGRenderContext&,
54 const SkSVGFilterContext&) const;
55
56 /** Propagates any inherited presentation attributes in the given context. */
57 void applyProperties(SkSVGRenderContext*) const;
58
65
66protected:
67 explicit SkSVGFe(SkSVGTag t) : INHERITED(t) {}
68
70 const SkSVGFilterContext&) const = 0;
71
72 virtual std::vector<SkSVGFeInputType> getInputs() const = 0;
73
74 bool parseAndSetAttribute(const char*, const char*) override;
75
76private:
77 /**
78 * Resolves the rect specified by the x, y, width and height attributes (if specified) on this
79 * filter effect. These attributes are resolved according to the given length context and
80 * the value of 'primitiveUnits' on the parent <filter> element.
81 */
82 SkRect resolveBoundaries(const SkSVGRenderContext&, const SkSVGFilterContext&) const;
83
85};
86
87#endif // SkSVGFe_DEFINED
#define SK_API
Definition: SkAPI.h:35
#define SVG_OPTIONAL_ATTR(attr_name, attr_type)
Definition: SkSVGNode.h:220
SkSVGTag
Definition: SkSVGNode.h:23
@ kFeColorMatrix
@ kFeSpecularLighting
@ kFeDisplacementMap
@ kFeGaussianBlur
@ kFeDiffuseLighting
@ kFeComponentTransfer
#define SVG_ATTR(attr_name, attr_type, attr_default)
Definition: SkSVGNode.h:210
SkSVGColorspace
Definition: SkSVGTypes.h:719
static const SkScalar Y
Definition: StrokeBench.cpp:55
static const SkScalar X
Definition: StrokeBench.cpp:54
virtual std::vector< SkSVGFeInputType > getInputs() const =0
virtual sk_sp< SkImageFilter > onMakeImageFilter(const SkSVGRenderContext &, const SkSVGFilterContext &) const =0
static bool IsFilterEffect(const sk_sp< SkSVGNode > &node)
Definition: SkSVGFe.h:20
virtual bool parseAndSetAttribute(const char *name, const char *value)
Definition: SkSVGNode.cpp:90
SkSVGTag tag() const
Definition: SkSVGNode.h:106