summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/svg/svg_fe_light_element.h
blob: 8a4687f5f6df7b35aa205e6c9dae926d64f54cb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
 * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org>
 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
 * Copyright (C) 2005 Oliver Hunt <oliver@nerget.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this library; see the file COPYING.LIB.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_SVG_SVG_FE_LIGHT_ELEMENT_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_SVG_SVG_FE_LIGHT_ELEMENT_H_

#include "third_party/blink/renderer/core/svg/svg_animated_number.h"
#include "third_party/blink/renderer/core/svg/svg_element.h"
#include "third_party/blink/renderer/core/svg_names.h"
#include "third_party/blink/renderer/platform/graphics/filters/light_source.h"
#include "third_party/blink/renderer/platform/heap/handle.h"

namespace blink {

class Filter;

class SVGFELightElement : public SVGElement {
 public:
  virtual scoped_refptr<LightSource> GetLightSource(Filter*) const = 0;
  static SVGFELightElement* FindLightElement(const SVGElement&);

  FloatPoint3D GetPosition() const;
  FloatPoint3D PointsAt() const;

  SVGAnimatedNumber* azimuth() { return azimuth_.Get(); }
  const SVGAnimatedNumber* azimuth() const { return azimuth_.Get(); }
  SVGAnimatedNumber* elevation() { return elevation_.Get(); }
  const SVGAnimatedNumber* elevation() const { return elevation_.Get(); }
  SVGAnimatedNumber* x() { return x_.Get(); }
  const SVGAnimatedNumber* x() const { return x_.Get(); }
  SVGAnimatedNumber* y() { return y_.Get(); }
  const SVGAnimatedNumber* y() const { return y_.Get(); }
  SVGAnimatedNumber* z() { return z_.Get(); }
  const SVGAnimatedNumber* z() const { return z_.Get(); }
  SVGAnimatedNumber* pointsAtX() { return points_at_x_.Get(); }
  const SVGAnimatedNumber* pointsAtX() const { return points_at_x_.Get(); }
  SVGAnimatedNumber* pointsAtY() { return points_at_y_.Get(); }
  const SVGAnimatedNumber* pointsAtY() const { return points_at_y_.Get(); }
  SVGAnimatedNumber* pointsAtZ() { return points_at_z_.Get(); }
  const SVGAnimatedNumber* pointsAtZ() const { return points_at_z_.Get(); }
  SVGAnimatedNumber* specularExponent() { return specular_exponent_.Get(); }
  const SVGAnimatedNumber* specularExponent() const {
    return specular_exponent_.Get();
  }
  SVGAnimatedNumber* limitingConeAngle() { return limiting_cone_angle_.Get(); }
  const SVGAnimatedNumber* limitingConeAngle() const {
    return limiting_cone_angle_.Get();
  }

  void Trace(Visitor*) const override;

 protected:
  SVGFELightElement(const QualifiedName&, Document&);

 private:
  void SvgAttributeChanged(const QualifiedName&) final;
  void ChildrenChanged(const ChildrenChange&) final;

  bool LayoutObjectIsNeeded(const ComputedStyle&) const override {
    return false;
  }

  Member<SVGAnimatedNumber> azimuth_;
  Member<SVGAnimatedNumber> elevation_;
  Member<SVGAnimatedNumber> x_;
  Member<SVGAnimatedNumber> y_;
  Member<SVGAnimatedNumber> z_;
  Member<SVGAnimatedNumber> points_at_x_;
  Member<SVGAnimatedNumber> points_at_y_;
  Member<SVGAnimatedNumber> points_at_z_;
  Member<SVGAnimatedNumber> specular_exponent_;
  Member<SVGAnimatedNumber> limiting_cone_angle_;
};

template <>
inline bool IsElementOfType<const SVGFELightElement>(const Node& node) {
  return IsA<SVGFELightElement>(node);
}
template <>
struct DowncastTraits<SVGFELightElement> {
  static bool AllowFrom(const Node& node) {
    auto* svg_element = DynamicTo<SVGElement>(node);
    return svg_element && AllowFrom(*svg_element);
  }
  static bool AllowFrom(const SVGElement& svg_element) {
    return svg_element.HasTagName(svg_names::kFEDistantLightTag) ||
           svg_element.HasTagName(svg_names::kFEPointLightTag) ||
           svg_element.HasTagName(svg_names::kFESpotLightTag);
  }
};

}  // namespace blink

#endif