Bug 389865 - Improve filter architecture. r=tor,sr=roc,a=pavlov

This commit is contained in:
longsonr@gmail.com 2007-08-31 07:44:28 -07:00
Родитель af532bd69f
Коммит 9221605bfb
2 изменённых файлов: 166 добавлений и 284 удалений

Просмотреть файл

@ -73,26 +73,18 @@
class nsSVGFilterResource class nsSVGFilterResource
{ {
public: public:
enum DefaultSubregionType {UNION, ALL}; nsSVGFilterResource(nsSVGFE *aFilter, nsSVGFilterInstance* aInstance);
nsSVGFilterResource(nsSVGFilterInstance* aInstance,
const nsSVGFilterInstance::ColorModel &aColorModel);
~nsSVGFilterResource(); ~nsSVGFilterResource();
/* /*
* Acquires a source image for reading * Acquires a source image for reading
* aIn: the name of the filter primitive to use as the source * aIn: the name of the filter primitive to use as the source
* aFilter: the filter that is calling AcquireImage
* aDefaultSubregionType: whether the default subregion is the union
* of the referenced nodes or the entire area
* aSourceData: out parameter - the image data of the filter primitive * aSourceData: out parameter - the image data of the filter primitive
* specified by aIn * specified by aIn
* aSurface: optional out parameter - the surface of the filter * aSurface: optional out parameter - the surface of the filter
* primitive image specified by aIn * primitive image specified by aIn
*/ */
nsresult AcquireSourceImage(nsIDOMSVGAnimatedString* aIn, nsresult AcquireSourceImage(nsIDOMSVGAnimatedString* aIn,
nsSVGFE* aFilter,
DefaultSubregionType aDefaultSubregionType,
PRUint8** aSourceData, PRUint8** aSourceData,
gfxImageSurface** aSurface = 0); gfxImageSurface** aSurface = 0);
@ -109,7 +101,6 @@ public:
PRUint8** aTargetData, PRUint8** aTargetData,
gfxImageSurface** aSurface = 0); gfxImageSurface** aSurface = 0);
/* /*
* The source region * The source region
*/ */
@ -163,23 +154,23 @@ private:
nsAutoString mInput, mResult; nsAutoString mInput, mResult;
nsRect mSourceRegion, mFilterSubregion; nsRect mSourceRegion, mFilterSubregion;
nsRefPtr<gfxImageSurface> mTargetImage; nsRefPtr<gfxImageSurface> mTargetImage;
nsSVGFE *mFilter;
nsSVGFilterInstance* mInstance; nsSVGFilterInstance* mInstance;
PRUint8 *mSourceData, *mTargetData; PRUint8 *mSourceData, *mTargetData;
PRUint32 mWidth, mHeight; PRUint32 mWidth, mHeight;
PRInt32 mStride; PRInt32 mStride;
nsSVGFilterInstance::ColorModel mColorModel;
}; };
nsSVGFilterResource::nsSVGFilterResource(nsSVGFilterInstance* aInstance, nsSVGFilterResource::nsSVGFilterResource(nsSVGFE *aFilter,
const nsSVGFilterInstance::ColorModel &aColorModel) : nsSVGFilterInstance* aInstance) :
mTargetImage(nsnull), mTargetImage(nsnull),
mFilter(aFilter),
mInstance(aInstance), mInstance(aInstance),
mSourceData(nsnull), mSourceData(nsnull),
mTargetData(nsnull), mTargetData(nsnull),
mWidth(0), mWidth(0),
mHeight(0), mHeight(0),
mStride(0), mStride(0)
mColorModel(aColorModel)
{ {
} }
@ -190,8 +181,6 @@ nsSVGFilterResource::~nsSVGFilterResource()
nsresult nsresult
nsSVGFilterResource::AcquireSourceImage(nsIDOMSVGAnimatedString* aIn, nsSVGFilterResource::AcquireSourceImage(nsIDOMSVGAnimatedString* aIn,
nsSVGFE* aFilter,
DefaultSubregionType defaultSubregionType,
PRUint8** aSourceData, PRUint8** aSourceData,
gfxImageSurface** aSurface) gfxImageSurface** aSurface)
{ {
@ -199,7 +188,8 @@ nsSVGFilterResource::AcquireSourceImage(nsIDOMSVGAnimatedString* aIn,
nsRefPtr<gfxImageSurface> surface; nsRefPtr<gfxImageSurface> surface;
mInstance->LookupImage(mInput, getter_AddRefs(surface), mInstance->LookupImage(mInput, getter_AddRefs(surface),
&mSourceRegion, mColorModel); &mSourceRegion,
mFilter->GetColorModel(aIn));
if (!surface) { if (!surface) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@ -210,9 +200,9 @@ nsSVGFilterResource::AcquireSourceImage(nsIDOMSVGAnimatedString* aIn,
mHeight = size.height; mHeight = size.height;
mStride = surface->Stride(); mStride = surface->Stride();
mInstance->GetFilterSubregion(aFilter, mInstance->GetFilterSubregion(mFilter,
(defaultSubregionType == ALL) ? mFilter->SubregionIsUnionOfRegions() ?
nsRect(0, 0, mWidth, mHeight) : mSourceRegion, mSourceRegion : nsRect(0, 0, mWidth, mHeight),
&mFilterSubregion); &mFilterSubregion);
*aSourceData = mSourceData; *aSourceData = mSourceData;
@ -250,7 +240,10 @@ nsSVGFilterResource::ReleaseTarget()
if (!mTargetImage) { if (!mTargetImage) {
return; return;
} }
mInstance->DefineImage(mResult, mTargetImage, mFilterSubregion, mColorModel); mInstance->DefineImage(mResult,
mTargetImage,
mFilterSubregion,
mFilter->GetColorModel(nsnull));
mTargetImage = nsnull; mTargetImage = nsnull;
} }
@ -290,10 +283,6 @@ NS_INTERFACE_MAP_END_INHERITING(nsSVGFEBase)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Implementation // Implementation
nsSVGFE::nsSVGFE(nsINodeInfo* aNodeInfo) : nsSVGFEBase(aNodeInfo)
{
}
nsresult nsresult
nsSVGFE::Init() nsSVGFE::Init()
{ {
@ -353,25 +342,6 @@ nsSVGFE::ScanDualValueAttribute(const nsAString& aValue, nsIAtom* aAttribute,
return PR_TRUE; return PR_TRUE;
} }
nsSVGFilterInstance::ColorModel
nsSVGFE::GetColorModel(nsSVGFilterInstance::ColorModel::AlphaChannel aAlphaChannel)
{
nsSVGFilterInstance::ColorModel
colorModel(nsSVGFilterInstance::ColorModel::LINEAR_RGB,
aAlphaChannel);
nsIFrame* frame = GetPrimaryFrame();
if (!frame)
return colorModel;
nsStyleContext* style = frame->GetStyleContext();
if (style->GetStyleSVG()->mColorInterpolationFilters ==
NS_STYLE_COLOR_INTERPOLATION_SRGB)
colorModel.mColorSpace = nsSVGFilterInstance::ColorModel::SRGB;
return colorModel;
}
nsresult nsresult
nsSVGFE::SetupScalingFilter(nsSVGFilterInstance *aInstance, nsSVGFE::SetupScalingFilter(nsSVGFilterInstance *aInstance,
nsSVGFilterResource *aResource, nsSVGFilterResource *aResource,
@ -384,9 +354,7 @@ nsSVGFE::SetupScalingFilter(nsSVGFilterInstance *aInstance,
// the filter resource. // the filter resource.
nsresult rv; nsresult rv;
PRUint8 *sourceData, *targetData; PRUint8 *sourceData, *targetData;
rv = aResource->AcquireSourceImage(aIn, this, rv = aResource->AcquireSourceImage(aIn, &sourceData,
nsSVGFilterResource::UNION,
&sourceData,
getter_AddRefs(aScaleInfo->mRealSource)); getter_AddRefs(aScaleInfo->mRealSource));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = aResource->AcquireTargetImage(mResult, &targetData, rv = aResource->AcquireTargetImage(mResult, &targetData,
@ -527,10 +495,11 @@ class nsSVGFEGaussianBlurElement : public nsSVGFEGaussianBlurElementBase,
public nsIDOMSVGFEGaussianBlurElement, public nsIDOMSVGFEGaussianBlurElement,
public nsISVGFilter public nsISVGFilter
{ {
protected:
friend nsresult NS_NewSVGFEGaussianBlurElement(nsIContent **aResult, friend nsresult NS_NewSVGFEGaussianBlurElement(nsIContent **aResult,
nsINodeInfo *aNodeInfo); nsINodeInfo *aNodeInfo);
nsSVGFEGaussianBlurElement(nsINodeInfo* aNodeInfo); protected:
nsSVGFEGaussianBlurElement(nsINodeInfo* aNodeInfo)
: nsSVGFEGaussianBlurElementBase(aNodeInfo) {}
nsresult Init(); nsresult Init();
public: public:
@ -609,11 +578,6 @@ NS_INTERFACE_MAP_END_INHERITING(nsSVGFEGaussianBlurElementBase)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Implementation // Implementation
nsSVGFEGaussianBlurElement::nsSVGFEGaussianBlurElement(nsINodeInfo *aNodeInfo)
: nsSVGFEGaussianBlurElementBase(aNodeInfo)
{
}
nsresult nsresult
nsSVGFEGaussianBlurElement::Init() nsSVGFEGaussianBlurElement::Init()
{ {
@ -834,10 +798,9 @@ nsSVGFEGaussianBlurElement::Filter(nsSVGFilterInstance *instance)
{ {
nsresult rv; nsresult rv;
PRUint8 *sourceData, *targetData; PRUint8 *sourceData, *targetData;
nsSVGFilterResource fr(instance, nsSVGFilterResource fr(this, instance);
GetColorModel(nsSVGFilterInstance::ColorModel::PREMULTIPLIED));
rv = fr.AcquireSourceImage(mIn1, this, nsSVGFilterResource::UNION, &sourceData); rv = fr.AcquireSourceImage(mIn1, &sourceData);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = fr.AcquireTargetImage(mResult, &targetData); rv = fr.AcquireTargetImage(mResult, &targetData);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
@ -901,10 +864,11 @@ class nsSVGFEBlendElement : public nsSVGFEBlendElementBase,
public nsIDOMSVGFEBlendElement, public nsIDOMSVGFEBlendElement,
public nsISVGFilter public nsISVGFilter
{ {
protected:
friend nsresult NS_NewSVGFEBlendElement(nsIContent **aResult, friend nsresult NS_NewSVGFEBlendElement(nsIContent **aResult,
nsINodeInfo *aNodeInfo); nsINodeInfo *aNodeInfo);
nsSVGFEBlendElement(nsINodeInfo* aNodeInfo); protected:
nsSVGFEBlendElement(nsINodeInfo* aNodeInfo)
: nsSVGFEBlendElementBase(aNodeInfo) {}
nsresult Init(); nsresult Init();
public: public:
@ -979,11 +943,6 @@ NS_INTERFACE_MAP_END_INHERITING(nsSVGFEBlendElementBase)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Implementation // Implementation
nsSVGFEBlendElement::nsSVGFEBlendElement(nsINodeInfo *aNodeInfo)
: nsSVGFEBlendElementBase(aNodeInfo)
{
}
nsresult nsresult
nsSVGFEBlendElement::Init() nsSVGFEBlendElement::Init()
{ {
@ -1047,10 +1006,9 @@ nsSVGFEBlendElement::Filter(nsSVGFilterInstance *instance)
{ {
nsresult rv; nsresult rv;
PRUint8 *sourceData, *targetData; PRUint8 *sourceData, *targetData;
nsSVGFilterResource fr(instance, nsSVGFilterResource fr(this, instance);
GetColorModel(nsSVGFilterInstance::ColorModel::PREMULTIPLIED));
rv = fr.AcquireSourceImage(mIn1, this, nsSVGFilterResource::UNION, &sourceData); rv = fr.AcquireSourceImage(mIn1, &sourceData);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = fr.AcquireTargetImage(mResult, &targetData); rv = fr.AcquireTargetImage(mResult, &targetData);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
@ -1065,7 +1023,7 @@ nsSVGFEBlendElement::Filter(nsSVGFilterInstance *instance)
fr.CopySourceImage(); fr.CopySourceImage();
rv = fr.AcquireSourceImage(mIn2, this, nsSVGFilterResource::UNION, &sourceData); rv = fr.AcquireSourceImage(mIn2, &sourceData);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rect = fr.GetFilterSubregion(); rect = fr.GetFilterSubregion();
@ -1135,10 +1093,11 @@ class nsSVGFEColorMatrixElement : public nsSVGFEColorMatrixElementBase,
public nsIDOMSVGFEColorMatrixElement, public nsIDOMSVGFEColorMatrixElement,
public nsISVGFilter public nsISVGFilter
{ {
protected:
friend nsresult NS_NewSVGFEColorMatrixElement(nsIContent **aResult, friend nsresult NS_NewSVGFEColorMatrixElement(nsIContent **aResult,
nsINodeInfo *aNodeInfo); nsINodeInfo *aNodeInfo);
nsSVGFEColorMatrixElement(nsINodeInfo* aNodeInfo); protected:
nsSVGFEColorMatrixElement(nsINodeInfo* aNodeInfo)
: nsSVGFEColorMatrixElementBase(aNodeInfo) {}
nsresult Init(); nsresult Init();
public: public:
@ -1163,6 +1122,8 @@ public:
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
protected: protected:
virtual PRBool OperatesOnPremultipledAlpha() { return PR_FALSE; }
virtual EnumAttributesInfo GetEnumInfo(); virtual EnumAttributesInfo GetEnumInfo();
enum { TYPE }; enum { TYPE };
@ -1211,11 +1172,6 @@ NS_INTERFACE_MAP_END_INHERITING(nsSVGFEColorMatrixElementBase)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Implementation // Implementation
nsSVGFEColorMatrixElement::nsSVGFEColorMatrixElement(nsINodeInfo *aNodeInfo)
: nsSVGFEColorMatrixElementBase(aNodeInfo)
{
}
nsresult nsresult
nsSVGFEColorMatrixElement::Init() nsSVGFEColorMatrixElement::Init()
{ {
@ -1300,10 +1256,9 @@ nsSVGFEColorMatrixElement::Filter(nsSVGFilterInstance *instance)
{ {
nsresult rv; nsresult rv;
PRUint8 *sourceData, *targetData; PRUint8 *sourceData, *targetData;
nsSVGFilterResource fr(instance, nsSVGFilterResource fr(this, instance);
GetColorModel(nsSVGFilterInstance::ColorModel::UNPREMULTIPLIED));
rv = fr.AcquireSourceImage(mIn1, this, nsSVGFilterResource::UNION, &sourceData); rv = fr.AcquireSourceImage(mIn1, &sourceData);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = fr.AcquireTargetImage(mResult, &targetData); rv = fr.AcquireTargetImage(mResult, &targetData);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
@ -1462,10 +1417,11 @@ class nsSVGFECompositeElement : public nsSVGFECompositeElementBase,
public nsIDOMSVGFECompositeElement, public nsIDOMSVGFECompositeElement,
public nsISVGFilter public nsISVGFilter
{ {
protected:
friend nsresult NS_NewSVGFECompositeElement(nsIContent **aResult, friend nsresult NS_NewSVGFECompositeElement(nsIContent **aResult,
nsINodeInfo *aNodeInfo); nsINodeInfo *aNodeInfo);
nsSVGFECompositeElement(nsINodeInfo* aNodeInfo); protected:
nsSVGFECompositeElement(nsINodeInfo* aNodeInfo)
: nsSVGFECompositeElementBase(aNodeInfo) {}
nsresult Init(); nsresult Init();
public: public:
@ -1553,11 +1509,6 @@ NS_INTERFACE_MAP_END_INHERITING(nsSVGFECompositeElementBase)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Implementation // Implementation
nsSVGFECompositeElement::nsSVGFECompositeElement(nsINodeInfo *aNodeInfo)
: nsSVGFECompositeElementBase(aNodeInfo)
{
}
nsresult nsresult
nsSVGFECompositeElement::Init() nsSVGFECompositeElement::Init()
{ {
@ -1656,11 +1607,9 @@ nsSVGFECompositeElement::Filter(nsSVGFilterInstance *instance)
nsresult rv; nsresult rv;
PRUint8 *sourceData, *targetData; PRUint8 *sourceData, *targetData;
nsRefPtr<gfxImageSurface> sourceSurface, targetSurface; nsRefPtr<gfxImageSurface> sourceSurface, targetSurface;
nsSVGFilterResource fr(this, instance);
nsSVGFilterResource fr(instance, rv = fr.AcquireSourceImage(mIn2, &sourceData, getter_AddRefs(sourceSurface));
GetColorModel(nsSVGFilterInstance::ColorModel::PREMULTIPLIED));
rv = fr.AcquireSourceImage(mIn2, this, nsSVGFilterResource::UNION, &sourceData,
getter_AddRefs(sourceSurface));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = fr.AcquireTargetImage(mResult, &targetData, rv = fr.AcquireTargetImage(mResult, &targetData,
getter_AddRefs(targetSurface)); getter_AddRefs(targetSurface));
@ -1694,7 +1643,7 @@ nsSVGFECompositeElement::Filter(nsSVGFilterInstance *instance)
fr.CopySourceImage(); fr.CopySourceImage();
// Blend in the second source image // Blend in the second source image
rv = fr.AcquireSourceImage(mIn1, this, nsSVGFilterResource::UNION, &sourceData); rv = fr.AcquireSourceImage(mIn1, &sourceData);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
float k1Scaled = k1 / 255.0f; float k1Scaled = k1 / 255.0f;
float k4Scaled = k4 / 255.0f; float k4Scaled = k4 / 255.0f;
@ -1730,7 +1679,7 @@ nsSVGFECompositeElement::Filter(nsSVGFilterInstance *instance)
gfxContext::OPERATOR_XOR }; gfxContext::OPERATOR_XOR };
ctx.SetOperator(opMap[op]); ctx.SetOperator(opMap[op]);
rv = fr.AcquireSourceImage(mIn1, this, nsSVGFilterResource::UNION, &sourceData, rv = fr.AcquireSourceImage(mIn1, &sourceData,
getter_AddRefs(sourceSurface)); getter_AddRefs(sourceSurface));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
ctx.SetSource(sourceSurface); ctx.SetSource(sourceSurface);
@ -1770,10 +1719,11 @@ class nsSVGFEComponentTransferElement : public nsSVGFEComponentTransferElementBa
public nsIDOMSVGFEComponentTransferElement, public nsIDOMSVGFEComponentTransferElement,
public nsISVGFilter public nsISVGFilter
{ {
protected:
friend nsresult NS_NewSVGFEComponentTransferElement(nsIContent **aResult, friend nsresult NS_NewSVGFEComponentTransferElement(nsIContent **aResult,
nsINodeInfo *aNodeInfo); nsINodeInfo *aNodeInfo);
nsSVGFEComponentTransferElement(nsINodeInfo* aNodeInfo); protected:
nsSVGFEComponentTransferElement(nsINodeInfo* aNodeInfo)
: nsSVGFEComponentTransferElementBase(aNodeInfo) {}
nsresult Init(); nsresult Init();
public: public:
@ -1799,6 +1749,7 @@ public:
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
protected: protected:
virtual PRBool OperatesOnPremultipledAlpha() { return PR_FALSE; }
nsCOMPtr<nsIDOMSVGAnimatedString> mIn1; nsCOMPtr<nsIDOMSVGAnimatedString> mIn1;
}; };
@ -1824,11 +1775,6 @@ NS_INTERFACE_MAP_END_INHERITING(nsSVGFEComponentTransferElementBase)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Implementation // Implementation
nsSVGFEComponentTransferElement::nsSVGFEComponentTransferElement(nsINodeInfo *aNodeInfo)
: nsSVGFEComponentTransferElementBase(aNodeInfo)
{
}
nsresult nsresult
nsSVGFEComponentTransferElement::Init() nsSVGFEComponentTransferElement::Init()
{ {
@ -1868,10 +1814,9 @@ nsSVGFEComponentTransferElement::Filter(nsSVGFilterInstance *instance)
{ {
nsresult rv; nsresult rv;
PRUint8 *sourceData, *targetData; PRUint8 *sourceData, *targetData;
nsSVGFilterResource fr(instance, nsSVGFilterResource fr(this, instance);
GetColorModel(nsSVGFilterInstance::ColorModel::UNPREMULTIPLIED));
rv = fr.AcquireSourceImage(mIn1, this, nsSVGFilterResource::UNION, &sourceData); rv = fr.AcquireSourceImage(mIn1, &sourceData);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = fr.AcquireTargetImage(mResult, &targetData); rv = fr.AcquireTargetImage(mResult, &targetData);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
@ -1931,10 +1876,11 @@ typedef nsSVGElement nsSVGComponentTransferFunctionElementBase;
class nsSVGComponentTransferFunctionElement : public nsSVGComponentTransferFunctionElementBase class nsSVGComponentTransferFunctionElement : public nsSVGComponentTransferFunctionElementBase
{ {
protected:
friend nsresult NS_NewSVGComponentTransferFunctionElement(nsIContent **aResult, friend nsresult NS_NewSVGComponentTransferFunctionElement(nsIContent **aResult,
nsINodeInfo *aNodeInfo); nsINodeInfo *aNodeInfo);
nsSVGComponentTransferFunctionElement(nsINodeInfo* aNodeInfo); protected:
nsSVGComponentTransferFunctionElement(nsINodeInfo* aNodeInfo)
: nsSVGComponentTransferFunctionElementBase(aNodeInfo) {}
nsresult Init(); nsresult Init();
public: public:
@ -2003,11 +1949,6 @@ NS_INTERFACE_MAP_END_INHERITING(nsSVGComponentTransferFunctionElementBase)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Implementation // Implementation
nsSVGComponentTransferFunctionElement::nsSVGComponentTransferFunctionElement(nsINodeInfo* aNodeInfo)
: nsSVGComponentTransferFunctionElementBase(aNodeInfo)
{
}
nsresult nsresult
nsSVGComponentTransferFunctionElement::Init() nsSVGComponentTransferFunctionElement::Init()
{ {
@ -2191,9 +2132,9 @@ nsSVGComponentTransferFunctionElement::GetNumberInfo()
class nsSVGFEFuncRElement : public nsSVGComponentTransferFunctionElement, class nsSVGFEFuncRElement : public nsSVGComponentTransferFunctionElement,
public nsIDOMSVGFEFuncRElement public nsIDOMSVGFEFuncRElement
{ {
protected:
friend nsresult NS_NewSVGFEFuncRElement(nsIContent **aResult, friend nsresult NS_NewSVGFEFuncRElement(nsIContent **aResult,
nsINodeInfo *aNodeInfo); nsINodeInfo *aNodeInfo);
protected:
nsSVGFEFuncRElement(nsINodeInfo* aNodeInfo) nsSVGFEFuncRElement(nsINodeInfo* aNodeInfo)
: nsSVGComponentTransferFunctionElement(aNodeInfo) {} : nsSVGComponentTransferFunctionElement(aNodeInfo) {}
@ -2231,9 +2172,9 @@ NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFEFuncRElement)
class nsSVGFEFuncGElement : public nsSVGComponentTransferFunctionElement, class nsSVGFEFuncGElement : public nsSVGComponentTransferFunctionElement,
public nsIDOMSVGFEFuncGElement public nsIDOMSVGFEFuncGElement
{ {
protected:
friend nsresult NS_NewSVGFEFuncGElement(nsIContent **aResult, friend nsresult NS_NewSVGFEFuncGElement(nsIContent **aResult,
nsINodeInfo *aNodeInfo); nsINodeInfo *aNodeInfo);
protected:
nsSVGFEFuncGElement(nsINodeInfo* aNodeInfo) nsSVGFEFuncGElement(nsINodeInfo* aNodeInfo)
: nsSVGComponentTransferFunctionElement(aNodeInfo) {} : nsSVGComponentTransferFunctionElement(aNodeInfo) {}
@ -2271,9 +2212,9 @@ NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFEFuncGElement)
class nsSVGFEFuncBElement : public nsSVGComponentTransferFunctionElement, class nsSVGFEFuncBElement : public nsSVGComponentTransferFunctionElement,
public nsIDOMSVGFEFuncBElement public nsIDOMSVGFEFuncBElement
{ {
protected:
friend nsresult NS_NewSVGFEFuncBElement(nsIContent **aResult, friend nsresult NS_NewSVGFEFuncBElement(nsIContent **aResult,
nsINodeInfo *aNodeInfo); nsINodeInfo *aNodeInfo);
protected:
nsSVGFEFuncBElement(nsINodeInfo* aNodeInfo) nsSVGFEFuncBElement(nsINodeInfo* aNodeInfo)
: nsSVGComponentTransferFunctionElement(aNodeInfo) {} : nsSVGComponentTransferFunctionElement(aNodeInfo) {}
@ -2311,9 +2252,9 @@ NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFEFuncBElement)
class nsSVGFEFuncAElement : public nsSVGComponentTransferFunctionElement, class nsSVGFEFuncAElement : public nsSVGComponentTransferFunctionElement,
public nsIDOMSVGFEFuncAElement public nsIDOMSVGFEFuncAElement
{ {
protected:
friend nsresult NS_NewSVGFEFuncAElement(nsIContent **aResult, friend nsresult NS_NewSVGFEFuncAElement(nsIContent **aResult,
nsINodeInfo *aNodeInfo); nsINodeInfo *aNodeInfo);
protected:
nsSVGFEFuncAElement(nsINodeInfo* aNodeInfo) nsSVGFEFuncAElement(nsINodeInfo* aNodeInfo)
: nsSVGComponentTransferFunctionElement(aNodeInfo) {} : nsSVGComponentTransferFunctionElement(aNodeInfo) {}
@ -2355,10 +2296,11 @@ class nsSVGFEMergeElement : public nsSVGFEMergeElementBase,
public nsIDOMSVGFEMergeElement, public nsIDOMSVGFEMergeElement,
public nsISVGFilter public nsISVGFilter
{ {
protected:
friend nsresult NS_NewSVGFEMergeElement(nsIContent **aResult, friend nsresult NS_NewSVGFEMergeElement(nsIContent **aResult,
nsINodeInfo *aNodeInfo); nsINodeInfo *aNodeInfo);
nsSVGFEMergeElement(nsINodeInfo* aNodeInfo); protected:
nsSVGFEMergeElement(nsINodeInfo* aNodeInfo)
: nsSVGFEMergeElementBase(aNodeInfo) {}
public: public:
// interfaces: // interfaces:
@ -2402,14 +2344,6 @@ NS_INTERFACE_MAP_BEGIN(nsSVGFEMergeElement)
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFEMergeElement) NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFEMergeElement)
NS_INTERFACE_MAP_END_INHERITING(nsSVGFEMergeElementBase) NS_INTERFACE_MAP_END_INHERITING(nsSVGFEMergeElementBase)
//----------------------------------------------------------------------
// Implementation
nsSVGFEMergeElement::nsSVGFEMergeElement(nsINodeInfo *aNodeInfo)
: nsSVGFEMergeElementBase(aNodeInfo)
{
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// nsIDOMNode methods // nsIDOMNode methods
@ -2421,9 +2355,8 @@ nsSVGFEMergeElement::Filter(nsSVGFilterInstance *instance)
nsresult rv; nsresult rv;
PRUint8 *sourceData, *targetData; PRUint8 *sourceData, *targetData;
nsRefPtr<gfxImageSurface> sourceSurface, targetSurface; nsRefPtr<gfxImageSurface> sourceSurface, targetSurface;
nsSVGFilterResource fr(this, instance);
nsSVGFilterResource fr(instance,
GetColorModel(nsSVGFilterInstance::ColorModel::PREMULTIPLIED));
rv = fr.AcquireTargetImage(mResult, &targetData, rv = fr.AcquireTargetImage(mResult, &targetData,
getter_AddRefs(targetSurface)); getter_AddRefs(targetSurface));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
@ -2439,8 +2372,7 @@ nsSVGFEMergeElement::Filter(nsSVGFilterInstance *instance)
nsCOMPtr<nsIDOMSVGAnimatedString> str; nsCOMPtr<nsIDOMSVGAnimatedString> str;
node->GetIn1(getter_AddRefs(str)); node->GetIn1(getter_AddRefs(str));
rv = fr.AcquireSourceImage(str, this, nsSVGFilterResource::UNION, rv = fr.AcquireSourceImage(str, &sourceData, getter_AddRefs(sourceSurface));
&sourceData, getter_AddRefs(sourceSurface));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
ctx.SetSource(sourceSurface); ctx.SetSource(sourceSurface);
@ -2476,10 +2408,11 @@ typedef nsSVGStylableElement nsSVGFEMergeNodeElementBase;
class nsSVGFEMergeNodeElement : public nsSVGFEMergeNodeElementBase, class nsSVGFEMergeNodeElement : public nsSVGFEMergeNodeElementBase,
public nsIDOMSVGFEMergeNodeElement public nsIDOMSVGFEMergeNodeElement
{ {
protected:
friend nsresult NS_NewSVGFEMergeNodeElement(nsIContent **aResult, friend nsresult NS_NewSVGFEMergeNodeElement(nsIContent **aResult,
nsINodeInfo *aNodeInfo); nsINodeInfo *aNodeInfo);
nsSVGFEMergeNodeElement(nsINodeInfo* aNodeInfo); protected:
nsSVGFEMergeNodeElement(nsINodeInfo* aNodeInfo)
: nsSVGFEMergeNodeElementBase(aNodeInfo) {}
nsresult Init(); nsresult Init();
public: public:
@ -2518,11 +2451,6 @@ NS_INTERFACE_MAP_END_INHERITING(nsSVGFEMergeNodeElementBase)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Implementation // Implementation
nsSVGFEMergeNodeElement::nsSVGFEMergeNodeElement(nsINodeInfo *aNodeInfo)
: nsSVGFEMergeNodeElementBase(aNodeInfo)
{
}
nsresult nsresult
nsSVGFEMergeNodeElement::Init() nsSVGFEMergeNodeElement::Init()
{ {
@ -2565,10 +2493,11 @@ class nsSVGFEOffsetElement : public nsSVGFEOffsetElementBase,
public nsIDOMSVGFEOffsetElement, public nsIDOMSVGFEOffsetElement,
public nsISVGFilter public nsISVGFilter
{ {
protected:
friend nsresult NS_NewSVGFEOffsetElement(nsIContent **aResult, friend nsresult NS_NewSVGFEOffsetElement(nsIContent **aResult,
nsINodeInfo *aNodeInfo); nsINodeInfo *aNodeInfo);
nsSVGFEOffsetElement(nsINodeInfo* aNodeInfo); protected:
nsSVGFEOffsetElement(nsINodeInfo* aNodeInfo)
: nsSVGFEOffsetElementBase(aNodeInfo) {}
nsresult Init(); nsresult Init();
public: public:
@ -2628,11 +2557,6 @@ NS_INTERFACE_MAP_END_INHERITING(nsSVGFEOffsetElementBase)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Implementation // Implementation
nsSVGFEOffsetElement::nsSVGFEOffsetElement(nsINodeInfo *aNodeInfo)
: nsSVGFEOffsetElementBase(aNodeInfo)
{
}
nsresult nsresult
nsSVGFEOffsetElement::Init() nsSVGFEOffsetElement::Init()
{ {
@ -2685,10 +2609,9 @@ nsSVGFEOffsetElement::Filter(nsSVGFilterInstance *instance)
{ {
nsresult rv; nsresult rv;
PRUint8 *sourceData, *targetData; PRUint8 *sourceData, *targetData;
nsSVGFilterResource fr(instance, nsSVGFilterResource fr(this, instance);
GetColorModel(nsSVGFilterInstance::ColorModel::PREMULTIPLIED));
rv = fr.AcquireSourceImage(mIn1, this, nsSVGFilterResource::UNION, &sourceData); rv = fr.AcquireSourceImage(mIn1, &sourceData);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = fr.AcquireTargetImage(mResult, &targetData); rv = fr.AcquireTargetImage(mResult, &targetData);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
@ -2757,10 +2680,11 @@ class nsSVGFEFloodElement : public nsSVGFEFloodElementBase,
public nsIDOMSVGFEFloodElement, public nsIDOMSVGFEFloodElement,
public nsISVGFilter public nsISVGFilter
{ {
protected:
friend nsresult NS_NewSVGFEFloodElement(nsIContent **aResult, friend nsresult NS_NewSVGFEFloodElement(nsIContent **aResult,
nsINodeInfo *aNodeInfo); nsINodeInfo *aNodeInfo);
nsSVGFEFloodElement(nsINodeInfo* aNodeInfo); protected:
nsSVGFEFloodElement(nsINodeInfo* aNodeInfo)
: nsSVGFEFloodElementBase(aNodeInfo) {}
nsresult Init(); nsresult Init();
public: public:
@ -2788,6 +2712,8 @@ public:
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
protected: protected:
virtual PRBool OperatesOnSRGB(nsIDOMSVGAnimatedString*) { return PR_TRUE; }
nsCOMPtr<nsIDOMSVGAnimatedString> mIn1; nsCOMPtr<nsIDOMSVGAnimatedString> mIn1;
}; };
@ -2812,11 +2738,6 @@ NS_INTERFACE_MAP_END_INHERITING(nsSVGFEFloodElementBase)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Implementation // Implementation
nsSVGFEFloodElement::nsSVGFEFloodElement(nsINodeInfo *aNodeInfo)
: nsSVGFEFloodElementBase(aNodeInfo)
{
}
nsresult nsresult
nsSVGFEFloodElement::Init() nsSVGFEFloodElement::Init()
{ {
@ -2857,13 +2778,9 @@ nsSVGFEFloodElement::Filter(nsSVGFilterInstance *instance)
nsresult rv; nsresult rv;
PRUint8 *sourceData, *targetData; PRUint8 *sourceData, *targetData;
nsRefPtr<gfxImageSurface> targetSurface; nsRefPtr<gfxImageSurface> targetSurface;
// flood colour is sRGB nsSVGFilterResource fr(this, instance);
nsSVGFilterInstance::ColorModel
colorModel(nsSVGFilterInstance::ColorModel::SRGB,
nsSVGFilterInstance::ColorModel::PREMULTIPLIED);
nsSVGFilterResource fr(instance, colorModel);
rv = fr.AcquireSourceImage(mIn1, this, nsSVGFilterResource::UNION, &sourceData); rv = fr.AcquireSourceImage(mIn1, &sourceData);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = fr.AcquireTargetImage(mResult, &targetData, rv = fr.AcquireTargetImage(mResult, &targetData,
getter_AddRefs(targetSurface)); getter_AddRefs(targetSurface));
@ -2917,13 +2834,16 @@ class nsSVGFETileElement : public nsSVGFETileElementBase,
public nsIDOMSVGFETileElement, public nsIDOMSVGFETileElement,
public nsISVGFilter public nsISVGFilter
{ {
protected:
friend nsresult NS_NewSVGFETileElement(nsIContent **aResult, friend nsresult NS_NewSVGFETileElement(nsIContent **aResult,
nsINodeInfo *aNodeInfo); nsINodeInfo *aNodeInfo);
nsSVGFETileElement(nsINodeInfo* aNodeInfo); protected:
nsSVGFETileElement(nsINodeInfo* aNodeInfo)
: nsSVGFETileElementBase(aNodeInfo) {}
nsresult Init(); nsresult Init();
public: public:
virtual PRBool SubregionIsUnionOfRegions() { return PR_FALSE; }
// interfaces: // interfaces:
NS_DECL_ISUPPORTS_INHERITED NS_DECL_ISUPPORTS_INHERITED
@ -2971,11 +2891,6 @@ NS_INTERFACE_MAP_END_INHERITING(nsSVGFETileElementBase)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Implementation // Implementation
nsSVGFETileElement::nsSVGFETileElement(nsINodeInfo *aNodeInfo)
: nsSVGFETileElementBase(aNodeInfo)
{
}
nsresult nsresult
nsSVGFETileElement::Init() nsSVGFETileElement::Init()
{ {
@ -3026,10 +2941,9 @@ nsSVGFETileElement::Filter(nsSVGFilterInstance *instance)
{ {
nsresult rv; nsresult rv;
PRUint8 *sourceData, *targetData; PRUint8 *sourceData, *targetData;
nsSVGFilterResource fr(instance, nsSVGFilterResource fr(this, instance);
GetColorModel(nsSVGFilterInstance::ColorModel::PREMULTIPLIED));
rv = fr.AcquireSourceImage(mIn1, this, nsSVGFilterResource::ALL, &sourceData); rv = fr.AcquireSourceImage(mIn1, &sourceData);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = fr.AcquireTargetImage(mResult, &targetData); rv = fr.AcquireTargetImage(mResult, &targetData);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
@ -3064,13 +2978,16 @@ class nsSVGFETurbulenceElement : public nsSVGFETurbulenceElementBase,
public nsIDOMSVGFETurbulenceElement, public nsIDOMSVGFETurbulenceElement,
public nsISVGFilter public nsISVGFilter
{ {
protected:
friend nsresult NS_NewSVGFETurbulenceElement(nsIContent **aResult, friend nsresult NS_NewSVGFETurbulenceElement(nsIContent **aResult,
nsINodeInfo *aNodeInfo); nsINodeInfo *aNodeInfo);
nsSVGFETurbulenceElement(nsINodeInfo* aNodeInfo); protected:
nsSVGFETurbulenceElement(nsINodeInfo* aNodeInfo)
: nsSVGFETurbulenceElementBase(aNodeInfo) {}
nsresult Init(); nsresult Init();
public: public:
virtual PRBool SubregionIsUnionOfRegions() { return PR_FALSE; }
// interfaces: // interfaces:
NS_DECL_ISUPPORTS_INHERITED NS_DECL_ISUPPORTS_INHERITED
@ -3228,11 +3145,6 @@ NS_INTERFACE_MAP_END_INHERITING(nsSVGFETurbulenceElementBase)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Implementation // Implementation
nsSVGFETurbulenceElement::nsSVGFETurbulenceElement(nsINodeInfo *aNodeInfo)
: nsSVGFETurbulenceElementBase(aNodeInfo)
{
}
nsresult nsresult
nsSVGFETurbulenceElement::Init() nsSVGFETurbulenceElement::Init()
{ {
@ -3327,14 +3239,13 @@ nsSVGFETurbulenceElement::Filter(nsSVGFilterInstance *instance)
{ {
nsresult rv; nsresult rv;
PRUint8 *sourceData, *targetData; PRUint8 *sourceData, *targetData;
nsSVGFilterResource fr(instance, nsSVGFilterResource fr(this, instance);
GetColorModel(nsSVGFilterInstance::ColorModel::PREMULTIPLIED));
nsIDOMSVGAnimatedString* sourceGraphic = nsnull; nsIDOMSVGAnimatedString* sourceGraphic = nsnull;
rv = NS_NewSVGAnimatedString(&sourceGraphic); rv = NS_NewSVGAnimatedString(&sourceGraphic);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = fr.AcquireSourceImage(sourceGraphic, this, nsSVGFilterResource::UNION, &sourceData); rv = fr.AcquireSourceImage(sourceGraphic, &sourceData);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = fr.AcquireTargetImage(mResult, &targetData); rv = fr.AcquireTargetImage(mResult, &targetData);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
@ -3597,10 +3508,11 @@ class nsSVGFEMorphologyElement : public nsSVGFEMorphologyElementBase,
public nsIDOMSVGFEMorphologyElement, public nsIDOMSVGFEMorphologyElement,
public nsISVGFilter public nsISVGFilter
{ {
protected:
friend nsresult NS_NewSVGFEMorphologyElement(nsIContent **aResult, friend nsresult NS_NewSVGFEMorphologyElement(nsIContent **aResult,
nsINodeInfo *aNodeInfo); nsINodeInfo *aNodeInfo);
nsSVGFEMorphologyElement(nsINodeInfo* aNodeInfo); protected:
nsSVGFEMorphologyElement(nsINodeInfo* aNodeInfo)
: nsSVGFEMorphologyElementBase(aNodeInfo) {}
nsresult Init(); nsresult Init();
public: public:
@ -3684,11 +3596,6 @@ NS_INTERFACE_MAP_END_INHERITING(nsSVGFEMorphologyElementBase)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Implementation // Implementation
nsSVGFEMorphologyElement::nsSVGFEMorphologyElement(nsINodeInfo *aNodeInfo)
: nsSVGFEMorphologyElementBase(aNodeInfo)
{
}
nsresult nsresult
nsSVGFEMorphologyElement::Init() nsSVGFEMorphologyElement::Init()
{ {
@ -3798,10 +3705,9 @@ nsSVGFEMorphologyElement::Filter(nsSVGFilterInstance *instance)
{ {
nsresult rv; nsresult rv;
PRUint8 *sourceData, *targetData; PRUint8 *sourceData, *targetData;
nsSVGFilterResource fr(instance, nsSVGFilterResource fr(this, instance);
GetColorModel(nsSVGFilterInstance::ColorModel::PREMULTIPLIED));
rv = fr.AcquireSourceImage(mIn1, this, nsSVGFilterResource::UNION, &sourceData); rv = fr.AcquireSourceImage(mIn1, &sourceData);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = fr.AcquireTargetImage(mResult, &targetData); rv = fr.AcquireTargetImage(mResult, &targetData);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
@ -3899,10 +3805,11 @@ class nsSVGFEConvolveMatrixElement : public nsSVGFEConvolveMatrixElementBase,
public nsIDOMSVGFEConvolveMatrixElement, public nsIDOMSVGFEConvolveMatrixElement,
public nsISVGFilter public nsISVGFilter
{ {
protected:
friend nsresult NS_NewSVGFEConvolveMatrixElement(nsIContent **aResult, friend nsresult NS_NewSVGFEConvolveMatrixElement(nsIContent **aResult,
nsINodeInfo *aNodeInfo); nsINodeInfo *aNodeInfo);
nsSVGFEConvolveMatrixElement(nsINodeInfo* aNodeInfo); protected:
nsSVGFEConvolveMatrixElement(nsINodeInfo* aNodeInfo)
: nsSVGFEConvolveMatrixElementBase(aNodeInfo) {}
nsresult Init(); nsresult Init();
public: public:
@ -3930,6 +3837,12 @@ public:
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
protected: protected:
virtual PRBool OperatesOnPremultipledAlpha() {
PRBool preserveAlpha;
mPreserveAlpha->GetAnimVal(&preserveAlpha);
return !preserveAlpha;
}
virtual NumberAttributesInfo GetNumberInfo(); virtual NumberAttributesInfo GetNumberInfo();
virtual EnumAttributesInfo GetEnumInfo(); virtual EnumAttributesInfo GetEnumInfo();
@ -3996,11 +3909,6 @@ NS_INTERFACE_MAP_END_INHERITING(nsSVGFEConvolveMatrixElementBase)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Implementation // Implementation
nsSVGFEConvolveMatrixElement::nsSVGFEConvolveMatrixElement(nsINodeInfo *aNodeInfo)
: nsSVGFEConvolveMatrixElementBase(aNodeInfo)
{
}
nsresult nsresult
nsSVGFEConvolveMatrixElement::Init() nsSVGFEConvolveMatrixElement::Init()
{ {
@ -4343,11 +4251,7 @@ nsSVGFEConvolveMatrixElement::Filter(nsSVGFilterInstance *instance)
divisor = 1; divisor = 1;
} }
nsSVGFilterResource nsSVGFilterResource fr(this, instance);
fr(instance, GetColorModel(preserveAlpha
? nsSVGFilterInstance::ColorModel::UNPREMULTIPLIED
: nsSVGFilterInstance::ColorModel::PREMULTIPLIED));
ScaleInfo info; ScaleInfo info;
nsresult rv = SetupScalingFilter(instance, &fr, mIn1, nsresult rv = SetupScalingFilter(instance, &fr, mIn1,
@ -4420,10 +4324,11 @@ typedef nsSVGElement nsSVGFEDistantLightElementBase;
class nsSVGFEDistantLightElement : public nsSVGFEDistantLightElementBase, class nsSVGFEDistantLightElement : public nsSVGFEDistantLightElementBase,
public nsIDOMSVGFEDistantLightElement public nsIDOMSVGFEDistantLightElement
{ {
protected:
friend nsresult NS_NewSVGFEDistantLightElement(nsIContent **aResult, friend nsresult NS_NewSVGFEDistantLightElement(nsIContent **aResult,
nsINodeInfo *aNodeInfo); nsINodeInfo *aNodeInfo);
nsSVGFEDistantLightElement(nsINodeInfo* aNodeInfo); protected:
nsSVGFEDistantLightElement(nsINodeInfo* aNodeInfo)
: nsSVGFEDistantLightElementBase(aNodeInfo) {}
public: public:
// interfaces: // interfaces:
@ -4466,14 +4371,6 @@ NS_INTERFACE_MAP_BEGIN(nsSVGFEDistantLightElement)
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFEDistantLightElement) NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFEDistantLightElement)
NS_INTERFACE_MAP_END_INHERITING(nsSVGFEDistantLightElementBase) NS_INTERFACE_MAP_END_INHERITING(nsSVGFEDistantLightElementBase)
//----------------------------------------------------------------------
// Implementation
nsSVGFEDistantLightElement::nsSVGFEDistantLightElement(nsINodeInfo* aNodeInfo)
: nsSVGFEDistantLightElementBase(aNodeInfo)
{
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// nsIDOMNode methods // nsIDOMNode methods
@ -4513,10 +4410,11 @@ typedef nsSVGElement nsSVGFEPointLightElementBase;
class nsSVGFEPointLightElement : public nsSVGFEPointLightElementBase, class nsSVGFEPointLightElement : public nsSVGFEPointLightElementBase,
public nsIDOMSVGFEPointLightElement public nsIDOMSVGFEPointLightElement
{ {
protected:
friend nsresult NS_NewSVGFEPointLightElement(nsIContent **aResult, friend nsresult NS_NewSVGFEPointLightElement(nsIContent **aResult,
nsINodeInfo *aNodeInfo); nsINodeInfo *aNodeInfo);
nsSVGFEPointLightElement(nsINodeInfo* aNodeInfo); protected:
nsSVGFEPointLightElement(nsINodeInfo* aNodeInfo)
: nsSVGFEPointLightElementBase(aNodeInfo) {}
public: public:
// interfaces: // interfaces:
@ -4560,14 +4458,6 @@ NS_INTERFACE_MAP_BEGIN(nsSVGFEPointLightElement)
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFEPointLightElement) NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFEPointLightElement)
NS_INTERFACE_MAP_END_INHERITING(nsSVGFEPointLightElementBase) NS_INTERFACE_MAP_END_INHERITING(nsSVGFEPointLightElementBase)
//----------------------------------------------------------------------
// Implementation
nsSVGFEPointLightElement::nsSVGFEPointLightElement(nsINodeInfo* aNodeInfo)
: nsSVGFEPointLightElementBase(aNodeInfo)
{
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// nsIDOMNode methods // nsIDOMNode methods
@ -4611,10 +4501,11 @@ typedef nsSVGElement nsSVGFESpotLightElementBase;
class nsSVGFESpotLightElement : public nsSVGFESpotLightElementBase, class nsSVGFESpotLightElement : public nsSVGFESpotLightElementBase,
public nsIDOMSVGFESpotLightElement public nsIDOMSVGFESpotLightElement
{ {
protected:
friend nsresult NS_NewSVGFESpotLightElement(nsIContent **aResult, friend nsresult NS_NewSVGFESpotLightElement(nsIContent **aResult,
nsINodeInfo *aNodeInfo); nsINodeInfo *aNodeInfo);
nsSVGFESpotLightElement(nsINodeInfo* aNodeInfo); protected:
nsSVGFESpotLightElement(nsINodeInfo* aNodeInfo)
: nsSVGFESpotLightElementBase(aNodeInfo) {}
public: public:
// interfaces: // interfaces:
@ -4664,14 +4555,6 @@ NS_INTERFACE_MAP_BEGIN(nsSVGFESpotLightElement)
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFESpotLightElement) NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFESpotLightElement)
NS_INTERFACE_MAP_END_INHERITING(nsSVGFESpotLightElementBase) NS_INTERFACE_MAP_END_INHERITING(nsSVGFESpotLightElementBase)
//----------------------------------------------------------------------
// Implementation
nsSVGFESpotLightElement::nsSVGFESpotLightElement(nsINodeInfo* aNodeInfo)
: nsSVGFESpotLightElementBase(aNodeInfo)
{
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// nsIDOMNode methods // nsIDOMNode methods
@ -4748,7 +4631,8 @@ class nsSVGFELightingElement : public nsSVGFELightingElementBase,
public nsISVGFilter public nsISVGFilter
{ {
protected: protected:
nsSVGFELightingElement(nsINodeInfo* aNodeInfo); nsSVGFELightingElement(nsINodeInfo* aNodeInfo)
: nsSVGFELightingElementBase(aNodeInfo) {}
nsresult Init(); nsresult Init();
public: public:
@ -4786,16 +4670,6 @@ protected:
nsCOMPtr<nsIDOMSVGAnimatedString> mIn1; nsCOMPtr<nsIDOMSVGAnimatedString> mIn1;
}; };
//----------------------------------------------------------------------
// nsISupports methods
NS_IMPL_ADDREF_INHERITED(nsSVGFELightingElement,nsSVGFELightingElementBase)
NS_IMPL_RELEASE_INHERITED(nsSVGFELightingElement,nsSVGFELightingElementBase)
NS_INTERFACE_MAP_BEGIN(nsSVGFELightingElement)
NS_INTERFACE_MAP_ENTRY(nsISVGFilter)
NS_INTERFACE_MAP_END_INHERITING(nsSVGFELightingElementBase)
nsSVGElement::NumberInfo nsSVGFELightingElement::sNumberInfo[6] = nsSVGElement::NumberInfo nsSVGFELightingElement::sNumberInfo[6] =
{ {
{ &nsGkAtoms::surfaceScale, 1 }, { &nsGkAtoms::surfaceScale, 1 },
@ -4806,10 +4680,18 @@ nsSVGElement::NumberInfo nsSVGFELightingElement::sNumberInfo[6] =
{ &nsGkAtoms::kernelUnitLength, 0 } { &nsGkAtoms::kernelUnitLength, 0 }
}; };
nsSVGFELightingElement::nsSVGFELightingElement(nsINodeInfo *aNodeInfo) //----------------------------------------------------------------------
: nsSVGFELightingElementBase(aNodeInfo) // nsISupports methods
{
} NS_IMPL_ADDREF_INHERITED(nsSVGFELightingElement,nsSVGFELightingElementBase)
NS_IMPL_RELEASE_INHERITED(nsSVGFELightingElement,nsSVGFELightingElementBase)
NS_INTERFACE_MAP_BEGIN(nsSVGFELightingElement)
NS_INTERFACE_MAP_ENTRY(nsISVGFilter)
NS_INTERFACE_MAP_END_INHERITING(nsSVGFELightingElementBase)
//----------------------------------------------------------------------
// Implementation
nsresult nsresult
nsSVGFELightingElement::Init() nsSVGFELightingElement::Init()
@ -4958,8 +4840,7 @@ GenerateNormal(float *N, const PRUint8 *data, PRInt32 stride, nsRect rect,
NS_IMETHODIMP NS_IMETHODIMP
nsSVGFELightingElement::Filter(nsSVGFilterInstance *instance) nsSVGFELightingElement::Filter(nsSVGFilterInstance *instance)
{ {
nsSVGFilterResource fr(instance, nsSVGFilterResource fr(this, instance);
GetColorModel(nsSVGFilterInstance::ColorModel::PREMULTIPLIED));
ScaleInfo info; ScaleInfo info;
nsresult rv = SetupScalingFilter(instance, &fr, mIn1, nsresult rv = SetupScalingFilter(instance, &fr, mIn1,
@ -5103,10 +4984,11 @@ typedef nsSVGFELightingElement nsSVGFEDiffuseLightingElementBase;
class nsSVGFEDiffuseLightingElement : public nsSVGFEDiffuseLightingElementBase, class nsSVGFEDiffuseLightingElement : public nsSVGFEDiffuseLightingElementBase,
public nsIDOMSVGFEDiffuseLightingElement public nsIDOMSVGFEDiffuseLightingElement
{ {
protected:
friend nsresult NS_NewSVGFEDiffuseLightingElement(nsIContent **aResult, friend nsresult NS_NewSVGFEDiffuseLightingElement(nsIContent **aResult,
nsINodeInfo *aNodeInfo); nsINodeInfo *aNodeInfo);
nsSVGFEDiffuseLightingElement(nsINodeInfo* aNodeInfo); protected:
nsSVGFEDiffuseLightingElement(nsINodeInfo* aNodeInfo)
: nsSVGFEDiffuseLightingElementBase(aNodeInfo) {}
public: public:
// interfaces: // interfaces:
@ -5146,14 +5028,6 @@ NS_INTERFACE_MAP_BEGIN(nsSVGFEDiffuseLightingElement)
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFEDiffuseLightingElement) NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFEDiffuseLightingElement)
NS_INTERFACE_MAP_END_INHERITING(nsSVGFEDiffuseLightingElementBase) NS_INTERFACE_MAP_END_INHERITING(nsSVGFEDiffuseLightingElementBase)
//----------------------------------------------------------------------
// Implementation
nsSVGFEDiffuseLightingElement::nsSVGFEDiffuseLightingElement(nsINodeInfo *aNodeInfo)
: nsSVGFEDiffuseLightingElementBase(aNodeInfo)
{
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// nsIDOMNode methods // nsIDOMNode methods
@ -5231,10 +5105,11 @@ typedef nsSVGFELightingElement nsSVGFESpecularLightingElementBase;
class nsSVGFESpecularLightingElement : public nsSVGFESpecularLightingElementBase, class nsSVGFESpecularLightingElement : public nsSVGFESpecularLightingElementBase,
public nsIDOMSVGFESpecularLightingElement public nsIDOMSVGFESpecularLightingElement
{ {
protected:
friend nsresult NS_NewSVGFESpecularLightingElement(nsIContent **aResult, friend nsresult NS_NewSVGFESpecularLightingElement(nsIContent **aResult,
nsINodeInfo *aNodeInfo); nsINodeInfo *aNodeInfo);
nsSVGFESpecularLightingElement(nsINodeInfo* aNodeInfo); protected:
nsSVGFESpecularLightingElement(nsINodeInfo* aNodeInfo)
: nsSVGFESpecularLightingElementBase(aNodeInfo) {}
public: public:
// interfaces: // interfaces:
@ -5277,14 +5152,6 @@ NS_INTERFACE_MAP_BEGIN(nsSVGFESpecularLightingElement)
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFESpecularLightingElement) NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFESpecularLightingElement)
NS_INTERFACE_MAP_END_INHERITING(nsSVGFESpecularLightingElementBase) NS_INTERFACE_MAP_END_INHERITING(nsSVGFESpecularLightingElementBase)
//----------------------------------------------------------------------
// Implementation
nsSVGFESpecularLightingElement::nsSVGFESpecularLightingElement(nsINodeInfo *aNodeInfo)
: nsSVGFESpecularLightingElementBase(aNodeInfo)
{
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// nsIDOMNode methods // nsIDOMNode methods
@ -5396,10 +5263,11 @@ class nsSVGFEUnimplementedMOZElement : public nsSVGFEUnimplementedMOZElementBase
public nsIDOMSVGFEUnimplementedMOZElement, public nsIDOMSVGFEUnimplementedMOZElement,
public nsISVGFilter public nsISVGFilter
{ {
protected:
friend nsresult NS_NewSVGFEUnimplementedMOZElement(nsIContent **aResult, friend nsresult NS_NewSVGFEUnimplementedMOZElement(nsIContent **aResult,
nsINodeInfo *aNodeInfo); nsINodeInfo *aNodeInfo);
nsSVGFEUnimplementedMOZElement(nsINodeInfo* aNodeInfo); protected:
nsSVGFEUnimplementedMOZElement(nsINodeInfo* aNodeInfo)
: nsSVGFEUnimplementedMOZElementBase(aNodeInfo) {}
public: public:
// interfaces: // interfaces:
@ -5441,14 +5309,6 @@ NS_INTERFACE_MAP_BEGIN(nsSVGFEUnimplementedMOZElement)
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFEUnimplementedMOZElement) NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFEUnimplementedMOZElement)
NS_INTERFACE_MAP_END_INHERITING(nsSVGFEUnimplementedMOZElementBase) NS_INTERFACE_MAP_END_INHERITING(nsSVGFEUnimplementedMOZElementBase)
//----------------------------------------------------------------------
// Implementation
nsSVGFEUnimplementedMOZElement::nsSVGFEUnimplementedMOZElement(nsINodeInfo *aNodeInfo)
: nsSVGFEUnimplementedMOZElementBase(aNodeInfo)
{
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// nsIDOMNode methods // nsIDOMNode methods

Просмотреть файл

@ -39,6 +39,7 @@
#include "nsSVGStylableElement.h" #include "nsSVGStylableElement.h"
#include "nsSVGLength2.h" #include "nsSVGLength2.h"
#include "nsIFrame.h"
class nsSVGFilterResource; class nsSVGFilterResource;
class nsIDOMSVGAnimatedString; class nsIDOMSVGAnimatedString;
@ -51,7 +52,7 @@ class nsSVGFE : public nsSVGFEBase
friend class nsSVGFilterInstance; friend class nsSVGFilterInstance;
protected: protected:
nsSVGFE(nsINodeInfo *aNodeInfo); nsSVGFE(nsINodeInfo *aNodeInfo) : nsSVGFEBase(aNodeInfo) {}
nsresult Init(); nsresult Init();
PRBool ScanDualValueAttribute(const nsAString& aValue, nsIAtom* aAttribute, PRBool ScanDualValueAttribute(const nsAString& aValue, nsIAtom* aAttribute,
@ -59,9 +60,6 @@ protected:
NumberInfo* aInfo1, NumberInfo* aInfo2, NumberInfo* aInfo1, NumberInfo* aInfo2,
nsAttrValue& aResult); nsAttrValue& aResult);
nsSVGFilterInstance::ColorModel
GetColorModel(nsSVGFilterInstance::ColorModel::AlphaChannel aAlphaChannel);
struct ScaleInfo { struct ScaleInfo {
nsRefPtr<gfxImageSurface> mRealSource; nsRefPtr<gfxImageSurface> mRealSource;
nsRefPtr<gfxImageSurface> mRealTarget; nsRefPtr<gfxImageSurface> mRealTarget;
@ -82,11 +80,35 @@ protected:
public: public:
nsSVGFilterInstance::ColorModel
GetColorModel(nsIDOMSVGAnimatedString* aIn) {
return nsSVGFilterInstance::ColorModel (
(OperatesOnSRGB(aIn) ?
nsSVGFilterInstance::ColorModel::SRGB :
nsSVGFilterInstance::ColorModel::LINEAR_RGB),
(OperatesOnPremultipledAlpha() ?
nsSVGFilterInstance::ColorModel::PREMULTIPLIED :
nsSVGFilterInstance::ColorModel::UNPREMULTIPLIED));
}
// See http://www.w3.org/TR/SVG/filters.html#FilterPrimitiveSubRegion
virtual PRBool SubregionIsUnionOfRegions() { return PR_TRUE; }
// interfaces: // interfaces:
NS_DECL_ISUPPORTS_INHERITED NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMSVGFILTERPRIMITIVESTANDARDATTRIBUTES NS_DECL_NSIDOMSVGFILTERPRIMITIVESTANDARDATTRIBUTES
protected: protected:
virtual PRBool OperatesOnPremultipledAlpha() { return PR_TRUE; }
virtual PRBool OperatesOnSRGB(nsIDOMSVGAnimatedString*) {
nsIFrame* frame = GetPrimaryFrame();
if (!frame) return PR_FALSE;
nsStyleContext* style = frame->GetStyleContext();
return style->GetStyleSVG()->mColorInterpolationFilters ==
NS_STYLE_COLOR_INTERPOLATION_SRGB;
}
// nsSVGElement specializations: // nsSVGElement specializations:
virtual LengthAttributesInfo GetLengthInfo(); virtual LengthAttributesInfo GetLengthInfo();