projects
/
synfig.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixing user name...
[synfig.git]
/
synfig-core
/
trunk
/
src
/
modules
/
lyr_std
/
shade.cpp
diff --git
a/synfig-core/trunk/src/modules/lyr_std/shade.cpp
b/synfig-core/trunk/src/modules/lyr_std/shade.cpp
index
b1746ef
..
4ab3917
100644
(file)
--- a/
synfig-core/trunk/src/modules/lyr_std/shade.cpp
+++ b/
synfig-core/trunk/src/modules/lyr_std/shade.cpp
@@
-1,11
+1,12
@@
/* === S Y N F I G ========================================================= */
/*! \file shade.cpp
/* === S Y N F I G ========================================================= */
/*! \file shade.cpp
-** \brief
Template Head
er
+** \brief
Implementation of the "Shade" lay
er
**
** $Id$
**
** \legal
** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
**
** $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
**
** This package is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License as
@@
-80,7
+81,7
@@
Layer_Shade::Layer_Shade():
size(0.1,0.1),
type(Blur::FASTGAUSSIAN),
color(Color::black()),
size(0.1,0.1),
type(Blur::FASTGAUSSIAN),
color(Color::black()),
- o
ffset
(0.2,-0.2),
+ o
rigin
(0.2,-0.2),
invert(false)
{
}
invert(false)
{
}
@@
-90,10
+91,14
@@
Layer_Shade::set_param(const String ¶m, const ValueBase &value)
{
IMPORT_PLUS(size,clamp(size));
IMPORT(type);
{
IMPORT_PLUS(size,clamp(size));
IMPORT(type);
- IMPORT(color);
- IMPORT(offset);
+ IMPORT_PLUS(color, { if (color.get_a() == 0) { if (converted_blend_) {
+ set_blend_method(Color::BLEND_ALPHA_OVER);
+ color.set_a(1); } else transparent_color_ = true; } });
+ IMPORT(origin);
IMPORT(invert);
IMPORT(invert);
+ IMPORT_AS(origin,"offset");
+
return Layer_Composite::set_param(param,value);
}
return Layer_Composite::set_param(param,value);
}
@@
-103,7
+108,7
@@
Layer_Shade::get_param(const String ¶m)const
EXPORT(size);
EXPORT(type);
EXPORT(color);
EXPORT(size);
EXPORT(type);
EXPORT(color);
- EXPORT(o
ffset
);
+ EXPORT(o
rigin
);
EXPORT(invert);
EXPORT_NAME();
EXPORT(invert);
EXPORT_NAME();
@@
-123,9
+128,9
@@
Layer_Shade::get_color(Context context, const Point &pos)const
Color shade(color);
if(!invert)
Color shade(color);
if(!invert)
- shade.set_a(context.get_color(blurpos-o
ffset
).get_a());
+ shade.set_a(context.get_color(blurpos-o
rigin
).get_a());
else
else
- shade.set_a(1.0f-context.get_color(blurpos-o
ffset
).get_a());
+ shade.set_a(1.0f-context.get_color(blurpos-o
rigin
).get_a());
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());
}
@@
-150,25
+155,23
@@
Layer_Shade::accelerated_render(Context context,Surface *surface,int quality, co
int halfsizex = (int) (abs(size[0]*.5/pw) + 3),
halfsizey = (int) (abs(size[1]*.5/ph) + 3);
int halfsizex = (int) (abs(size[0]*.5/pw) + 3),
halfsizey = (int) (abs(size[1]*.5/ph) + 3);
- int o
ffset_u(-round_to_int(offset[0]/pw)),offset_v(-round_to_int(offset
[1]/ph));
+ int o
rigin_u(-round_to_int(origin[0]/pw)),origin_v(-round_to_int(origin
[1]/ph));
- int o
ffset_w(w+abs(offset_u)),offset_h(h+abs(offset
_v));
+ int o
rigin_w(w+abs(origin_u)),origin_h(h+abs(origin
_v));
workdesc.set_subwindow(
workdesc.set_subwindow(
- o
ffset_u<0?offset
_u:0,
- o
ffset_v<0?offset
_v:0,
- (o
ffset_u>0?offset
_u:0)+w,
- (o
ffset_v>0?offset
_v:0)+h
+ o
rigin_u<0?origin
_u:0,
+ o
rigin_v<0?origin
_v:0,
+ (o
rigin_u>0?origin
_u:0)+w,
+ (o
rigin_v>0?origin
_v:0)+h
);
);
- /*
- if(quality >=10)
+ if(quality >= 10)
{
halfsizex=1;
halfsizey=1;
{
halfsizex=1;
halfsizey=1;
- }else
- */
- if(quality == 9)
+ }
+ else if (quality == 9)
{
halfsizex/=4;
halfsizey/=4;
{
halfsizex/=4;
halfsizey/=4;
@@
-181,7
+184,7
@@
Layer_Shade::accelerated_render(Context context,Surface *surface,int quality, co
case Blur::BOX:
case Blur::CROSS:
{
case Blur::BOX:
case Blur::CROSS:
{
- workdesc.set_subwindow(-max(1,halfsizex),-max(1,halfsizey),o
ffset_w+2*max(1,halfsizex),offset
_h+2*max(1,halfsizey));
+ workdesc.set_subwindow(-max(1,halfsizex),-max(1,halfsizey),o
rigin_w+2*max(1,halfsizex),origin
_h+2*max(1,halfsizey));
break;
}
case Blur::FASTGAUSSIAN:
break;
}
case Blur::FASTGAUSSIAN:
@@
-191,7
+194,7
@@
Layer_Shade::accelerated_render(Context context,Surface *surface,int quality, co
halfsizex*=2;
halfsizey*=2;
}
halfsizex*=2;
halfsizey*=2;
}
- workdesc.set_subwindow(-max(1,halfsizex),-max(1,halfsizey),o
ffset_w+2*max(1,halfsizex),offset
_h+2*max(1,halfsizey));
+ workdesc.set_subwindow(-max(1,halfsizex),-max(1,halfsizey),o
rigin_w+2*max(1,halfsizex),origin
_h+2*max(1,halfsizey));
break;
}
case Blur::GAUSSIAN:
break;
}
case Blur::GAUSSIAN:
@@
-208,7
+211,7
@@
Layer_Shade::accelerated_render(Context context,Surface *surface,int quality, co
halfsizex = (halfsizex + 1)/2;
halfsizey = (halfsizey + 1)/2;
halfsizex = (halfsizex + 1)/2;
halfsizey = (halfsizey + 1)/2;
- workdesc.set_subwindow( -halfsizex, -halfsizey, o
ffset_w+2*halfsizex, offset
_h+2*halfsizey );
+ workdesc.set_subwindow( -halfsizex, -halfsizey, o
rigin_w+2*halfsizex, origin
_h+2*halfsizey );
break;
}
break;
}
@@
-259,18
+262,18
@@
Layer_Shade::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());
//be sure the surface is of the correct size
surface->set_wh(renddesc.get_w(),renddesc.get_h());
- int u = halfsizex-(o
ffset_u<0?offset_u:0), v = halfsizey-(offset_v<0?offset
_v:0);
+ int u = halfsizex-(o
rigin_u<0?origin_u:0), v = halfsizey-(origin_v<0?origin
_v:0);
for(y=0;y<renddesc.get_h();y++,v++)
{
for(y=0;y<renddesc.get_h();y++,v++)
{
- u = halfsizex-(o
ffset_u<0?offset
_u:0);
+ u = halfsizex-(o
rigin_u<0?origin
_u:0);
for(x=0;x<renddesc.get_w();x++,u++)
{
Color a(color);
if(!invert)
for(x=0;x<renddesc.get_w();x++,u++)
{
Color a(color);
if(!invert)
- a.set_a(blurred.linear_sample(o
ffset_u+(float)u,offset
_v+(float)v));
+ a.set_a(blurred.linear_sample(o
rigin_u+(float)u,origin
_v+(float)v));
else
else
- a.set_a(1.0f-blurred.linear_sample(o
ffset_u+(float)u,offset
_v+(float)v));
+ a.set_a(1.0f-blurred.linear_sample(o
rigin_u+(float)u,origin
_v+(float)v));
if(a.get_a() || get_blend_method()==Color::BLEND_STRAIGHT)
{
if(a.get_a() || get_blend_method()==Color::BLEND_STRAIGHT)
{
@@
-332,18
+335,18
@@
Layer_Shade::accelerated_render(Context context,Surface *surface,int quality, co
Blur(size,type,&stagetwo)(blurred,workdesc.get_br()-workdesc.get_tl(),blurred);
Blur(size,type,&stagetwo)(blurred,workdesc.get_br()-workdesc.get_tl(),blurred);
- int u = halfsizex-(o
ffset_u<0?offset_u:0), v = halfsizey-(offset_v<0?offset
_v:0);
+ int u = halfsizex-(o
rigin_u<0?origin_u:0), v = halfsizey-(origin_v<0?origin
_v:0);
for(y=0;y<renddesc.get_h();y++,v++)
{
for(y=0;y<renddesc.get_h();y++,v++)
{
- u = halfsizex-(o
ffset_u<0?offset
_u:0);
+ u = halfsizex-(o
rigin_u<0?origin
_u:0);
for(x=0;x<renddesc.get_w();x++,u++)
{
Color a(color);
if(!invert)
for(x=0;x<renddesc.get_w();x++,u++)
{
Color a(color);
if(!invert)
- a.set_a(blurred.linear_sample(((float)o
ffset_u+(float)u)/(float)fw,((float)offset
_v+(float)v)/(float)fh));
+ a.set_a(blurred.linear_sample(((float)o
rigin_u+(float)u)/(float)fw,((float)origin
_v+(float)v)/(float)fh));
else
else
- a.set_a(1.0f-blurred.linear_sample(((float)o
ffset_u+(float)u)/fw,((float)offset
_v+(float)v)/(float)fh));
+ a.set_a(1.0f-blurred.linear_sample(((float)o
rigin_u+(float)u)/fw,((float)origin
_v+(float)v)/(float)fh));
if(a.get_a() || get_blend_method()==Color::BLEND_STRAIGHT)
{
if(a.get_a() || get_blend_method()==Color::BLEND_STRAIGHT)
{
@@
-371,14
+374,14
@@
Layer_Shade::get_param_vocab(void)const
ret.push_back(ParamDesc("color")
.set_local_name(_("Color"))
);
ret.push_back(ParamDesc("color")
.set_local_name(_("Color"))
);
- ret.push_back(ParamDesc("o
ffset
")
- .set_local_name(_("O
ffset
"))
+ ret.push_back(ParamDesc("o
rigin
")
+ .set_local_name(_("O
rigin
"))
);
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()
- .set_origin("o
ffset
")
+ .set_origin("o
rigin
")
);
ret.push_back(ParamDesc("type")
.set_local_name(_("Type"))
);
ret.push_back(ParamDesc("type")
.set_local_name(_("Type"))
@@
-412,7
+415,7
@@
Layer_Shade::get_full_bounding_rect(Context context)const
if(Color::is_onto(get_blend_method()))
return under;
if(Color::is_onto(get_blend_method()))
return under;
- Rect bounds((under+o
ffset
).expand_x(size[0]).expand_y(size[1]));
+ Rect bounds((under+o
rigin
).expand_x(size[0]).expand_y(size[1]));
if(is_solid_color())
return bounds;
if(is_solid_color())
return bounds;