skia2/modules/svg/include/SkSVGFeLightSource.h
Tyler Denniston 32b3089618 [svg] Add light source classes and lighting-color pres attr
https://www.w3.org/TR/SVG11/filters.html#LightSourceDefinitions

The three classes represent light source elements that will eventually
be used for feSpecularLighting and feDiffuseLighting. Currently they are
unused.

Also added the (currently unused) lighting-color presentation attribute.

Bug: skia:10841
Change-Id: Ic7824671662b8cd88cf627affc54173d5e881b7d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/359557
Commit-Queue: Tyler Denniston <tdenniston@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2021-01-26 21:36:34 +00:00

87 lines
2.4 KiB
C++

/*
* Copyright 2021 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkSVGFeLightSource_DEFINED
#define SkSVGFeLightSource_DEFINED
#include "modules/svg/include/SkSVGHiddenContainer.h"
#include "modules/svg/include/SkSVGTypes.h"
class SkSVGFeLightSource : public SkSVGHiddenContainer {
public:
void appendChild(sk_sp<SkSVGNode>) final {
SkDebugf("cannot append child nodes to an SVG light source.\n");
}
protected:
explicit SkSVGFeLightSource(SkSVGTag tag) : INHERITED(tag) {}
private:
using INHERITED = SkSVGHiddenContainer;
};
class SkSVGFeDistantLight final : public SkSVGFeLightSource {
public:
static sk_sp<SkSVGFeDistantLight> Make() {
return sk_sp<SkSVGFeDistantLight>(new SkSVGFeDistantLight());
}
SVG_ATTR(Azimuth , SkSVGNumberType, 0)
SVG_ATTR(Elevation, SkSVGNumberType, 0)
private:
SkSVGFeDistantLight() : INHERITED(SkSVGTag::kFeDistantLight) {}
bool parseAndSetAttribute(const char*, const char*) override;
using INHERITED = SkSVGFeLightSource;
};
class SkSVGFePointLight final : public SkSVGFeLightSource {
public:
static sk_sp<SkSVGFePointLight> Make() {
return sk_sp<SkSVGFePointLight>(new SkSVGFePointLight());
}
SVG_ATTR(X, SkSVGNumberType, 0)
SVG_ATTR(Y, SkSVGNumberType, 0)
SVG_ATTR(Z, SkSVGNumberType, 0)
private:
SkSVGFePointLight() : INHERITED(SkSVGTag::kFePointLight) {}
bool parseAndSetAttribute(const char*, const char*) override;
using INHERITED = SkSVGFeLightSource;
};
class SkSVGFeSpotLight final : public SkSVGFeLightSource {
public:
static sk_sp<SkSVGFeSpotLight> Make() {
return sk_sp<SkSVGFeSpotLight>(new SkSVGFeSpotLight());
}
SVG_ATTR(X , SkSVGNumberType, 0)
SVG_ATTR(Y , SkSVGNumberType, 0)
SVG_ATTR(Z , SkSVGNumberType, 0)
SVG_ATTR(PointsAtX , SkSVGNumberType, 0)
SVG_ATTR(PointsAtY , SkSVGNumberType, 0)
SVG_ATTR(PointsAtZ , SkSVGNumberType, 0)
SVG_ATTR(SpecularExponent, SkSVGNumberType, 1)
SVG_OPTIONAL_ATTR(LimitingConeAngle, SkSVGNumberType)
private:
SkSVGFeSpotLight() : INHERITED(SkSVGTag::kFeSpotLight) {}
bool parseAndSetAttribute(const char*, const char*) override;
using INHERITED = SkSVGFeLightSource;
};
#endif // SkSVGFeLightSource_DEFINED