Author: Carlos Lopez <[email protected]>
Date: Sat Jun 9 11:57:44 2012 +0200
Templatize _BlendFunc for generic alpha pen usage
---
synfig-core/src/modules/mod_geometry/circle.cpp | 2 +-
synfig-core/src/synfig/layer_shape.cpp | 2 +-
synfig-core/src/synfig/surface.h | 19 ++++++++++---------
3 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/synfig-core/src/modules/mod_geometry/circle.cpp
b/synfig-core/src/modules/mod_geometry/circle.cpp
index 4c0f7cc..6bd9ecd 100644
--- a/synfig-core/src/modules/mod_geometry/circle.cpp
+++ b/synfig-core/src/modules/mod_geometry/circle.cpp
@@ -512,7 +512,7 @@ Circle::accelerated_render(Context context,Surface
*surface,int quality, const R
return false;
}
- Surface::alpha_pen
p(surface->begin(),get_amount(),_BlendFunc(get_blend_method()));
+ Surface::alpha_pen
p(surface->begin(),get_amount(),get_blend_method());
p.set_value(color);
p.put_block(h,w);
diff --git a/synfig-core/src/synfig/layer_shape.cpp
b/synfig-core/src/synfig/layer_shape.cpp
index 2116d2f..a6d6297 100644
--- a/synfig-core/src/synfig/layer_shape.cpp
+++ b/synfig-core/src/synfig/layer_shape.cpp
@@ -2159,7 +2159,7 @@ void Layer_Shape::curve_to_smooth(Real x2, Real y2, Real
x, Real y) //x1,y1 der
bool Layer_Shape::render_polyspan(Surface *surface, PolySpan &polyspan,
Color::BlendMethod got_blend_method, Color::value_type got_amount) const
{
- Surface::alpha_pen
p(surface->begin(),got_amount,_BlendFunc(got_blend_method));
+ Surface::alpha_pen p(surface->begin(),got_amount,got_blend_method);
PolySpan::cover_array::iterator cur_mark = polyspan.covers.begin();
PolySpan::cover_array::iterator end_mark = polyspan.covers.end();
diff --git a/synfig-core/src/synfig/surface.h b/synfig-core/src/synfig/surface.h
index 875385a..4195808 100644
--- a/synfig-core/src/synfig/surface.h
+++ b/synfig-core/src/synfig/surface.h
@@ -120,15 +120,16 @@ public:
#ifndef DOXYGEN_SKIP
/*! \internal Used by Pen_Alpha */
+template <class C, typename A=Color::value_type>
struct _BlendFunc
{
- Color::BlendMethod blend_method;
+ typename C::BlendMethod blend_method;
- _BlendFunc(Color::BlendMethod b=
Color::BLEND_COMPOSITE):blend_method(b) { }
+ _BlendFunc(typename Color::BlendMethod b=
Color::BLEND_COMPOSITE):blend_method(b) { }
- Color operator()(const Color &a,const Color &b,const Color::value_type
&t)const
+ C operator()(const C &a,const C &b,const A &t)const
{
- return Color::blend(b,a,t,blend_method);
+ return C::blend(b,a,t,blend_method);
}
}; // END of class _BlendFunc
@@ -143,16 +144,16 @@ struct _BlendFunc
** The default blending method is Color::BLEND_COMPOSITE.
** \see Color::BlendMethod
*/
-class Surface::alpha_pen : public etl::alpha_pen< etl::generic_pen<Color,
ColorAccumulator>, Color::value_type, _BlendFunc >
+class Surface::alpha_pen : public etl::alpha_pen< etl::generic_pen<Color,
ColorAccumulator>, Color::value_type, _BlendFunc<Color> >
{
public:
alpha_pen() { }
- alpha_pen(const etl::alpha_pen< etl::generic_pen<Color,
ColorAccumulator>, Color::value_type, _BlendFunc > &x):
- etl::alpha_pen< etl::generic_pen<Color, ColorAccumulator>,
Color::value_type, _BlendFunc >(x)
+ alpha_pen(const etl::alpha_pen< etl::generic_pen<Color,
ColorAccumulator>, Color::value_type, _BlendFunc<Color> > &x):
+ etl::alpha_pen< etl::generic_pen<Color, ColorAccumulator>,
Color::value_type, _BlendFunc<Color> >(x)
{ }
- alpha_pen(const etl::generic_pen<Color, ColorAccumulator>& pen, const
Color::value_type &a = 1, const _BlendFunc &func = _BlendFunc()):
- etl::alpha_pen< etl::generic_pen<Color, ColorAccumulator>,
Color::value_type, _BlendFunc >(pen,a,func)
+ alpha_pen(const etl::generic_pen<Color, ColorAccumulator>& pen, const
Color::value_type &a = 1, const _BlendFunc<Color> &func = _BlendFunc<Color>()):
+ etl::alpha_pen< etl::generic_pen<Color, ColorAccumulator>,
Color::value_type, _BlendFunc<Color> >(pen,a,func)
{ }
//! Sets the blend method to that described by \a method
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Synfig-devl mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synfig-devl