/src/mozilla-central/dom/svg/SVGFESpecularLightingElement.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #include "mozilla/dom/SVGFESpecularLightingElement.h" |
8 | | #include "mozilla/dom/SVGFESpecularLightingElementBinding.h" |
9 | | #include "nsSVGUtils.h" |
10 | | #include "nsSVGFilterInstance.h" |
11 | | |
12 | | NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FESpecularLighting) |
13 | | |
14 | | using namespace mozilla::gfx; |
15 | | |
16 | | namespace mozilla { |
17 | | namespace dom { |
18 | | |
19 | | JSObject* |
20 | | SVGFESpecularLightingElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) |
21 | 0 | { |
22 | 0 | return SVGFESpecularLightingElement_Binding::Wrap(aCx, this, aGivenProto); |
23 | 0 | } |
24 | | |
25 | | //---------------------------------------------------------------------- |
26 | | // nsINode methods |
27 | | |
28 | | NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFESpecularLightingElement) |
29 | | |
30 | | already_AddRefed<SVGAnimatedString> |
31 | | SVGFESpecularLightingElement::In1() |
32 | 0 | { |
33 | 0 | return mStringAttributes[IN1].ToDOMAnimatedString(this); |
34 | 0 | } |
35 | | |
36 | | already_AddRefed<SVGAnimatedNumber> |
37 | | SVGFESpecularLightingElement::SurfaceScale() |
38 | 0 | { |
39 | 0 | return mNumberAttributes[SURFACE_SCALE].ToDOMAnimatedNumber(this); |
40 | 0 | } |
41 | | |
42 | | already_AddRefed<SVGAnimatedNumber> |
43 | | SVGFESpecularLightingElement::SpecularConstant() |
44 | 0 | { |
45 | 0 | return mNumberAttributes[SPECULAR_CONSTANT].ToDOMAnimatedNumber(this); |
46 | 0 | } |
47 | | |
48 | | already_AddRefed<SVGAnimatedNumber> |
49 | | SVGFESpecularLightingElement::SpecularExponent() |
50 | 0 | { |
51 | 0 | return mNumberAttributes[SPECULAR_EXPONENT].ToDOMAnimatedNumber(this); |
52 | 0 | } |
53 | | |
54 | | already_AddRefed<SVGAnimatedNumber> |
55 | | SVGFESpecularLightingElement::KernelUnitLengthX() |
56 | 0 | { |
57 | 0 | return mNumberPairAttributes[KERNEL_UNIT_LENGTH].ToDOMAnimatedNumber( |
58 | 0 | nsSVGNumberPair::eFirst, this); |
59 | 0 | } |
60 | | |
61 | | already_AddRefed<SVGAnimatedNumber> |
62 | | SVGFESpecularLightingElement::KernelUnitLengthY() |
63 | 0 | { |
64 | 0 | return mNumberPairAttributes[KERNEL_UNIT_LENGTH].ToDOMAnimatedNumber( |
65 | 0 | nsSVGNumberPair::eSecond, this); |
66 | 0 | } |
67 | | |
68 | | //---------------------------------------------------------------------- |
69 | | // nsSVGElement methods |
70 | | |
71 | | FilterPrimitiveDescription |
72 | | SVGFESpecularLightingElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance, |
73 | | const IntRect& aFilterSubregion, |
74 | | const nsTArray<bool>& aInputsAreTainted, |
75 | | nsTArray<RefPtr<SourceSurface>>& aInputImages) |
76 | 0 | { |
77 | 0 | float specularExponent = mNumberAttributes[SPECULAR_EXPONENT].GetAnimValue(); |
78 | 0 | float specularConstant = mNumberAttributes[SPECULAR_CONSTANT].GetAnimValue(); |
79 | 0 |
|
80 | 0 | // specification defined range (15.22) |
81 | 0 | if (specularExponent < 1 || specularExponent > 128) { |
82 | 0 | return FilterPrimitiveDescription(); |
83 | 0 | } |
84 | 0 | |
85 | 0 | SpecularLightingAttributes atts; |
86 | 0 | atts.mLightingConstant = specularConstant; |
87 | 0 | atts.mSpecularExponent = specularExponent; |
88 | 0 | if (!AddLightingAttributes(static_cast<DiffuseLightingAttributes*>(&atts), aInstance)) { |
89 | 0 | return FilterPrimitiveDescription(); |
90 | 0 | } |
91 | 0 | |
92 | 0 | return FilterPrimitiveDescription(AsVariant(std::move(atts))); |
93 | 0 | } |
94 | | |
95 | | bool |
96 | | SVGFESpecularLightingElement::AttributeAffectsRendering(int32_t aNameSpaceID, |
97 | | nsAtom* aAttribute) const |
98 | 0 | { |
99 | 0 | return SVGFESpecularLightingElementBase::AttributeAffectsRendering(aNameSpaceID, aAttribute) || |
100 | 0 | (aNameSpaceID == kNameSpaceID_None && |
101 | 0 | (aAttribute == nsGkAtoms::specularConstant || |
102 | 0 | aAttribute == nsGkAtoms::specularExponent)); |
103 | 0 | } |
104 | | |
105 | | } // namespace dom |
106 | | } // namespace mozilla |