X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fmodules%2Fmod_filter%2Fradialblur.cpp;h=6ecc5bb330c1b37593f322e8883b175506ebe68d;hb=756c0d29ac1742f231e6615f9a577e574e35a4af;hp=93586fde170354bbc57020b478672caf6a5d5f0b;hpb=21bfc670b83d4c45da9ed1b95063b7e6a007168c;p=synfig.git diff --git a/synfig-core/trunk/src/modules/mod_filter/radialblur.cpp b/synfig-core/trunk/src/modules/mod_filter/radialblur.cpp index 93586fd..6ecc5bb 100644 --- a/synfig-core/trunk/src/modules/mod_filter/radialblur.cpp +++ b/synfig-core/trunk/src/modules/mod_filter/radialblur.cpp @@ -1,9 +1,12 @@ -/*! ======================================================================== -** Synfig -** Template File -** $Id: radialblur.cpp,v 1.1.1.1 2005/01/04 01:23:10 darco Exp $ +/* === S Y N F I G ========================================================= */ +/*! \file radialblur.cpp +** \brief Implementation of the "Radial Blur" layer ** +** $Id$ +** +** \legal ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2007, 2008 Chris Moore ** ** This package is free software; you can redistribute it and/or ** modify it under the terms of the GNU General Public License as @@ -14,6 +17,7 @@ ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ** General Public License for more details. +** \endlegal ** ** === N O T E S =========================================================== ** @@ -48,10 +52,10 @@ SYNFIG_LAYER_INIT(RadialBlur); SYNFIG_LAYER_SET_NAME(RadialBlur,"radial_blur"); -SYNFIG_LAYER_SET_LOCAL_NAME(RadialBlur,_("Radial Blur")); -SYNFIG_LAYER_SET_CATEGORY(RadialBlur,_("Blurs")); +SYNFIG_LAYER_SET_LOCAL_NAME(RadialBlur,N_("Radial Blur")); +SYNFIG_LAYER_SET_CATEGORY(RadialBlur,N_("Blurs")); SYNFIG_LAYER_SET_VERSION(RadialBlur,"0.1"); -SYNFIG_LAYER_SET_CVS_ID(RadialBlur,"$Id: radialblur.cpp,v 1.1.1.1 2005/01/04 01:23:10 darco Exp $"); +SYNFIG_LAYER_SET_CVS_ID(RadialBlur,"$Id$"); /* === P R O C E D U R E S ================================================= */ @@ -76,8 +80,8 @@ RadialBlur::set_param(const String & param, const ValueBase &value) IMPORT(origin); IMPORT(size); IMPORT(fade_out); - - return Layer_Composite::set_param(param,value); + + return Layer_Composite::set_param(param,value); } ValueBase @@ -86,18 +90,18 @@ RadialBlur::get_param(const String ¶m)const EXPORT(origin); EXPORT(size); EXPORT(fade_out); - + EXPORT_NAME(); EXPORT_VERSION(); - - return Layer_Composite::get_param(param); + + return Layer_Composite::get_param(param); } Layer::Vocab RadialBlur::get_param_vocab()const { Layer::Vocab ret(Layer_Composite::get_param_vocab()); - + ret.push_back(ParamDesc("origin") .set_local_name(_("Origin")) .set_description(_("Point where you want the origin to be")) @@ -112,7 +116,7 @@ RadialBlur::get_param_vocab()const ret.push_back(ParamDesc("fade_out") .set_local_name(_("Fade Out")) ); - + return ret; } @@ -126,63 +130,101 @@ RadialBlur::get_color(Context context, const Point &p)const bool RadialBlur::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const { + // don't do anything at quality 10 + if (quality == 10) + return context.accelerated_render(surface,quality,renddesc,cb); + if(cb && !cb->amount_complete(0,10000)) return false; - - Surface tmp_surface; - - if(!context.accelerated_render(surface,quality,renddesc,cb)) - return false; - tmp_surface=*surface; - - int x,y; + Surface tmp_surface; + const Point tl(renddesc.get_tl()), br(renddesc.get_br()); + const int w(renddesc.get_w()), h(renddesc.get_h()); + const Real pw(renddesc.get_pw()),ph(renddesc.get_ph()); - const Point tl(renddesc.get_tl()); + Rect rect(tl, br); Point pos; - const int w(surface->get_w()); - const int h(surface->get_h()); - const Real pw(renddesc.get_pw()),ph(renddesc.get_ph()); + + // find how far towards the origin of the blur we are going to + // wander for each of the 4 corners of our tile, expanding the + // render description for each of them if necessary + int x, y; + for(y=0,pos[1]=tl[1];yset_wh(w, h); + Surface::pen pen(surface->get_pen(0, 0)); + tmp_surface.blit_to(pen, + int((tl[0] - tmp_surface_tl[0])/pw + 0.5), + int((tl[1] - tmp_surface_tl[1])/ph + 0.5), + w, h); Surface::alpha_pen apen(surface->begin()); apen.set_alpha(get_amount()); apen.set_blend_method(get_blend_method()); - + +/* int steps(5); - + if(quality>=9)steps=20; else if(quality>=5)steps=30; else if(quality>=4)steps=60; else if(quality>=3)steps=100; else steps=120; - +*/ + Surface::value_prep_type cooker; - + + // loop through the pixels for(y=0,pos[1]=tl[1];y 0) ? 1 : -1; dy = abs(y1 - y0); @@ -216,8 +258,9 @@ RadialBlur::accelerated_render(Context context,Surface *surface,int quality, con pool+=cooker.cook(tmp_surface[x0][y0]); poolsize+=1; } - } - + } else + printf("%s:%d unexpected %d >= %d or %d >= %d?\n", __FILE__, __LINE__, x0, w, y0, h); + while (e >= 0) { y0 += sy; @@ -235,7 +278,7 @@ RadialBlur::accelerated_render(Context context,Surface *surface,int quality, con Point begin,end; begin=pos; end=(pos-origin)*(1.0f-size)+origin; - + Color pool(Color::alpha()); float f,poolsize(0); int i; @@ -244,7 +287,7 @@ RadialBlur::accelerated_render(Context context,Surface *surface,int quality, con { Point loc((end-begin)*f+begin-tl); loc[0]/=pw;loc[1]/=ph; - + if(fade_out) pool+=tmp_surface.linear_sample(loc[0],loc[1])*(i-steps),poolsize+=(i-steps); else @@ -258,5 +301,21 @@ RadialBlur::accelerated_render(Context context,Surface *surface,int quality, con if(cb && !cb->amount_complete(10000,10000)) return false; +// #define DRAW_TILE_OUTLINES +#ifdef DRAW_TILE_OUTLINES + // draw red lines to show tiles + { + int x, y; + if (w != 0 && h != 0) { + Surface::alpha_pen apen(surface->begin()); + apen.set_alpha(get_amount()); + apen.set_blend_method(get_blend_method()); + apen.set_value(Color(1, 0, 0, .1)); + for (x = 0; x < w; x++) { apen.put_value(); apen.inc_x(); } apen.dec_x(w); + for (y = 0; y < h; y++) { apen.put_value(); apen.inc_y(); } apen.dec_y(h); + } + } +#endif // DRAW_TILE_OUTLINES + return true; }