From 63e23566cf442962543320c98b049f21c4e13157 Mon Sep 17 00:00:00 2001 From: Robert Longson Date: Wed, 30 Jun 2010 21:24:53 +0100 Subject: [PATCH] Bug 573687 - Clamp radial gradients with small radii correctly. r=jwatt --- layout/reftests/svg/radialGradient-basic-03-ref.svg | 5 +++++ layout/reftests/svg/radialGradient-basic-03.svg | 5 +++++ layout/svg/base/src/nsSVGGradientFrame.cpp | 13 +++++-------- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/layout/reftests/svg/radialGradient-basic-03-ref.svg b/layout/reftests/svg/radialGradient-basic-03-ref.svg index aabc31d420ce..954099afe7e6 100644 --- a/layout/reftests/svg/radialGradient-basic-03-ref.svg +++ b/layout/reftests/svg/radialGradient-basic-03-ref.svg @@ -25,10 +25,15 @@ + + + + + \ No newline at end of file diff --git a/layout/reftests/svg/radialGradient-basic-03.svg b/layout/reftests/svg/radialGradient-basic-03.svg index 8d2add380816..82905de3dd3c 100644 --- a/layout/reftests/svg/radialGradient-basic-03.svg +++ b/layout/reftests/svg/radialGradient-basic-03.svg @@ -25,10 +25,15 @@ + + + + + \ No newline at end of file diff --git a/layout/svg/base/src/nsSVGGradientFrame.cpp b/layout/svg/base/src/nsSVGGradientFrame.cpp index 2ad461d3b61c..395f5bbd9d6f 100644 --- a/layout/svg/base/src/nsSVGGradientFrame.cpp +++ b/layout/svg/base/src/nsSVGGradientFrame.cpp @@ -587,14 +587,11 @@ nsSVGRadialGradientFrame::CreateGradient() // The focal point (fFx and fFy) must be clamped to be *inside* - not on - // the circumference of the gradient or we'll get rendering anomalies. We // calculate the distance from the focal point to the gradient center and - // make sure it is *less* than the gradient radius. 0.99 is used as the - // factor of the radius because it's close enough to 1 that we won't get a - // fringe at the edge of the gradient if we clamp, but not so close to 1 - // that rounding error will give us the same results as using fR itself. - // Also note that .99 < 255/256/2 which is the limit of the fractional part - // of cairo's 24.8 fixed point representation divided by 2 to ensure that - // we get different cairo fractions - double dMax = 0.99 * r; + // make sure it is *less* than the gradient radius. + // 1/128 is the limit of the fractional part of cairo's 24.8 fixed point + // representation divided by 2 to ensure that we get different cairo + // fractions + double dMax = NS_MAX(0.0, r - 1.0/128); float dx = fx - cx; float dy = fy - cy; double d = sqrt((dx * dx) + (dy * dy));