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