зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
aa63ccb953
Коммит
3272a2350d
|
@ -81,6 +81,7 @@ CPPSRCS = \
|
|||
SVGFEColorMatrixElement.cpp \
|
||||
SVGFEComponentTransferElement.cpp \
|
||||
SVGFECompositeElement.cpp \
|
||||
SVGFEDiffuseLightingElement.cpp \
|
||||
SVGFEDistantLightElement.cpp \
|
||||
SVGFEFloodElement.cpp \
|
||||
SVGFEGaussianBlurElement.cpp \
|
||||
|
@ -190,6 +191,7 @@ EXPORTS_mozilla/dom = \
|
|||
SVGFEColorMatrixElement.h \
|
||||
SVGFEComponentTransferElement.h \
|
||||
SVGFECompositeElement.h \
|
||||
SVGFEDiffuseLightingElement.h \
|
||||
SVGFEDistantLightElement.h \
|
||||
SVGFEFloodElement.h \
|
||||
SVGFEGaussianBlurElement.h \
|
||||
|
|
|
@ -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
|
|
@ -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));
|
||||
}
|
||||
|
||||
//---------------------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------------------------
|
||||
|
||||
typedef nsSVGFE nsSVGFEDisplacementMapElementBase;
|
||||
|
|
Загрузка…
Ссылка в новой задаче