blob: 643c150001083d8a00c49439930d5254ea5ce6c7 [file] [log] [blame]
Tyler Denniston32b30892021-01-26 14:36:32 -05001/*
2 * Copyright 2021 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 SkSVGFeLightSource_DEFINED
9#define SkSVGFeLightSource_DEFINED
10
Tyler Denniston8cfe7182021-04-29 14:54:25 -040011#include "include/core/SkPoint3.h"
Tyler Denniston32b30892021-01-26 14:36:32 -050012#include "modules/svg/include/SkSVGHiddenContainer.h"
13#include "modules/svg/include/SkSVGTypes.h"
14
15class SkSVGFeLightSource : public SkSVGHiddenContainer {
16public:
17 void appendChild(sk_sp<SkSVGNode>) final {
18 SkDebugf("cannot append child nodes to an SVG light source.\n");
19 }
20
21protected:
22 explicit SkSVGFeLightSource(SkSVGTag tag) : INHERITED(tag) {}
23
24private:
25 using INHERITED = SkSVGHiddenContainer;
26};
27
28class SkSVGFeDistantLight final : public SkSVGFeLightSource {
29public:
30 static sk_sp<SkSVGFeDistantLight> Make() {
31 return sk_sp<SkSVGFeDistantLight>(new SkSVGFeDistantLight());
32 }
33
Tyler Denniston8cfe7182021-04-29 14:54:25 -040034 SkPoint3 computeDirection() const;
35
Tyler Denniston32b30892021-01-26 14:36:32 -050036 SVG_ATTR(Azimuth , SkSVGNumberType, 0)
37 SVG_ATTR(Elevation, SkSVGNumberType, 0)
38
39private:
40 SkSVGFeDistantLight() : INHERITED(SkSVGTag::kFeDistantLight) {}
41
42 bool parseAndSetAttribute(const char*, const char*) override;
43
44 using INHERITED = SkSVGFeLightSource;
45};
46
47class SkSVGFePointLight final : public SkSVGFeLightSource {
48public:
49 static sk_sp<SkSVGFePointLight> Make() {
50 return sk_sp<SkSVGFePointLight>(new SkSVGFePointLight());
51 }
52
53 SVG_ATTR(X, SkSVGNumberType, 0)
54 SVG_ATTR(Y, SkSVGNumberType, 0)
55 SVG_ATTR(Z, SkSVGNumberType, 0)
56
57private:
58 SkSVGFePointLight() : INHERITED(SkSVGTag::kFePointLight) {}
59
60 bool parseAndSetAttribute(const char*, const char*) override;
61
62 using INHERITED = SkSVGFeLightSource;
63};
64
65class SkSVGFeSpotLight final : public SkSVGFeLightSource {
66public:
67 static sk_sp<SkSVGFeSpotLight> Make() {
68 return sk_sp<SkSVGFeSpotLight>(new SkSVGFeSpotLight());
69 }
70
71 SVG_ATTR(X , SkSVGNumberType, 0)
72 SVG_ATTR(Y , SkSVGNumberType, 0)
73 SVG_ATTR(Z , SkSVGNumberType, 0)
74 SVG_ATTR(PointsAtX , SkSVGNumberType, 0)
75 SVG_ATTR(PointsAtY , SkSVGNumberType, 0)
76 SVG_ATTR(PointsAtZ , SkSVGNumberType, 0)
77 SVG_ATTR(SpecularExponent, SkSVGNumberType, 1)
78
79 SVG_OPTIONAL_ATTR(LimitingConeAngle, SkSVGNumberType)
80
81private:
82 SkSVGFeSpotLight() : INHERITED(SkSVGTag::kFeSpotLight) {}
83
84 bool parseAndSetAttribute(const char*, const char*) override;
85
86 using INHERITED = SkSVGFeLightSource;
87};
88
89#endif // SkSVGFeLightSource_DEFINED