Reading back your suggestion of use a derived class for CairoSurface I
think that it is not a good idea. synfig::Surface has one alpha_pen defined
(and used everywhere) that is a class that is constructed based on Color
class and ColorPrep. ColorPrep is hard coded to use a Color class so at
some point we need to create a CairoColorPrep. Also the blend function are
passed to the alpha_pen to perform the blending of two colors.
Since my idea is to emulate the current Software render using a
CairoSurface (with ARGB 32 bits colors) without use initially any of the
Cairo high level API, it is needed to:
1) Define a CairoColor class. I wanted it to be a template specialization
but it is a bit complex. Also a custom independent CairoColor would be
better since there are some operations that needs to be redefined in any
case at the implementation. For example the sum/subtraction of two colors
needs to check if the color channel has passed the 255 or 0 value to avoid
cycle the value.
2) Based on CairoColor recreate the CairoColorPrep class. ColorAccumulator
is not needed since the USE_HALF directive won't never be used with Cairo.
3) Modify etl::surface to handle the pitch as stride. So set_pitch member
function is needed.
4) Based on CairoColor and CairoColorPrep classes create CairoSurface with
its corresponding CairoAlphaPen based on the current etl::surface and
etl::alpha_pen templates. CairoSurface will have a cairo_surface_t pointer
inside that will be initialized properly. The pointer to data will be get
from the cairo_image_surface_get_data () and passed to surface at creation
time.
5) Define the blend methods using a template function like this (one
example):
template <class C>
static C blendfunc_ALPHA_DARKEN(C &a,C &b,float amount)
{
if(a.get_a()*amount > b.get_a())
return a.set_a(a.get_a()*amount);
return b;
}
So I can reproduce the blend methods using a CairoColor instead.
Once the emulation is completed, then starts the second stage. Use Cairo
properly when possible as described in the document I posted in google docs.
Cheers!
--
Carlos
http://synfig.org
------------------------------------------------------------------------------
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
Synfig-devl@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/synfig-devl