/src/mozilla-central/dom/svg/SVGFEGaussianBlurElement.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/SVGFEGaussianBlurElement.h" |
8 | | #include "mozilla/dom/SVGFEGaussianBlurElementBinding.h" |
9 | | #include "nsSVGFilterInstance.h" |
10 | | #include "nsSVGUtils.h" |
11 | | |
12 | | NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FEGaussianBlur) |
13 | | |
14 | | using namespace mozilla::gfx; |
15 | | |
16 | | namespace mozilla { |
17 | | namespace dom { |
18 | | |
19 | | JSObject* |
20 | | SVGFEGaussianBlurElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) |
21 | 0 | { |
22 | 0 | return SVGFEGaussianBlurElement_Binding::Wrap(aCx, this, aGivenProto); |
23 | 0 | } |
24 | | |
25 | | nsSVGElement::NumberPairInfo SVGFEGaussianBlurElement::sNumberPairInfo[1] = |
26 | | { |
27 | | { &nsGkAtoms::stdDeviation, 0, 0 } |
28 | | }; |
29 | | |
30 | | nsSVGElement::StringInfo SVGFEGaussianBlurElement::sStringInfo[2] = |
31 | | { |
32 | | { &nsGkAtoms::result, kNameSpaceID_None, true }, |
33 | | { &nsGkAtoms::in, kNameSpaceID_None, true } |
34 | | }; |
35 | | |
36 | | //---------------------------------------------------------------------- |
37 | | // nsINode methods |
38 | | |
39 | | NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFEGaussianBlurElement) |
40 | | |
41 | | //---------------------------------------------------------------------- |
42 | | |
43 | | already_AddRefed<SVGAnimatedString> |
44 | | SVGFEGaussianBlurElement::In1() |
45 | 0 | { |
46 | 0 | return mStringAttributes[IN1].ToDOMAnimatedString(this); |
47 | 0 | } |
48 | | |
49 | | already_AddRefed<SVGAnimatedNumber> |
50 | | SVGFEGaussianBlurElement::StdDeviationX() |
51 | 0 | { |
52 | 0 | return mNumberPairAttributes[STD_DEV].ToDOMAnimatedNumber(nsSVGNumberPair::eFirst, this); |
53 | 0 | } |
54 | | |
55 | | already_AddRefed<SVGAnimatedNumber> |
56 | | SVGFEGaussianBlurElement::StdDeviationY() |
57 | 0 | { |
58 | 0 | return mNumberPairAttributes[STD_DEV].ToDOMAnimatedNumber(nsSVGNumberPair::eSecond, this); |
59 | 0 | } |
60 | | |
61 | | void |
62 | | SVGFEGaussianBlurElement::SetStdDeviation(float stdDeviationX, float stdDeviationY) |
63 | 0 | { |
64 | 0 | mNumberPairAttributes[STD_DEV].SetBaseValues(stdDeviationX, stdDeviationY, this); |
65 | 0 | } |
66 | | |
67 | | FilterPrimitiveDescription |
68 | | SVGFEGaussianBlurElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance, |
69 | | const IntRect& aFilterSubregion, |
70 | | const nsTArray<bool>& aInputsAreTainted, |
71 | | nsTArray<RefPtr<SourceSurface>>& aInputImages) |
72 | 0 | { |
73 | 0 | float stdX = aInstance->GetPrimitiveNumber(SVGContentUtils::X, |
74 | 0 | &mNumberPairAttributes[STD_DEV], |
75 | 0 | nsSVGNumberPair::eFirst); |
76 | 0 | float stdY = aInstance->GetPrimitiveNumber(SVGContentUtils::Y, |
77 | 0 | &mNumberPairAttributes[STD_DEV], |
78 | 0 | nsSVGNumberPair::eSecond); |
79 | 0 | if (stdX < 0 || stdY < 0) { |
80 | 0 | return FilterPrimitiveDescription(); |
81 | 0 | } |
82 | 0 | |
83 | 0 | GaussianBlurAttributes atts; |
84 | 0 | atts.mStdDeviation = Size(stdX, stdY); |
85 | 0 | return FilterPrimitiveDescription(AsVariant(std::move(atts))); |
86 | 0 | } |
87 | | |
88 | | bool |
89 | | SVGFEGaussianBlurElement::AttributeAffectsRendering(int32_t aNameSpaceID, |
90 | | nsAtom* aAttribute) const |
91 | 0 | { |
92 | 0 | return SVGFEGaussianBlurElementBase::AttributeAffectsRendering(aNameSpaceID, aAttribute) || |
93 | 0 | (aNameSpaceID == kNameSpaceID_None && |
94 | 0 | (aAttribute == nsGkAtoms::in || |
95 | 0 | aAttribute == nsGkAtoms::stdDeviation)); |
96 | 0 | } |
97 | | |
98 | | void |
99 | | SVGFEGaussianBlurElement::GetSourceImageNames(nsTArray<nsSVGStringInfo>& aSources) |
100 | 0 | { |
101 | 0 | aSources.AppendElement(nsSVGStringInfo(&mStringAttributes[IN1], this)); |
102 | 0 | } |
103 | | |
104 | | //---------------------------------------------------------------------- |
105 | | // nsSVGElement methods |
106 | | |
107 | | nsSVGElement::NumberPairAttributesInfo |
108 | | SVGFEGaussianBlurElement::GetNumberPairInfo() |
109 | 0 | { |
110 | 0 | return NumberPairAttributesInfo(mNumberPairAttributes, sNumberPairInfo, |
111 | 0 | ArrayLength(sNumberPairInfo)); |
112 | 0 | } |
113 | | |
114 | | nsSVGElement::StringAttributesInfo |
115 | | SVGFEGaussianBlurElement::GetStringInfo() |
116 | 0 | { |
117 | 0 | return StringAttributesInfo(mStringAttributes, sStringInfo, |
118 | 0 | ArrayLength(sStringInfo)); |
119 | 0 | } |
120 | | |
121 | | } // namespace dom |
122 | | } // namespace mozilla |