From 2545d88069c81e70e82ef3c4614816e40eb899d0 Mon Sep 17 00:00:00 2001 From: Carlos Lopez Date: Wed, 14 Apr 2010 19:24:10 +0200 Subject: [PATCH] Add new parameters for motionblur. Enable linear, constant and hyperbolic sub-samples. Patch thanks to Brendon Higgins --- synfig-core/src/synfig/layer_motionblur.cpp | 78 ++++++++++++++++++++++++++--- synfig-core/src/synfig/layer_motionblur.h | 13 +++++ 2 files changed, 84 insertions(+), 7 deletions(-) diff --git a/synfig-core/src/synfig/layer_motionblur.cpp b/synfig-core/src/synfig/layer_motionblur.cpp index 59f90f7..eb489d9 100644 --- a/synfig-core/src/synfig/layer_motionblur.cpp +++ b/synfig-core/src/synfig/layer_motionblur.cpp @@ -61,8 +61,12 @@ SYNFIG_LAYER_SET_CVS_ID(Layer_MotionBlur,"$Id$"); /* === M E M B E R S ======================================================= */ Layer_MotionBlur::Layer_MotionBlur(): - Layer_Composite (1.0,Color::BLEND_STRAIGHT), - aperture (0) + Layer_Composite (1.0,Color::BLEND_STRAIGHT), + aperture (0), + subsamples_factor (1.0), + subsampling_type (SUBSAMPLING_CONSTANT), + subsample_start (0.0), + subsample_end (1.0) { } @@ -71,13 +75,21 @@ Layer_MotionBlur::set_param(const String ¶m, const ValueBase &value) { IMPORT(aperture); + IMPORT(subsamples_factor); + IMPORT(subsampling_type); + IMPORT(subsample_start); + IMPORT(subsample_end); return Layer_Composite::set_param(param,value); } ValueBase Layer_MotionBlur::get_param(const String ¶m)const { - EXPORT(aperture); + EXPORT(aperture); + EXPORT(subsamples_factor); + EXPORT(subsampling_type); + EXPORT(subsample_start); + EXPORT(subsample_end); EXPORT_NAME(); EXPORT_VERSION(); @@ -123,6 +135,30 @@ Layer_MotionBlur::get_param_vocab()const .set_description(_("Shutter Time")) ); + ret.push_back(ParamDesc("subsamples_factor") + .set_local_name(_("Subsamples Factor")) + .set_description(_("Multiplies The Number Of Subsamples Rendered")) + ); + + ret.push_back(ParamDesc("subsampling_type") + .set_local_name(_("Subsampling Type")) + .set_description(_("Curve Type For Weighting Subsamples")) + .set_hint("enum") + .add_enum_value(SUBSAMPLING_CONSTANT,"constant",_("Constant")) + .add_enum_value(SUBSAMPLING_LINEAR,"linear",_("Linear")) + .add_enum_value(SUBSAMPLING_HYPERBOLIC,"hyperbolic",_("Hyperbolic")) + ); + + ret.push_back(ParamDesc("subsample_start") + .set_local_name(_("Subsample Start Amount")) + .set_description(_("Relative Amount Of The First Subsample, For Linear Weighting")) + ); + + ret.push_back(ParamDesc("subsample_end") + .set_local_name(_("Subsample End Amount")) + .set_description(_("Relative Amount Of The Last Subsample, For Linear Weighting")) + ); + return ret; } @@ -170,7 +206,17 @@ Layer_MotionBlur::accelerated_render(Context context,Surface *surface,int qualit } - if (samples == 1) return context.accelerated_render(surface,quality,renddesc,cb); + samples *= subsamples_factor; + + if (samples <= 1) return context.accelerated_render(surface,quality,renddesc,cb); + + // Only in modes where subsample_start/end matters... + if(subsampling_type == SUBSAMPLING_LINEAR) + { + // We won't render when the scale==0, so we'll use those samples elsewhere + if(subsample_start == 0) samples++; + if(subsample_end == 0) samples++; + } Surface tmp; int i; @@ -179,14 +225,32 @@ Layer_MotionBlur::accelerated_render(Context context,Surface *surface,int qualit surface->set_wh(renddesc.get_w(),renddesc.get_h()); surface->clear(); + // Render subsamples from time_cur-aperture to time_cur for(i=0;i