Gnash 0.8.9
|
00001 // 00002 // Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. 00003 // 00004 // This program is free software; you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation; either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // This program is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with this program; if not, write to the Free Software 00016 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00017 00018 00019 #ifndef GNASH_FILTERS_H 00020 #define GNASH_FILTERS_H 00021 00022 #include <boost/cstdint.hpp> 00023 #include <vector> 00024 00025 namespace gnash { 00026 class SWFStream; 00027 } 00028 00029 namespace gnash { 00030 00031 // The common base class for AS display filters. 00032 class BitmapFilter 00033 { 00034 public: 00035 virtual bool read(SWFStream& /*in*/) { 00036 return true; 00037 } 00038 BitmapFilter() {} 00039 virtual ~BitmapFilter() {} 00040 }; 00041 00042 // A bevel effect filter. 00043 class BevelFilter : public BitmapFilter 00044 { 00045 public: 00046 enum bevel_type 00047 { 00048 OUTER_BEVEL = 1, 00049 INNER_BEVEL = 2, 00050 FULL_BEVEL = 3 00051 }; 00052 00053 // Fill from a SWFStream. See parser/filter_factory.cpp for the implementations. 00054 virtual bool read(SWFStream& in); 00055 00056 virtual ~BevelFilter() {} 00057 00058 BevelFilter() 00059 : 00060 m_distance(0.0f), 00061 m_angle(0.0f), 00062 m_highlightColor(0), 00063 m_highlightAlpha(0), 00064 m_shadowColor(0), 00065 m_shadowAlpha(0), 00066 m_blurX(0.0f), 00067 m_blurY(0.0f), 00068 m_strength(0.0f), 00069 m_quality(0), 00070 m_type(FULL_BEVEL), 00071 m_knockout(false) 00072 {} 00073 00074 BevelFilter(float distance, float angle, boost::uint32_t hcolor, 00075 boost::uint8_t halpha, boost::uint32_t scolor, boost::uint8_t salpha, 00076 float blurX, float blurY, float strength, 00077 boost::uint8_t quality, bevel_type type, bool knockout) : 00078 m_distance(distance), m_angle(angle), m_highlightColor(hcolor), 00079 m_highlightAlpha(halpha), m_shadowColor(scolor), m_shadowAlpha(salpha), 00080 m_blurX(blurX), m_blurY(blurY), m_strength(strength), 00081 m_quality(quality), m_type(type), m_knockout(knockout) 00082 {} 00083 00084 float m_distance; // Distance of the filter in pixels. 00085 float m_angle; // Angle of the filter. 00086 boost::uint32_t m_highlightColor; // Color of the highlight. 00087 boost::uint8_t m_highlightAlpha; // Alpha of the highlight. 00088 boost::uint32_t m_shadowColor; // RGB color. 00089 boost::uint8_t m_shadowAlpha; // Alpha strength, as a percentage(?) 00090 float m_blurX; // horizontal blur 00091 float m_blurY; // vertical blur 00092 float m_strength; // How strong is the filter. 00093 boost::uint8_t m_quality; // How many times to apply the filter. 00094 bevel_type m_type; // The type of filter. (Rendered as string in AS) 00095 bool m_knockout; // If true, render only the filter effect. 00096 }; 00097 00098 // A blur effect filter. 00099 class BlurFilter : public BitmapFilter 00100 { 00101 public: 00102 // Fill from a SWFStream. See parser/filter_factory.cpp for the implementations. 00103 virtual bool read(SWFStream& in); 00104 00105 virtual ~BlurFilter() {} 00106 00107 BlurFilter() : 00108 m_blurX(0.0f), m_blurY(0.0f), m_quality(0) 00109 {} 00110 00111 BlurFilter(float blurX, float blurY, boost::uint8_t quality) : 00112 m_blurX(blurX), m_blurY(blurY), m_quality(quality) 00113 {} 00114 00115 float m_blurX; // How much horizontal blur. 00116 float m_blurY; // How much vertical blur. 00117 boost::uint8_t m_quality; // How many passes to take. 00118 }; 00119 00120 // A color SWFMatrix effect filter. 00121 class ColorMatrixFilter : public BitmapFilter 00122 { 00123 public: 00124 // Fill from a SWFStream. See parser/filter_factory.cpp for the implementations. 00125 virtual bool read(SWFStream& in); 00126 00127 virtual ~ColorMatrixFilter() {} 00128 00129 ColorMatrixFilter() : 00130 m_matrix() 00131 {} 00132 00133 ColorMatrixFilter(std::vector<float> a_matrix) : 00134 m_matrix(a_matrix) 00135 {} 00136 00137 protected: 00138 std::vector<float> m_matrix; // The color SWFMatrix 00139 }; 00140 00141 // A convolution effect filter. 00142 class ConvolutionFilter : public BitmapFilter 00143 { 00144 public: 00145 // Fill from a SWFStream. See parser/filter_factory.cpp for 00146 // the implementations. 00147 virtual bool read(SWFStream& in); 00148 00149 virtual ~ConvolutionFilter() {} 00150 00151 ConvolutionFilter() 00152 : 00153 _matrixX(), 00154 _matrixY(), 00155 _matrix(), 00156 _divisor(), 00157 _bias(), 00158 _preserveAlpha(false), 00159 _clamp(false), 00160 _color(), 00161 _alpha() 00162 {} 00163 00164 ConvolutionFilter(boost::uint8_t matrixX, boost::uint8_t matrixY, 00165 const std::vector<float>& _matrix, float divisor, float bias, 00166 bool preserveAlpha, bool clamp, boost::uint32_t color, 00167 boost::uint8_t alpha) 00168 : 00169 _matrixX(matrixX), 00170 _matrixY(matrixY), 00171 _matrix(_matrix), 00172 _divisor(divisor), 00173 _bias(bias), 00174 _preserveAlpha(preserveAlpha), 00175 _clamp(clamp), 00176 _color(color), 00177 _alpha(alpha) 00178 {} 00179 00180 protected: 00181 boost::uint8_t _matrixX; // Number of columns 00182 boost::uint8_t _matrixY; // Number of rows 00183 std::vector<float> _matrix; // The convolution matrix 00184 float _divisor; 00185 float _bias; 00186 bool _preserveAlpha; // If true, don't convolute the alpha channel 00187 bool _clamp; // Whether or not to clamp 00188 boost::uint32_t _color; // For off-image pixels 00189 boost::uint8_t _alpha; // For off-image pixels 00190 }; 00191 00192 // A drop shadow effect filter. 00193 class DropShadowFilter : public BitmapFilter 00194 { 00195 public: 00196 // Fill from a SWFStream. See parser/filter_factory.cpp for the implementations. 00197 virtual bool read(SWFStream& in); 00198 00199 virtual ~DropShadowFilter() {} 00200 00201 DropShadowFilter() : 00202 m_distance(0.0f), m_angle(0.0f), m_color(0), m_alpha(0), 00203 m_blurX(0.0f), m_blurY(0.0f), m_strength(0.0f), m_quality(0), 00204 m_inner(false), m_knockout(false), m_hideObject(false) 00205 {} 00206 00207 DropShadowFilter(float distance, float angle, boost::uint32_t color, 00208 boost::uint8_t alpha, float blurX, float blurY, float strength, 00209 boost::uint8_t quality, bool inner, bool knockout, bool hideObject) : 00210 m_distance(distance), m_angle(angle), m_color(color), 00211 m_alpha(alpha), m_blurX(blurX), m_blurY(blurY), m_strength(strength), 00212 m_quality(quality), m_inner(inner), m_knockout(knockout), 00213 m_hideObject(hideObject) 00214 {} 00215 00216 float m_distance; // Distance of the filter in pixels. 00217 float m_angle; // Angle of the filter. 00218 boost::uint32_t m_color; // RGB color. 00219 boost::uint8_t m_alpha; // Alpha strength, as a percentage(?) 00220 float m_blurX; // horizontal blur 00221 float m_blurY; // vertical blur 00222 float m_strength; // How strong is the filter. 00223 boost::uint8_t m_quality; // How many times to apply the filter. 00224 bool m_inner; // Is this an inner shadow? 00225 bool m_knockout; // If true, render only the filter effect. 00226 bool m_hideObject; // Does this hide the object? 00227 }; 00228 00229 00230 // A glow effect filter. 00231 class GlowFilter : public BitmapFilter 00232 { 00233 public: 00234 // Fill from a SWFStream. See parser/filter_factory.cpp for the implementations. 00235 virtual bool read(SWFStream& in); 00236 00237 virtual ~GlowFilter() {} 00238 00239 GlowFilter() : 00240 m_color(0), m_alpha(0), 00241 m_blurX(0.0f), m_blurY(0.0f), m_strength(0.0f), m_quality(0), 00242 m_inner(false), m_knockout(false) 00243 {} 00244 00245 GlowFilter(boost::uint32_t color, 00246 boost::uint8_t alpha, float blurX, float blurY, float strength, 00247 boost::uint8_t quality, bool inner, bool knockout) : 00248 m_color(color), 00249 m_alpha(alpha), m_blurX(blurX), m_blurY(blurY), m_strength(strength), 00250 m_quality(quality), m_inner(inner), m_knockout(knockout) 00251 {} 00252 00253 boost::uint32_t m_color; // RGB color. 00254 boost::uint8_t m_alpha; // Alpha strength, as a percentage(?) 00255 float m_blurX; // horizontal blur 00256 float m_blurY; // vertical blur 00257 float m_strength; // How strong is the filter. 00258 boost::uint8_t m_quality; // How many times to apply the filter. 00259 bool m_inner; // Is this an inner shadow? 00260 bool m_knockout; // If true, render only the filter effect. 00261 }; 00262 00263 00264 // A gradient bevel effect filter. 00265 class GradientBevelFilter : public BitmapFilter 00266 { 00267 public: 00268 enum glow_types 00269 { 00270 INNER_BEVEL = 2, 00271 OUTER_BEVEL = 1, 00272 FULL_BEVEL = 3 00273 }; 00274 00275 // Fill from a SWFStream. See parser/filter_factory.cpp for the implementations. 00276 virtual bool read(SWFStream& in); 00277 00278 virtual ~GradientBevelFilter() {} 00279 00280 GradientBevelFilter() : 00281 m_distance(0.0f), m_angle(0.0f), m_colors(), m_alphas(), m_ratios(), 00282 m_blurX(0.0f), m_blurY(0.0f), m_strength(0.0f), m_quality(0), 00283 m_type(INNER_BEVEL), m_knockout(false) 00284 {} 00285 00286 GradientBevelFilter(float distance, float angle, 00287 std::vector<boost::uint32_t> colors, 00288 std::vector<boost::uint8_t> alphas, 00289 std::vector<boost::uint8_t> ratios, 00290 float blurX, float blurY, float strength, 00291 boost::uint8_t quality, glow_types type, bool knockout) : 00292 m_distance(distance), m_angle(angle), 00293 m_colors(colors), m_alphas(alphas), m_ratios(ratios), 00294 m_blurX(blurX), m_blurY(blurY), m_strength(strength), 00295 m_quality(quality), m_type(type), m_knockout(knockout) 00296 {} 00297 00298 float m_distance; // Distance of the filter in pixels. 00299 float m_angle; // Angle of the filter. 00300 std::vector<boost::uint32_t> m_colors; // Colors of the gradients. 00301 std::vector<boost::uint8_t> m_alphas; // Alphas of the gradients. 00302 std::vector<boost::uint8_t> m_ratios; // Ratios of the gradients. 00303 float m_blurX; // horizontal blur 00304 float m_blurY; // vertical blur 00305 float m_strength; // How strong is the filter. 00306 boost::uint8_t m_quality; // How many times to apply the filter. 00307 glow_types m_type; // What type of effect. 00308 bool m_knockout; // If true, render only the filter effect. 00309 }; 00310 00311 // A gradient glow effect filter. 00312 class GradientGlowFilter : public BitmapFilter 00313 { 00314 public: 00315 enum glow_types 00316 { 00317 INNER_GLOW = 2, 00318 OUTER_GLOW = 1, 00319 FULL_GLOW = 3 00320 }; 00321 00322 // Fill from a SWFStream. See parser/filter_factory.cpp for the implementations. 00323 virtual bool read(SWFStream& in); 00324 00325 virtual ~GradientGlowFilter() {} 00326 00327 GradientGlowFilter() : 00328 m_distance(0.0f), m_angle(0.0f), m_colors(), m_alphas(), m_ratios(), 00329 m_blurX(0.0f), m_blurY(0.0f), m_strength(0.0f), m_quality(0), 00330 m_type(INNER_GLOW), m_knockout(false) 00331 {} 00332 00333 GradientGlowFilter(float distance, float angle, 00334 std::vector<boost::uint32_t> colors, 00335 std::vector<boost::uint8_t> alphas, 00336 std::vector<boost::uint8_t> ratios, 00337 float blurX, float blurY, float strength, 00338 boost::uint8_t quality, glow_types type, bool knockout) : 00339 m_distance(distance), m_angle(angle), m_colors(colors), m_alphas(alphas), 00340 m_ratios(ratios), m_blurX(blurX), m_blurY(blurY), m_strength(strength), 00341 m_quality(quality), m_type(type), m_knockout(knockout) 00342 {} 00343 00344 float m_distance; // Distance of the filter in pixels. 00345 float m_angle; // Angle of the filter. 00346 std::vector<boost::uint32_t> m_colors; // Colors of the gradients. 00347 std::vector<boost::uint8_t> m_alphas; // Alphas of the gradients. 00348 std::vector<boost::uint8_t> m_ratios; // Ratios of the gradients. 00349 float m_blurX; // horizontal blur 00350 float m_blurY; // vertical blur 00351 float m_strength; // How strong is the filter. 00352 boost::uint8_t m_quality; // How many times to apply the filter. 00353 glow_types m_type; // What type of effect. 00354 bool m_knockout; // If true, render only the filter effect. 00355 }; 00356 00357 } // Namespace gnash 00358 00359 #endif