Skip to content

Commit

Permalink
Layer_SolidColor: add support for Cairo render using cairo_t*.
Browse files Browse the repository at this point in the history
  • Loading branch information
genete committed Jun 16, 2013
1 parent 1ea003d commit 2b8724b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
47 changes: 47 additions & 0 deletions synfig-core/src/synfig/layer_solidcolor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,51 @@ Layer_SolidColor::accelerated_cairorender(Context context,cairo_surface_t *surfa
return true;
}

//////
//////

bool
Layer_SolidColor::accelerated_cairorender(Context context, cairo_t *cr, int quality, const RendDesc &renddesc, ProgressCallback *cb)const
{
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_save(cr);
cairo_set_source_rgba(cr, r, g, b, a);
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
cairo_paint(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(cr,quality,renddesc,&supercb))
return false;

cairo_save(cr);
cairo_reset_clip(cr);
cairo_set_source_rgba(cr, r, g, b, a);
cairo_paint_with_alpha_operator(cr, get_amount(), get_blend_method());
cairo_restore(cr);

// Mark our progress as finished
if(cb && !cb->amount_complete(10000,10000))
return false;

return true;
}

//////
1 change: 1 addition & 0 deletions synfig-core/src/synfig/layer_solidcolor.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class Layer_SolidColor : public Layer_Composite, public Layer_NoDeform

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 bool accelerated_cairorender(Context context, cairo_t *cr, 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;
Expand Down

0 comments on commit 2b8724b

Please sign in to comment.