[Webkit-unassigned] [Bug 5864] feTurbulence is not implemented

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Nov 9 13:23:57 PST 2009


https://bugs.webkit.org/show_bug.cgi?id=5864


Oliver Hunt <oliver at apple.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #42743|review?                     |review-
               Flag|                            |




--- Comment #4 from Oliver Hunt <oliver at apple.com>  2009-11-09 13:23:57 PDT ---
(From update of attachment 42743)
> Index: WebCore/ChangeLog
> ===================================================================
> --- WebCore/ChangeLog	(revision 50642)
> +++ WebCore/ChangeLog	(working copy)
> @@ -1,3 +1,25 @@
> +2009-11-09  Dirk Schulze  <krit at webkit.org>
> +
> +        Reviewed by NOBODY (OOPS!).
> +
> +        feTurbulence if not implemented
> +        [https://bugs.webkit.org/show_bug.cgi?id=5864]
> +
> +        This is the implementation of feTurbulence. The
> +        calculation code is a modified version of what appears
> +        in the SVG 1.1 specification for feTurbulence.
> +
> +        Test: svg/W3C-SVG-1.1/filters-turb-01-f.svg
> +
> +        * svg/graphics/filters/SVGFETurbulence.cpp:
> +        (WebCore::FETurbulence::setup_seed):
> +        (WebCore::FETurbulence::random):
> +        (WebCore::FETurbulence::init):
> +        (WebCore::FETurbulence::noise2):
> +        (WebCore::FETurbulence::turbulence):
> +        (WebCore::FETurbulence::apply):
> +        * svg/graphics/filters/SVGFETurbulence.h:
> +
>  2009-11-09  Martin Robinson  <martin.james.robinson at gmail.com>
>  
>          Reviewed by Jan Alonzo.
> Index: WebCore/svg/graphics/filters/SVGFETurbulence.cpp
> ===================================================================
> --- WebCore/svg/graphics/filters/SVGFETurbulence.cpp	(revision 50605)
> +++ WebCore/svg/graphics/filters/SVGFETurbulence.cpp	(working copy)
> @@ -2,6 +2,7 @@
>      Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann at kde.org>
>                    2004, 2005 Rob Buis <buis at kde.org>
>                    2005 Eric Seidel <eric at webkit.org>
> +                  2009 Dirk Schulze <krit at webkit.org>
>  
>      This library is free software; you can redistribute it and/or
>      modify it under the terms of the GNU Library General Public
> @@ -23,8 +24,13 @@
>  
>  #if ENABLE(SVG) && ENABLE(FILTERS)
>  #include "SVGFETurbulence.h"
> -#include "SVGRenderTreeAsText.h"
> +
> +#include "CanvasPixelArray.h"
>  #include "Filter.h"
> +#include "ImageData.h"
> +#include "SVGRenderTreeAsText.h"
> +
> +#include <math.h>
>  
>  namespace WebCore {
>  
> @@ -106,8 +112,187 @@ void FETurbulence::setStitchTiles(bool s
>      m_stitchTiles = stitch;
>  }
>  
> -void FETurbulence::apply(Filter*)
> +// The turbulence calculation code is an adapted version of what
> +// appears in the SVG 1.1 specification:
> +// http://www.w3.org/TR/SVG11/filters.html#feTurbulence
> +long FETurbulence::setup_seed(long lSeed)
> +{
> +    if (lSeed <= 0) lSeed = -(lSeed % (RAND_m - 1)) + 1;
> +    if (lSeed > RAND_m - 1) lSeed = RAND_m - 1;
> +    return lSeed;
> +}
> +
> +long FETurbulence::random(long lSeed)
> +{
> +    long result;
> +    result = RAND_a * (lSeed % RAND_q) - RAND_r * (lSeed / RAND_q);
should be:
long result = RAND_a * (lSeed % RAND_q) - RAND_r * (lSeed / RAND_q);


> +double FETurbulence::noise2(int nColorChannel, double vec[2], StitchInfo *pStitchInfo)
>  {
> +    int bx0, bx1, by0, by1, b00, b10, b01, b11;
> +    double rx0, rx1, ry0, ry1, *q, sx, sy, a, b, t, u, v;
> +    int i, j;
> +    t = vec[0] + PerlinN;
> +    bx0 = (int)t;

should be static_cast<int>

> +    rx0 = t - (int)t;
ditto

> +    by0 = (int)t;
ditto

> +    ry0 = t - (int)t;
ditto

> +unsigned char FETurbulence::turbulence(int nColorChannel, double *point, const IntSize& filterSize)
> +{
> +    StitchInfo stitch;
> +    StitchInfo *pStitchInfo = NULL; // Not stitching when NULL.
We use 0 not NULL

> +            double fLoFreq = double(floor(fTileWidth * m_baseFrequencyX)) / fTileWidth;
> +            double fHiFreq = double(ceil(fTileWidth * m_baseFrequencyX)) / fTileWidth;

static_cast!!! ZOMBBQPWN13S, ignoring the remainder of these


> Index: WebCore/svg/graphics/filters/SVGFETurbulence.h
> ===================================================================
> --- WebCore/svg/graphics/filters/SVGFETurbulence.h	(revision 50605)
> +++ WebCore/svg/graphics/filters/SVGFETurbulence.h	(working copy)

> +/* Produces results in the range [1, 2**31 - 2].
> +Algorithm is: r = (a * r) mod m
> +where a = 16807 and m = 2**31 - 1 = 2147483647
> +See [Park & Miller], CACM vol. 31 no. 10 p. 1195, Oct. 1988
> +To test: the algorithm should produce the result 1043618065
> +as the 10,000th generated number if the original seed is 1.
> +*/
> +#define RAND_m 2147483647 /* 2**31 - 1 */
> +#define RAND_a 16807 /* 7**5; primitive root of m */
> +#define RAND_q 127773 /* m / a */
> +#define RAND_r 2836 /* m % a */
> +#define BSize 0x100
> +#define BM 0xff
> +#define PerlinN 0x1000
> +#define NP 12 /* 2^PerlinN */
> +#define NM 0xfff
> +#define s_curve(t) ( t * t * (3. - 2. * t) )
> +#define lerp(t, a, b) ( a + t * (b - a) )

static const <int/long> and a pair of static inline functions.


Finally, i'm _really_ concerned about the performance of this.  It should be
possible to do this purely in integer arithmetic (I think Ken Perlin describes
this) and until we have effective recompute reduction this could be very
expensive on repaint.

r- pending the various style, etc issues.

--Oliver

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the webkit-unassigned mailing list