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 "include/core/SkPoint3.h" 12 #include "modules/svg/include/SkSVGHiddenContainer.h" 13 #include "modules/svg/include/SkSVGTypes.h" 14 15 class SkSVGFeLightSource : public SkSVGHiddenContainer { 16 public: appendChild(sk_sp<SkSVGNode>)17 void appendChild(sk_sp<SkSVGNode>) final { 18 SkDebugf("cannot append child nodes to an SVG light source.\n"); 19 } 20 21 protected: SkSVGFeLightSource(SkSVGTag tag)22 explicit SkSVGFeLightSource(SkSVGTag tag) : INHERITED(tag) {} 23 24 private: 25 using INHERITED = SkSVGHiddenContainer; 26 }; 27 28 class SkSVGFeDistantLight final : public SkSVGFeLightSource { 29 public: Make()30 static sk_sp<SkSVGFeDistantLight> Make() { 31 return sk_sp<SkSVGFeDistantLight>(new SkSVGFeDistantLight()); 32 } 33 34 SkPoint3 computeDirection() const; 35 36 SVG_ATTR(Azimuth , SkSVGNumberType, 0) 37 SVG_ATTR(Elevation, SkSVGNumberType, 0) 38 39 private: SkSVGFeDistantLight()40 SkSVGFeDistantLight() : INHERITED(SkSVGTag::kFeDistantLight) {} 41 42 bool parseAndSetAttribute(const char*, const char*) override; 43 44 using INHERITED = SkSVGFeLightSource; 45 }; 46 47 class SkSVGFePointLight final : public SkSVGFeLightSource { 48 public: Make()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 57 private: SkSVGFePointLight()58 SkSVGFePointLight() : INHERITED(SkSVGTag::kFePointLight) {} 59 60 bool parseAndSetAttribute(const char*, const char*) override; 61 62 using INHERITED = SkSVGFeLightSource; 63 }; 64 65 class SkSVGFeSpotLight final : public SkSVGFeLightSource { 66 public: Make()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 SVG_OPTIONAL_ATTR(LimitingConeAngle,SkSVGNumberType)79 SVG_OPTIONAL_ATTR(LimitingConeAngle, SkSVGNumberType) 80 81 private: 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 90