diff --git a/synfig-core/src/modules/lyr_std/clamp.cpp b/synfig-core/src/modules/lyr_std/clamp.cpp index 494909a..e2b533f 100644 --- a/synfig-core/src/modules/lyr_std/clamp.cpp +++ b/synfig-core/src/modules/lyr_std/clamp.cpp @@ -288,32 +288,6 @@ Layer_Clamp::get_color(Context context, const Point &pos)const return clamp_color(context.get_color(pos)); } -bool -Layer_Clamp::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const -{ - RENDER_TRANSFORMED_IF_NEED(__FILE__, __LINE__) - - SuperCallback supercb(cb,0,9500,10000); - - if(!context.accelerated_render(surface,quality,renddesc,&supercb)) - return false; - - int x,y; - - Surface::pen pen(surface->begin()); - - for(y=0;yamount_complete(10000,10000)) - return false; - - return true; -} - - Rect Layer_Clamp::get_full_bounding_rect(Context context)const { diff --git a/synfig-core/src/modules/lyr_std/clamp.h b/synfig-core/src/modules/lyr_std/clamp.h index ea21a27..9883668 100644 --- a/synfig-core/src/modules/lyr_std/clamp.h +++ b/synfig-core/src/modules/lyr_std/clamp.h @@ -116,8 +116,6 @@ public: virtual Rect get_full_bounding_rect(Context context)const; - virtual bool accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const; - virtual Vocab get_param_vocab()const; virtual rendering::Task::Handle build_rendering_task_vfunc(Context context)const; diff --git a/synfig-core/src/modules/lyr_std/rotate.cpp b/synfig-core/src/modules/lyr_std/rotate.cpp index 6f2e980..2c6cac2 100644 --- a/synfig-core/src/modules/lyr_std/rotate.cpp +++ b/synfig-core/src/modules/lyr_std/rotate.cpp @@ -192,54 +192,6 @@ Rotate::get_color(Context context, const Point &p)const return context.get_color(newpos); } -bool -Rotate::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const -{ - Vector origin=param_origin.get(Vector()); - Angle amount=param_amount.get(Angle()); - - RendDesc transformed_renddesc(renddesc); - transformed_renddesc.clear_flags(); - transformed_renddesc.set_transformation_matrix( - renddesc.get_transformation_matrix() - * Matrix().set_translate(origin) - * Matrix().set_rotate(amount) - * Matrix().set_translate(-origin) ); - return context.accelerated_render(surface,quality,transformed_renddesc,cb); -} - -/////////// - -bool -Rotate::accelerated_cairorender(Context context, cairo_t *cr,int quality, const RendDesc &renddesc, ProgressCallback *cb)const -{ - Vector origin=param_origin.get(Vector()); - Angle amount=param_amount.get(Angle()); - - const double rtx(origin[0]); - const double rty(origin[1]); - - float angle=Angle::rad(amount).get(); - - cairo_save(cr); - cairo_translate(cr, rtx, rty); - cairo_rotate(cr, angle); - cairo_translate(cr, -rtx, -rty); - - // is this really useful? - if(quality>8) cairo_pattern_set_filter(cairo_get_source(cr), CAIRO_FILTER_FAST); - else if(quality>=4) cairo_pattern_set_filter(cairo_get_source(cr), CAIRO_FILTER_GOOD); - else cairo_pattern_set_filter(cairo_get_source(cr), CAIRO_FILTER_BEST); - - if(!context.accelerated_cairorender(cr,quality,renddesc,cb)) - { - cairo_restore(cr); - return false; - } - cairo_restore(cr); - return true; -} - Rect Rotate::get_full_bounding_rect(Context context)const { diff --git a/synfig-core/src/modules/lyr_std/rotate.h b/synfig-core/src/modules/lyr_std/rotate.h index 5b68be2..a7f1385 100644 --- a/synfig-core/src/modules/lyr_std/rotate.h +++ b/synfig-core/src/modules/lyr_std/rotate.h @@ -68,8 +68,6 @@ public: virtual bool set_param(const String & param, const ValueBase &value); virtual ValueBase get_param(const String & param)const; 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_t *cr, int quality, const RendDesc &renddesc, ProgressCallback *cb)const; Layer::Handle hit_check(Context context, const Point &point)const; virtual Vocab get_param_vocab()const; virtual Rect get_full_bounding_rect(Context context)const; diff --git a/synfig-core/src/modules/lyr_std/shade.cpp b/synfig-core/src/modules/lyr_std/shade.cpp index 75e2358..fcfe706 100644 --- a/synfig-core/src/modules/lyr_std/shade.cpp +++ b/synfig-core/src/modules/lyr_std/shade.cpp @@ -176,454 +176,6 @@ Layer_Shade::get_color(Context context, const Point &pos)const return Color::blend(shade,context.get_color(pos),get_amount(),get_blend_method()); } -bool -Layer_Shade::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const -{ - RENDER_TRANSFORMED_IF_NEED(__FILE__, __LINE__) - - Vector size=param_size.get(Vector()); - int type=param_type.get(int()); - Color color=param_color.get(Color()); - Vector origin=param_origin.get(Vector()); - bool invert=param_invert.get(bool()); - - int x,y; - - const int w = renddesc.get_w(), - h = renddesc.get_h(); - const Real pw = renddesc.get_pw(), - ph = renddesc.get_ph(); - - RendDesc workdesc(renddesc); - Surface worksurface; - etl::surface blurred; - - //expand the working surface to accommodate the blur - - //the expanded size = 1/2 the size in each direction rounded up - int halfsizex = (int) (abs(size[0]*.5/pw) + 3), - halfsizey = (int) (abs(size[1]*.5/ph) + 3); - - int origin_u(-round_to_int(origin[0]/pw)),origin_v(-round_to_int(origin[1]/ph)); - - int origin_w(w+abs(origin_u)),origin_h(h+abs(origin_v)); - - workdesc.set_subwindow( - origin_u<0?origin_u:0, - origin_v<0?origin_v:0, - (origin_u>0?origin_u:0)+w, - (origin_v>0?origin_v:0)+h - ); - - if(quality >= 10) - { - halfsizex=1; - halfsizey=1; - } - else if (quality == 9) - { - halfsizex/=4; - halfsizey/=4; - } - - //expand by 1/2 size in each direction on either side - switch(type) - { - case Blur::DISC: - case Blur::BOX: - case Blur::CROSS: - { - workdesc.set_subwindow(-max(1,halfsizex),-max(1,halfsizey),origin_w+2*max(1,halfsizex),origin_h+2*max(1,halfsizey)); - break; - } - case Blur::FASTGAUSSIAN: - { - if(quality < 4) - { - halfsizex*=2; - halfsizey*=2; - } - workdesc.set_subwindow(-max(1,halfsizex),-max(1,halfsizey),origin_w+2*max(1,halfsizex),origin_h+2*max(1,halfsizey)); - break; - } - case Blur::GAUSSIAN: - { - #define GAUSSIAN_ADJUSTMENT (0.05) - Real pw = (Real)workdesc.get_w()/(workdesc.get_br()[0]-workdesc.get_tl()[0]); - Real ph = (Real)workdesc.get_h()/(workdesc.get_br()[1]-workdesc.get_tl()[1]); - - pw=pw*pw; - ph=ph*ph; - - halfsizex = (int)(abs(pw)*size[0]*GAUSSIAN_ADJUSTMENT+0.5); - halfsizey = (int)(abs(ph)*size[1]*GAUSSIAN_ADJUSTMENT+0.5); - - halfsizex = (halfsizex + 1)/2; - halfsizey = (halfsizey + 1)/2; - workdesc.set_subwindow( -halfsizex, -halfsizey, origin_w+2*halfsizex, origin_h+2*halfsizey ); - - break; - } - } -#define SCALE_FACTOR (64.0) - if(/*quality>9 || */size[0]<=pw*SCALE_FACTOR) - { - SuperCallback stageone(cb,0,5000,10000); - SuperCallback stagetwo(cb,5000,10000,10000); - - //callbacks depend on how long the blur takes - if(size[0] || size[1]) - { - if(type == Blur::DISC) - { - stageone = SuperCallback(cb,0,5000,10000); - stagetwo = SuperCallback(cb,5000,10000,10000); - } - else - { - stageone = SuperCallback(cb,0,9000,10000); - stagetwo = SuperCallback(cb,9000,10000,10000); - } - } - else - { - stageone = SuperCallback(cb,0,9999,10000); - stagetwo = SuperCallback(cb,9999,10000,10000); - } - - - - //render the background onto the expanded surface - if(!context.accelerated_render(&worksurface,quality,workdesc,&stageone)) - return false; - - // Copy over the alpha - blurred.set_wh(worksurface.get_w(),worksurface.get_h()); - for(int j=0;jset_wh(renddesc.get_w(),renddesc.get_h()); - - int v = halfsizey-(origin_v<0?origin_v:0); - for(y=0;yamount_complete(10000,10000)) - { - //if(cb)cb->error(strprintf(__FILE__"%d: Accelerated Renderer Failure",__LINE__)); - return false; - } - - return true; -} - - -/// -bool -Layer_Shade::accelerated_cairorender(Context context,cairo_t *cr, int quality, const RendDesc &renddesc, ProgressCallback *cb)const -{ - Vector size=param_size.get(Vector()); - int type=param_type.get(int()); - Color color=param_color.get(Color()); - Vector origin=param_origin.get(Vector()); - bool invert=param_invert.get(bool()); - - int x,y; - SuperCallback stageone(cb,0,5000,10000); - SuperCallback stagetwo(cb,5000,10000,10000); - - RendDesc workdesc(renddesc); - cairo_surface_t *worksurface; - etl::surface blurred; - - // Untransform the render desc - if(!cairo_renddesc_untransform(cr, workdesc)) - return false; - - const int w=workdesc.get_w(), h=workdesc.get_h(); - const double pw=(workdesc.get_br()[0]-workdesc.get_tl()[0])/w; - const double ph=(workdesc.get_br()[1]-workdesc.get_tl()[1])/h; - - //callbacks depend on how long the blur takes - if(size[0] || size[1]) - { - if(type == Blur::DISC) - { - stageone = SuperCallback(cb,0,5000,10000); - stagetwo = SuperCallback(cb,5000,10000,10000); - } - else - { - stageone = SuperCallback(cb,0,9000,10000); - stagetwo = SuperCallback(cb,9000,10000,10000); - } - } - else - { - stageone = SuperCallback(cb,0,9999,10000); - stagetwo = SuperCallback(cb,9999,10000,10000); - } - - //expand the working surface to accommodate the blur - //the expanded size = 1/2 the size in each direction rounded up - int halfsizex = (int) (abs(size[0]*.5/pw) + 3), - halfsizey = (int) (abs(size[1]*.5/ph) + 3); - - int origin_u(-round_to_int(origin[0]/pw)),origin_v(-round_to_int(origin[1]/ph)); - - int origin_w(w+abs(origin_u)),origin_h(h+abs(origin_v)); - - workdesc.set_subwindow( - origin_u<0?origin_u:0, - origin_v<0?origin_v:0, - (origin_u>0?origin_u:0)+w, - (origin_v>0?origin_v:0)+h - ); - - if(quality >= 10) - { - halfsizex=1; - halfsizey=1; - } - else if (quality == 9) - { - halfsizex/=4; - halfsizey/=4; - } -#define SCALE_FACTOR (64.0) - //expand by 1/2 size in each direction on either side - switch(type) - { - case Blur::DISC: - case Blur::BOX: - case Blur::CROSS: - { - // If passed a certain size don't expand more - halfsizex=halfsizex>SCALE_FACTOR?SCALE_FACTOR:halfsizex; - halfsizey=halfsizey>SCALE_FACTOR?SCALE_FACTOR:halfsizey; - workdesc.set_subwindow(-max(1,halfsizex),-max(1,halfsizey),origin_w+2*max(1,halfsizex),origin_h+2*max(1,halfsizey)); - break; - } - case Blur::FASTGAUSSIAN: - { - if(quality < 4) - { - halfsizex*=2; - halfsizey*=2; - } - // If passed a certain size don't expand more - halfsizex=halfsizex>SCALE_FACTOR?SCALE_FACTOR:halfsizex; - halfsizey=halfsizey>SCALE_FACTOR?SCALE_FACTOR:halfsizey; - workdesc.set_subwindow(-max(1,halfsizex),-max(1,halfsizey),origin_w+2*max(1,halfsizex),origin_h+2*max(1,halfsizey)); - break; - } - case Blur::GAUSSIAN: - { -#define GAUSSIAN_ADJUSTMENT (0.05) - Real pw = (Real)workdesc.get_w()/(workdesc.get_br()[0]-workdesc.get_tl()[0]); - Real ph = (Real)workdesc.get_h()/(workdesc.get_br()[1]-workdesc.get_tl()[1]); - - pw=pw*pw; - ph=ph*ph; - - halfsizex = (int)(abs(pw)*size[0]*GAUSSIAN_ADJUSTMENT+0.5); - halfsizey = (int)(abs(ph)*size[1]*GAUSSIAN_ADJUSTMENT+0.5); - - halfsizex = (halfsizex + 1)/2; - halfsizey = (halfsizey + 1)/2; - // If passed a certain size don't expand more - halfsizex=halfsizex>SCALE_FACTOR?SCALE_FACTOR:halfsizex; - halfsizey=halfsizey>SCALE_FACTOR?SCALE_FACTOR:halfsizey; - workdesc.set_subwindow( -halfsizex, -halfsizey, origin_w+2*halfsizex, origin_h+2*halfsizey ); - - break; - } - } - - // New expanded workdesc values - const int ww=workdesc.get_w(); - const int wh=workdesc.get_h(); - const double wtlx=workdesc.get_tl()[0]; - const double wtly=workdesc.get_tl()[1]; - - // setup the worksurface - worksurface=cairo_surface_create_similar(cairo_get_target(cr), CAIRO_CONTENT_COLOR_ALPHA, ww, wh); - cairo_t* subcr=cairo_create(worksurface); - cairo_scale(subcr, 1/pw, 1/ph); - cairo_translate(subcr, -wtlx, -wtly); - - //render the background onto the expanded surface - if(!context.accelerated_cairorender(subcr,quality,workdesc,&stageone)) - return false; - // copy the background on the target surface if applies - if(!is_solid_color()) - { - //cairo_translate(subcr, origin[0], origin[1]); - cairo_save(cr); - cairo_translate(cr, wtlx, wtly); - cairo_scale(cr, pw, ph); - cairo_set_source_surface(cr, worksurface, 0, 0); - cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); - cairo_paint(cr); - cairo_restore(cr); - } - - // Extract the CairoSurface from the cairo_surface_t - CairoSurface cairoworksurface(worksurface); - if(!cairoworksurface.map_cairo_image()) - { - info("map cairo image failed"); - return false; - } - // Extract the alpha - blurred.set_wh(workdesc.get_w(),workdesc.get_h()); - float div=1.0/((float)(CairoColor::ceil)); - for(int j=0;jamount_complete(10000,10000)) - { - //if(cb)cb->error(strprintf(__FILE__"%d: Accelerated Renderer Failure",__LINE__)); - return false; - } - - return true; -} - -/// - Layer::Vocab Layer_Shade::get_param_vocab(void)const { diff --git a/synfig-core/src/modules/lyr_std/shade.h b/synfig-core/src/modules/lyr_std/shade.h index 8b9055b..52ff2aa 100644 --- a/synfig-core/src/modules/lyr_std/shade.h +++ b/synfig-core/src/modules/lyr_std/shade.h @@ -64,9 +64,6 @@ public: virtual ValueBase get_param(const String & param)const; 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_t *cr, int quality, const RendDesc &renddesc, ProgressCallback *cb)const; virtual Rect get_full_bounding_rect(Context context)const; virtual Vocab get_param_vocab()const; virtual bool reads_context()const { return true; } diff --git a/synfig-core/src/modules/lyr_std/stretch.cpp b/synfig-core/src/modules/lyr_std/stretch.cpp index 08fff3e..b7aca40 100644 --- a/synfig-core/src/modules/lyr_std/stretch.cpp +++ b/synfig-core/src/modules/lyr_std/stretch.cpp @@ -182,63 +182,6 @@ Layer_Stretch::get_transform()const return new Stretch_Trans(this); } -bool -Layer_Stretch::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const -{ - Vector amount=param_amount.get(Vector()); - Point center=param_center.get(Point()); - - if (amount[0] == 0 || amount[1] == 0) - { - surface->set_wh(renddesc.get_w(), renddesc.get_h()); - surface->clear(); - return true; - } - - RendDesc transformed_renddesc(renddesc); - transformed_renddesc.clear_flags(); - transformed_renddesc.set_transformation_matrix( - renddesc.get_transformation_matrix() - * Matrix().set_translate(center) - * Matrix().set_scale(amount) - * Matrix().set_translate(-center) ); - - // Render the scene - return context.accelerated_render(surface,quality,transformed_renddesc,cb); -} - - - -bool -Layer_Stretch::accelerated_cairorender(Context context, cairo_t *cr, int quality, const RendDesc &renddesc, ProgressCallback *cb)const -{ - Vector amount=param_amount.get(Vector()); - Point center=param_center.get(Point()); - - if (amount[0] == 0 || amount[1] == 0) - { - cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR); - cairo_fill(cr); - return true; - } - const double stx(center[0]); - const double sty(center[1]); - - cairo_save(cr); - cairo_translate(cr, stx, sty); - cairo_scale(cr, amount[0], amount[1]); - cairo_translate(cr, -stx, -sty); - - if(!context.accelerated_cairorender(cr,quality,renddesc,cb)) - { - cairo_restore(cr); - return false; - } - cairo_restore(cr); - return true; -} - - Rect Layer_Stretch::get_full_bounding_rect(Context context)const { diff --git a/synfig-core/src/modules/lyr_std/stretch.h b/synfig-core/src/modules/lyr_std/stretch.h index 5524370..47ec395 100644 --- a/synfig-core/src/modules/lyr_std/stretch.h +++ b/synfig-core/src/modules/lyr_std/stretch.h @@ -68,8 +68,6 @@ 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_t *cr,int quality, const RendDesc &renddesc, ProgressCallback *cb)const; Layer::Handle hit_check(Context context, const Point &point)const; virtual Vocab get_param_vocab()const; diff --git a/synfig-core/src/modules/lyr_std/supersample.cpp b/synfig-core/src/modules/lyr_std/supersample.cpp index cc565dc..0d9e119 100644 --- a/synfig-core/src/modules/lyr_std/supersample.cpp +++ b/synfig-core/src/modules/lyr_std/supersample.cpp @@ -126,231 +126,6 @@ SuperSample::get_param(const String& param)const return ValueBase(); } -RendDesc -SuperSample::get_sub_renddesc_vfunc(const RendDesc &renddesc) const -{ - int width=param_width.get(int()); - int height=param_height.get(int()); - - RendDesc desc(renddesc); - desc.clear_flags(); - desc.set_wh(desc.get_w()*width,desc.get_h()*height); - - return desc; -} - -bool -SuperSample::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const -{ - RENDER_TRANSFORMED_IF_NEED(__FILE__, __LINE__) - - int width=param_width.get(int()); - int height=param_height.get(int()); - bool scanline=param_scanline.get(bool()); - bool alpha_aware=param_alpha_aware.get(bool()); - - // don't bother supersampling if our quality is too low. - if(quality>=10) - return context.accelerated_render(surface,quality,renddesc,cb); - - RendDesc desc = get_sub_renddesc(renddesc); - - SuperCallback subcb(cb,1,9000,10000); - SuperCallback stagetwo(cb,9000,10000,10000); - - Surface tempsurface; - - // Render the scene - if(scanline) - { - handle target=surface_target_scanline(&tempsurface); - if(!target) - { - if(cb)cb->error(_("Unable to create SurfaceTarget")); - return false; - } - target->set_rend_desc(&desc); - - if(!render(context.get_previous(),target,desc,&subcb)) - { - if(cb)cb->error(strprintf(__FILE__"%d: Scanline Renderer Failure",__LINE__)); - return false; - } - } - else - if(!context.accelerated_render(&tempsurface,quality,desc,cb)) - { - //if(cb)cb->error(strprintf(__FILE__"%d: Accelerated Renderer Failure",__LINE__)); - return false; - } - - surface->set_wh(renddesc.get_w(),renddesc.get_h()); - - Surface::pen pen(surface->begin()); - Surface::pen temp_pen(tempsurface.begin()); - - if(cb && !cb->amount_complete(9001,10000)) return false; - - if(alpha_aware) - { - int x,y,u,v; - float sum; - Color pool; - for(y=0;yget_h();y++,pen.inc_y(),pen.dec_x(x),temp_pen.inc_y(height),temp_pen.dec_x(x*width)) - { - for(x=0;xget_w();x++,pen.inc_x(),temp_pen.inc_x(width)) - { - pool=Color(0,0,0,0); - sum=0; - - for(v=0;vget_h())) - return false; - } - } - } - else - { - int x,y,u,v; - Color pool; - float multiplier=1.0f/float(width*height); - for(y=0;yget_h();y++,pen.inc_y(),pen.dec_x(x),temp_pen.inc_y(height),temp_pen.dec_x(x*width)) - { - for(x=0;xget_w();x++,pen.inc_x(),temp_pen.inc_x(width)) - { - pool=Color(0,0,0,0); - for(v=0;vget_h())) - return false; - } - } - } - - if(cb && !cb->amount_complete(10000,10000)) return false; - - return true; -} - - -//// -bool -SuperSample::accelerated_cairorender(Context context, cairo_t *cr, int quality, const RendDesc &renddesc, ProgressCallback *cb)const -{ - int width=param_width.get(int()); - int height=param_height.get(int()); - - // don't bother supersampling if our quality is too low. - if(quality>=10 || (width==1 && height==1)) - return context.accelerated_cairorender(cr,quality,renddesc,cb); - - RendDesc desc(renddesc); - // Untransform the render desc - if(!cairo_renddesc_untransform(cr, desc)) - return false; - - //grab values before expand - const double pw=desc.get_pw(); - const double ph=desc.get_ph(); - const double tlx=desc.get_tl()[0]; - const double tly=desc.get_tl()[1]; - - // Expand the renddesc - desc.clear_flags(); - desc.set_wh(desc.get_w()*width,desc.get_h()*height); - - // New expanded desc values - const int ww=desc.get_w(); - const int wh=desc.get_h(); - const double wtlx=desc.get_tl()[0]; - const double wtly=desc.get_tl()[1]; - const double wpw=desc.get_pw(); - const double wph=desc.get_ph(); - - cairo_surface_t* tempsurface=cairo_surface_create_similar(cairo_get_target(cr), CAIRO_CONTENT_COLOR_ALPHA, ww, wh); - cairo_t* tempcr=cairo_create(tempsurface); - cairo_scale(tempcr, 1/wpw, 1/wph); - cairo_translate(tempcr, -wtlx, -wtly); - // Render the scene - if(!context.accelerated_cairorender(tempcr,quality,desc,cb)) - { - if(cb)cb->error(strprintf(__FILE__"%d: Accelerated Renderer Failure",__LINE__)); - return false; - } - cairo_destroy(tempcr); - // Calculate the scales values - float scalex=1.0/width; - float scaley=1.0/height; - // Calculate the cairo filter based on quality - cairo_filter_t filter; - cairo_antialias_t anti; - switch(quality) - { - case 1: - case 2: - case 3: - case 4: - case 5: // Best - filter=CAIRO_FILTER_BEST; - anti=CAIRO_ANTIALIAS_BEST; - break; - case 6: - case 7: - case 8: // Good - filter=CAIRO_FILTER_GOOD; - anti=CAIRO_ANTIALIAS_GOOD; - break; - case 9: // Fast - default: - filter=CAIRO_FILTER_FAST; - anti=CAIRO_ANTIALIAS_FAST; - break; - } - cairo_save(cr); - - cairo_translate(cr, tlx, tly); - cairo_scale(cr, pw, ph); - - cairo_scale(cr, scalex, scaley); - cairo_set_source_surface(cr, tempsurface, 0,0); - cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); - cairo_pattern_set_filter(cairo_get_source(cr), filter); - cairo_set_antialias(cr, anti); - cairo_paint(cr); - - cairo_restore(cr); - - cairo_surface_destroy(tempsurface); - - return true; -} - -//// - Layer::Vocab SuperSample::get_param_vocab(void)const { diff --git a/synfig-core/src/modules/lyr_std/supersample.h b/synfig-core/src/modules/lyr_std/supersample.h index 81791f6..3809807 100644 --- a/synfig-core/src/modules/lyr_std/supersample.h +++ b/synfig-core/src/modules/lyr_std/supersample.h @@ -54,6 +54,7 @@ private: ValueBase param_width, param_height; //!Parameter (bool) ValueBase param_scanline, param_alpha_aware; + public: SuperSample(); @@ -61,14 +62,11 @@ public: virtual ValueBase get_param(const String & param)const; - virtual bool accelerated_render(Context context,Surface *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 Rect get_bounding_rect(Context context)const; virtual Vocab get_param_vocab()const; protected: - virtual RendDesc get_sub_renddesc_vfunc(const RendDesc &renddesc) const; virtual rendering::Task::Handle build_rendering_task_vfunc(Context context)const; }; diff --git a/synfig-core/src/modules/lyr_std/translate.cpp b/synfig-core/src/modules/lyr_std/translate.cpp index 1da56aa..7b1db84 100644 --- a/synfig-core/src/modules/lyr_std/translate.cpp +++ b/synfig-core/src/modules/lyr_std/translate.cpp @@ -152,52 +152,13 @@ public: return "translate"; } }; + etl::handle Translate::get_transform()const { return new Translate_Trans(this); } -bool -Translate::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const -{ - Vector origin=param_origin.get(Vector()); - - RendDesc transformed_renddesc(renddesc); - transformed_renddesc.clear_flags(); - transformed_renddesc.set_transformation_matrix( - renddesc.get_transformation_matrix() - * Matrix().set_translate(origin) ); - - // Render the scene - if(!context.accelerated_render(surface,quality,transformed_renddesc,cb)) - { - if(cb)cb->error(strprintf(__FILE__"%d: Accelerated Renderer Failure",__LINE__)); - return false; - } - - return true; -} - -///// -bool -Translate::accelerated_cairorender(Context context, cairo_t *cr, int quality, const RendDesc &renddesc, ProgressCallback *cb)const -{ - Vector origin=param_origin.get(Vector()); - cairo_save(cr); - cairo_translate(cr, origin[0], origin[1]); - - if(!context.accelerated_cairorender(cr,quality,renddesc,cb)) - { - cairo_restore(cr); - return false; - } - cairo_restore(cr); - return true; -} - -///// - Rect Translate::get_full_bounding_rect(Context context)const { diff --git a/synfig-core/src/modules/lyr_std/translate.h b/synfig-core/src/modules/lyr_std/translate.h index 45f3ab7..819026d 100644 --- a/synfig-core/src/modules/lyr_std/translate.h +++ b/synfig-core/src/modules/lyr_std/translate.h @@ -63,8 +63,6 @@ public: virtual bool set_param(const String & param, const ValueBase &value); virtual ValueBase get_param(const String & param)const; 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_t *cr, int quality, const RendDesc &renddesc, ProgressCallback *cb)const; virtual Vocab get_param_vocab()const; virtual Rect get_full_bounding_rect(Context context)const; Layer::Handle hit_check(Context context, const Point &point)const; diff --git a/synfig-core/src/modules/lyr_std/zoom.cpp b/synfig-core/src/modules/lyr_std/zoom.cpp index e8111a8..dce69f7 100644 --- a/synfig-core/src/modules/lyr_std/zoom.cpp +++ b/synfig-core/src/modules/lyr_std/zoom.cpp @@ -162,56 +162,13 @@ public: return "zoom"; } }; + etl::handle Zoom::get_transform()const { return new Zoom_Trans(this); } -bool -Zoom::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const -{ - Vector center=param_center.get(Vector()); - Real amount=param_amount.get(Real()); - - RendDesc transformed_renddesc(renddesc); - transformed_renddesc.clear_flags(); - transformed_renddesc.set_transformation_matrix( - renddesc.get_transformation_matrix() - * Matrix().set_translate(center) - * Matrix().set_scale(exp(amount)) - * Matrix().set_translate(-center) ); - - // Render the scene - return context.accelerated_render(surface,quality,transformed_renddesc,cb); -} - - -///// -bool -Zoom::accelerated_cairorender(Context context, cairo_t *cr,int quality, const RendDesc &renddesc, ProgressCallback *cb)const -{ - Vector center=param_center.get(Vector()); - Real amount=param_amount.get(Real()); - - double zoomfactor=exp(amount); - - cairo_save(cr); - cairo_translate(cr, center[0], center[1]); - cairo_scale(cr, zoomfactor, zoomfactor); - cairo_translate(cr, -center[0], -center[1]); - - if(!context.accelerated_cairorender(cr,quality,renddesc,cb)) - { - cairo_restore(cr); - return false; - } - cairo_restore(cr); - return true; -} -///// - - Rect Zoom::get_full_bounding_rect(Context context)const { diff --git a/synfig-core/src/modules/lyr_std/zoom.h b/synfig-core/src/modules/lyr_std/zoom.h index ca68af2..8ba5848 100644 --- a/synfig-core/src/modules/lyr_std/zoom.h +++ b/synfig-core/src/modules/lyr_std/zoom.h @@ -61,8 +61,6 @@ public: virtual bool set_param(const String & param, const ValueBase &value); virtual ValueBase get_param(const String & param)const; 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_t *cr, int quality, const RendDesc &renddesc, ProgressCallback *cb)const; Layer::Handle hit_check(Context context, const Point &point)const; virtual Vocab get_param_vocab()const; virtual Rect get_full_bounding_rect(Context context)const; diff --git a/synfig-core/src/modules/mod_filter/blur.cpp b/synfig-core/src/modules/mod_filter/blur.cpp index 9786626..ec1ce8c 100644 --- a/synfig-core/src/modules/mod_filter/blur.cpp +++ b/synfig-core/src/modules/mod_filter/blur.cpp @@ -140,300 +140,6 @@ Blur_Layer::get_color(Context context, const Point &pos)const return Color::blend(context.get_color(blurpos),context.get_color(pos),get_amount(),get_blend_method()); } -bool -Blur_Layer::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const -{ - RENDER_TRANSFORMED_IF_NEED(__FILE__, __LINE__) - - synfig::Point size=param_size.get(Point()); - int type=param_type.get(int()); - size *= rendering::software::Blur::get_size_amplifier((rendering::Blur::Type)type) - * ::Blur::get_size_amplifier(type); - - // don't do anything at quality 10 - if (quality == 10) - return context.accelerated_render(surface,quality,renddesc,cb); - - // int x,y; - SuperCallback stageone(cb,0,5000,10000); - SuperCallback stagetwo(cb,5000,10000,10000); - - const int w = renddesc.get_w(), - h = renddesc.get_h(); - const Real pw = renddesc.get_pw(), - ph = renddesc.get_ph(); - - RendDesc workdesc(renddesc); - Surface worksurface,blurred; - - //callbacks depend on how long the blur takes - if(size[0] || size[1]) - { - if(type == Blur::DISC) - { - stageone = SuperCallback(cb,0,5000,10000); - stagetwo = SuperCallback(cb,5000,10000,10000); - } - else - { - stageone = SuperCallback(cb,0,9000,10000); - stagetwo = SuperCallback(cb,9000,10000,10000); - } - } - else - { - stageone = SuperCallback(cb,0,9999,10000); - stagetwo = SuperCallback(cb,9999,10000,10000); - } - - //expand the working surface to accommodate the blur - - //the expanded size = 1/2 the size in each direction rounded up - int halfsizex = (int) (abs(size[0]*.5/pw) + 3), - halfsizey = (int) (abs(size[1]*.5/ph) + 3); - - //expand by 1/2 size in each direction on either side - switch(type) - { - case Blur::DISC: - case Blur::BOX: - case Blur::CROSS: - { - workdesc.set_subwindow(-max(1,halfsizex),-max(1,halfsizey),w+2*max(1,halfsizex),h+2*max(1,halfsizey)); - break; - } - case Blur::FASTGAUSSIAN: - { - if(quality < 4) - { - halfsizex*=2; - halfsizey*=2; - } - workdesc.set_subwindow(-max(1,halfsizex),-max(1,halfsizey),w+2*max(1,halfsizex),h+2*max(1,halfsizey)); - break; - } - case Blur::GAUSSIAN: - { - #define GAUSSIAN_ADJUSTMENT (0.05) - Real pw = (Real)workdesc.get_w()/(workdesc.get_br()[0]-workdesc.get_tl()[0]); - Real ph = (Real)workdesc.get_h()/(workdesc.get_br()[1]-workdesc.get_tl()[1]); - - pw=pw*pw; - ph=ph*ph; - - halfsizex = (int)(abs(pw)*size[0]*GAUSSIAN_ADJUSTMENT+0.5); - halfsizey = (int)(abs(ph)*size[1]*GAUSSIAN_ADJUSTMENT+0.5); - - halfsizex = (halfsizex + 1)/2; - halfsizey = (halfsizey + 1)/2; - workdesc.set_subwindow( -halfsizex, -halfsizey, w+2*halfsizex, h+2*halfsizey ); - - break; - } - } - - //render the background onto the expanded surface - if(!context.accelerated_render(&worksurface,quality,workdesc,&stageone)) - return false; - - //blur the image - Blur(size,type,&stagetwo)(worksurface,workdesc.get_br()-workdesc.get_tl(),blurred); - - //be sure the surface is of the correct size - surface->set_wh(renddesc.get_w(),renddesc.get_h()); - - { - Surface::pen pen(surface->begin()); - worksurface.blit_to(pen,halfsizex,halfsizey,renddesc.get_w(),renddesc.get_h()); - } - { - Surface::alpha_pen pen(surface->begin()); - pen.set_alpha(get_amount()); - pen.set_blend_method(get_blend_method()); - blurred.blit_to(pen,halfsizex,halfsizey,renddesc.get_w(),renddesc.get_h()); - } - if(cb && !cb->amount_complete(10000,10000)) - { - //if(cb)cb->error(strprintf(__FILE__"%d: Accelerated Renderer Failure",__LINE__)); - return false; - } - - // check size - for(int i = surface->get_w()-2; i; --i) - { - Real a0 = (*surface)[0][i].get_a(); - Real a1 = (*surface)[0][i+1].get_a(); - if (type == 2) a0*=2.0, a1*=2.0; - if (a0 > 0.25) { - Real d = (a1 - a0); - Real p = fabs(d) > 1e-10 ? (a0 - 0.25)/d : 0.0; - p += i - 200; - Real pw = (Real)workdesc.get_w()/(workdesc.get_br()[0]-workdesc.get_tl()[0]); - info("legacy type %d size %f actual size %f", type, size[0]*pw, p); - break; - } - } - - return true; -} - -///// -bool -Blur_Layer::accelerated_cairorender(Context context, cairo_t *cr, int quality, const RendDesc &renddesc, ProgressCallback *cb)const -{ - synfig::Point size=param_size.get(Point()); - int type=param_type.get(int()); - size *= rendering::software::Blur::get_size_amplifier((rendering::Blur::Type)type) - * ::Blur::get_size_amplifier(type); - - // don't do anything at quality 10 - if (quality == 10) - return context.accelerated_cairorender(cr,quality,renddesc,cb); - - SuperCallback stageone(cb,0,5000,10000); - SuperCallback stagetwo(cb,5000,10000,10000); - // Calculate the callbacks sizes - // callbacks depend on how long the blur takes - if(size[0] || size[1]) - { - if(type == Blur::DISC) - { - stageone = SuperCallback(cb,0,5000,10000); - stagetwo = SuperCallback(cb,5000,10000,10000); - } - else - { - stageone = SuperCallback(cb,0,9000,10000); - stagetwo = SuperCallback(cb,9000,10000,10000); - } - } - else - { - stageone = SuperCallback(cb,0,9999,10000); - stagetwo = SuperCallback(cb,9999,10000,10000); - } - - RendDesc workdesc(renddesc); - cairo_surface_t *worksurface, *blurred; - - if(!cairo_renddesc_untransform(cr, workdesc)) - return false; - - // Expand the working surface to accommodate the blur - //the expanded size = 1/2 the size in each direction rounded up - int w=workdesc.get_w(), h=workdesc.get_h(); - const double wpw=(workdesc.get_br()[0]-workdesc.get_tl()[0])/w; - const double wph=(workdesc.get_br()[1]-workdesc.get_tl()[1])/h; - int halfsizex = (int) (abs(size[0]*.5/wpw) + 3), - halfsizey = (int) (abs(size[1]*.5/wph) + 3); - - //expand by 1/2 size in each direction on either side - switch(type) - { - case Blur::DISC: - case Blur::BOX: - case Blur::CROSS: - { - workdesc.set_subwindow(-max(1,halfsizex),-max(1,halfsizey),w+2*max(1,halfsizex),h+2*max(1,halfsizey)); - break; - } - case Blur::FASTGAUSSIAN: - { - if(quality < 4) - { - halfsizex*=2; - halfsizey*=2; - } - workdesc.set_subwindow(-max(1,halfsizex),-max(1,halfsizey),w+2*max(1,halfsizex),h+2*max(1,halfsizey)); - break; - } - case Blur::GAUSSIAN: - { -#define GAUSSIAN_ADJUSTMENT (0.05) - Real pw = (Real)workdesc.get_w()/(workdesc.get_br()[0]-workdesc.get_tl()[0]); - Real ph = (Real)workdesc.get_h()/(workdesc.get_br()[1]-workdesc.get_tl()[1]); - - pw=pw*pw; - ph=ph*ph; - - halfsizex = (int)(abs(pw)*size[0]*GAUSSIAN_ADJUSTMENT+0.5); - halfsizey = (int)(abs(ph)*size[1]*GAUSSIAN_ADJUSTMENT+0.5); - - halfsizex = (halfsizex + 1)/2; - halfsizey = (halfsizey + 1)/2; - workdesc.set_subwindow( -halfsizex, -halfsizey, w+2*halfsizex, h+2*halfsizey ); -#undef GAUSSIAN_ADJUSTMENT - break; - } - } - - // New expanded workdesc values - const int ww=workdesc.get_w(); - const int wh=workdesc.get_h(); - const double wtlx=workdesc.get_tl()[0]; - const double wtly=workdesc.get_tl()[1]; - - // Create a surface to work on - worksurface=cairo_surface_create_similar(cairo_get_target(cr), CAIRO_CONTENT_COLOR_ALPHA, ww, wh); - // Create one new cairo_t* to render the layer's context on worksurface - cairo_t* cr2=cairo_create(worksurface); - // We need to scale up the surface to the pixel size to be able to make the blur - cairo_scale(cr2, 1/wpw, 1/wph); - cairo_translate(cr2, -wtlx, -wtly); - // Lets render the background onto the expanded surface - if(!context.accelerated_cairorender(cr2,quality,workdesc,&stageone)) - { - if(cb)cb->error(strprintf(__FILE__"%d: Accelerated Cairo Renderer Failure",__LINE__)); - cairo_surface_destroy(worksurface); - return false; - } - // If the context was rendered, then blur it. - blurred=cairo_surface_create_similar(worksurface, CAIRO_CONTENT_COLOR_ALPHA, ww, wh); - //blur the image - Blur(size,type,&stagetwo)(worksurface,workdesc.get_br()-workdesc.get_tl(),blurred); - // We are done with cr2, destroy it - cairo_destroy(cr2); - // Let's composite the two surfaces: blurred over worksurface - cr2=cairo_create(worksurface); - cairo_set_source_surface(cr2, blurred, 0, 0); - cairo_paint_with_alpha_operator(cr2, get_amount(), get_blend_method()); - cairo_destroy(cr2); - // Now let's paint the blurred result on the cairo context. - // But first we need to scale it down to the user coordinate space so when the - // blurred surface is treated as the rest of layers it scales right to pixel size. - // WE need to scale down the same that we scaled up to access the pixels. - // This iwhat we would obtain: - // [T][S][DRAW1][T1'][S1'][Blur][T1][S1][DRAW2] - // ------CR2----- - // -----image surface-- - // --------------CR--------------------------- - // Where: - // [T][S] are the user to device transformation from renddesc - // [DRAW1] are potential cairo operations before the blur layer - // [T1][S1] are the user to device transformations from workdesc - // [T1'][S1'] are the inverse of above - // [DRAW2]is the cairo drawing operations below the blur - cairo_save(cr); - cairo_translate(cr, wtlx, wtly); - cairo_scale(cr, wpw, wph); - // then set the source surface the worksurface - cairo_set_source_surface(cr, worksurface, 0, 0); - cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); - cairo_paint(cr); - cairo_restore(cr); - if(cb && !cb->amount_complete(10000,10000)) - { - if(cb)cb->error(strprintf(__FILE__"%d: Accelerated Renderer Failure",__LINE__)); - return false; - } - cairo_surface_destroy(blurred); - cairo_surface_destroy(worksurface); - return true; -} - - - - Layer::Vocab Blur_Layer::get_param_vocab(void)const { diff --git a/synfig-core/src/modules/mod_filter/blur.h b/synfig-core/src/modules/mod_filter/blur.h index 286d748..e1d5bf9 100644 --- a/synfig-core/src/modules/mod_filter/blur.h +++ b/synfig-core/src/modules/mod_filter/blur.h @@ -56,8 +56,6 @@ 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_t *cr, int quality, const RendDesc &renddesc, ProgressCallback *cb)const; virtual synfig::Rect get_full_bounding_rect(Context context)const; virtual Vocab get_param_vocab()const; diff --git a/synfig-core/src/modules/mod_filter/colorcorrect.cpp b/synfig-core/src/modules/mod_filter/colorcorrect.cpp index 85a25c4..af0d7b8 100644 --- a/synfig-core/src/modules/mod_filter/colorcorrect.cpp +++ b/synfig-core/src/modules/mod_filter/colorcorrect.cpp @@ -220,89 +220,6 @@ Layer_ColorCorrect::get_color(Context context, const Point &pos)const return correct_color(context.get_color(pos)); } -bool -Layer_ColorCorrect::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const -{ - RENDER_TRANSFORMED_IF_NEED(__FILE__, __LINE__) - - SuperCallback supercb(cb,0,9500,10000); - - if(!context.accelerated_render(surface,quality,renddesc,&supercb)) - return false; - - int x,y; - - Surface::pen pen(surface->begin()); - - for(y=0;yamount_complete(10000,10000)) - return false; - - return true; -} - -bool -Layer_ColorCorrect::accelerated_cairorender(Context context, cairo_t *cr, int quality, const RendDesc &renddesc_, ProgressCallback *cb)const -{ - RendDesc renddesc(renddesc_); - - // Untransform the render desc - if(!cairo_renddesc_untransform(cr, renddesc)) - return false; - - const Real pw(renddesc.get_pw()),ph(renddesc.get_ph()); - const Point tl(renddesc.get_tl()); - const int w(renddesc.get_w()); - const int h(renddesc.get_h()); - - int x,y; - - SuperCallback supercb(cb,0,9500,10000); - - cairo_surface_t *surface; - - surface=cairo_surface_create_similar(cairo_get_target(cr), CAIRO_CONTENT_COLOR_ALPHA, w, h); - cairo_t* subcr=cairo_create(surface); - cairo_scale(subcr, 1/pw, 1/ph); - cairo_translate(subcr, -tl[0], -tl[1]); - - if(!context.accelerated_cairorender(subcr,quality,renddesc,&supercb)) - return false; - - cairo_destroy(subcr); - - CairoSurface csurface(surface); - csurface.map_cairo_image(); - - CairoSurface::pen pen(csurface.begin()); - - for(y=0;yamount_complete(10000,10000)) - return false; - - return true; -} - Rect Layer_ColorCorrect::get_full_bounding_rect(Context context)const { diff --git a/synfig-core/src/modules/mod_filter/colorcorrect.h b/synfig-core/src/modules/mod_filter/colorcorrect.h index a1ef4e2..781e85d 100644 --- a/synfig-core/src/modules/mod_filter/colorcorrect.h +++ b/synfig-core/src/modules/mod_filter/colorcorrect.h @@ -76,9 +76,6 @@ public: virtual Rect get_full_bounding_rect(Context context)const; - virtual bool accelerated_render(Context context,Surface *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 rendering::Task::Handle build_rendering_task_vfunc(Context context)const; diff --git a/synfig-core/src/modules/mod_geometry/checkerboard.cpp b/synfig-core/src/modules/mod_geometry/checkerboard.cpp index cc597ed..ec5943c 100644 --- a/synfig-core/src/modules/mod_geometry/checkerboard.cpp +++ b/synfig-core/src/modules/mod_geometry/checkerboard.cpp @@ -314,147 +314,6 @@ CheckerBoard::get_color(Context context, const Point &getpos)const return Color::blend(Color::alpha(),context.get_color(getpos),get_amount(),get_blend_method()); } -bool -CheckerBoard::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const -{ - RENDER_TRANSFORMED_IF_NEED(__FILE__, __LINE__) - - Color color=param_color.get(Color()); - - SuperCallback supercb(cb,0,9500,10000); - - if(!context.accelerated_render(surface,quality,renddesc,&supercb)) - return false; - if(get_amount()==0) - return true; - - int x,y; - - const Point tl(renddesc.get_tl()); - Point pos; - const int w(surface->get_w()); - const int h(surface->get_h()); - const Real pw(renddesc.get_pw()),ph(renddesc.get_ph()); - - Surface::alpha_pen apen(surface->begin()); - - apen.set_alpha(get_amount()); - apen.set_blend_method(get_blend_method()); - apen.set_value(color); - - for(y=0,pos[1]=tl[1];yamount_complete(10000,10000)) - return false; - - return true; -} - -////////// -bool -CheckerBoard::accelerated_cairorender(Context context, cairo_t *cr, int quality, const RendDesc &renddesc, ProgressCallback *cb)const -{ - Color color=param_color.get(Color()); - Point origin=param_origin.get(Point()); - Point size=param_size.get(Point()); - - SuperCallback supercb(cb,0,9500,10000); - - if(!is_solid_color()) - if(!context.accelerated_cairorender(cr,quality,renddesc,&supercb)) - return false; - - if(get_amount()==0) - return true; - - const float r(color.get_r()); - const float g(color.get_g()); - const float b(color.get_b()); - const float a(color.get_a()); - - const Point tl(renddesc.get_tl()); - const Point br(renddesc.get_br()); - - const int w(renddesc.get_w()); - const int h(renddesc.get_h()); - - // Width and Height of a pixel - const Real pw = (br[0] - tl[0]) / w; - const Real ph = (br[1] - tl[1]) / h; - - // These are translation and scale values - const double sx(1/pw); - const double sy(1/ph); - - Point newsize(size); - // Normalize the size - if(newsize[0] <0.0) newsize[0]=-newsize[0]; - if(newsize[1] <0.0) newsize[1]=-newsize[1]; - // Calculate one average size that fits in a number integer of pixels - newsize[0]=((int)(2.0*newsize[0]*sx))/(2.0*sx); - newsize[1]=((int)(2.0*newsize[1]*sy))/(2.0*sy); - - if(!context.accelerated_cairorender(cr,quality,renddesc,cb)) - { - if(cb)cb->error(etl::strprintf(__FILE__"%d: Accelerated Cairo Renderer Failure",__LINE__)); - return false; - } - // Now let's render the minimum checkerboard in other surface - // Initially I'll fill it completely with the alpha color - // Create a similar image with the same dimensions than the minimum checkerboard - RendDesc desc(renddesc); - // this will modify the w and h values in pixels. - desc.set_flags(RendDesc::PX_ASPECT|RendDesc::IM_SPAN); - desc.set_tl_br(Point(-newsize[0], +newsize[1]), Point(+newsize[0], -newsize[1])); - cairo_surface_t* subimage=cairo_surface_create_similar(cairo_get_target(cr), CAIRO_CONTENT_COLOR_ALPHA, desc.get_w(), desc.get_h()); - - cairo_t* subcr=cairo_create(subimage); - cairo_save(subcr); - cairo_set_source_rgba(subcr, r, g, b, a); - cairo_rectangle(subcr, 0, 0, desc.get_w()/2, desc.get_h()/2); - cairo_clip(subcr); - cairo_paint(subcr); - cairo_restore(subcr); - cairo_save(subcr); - cairo_set_source_rgba(subcr, r, g, b, a); - cairo_rectangle(subcr, desc.get_w()/2, desc.get_h()/2, desc.get_w()/2, desc.get_h()/2); - cairo_clip(subcr); - cairo_paint(subcr); - cairo_restore(subcr); - - cairo_save(cr); - cairo_translate(cr, origin[0], origin[1]); - cairo_scale(cr, 1/sx, 1/sy); - cairo_pattern_t* pattern=cairo_pattern_create_for_surface(subimage); - - cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT); - cairo_set_source(cr, pattern); - if(is_solid_color()) - { - cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); - cairo_paint_with_alpha(cr, get_amount()); - } - else - { - cairo_paint_with_alpha_operator(cr, get_amount(), get_blend_method()); - } - cairo_restore(cr); - - cairo_pattern_destroy(pattern); - - // Mark our progress as finished - if(cb && !cb->amount_complete(10000,10000)) - return false; - - return true; -} - -////////// - rendering::Task::Handle CheckerBoard::build_composite_task_vfunc(ContextParams /*context_params*/)const { diff --git a/synfig-core/src/modules/mod_geometry/checkerboard.h b/synfig-core/src/modules/mod_geometry/checkerboard.h index b7f7ad0..ae3cb60 100644 --- a/synfig-core/src/modules/mod_geometry/checkerboard.h +++ b/synfig-core/src/modules/mod_geometry/checkerboard.h @@ -67,9 +67,6 @@ public: synfig::Layer::Handle hit_check(synfig::Context context, const synfig::Point &point)const; - virtual bool accelerated_render(synfig::Context context,synfig::Surface *surface,int quality, const synfig::RendDesc &renddesc, synfig::ProgressCallback *cb)const; - virtual bool accelerated_cairorender(synfig::Context context, cairo_t *cr, int quality, const synfig::RendDesc &renddesc, synfig::ProgressCallback *cb)const; - protected: virtual synfig::rendering::Task::Handle build_composite_task_vfunc(synfig::ContextParams context_params)const; };