X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fmodules%2Flyr_std%2Fbevel.cpp;h=dacf2705ae6e67602b71d79bd37c2d9e050334ac;hb=990f7bb7694e0472ed6ad165e0724864539071cd;hp=aaff2245f84400a2be81669e34bfeb9bcc277e68;hpb=28f28705612902c15cd0702cc891fba35bf2d2df;p=synfig.git diff --git a/synfig-core/trunk/src/modules/lyr_std/bevel.cpp b/synfig-core/trunk/src/modules/lyr_std/bevel.cpp index aaff224..dacf270 100644 --- a/synfig-core/trunk/src/modules/lyr_std/bevel.cpp +++ b/synfig-core/trunk/src/modules/lyr_std/bevel.cpp @@ -1,20 +1,21 @@ /* === S Y N F I G ========================================================= */ -/*! \file shade.cpp -** \brief Template Header +/*! \file bevel.cpp +** \brief Implementation of the "Bevel" layer ** -** $Id: bevel.cpp,v 1.2 2005/01/24 03:08:17 darco Exp $ +** $Id$ ** ** \legal -** Copyright (c) 2002 Robert B. Quattlebaum Jr. +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley ** -** This software and associated documentation -** are CONFIDENTIAL and PROPRIETARY property of -** the above-mentioned copyright holder. +** This package is free software; you can redistribute it and/or +** modify it under the terms of the GNU General Public License as +** published by the Free Software Foundation; either version 2 of +** the License, or (at your option) any later version. ** -** You may not copy, print, publish, or in any -** other way distribute this software without -** a prior written agreement with -** the copyright holder. +** This package is distributed in the hope that it will be useful, +** 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 */ /* ========================================================================= */ @@ -63,10 +64,10 @@ using namespace std; SYNFIG_LAYER_INIT(Layer_Bevel); SYNFIG_LAYER_SET_NAME(Layer_Bevel,"bevel"); -SYNFIG_LAYER_SET_LOCAL_NAME(Layer_Bevel,_("Bevel")); -SYNFIG_LAYER_SET_CATEGORY(Layer_Bevel,_("Stylize")); +SYNFIG_LAYER_SET_LOCAL_NAME(Layer_Bevel,N_("Bevel")); +SYNFIG_LAYER_SET_CATEGORY(Layer_Bevel,N_("Stylize")); SYNFIG_LAYER_SET_VERSION(Layer_Bevel,"0.2"); -SYNFIG_LAYER_SET_CVS_ID(Layer_Bevel,"$Id: bevel.cpp,v 1.2 2005/01/24 03:08:17 darco Exp $"); +SYNFIG_LAYER_SET_CVS_ID(Layer_Bevel,"$Id$"); /* -- F U N C T I O N S ----------------------------------------------------- */ @@ -111,7 +112,7 @@ Layer_Bevel::set_param(const String ¶m, const ValueBase &value) IMPORT(type); IMPORT(use_luma); IMPORT(solid); - + return Layer_Composite::set_param(param,value); } @@ -126,11 +127,11 @@ Layer_Bevel::get_param(const String ¶m)const EXPORT(angle); EXPORT(use_luma); EXPORT(solid); - + EXPORT_NAME(); EXPORT_VERSION(); - - return Layer_Composite::get_param(param); + + return Layer_Composite::get_param(param); } Color @@ -141,18 +142,18 @@ Layer_Bevel::get_color(Context context, const Point &pos)const if(get_amount()==0.0) return context.get_color(pos); - + Color shade; Real hi_alpha(1.0f-context.get_color(blurpos+offset).get_a()); Real lo_alpha(1.0f-context.get_color(blurpos-offset).get_a()); - + Real shade_alpha(hi_alpha-lo_alpha); if(shade_alpha>0) shade=color1,shade.set_a(shade_alpha); - else + else shade=color2,shade.set_a(-shade_alpha); - + return Color::blend(shade,context.get_color(pos),get_amount(),get_blend_method()); } @@ -162,39 +163,39 @@ Layer_Bevel::accelerated_render(Context context,Surface *surface,int quality, co int x,y; SuperCallback stageone(cb,0,5000,10000); SuperCallback stagetwo(cb,5000,10000,10000); - + const int w = renddesc.get_w(), h = renddesc.get_h(); const Real pw = renddesc.get_pw(), ph = renddesc.get_ph(); const Vector size(softness,softness); - + RendDesc workdesc(renddesc); Surface worksurface; etl::surface blurred; - + //callbacks depend on how long the blur takes if(size[0] || size[1]) { if(type == Blur::DISC) { stageone = SuperCallback(cb,0,5000,10000); - stagetwo = SuperCallback(cb,5000,10000,10000); + stagetwo = SuperCallback(cb,5000,10000,10000); } else { stageone = SuperCallback(cb,0,9000,10000); - stagetwo = SuperCallback(cb,9000,10000,10000); + stagetwo = SuperCallback(cb,9000,10000,10000); } } else { stageone = SuperCallback(cb,0,9999,10000); - stagetwo = SuperCallback(cb,9999,10000,10000); + stagetwo = SuperCallback(cb,9999,10000,10000); } - + //expand the working surface to accommodate the blur - + //the expanded size = 1/2 the size in each direction rounded up int halfsizex = (int) (abs(size[0]*.5/pw) + 3), halfsizey = (int) (abs(size[1]*.5/ph) + 3); @@ -208,7 +209,7 @@ Layer_Bevel::accelerated_render(Context context,Surface *surface,int quality, co w+abs(offset_u), h+abs(offset_v) ); - + //expand by 1/2 size in each direction on either side switch(type) { @@ -234,7 +235,7 @@ Layer_Bevel::accelerated_render(Context context,Surface *surface,int quality, co #define GAUSSIAN_ADJUSTMENT (0.05) Real pw = (Real)workdesc.get_w()/(workdesc.get_br()[0]-workdesc.get_tl()[0]); Real ph = (Real)workdesc.get_h()/(workdesc.get_br()[1]-workdesc.get_tl()[1]); - + pw=pw*pw; ph=ph*ph; @@ -244,11 +245,11 @@ Layer_Bevel::accelerated_render(Context context,Surface *surface,int quality, co halfsizex = (halfsizex + 1)/2; halfsizey = (halfsizey + 1)/2; workdesc.set_subwindow( -halfsizex, -halfsizey, offset_w+2*halfsizex, offset_h+2*halfsizey ); - + break; } } - + //render the background onto the expanded surface if(!context.accelerated_render(&worksurface,quality,workdesc,&stageone)) return false; @@ -277,7 +278,7 @@ Layer_Bevel::accelerated_render(Context context,Surface *surface,int quality, co //be sure the surface is of the correct size surface->set_wh(renddesc.get_w(),renddesc.get_h()); - + int u = halfsizex+abs(offset_u), v = halfsizey+abs(offset_v); for(y=0;y0) shade=color1,shade.set_a(shade.get_a()*alpha); - else + else shade=color2,shade.set_a(shade.get_a()*-alpha); } - - + + if(shade.get_a()) { (*surface)[y][x]=Color::blend(shade,worksurface[v][u],get_amount(),get_blend_method()); @@ -336,16 +337,16 @@ Layer_Bevel::accelerated_render(Context context,Surface *surface,int quality, co else (*surface)[y][x] = worksurface[v][u]; } } - + if(cb && !cb->amount_complete(10000,10000)) { //if(cb)cb->error(strprintf(__FILE__"%d: Accelerated Renderer Failure",__LINE__)); return false; } - + return true; } - + Layer::Vocab Layer_Bevel::get_param_vocab(void)const { @@ -385,7 +386,7 @@ Layer_Bevel::get_param_vocab(void)const ret.push_back(ParamDesc("solid") .set_local_name(_("Solid")) ); - + return ret; } @@ -403,6 +404,6 @@ Layer_Bevel::get_full_bounding_rect(Context context)const Rect bounds(under.expand(softness)); bounds.expand_x(abs(depth)); bounds.expand_y(abs(depth)); - + return bounds; }