mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 847120: Move SVGFEDiffuseLightingElement to its own file r=Ms2ger
--HG-- rename : content/svg/content/src/nsSVGFilters.cpp => content/svg/content/src/SVGFEDiffuseLightingElement.cpp rename : content/svg/content/src/nsSVGFilters.cpp => content/svg/content/src/SVGFEDiffuseLightingElement.h
This commit is contained in:
parent
f7262b7a39
commit
e338c35b8f
@ -81,6 +81,7 @@ CPPSRCS = \
|
|||||||
SVGFEColorMatrixElement.cpp \
|
SVGFEColorMatrixElement.cpp \
|
||||||
SVGFEComponentTransferElement.cpp \
|
SVGFEComponentTransferElement.cpp \
|
||||||
SVGFECompositeElement.cpp \
|
SVGFECompositeElement.cpp \
|
||||||
|
SVGFEDiffuseLightingElement.cpp \
|
||||||
SVGFEDistantLightElement.cpp \
|
SVGFEDistantLightElement.cpp \
|
||||||
SVGFEFloodElement.cpp \
|
SVGFEFloodElement.cpp \
|
||||||
SVGFEGaussianBlurElement.cpp \
|
SVGFEGaussianBlurElement.cpp \
|
||||||
@ -190,6 +191,7 @@ EXPORTS_mozilla/dom = \
|
|||||||
SVGFEColorMatrixElement.h \
|
SVGFEColorMatrixElement.h \
|
||||||
SVGFEComponentTransferElement.h \
|
SVGFEComponentTransferElement.h \
|
||||||
SVGFECompositeElement.h \
|
SVGFECompositeElement.h \
|
||||||
|
SVGFEDiffuseLightingElement.h \
|
||||||
SVGFEDistantLightElement.h \
|
SVGFEDistantLightElement.h \
|
||||||
SVGFEFloodElement.h \
|
SVGFEFloodElement.h \
|
||||||
SVGFEGaussianBlurElement.h \
|
SVGFEGaussianBlurElement.h \
|
||||||
|
104
content/svg/content/src/SVGFEDiffuseLightingElement.cpp
Normal file
104
content/svg/content/src/SVGFEDiffuseLightingElement.cpp
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
/* a*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
#include "mozilla/dom/SVGFEDiffuseLightingElement.h"
|
||||||
|
|
||||||
|
NS_IMPL_NS_NEW_SVG_ELEMENT(FEDiffuseLighting)
|
||||||
|
|
||||||
|
namespace mozilla {
|
||||||
|
namespace dom {
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
// nsISupports methods
|
||||||
|
|
||||||
|
NS_IMPL_ADDREF_INHERITED(nsSVGFEDiffuseLightingElement,nsSVGFEDiffuseLightingElementBase)
|
||||||
|
NS_IMPL_RELEASE_INHERITED(nsSVGFEDiffuseLightingElement,nsSVGFEDiffuseLightingElementBase)
|
||||||
|
|
||||||
|
DOMCI_NODE_DATA(SVGFEDiffuseLightingElement, nsSVGFEDiffuseLightingElement)
|
||||||
|
|
||||||
|
NS_INTERFACE_TABLE_HEAD(nsSVGFEDiffuseLightingElement)
|
||||||
|
NS_NODE_INTERFACE_TABLE5(nsSVGFEDiffuseLightingElement, nsIDOMNode,
|
||||||
|
nsIDOMElement, nsIDOMSVGElement,
|
||||||
|
nsIDOMSVGFilterPrimitiveStandardAttributes,
|
||||||
|
nsIDOMSVGFEDiffuseLightingElement)
|
||||||
|
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGFEDiffuseLightingElement)
|
||||||
|
NS_INTERFACE_MAP_END_INHERITING(nsSVGFEDiffuseLightingElementBase)
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
// nsIDOMNode methods
|
||||||
|
|
||||||
|
NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFEDiffuseLightingElement)
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
// nsSVGFEDiffuseLightingElement methods
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsSVGFEDiffuseLightingElement::GetIn1(nsIDOMSVGAnimatedString * *aIn)
|
||||||
|
{
|
||||||
|
return mStringAttributes[IN1].ToDOMAnimatedString(aIn, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsSVGFEDiffuseLightingElement::GetSurfaceScale(nsIDOMSVGAnimatedNumber **aScale)
|
||||||
|
{
|
||||||
|
return mNumberAttributes[SURFACE_SCALE].ToDOMAnimatedNumber(aScale,
|
||||||
|
this);
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsSVGFEDiffuseLightingElement::GetDiffuseConstant(nsIDOMSVGAnimatedNumber **aConstant)
|
||||||
|
{
|
||||||
|
return mNumberAttributes[DIFFUSE_CONSTANT].ToDOMAnimatedNumber(aConstant,
|
||||||
|
this);
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsSVGFEDiffuseLightingElement::GetKernelUnitLengthX(nsIDOMSVGAnimatedNumber **aKernelX)
|
||||||
|
{
|
||||||
|
return mNumberPairAttributes[KERNEL_UNIT_LENGTH].ToDOMAnimatedNumber(aKernelX,
|
||||||
|
nsSVGNumberPair::eFirst,
|
||||||
|
this);
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsSVGFEDiffuseLightingElement::GetKernelUnitLengthY(nsIDOMSVGAnimatedNumber **aKernelY)
|
||||||
|
{
|
||||||
|
return mNumberPairAttributes[KERNEL_UNIT_LENGTH].ToDOMAnimatedNumber(aKernelY,
|
||||||
|
nsSVGNumberPair::eSecond,
|
||||||
|
this);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
nsSVGFEDiffuseLightingElement::AttributeAffectsRendering(int32_t aNameSpaceID,
|
||||||
|
nsIAtom* aAttribute) const
|
||||||
|
{
|
||||||
|
return nsSVGFEDiffuseLightingElementBase::AttributeAffectsRendering(aNameSpaceID, aAttribute) ||
|
||||||
|
(aNameSpaceID == kNameSpaceID_None &&
|
||||||
|
aAttribute == nsGkAtoms::diffuseConstant);
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
// nsSVGElement methods
|
||||||
|
|
||||||
|
void
|
||||||
|
nsSVGFEDiffuseLightingElement::LightPixel(const float *N, const float *L,
|
||||||
|
nscolor color, uint8_t *targetData)
|
||||||
|
{
|
||||||
|
float diffuseNL =
|
||||||
|
mNumberAttributes[DIFFUSE_CONSTANT].GetAnimValue() * DOT(N, L);
|
||||||
|
|
||||||
|
if (diffuseNL < 0) diffuseNL = 0;
|
||||||
|
|
||||||
|
targetData[GFX_ARGB32_OFFSET_B] =
|
||||||
|
std::min(uint32_t(diffuseNL * NS_GET_B(color)), 255U);
|
||||||
|
targetData[GFX_ARGB32_OFFSET_G] =
|
||||||
|
std::min(uint32_t(diffuseNL * NS_GET_G(color)), 255U);
|
||||||
|
targetData[GFX_ARGB32_OFFSET_R] =
|
||||||
|
std::min(uint32_t(diffuseNL * NS_GET_R(color)), 255U);
|
||||||
|
targetData[GFX_ARGB32_OFFSET_A] = 255;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace dom
|
||||||
|
} // namespace mozilla
|
54
content/svg/content/src/SVGFEDiffuseLightingElement.h
Normal file
54
content/svg/content/src/SVGFEDiffuseLightingElement.h
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/* a*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
#ifndef mozilla_dom_SVGFEDiffuseLightingElement_h
|
||||||
|
#define mozilla_dom_SVGFEDiffuseLightingElement_h
|
||||||
|
|
||||||
|
#include "nsSVGFilters.h"
|
||||||
|
|
||||||
|
namespace mozilla {
|
||||||
|
namespace dom {
|
||||||
|
|
||||||
|
typedef nsSVGFELightingElement nsSVGFEDiffuseLightingElementBase;
|
||||||
|
|
||||||
|
class nsSVGFEDiffuseLightingElement : public nsSVGFEDiffuseLightingElementBase,
|
||||||
|
public nsIDOMSVGFEDiffuseLightingElement
|
||||||
|
{
|
||||||
|
friend nsresult NS_NewSVGFEDiffuseLightingElement(nsIContent **aResult,
|
||||||
|
already_AddRefed<nsINodeInfo> aNodeInfo);
|
||||||
|
protected:
|
||||||
|
nsSVGFEDiffuseLightingElement(already_AddRefed<nsINodeInfo> aNodeInfo)
|
||||||
|
: nsSVGFEDiffuseLightingElementBase(aNodeInfo) {}
|
||||||
|
|
||||||
|
public:
|
||||||
|
// interfaces:
|
||||||
|
NS_DECL_ISUPPORTS_INHERITED
|
||||||
|
|
||||||
|
// DiffuseLighting
|
||||||
|
NS_DECL_NSIDOMSVGFEDIFFUSELIGHTINGELEMENT
|
||||||
|
|
||||||
|
NS_FORWARD_NSIDOMSVGFILTERPRIMITIVESTANDARDATTRIBUTES(nsSVGFEDiffuseLightingElementBase::)
|
||||||
|
NS_FORWARD_NSIDOMSVGELEMENT(nsSVGFEDiffuseLightingElementBase::)
|
||||||
|
NS_FORWARD_NSIDOMNODE_TO_NSINODE
|
||||||
|
NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
|
||||||
|
|
||||||
|
virtual bool AttributeAffectsRendering(
|
||||||
|
int32_t aNameSpaceID, nsIAtom* aAttribute) const;
|
||||||
|
|
||||||
|
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
|
||||||
|
|
||||||
|
virtual nsXPCClassInfo* GetClassInfo();
|
||||||
|
|
||||||
|
virtual nsIDOMNode* AsDOMNode() { return this; }
|
||||||
|
protected:
|
||||||
|
virtual void LightPixel(const float *N, const float *L,
|
||||||
|
nscolor color, uint8_t *targetData);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dom
|
||||||
|
} // namespace mozilla
|
||||||
|
|
||||||
|
#endif // mozilla_dom_SVGFEDiffuseLightingElement_h
|
@ -2390,137 +2390,6 @@ nsSVGFELightingElement::GetStringInfo()
|
|||||||
ArrayLength(sStringInfo));
|
ArrayLength(sStringInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------DiffuseLighting------------------------
|
|
||||||
|
|
||||||
typedef nsSVGFELightingElement nsSVGFEDiffuseLightingElementBase;
|
|
||||||
|
|
||||||
class nsSVGFEDiffuseLightingElement : public nsSVGFEDiffuseLightingElementBase,
|
|
||||||
public nsIDOMSVGFEDiffuseLightingElement
|
|
||||||
{
|
|
||||||
friend nsresult NS_NewSVGFEDiffuseLightingElement(nsIContent **aResult,
|
|
||||||
already_AddRefed<nsINodeInfo> aNodeInfo);
|
|
||||||
protected:
|
|
||||||
nsSVGFEDiffuseLightingElement(already_AddRefed<nsINodeInfo> aNodeInfo)
|
|
||||||
: nsSVGFEDiffuseLightingElementBase(aNodeInfo) {}
|
|
||||||
|
|
||||||
public:
|
|
||||||
// interfaces:
|
|
||||||
NS_DECL_ISUPPORTS_INHERITED
|
|
||||||
|
|
||||||
// DiffuseLighting
|
|
||||||
NS_DECL_NSIDOMSVGFEDIFFUSELIGHTINGELEMENT
|
|
||||||
|
|
||||||
NS_FORWARD_NSIDOMSVGFILTERPRIMITIVESTANDARDATTRIBUTES(nsSVGFEDiffuseLightingElementBase::)
|
|
||||||
NS_FORWARD_NSIDOMSVGELEMENT(nsSVGFEDiffuseLightingElementBase::)
|
|
||||||
NS_FORWARD_NSIDOMNODE_TO_NSINODE
|
|
||||||
NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
|
|
||||||
|
|
||||||
virtual bool AttributeAffectsRendering(
|
|
||||||
int32_t aNameSpaceID, nsIAtom* aAttribute) const;
|
|
||||||
|
|
||||||
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
|
|
||||||
|
|
||||||
virtual nsXPCClassInfo* GetClassInfo();
|
|
||||||
|
|
||||||
virtual nsIDOMNode* AsDOMNode() { return this; }
|
|
||||||
protected:
|
|
||||||
virtual void LightPixel(const float *N, const float *L,
|
|
||||||
nscolor color, uint8_t *targetData);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
NS_IMPL_NS_NEW_SVG_ELEMENT(FEDiffuseLighting)
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
// nsISupports methods
|
|
||||||
|
|
||||||
NS_IMPL_ADDREF_INHERITED(nsSVGFEDiffuseLightingElement,nsSVGFEDiffuseLightingElementBase)
|
|
||||||
NS_IMPL_RELEASE_INHERITED(nsSVGFEDiffuseLightingElement,nsSVGFEDiffuseLightingElementBase)
|
|
||||||
|
|
||||||
DOMCI_NODE_DATA(SVGFEDiffuseLightingElement, nsSVGFEDiffuseLightingElement)
|
|
||||||
|
|
||||||
NS_INTERFACE_TABLE_HEAD(nsSVGFEDiffuseLightingElement)
|
|
||||||
NS_NODE_INTERFACE_TABLE5(nsSVGFEDiffuseLightingElement, nsIDOMNode,
|
|
||||||
nsIDOMElement, nsIDOMSVGElement,
|
|
||||||
nsIDOMSVGFilterPrimitiveStandardAttributes,
|
|
||||||
nsIDOMSVGFEDiffuseLightingElement)
|
|
||||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGFEDiffuseLightingElement)
|
|
||||||
NS_INTERFACE_MAP_END_INHERITING(nsSVGFEDiffuseLightingElementBase)
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
// nsIDOMNode methods
|
|
||||||
|
|
||||||
NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFEDiffuseLightingElement)
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
// nsSVGFEDiffuseLightingElement methods
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsSVGFEDiffuseLightingElement::GetIn1(nsIDOMSVGAnimatedString * *aIn)
|
|
||||||
{
|
|
||||||
return mStringAttributes[IN1].ToDOMAnimatedString(aIn, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsSVGFEDiffuseLightingElement::GetSurfaceScale(nsIDOMSVGAnimatedNumber **aScale)
|
|
||||||
{
|
|
||||||
return mNumberAttributes[SURFACE_SCALE].ToDOMAnimatedNumber(aScale,
|
|
||||||
this);
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsSVGFEDiffuseLightingElement::GetDiffuseConstant(nsIDOMSVGAnimatedNumber **aConstant)
|
|
||||||
{
|
|
||||||
return mNumberAttributes[DIFFUSE_CONSTANT].ToDOMAnimatedNumber(aConstant,
|
|
||||||
this);
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsSVGFEDiffuseLightingElement::GetKernelUnitLengthX(nsIDOMSVGAnimatedNumber **aKernelX)
|
|
||||||
{
|
|
||||||
return mNumberPairAttributes[KERNEL_UNIT_LENGTH].ToDOMAnimatedNumber(aKernelX,
|
|
||||||
nsSVGNumberPair::eFirst,
|
|
||||||
this);
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsSVGFEDiffuseLightingElement::GetKernelUnitLengthY(nsIDOMSVGAnimatedNumber **aKernelY)
|
|
||||||
{
|
|
||||||
return mNumberPairAttributes[KERNEL_UNIT_LENGTH].ToDOMAnimatedNumber(aKernelY,
|
|
||||||
nsSVGNumberPair::eSecond,
|
|
||||||
this);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
nsSVGFEDiffuseLightingElement::AttributeAffectsRendering(int32_t aNameSpaceID,
|
|
||||||
nsIAtom* aAttribute) const
|
|
||||||
{
|
|
||||||
return nsSVGFEDiffuseLightingElementBase::AttributeAffectsRendering(aNameSpaceID, aAttribute) ||
|
|
||||||
(aNameSpaceID == kNameSpaceID_None &&
|
|
||||||
aAttribute == nsGkAtoms::diffuseConstant);
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
// nsSVGElement methods
|
|
||||||
|
|
||||||
void
|
|
||||||
nsSVGFEDiffuseLightingElement::LightPixel(const float *N, const float *L,
|
|
||||||
nscolor color, uint8_t *targetData)
|
|
||||||
{
|
|
||||||
float diffuseNL =
|
|
||||||
mNumberAttributes[DIFFUSE_CONSTANT].GetAnimValue() * DOT(N, L);
|
|
||||||
|
|
||||||
if (diffuseNL < 0) diffuseNL = 0;
|
|
||||||
|
|
||||||
targetData[GFX_ARGB32_OFFSET_B] =
|
|
||||||
std::min(uint32_t(diffuseNL * NS_GET_B(color)), 255U);
|
|
||||||
targetData[GFX_ARGB32_OFFSET_G] =
|
|
||||||
std::min(uint32_t(diffuseNL * NS_GET_G(color)), 255U);
|
|
||||||
targetData[GFX_ARGB32_OFFSET_R] =
|
|
||||||
std::min(uint32_t(diffuseNL * NS_GET_R(color)), 255U);
|
|
||||||
targetData[GFX_ARGB32_OFFSET_A] = 255;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------Displacement------------------------
|
//---------------------Displacement------------------------
|
||||||
|
|
||||||
typedef nsSVGFE nsSVGFEDisplacementMapElementBase;
|
typedef nsSVGFE nsSVGFEDisplacementMapElementBase;
|
||||||
|
Loading…
Reference in New Issue
Block a user