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

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

@ -39,6 +39,7 @@
#include "nsSVGStylableElement.h"
#include "nsSVGLength2.h"
#include "nsIFrame.h"
class nsSVGFilterResource;
class nsIDOMSVGAnimatedString;
@ -51,7 +52,7 @@ class nsSVGFE : public nsSVGFEBase
friend class nsSVGFilterInstance;
protected:
nsSVGFE(nsINodeInfo *aNodeInfo);
nsSVGFE(nsINodeInfo *aNodeInfo) : nsSVGFEBase(aNodeInfo) {}
nsresult Init();
PRBool ScanDualValueAttribute(const nsAString& aValue, nsIAtom* aAttribute,
@ -59,9 +60,6 @@ protected:
NumberInfo* aInfo1, NumberInfo* aInfo2,
nsAttrValue& aResult);
nsSVGFilterInstance::ColorModel
GetColorModel(nsSVGFilterInstance::ColorModel::AlphaChannel aAlphaChannel);
struct ScaleInfo {
nsRefPtr<gfxImageSurface> mRealSource;
nsRefPtr<gfxImageSurface> mRealTarget;
@ -82,11 +80,35 @@ protected:
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:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMSVGFILTERPRIMITIVESTANDARDATTRIBUTES
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:
virtual LengthAttributesInfo GetLengthInfo();