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/. */
7 #ifndef DOM_SVG_SVGFEDISPLACEMENTMAPELEMENT_H_
8 #define DOM_SVG_SVGFEDISPLACEMENTMAPELEMENT_H_
10 #include "SVGAnimatedEnumeration.h"
11 #include "mozilla/dom/SVGFilters.h"
13 nsresult
NS_NewSVGFEDisplacementMapElement(
14 nsIContent
** aResult
, already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
);
16 namespace mozilla::dom
{
18 using SVGFEDisplacementMapElementBase
= SVGFilterPrimitiveElement
;
20 class SVGFEDisplacementMapElement final
21 : public SVGFEDisplacementMapElementBase
{
23 friend nsresult(::NS_NewSVGFEDisplacementMapElement(
25 already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
));
26 explicit SVGFEDisplacementMapElement(
27 already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
)
28 : SVGFEDisplacementMapElementBase(std::move(aNodeInfo
)) {}
29 JSObject
* WrapNode(JSContext
* aCx
,
30 JS::Handle
<JSObject
*> aGivenProto
) override
;
33 FilterPrimitiveDescription
GetPrimitiveDescription(
34 SVGFilterInstance
* aInstance
, const IntRect
& aFilterSubregion
,
35 const nsTArray
<bool>& aInputsAreTainted
,
36 nsTArray
<RefPtr
<SourceSurface
>>& aInputImages
) override
;
37 bool AttributeAffectsRendering(int32_t aNameSpaceID
,
38 nsAtom
* aAttribute
) const override
;
39 SVGAnimatedString
& GetResultImageName() override
{
40 return mStringAttributes
[RESULT
];
42 void GetSourceImageNames(nsTArray
<SVGStringInfo
>& aSources
) override
;
44 nsresult
Clone(dom::NodeInfo
*, nsINode
** aResult
) const override
;
46 nsresult
BindToTree(BindContext
& aCtx
, nsINode
& aParent
) override
;
49 already_AddRefed
<DOMSVGAnimatedString
> In1();
50 already_AddRefed
<DOMSVGAnimatedString
> In2();
51 already_AddRefed
<DOMSVGAnimatedNumber
> Scale();
52 already_AddRefed
<DOMSVGAnimatedEnumeration
> XChannelSelector();
53 already_AddRefed
<DOMSVGAnimatedEnumeration
> YChannelSelector();
56 virtual bool OperatesOnSRGB(int32_t aInputIndex
,
57 bool aInputIsAlreadySRGB
) override
{
58 switch (aInputIndex
) {
60 return aInputIsAlreadySRGB
;
62 return SVGFEDisplacementMapElementBase::OperatesOnSRGB(
63 aInputIndex
, aInputIsAlreadySRGB
);
65 NS_ERROR("Will not give correct color model");
70 NumberAttributesInfo
GetNumberInfo() override
;
71 EnumAttributesInfo
GetEnumInfo() override
;
72 StringAttributesInfo
GetStringInfo() override
;
75 SVGAnimatedNumber mNumberAttributes
[1];
76 static NumberInfo sNumberInfo
[1];
78 enum { CHANNEL_X
, CHANNEL_Y
};
79 SVGAnimatedEnumeration mEnumAttributes
[2];
80 static SVGEnumMapping sChannelMap
[];
81 static EnumInfo sEnumInfo
[2];
83 enum { RESULT
, IN1
, IN2
};
84 SVGAnimatedString mStringAttributes
[3];
85 static StringInfo sStringInfo
[3];
88 } // namespace mozilla::dom
90 #endif // DOM_SVG_SVGFEDISPLACEMENTMAPELEMENT_H_