1/*
2 * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
4 * Copyright (C) 2005 Oliver Hunt <oliver@nerget.com>
5 * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
16 *
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
21 */
22
23#pragma once
24
25#include "LightSource.h"
26#include "SVGElement.h"
27
28namespace WebCore {
29
30class SVGFilterBuilder;
31
32class SVGFELightElement : public SVGElement {
33 WTF_MAKE_ISO_ALLOCATED(SVGFELightElement);
34public:
35 virtual Ref<LightSource> lightSource(SVGFilterBuilder&) const = 0;
36 static SVGFELightElement* findLightElement(const SVGElement*);
37
38 float azimuth() const { return m_azimuth->currentValue(); }
39 float elevation() const { return m_elevation->currentValue(); }
40 float x() const { return m_x->currentValue(); }
41 float y() const { return m_y->currentValue(); }
42 float z() const { return m_z->currentValue(); }
43 float pointsAtX() const { return m_pointsAtX->currentValue(); }
44 float pointsAtY() const { return m_pointsAtY->currentValue(); }
45 float pointsAtZ() const { return m_pointsAtZ->currentValue(); }
46 float specularExponent() const { return m_specularExponent->currentValue(); }
47 float limitingConeAngle() const { return m_limitingConeAngle->currentValue(); }
48
49 SVGAnimatedNumber& azimuthAnimated() { return m_azimuth; }
50 SVGAnimatedNumber& elevationAnimated() { return m_elevation; }
51 SVGAnimatedNumber& xAnimated() { return m_x; }
52 SVGAnimatedNumber& yAnimated() { return m_y; }
53 SVGAnimatedNumber& zAnimated() { return m_z; }
54 SVGAnimatedNumber& pointsAtXAnimated() { return m_pointsAtX; }
55 SVGAnimatedNumber& pointsAtYAnimated() { return m_pointsAtY; }
56 SVGAnimatedNumber& pointsAtZAnimated() { return m_pointsAtZ; }
57 SVGAnimatedNumber& specularExponentAnimated() { return m_specularExponent; }
58 SVGAnimatedNumber& limitingConeAngleAnimated() { return m_limitingConeAngle; }
59
60protected:
61 SVGFELightElement(const QualifiedName&, Document&);
62
63 bool rendererIsNeeded(const RenderStyle&) override { return false; }
64
65private:
66 using PropertyRegistry = SVGPropertyOwnerRegistry<SVGFELightElement, SVGElement>;
67 const SVGPropertyRegistry& propertyRegistry() const final { return m_propertyRegistry; }
68
69 void parseAttribute(const QualifiedName&, const AtomicString&) override;
70 void svgAttributeChanged(const QualifiedName&) override;
71 void childrenChanged(const ChildChange&) override;
72
73 PropertyRegistry m_propertyRegistry { *this };
74 Ref<SVGAnimatedNumber> m_azimuth { SVGAnimatedNumber::create(this) };
75 Ref<SVGAnimatedNumber> m_elevation { SVGAnimatedNumber::create(this) };
76 Ref<SVGAnimatedNumber> m_x { SVGAnimatedNumber::create(this) };
77 Ref<SVGAnimatedNumber> m_y { SVGAnimatedNumber::create(this) };
78 Ref<SVGAnimatedNumber> m_z { SVGAnimatedNumber::create(this) };
79 Ref<SVGAnimatedNumber> m_pointsAtX { SVGAnimatedNumber::create(this) };
80 Ref<SVGAnimatedNumber> m_pointsAtY { SVGAnimatedNumber::create(this) };
81 Ref<SVGAnimatedNumber> m_pointsAtZ { SVGAnimatedNumber::create(this) };
82 Ref<SVGAnimatedNumber> m_specularExponent { SVGAnimatedNumber::create(this, 1) };
83 Ref<SVGAnimatedNumber> m_limitingConeAngle { SVGAnimatedNumber::create(this) };
84};
85
86} // namespace WebCore
87