SVGFEDistantLightElement.cpp (2441B)
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/SVGFEDistantLightElement.h" 8 9 #include "mozilla/SVGFilterInstance.h" 10 #include "mozilla/dom/SVGFEDistantLightElementBinding.h" 11 12 NS_IMPL_NS_NEW_SVG_ELEMENT(FEDistantLight) 13 14 using namespace mozilla::gfx; 15 16 namespace mozilla::dom { 17 18 JSObject* SVGFEDistantLightElement::WrapNode( 19 JSContext* aCx, JS::Handle<JSObject*> aGivenProto) { 20 return SVGFEDistantLightElement_Binding::Wrap(aCx, this, aGivenProto); 21 } 22 23 SVGElement::NumberInfo SVGFEDistantLightElement::sNumberInfo[2] = { 24 {nsGkAtoms::azimuth, 0}, {nsGkAtoms::elevation, 0}}; 25 26 //---------------------------------------------------------------------- 27 //---------------------------------------------------------------------- 28 // nsINode methods 29 30 NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFEDistantLightElement) 31 32 // SVGFilterPrimitiveChildElement methods 33 34 bool SVGFEDistantLightElement::AttributeAffectsRendering( 35 int32_t aNameSpaceID, nsAtom* aAttribute) const { 36 return aNameSpaceID == kNameSpaceID_None && 37 (aAttribute == nsGkAtoms::azimuth || 38 aAttribute == nsGkAtoms::elevation); 39 } 40 41 LightType SVGFEDistantLightElement::ComputeLightAttributes( 42 SVGFilterInstance* aInstance, nsTArray<float>& aFloatAttributes) { 43 float azimuth, elevation; 44 GetAnimatedNumberValues(&azimuth, &elevation, nullptr); 45 46 aFloatAttributes.SetLength(kDistantLightNumAttributes); 47 aFloatAttributes[kDistantLightAzimuthIndex] = azimuth; 48 aFloatAttributes[kDistantLightElevationIndex] = elevation; 49 return LightType::Distant; 50 } 51 52 already_AddRefed<DOMSVGAnimatedNumber> SVGFEDistantLightElement::Azimuth() { 53 return mNumberAttributes[AZIMUTH].ToDOMAnimatedNumber(this); 54 } 55 56 already_AddRefed<DOMSVGAnimatedNumber> SVGFEDistantLightElement::Elevation() { 57 return mNumberAttributes[ELEVATION].ToDOMAnimatedNumber(this); 58 } 59 60 //---------------------------------------------------------------------- 61 // SVGElement methods 62 63 SVGElement::NumberAttributesInfo SVGFEDistantLightElement::GetNumberInfo() { 64 return NumberAttributesInfo(mNumberAttributes, sNumberInfo, 65 std::size(sNumberInfo)); 66 } 67 68 } // namespace mozilla::dom