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 #include "mozilla/dom/SVGFEComponentTransferElement.h"
9 #include "mozilla/dom/SVGComponentTransferFunctionElement.h"
10 #include "mozilla/dom/SVGFEComponentTransferElementBinding.h"
11 #include "mozilla/gfx/2D.h"
13 NS_IMPL_NS_NEW_SVG_ELEMENT(FEComponentTransfer
)
15 using namespace mozilla::gfx
;
21 JSObject
* SVGFEComponentTransferElement::WrapNode(
22 JSContext
* aCx
, JS::Handle
<JSObject
*> aGivenProto
) {
23 return SVGFEComponentTransferElement_Binding::Wrap(aCx
, this, aGivenProto
);
26 SVGElement::StringInfo
SVGFEComponentTransferElement::sStringInfo
[2] = {
27 {nsGkAtoms::result
, kNameSpaceID_None
, true},
28 {nsGkAtoms::in
, kNameSpaceID_None
, true}};
30 //----------------------------------------------------------------------
33 NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFEComponentTransferElement
)
35 already_AddRefed
<DOMSVGAnimatedString
> SVGFEComponentTransferElement::In1() {
36 return mStringAttributes
[IN1
].ToDOMAnimatedString(this);
39 //----------------------------------------------------------------------
42 SVGElement::StringAttributesInfo
43 SVGFEComponentTransferElement::GetStringInfo() {
44 return StringAttributesInfo(mStringAttributes
, sStringInfo
,
45 ArrayLength(sStringInfo
));
48 //--------------------------------------------
50 FilterPrimitiveDescription
51 SVGFEComponentTransferElement::GetPrimitiveDescription(
52 SVGFilterInstance
* aInstance
, const IntRect
& aFilterSubregion
,
53 const nsTArray
<bool>& aInputsAreTainted
,
54 nsTArray
<RefPtr
<SourceSurface
>>& aInputImages
) {
55 RefPtr
<SVGComponentTransferFunctionElement
> childForChannel
[4];
57 for (nsIContent
* childContent
= nsINode::GetFirstChild(); childContent
;
58 childContent
= childContent
->GetNextSibling()) {
59 RefPtr
<SVGComponentTransferFunctionElement
> child
;
62 (SVGComponentTransferFunctionElement
**)getter_AddRefs(child
));
64 childForChannel
[child
->GetChannel()] = child
;
68 ComponentTransferAttributes atts
;
69 for (int32_t i
= 0; i
< 4; i
++) {
70 if (childForChannel
[i
]) {
71 childForChannel
[i
]->ComputeAttributes(i
, atts
);
73 atts
.mTypes
[i
] = (uint8_t)SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY
;
76 return FilterPrimitiveDescription(AsVariant(std::move(atts
)));
79 bool SVGFEComponentTransferElement::AttributeAffectsRendering(
80 int32_t aNameSpaceID
, nsAtom
* aAttribute
) const {
81 return SVGFEComponentTransferElementBase::AttributeAffectsRendering(
82 aNameSpaceID
, aAttribute
) ||
83 (aNameSpaceID
== kNameSpaceID_None
&& aAttribute
== nsGkAtoms::in
);
86 void SVGFEComponentTransferElement::GetSourceImageNames(
87 nsTArray
<SVGStringInfo
>& aSources
) {
88 aSources
.AppendElement(SVGStringInfo(&mStringAttributes
[IN1
], this));
92 } // namespace mozilla