X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fmodules%2Flyr_std%2Frotate.cpp;h=fd13f92394f7c1a6c17e36bd7c63032cb670ac05;hb=9459638ad6797b8139f1e9f0715c96076dbf0890;hp=963e8e511205c81cf9efb428a2442ec8b2104a4b;hpb=675aca937d23c7f460edf42ac3ec0ffa06205a2c;p=synfig.git diff --git a/synfig-core/trunk/src/modules/lyr_std/rotate.cpp b/synfig-core/trunk/src/modules/lyr_std/rotate.cpp index 963e8e5..fd13f92 100644 --- a/synfig-core/trunk/src/modules/lyr_std/rotate.cpp +++ b/synfig-core/trunk/src/modules/lyr_std/rotate.cpp @@ -1,11 +1,12 @@ /* === S Y N F I G ========================================================= */ /*! \file rotate.cpp -** \brief Template Header +** \brief Implementation of the "Rotate" layer ** ** $Id$ ** ** \legal ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 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 @@ -51,8 +52,8 @@ SYNFIG_LAYER_INIT(Rotate); SYNFIG_LAYER_SET_NAME(Rotate,"rotate"); -SYNFIG_LAYER_SET_LOCAL_NAME(Rotate,_("Rotate")); -SYNFIG_LAYER_SET_CATEGORY(Rotate,_("Transform")); +SYNFIG_LAYER_SET_LOCAL_NAME(Rotate,N_("Rotate")); +SYNFIG_LAYER_SET_CATEGORY(Rotate,N_("Transform")); SYNFIG_LAYER_SET_VERSION(Rotate,"0.1"); SYNFIG_LAYER_SET_CVS_ID(Rotate,"$Id$"); @@ -79,7 +80,7 @@ Rotate::set_param(const String & param, const ValueBase &value) { IMPORT(origin); - if(param=="amount" && value.same_as(amount)) + if(param=="amount" && value.same_type_as(amount)) { amount=value.get(amount); sin_val=Angle::sin(amount).get(); @@ -188,42 +189,50 @@ Rotate::accelerated_render(Context context,Surface *surface,int quality, const R Point tl(renddesc.get_tl()-origin); Point br(renddesc.get_br()-origin); - Point rot_tl(cos_val*tl[0]+sin_val*tl[1],-sin_val*tl[0]+cos_val*tl[1]); - Point rot_br(cos_val*br[0]+sin_val*br[1],-sin_val*br[0]+cos_val*br[1]); - Point rot_tr(cos_val*br[0]+sin_val*tl[1],-sin_val*br[0]+cos_val*tl[1]); - Point rot_bl(cos_val*tl[0]+sin_val*br[1],-sin_val*tl[0]+cos_val*br[1]); - rot_tl+=origin; - rot_br+=origin; - rot_tr+=origin; - rot_bl+=origin; - - Point min_point(min(min(min(rot_tl[0],rot_br[0]),rot_tr[0]),rot_bl[0]),min(min(min(rot_tl[1],rot_br[1]),rot_tr[1]),rot_bl[1])); - Point max_point(max(max(max(rot_tl[0],rot_br[0]),rot_tr[0]),rot_bl[0]),max(max(max(rot_tl[1],rot_br[1]),rot_tr[1]),rot_bl[1])); - - if(tl[0]>br[0]) - { - tl[0]=max_point[0]; - br[0]=min_point[0]; - } - else - { - br[0]=max_point[0]; - tl[0]=min_point[0]; - } - if(tl[1]>br[1]) - { - tl[1]=max_point[1]; - br[1]=min_point[1]; - } - else + { - br[1]=max_point[1]; - tl[1]=min_point[1]; + Point rot_tl(cos_val*tl[0]+sin_val*tl[1],-sin_val*tl[0]+cos_val*tl[1]); + Point rot_br(cos_val*br[0]+sin_val*br[1],-sin_val*br[0]+cos_val*br[1]); + Point rot_tr(cos_val*br[0]+sin_val*tl[1],-sin_val*br[0]+cos_val*tl[1]); + Point rot_bl(cos_val*tl[0]+sin_val*br[1],-sin_val*tl[0]+cos_val*br[1]); + rot_tl+=origin; + rot_br+=origin; + rot_tr+=origin; + rot_bl+=origin; + + Point min_point(min(min(min(rot_tl[0],rot_br[0]),rot_tr[0]),rot_bl[0]),min(min(min(rot_tl[1],rot_br[1]),rot_tr[1]),rot_bl[1])); + Point max_point(max(max(max(rot_tl[0],rot_br[0]),rot_tr[0]),rot_bl[0]),max(max(max(rot_tl[1],rot_br[1]),rot_tr[1]),rot_bl[1])); + + if(tl[0]>br[0]) + { + tl[0]=max_point[0]; + br[0]=min_point[0]; + } + else + { + br[0]=max_point[0]; + tl[0]=min_point[0]; + } + if(tl[1]>br[1]) + { + tl[1]=max_point[1]; + br[1]=min_point[1]; + } + else + { + br[1]=max_point[1]; + tl[1]=min_point[1]; + } } Real pw=(renddesc.get_w())/(renddesc.get_br()[0]-renddesc.get_tl()[0]); Real ph=(renddesc.get_h())/(renddesc.get_br()[1]-renddesc.get_tl()[1]); + // we're going to round the canvas size to an integer number of pixels, so round the + // tl-br rectangle accordingly - otherwise we see the jittering described in bug 2152666 + br[0] -= (pw*(br[0]-tl[0]) - round_to_int(pw*(br[0]-tl[0]))) / pw; + br[1] -= (ph*(br[1]-tl[1]) - round_to_int(ph*(br[1]-tl[1]))) / ph; + RendDesc desc(renddesc); desc.clear_flags(); //desc.set_flags(RendDesc::PX_ASPECT); @@ -256,7 +265,7 @@ Rotate::accelerated_render(Context context,Surface *surface,int quality, const R tmp=Point(cos_val*(point[0]-origin[0])+sin_val*(point[1]-origin[1]),-sin_val*(point[0]-origin[0])+cos_val*(point[1]-origin[1])) +origin; (*surface)[y][x]=source.cubic_sample((tmp[0]-tl[0])*pw,(tmp[1]-tl[1])*ph); } - if(y&31==0 && cb) + if((y&31)==0 && cb) { if(!stagetwo.amount_complete(y,surface->get_h())) return false; @@ -276,7 +285,7 @@ Rotate::accelerated_render(Context context,Surface *surface,int quality, const R tmp=Point(cos_val*(point[0]-origin[0])+sin_val*(point[1]-origin[1]),-sin_val*(point[0]-origin[0])+cos_val*(point[1]-origin[1])) +origin; (*surface)[y][x]=source.linear_sample((tmp[0]-tl[0])*pw,(tmp[1]-tl[1])*ph); } - if(y&31==0 && cb) + if((y&31)==0 && cb) { if(!stagetwo.amount_complete(y,surface->get_h())) return false; @@ -306,7 +315,7 @@ Rotate::accelerated_render(Context context,Surface *surface,int quality, const R //pen.set_value(source[v][u]); (*surface)[y][x]=source[v][u]; } - if(y&31==0 && cb) + if((y&31)==0 && cb) { if(!stagetwo.amount_complete(y,surface->get_h())) return false;