00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef GNASH_FILTERS_H
00021 #define GNASH_FILTERS_H
00022
00023 #include <boost/cstdint.hpp>
00024 #include <vector>
00025
00026 namespace gnash {
00027 class SWFStream;
00028 }
00029
00030 namespace gnash {
00031
00032
00033 class BitmapFilter
00034 {
00035 public:
00036 virtual bool read(SWFStream& ) {
00037 return true;
00038 }
00039 BitmapFilter() {}
00040 virtual ~BitmapFilter() {}
00041 };
00042
00043
00044 class BevelFilter : public BitmapFilter
00045 {
00046 public:
00047 enum bevel_type
00048 {
00049 OUTER_BEVEL = 1,
00050 INNER_BEVEL = 2,
00051 FULL_BEVEL = 3
00052 };
00053
00054
00055 virtual bool read(SWFStream& in);
00056
00057 virtual ~BevelFilter() {}
00058
00059 BevelFilter()
00060 :
00061 m_distance(0.0f),
00062 m_angle(0.0f),
00063 m_highlightColor(0),
00064 m_highlightAlpha(0),
00065 m_shadowColor(0),
00066 m_shadowAlpha(0),
00067 m_blurX(0.0f),
00068 m_blurY(0.0f),
00069 m_strength(0.0f),
00070 m_quality(0),
00071 m_type(FULL_BEVEL),
00072 m_knockout(false)
00073 {}
00074
00075 BevelFilter(float distance, float angle, boost::uint32_t hcolor,
00076 boost::uint8_t halpha, boost::uint32_t scolor, boost::uint8_t salpha,
00077 float blurX, float blurY, float strength,
00078 boost::uint8_t quality, bevel_type type, bool knockout) :
00079 m_distance(distance), m_angle(angle), m_highlightColor(hcolor),
00080 m_highlightAlpha(halpha), m_shadowColor(scolor), m_shadowAlpha(salpha),
00081 m_blurX(blurX), m_blurY(blurY), m_strength(strength),
00082 m_quality(quality), m_type(type), m_knockout(knockout)
00083 {}
00084
00085 float m_distance;
00086 float m_angle;
00087 boost::uint32_t m_highlightColor;
00088 boost::uint8_t m_highlightAlpha;
00089 boost::uint32_t m_shadowColor;
00090 boost::uint8_t m_shadowAlpha;
00091 float m_blurX;
00092 float m_blurY;
00093 float m_strength;
00094 boost::uint8_t m_quality;
00095 bevel_type m_type;
00096 bool m_knockout;
00097 };
00098
00099
00100 class BlurFilter : public BitmapFilter
00101 {
00102 public:
00103
00104 virtual bool read(SWFStream& in);
00105
00106 virtual ~BlurFilter() {}
00107
00108 BlurFilter() :
00109 m_blurX(0.0f), m_blurY(0.0f), m_quality(0)
00110 {}
00111
00112 BlurFilter(float blurX, float blurY, boost::uint8_t quality) :
00113 m_blurX(blurX), m_blurY(blurY), m_quality(quality)
00114 {}
00115
00116 float m_blurX;
00117 float m_blurY;
00118 boost::uint8_t m_quality;
00119 };
00120
00121
00122 class ColorMatrixFilter : public BitmapFilter
00123 {
00124 public:
00125
00126 virtual bool read(SWFStream& in);
00127
00128 virtual ~ColorMatrixFilter() {}
00129
00130 ColorMatrixFilter() :
00131 m_matrix()
00132 {}
00133
00134 ColorMatrixFilter(std::vector<float> a_matrix) :
00135 m_matrix(a_matrix)
00136 {}
00137
00138 protected:
00139 std::vector<float> m_matrix;
00140 };
00141
00142
00143 class ConvolutionFilter : public BitmapFilter
00144 {
00145 public:
00146
00147
00148 virtual bool read(SWFStream& in);
00149
00150 virtual ~ConvolutionFilter() {}
00151
00152 ConvolutionFilter()
00153 :
00154 _matrixX(),
00155 _matrixY(),
00156 _matrix(),
00157 _divisor(),
00158 _bias(),
00159 _preserveAlpha(false),
00160 _clamp(false),
00161 _color(),
00162 _alpha()
00163 {}
00164
00165 ConvolutionFilter(boost::uint8_t matrixX, boost::uint8_t matrixY,
00166 const std::vector<float>& _matrix, float divisor, float bias,
00167 bool preserveAlpha, bool clamp, boost::uint32_t color,
00168 boost::uint8_t alpha)
00169 :
00170 _matrixX(matrixX),
00171 _matrixY(matrixY),
00172 _matrix(_matrix),
00173 _divisor(divisor),
00174 _bias(bias),
00175 _preserveAlpha(preserveAlpha),
00176 _clamp(clamp),
00177 _color(color),
00178 _alpha(alpha)
00179 {}
00180
00181 protected:
00182 boost::uint8_t _matrixX;
00183 boost::uint8_t _matrixY;
00184 std::vector<float> _matrix;
00185 float _divisor;
00186 float _bias;
00187 bool _preserveAlpha;
00188 bool _clamp;
00189 boost::uint32_t _color;
00190 boost::uint8_t _alpha;
00191 };
00192
00193
00194 class DropShadowFilter : public BitmapFilter
00195 {
00196 public:
00197
00198 virtual bool read(SWFStream& in);
00199
00200 virtual ~DropShadowFilter() {}
00201
00202 DropShadowFilter() :
00203 m_distance(0.0f), m_angle(0.0f), m_color(0), m_alpha(0),
00204 m_blurX(0.0f), m_blurY(0.0f), m_strength(0.0f), m_quality(0),
00205 m_inner(false), m_knockout(false), m_hideObject(false)
00206 {}
00207
00208 DropShadowFilter(float distance, float angle, boost::uint32_t color,
00209 boost::uint8_t alpha, float blurX, float blurY, float strength,
00210 boost::uint8_t quality, bool inner, bool knockout, bool hideObject) :
00211 m_distance(distance), m_angle(angle), m_color(color),
00212 m_alpha(alpha), m_blurX(blurX), m_blurY(blurY), m_strength(strength),
00213 m_quality(quality), m_inner(inner), m_knockout(knockout),
00214 m_hideObject(hideObject)
00215 {}
00216
00217 float m_distance;
00218 float m_angle;
00219 boost::uint32_t m_color;
00220 boost::uint8_t m_alpha;
00221 float m_blurX;
00222 float m_blurY;
00223 float m_strength;
00224 boost::uint8_t m_quality;
00225 bool m_inner;
00226 bool m_knockout;
00227 bool m_hideObject;
00228 };
00229
00230
00231
00232 class GlowFilter : public BitmapFilter
00233 {
00234 public:
00235
00236 virtual bool read(SWFStream& in);
00237
00238 virtual ~GlowFilter() {}
00239
00240 GlowFilter() :
00241 m_color(0), m_alpha(0),
00242 m_blurX(0.0f), m_blurY(0.0f), m_strength(0.0f), m_quality(0),
00243 m_inner(false), m_knockout(false)
00244 {}
00245
00246 GlowFilter(boost::uint32_t color,
00247 boost::uint8_t alpha, float blurX, float blurY, float strength,
00248 boost::uint8_t quality, bool inner, bool knockout) :
00249 m_color(color),
00250 m_alpha(alpha), m_blurX(blurX), m_blurY(blurY), m_strength(strength),
00251 m_quality(quality), m_inner(inner), m_knockout(knockout)
00252 {}
00253
00254 boost::uint32_t m_color;
00255 boost::uint8_t m_alpha;
00256 float m_blurX;
00257 float m_blurY;
00258 float m_strength;
00259 boost::uint8_t m_quality;
00260 bool m_inner;
00261 bool m_knockout;
00262 };
00263
00264
00265
00266 class GradientBevelFilter : public BitmapFilter
00267 {
00268 public:
00269 enum glow_types
00270 {
00271 INNER_BEVEL = 2,
00272 OUTER_BEVEL = 1,
00273 FULL_BEVEL = 3
00274 };
00275
00276
00277 virtual bool read(SWFStream& in);
00278
00279 virtual ~GradientBevelFilter() {}
00280
00281 GradientBevelFilter() :
00282 m_distance(0.0f), m_angle(0.0f), m_colors(), m_alphas(), m_ratios(),
00283 m_blurX(0.0f), m_blurY(0.0f), m_strength(0.0f), m_quality(0),
00284 m_type(INNER_BEVEL), m_knockout(false)
00285 {}
00286
00287 GradientBevelFilter(float distance, float angle,
00288 std::vector<boost::uint32_t> colors,
00289 std::vector<boost::uint8_t> alphas,
00290 std::vector<boost::uint8_t> ratios,
00291 float blurX, float blurY, float strength,
00292 boost::uint8_t quality, glow_types type, bool knockout) :
00293 m_distance(distance), m_angle(angle),
00294 m_colors(colors), m_alphas(alphas), m_ratios(ratios),
00295 m_blurX(blurX), m_blurY(blurY), m_strength(strength),
00296 m_quality(quality), m_type(type), m_knockout(knockout)
00297 {}
00298
00299 float m_distance;
00300 float m_angle;
00301 std::vector<boost::uint32_t> m_colors;
00302 std::vector<boost::uint8_t> m_alphas;
00303 std::vector<boost::uint8_t> m_ratios;
00304 float m_blurX;
00305 float m_blurY;
00306 float m_strength;
00307 boost::uint8_t m_quality;
00308 glow_types m_type;
00309 bool m_knockout;
00310 };
00311
00312
00313 class GradientGlowFilter : public BitmapFilter
00314 {
00315 public:
00316 enum glow_types
00317 {
00318 INNER_GLOW = 2,
00319 OUTER_GLOW = 1,
00320 FULL_GLOW = 3
00321 };
00322
00323
00324 virtual bool read(SWFStream& in);
00325
00326 virtual ~GradientGlowFilter() {}
00327
00328 GradientGlowFilter() :
00329 m_distance(0.0f), m_angle(0.0f), m_colors(), m_alphas(), m_ratios(),
00330 m_blurX(0.0f), m_blurY(0.0f), m_strength(0.0f), m_quality(0),
00331 m_type(INNER_GLOW), m_knockout(false)
00332 {}
00333
00334 GradientGlowFilter(float distance, float angle,
00335 std::vector<boost::uint32_t> colors,
00336 std::vector<boost::uint8_t> alphas,
00337 std::vector<boost::uint8_t> ratios,
00338 float blurX, float blurY, float strength,
00339 boost::uint8_t quality, glow_types type, bool knockout) :
00340 m_distance(distance), m_angle(angle), m_colors(colors), m_alphas(alphas),
00341 m_ratios(ratios), m_blurX(blurX), m_blurY(blurY), m_strength(strength),
00342 m_quality(quality), m_type(type), m_knockout(knockout)
00343 {}
00344
00345 float m_distance;
00346 float m_angle;
00347 std::vector<boost::uint32_t> m_colors;
00348 std::vector<boost::uint8_t> m_alphas;
00349 std::vector<boost::uint8_t> m_ratios;
00350 float m_blurX;
00351 float m_blurY;
00352 float m_strength;
00353 boost::uint8_t m_quality;
00354 glow_types m_type;
00355 bool m_knockout;
00356 };
00357
00358 }
00359
00360 #endif