mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1417699 - Remove PrimitiveType enum r=mstange
Ran into a couple of test failures because I was leaving mAttributes empty for empty things like MergeAttributes, and only setting mType. Since mType is now redundant though, and since it's the only use of PrimitiveType, I figured I'd just remove it entirely. Depends on D4900 Differential Revision: https://phabricator.services.mozilla.com/D6209 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
e79792a58a
commit
f0ed0dee36
@ -89,11 +89,9 @@ SVGFEBlendElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
|
||||
nsTArray<RefPtr<SourceSurface>>& 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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -115,7 +115,6 @@ SVGFECompositeElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
|
||||
const nsTArray<bool>& aInputsAreTainted,
|
||||
nsTArray<RefPtr<SourceSurface>>& 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
|
||||
|
@ -172,7 +172,7 @@ SVGFEConvolveMatrixElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstan
|
||||
const nsTArray<bool>& aInputsAreTainted,
|
||||
nsTArray<RefPtr<SourceSurface>>& 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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -40,7 +40,6 @@ SVGFEFloodElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
|
||||
const nsTArray<bool>& aInputsAreTainted,
|
||||
nsTArray<RefPtr<SourceSurface>>& 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)));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -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
|
||||
|
@ -217,7 +217,7 @@ SVGFEImageElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
|
||||
{
|
||||
nsIFrame* frame = GetPrimaryFrame();
|
||||
if (!frame) {
|
||||
return FilterPrimitiveDescription(PrimitiveType::Empty);
|
||||
return FilterPrimitiveDescription();
|
||||
}
|
||||
|
||||
nsCOMPtr<imgIRequest> 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
|
||||
|
@ -34,7 +34,7 @@ SVGFEMergeElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
|
||||
const nsTArray<bool>& aInputsAreTainted,
|
||||
nsTArray<RefPtr<SourceSurface>>& aInputImages)
|
||||
{
|
||||
return FilterPrimitiveDescription(PrimitiveType::Merge);
|
||||
return FilterPrimitiveDescription(AsVariant(MergeAttributes()));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -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
|
||||
|
@ -66,15 +66,13 @@ SVGFEOffsetElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
|
||||
const nsTArray<bool>& aInputsAreTainted,
|
||||
nsTArray<RefPtr<SourceSurface>>& 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
|
||||
|
@ -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<DiffuseLightingAttributes*>(&atts), aInstance)) {
|
||||
return FilterPrimitiveDescription(PrimitiveType::Empty);
|
||||
return FilterPrimitiveDescription();
|
||||
}
|
||||
|
||||
descr.Attributes() = AsVariant(std::move(atts));
|
||||
return descr;
|
||||
return FilterPrimitiveDescription(AsVariant(std::move(atts)));
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -54,7 +54,7 @@ SVGFETileElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
|
||||
const nsTArray<bool>& aInputsAreTainted,
|
||||
nsTArray<RefPtr<SourceSurface>>& aInputImages)
|
||||
{
|
||||
return FilterPrimitiveDescription(PrimitiveType::Tile);
|
||||
return FilterPrimitiveDescription(AsVariant(TileAttributes()));
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -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
|
||||
|
@ -253,14 +253,6 @@ struct ParamTraits<mozilla::gfx::FeatureStatus>
|
||||
mozilla::gfx::FeatureStatus::LAST>
|
||||
{};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::gfx::PrimitiveType>
|
||||
: public ContiguousEnumSerializer<
|
||||
mozilla::gfx::PrimitiveType,
|
||||
mozilla::gfx::PrimitiveType::Empty,
|
||||
mozilla::gfx::PrimitiveType::Max>
|
||||
{};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::gfx::LightType>
|
||||
: public ContiguousEnumSerializer<
|
||||
@ -1181,7 +1173,6 @@ struct ParamTraits<mozilla::gfx::FilterPrimitiveDescription>
|
||||
|
||||
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<mozilla::gfx::FilterPrimitiveDescription>
|
||||
|
||||
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<mozilla::gfx::FilterPrimitiveDescription>
|
||||
return false;
|
||||
}
|
||||
|
||||
aResult->SetType(type);
|
||||
aResult->SetPrimitiveSubregion(primitiveSubregion);
|
||||
aResult->SetFilterSpaceBounds(filterSpaceBounds);
|
||||
aResult->SetIsTainted(isTainted);
|
||||
|
@ -1091,7 +1091,7 @@ FilterNodeFromPrimitiveDescription(const FilterPrimitiveDescription& aDescriptio
|
||||
already_AddRefed<FilterNode> match(const DiffuseLightingAttributes& aLighting)
|
||||
{
|
||||
bool isSpecular =
|
||||
mDescription.Type() == PrimitiveType::SpecularLighting;
|
||||
mDescription.Attributes().is<SpecularLightingAttributes>();
|
||||
|
||||
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<TileAttributes>() ||
|
||||
atts.is<OffsetAttributes>() ||
|
||||
atts.is<ToAlphaAttributes>()) {
|
||||
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<ConvolveMatrixAttributes>());
|
||||
return aDescr.Attributes().as<ConvolveMatrixAttributes>().mPreserveAlpha ?
|
||||
AlphaModel::Unpremultiplied : AlphaModel::Premultiplied;
|
||||
|
||||
default:
|
||||
return AlphaModel::Premultiplied;
|
||||
}
|
||||
if (atts.is<ColorMatrixAttributes>() ||
|
||||
atts.is<ComponentTransferAttributes>()) {
|
||||
return AlphaModel::Unpremultiplied;
|
||||
}
|
||||
if (atts.is<DisplacementMapAttributes>()) {
|
||||
return aInputIndex == 0 ?
|
||||
AlphaModel::Premultiplied : AlphaModel::Unpremultiplied;
|
||||
}
|
||||
if (atts.is<ConvolveMatrixAttributes>()) {
|
||||
return atts.as<ConvolveMatrixAttributes>().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 &&
|
||||
|
@ -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<int32_t> mInputPrimitives;
|
||||
IntRect mFilterPrimitiveSubregion;
|
||||
|
@ -44,68 +44,38 @@ nsresult
|
||||
nsCSSFilterInstance::BuildPrimitives(nsTArray<FilterPrimitiveDescription>& 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<FilterPrimitiveDescription>& aPrim
|
||||
}
|
||||
|
||||
FilterPrimitiveDescription
|
||||
nsCSSFilterInstance::CreatePrimitiveDescription(PrimitiveType aType,
|
||||
const nsTArray<FilterPrimitiveDescription>& aPrimitiveDescrs,
|
||||
nsCSSFilterInstance::CreatePrimitiveDescription(const nsTArray<FilterPrimitiveDescription>& 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());
|
||||
|
@ -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<FilterPrimitiveDescription>& aPrimitiveDescrs,
|
||||
FilterPrimitiveDescription CreatePrimitiveDescription(const nsTArray<FilterPrimitiveDescription>& aPrimitiveDescrs,
|
||||
bool aInputIsTainted);
|
||||
|
||||
/**
|
||||
|
@ -309,7 +309,7 @@ nsSVGFilterInstance::GetOrCreateSourceAlphaIndex(nsTArray<FilterPrimitiveDescrip
|
||||
|
||||
// Otherwise, create a primitive description to turn the previous filter's
|
||||
// output into a SourceAlpha input.
|
||||
FilterPrimitiveDescription descr(PrimitiveType::ToAlpha);
|
||||
FilterPrimitiveDescription descr(AsVariant(ToAlphaAttributes()));
|
||||
descr.SetInputPrimitive(0, mSourceGraphicIndex);
|
||||
|
||||
const FilterPrimitiveDescription& sourcePrimitiveDescr =
|
||||
@ -321,7 +321,7 @@ nsSVGFilterInstance::GetOrCreateSourceAlphaIndex(nsTArray<FilterPrimitiveDescrip
|
||||
descr.SetInputColorSpace(0, colorSpace);
|
||||
descr.SetOutputColorSpace(colorSpace);
|
||||
|
||||
aPrimitiveDescrs.AppendElement(descr);
|
||||
aPrimitiveDescrs.AppendElement(std::move(descr));
|
||||
mSourceAlphaIndex = aPrimitiveDescrs.Length() - 1;
|
||||
mSourceAlphaAvailable = true;
|
||||
return mSourceAlphaIndex;
|
||||
|
Loading…
Reference in New Issue
Block a user