2 * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
4 * Copyright (C) 2005 Eric Seidel <eric@webkit.org>
5 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
6 * Copyright (C) 2010 Renata Hodovan <reni@inf.u-szeged.hu>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public License
19 * along with this library; see the file COPYING.LIB. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
24 #ifndef FETurbulence_h
25 #define FETurbulence_h
28 #include "FilterEffect.h"
34 FETURBULENCE_TYPE_UNKNOWN = 0,
35 FETURBULENCE_TYPE_FRACTALNOISE = 1,
36 FETURBULENCE_TYPE_TURBULENCE = 2
39 class FETurbulence : public FilterEffect {
41 static PassRefPtr<FETurbulence> create(Filter*, TurbulenceType, float, float, int, float, bool);
43 TurbulenceType type() const;
44 bool setType(TurbulenceType);
46 float baseFrequencyY() const;
47 bool setBaseFrequencyY(float);
49 float baseFrequencyX() const;
50 bool setBaseFrequencyX(float);
55 int numOctaves() const;
56 bool setNumOctaves(int);
58 bool stitchTiles() const;
59 bool setStitchTiles(bool);
61 #if ENABLE(PARALLEL_JOBS)
62 static void fillRegionWorker(void*);
65 virtual void platformApplySoftware();
68 virtual void determineAbsolutePaintRect() { setAbsolutePaintRect(enclosingIntRect(maxEffectRect())); }
70 virtual TextStream& externalRepresentation(TextStream&, int indention) const;
73 static const int s_blockSize = 256;
74 static const int s_blockMask = s_blockSize - 1;
75 #if ENABLE(PARALLEL_JOBS)
76 static const int s_minimalRectDimension = (100 * 100); // Empirical data limit for parallel jobs
81 int latticeSelector[2 * s_blockSize + 2];
82 float gradient[4][2 * s_blockSize + 2][2];
83 int width; // How much to subtract to wrap for stitching.
85 int wrapX; // Minimum value to wrap.
89 PaintingData(long paintingSeed, const IntSize& paintingSize);
93 #if ENABLE(PARALLEL_JOBS)
94 template<typename Type>
95 friend class ParallelJobs;
97 struct FillRegionParameters {
99 ByteArray* pixelArray;
100 PaintingData* paintingData;
105 static void fillRegionWorker(FillRegionParameters*);
108 FETurbulence(Filter*, TurbulenceType, float, float, int, float, bool);
110 inline void initPaint(PaintingData&);
111 float noise2D(int channel, PaintingData&, const FloatPoint&);
112 unsigned char calculateTurbulenceValueForPoint(int channel, PaintingData&, const FloatPoint&);
113 inline void fillRegion(ByteArray*, PaintingData&, int, int);
115 TurbulenceType m_type;
116 float m_baseFrequencyX;
117 float m_baseFrequencyY;
123 } // namespace WebCore
125 #endif // ENABLE(FILTERS)
127 #endif // FETurbulence_h