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