From 4dab21f0abd3d3dde8281995476500d818a347f2 Mon Sep 17 00:00:00 2001 From: Robert Longson Date: Thu, 29 Sep 2011 15:03:21 +0100 Subject: [PATCH] Bug 630657 - masks should respect color-interpolation. r=jwatt --- content/svg/content/src/nsSVGMaskElement.cpp | 1 + layout/reftests/svg/mask-basic-02-ref.svg | 11 +++++++++++ layout/reftests/svg/mask-basic-02.svg | 17 +++++++++++++++++ layout/reftests/svg/reftest.list | 1 + layout/svg/base/src/nsSVGMaskFrame.cpp | 12 +++++++++++- layout/svg/base/src/nsSVGMaskFrame.h | 2 ++ 6 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 layout/reftests/svg/mask-basic-02-ref.svg create mode 100644 layout/reftests/svg/mask-basic-02.svg diff --git a/content/svg/content/src/nsSVGMaskElement.cpp b/content/svg/content/src/nsSVGMaskElement.cpp index 6e8f4372c7ca..46857b574174 100644 --- a/content/svg/content/src/nsSVGMaskElement.cpp +++ b/content/svg/content/src/nsSVGMaskElement.cpp @@ -157,6 +157,7 @@ nsSVGMaskElement::IsAttributeMapped(const nsIAtom* name) const sFiltersMap, sFontSpecificationMap, sGradientStopMap, + sGraphicsMap, sMarkersMap, sTextContentElementsMap, sViewportsMap diff --git a/layout/reftests/svg/mask-basic-02-ref.svg b/layout/reftests/svg/mask-basic-02-ref.svg new file mode 100644 index 000000000000..ac4e7f3f32bc --- /dev/null +++ b/layout/reftests/svg/mask-basic-02-ref.svg @@ -0,0 +1,11 @@ + + + + Reference that mask defaults to sRGB + + + + diff --git a/layout/reftests/svg/mask-basic-02.svg b/layout/reftests/svg/mask-basic-02.svg new file mode 100644 index 000000000000..71204df0e7af --- /dev/null +++ b/layout/reftests/svg/mask-basic-02.svg @@ -0,0 +1,17 @@ + + + + Testcase that mask defaults to sRGB + + + + + + + + + + diff --git a/layout/reftests/svg/reftest.list b/layout/reftests/svg/reftest.list index cbe068d19f51..015e98541f91 100644 --- a/layout/reftests/svg/reftest.list +++ b/layout/reftests/svg/reftest.list @@ -145,6 +145,7 @@ fails == inline-in-xul-basic-01.xul pass.svg == marker-attribute-01.svg pass.svg == marker-viewBox-01.svg marker-viewBox-01-ref.svg == mask-basic-01.svg pass.svg +== mask-basic-02.svg mask-basic-02-ref.svg == mask-containing-masked-content-01.svg pass.svg == mask-transformed-01.svg mask-transformed-01-ref.svg == nested-viewBox-01.svg pass.svg diff --git a/layout/svg/base/src/nsSVGMaskFrame.cpp b/layout/svg/base/src/nsSVGMaskFrame.cpp index 7102e97afbaa..c7589ffecffe 100644 --- a/layout/svg/base/src/nsSVGMaskFrame.cpp +++ b/layout/svg/base/src/nsSVGMaskFrame.cpp @@ -138,7 +138,10 @@ nsSVGMaskFrame::ComputeMaskAlpha(nsSVGRenderState *aContext, nsIntRect rect(0, 0, surfaceSize.width, surfaceSize.height); nsSVGUtils::UnPremultiplyImageDataAlpha(data, stride, rect); - nsSVGUtils::ConvertImageDataToLinearRGB(data, stride, rect); + if (GetStyleSVG()->mColorInterpolation == + NS_STYLE_COLOR_INTERPOLATION_LINEARRGB) { + nsSVGUtils::ConvertImageDataToLinearRGB(data, stride, rect); + } for (PRInt32 y = 0; y < surfaceSize.height; y++) for (PRInt32 x = 0; x < surfaceSize.width; x++) { @@ -160,6 +163,13 @@ nsSVGMaskFrame::ComputeMaskAlpha(nsSVGRenderState *aContext, return retval; } +/* virtual */ void +nsSVGMaskFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext) +{ + nsSVGEffects::InvalidateRenderingObservers(this); + nsSVGMaskFrameBase::DidSetStyleContext(aOldStyleContext); +} + NS_IMETHODIMP nsSVGMaskFrame::AttributeChanged(PRInt32 aNameSpaceID, nsIAtom* aAttribute, diff --git a/layout/svg/base/src/nsSVGMaskFrame.h b/layout/svg/base/src/nsSVGMaskFrame.h index f069b8d387d2..245645ca8167 100644 --- a/layout/svg/base/src/nsSVGMaskFrame.h +++ b/layout/svg/base/src/nsSVGMaskFrame.h @@ -63,6 +63,8 @@ public: const gfxMatrix &aMatrix, float aOpacity = 1.0f); + virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext); + NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRInt32 aModType);