diff --git a/gfx/2d/FilterNodeSoftware.cpp b/gfx/2d/FilterNodeSoftware.cpp index bb111c511ef5..33585048c329 100644 --- a/gfx/2d/FilterNodeSoftware.cpp +++ b/gfx/2d/FilterNodeSoftware.cpp @@ -1460,6 +1460,9 @@ FilterNodeColorMatrixSoftware::RequestFromInputsForRect(const IntRect &aRect) IntRect FilterNodeColorMatrixSoftware::GetOutputRectInRect(const IntRect& aRect) { + if (mMatrix._54 > 0.0f) { + return aRect; + } return GetInputRectInRect(IN_COLOR_MATRIX_IN, aRect); } @@ -1808,7 +1811,10 @@ FilterNodeComponentTransferSoftware::RequestFromInputsForRect(const IntRect &aRe IntRect FilterNodeComponentTransferSoftware::GetOutputRectInRect(const IntRect& aRect) { - return GetInputRectInRect(IN_TRANSFER_IN, aRect); + if (mDisableA) { + return GetInputRectInRect(IN_TRANSFER_IN, aRect); + } + return aRect; } int32_t diff --git a/gfx/src/FilterSupport.cpp b/gfx/src/FilterSupport.cpp index 9a31822cad65..697d9dfe2215 100644 --- a/gfx/src/FilterSupport.cpp +++ b/gfx/src/FilterSupport.cpp @@ -1389,6 +1389,42 @@ FilterSupport::ComputeResultChangeRegion(const FilterDescription& aFilter, return resultChangeRegions[resultChangeRegions.Length() - 1]; } +static float +ResultOfZeroUnderTransferFunction(const AttributeMap& aFunctionAttributes) +{ + switch (aFunctionAttributes.GetUint(eComponentTransferFunctionType)) { + case SVG_FECOMPONENTTRANSFER_TYPE_TABLE: + { + const nsTArray& tableValues = + aFunctionAttributes.GetFloats(eComponentTransferFunctionTableValues); + if (tableValues.Length() < 2) { + return 0.0f; + } + return tableValues[0]; + } + + case SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE: + { + const nsTArray& tableValues = + aFunctionAttributes.GetFloats(eComponentTransferFunctionTableValues); + if (tableValues.Length() < 1) { + return 0.0f; + } + return tableValues[0]; + } + + case SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: + return aFunctionAttributes.GetFloat(eComponentTransferFunctionIntercept); + + case SVG_FECOMPONENTTRANSFER_TYPE_GAMMA: + return aFunctionAttributes.GetFloat(eComponentTransferFunctionOffset); + + case SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY: + default: + return 0.0f; + } +} + nsIntRegion FilterSupport::PostFilterExtentsForPrimitive(const FilterPrimitiveDescription& aDescription, const nsTArray& aInputExtents) @@ -1439,6 +1475,27 @@ FilterSupport::PostFilterExtentsForPrimitive(const FilterPrimitiveDescription& a return ThebesIntRect(aDescription.PrimitiveSubregion()); } + case PrimitiveType::ColorMatrix: + { + if (atts.GetUint(eColorMatrixType) == (uint32_t)SVG_FECOLORMATRIX_TYPE_MATRIX) { + const nsTArray& values = atts.GetFloats(eColorMatrixValues); + if (values[19] > 0.0f) { + return ThebesIntRect(aDescription.PrimitiveSubregion()); + } + } + return aInputExtents[0]; + } + + case PrimitiveType::ComponentTransfer: + { + AttributeMap functionAttributes = + atts.GetAttributeMap(eComponentTransferFunctionA); + if (ResultOfZeroUnderTransferFunction(functionAttributes) > 0.0f) { + return ThebesIntRect(aDescription.PrimitiveSubregion()); + } + return aInputExtents[0]; + } + case PrimitiveType::Turbulence: case PrimitiveType::Image: { diff --git a/layout/reftests/svg/filters/outside-sourcegraphic-1.svg b/layout/reftests/svg/filters/outside-sourcegraphic-1.svg new file mode 100644 index 000000000000..f360aa12fd0e --- /dev/null +++ b/layout/reftests/svg/filters/outside-sourcegraphic-1.svg @@ -0,0 +1,10 @@ + + + + + + + diff --git a/layout/reftests/svg/filters/outside-sourcegraphic-2.svg b/layout/reftests/svg/filters/outside-sourcegraphic-2.svg new file mode 100644 index 000000000000..6699d620b9be --- /dev/null +++ b/layout/reftests/svg/filters/outside-sourcegraphic-2.svg @@ -0,0 +1,13 @@ + + + + + + + diff --git a/layout/reftests/svg/filters/outside-sourcegraphic-3.svg b/layout/reftests/svg/filters/outside-sourcegraphic-3.svg new file mode 100644 index 000000000000..f8f6b363872c --- /dev/null +++ b/layout/reftests/svg/filters/outside-sourcegraphic-3.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + diff --git a/layout/reftests/svg/filters/outside-sourcegraphic-ref.svg b/layout/reftests/svg/filters/outside-sourcegraphic-ref.svg new file mode 100644 index 000000000000..a336d2215849 --- /dev/null +++ b/layout/reftests/svg/filters/outside-sourcegraphic-ref.svg @@ -0,0 +1,7 @@ + + + + diff --git a/layout/reftests/svg/filters/reftest.list b/layout/reftests/svg/filters/reftest.list index d5cdd1bed2a8..0fde197fdfd0 100644 --- a/layout/reftests/svg/filters/reftest.list +++ b/layout/reftests/svg/filters/reftest.list @@ -116,3 +116,7 @@ fuzzy(2,2659) skip-if(d2d) == feSpecularLighting-1.svg feSpecularLighting-1-ref. == fePointLight-zoomed-page.svg fePointLight-zoomed-page-ref.svg == feTurbulence-offset.svg feTurbulence-offset-ref.svg + +== outside-sourcegraphic-1.svg outside-sourcegraphic-ref.svg +== outside-sourcegraphic-2.svg outside-sourcegraphic-ref.svg +== outside-sourcegraphic-3.svg outside-sourcegraphic-ref.svg