X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fmodules%2Flyr_std%2Fsphere_distort.cpp;h=9c0003e677e2c6141fbf216e8fb691f4fbca51db;hb=9459638ad6797b8139f1e9f0715c96076dbf0890;hp=2ed5361fdd9f5f6da715bff0926e7c0bd5827121;hpb=5ddcf36f04cfbd10fabda4e3c5633cb27cdd4c0a;p=synfig.git diff --git a/synfig-core/trunk/src/modules/lyr_std/sphere_distort.cpp b/synfig-core/trunk/src/modules/lyr_std/sphere_distort.cpp index 2ed5361..9c0003e 100644 --- a/synfig-core/trunk/src/modules/lyr_std/sphere_distort.cpp +++ b/synfig-core/trunk/src/modules/lyr_std/sphere_distort.cpp @@ -1,11 +1,12 @@ /* === S Y N F I G ========================================================= */ /*! \file sphere_distort.cpp -** \brief Sphere Distort File +** \brief Implementation of the "Spherize" layer ** -** $Id: sphere_distort.cpp,v 1.2 2005/01/24 05:00:18 darco Exp $ +** $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 @@ -68,10 +69,10 @@ enum SYNFIG_LAYER_INIT(Layer_SphereDistort); SYNFIG_LAYER_SET_NAME(Layer_SphereDistort,"spherize"); -SYNFIG_LAYER_SET_LOCAL_NAME(Layer_SphereDistort,_("Spherize")); -SYNFIG_LAYER_SET_CATEGORY(Layer_SphereDistort,_("Distortions")); +SYNFIG_LAYER_SET_LOCAL_NAME(Layer_SphereDistort,N_("Spherize")); +SYNFIG_LAYER_SET_CATEGORY(Layer_SphereDistort,N_("Distortions")); SYNFIG_LAYER_SET_VERSION(Layer_SphereDistort,"0.2"); -SYNFIG_LAYER_SET_CVS_ID(Layer_SphereDistort,"$Id: sphere_distort.cpp,v 1.2 2005/01/24 05:00:18 darco Exp $"); +SYNFIG_LAYER_SET_CVS_ID(Layer_SphereDistort,"$Id$"); /* === P R O C E D U R E S ================================================= */ @@ -80,8 +81,7 @@ SYNFIG_LAYER_SET_CVS_ID(Layer_SphereDistort,"$Id: sphere_distort.cpp,v 1.2 2005/ /* === E N T R Y P O I N T ================================================= */ Layer_SphereDistort::Layer_SphereDistort() -:Layer_Composite(1.0,Color::BLEND_STRAIGHT), -center(0,0), +:center(0,0), radius(1), percent(1.0), type(TYPE_NORMAL), @@ -349,7 +349,14 @@ bool Layer_SphereDistort::accelerated_render(Context context,Surface *surface,in (type == TYPE_DISTV && (sphr.miny >= windr.maxy || windr.miny >= sphr.maxy)) ) { //synfig::warning("Spherize: Bounding box reject"); - return context.accelerated_render(surface,quality,renddesc,cb); + if (clip) + { + surface->set_wh(renddesc.get_w(), renddesc.get_h()); + surface->clear(); + return true; + } + else + return context.accelerated_render(surface,quality,renddesc,cb); } //synfig::warning("Spherize: Bounding box accept"); @@ -395,7 +402,7 @@ bool Layer_SphereDistort::accelerated_render(Context context,Surface *surface,in close = origin[i] + v[i]*t; - //now get transforms and expand the rectangle to accomodate + //now get transforms and expand the rectangle to accommodate Point p = sphtrans(close,center,radius,percent,type); expandr.expand(p[0],p[1]); p = sphtrans(origin[i],center,radius,percent,type); @@ -407,7 +414,7 @@ bool Layer_SphereDistort::accelerated_render(Context context,Surface *surface,in /*synfig::warning("Spherize: Bounding box (%f,%f)-(%f,%f)", expandr.minx,expandr.miny,expandr.maxx,expandr.maxy);*/ - //now that we have the bouding rectangle of ALL the pixels (should be...) + //now that we have the bounding rectangle of ALL the pixels (should be...) //order it so that it's in the same orientation as the tl,br pair //synfig::warning("Spherize: Organize like tl,br"); @@ -504,19 +511,14 @@ bool Layer_SphereDistort::accelerated_render(Context context,Surface *surface,in } //sample at that pixel location based on the quality - if(quality <= 4) //cubic - { + if(quality <= 4) // cubic p.put_value(background.cubic_sample(xs,ys)); - }else if(quality <= 5) //cosine - { + else if(quality <= 5) // cosine p.put_value(background.cosine_sample(xs,ys)); - }else if(quality <= 6) //linear - { + else if(quality <= 6) // linear p.put_value(background.linear_sample(xs,ys)); - }else //nearest - { + else // nearest p.put_value(background[round_to_int(ys)][round_to_int(xs)]); - } } p.dec_x(w); } @@ -552,19 +554,21 @@ Rect Layer_SphereDistort::get_bounding_rect()const { Rect bounds(Rect::full_plane()); + + if (clip) + return bounds; + switch(type) { case TYPE_NORMAL: - bounds=Rect( - center[0]+(radius), - center[1]+(radius), - center[0]-(radius), - center[1]-(radius) - ); + bounds=Rect(center[0]+radius, center[1]+radius, + center[0]-radius, center[1]-radius); break; case TYPE_DISTH: + bounds = Rect::vertical_strip(center[0]-radius, center[0]+radius); break; case TYPE_DISTV: + bounds = Rect::horizontal_strip(center[1]-radius, center[1]+radius); break; default: break; @@ -572,4 +576,3 @@ Layer_SphereDistort::get_bounding_rect()const return bounds; } -