Author: Carlos Lopez <genet...@gmail.com> Date: Sun Jul 22 11:58:59 2012 +0200
Layer_SolidColor: new accelerated_cairorender member function. --- synfig-core/src/synfig/layer_solidcolor.cpp | 51 +++++++++++++++++++++++++++ synfig-core/src/synfig/layer_solidcolor.h | 2 +- 2 files changed, 52 insertions(+), 1 deletions(-) diff --git a/synfig-core/src/synfig/layer_solidcolor.cpp b/synfig-core/src/synfig/layer_solidcolor.cpp index a560633..db41f64 100644 --- a/synfig-core/src/synfig/layer_solidcolor.cpp +++ b/synfig-core/src/synfig/layer_solidcolor.cpp @@ -171,3 +171,54 @@ Layer_SolidColor::accelerated_render(Context context,Surface *surface,int qualit return true; } + +////// + +bool +Layer_SolidColor::accelerated_cairorender(Context context,cairo_surface_t *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const +{ + cairo_t* cr=cairo_create(surface); + float r(color.get_r()), + g(color.get_g()), + b(color.get_b()), + a(color.get_a()); + + if(get_amount()==1.0 && get_blend_method()==Color::BLEND_STRAIGHT + || + get_amount()==1.0 && color.get_a()==1.0 && get_blend_method()==Color::BLEND_COMPOSITE + ) + { + // Mark our progress as starting + if(cb && !cb->amount_complete(0,1000)) + return false; + cairo_set_source_rgba(cr, r, g, b, a); + cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); + cairo_paint(cr); + cairo_destroy(cr); + // Mark our progress as finished + if(cb && !cb->amount_complete(1000,1000)) + return false; + return true; + } + + SuperCallback supercb(cb,0,9500,10000); + + if(!context.accelerated_cairorender(surface,quality,renddesc,&supercb)) + { + cairo_destroy(cr); + return false; + } + + cairo_set_source_rgba(cr, r, g, b, a); + cairo_set_operator(cr, CAIRO_OPERATOR_OVER); // TODO: this has to be the real blend method! + cairo_paint_with_alpha(cr, get_amount()); + cairo_destroy(cr); + + // Mark our progress as finished + if(cb && !cb->amount_complete(10000,10000)) + return false; + + return true; +} + +////// \ No newline at end of file diff --git a/synfig-core/src/synfig/layer_solidcolor.h b/synfig-core/src/synfig/layer_solidcolor.h index 90a509d..6fdd6fe 100644 --- a/synfig-core/src/synfig/layer_solidcolor.h +++ b/synfig-core/src/synfig/layer_solidcolor.h @@ -57,7 +57,7 @@ public: virtual Color get_color(Context context, const Point &pos)const; virtual bool accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const; - + virtual bool accelerated_cairorender(Context context,cairo_surface_t *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const; virtual Vocab get_param_vocab()const; virtual synfig::Layer::Handle hit_check(synfig::Context context, const synfig::Point &point)const; ------------------------------------------------------------------------------ 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