**
** This package is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License as
**
** This package is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License as
SYNFIG_LAYER_INIT(Layer_Shade);
SYNFIG_LAYER_SET_NAME(Layer_Shade,"shade");
SYNFIG_LAYER_INIT(Layer_Shade);
SYNFIG_LAYER_SET_NAME(Layer_Shade,"shade");
-SYNFIG_LAYER_SET_LOCAL_NAME(Layer_Shade,_("Shade"));
-SYNFIG_LAYER_SET_CATEGORY(Layer_Shade,_("Stylize"));
+SYNFIG_LAYER_SET_LOCAL_NAME(Layer_Shade,N_("Shade"));
+SYNFIG_LAYER_SET_CATEGORY(Layer_Shade,N_("Stylize"));
return Color::blend(shade,context.get_color(pos),get_amount(),get_blend_method());
}
return Color::blend(shade,context.get_color(pos),get_amount(),get_blend_method());
}
Layer_Shade::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const
{
int x,y;
Layer_Shade::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const
{
int x,y;
const int w = renddesc.get_w(),
h = renddesc.get_h();
const Real pw = renddesc.get_pw(),
ph = renddesc.get_ph();
const int w = renddesc.get_w(),
h = renddesc.get_h();
const Real pw = renddesc.get_pw(),
ph = renddesc.get_ph();
//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);
//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);
- offset_u<0?offset_u:0,
- offset_v<0?offset_v:0,
- (offset_u>0?offset_u:0)+w,
- (offset_v>0?offset_v:0)+h
+ origin_u<0?origin_u:0,
+ origin_v<0?origin_v:0,
+ (origin_u>0?origin_u:0)+w,
+ (origin_v>0?origin_v:0)+h
- workdesc.set_subwindow(-max(1,halfsizex),-max(1,halfsizey),offset_w+2*max(1,halfsizex),offset_h+2*max(1,halfsizey));
+ workdesc.set_subwindow(-max(1,halfsizex),-max(1,halfsizey),origin_w+2*max(1,halfsizex),origin_h+2*max(1,halfsizey));
- workdesc.set_subwindow(-max(1,halfsizex),-max(1,halfsizey),offset_w+2*max(1,halfsizex),offset_h+2*max(1,halfsizey));
+ workdesc.set_subwindow(-max(1,halfsizex),-max(1,halfsizey),origin_w+2*max(1,halfsizex),origin_h+2*max(1,halfsizey));
#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]);
#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]);
- workdesc.set_subwindow( -halfsizex, -halfsizey, offset_w+2*halfsizex, offset_h+2*halfsizey );
-
+ workdesc.set_subwindow( -halfsizex, -halfsizey, origin_w+2*halfsizex, origin_h+2*halfsizey );
+
{
SuperCallback stageone(cb,0,5000,10000);
SuperCallback stagetwo(cb,5000,10000,10000);
{
SuperCallback stageone(cb,0,5000,10000);
SuperCallback stagetwo(cb,5000,10000,10000);
//callbacks depend on how long the blur takes
if(size[0] || size[1])
{
if(type == Blur::DISC)
{
stageone = SuperCallback(cb,0,5000,10000);
//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);
}
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);
}
}
else
{
stageone = SuperCallback(cb,0,9999,10000);
- stagetwo = SuperCallback(cb,9999,10000,10000);
+ stagetwo = SuperCallback(cb,9999,10000,10000);
//render the background onto the expanded surface
if(!context.accelerated_render(&worksurface,quality,workdesc,&stageone))
return false;
//render the background onto the expanded surface
if(!context.accelerated_render(&worksurface,quality,workdesc,&stageone))
return false;
// Copy over the alpha
blurred.set_wh(worksurface.get_w(),worksurface.get_h());
for(int j=0;j<worksurface.get_h();j++)
// Copy over the alpha
blurred.set_wh(worksurface.get_w(),worksurface.get_h());
for(int j=0;j<worksurface.get_h();j++)
//blur the image
Blur(size,type,&stagetwo)(blurred,workdesc.get_br()-workdesc.get_tl(),blurred);
//blur the image
Blur(size,type,&stagetwo)(blurred,workdesc.get_br()-workdesc.get_tl(),blurred);
//be sure the surface is of the correct size
surface->set_wh(renddesc.get_w(),renddesc.get_h());
//be sure the surface is of the correct size
surface->set_wh(renddesc.get_w(),renddesc.get_h());
if(a.get_a() || get_blend_method()==Color::BLEND_STRAIGHT)
{
(*surface)[y][x]=Color::blend(a,worksurface[v][u],get_amount(),get_blend_method());
if(a.get_a() || get_blend_method()==Color::BLEND_STRAIGHT)
{
(*surface)[y][x]=Color::blend(a,worksurface[v][u],get_amount(),get_blend_method());
SuperCallback stageone(cb,0,5000,10000);
SuperCallback stagetwo(cb,5000,10000,10000);
SuperCallback stageone(cb,0,5000,10000);
SuperCallback stagetwo(cb,5000,10000,10000);
//callbacks depend on how long the blur takes
if(size[0] || size[1])
{
if(type == Blur::DISC)
{
stageone = SuperCallback(cb,0,5000,10000);
//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);
}
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);
}
}
else
{
stageone = SuperCallback(cb,0,9999,10000);
- stagetwo = SuperCallback(cb,9999,10000,10000);
+ stagetwo = SuperCallback(cb,9999,10000,10000);
}
int fw(floor_to_int(abs(size[0]/(pw*SCALE_FACTOR)))+1);
int fh(floor_to_int(abs(size[1]/(ph*SCALE_FACTOR)))+1);
int tmpw(round_to_int((float)workdesc.get_w()/fw)),tmph(round_to_int((float)workdesc.get_h()/fh));
}
int fw(floor_to_int(abs(size[0]/(pw*SCALE_FACTOR)))+1);
int fh(floor_to_int(abs(size[1]/(ph*SCALE_FACTOR)))+1);
int tmpw(round_to_int((float)workdesc.get_w()/fw)),tmph(round_to_int((float)workdesc.get_h()/fh));
workdesc.clear_flags();
workdesc.set_wh(tmpw,tmph);
//synfig::info("fw: %d, fh: %d",fw,fh);
workdesc.clear_flags();
workdesc.set_wh(tmpw,tmph);
//synfig::info("fw: %d, fh: %d",fw,fh);
for(int j=0;j<worksurface.get_h();j++)
for(int i=0;i<worksurface.get_w();i++)
blurred[j][i]=worksurface[j][i].get_a();
for(int j=0;j<worksurface.get_h();j++)
for(int i=0;i<worksurface.get_w();i++)
blurred[j][i]=worksurface[j][i].get_a();
//blur the image
Blur(size,type,&stagetwo)(blurred,workdesc.get_br()-workdesc.get_tl(),blurred);
//blur the image
Blur(size,type,&stagetwo)(blurred,workdesc.get_br()-workdesc.get_tl(),blurred);
if(a.get_a() || get_blend_method()==Color::BLEND_STRAIGHT)
{
(*surface)[y][x]=Color::blend(a,(*surface)[y][x],get_amount(),get_blend_method());
if(a.get_a() || get_blend_method()==Color::BLEND_STRAIGHT)
{
(*surface)[y][x]=Color::blend(a,(*surface)[y][x],get_amount(),get_blend_method());
if(cb && !cb->amount_complete(10000,10000))
{
//if(cb)cb->error(strprintf(__FILE__"%d: Accelerated Renderer Failure",__LINE__));
return false;
}
if(cb && !cb->amount_complete(10000,10000))
{
//if(cb)cb->error(strprintf(__FILE__"%d: Accelerated Renderer Failure",__LINE__));
return false;
}
);
ret.push_back(ParamDesc("size")
.set_local_name(_("Size"))
.set_description(_("Size of Shade"))
.set_is_distance()
);
ret.push_back(ParamDesc("size")
.set_local_name(_("Size"))
.set_description(_("Size of Shade"))
.set_is_distance()
.add_enum_value(Blur::GAUSSIAN,"gaussian",_("Gaussian Blur"))
.add_enum_value(Blur::DISC,"disc",_("Disc Blur"))
);
.add_enum_value(Blur::GAUSSIAN,"gaussian",_("Gaussian Blur"))
.add_enum_value(Blur::DISC,"disc",_("Disc Blur"))
);