/src/skia/modules/svg/include/SkSVGFeLighting.h
Line | Count | Source (jump to first uncovered line) |
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 SkSVGFeLighting_DEFINED |
9 | | #define SkSVGFeLighting_DEFINED |
10 | | |
11 | | #include "modules/svg/include/SkSVGFe.h" |
12 | | #include "modules/svg/include/SkSVGTypes.h" |
13 | | |
14 | | class SkSVGFeDistantLight; |
15 | | class SkSVGFePointLight; |
16 | | class SkSVGFeSpotLight; |
17 | | |
18 | | class SkSVGFeLighting : public SkSVGFe { |
19 | | public: |
20 | | struct KernelUnitLength { |
21 | | SkSVGNumberType fDx; |
22 | | SkSVGNumberType fDy; |
23 | | }; |
24 | | |
25 | | SVG_ATTR(SurfaceScale, SkSVGNumberType, 1) |
26 | | SVG_OPTIONAL_ATTR(KernelUnitLength, KernelUnitLength) |
27 | | |
28 | | protected: |
29 | 0 | explicit SkSVGFeLighting(SkSVGTag t) : INHERITED(t) {} |
30 | | |
31 | 0 | std::vector<SkSVGFeInputType> getInputs() const final { return {this->getIn()}; } |
32 | | |
33 | | bool parseAndSetAttribute(const char*, const char*) override; |
34 | | |
35 | | sk_sp<SkImageFilter> onMakeImageFilter(const SkSVGRenderContext&, |
36 | | const SkSVGFilterContext&) const final; |
37 | | |
38 | | virtual sk_sp<SkImageFilter> makeDistantLight(const SkSVGRenderContext&, |
39 | | const SkSVGFilterContext&, |
40 | | const SkSVGFeDistantLight*) const = 0; |
41 | | |
42 | | virtual sk_sp<SkImageFilter> makePointLight(const SkSVGRenderContext&, |
43 | | const SkSVGFilterContext&, |
44 | | const SkSVGFePointLight*) const = 0; |
45 | | |
46 | | virtual sk_sp<SkImageFilter> makeSpotLight(const SkSVGRenderContext&, |
47 | | const SkSVGFilterContext&, |
48 | | const SkSVGFeSpotLight*) const = 0; |
49 | | |
50 | | SkColor resolveLightingColor(const SkSVGRenderContext&) const; |
51 | | |
52 | | SkPoint3 resolveXYZ(const SkSVGRenderContext&, |
53 | | const SkSVGFilterContext&, |
54 | | SkSVGNumberType, |
55 | | SkSVGNumberType, |
56 | | SkSVGNumberType) const; |
57 | | |
58 | | private: |
59 | | using INHERITED = SkSVGFe; |
60 | | }; |
61 | | |
62 | | class SkSVGFeSpecularLighting final : public SkSVGFeLighting { |
63 | | public: |
64 | 0 | static sk_sp<SkSVGFeSpecularLighting> Make() { |
65 | 0 | return sk_sp<SkSVGFeSpecularLighting>(new SkSVGFeSpecularLighting()); |
66 | 0 | } |
67 | | |
68 | | SVG_ATTR(SpecularConstant, SkSVGNumberType, 1) |
69 | | SVG_ATTR(SpecularExponent, SkSVGNumberType, 1) |
70 | | |
71 | | protected: |
72 | | bool parseAndSetAttribute(const char*, const char*) override; |
73 | | |
74 | | sk_sp<SkImageFilter> makeDistantLight(const SkSVGRenderContext&, |
75 | | const SkSVGFilterContext&, |
76 | | const SkSVGFeDistantLight*) const final; |
77 | | |
78 | | sk_sp<SkImageFilter> makePointLight(const SkSVGRenderContext&, |
79 | | const SkSVGFilterContext&, |
80 | | const SkSVGFePointLight*) const final; |
81 | | |
82 | | sk_sp<SkImageFilter> makeSpotLight(const SkSVGRenderContext&, |
83 | | const SkSVGFilterContext&, |
84 | | const SkSVGFeSpotLight*) const final; |
85 | | |
86 | | private: |
87 | 0 | SkSVGFeSpecularLighting() : INHERITED(SkSVGTag::kFeSpecularLighting) {} |
88 | | |
89 | | using INHERITED = SkSVGFeLighting; |
90 | | }; |
91 | | |
92 | | class SkSVGFeDiffuseLighting final : public SkSVGFeLighting { |
93 | | public: |
94 | 0 | static sk_sp<SkSVGFeDiffuseLighting> Make() { |
95 | 0 | return sk_sp<SkSVGFeDiffuseLighting>(new SkSVGFeDiffuseLighting()); |
96 | 0 | } |
97 | | |
98 | | SVG_ATTR(DiffuseConstant, SkSVGNumberType, 1) |
99 | | |
100 | | protected: |
101 | | bool parseAndSetAttribute(const char*, const char*) override; |
102 | | |
103 | | sk_sp<SkImageFilter> makeDistantLight(const SkSVGRenderContext&, |
104 | | const SkSVGFilterContext&, |
105 | | const SkSVGFeDistantLight*) const final; |
106 | | |
107 | | sk_sp<SkImageFilter> makePointLight(const SkSVGRenderContext&, |
108 | | const SkSVGFilterContext&, |
109 | | const SkSVGFePointLight*) const final; |
110 | | |
111 | | sk_sp<SkImageFilter> makeSpotLight(const SkSVGRenderContext&, |
112 | | const SkSVGFilterContext&, |
113 | | const SkSVGFeSpotLight*) const final; |
114 | | |
115 | | private: |
116 | 0 | SkSVGFeDiffuseLighting() : INHERITED(SkSVGTag::kFeDiffuseLighting) {} |
117 | | |
118 | | using INHERITED = SkSVGFeLighting; |
119 | | }; |
120 | | |
121 | | #endif // SkSVGFeLighting_DEFINED |