19 this->setSurfaceScale(
20 SkSVGAttributeParser::parse<SkSVGNumberType>(
"surfaceScale", n, v)) ||
21 this->setKernelUnitLength(SkSVGAttributeParser::parse<SkSVGFeLighting::KernelUnitLength>(
22 "kernelUnitLength", n, v));
26bool SkSVGAttributeParser::parse<SkSVGFeLighting::KernelUnitLength>(
28 std::vector<SkSVGNumberType> values;
29 if (!this->parse(&values)) {
33 kernelUnitLength->
fDx = values[0];
34 kernelUnitLength->
fDy = values.size() > 1 ? values[1] : values[0];
41 switch (child->tag()) {
57 SkDebugf(
"lighting filter effect needs exactly one light source\n");
62 const auto color = this->getLightingColor();
63 if (!
color.isValue()) {
65 SkDebugf(
"unhandled: lighting-color has no value\n");
78 const auto xy =
SkV2{
x,
y} * obbt.scale + obbt.offset;
87 this->setSpecularConstant(
88 SkSVGAttributeParser::parse<SkSVGNumberType>(
"specularConstant", n, v)) ||
89 this->setSpecularExponent(
90 SkSVGAttributeParser::parse<SkSVGNumberType>(
"specularExponent", n, v));
99 this->
resolveXYZ(ctx, fctx, dir.fX, dir.fY, dir.fZ),
100 this->resolveLightingColor(ctx),
101 this->getSurfaceScale(),
104 fctx.
resolveInput(ctx, this->getIn(), this->resolveColorspace(ctx, fctx)),
105 this->resolveFilterSubregion(ctx, fctx));
112 this->
resolveXYZ(ctx, fctx, light->getX(), light->getY(), light->getZ()),
113 this->resolveLightingColor(ctx),
114 this->getSurfaceScale(),
117 fctx.
resolveInput(ctx, this->getIn(), this->resolveColorspace(ctx, fctx)),
118 this->resolveFilterSubregion(ctx, fctx));
124 const auto& limitingConeAngle = light->getLimitingConeAngle();
125 const float cutoffAngle = limitingConeAngle.isValid() ? *limitingConeAngle : 180.f;
128 this->
resolveXYZ(ctx, fctx, light->getX(), light->getY(), light->getZ()),
130 ctx, fctx, light->getPointsAtX(), light->getPointsAtY(), light->getPointsAtZ()),
131 light->getSpecularExponent(),
133 this->resolveLightingColor(ctx),
134 this->getSurfaceScale(),
137 fctx.
resolveInput(ctx, this->getIn(), this->resolveColorspace(ctx, fctx)),
138 this->resolveFilterSubregion(ctx, fctx));
143 this->setDiffuseConstant(
144 SkSVGAttributeParser::parse<SkSVGNumberType>(
"diffuseConstant", n, v));
153 this->
resolveXYZ(ctx, fctx, dir.fX, dir.fY, dir.fZ),
154 this->resolveLightingColor(ctx),
155 this->getSurfaceScale(),
156 this->getDiffuseConstant(),
157 fctx.
resolveInput(ctx, this->getIn(), this->resolveColorspace(ctx, fctx)),
158 this->resolveFilterSubregion(ctx, fctx));
165 this->
resolveXYZ(ctx, fctx, light->getX(), light->getY(), light->getZ()),
166 this->resolveLightingColor(ctx),
167 this->getSurfaceScale(),
168 this->getDiffuseConstant(),
169 fctx.
resolveInput(ctx, this->getIn(), this->resolveColorspace(ctx, fctx)),
170 this->resolveFilterSubregion(ctx, fctx));
176 const auto& limitingConeAngle = light->getLimitingConeAngle();
177 const float cutoffAngle = limitingConeAngle.isValid() ? *limitingConeAngle : 180.f;
180 this->
resolveXYZ(ctx, fctx, light->getX(), light->getY(), light->getZ()),
182 ctx, fctx, light->getPointsAtX(), light->getPointsAtY(), light->getPointsAtZ()),
183 light->getSpecularExponent(),
185 this->resolveLightingColor(ctx),
186 this->getSurfaceScale(),
187 this->getDiffuseConstant(),
188 fctx.
resolveInput(ctx, this->getIn(), this->resolveColorspace(ctx, fctx)),
189 this->resolveFilterSubregion(ctx, fctx));
constexpr SkColor SK_ColorWHITE
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static sk_sp< SkImageFilter > PointLitDiffuse(const SkPoint3 &location, SkColor lightColor, SkScalar surfaceScale, SkScalar kd, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > DistantLitSpecular(const SkPoint3 &direction, SkColor lightColor, SkScalar surfaceScale, SkScalar ks, SkScalar shininess, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > DistantLitDiffuse(const SkPoint3 &direction, SkColor lightColor, SkScalar surfaceScale, SkScalar kd, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > PointLitSpecular(const SkPoint3 &location, SkColor lightColor, SkScalar surfaceScale, SkScalar ks, SkScalar shininess, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > SpotLitDiffuse(const SkPoint3 &location, const SkPoint3 &target, SkScalar falloffExponent, SkScalar cutoffAngle, SkColor lightColor, SkScalar surfaceScale, SkScalar kd, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > SpotLitSpecular(const SkPoint3 &location, const SkPoint3 &target, SkScalar falloffExponent, SkScalar cutoffAngle, SkColor lightColor, SkScalar surfaceScale, SkScalar ks, SkScalar shininess, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
skia_private::STArray< 1, sk_sp< SkSVGNode >, true > fChildren
sk_sp< SkImageFilter > makeDistantLight(const SkSVGRenderContext &, const SkSVGFilterContext &, const SkSVGFeDistantLight *) const final
sk_sp< SkImageFilter > makePointLight(const SkSVGRenderContext &, const SkSVGFilterContext &, const SkSVGFePointLight *) const final
sk_sp< SkImageFilter > makeSpotLight(const SkSVGRenderContext &, const SkSVGFilterContext &, const SkSVGFeSpotLight *) const final
bool parseAndSetAttribute(const char *, const char *) override
SkPoint3 computeDirection() const
virtual sk_sp< SkImageFilter > makePointLight(const SkSVGRenderContext &, const SkSVGFilterContext &, const SkSVGFePointLight *) const =0
bool parseAndSetAttribute(const char *, const char *) override
sk_sp< SkImageFilter > onMakeImageFilter(const SkSVGRenderContext &, const SkSVGFilterContext &) const final
SkPoint3 resolveXYZ(const SkSVGRenderContext &, const SkSVGFilterContext &, SkSVGNumberType, SkSVGNumberType, SkSVGNumberType) const
virtual sk_sp< SkImageFilter > makeDistantLight(const SkSVGRenderContext &, const SkSVGFilterContext &, const SkSVGFeDistantLight *) const =0
SkColor resolveLightingColor(const SkSVGRenderContext &) const
virtual sk_sp< SkImageFilter > makeSpotLight(const SkSVGRenderContext &, const SkSVGFilterContext &, const SkSVGFeSpotLight *) const =0
sk_sp< SkImageFilter > makeSpotLight(const SkSVGRenderContext &, const SkSVGFilterContext &, const SkSVGFeSpotLight *) const final
bool parseAndSetAttribute(const char *, const char *) override
sk_sp< SkImageFilter > makePointLight(const SkSVGRenderContext &, const SkSVGFilterContext &, const SkSVGFePointLight *) const final
sk_sp< SkImageFilter > makeDistantLight(const SkSVGRenderContext &, const SkSVGFilterContext &, const SkSVGFeDistantLight *) const final
bool parseAndSetAttribute(const char *, const char *) override
sk_sp< SkImageFilter > resolveInput(const SkSVGRenderContext &, const SkSVGFeInputType &) const
const SkSVGObjectBoundingBoxUnits & primitiveUnits() const
SkSVGColorType resolveSvgColor(const SkSVGColor &) const
OBBTransform transformForCurrentOBB(SkSVGObjectBoundingBoxUnits) const
static SkPoint3 Make(SkScalar x, SkScalar y, SkScalar z)