diff --git a/dom/svg/SVGFEBlendElement.cpp b/dom/svg/SVGFEBlendElement.cpp index 48307ad5140f..210dd01fc1f1 100644 --- a/dom/svg/SVGFEBlendElement.cpp +++ b/dom/svg/SVGFEBlendElement.cpp @@ -89,11 +89,9 @@ SVGFEBlendElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance, nsTArray>& aInputImages) { uint32_t mode = mEnumAttributes[MODE].GetAnimValue(); - FilterPrimitiveDescription descr(PrimitiveType::Blend); BlendAttributes attributes; attributes.mBlendMode = mode; - descr.Attributes() = AsVariant(attributes); - return descr; + return FilterPrimitiveDescription(AsVariant(std::move(attributes))); } bool diff --git a/dom/svg/SVGFEColorMatrixElement.cpp b/dom/svg/SVGFEColorMatrixElement.cpp index 3164415740fd..da1b29c9bcba 100644 --- a/dom/svg/SVGFEColorMatrixElement.cpp +++ b/dom/svg/SVGFEColorMatrixElement.cpp @@ -94,7 +94,6 @@ SVGFEColorMatrixElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance, uint32_t type = mEnumAttributes[TYPE].GetAnimValue(); const SVGNumberList &values = mNumberListAttributes[VALUES].GetAnimValue(); - FilterPrimitiveDescription descr(PrimitiveType::ColorMatrix); ColorMatrixAttributes atts; if (!mNumberListAttributes[VALUES].IsExplicitlySet() && (type == SVG_FECOLORMATRIX_TYPE_MATRIX || @@ -114,8 +113,7 @@ SVGFEColorMatrixElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance, } } - descr.Attributes() = AsVariant(std::move(atts)); - return descr; + return FilterPrimitiveDescription(AsVariant(std::move(atts))); } bool diff --git a/dom/svg/SVGFEComponentTransferElement.cpp b/dom/svg/SVGFEComponentTransferElement.cpp index 9356a93de0ff..882446725021 100644 --- a/dom/svg/SVGFEComponentTransferElement.cpp +++ b/dom/svg/SVGFEComponentTransferElement.cpp @@ -72,7 +72,6 @@ SVGFEComponentTransferElement::GetPrimitiveDescription(nsSVGFilterInstance* aIns } } - FilterPrimitiveDescription descr(PrimitiveType::ComponentTransfer); ComponentTransferAttributes atts; for (int32_t i = 0; i < 4; i++) { if (childForChannel[i]) { @@ -82,8 +81,7 @@ SVGFEComponentTransferElement::GetPrimitiveDescription(nsSVGFilterInstance* aIns (uint8_t)SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY; } } - descr.Attributes() = AsVariant(std::move(atts)); - return descr; + return FilterPrimitiveDescription(AsVariant(std::move(atts))); } bool diff --git a/dom/svg/SVGFECompositeElement.cpp b/dom/svg/SVGFECompositeElement.cpp index 422015502b37..9fc0ca327c6e 100644 --- a/dom/svg/SVGFECompositeElement.cpp +++ b/dom/svg/SVGFECompositeElement.cpp @@ -115,7 +115,6 @@ SVGFECompositeElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance, const nsTArray& aInputsAreTainted, nsTArray>& aInputImages) { - FilterPrimitiveDescription descr(PrimitiveType::Composite); CompositeAttributes atts; uint32_t op = mEnumAttributes[OPERATOR].GetAnimValue(); atts.mOperator = op; @@ -126,8 +125,7 @@ SVGFECompositeElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance, atts.mCoefficients.AppendElements(k, 4); } - descr.Attributes() = AsVariant(std::move(atts)); - return descr; + return FilterPrimitiveDescription(AsVariant(std::move(atts))); } bool diff --git a/dom/svg/SVGFEConvolveMatrixElement.cpp b/dom/svg/SVGFEConvolveMatrixElement.cpp index 09994a902898..65db0f7c6e3a 100644 --- a/dom/svg/SVGFEConvolveMatrixElement.cpp +++ b/dom/svg/SVGFEConvolveMatrixElement.cpp @@ -172,7 +172,7 @@ SVGFEConvolveMatrixElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstan const nsTArray& aInputsAreTainted, nsTArray>& aInputImages) { - FilterPrimitiveDescription failureDescription(PrimitiveType::Empty); + FilterPrimitiveDescription failureDescription; const SVGNumberList &kernelMatrix = mNumberListAttributes[KERNELMATRIX].GetAnimValue(); @@ -238,7 +238,6 @@ SVGFEConvolveMatrixElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstan return failureDescription; } - FilterPrimitiveDescription descr(PrimitiveType::ConvolveMatrix); ConvolveMatrixAttributes atts; atts.mKernelSize = IntSize(orderX, orderY); atts.mKernelMatrix.AppendElements(&kernelMatrix[0], kmLength); @@ -249,8 +248,7 @@ SVGFEConvolveMatrixElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstan atts.mKernelUnitLength = kernelUnitLength; atts.mPreserveAlpha = preserveAlpha; - descr.Attributes() = AsVariant(std::move(atts)); - return descr; + return FilterPrimitiveDescription(AsVariant(std::move(atts))); } bool diff --git a/dom/svg/SVGFEDiffuseLightingElement.cpp b/dom/svg/SVGFEDiffuseLightingElement.cpp index 66def310f150..e7fbd5a64535 100644 --- a/dom/svg/SVGFEDiffuseLightingElement.cpp +++ b/dom/svg/SVGFEDiffuseLightingElement.cpp @@ -69,15 +69,13 @@ SVGFEDiffuseLightingElement::GetPrimitiveDescription(nsSVGFilterInstance* aInsta { float diffuseConstant = mNumberAttributes[DIFFUSE_CONSTANT].GetAnimValue(); - FilterPrimitiveDescription descr(PrimitiveType::DiffuseLighting); DiffuseLightingAttributes atts; atts.mLightingConstant = diffuseConstant; if (!AddLightingAttributes(&atts, aInstance)) { - return FilterPrimitiveDescription(PrimitiveType::Empty); + return FilterPrimitiveDescription(); } - descr.Attributes() = AsVariant(std::move(atts)); - return descr; + return FilterPrimitiveDescription(AsVariant(std::move(atts))); } bool diff --git a/dom/svg/SVGFEDisplacementMapElement.cpp b/dom/svg/SVGFEDisplacementMapElement.cpp index 349b7f6fb708..f898de2ca48f 100644 --- a/dom/svg/SVGFEDisplacementMapElement.cpp +++ b/dom/svg/SVGFEDisplacementMapElement.cpp @@ -100,24 +100,20 @@ SVGFEDisplacementMapElement::GetPrimitiveDescription(nsSVGFilterInstance* aInsta if (aInputsAreTainted[1]) { // If the map is tainted, refuse to apply the effect and act as a // pass-through filter instead, as required by the spec. - FilterPrimitiveDescription descr(PrimitiveType::Offset); OffsetAttributes atts; atts.mValue = IntPoint(0, 0); - descr.Attributes() = AsVariant(std::move(atts)); - return descr; + return FilterPrimitiveDescription(AsVariant(std::move(atts))); } float scale = aInstance->GetPrimitiveNumber(SVGContentUtils::XY, &mNumberAttributes[SCALE]); uint32_t xChannel = mEnumAttributes[CHANNEL_X].GetAnimValue(); uint32_t yChannel = mEnumAttributes[CHANNEL_Y].GetAnimValue(); - FilterPrimitiveDescription descr(PrimitiveType::DisplacementMap); DisplacementMapAttributes atts; atts.mScale = scale; atts.mXChannel = xChannel; atts.mYChannel = yChannel; - descr.Attributes() = AsVariant(std::move(atts)); - return descr; + return FilterPrimitiveDescription(AsVariant(std::move(atts))); } bool diff --git a/dom/svg/SVGFEDropShadowElement.cpp b/dom/svg/SVGFEDropShadowElement.cpp index 6dffb4f35fc9..b43cfdfa1e7c 100644 --- a/dom/svg/SVGFEDropShadowElement.cpp +++ b/dom/svg/SVGFEDropShadowElement.cpp @@ -95,7 +95,7 @@ SVGFEDropShadowElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance, &mNumberPairAttributes[STD_DEV], nsSVGNumberPair::eSecond); if (stdX < 0 || stdY < 0) { - return FilterPrimitiveDescription(PrimitiveType::Empty); + return FilterPrimitiveDescription(); } IntPoint offset(int32_t(aInstance->GetPrimitiveNumber( @@ -103,7 +103,6 @@ SVGFEDropShadowElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance, int32_t(aInstance->GetPrimitiveNumber( SVGContentUtils::Y, &mNumberAttributes[DY]))); - FilterPrimitiveDescription descr(PrimitiveType::DropShadow); DropShadowAttributes atts; atts.mStdDeviation = Size(stdX, stdY); atts.mOffset = offset; @@ -117,8 +116,7 @@ SVGFEDropShadowElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance, } else { atts.mColor = Color(); } - descr.Attributes() = AsVariant(std::move(atts)); - return descr; + return FilterPrimitiveDescription(AsVariant(std::move(atts))); } bool diff --git a/dom/svg/SVGFEFloodElement.cpp b/dom/svg/SVGFEFloodElement.cpp index 8bd71337cfef..b338a06152f9 100644 --- a/dom/svg/SVGFEFloodElement.cpp +++ b/dom/svg/SVGFEFloodElement.cpp @@ -40,7 +40,6 @@ SVGFEFloodElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance, const nsTArray& aInputsAreTainted, nsTArray>& aInputImages) { - FilterPrimitiveDescription descr(PrimitiveType::Flood); FloodAttributes atts; nsIFrame* frame = GetPrimaryFrame(); if (frame) { @@ -51,8 +50,7 @@ SVGFEFloodElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance, } else { atts.mColor = Color(); } - descr.Attributes() = AsVariant(std::move(atts)); - return descr; + return FilterPrimitiveDescription(AsVariant(std::move(atts))); } //---------------------------------------------------------------------- diff --git a/dom/svg/SVGFEGaussianBlurElement.cpp b/dom/svg/SVGFEGaussianBlurElement.cpp index 8bcb201f302b..23aa99d0d54b 100644 --- a/dom/svg/SVGFEGaussianBlurElement.cpp +++ b/dom/svg/SVGFEGaussianBlurElement.cpp @@ -77,14 +77,12 @@ SVGFEGaussianBlurElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance &mNumberPairAttributes[STD_DEV], nsSVGNumberPair::eSecond); if (stdX < 0 || stdY < 0) { - return FilterPrimitiveDescription(PrimitiveType::Empty); + return FilterPrimitiveDescription(); } - FilterPrimitiveDescription descr(PrimitiveType::GaussianBlur); GaussianBlurAttributes atts; atts.mStdDeviation = Size(stdX, stdY); - descr.Attributes() = AsVariant(std::move(atts)); - return descr; + return FilterPrimitiveDescription(AsVariant(std::move(atts))); } bool diff --git a/dom/svg/SVGFEImageElement.cpp b/dom/svg/SVGFEImageElement.cpp index ca3a87f69453..0609079a5be9 100644 --- a/dom/svg/SVGFEImageElement.cpp +++ b/dom/svg/SVGFEImageElement.cpp @@ -217,7 +217,7 @@ SVGFEImageElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance, { nsIFrame* frame = GetPrimaryFrame(); if (!frame) { - return FilterPrimitiveDescription(PrimitiveType::Empty); + return FilterPrimitiveDescription(); } nsCOMPtr currentRequest; @@ -236,7 +236,7 @@ SVGFEImageElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance, } if (!image) { - return FilterPrimitiveDescription(PrimitiveType::Empty); + return FilterPrimitiveDescription(); } IntSize nativeSize; @@ -252,7 +252,6 @@ SVGFEImageElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance, SamplingFilter samplingFilter = nsLayoutUtils::GetSamplingFilterForFrame(frame); - FilterPrimitiveDescription descr(PrimitiveType::Image); ImageAttributes atts; atts.mFilter = (uint32_t)samplingFilter; atts.mTransform = TM; @@ -261,9 +260,7 @@ SVGFEImageElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance, size_t imageIndex = aInputImages.Length(); aInputImages.AppendElement(image); atts.mInputIndex = (uint32_t)imageIndex; - descr.Attributes() = AsVariant(std::move(atts)); - - return descr; + return FilterPrimitiveDescription(AsVariant(std::move(atts))); } bool diff --git a/dom/svg/SVGFEMergeElement.cpp b/dom/svg/SVGFEMergeElement.cpp index 49a0a82daaed..05e653724a58 100644 --- a/dom/svg/SVGFEMergeElement.cpp +++ b/dom/svg/SVGFEMergeElement.cpp @@ -34,7 +34,7 @@ SVGFEMergeElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance, const nsTArray& aInputsAreTainted, nsTArray>& aInputImages) { - return FilterPrimitiveDescription(PrimitiveType::Merge); + return FilterPrimitiveDescription(AsVariant(MergeAttributes())); } void diff --git a/dom/svg/SVGFEMorphologyElement.cpp b/dom/svg/SVGFEMorphologyElement.cpp index 73e0e1c5295f..e093e06740e0 100644 --- a/dom/svg/SVGFEMorphologyElement.cpp +++ b/dom/svg/SVGFEMorphologyElement.cpp @@ -120,12 +120,10 @@ SVGFEMorphologyElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance, { int32_t rx, ry; GetRXY(&rx, &ry, *aInstance); - FilterPrimitiveDescription descr(PrimitiveType::Morphology); MorphologyAttributes atts; atts.mRadii = Size(rx, ry); atts.mOperator = (uint32_t)mEnumAttributes[OPERATOR].GetAnimValue(); - descr.Attributes() = AsVariant(std::move(atts)); - return descr; + return FilterPrimitiveDescription(AsVariant(std::move(atts))); } bool diff --git a/dom/svg/SVGFEOffsetElement.cpp b/dom/svg/SVGFEOffsetElement.cpp index 4f545cff386b..4e7fcbb10e99 100644 --- a/dom/svg/SVGFEOffsetElement.cpp +++ b/dom/svg/SVGFEOffsetElement.cpp @@ -66,15 +66,13 @@ SVGFEOffsetElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance, const nsTArray& aInputsAreTainted, nsTArray>& aInputImages) { - FilterPrimitiveDescription descr(PrimitiveType::Offset); OffsetAttributes atts; IntPoint offset(int32_t(aInstance->GetPrimitiveNumber( SVGContentUtils::X, &mNumberAttributes[DX])), int32_t(aInstance->GetPrimitiveNumber( SVGContentUtils::Y, &mNumberAttributes[DY]))); atts.mValue = offset; - descr.Attributes() = AsVariant(std::move(atts)); - return descr; + return FilterPrimitiveDescription(AsVariant(std::move(atts))); } bool diff --git a/dom/svg/SVGFESpecularLightingElement.cpp b/dom/svg/SVGFESpecularLightingElement.cpp index b008d1241fa5..14f1af278bb3 100644 --- a/dom/svg/SVGFESpecularLightingElement.cpp +++ b/dom/svg/SVGFESpecularLightingElement.cpp @@ -79,19 +79,17 @@ SVGFESpecularLightingElement::GetPrimitiveDescription(nsSVGFilterInstance* aInst // specification defined range (15.22) if (specularExponent < 1 || specularExponent > 128) { - return FilterPrimitiveDescription(PrimitiveType::Empty); + return FilterPrimitiveDescription(); } - FilterPrimitiveDescription descr(PrimitiveType::SpecularLighting); SpecularLightingAttributes atts; atts.mLightingConstant = specularConstant; atts.mSpecularExponent = specularExponent; if (!AddLightingAttributes(static_cast(&atts), aInstance)) { - return FilterPrimitiveDescription(PrimitiveType::Empty); + return FilterPrimitiveDescription(); } - descr.Attributes() = AsVariant(std::move(atts)); - return descr; + return FilterPrimitiveDescription(AsVariant(std::move(atts))); } bool diff --git a/dom/svg/SVGFETileElement.cpp b/dom/svg/SVGFETileElement.cpp index 0b39a8a91067..46419887b344 100644 --- a/dom/svg/SVGFETileElement.cpp +++ b/dom/svg/SVGFETileElement.cpp @@ -54,7 +54,7 @@ SVGFETileElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance, const nsTArray& aInputsAreTainted, nsTArray>& aInputImages) { - return FilterPrimitiveDescription(PrimitiveType::Tile); + return FilterPrimitiveDescription(AsVariant(TileAttributes())); } bool diff --git a/dom/svg/SVGFETurbulenceElement.cpp b/dom/svg/SVGFETurbulenceElement.cpp index 6f0f98c87d1f..108cbeb5eca6 100644 --- a/dom/svg/SVGFETurbulenceElement.cpp +++ b/dom/svg/SVGFETurbulenceElement.cpp @@ -136,13 +136,11 @@ SVGFETurbulenceElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance, // A base frequency of zero results in transparent black for // type="turbulence" and in 50% alpha 50% gray for type="fractalNoise". if (type == SVG_TURBULENCE_TYPE_TURBULENCE) { - return FilterPrimitiveDescription(PrimitiveType::Empty); + return FilterPrimitiveDescription(); } - FilterPrimitiveDescription descr(PrimitiveType::Flood); FloodAttributes atts; atts.mColor = Color(0.5, 0.5, 0.5, 0.5); - descr.Attributes() = AsVariant(std::move(atts)); - return descr; + return FilterPrimitiveDescription(AsVariant(std::move(atts))); } // We interpret the base frequency as relative to user space units. In other @@ -162,7 +160,6 @@ SVGFETurbulenceElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance, fY == 0 ? 0 : (1 / firstPeriodInFilterSpace.height)); gfxPoint offset = firstPeriodInFilterSpace.TopLeft(); - FilterPrimitiveDescription descr(PrimitiveType::Turbulence); TurbulenceAttributes atts; atts.mOffset = IntPoint::Truncate(offset.x, offset.y); atts.mBaseFrequency = frequencyInFilterSpace; @@ -170,8 +167,7 @@ SVGFETurbulenceElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance, atts.mOctaves = octaves; atts.mStitchable = stitch == SVG_STITCHTYPE_STITCH; atts.mType = type; - descr.Attributes() = AsVariant(std::move(atts)); - return descr; + return FilterPrimitiveDescription(AsVariant(std::move(atts))); } bool diff --git a/gfx/ipc/GfxMessageUtils.h b/gfx/ipc/GfxMessageUtils.h index 67e4321fabd2..6618ba039fbe 100644 --- a/gfx/ipc/GfxMessageUtils.h +++ b/gfx/ipc/GfxMessageUtils.h @@ -253,14 +253,6 @@ struct ParamTraits mozilla::gfx::FeatureStatus::LAST> {}; -template <> -struct ParamTraits - : public ContiguousEnumSerializer< - mozilla::gfx::PrimitiveType, - mozilla::gfx::PrimitiveType::Empty, - mozilla::gfx::PrimitiveType::Max> -{}; - template <> struct ParamTraits : public ContiguousEnumSerializer< @@ -1181,7 +1173,6 @@ struct ParamTraits static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.Type()); WriteParam(aMsg, aParam.PrimitiveSubregion()); WriteParam(aMsg, aParam.FilterSpaceBounds()); WriteParam(aMsg, aParam.IsTainted()); @@ -1196,14 +1187,12 @@ struct ParamTraits static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { - mozilla::gfx::PrimitiveType type; mozilla::gfx::IntRect primitiveSubregion; mozilla::gfx::IntRect filterSpaceBounds; bool isTainted = false; mozilla::gfx::ColorSpace outputColorSpace; size_t numberOfInputs = 0; - if (!ReadParam(aMsg, aIter, &type) || - !ReadParam(aMsg, aIter, &primitiveSubregion) || + if (!ReadParam(aMsg, aIter, &primitiveSubregion) || !ReadParam(aMsg, aIter, &filterSpaceBounds) || !ReadParam(aMsg, aIter, &isTainted) || !ReadParam(aMsg, aIter, &outputColorSpace) || @@ -1211,7 +1200,6 @@ struct ParamTraits return false; } - aResult->SetType(type); aResult->SetPrimitiveSubregion(primitiveSubregion); aResult->SetFilterSpaceBounds(filterSpaceBounds); aResult->SetIsTainted(isTainted); diff --git a/gfx/src/FilterSupport.cpp b/gfx/src/FilterSupport.cpp index 2856d4808917..348c806bdef5 100644 --- a/gfx/src/FilterSupport.cpp +++ b/gfx/src/FilterSupport.cpp @@ -1091,7 +1091,7 @@ FilterNodeFromPrimitiveDescription(const FilterPrimitiveDescription& aDescriptio already_AddRefed match(const DiffuseLightingAttributes& aLighting) { bool isSpecular = - mDescription.Type() == PrimitiveType::SpecularLighting; + mDescription.Attributes().is(); if (aLighting.mLightType == LightType::None) { return nullptr; @@ -1230,28 +1230,25 @@ InputAlphaModelForPrimitive(const FilterPrimitiveDescription& aDescr, int32_t aInputIndex, AlphaModel aOriginalAlphaModel) { - switch (aDescr.Type()) { - case PrimitiveType::Tile: - case PrimitiveType::Offset: - case PrimitiveType::ToAlpha: + const PrimitiveAttributes& atts = aDescr.Attributes(); + if (atts.is() || + atts.is() || + atts.is()) { return aOriginalAlphaModel; - - case PrimitiveType::ColorMatrix: - case PrimitiveType::ComponentTransfer: - return AlphaModel::Unpremultiplied; - - case PrimitiveType::DisplacementMap: - return aInputIndex == 0 ? - AlphaModel::Premultiplied : AlphaModel::Unpremultiplied; - - case PrimitiveType::ConvolveMatrix: - MOZ_ASSERT(aDescr.Attributes().is()); - return aDescr.Attributes().as().mPreserveAlpha ? - AlphaModel::Unpremultiplied : AlphaModel::Premultiplied; - - default: - return AlphaModel::Premultiplied; } + if (atts.is() || + atts.is()) { + return AlphaModel::Unpremultiplied; + } + if (atts.is()) { + return aInputIndex == 0 ? + AlphaModel::Premultiplied : AlphaModel::Unpremultiplied; + } + if (atts.is()) { + return atts.as().mPreserveAlpha ? + AlphaModel::Unpremultiplied : AlphaModel::Premultiplied; + } + return AlphaModel::Premultiplied; } static AlphaModel @@ -2040,24 +2037,21 @@ FilterSupport::ComputeSourceNeededRegions(const FilterDescription& aFilter, // FilterPrimitiveDescription FilterPrimitiveDescription::FilterPrimitiveDescription() - : mType(PrimitiveType::Empty) - , mAttributes(EmptyAttributes()) + : mAttributes(EmptyAttributes()) , mOutputColorSpace(ColorSpace::SRGB) , mIsTainted(false) { } -FilterPrimitiveDescription::FilterPrimitiveDescription(PrimitiveType aType) - : mType(aType) - , mAttributes(EmptyAttributes()) +FilterPrimitiveDescription::FilterPrimitiveDescription(PrimitiveAttributes&& aAttributes) + : mAttributes(std::move(aAttributes)) , mOutputColorSpace(ColorSpace::SRGB) , mIsTainted(false) { } FilterPrimitiveDescription::FilterPrimitiveDescription(const FilterPrimitiveDescription& aOther) - : mType(aOther.mType) - , mAttributes(aOther.mAttributes) + : mAttributes(aOther.mAttributes) , mInputPrimitives(aOther.mInputPrimitives) , mFilterPrimitiveSubregion(aOther.mFilterPrimitiveSubregion) , mFilterSpaceBounds(aOther.mFilterSpaceBounds) @@ -2071,7 +2065,6 @@ FilterPrimitiveDescription& FilterPrimitiveDescription::operator=(const FilterPrimitiveDescription& aOther) { if (this != &aOther) { - mType = aOther.mType; mAttributes = aOther.mAttributes; mInputPrimitives = aOther.mInputPrimitives; mFilterPrimitiveSubregion = aOther.mFilterPrimitiveSubregion; @@ -2084,8 +2077,7 @@ FilterPrimitiveDescription::operator=(const FilterPrimitiveDescription& aOther) } FilterPrimitiveDescription::FilterPrimitiveDescription(FilterPrimitiveDescription&& aOther) - : mType(aOther.mType) - , mAttributes(std::move(aOther.mAttributes)) + : mAttributes(std::move(aOther.mAttributes)) , mInputPrimitives(std::move(aOther.mInputPrimitives)) , mFilterPrimitiveSubregion(aOther.mFilterPrimitiveSubregion) , mFilterSpaceBounds(aOther.mFilterSpaceBounds) @@ -2099,7 +2091,6 @@ FilterPrimitiveDescription& FilterPrimitiveDescription::operator=(FilterPrimitiveDescription&& aOther) { if (this != &aOther) { - mType = aOther.mType; mAttributes = std::move(aOther.mAttributes); mInputPrimitives = std::move(aOther.mInputPrimitives); mFilterPrimitiveSubregion = aOther.mFilterPrimitiveSubregion; @@ -2114,8 +2105,7 @@ FilterPrimitiveDescription::operator=(FilterPrimitiveDescription&& aOther) bool FilterPrimitiveDescription::operator==(const FilterPrimitiveDescription& aOther) const { - return mType == aOther.mType && - mFilterPrimitiveSubregion.IsEqualInterior(aOther.mFilterPrimitiveSubregion) && + return mFilterPrimitiveSubregion.IsEqualInterior(aOther.mFilterPrimitiveSubregion) && mFilterSpaceBounds.IsEqualInterior(aOther.mFilterSpaceBounds) && mOutputColorSpace == aOther.mOutputColorSpace && mIsTainted == aOther.mIsTainted && diff --git a/gfx/src/FilterSupport.h b/gfx/src/FilterSupport.h index 9f2690c9b1e0..5afc12dacbc1 100644 --- a/gfx/src/FilterSupport.h +++ b/gfx/src/FilterSupport.h @@ -94,30 +94,6 @@ struct FilterAttribute; // Limits const float kMaxStdDeviation = 500; -enum class PrimitiveType { - Empty = 0, - Blend, - Morphology, - ColorMatrix, - Flood, - Tile, - ComponentTransfer, - Opacity, - ConvolveMatrix, - Offset, - DisplacementMap, - Turbulence, - Composite, - Merge, - Image, - GaussianBlur, - DropShadow, - DiffuseLighting, - SpecularLighting, - ToAlpha, - Max -}; - // Simple PrimitiveAttributes: struct EmptyAttributes { @@ -468,14 +444,12 @@ public: }; FilterPrimitiveDescription(); - explicit FilterPrimitiveDescription(PrimitiveType aType); + explicit FilterPrimitiveDescription(PrimitiveAttributes&& aAttributes); FilterPrimitiveDescription(FilterPrimitiveDescription&& aOther); FilterPrimitiveDescription& operator=(FilterPrimitiveDescription&& aOther); FilterPrimitiveDescription(const FilterPrimitiveDescription& aOther); FilterPrimitiveDescription& operator=(const FilterPrimitiveDescription& aOther); - PrimitiveType Type() const { return mType; } - void SetType(PrimitiveType aType) { mType = aType; } const PrimitiveAttributes& Attributes() const { return mAttributes; } PrimitiveAttributes& Attributes() { return mAttributes; } @@ -537,7 +511,6 @@ public: } private: - PrimitiveType mType; PrimitiveAttributes mAttributes; nsTArray mInputPrimitives; IntRect mFilterPrimitiveSubregion; diff --git a/layout/svg/nsCSSFilterInstance.cpp b/layout/svg/nsCSSFilterInstance.cpp index 3359c86e4fd5..b91f35ca6868 100644 --- a/layout/svg/nsCSSFilterInstance.cpp +++ b/layout/svg/nsCSSFilterInstance.cpp @@ -44,68 +44,38 @@ nsresult nsCSSFilterInstance::BuildPrimitives(nsTArray& aPrimitiveDescrs, bool aInputIsTainted) { - FilterPrimitiveDescription descr; + FilterPrimitiveDescription descr = CreatePrimitiveDescription(aPrimitiveDescrs, + aInputIsTainted); nsresult result; - switch(mFilter.GetType()) { case NS_STYLE_FILTER_BLUR: - descr = CreatePrimitiveDescription(PrimitiveType::GaussianBlur, - aPrimitiveDescrs, - aInputIsTainted); result = SetAttributesForBlur(descr); break; case NS_STYLE_FILTER_BRIGHTNESS: - descr = CreatePrimitiveDescription(PrimitiveType::ComponentTransfer, - aPrimitiveDescrs, - aInputIsTainted); result = SetAttributesForBrightness(descr); break; case NS_STYLE_FILTER_CONTRAST: - descr = CreatePrimitiveDescription(PrimitiveType::ComponentTransfer, - aPrimitiveDescrs, - aInputIsTainted); result = SetAttributesForContrast(descr); break; case NS_STYLE_FILTER_DROP_SHADOW: - descr = CreatePrimitiveDescription(PrimitiveType::DropShadow, - aPrimitiveDescrs, - aInputIsTainted); result = SetAttributesForDropShadow(descr); break; case NS_STYLE_FILTER_GRAYSCALE: - descr = CreatePrimitiveDescription(PrimitiveType::ColorMatrix, - aPrimitiveDescrs, - aInputIsTainted); result = SetAttributesForGrayscale(descr); break; case NS_STYLE_FILTER_HUE_ROTATE: - descr = CreatePrimitiveDescription(PrimitiveType::ColorMatrix, - aPrimitiveDescrs, - aInputIsTainted); result = SetAttributesForHueRotate(descr); break; case NS_STYLE_FILTER_INVERT: - descr = CreatePrimitiveDescription(PrimitiveType::ComponentTransfer, - aPrimitiveDescrs, - aInputIsTainted); result = SetAttributesForInvert(descr); break; case NS_STYLE_FILTER_OPACITY: - descr = CreatePrimitiveDescription(PrimitiveType::Opacity, - aPrimitiveDescrs, - aInputIsTainted); result = SetAttributesForOpacity(descr); break; case NS_STYLE_FILTER_SATURATE: - descr = CreatePrimitiveDescription(PrimitiveType::ColorMatrix, - aPrimitiveDescrs, - aInputIsTainted); result = SetAttributesForSaturate(descr); break; case NS_STYLE_FILTER_SEPIA: - descr = CreatePrimitiveDescription(PrimitiveType::ColorMatrix, - aPrimitiveDescrs, - aInputIsTainted); result = SetAttributesForSepia(descr); break; default: @@ -127,10 +97,9 @@ nsCSSFilterInstance::BuildPrimitives(nsTArray& aPrim } FilterPrimitiveDescription -nsCSSFilterInstance::CreatePrimitiveDescription(PrimitiveType aType, - const nsTArray& aPrimitiveDescrs, +nsCSSFilterInstance::CreatePrimitiveDescription(const nsTArray& aPrimitiveDescrs, bool aInputIsTainted) { - FilterPrimitiveDescription descr(aType); + FilterPrimitiveDescription descr; int32_t inputIndex = GetLastResultIndex(aPrimitiveDescrs); descr.SetInputPrimitive(0, inputIndex); descr.SetIsTainted(inputIndex < 0 ? aInputIsTainted : aPrimitiveDescrs[inputIndex].IsTainted()); diff --git a/layout/svg/nsCSSFilterInstance.h b/layout/svg/nsCSSFilterInstance.h index a9581bcf80ed..25eac50fd0bd 100644 --- a/layout/svg/nsCSSFilterInstance.h +++ b/layout/svg/nsCSSFilterInstance.h @@ -27,7 +27,6 @@ class nsCSSFilterInstance typedef mozilla::gfx::Color Color; typedef mozilla::gfx::FilterPrimitiveDescription FilterPrimitiveDescription; typedef mozilla::gfx::IntPoint IntPoint; - typedef mozilla::gfx::PrimitiveType PrimitiveType; typedef mozilla::gfx::Size Size; public: @@ -67,8 +66,7 @@ private: * Returns a new FilterPrimitiveDescription with its basic properties set up. * See the comment above BuildPrimitives for the meaning of aInputIsTainted. */ - FilterPrimitiveDescription CreatePrimitiveDescription(PrimitiveType aType, - const nsTArray& aPrimitiveDescrs, + FilterPrimitiveDescription CreatePrimitiveDescription(const nsTArray& aPrimitiveDescrs, bool aInputIsTainted); /** diff --git a/layout/svg/nsSVGFilterInstance.cpp b/layout/svg/nsSVGFilterInstance.cpp index 1c284e0ed5ef..bf94ae2179ee 100644 --- a/layout/svg/nsSVGFilterInstance.cpp +++ b/layout/svg/nsSVGFilterInstance.cpp @@ -309,7 +309,7 @@ nsSVGFilterInstance::GetOrCreateSourceAlphaIndex(nsTArray