X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fmodules%2Fmod_filter%2Fradialblur.cpp;h=4c7f749990aa18883fcd51ba67247d38cda07099;hb=37600b4b217caa5e316984ec0b035c5e8f9698af;hp=786615a9cd64c871aa53c38fc8d0e12953d80e3d;hpb=675aca937d23c7f460edf42ac3ec0ffa06205a2c;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 786615a..4c7f749 100644 --- a/synfig-core/trunk/src/modules/mod_filter/radialblur.cpp +++ b/synfig-core/trunk/src/modules/mod_filter/radialblur.cpp @@ -6,6 +6,7 @@ ** ** \legal ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2007 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 @@ -133,25 +134,57 @@ RadialBlur::accelerated_render(Context context,Surface *surface,int quality, con return false; 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()); - if(!context.accelerated_render(surface,quality,renddesc,cb)) - return false; - - tmp_surface=*surface; + Rect rect(tl, br); + Point pos; - int x,y; + // 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];yget_w()); - const int h(surface->get_h()); - const Real pw(renddesc.get_pw()),ph(renddesc.get_ph()); + // copy the part of the layers beneath us that corresponds to this tile + surface->set_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; @@ -159,15 +192,17 @@ RadialBlur::accelerated_render(Context context,Surface *surface,int quality, con 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; @@ -219,7 +254,8 @@ 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) { @@ -261,5 +297,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; }