Changeset 51708 in webkit


Ignore:
Timestamp:
Dec 4, 2009 12:19:50 PM (14 years ago)
Author:
krit@webkit.org
Message:

2009-12-04 Dirk Schulze <krit@webkit.org>

Reviewed by Nikolas Zimmermann.

Gradient SVG animation demonstrates tearing at animation extremes
https://bugs.webkit.org/show_bug.cgi?id=11929

The focalPoint of a radial gradient is temporarly substracted by
the centralPoint, if the focalPoint is not in the radius of the
gradient. This is needed to calculate a new postion of the focalPoint
according to the specification. But the new focalPoint needs to be
moved by the centralPoint after this calculation, which is not the case
at the moment. This patch fixes this issue. It was also introduced a
deviation of maximal 0.2% for Cairo to get around the fixed point numbers
in Cairo.

W3C-SVG-1.1/pservers-grad-13-b needed an update. The missing adjustment
of the new focalPoint caused wrong results for the last three tests.

Test: svg/custom/radial-gradient-with-outstanding-focalPoint.svg

  • svg/SVGRadialGradientElement.cpp: (WebCore::SVGRadialGradientElement::buildGradient):

Gradient SVG animation demonstrates tearing at animation extremes
https://bugs.webkit.org/show_bug.cgi?id=11929

In SVG a focalPoint must be inside the radius of a radial gradient.
It this isn't the case, we have to move the focalPoint into the radius.
This checks the correct behavior of WebKit on false values for fx, fy.

  • platform/mac/svg/W3C-SVG-1.1/pservers-grad-13-b-expected.checksum:
  • platform/mac/svg/W3C-SVG-1.1/pservers-grad-13-b-expected.png:
  • platform/mac/svg/custom/radial-gradient-with-outstanding-focalPoint-expected.checksum: Added.
  • platform/mac/svg/custom/radial-gradient-with-outstanding-focalPoint-expected.png: Added.
  • platform/mac/svg/custom/radial-gradient-with-outstanding-focalPoint-expected.txt: Added.
  • svg/custom/radial-gradient-with-outstanding-focalPoint.svg: Added.
Location:
trunk
Files:
4 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r51706 r51708  
     12009-12-04  Dirk Schulze  <krit@webkit.org>
     2
     3        Reviewed by Nikolas Zimmermann.
     4
     5        Gradient SVG animation demonstrates tearing at animation extremes
     6        https://bugs.webkit.org/show_bug.cgi?id=11929
     7
     8        In SVG a focalPoint must be inside the radius of a radial gradient.
     9        It this isn't the case, we have to move the focalPoint into the radius.
     10        This checks the correct behavior of WebKit on false values for fx, fy.
     11
     12        * platform/mac/svg/W3C-SVG-1.1/pservers-grad-13-b-expected.checksum:
     13        * platform/mac/svg/W3C-SVG-1.1/pservers-grad-13-b-expected.png:
     14        * platform/mac/svg/custom/radial-gradient-with-outstanding-focalPoint-expected.checksum: Added.
     15        * platform/mac/svg/custom/radial-gradient-with-outstanding-focalPoint-expected.png: Added.
     16        * platform/mac/svg/custom/radial-gradient-with-outstanding-focalPoint-expected.txt: Added.
     17        * svg/custom/radial-gradient-with-outstanding-focalPoint.svg: Added.
     18
    1192009-12-04  Chris Fleizach  <cfleizach@apple.com>
    220
  • trunk/LayoutTests/platform/mac/svg/W3C-SVG-1.1/pservers-grad-13-b-expected.checksum

    r44224 r51708  
    1 1057e5426ca845b73d4597e53eb4e6bf
     1f7609cc7980e789d33a009b729585da2
  • trunk/WebCore/ChangeLog

    r51707 r51708  
     12009-12-04  Dirk Schulze  <krit@webkit.org>
     2
     3        Reviewed by Nikolas Zimmermann.
     4
     5        Gradient SVG animation demonstrates tearing at animation extremes
     6        https://bugs.webkit.org/show_bug.cgi?id=11929
     7
     8        The focalPoint of a radial gradient is temporarly substracted by
     9        the centralPoint, if the focalPoint is not in the radius of the
     10        gradient. This is needed to calculate a new postion of the focalPoint
     11        according to the specification. But the new focalPoint needs to be
     12        moved by the centralPoint after this calculation, which is not the case
     13        at the moment. This patch fixes this issue. It was also introduced a
     14        deviation of maximal 0.2% for Cairo to get around the fixed point numbers
     15        in Cairo.
     16
     17        W3C-SVG-1.1/pservers-grad-13-b needed an update. The missing adjustment
     18        of the new focalPoint caused wrong results for the last three tests.
     19
     20        Test: svg/custom/radial-gradient-with-outstanding-focalPoint.svg
     21
     22        * svg/SVGRadialGradientElement.cpp:
     23        (WebCore::SVGRadialGradientElement::buildGradient):
     24
    1252009-12-04  Anton Muhin  <antonm@chromium.org>
    226
  • trunk/WebCore/svg/SVGRadialGradientElement.cpp

    r49481 r51708  
    106106    }
    107107
    108     float adjustedFocusX = focalPoint.x();
    109     float adjustedFocusY = focalPoint.y();
    110 
    111     float fdx = focalPoint.x() - centerPoint.x();
    112     float fdy = focalPoint.y() - centerPoint.y();
     108    FloatPoint adjustedFocalPoint = focalPoint;
     109    float dfx = focalPoint.x() - centerPoint.x();
     110    float dfy = focalPoint.y() - centerPoint.y();
    113111
    114112    // Spec: If (fx, fy) lies outside the circle defined by (cx, cy) and
    115113    // r, set (fx, fy) to the point of intersection of the line through
    116114    // (fx, fy) and the circle.
    117     if (sqrt(fdx * fdx + fdy * fdy) > radius) {
    118         float angle = atan2f(focalPoint.y() * 100.0f, focalPoint.x() * 100.0f);
    119         adjustedFocusX = cosf(angle) * radius;
    120         adjustedFocusY = sinf(angle) * radius;
     115    if (sqrt(dfx * dfx + dfy * dfy) >= radius) {
     116        float angle = atan2f(dfx, dfy);
     117
     118        // The maximum deviation of 0.2% is needed on Cairo, since Cairo
     119        // is working with fixed point numbers.
     120#if PLATFORM(CAIRO)
     121        if (focalPoint.x() < centerPoint.x())
     122            dfx = cosf(angle) * radius + 0.002f;
     123        else
     124            dfx = cosf(angle) * radius - 0.002f;
     125        if (focalPoint.y() < centerPoint.y())
     126            dfy = sinf(angle) * radius + 0.002f;
     127        else
     128            dfy = sinf(angle) * radius - 0.002f;
     129#else
     130        dfx = cosf(angle) * radius;
     131        dfy = sinf(angle) * radius;
     132#endif
     133
     134        adjustedFocalPoint = FloatPoint(dfx + centerPoint.x(), dfy + centerPoint.y());
    121135    }
    122136
    123137    RefPtr<Gradient> gradient = Gradient::create(
    124         FloatPoint(adjustedFocusX, adjustedFocusY),
     138        adjustedFocalPoint,
    125139        0.f, // SVG does not support a "focus radius"
    126140        centerPoint,
Note: See TracChangeset for help on using the changeset viewer.