2 // Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 3 of the License, or
7 // (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 #ifndef GNASH_FILTERS_H
20 #define GNASH_FILTERS_H
22 #include <boost/cstdint.hpp>
31 // The common base class for AS display filters.
35 virtual bool read(SWFStream
& /*in*/) {
39 virtual ~BitmapFilter() {}
42 // A bevel effect filter.
43 class BevelFilter
: public BitmapFilter
53 // Fill from a SWFStream. See parser/filter_factory.cpp for the implementations.
54 virtual bool read(SWFStream
& in
);
56 virtual ~BevelFilter() {}
74 BevelFilter(float distance
, float angle
, boost::uint32_t hcolor
,
75 boost::uint8_t halpha
, boost::uint32_t scolor
, boost::uint8_t salpha
,
76 float blurX
, float blurY
, float strength
,
77 boost::uint8_t quality
, bevel_type type
, bool knockout
) :
78 m_distance(distance
), m_angle(angle
), m_highlightColor(hcolor
),
79 m_highlightAlpha(halpha
), m_shadowColor(scolor
), m_shadowAlpha(salpha
),
80 m_blurX(blurX
), m_blurY(blurY
), m_strength(strength
),
81 m_quality(quality
), m_type(type
), m_knockout(knockout
)
84 float m_distance
; // Distance of the filter in pixels.
85 float m_angle
; // Angle of the filter.
86 boost::uint32_t m_highlightColor
; // Color of the highlight.
87 boost::uint8_t m_highlightAlpha
; // Alpha of the highlight.
88 boost::uint32_t m_shadowColor
; // RGB color.
89 boost::uint8_t m_shadowAlpha
; // Alpha strength, as a percentage(?)
90 float m_blurX
; // horizontal blur
91 float m_blurY
; // vertical blur
92 float m_strength
; // How strong is the filter.
93 boost::uint8_t m_quality
; // How many times to apply the filter.
94 bevel_type m_type
; // The type of filter. (Rendered as string in AS)
95 bool m_knockout
; // If true, render only the filter effect.
98 // A blur effect filter.
99 class BlurFilter
: public BitmapFilter
102 // Fill from a SWFStream. See parser/filter_factory.cpp for the implementations.
103 virtual bool read(SWFStream
& in
);
105 virtual ~BlurFilter() {}
108 m_blurX(0.0f
), m_blurY(0.0f
), m_quality(0)
111 BlurFilter(float blurX
, float blurY
, boost::uint8_t quality
) :
112 m_blurX(blurX
), m_blurY(blurY
), m_quality(quality
)
115 float m_blurX
; // How much horizontal blur.
116 float m_blurY
; // How much vertical blur.
117 boost::uint8_t m_quality
; // How many passes to take.
120 // A color SWFMatrix effect filter.
121 class ColorMatrixFilter
: public BitmapFilter
124 // Fill from a SWFStream. See parser/filter_factory.cpp for the implementations.
125 virtual bool read(SWFStream
& in
);
127 virtual ~ColorMatrixFilter() {}
129 ColorMatrixFilter() :
133 ColorMatrixFilter(std::vector
<float> a_matrix
) :
138 std::vector
<float> m_matrix
; // The color SWFMatrix
141 // A convolution effect filter.
142 class ConvolutionFilter
: public BitmapFilter
145 // Fill from a SWFStream. See parser/filter_factory.cpp for
146 // the implementations.
147 virtual bool read(SWFStream
& in
);
149 virtual ~ConvolutionFilter() {}
158 _preserveAlpha(false),
164 ConvolutionFilter(boost::uint8_t matrixX
, boost::uint8_t matrixY
,
165 const std::vector
<float>& _matrix
, float divisor
, float bias
,
166 bool preserveAlpha
, bool clamp
, boost::uint32_t color
,
167 boost::uint8_t alpha
)
174 _preserveAlpha(preserveAlpha
),
181 boost::uint8_t _matrixX
; // Number of columns
182 boost::uint8_t _matrixY
; // Number of rows
183 std::vector
<float> _matrix
; // The convolution matrix
186 bool _preserveAlpha
; // If true, don't convolute the alpha channel
187 bool _clamp
; // Whether or not to clamp
188 boost::uint32_t _color
; // For off-image pixels
189 boost::uint8_t _alpha
; // For off-image pixels
192 // A drop shadow effect filter.
193 class DropShadowFilter
: public BitmapFilter
196 // Fill from a SWFStream. See parser/filter_factory.cpp for the implementations.
197 virtual bool read(SWFStream
& in
);
199 virtual ~DropShadowFilter() {}
202 m_distance(0.0f
), m_angle(0.0f
), m_color(0), m_alpha(0),
203 m_blurX(0.0f
), m_blurY(0.0f
), m_strength(0.0f
), m_quality(0),
204 m_inner(false), m_knockout(false), m_hideObject(false)
207 DropShadowFilter(float distance
, float angle
, boost::uint32_t color
,
208 boost::uint8_t alpha
, float blurX
, float blurY
, float strength
,
209 boost::uint8_t quality
, bool inner
, bool knockout
, bool hideObject
) :
210 m_distance(distance
), m_angle(angle
), m_color(color
),
211 m_alpha(alpha
), m_blurX(blurX
), m_blurY(blurY
), m_strength(strength
),
212 m_quality(quality
), m_inner(inner
), m_knockout(knockout
),
213 m_hideObject(hideObject
)
216 float m_distance
; // Distance of the filter in pixels.
217 float m_angle
; // Angle of the filter.
218 boost::uint32_t m_color
; // RGB color.
219 boost::uint8_t m_alpha
; // Alpha strength, as a percentage(?)
220 float m_blurX
; // horizontal blur
221 float m_blurY
; // vertical blur
222 float m_strength
; // How strong is the filter.
223 boost::uint8_t m_quality
; // How many times to apply the filter.
224 bool m_inner
; // Is this an inner shadow?
225 bool m_knockout
; // If true, render only the filter effect.
226 bool m_hideObject
; // Does this hide the object?
230 // A glow effect filter.
231 class GlowFilter
: public BitmapFilter
234 // Fill from a SWFStream. See parser/filter_factory.cpp for the implementations.
235 virtual bool read(SWFStream
& in
);
237 virtual ~GlowFilter() {}
240 m_color(0), m_alpha(0),
241 m_blurX(0.0f
), m_blurY(0.0f
), m_strength(0.0f
), m_quality(0),
242 m_inner(false), m_knockout(false)
245 GlowFilter(boost::uint32_t color
,
246 boost::uint8_t alpha
, float blurX
, float blurY
, float strength
,
247 boost::uint8_t quality
, bool inner
, bool knockout
) :
249 m_alpha(alpha
), m_blurX(blurX
), m_blurY(blurY
), m_strength(strength
),
250 m_quality(quality
), m_inner(inner
), m_knockout(knockout
)
253 boost::uint32_t m_color
; // RGB color.
254 boost::uint8_t m_alpha
; // Alpha strength, as a percentage(?)
255 float m_blurX
; // horizontal blur
256 float m_blurY
; // vertical blur
257 float m_strength
; // How strong is the filter.
258 boost::uint8_t m_quality
; // How many times to apply the filter.
259 bool m_inner
; // Is this an inner shadow?
260 bool m_knockout
; // If true, render only the filter effect.
264 // A gradient bevel effect filter.
265 class GradientBevelFilter
: public BitmapFilter
275 // Fill from a SWFStream. See parser/filter_factory.cpp for the implementations.
276 virtual bool read(SWFStream
& in
);
278 virtual ~GradientBevelFilter() {}
280 GradientBevelFilter() :
281 m_distance(0.0f
), m_angle(0.0f
), m_colors(), m_alphas(), m_ratios(),
282 m_blurX(0.0f
), m_blurY(0.0f
), m_strength(0.0f
), m_quality(0),
283 m_type(INNER_BEVEL
), m_knockout(false)
286 GradientBevelFilter(float distance
, float angle
,
287 std::vector
<boost::uint32_t> colors
,
288 std::vector
<boost::uint8_t> alphas
,
289 std::vector
<boost::uint8_t> ratios
,
290 float blurX
, float blurY
, float strength
,
291 boost::uint8_t quality
, glow_types type
, bool knockout
) :
292 m_distance(distance
), m_angle(angle
),
293 m_colors(colors
), m_alphas(alphas
), m_ratios(ratios
),
294 m_blurX(blurX
), m_blurY(blurY
), m_strength(strength
),
295 m_quality(quality
), m_type(type
), m_knockout(knockout
)
298 float m_distance
; // Distance of the filter in pixels.
299 float m_angle
; // Angle of the filter.
300 std::vector
<boost::uint32_t> m_colors
; // Colors of the gradients.
301 std::vector
<boost::uint8_t> m_alphas
; // Alphas of the gradients.
302 std::vector
<boost::uint8_t> m_ratios
; // Ratios of the gradients.
303 float m_blurX
; // horizontal blur
304 float m_blurY
; // vertical blur
305 float m_strength
; // How strong is the filter.
306 boost::uint8_t m_quality
; // How many times to apply the filter.
307 glow_types m_type
; // What type of effect.
308 bool m_knockout
; // If true, render only the filter effect.
311 // A gradient glow effect filter.
312 class GradientGlowFilter
: public BitmapFilter
322 // Fill from a SWFStream. See parser/filter_factory.cpp for the implementations.
323 virtual bool read(SWFStream
& in
);
325 virtual ~GradientGlowFilter() {}
327 GradientGlowFilter() :
328 m_distance(0.0f
), m_angle(0.0f
), m_colors(), m_alphas(), m_ratios(),
329 m_blurX(0.0f
), m_blurY(0.0f
), m_strength(0.0f
), m_quality(0),
330 m_type(INNER_GLOW
), m_knockout(false)
333 GradientGlowFilter(float distance
, float angle
,
334 std::vector
<boost::uint32_t> colors
,
335 std::vector
<boost::uint8_t> alphas
,
336 std::vector
<boost::uint8_t> ratios
,
337 float blurX
, float blurY
, float strength
,
338 boost::uint8_t quality
, glow_types type
, bool knockout
) :
339 m_distance(distance
), m_angle(angle
), m_colors(colors
), m_alphas(alphas
),
340 m_ratios(ratios
), m_blurX(blurX
), m_blurY(blurY
), m_strength(strength
),
341 m_quality(quality
), m_type(type
), m_knockout(knockout
)
344 float m_distance
; // Distance of the filter in pixels.
345 float m_angle
; // Angle of the filter.
346 std::vector
<boost::uint32_t> m_colors
; // Colors of the gradients.
347 std::vector
<boost::uint8_t> m_alphas
; // Alphas of the gradients.
348 std::vector
<boost::uint8_t> m_ratios
; // Ratios of the gradients.
349 float m_blurX
; // horizontal blur
350 float m_blurY
; // vertical blur
351 float m_strength
; // How strong is the filter.
352 boost::uint8_t m_quality
; // How many times to apply the filter.
353 glow_types m_type
; // What type of effect.
354 bool m_knockout
; // If true, render only the filter effect.