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