src/modules/lyr_std/sphere_distort.h
src/modules/lyr_std/stretch.cpp
src/modules/lyr_std/stretch.h
+src/modules/lyr_std/stroboscope.cpp
+src/modules/lyr_std/stroboscope.h
src/modules/lyr_std/supersample.cpp
src/modules/lyr_std/supersample.h
src/modules/lyr_std/timeloop.cpp
sphere_distort.h \
sphere_distort.cpp \
curvewarp.cpp \
- curvewarp.h
+ curvewarp.h \
+ stroboscope.cpp \
+ stroboscope.h
liblyr_std_la_CXXFLAGS = \
@SYNFIG_CFLAGS@
}
surface.clear();
- if(!newimporter->get_frame(surface,Time(0),trimmed,width,height,top,left))
+ if(!newimporter->get_frame(surface,get_canvas()->rend_desc(),Time(0),trimmed,width,height,top,left))
{
synfig::warning(strprintf("Unable to get frame from \"%s\"",filename_with_path.c_str()));
}
{
if(get_amount() && importer &&
importer->is_animated())
- importer->get_frame(surface,time+time_offset,trimmed,width,height,top,left);
+ importer->get_frame(surface,get_canvas()->rend_desc(),time+time_offset,trimmed,width,height,top,left);
context.set_time(time);
}
{
if(get_amount() && importer &&
importer->is_animated())
- importer->get_frame(surface,time+time_offset,trimmed,width,height,top,left);
+ importer->get_frame(surface,get_canvas()->rend_desc(),time+time_offset,trimmed,width,height,top,left);
context.set_time(time,pos);
}
#include "warp.h"
#include "timeloop.h"
#include "curvewarp.h"
+#include "stroboscope.h"
#endif
LAYER(Layer_Shade)
LAYER(Layer_Bevel)
LAYER(Layer_TimeLoop)
+ LAYER(Layer_Stroboscope)
LAYER(Layer_SphereDistort)
LAYER(CurveWarp)
END_LAYERS
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file stroboscope.cpp
+** \brief Implementation of the "Stroboscope" layer
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2007, 2008 Chris Moore
+** Copyright (c) 2009 Ray Frederikson
+**
+** This package is free software; you can redistribute it and/or
+** modify it under the terms of the GNU General Public License as
+** published by the Free Software Foundation; either version 2 of
+** the License, or (at your option) any later version.
+**
+** This package is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** General Public License for more details.
+** \endlegal
+**
+** === N O T E S ===========================================================
+**
+** ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+# include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "stroboscope.h"
+#include <synfig/valuenode.h>
+#include <synfig/valuenode_const.h>
+#include <synfig/valuenode_subtract.h>
+#include <synfig/time.h>
+#include <synfig/context.h>
+#include <synfig/paramdesc.h>
+#include <synfig/renddesc.h>
+#include <synfig/value.h>
+#include <synfig/canvas.h>
+
+#endif
+
+using namespace synfig;
+using namespace std;
+using namespace etl;
+
+/* === M A C R O S ========================================================= */
+
+/* === G L O B A L S ======================================================= */
+
+SYNFIG_LAYER_INIT(Layer_Stroboscope);
+SYNFIG_LAYER_SET_NAME(Layer_Stroboscope,"stroboscope");
+SYNFIG_LAYER_SET_LOCAL_NAME(Layer_Stroboscope,N_("Stroboscope"));
+SYNFIG_LAYER_SET_CATEGORY(Layer_Stroboscope,N_("Other"));
+SYNFIG_LAYER_SET_VERSION(Layer_Stroboscope,"0.1");
+SYNFIG_LAYER_SET_CVS_ID(Layer_Stroboscope,"$Id$");
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Layer_Stroboscope::Layer_Stroboscope()
+{
+ frequency=2.0;
+}
+
+Layer_Stroboscope::~Layer_Stroboscope()
+{
+}
+
+bool
+Layer_Stroboscope::set_param(const String & param, const ValueBase &value)
+{
+ IMPORT(frequency);
+
+ return Layer::set_param(param,value);
+}
+
+ValueBase
+Layer_Stroboscope::get_param(const String & param)const
+{
+ EXPORT(frequency);
+ EXPORT_NAME();
+ EXPORT_VERSION();
+
+ return Layer::get_param(param);
+}
+
+Layer::Vocab
+Layer_Stroboscope::get_param_vocab()const
+{
+ Layer::Vocab ret(Layer::get_param_vocab());
+
+ ret.push_back(ParamDesc("frequency")
+ .set_local_name(_("Frequency"))
+ .set_description(_("Frequency of the Strobe in times per second"))
+ );
+
+ return ret;
+}
+
+void
+Layer_Stroboscope::set_time(Context context, Time t)const
+{
+ Time ret_time=Time::begin();
+ if(frequency > 0.0)
+ ret_time = Time(1.0)/frequency*floor(t*frequency);
+
+ context.set_time(ret_time);
+}
+
+Color
+Layer_Stroboscope::get_color(Context context, const Point &pos)const
+{
+ return context.get_color(pos);
+}
+
+bool
+Layer_Stroboscope::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const
+{
+ return context.accelerated_render(surface,quality,renddesc,cb);
+}
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file stroboscope.h
+** \brief Header file for implementation of the "Stroboscope" layer
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2008 Chris Moore
+** Copyright (c) 2009 Ray Frederikson
+**
+** This package is free software; you can redistribute it and/or
+** modify it under the terms of the GNU General Public License as
+** published by the Free Software Foundation; either version 2 of
+** the License, or (at your option) any later version.
+**
+** This package is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** General Public License for more details.
+** \endlegal
+*/
+/* ========================================================================= */
+
+/* === S T A R T =========================================================== */
+
+#ifndef __SYNFIG_STROBOSCOPE_H
+#define __SYNFIG_STROBOSCOPE_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <synfig/layer.h>
+#include <synfig/color.h>
+#include <synfig/time.h>
+#include <synfig/context.h>
+
+/* === M A C R O S ========================================================= */
+
+/* === T Y P E D E F S ===================================================== */
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+class Layer_Stroboscope : public synfig::Layer
+{
+ SYNFIG_LAYER_MODULE_EXT
+
+private:
+ float frequency;
+
+protected:
+ Layer_Stroboscope();
+
+public:
+ ~Layer_Stroboscope();
+
+ virtual bool set_param(const synfig::String & param, const synfig::ValueBase &value);
+
+ virtual synfig::ValueBase get_param(const synfig::String & param)const;
+
+ virtual Vocab get_param_vocab()const;
+ virtual synfig::Color get_color(synfig::Context context, const synfig::Point &pos)const;
+
+ virtual void set_time(synfig::Context context, synfig::Time time)const;
+ virtual bool accelerated_render(synfig::Context context,synfig::Surface *surface,int quality, const synfig::RendDesc &renddesc, synfig::ProgressCallback *cb)const;
+};
+
+/* === E N D =============================================================== */
+
+#endif
}
bool
-bmp_mptr::get_frame(synfig::Surface &surface,Time /*time*/, synfig::ProgressCallback *cb)
+bmp_mptr::get_frame(synfig::Surface &surface, const synfig::RendDesc &renddesc, Time /*time*/, synfig::ProgressCallback *cb)
{
FILE *file=fopen(filename.c_str(),"rb");
if(!file)
bmp_mptr(const char *filename);
~bmp_mptr();
- virtual bool get_frame(synfig::Surface &surface,synfig::Time time, synfig::ProgressCallback *callback);
+ virtual bool get_frame(synfig::Surface &surface, const synfig::RendDesc &renddesc, synfig::Time time, synfig::ProgressCallback *callback);
};
/* === E N D =============================================================== */
}
bool
-ffmpeg_mptr::get_frame(synfig::Surface &surface,Time time, synfig::ProgressCallback *)
+ffmpeg_mptr::get_frame(synfig::Surface &surface, const synfig::RendDesc &renddesc, Time time, synfig::ProgressCallback *)
{
int i=(int)(time*fps);
if(i!=cur_frame)
virtual bool is_animated();
- virtual bool get_frame(synfig::Surface &surface,synfig::Time time, synfig::ProgressCallback *callback);
+ virtual bool get_frame(synfig::Surface &surface, const synfig::RendDesc &renddesc, synfig::Time time, synfig::ProgressCallback *callback);
};
/* === E N D =============================================================== */
}
bool
-imagemagick_mptr::get_frame(synfig::Surface &surface,Time /*time*/, synfig::ProgressCallback *cb)
+imagemagick_mptr::get_frame(synfig::Surface &surface, const synfig::RendDesc &renddesc, Time /*time*/, synfig::ProgressCallback *cb)
{
//#define HAS_LIBPNG 1
return false;
}
- if(!importer->get_frame(surface,0,cb))
+ if(!importer->get_frame(surface,renddesc,0,cb))
{
if(cb)cb->error(_("Unable to get frame from ")+temp_file);
else synfig::error(_("Unable to get frame from ")+temp_file);
~imagemagick_mptr();
- virtual bool get_frame(synfig::Surface &surface,synfig::Time time, synfig::ProgressCallback *callback);
+ virtual bool get_frame(synfig::Surface &surface, const synfig::RendDesc &renddesc, synfig::Time time, synfig::ProgressCallback *callback);
};
/* === E N D =============================================================== */
}
bool
-jpeg_mptr::get_frame(synfig::Surface &surface,Time, synfig::ProgressCallback */*cb*/)
+jpeg_mptr::get_frame(synfig::Surface &surface, const synfig::RendDesc &renddesc, Time, synfig::ProgressCallback */*cb*/)
{
surface=surface_buffer;
return true;
jpeg_mptr(const char *filename);
~jpeg_mptr();
- virtual bool get_frame(synfig::Surface &surface,synfig::Time time, synfig::ProgressCallback *callback);
+ virtual bool get_frame(synfig::Surface &surface, const synfig::RendDesc &renddesc, synfig::Time time, synfig::ProgressCallback *callback);
};
/* === E N D =============================================================== */
}
bool
-Importer_LibAVCodec::get_frame(synfig::Surface &/*surface*/,Time, synfig::ProgressCallback */*cb*/)
+Importer_LibAVCodec::get_frame(synfig::Surface &/*surface*/, const synfig::RendDesc &renddesc, Time, synfig::ProgressCallback */*cb*/)
{
return false;
}
Importer_LibAVCodec(const char *filename);
~Importer_LibAVCodec();
- virtual bool get_frame(synfig::Surface &surface,synfig::Time time, synfig::ProgressCallback *callback);
+ virtual bool get_frame(synfig::Surface &surface, const synfig::RendDesc &renddesc, synfig::Time time, synfig::ProgressCallback *callback);
};
/* === E N D =============================================================== */
}
bool
-exr_mptr::get_frame(synfig::Surface &out_surface,Time, synfig::ProgressCallback *cb)
+exr_mptr::get_frame(synfig::Surface &out_surface, const synfig::RendDesc &renddesc, Time, synfig::ProgressCallback *cb)
{
try
{
- virtual bool get_frame(synfig::Surface &surface,synfig::Time time, synfig::ProgressCallback *callback);
+ virtual bool get_frame(synfig::Surface &surface, const synfig::RendDesc &renddesc, synfig::Time time, synfig::ProgressCallback *callback);
};
}
bool
-png_mptr::get_frame(synfig::Surface &surface,Time, synfig::ProgressCallback */*cb*/)
+png_mptr::get_frame(synfig::Surface &surface, const synfig::RendDesc &renddesc, Time, synfig::ProgressCallback */*cb*/)
{
//assert(0); // shouldn't be called?
surface=surface_buffer;
}
bool
-png_mptr::get_frame(synfig::Surface &surface,Time,
+png_mptr::get_frame(synfig::Surface &surface, const synfig::RendDesc &renddesc, Time,
bool &trimmed, unsigned int &width, unsigned int &height, unsigned int &top, unsigned int &left,
synfig::ProgressCallback */*cb*/)
{
png_mptr(const char *filename);
~png_mptr();
- virtual bool get_frame(synfig::Surface &surface,synfig::Time time, synfig::ProgressCallback *callback);
- virtual bool get_frame(synfig::Surface &surface,synfig::Time time,
+ virtual bool get_frame(synfig::Surface &surface, const synfig::RendDesc &renddesc, synfig::Time time, synfig::ProgressCallback *callback);
+ virtual bool get_frame(synfig::Surface &surface, const synfig::RendDesc &renddesc, synfig::Time time,
bool &trimmed, unsigned int &width, unsigned int &height, unsigned int &top, unsigned int &left,
synfig::ProgressCallback *callback);
};
}
bool
-ppm_mptr::get_frame(synfig::Surface &surface,Time, synfig::ProgressCallback *cb)
+ppm_mptr::get_frame(synfig::Surface &surface, const synfig::RendDesc &renddesc, Time, synfig::ProgressCallback *cb)
{
SmartFILE file(fopen(filename.c_str(),"rb"));
if(!file)
ppm_mptr(const char *filename);
~ppm_mptr();
- virtual bool get_frame(synfig::Surface &surface,synfig::Time time, synfig::ProgressCallback *callback);
+ virtual bool get_frame(synfig::Surface &surface, const synfig::RendDesc &renddesc, synfig::Time time, synfig::ProgressCallback *callback);
}; // END of class ppm_mptr
/* === E N D =============================================================== */
while(!(context)->empty())
{
// If this layer is active, and
- // it either isn't already set to the given time or
- // it's a time loop layer,
+ // it either isn't already set to the given time
+ // or it's a stroboscope layer,
+ // or it's a time loop layer,
// then break out of the loop and set its time
if((*context)->active() &&
(!(*context)->dirty_time_.is_equal(time) ||
+ (*context)->get_name() == "stroboscope" ||
(*context)->get_name() == "timeloop"))
break;
#include "string.h"
#include "time.h"
#include "gamma.h"
+#include "renddesc.h"
/* === M A C R O S ========================================================= */
** \return \c true on success, \c false on error
** \see ProgressCallback, Surface
*/
- virtual bool get_frame(Surface &surface,Time time, ProgressCallback *callback=NULL)=0;
- virtual bool get_frame(Surface &surface,Time time,
+ virtual bool get_frame(Surface &surface, const RendDesc &renddesc, Time time, ProgressCallback *callback=NULL)=0;
+ virtual bool get_frame(Surface &surface, const RendDesc &renddesc,Time time,
bool &trimmed __attribute__ ((unused)),
unsigned int &width __attribute__ ((unused)),
unsigned int &height __attribute__ ((unused)),
unsigned int &left __attribute__ ((unused)),
ProgressCallback *callback=NULL)
{
- return get_frame(surface,time,callback);
+ return get_frame(surface,renddesc,time,callback);
}
//! Returns \c true if the importer pays attention to the \a time parameter of get_frame()
}
bool
-ListImporter::get_frame(Surface &surface,Time time, ProgressCallback *cb)
+ListImporter::get_frame(Surface &surface, const RendDesc &renddesc, Time time, ProgressCallback *cb)
{
- int frame=round_to_int(time*fps);
+ float document_fps=renddesc.get_frame_rate();
+ int document_frame=round_to_int(time*document_fps);
+ int frame=floor_to_int(document_frame*fps/document_fps);
if(!filename_list.size())
{
return false;
}
- if(!importer->get_frame(surface,0,cb))
+ if(!importer->get_frame(surface,renddesc,0,cb))
{
if(cb)cb->error(_("Unable to get frame from ")+filename_list[frame]);
else synfig::error(_("Unable to get frame from ")+filename_list[frame]);
virtual ~ListImporter();
- virtual bool get_frame(Surface &surface,Time time, ProgressCallback *callback=NULL);
+ virtual bool get_frame(Surface &surface, const RendDesc &renddesc, Time time, ProgressCallback *callback=NULL);
virtual bool is_animated();
if(candidate_check(get_param_vocab(),x))
{
ValueDesc value_desc=x.find("value_desc")->second.get_value_desc();
- if(!value_desc ||
- value_desc.parent_is_canvas() ||
- (value_desc.is_value_node() && value_desc.get_value_node()->is_exported()) ||
- (value_desc.get_value_type()==ValueBase::TYPE_CANVAS && !value_desc.get_value().get(Canvas::Handle())->is_inline()))
+ if(!value_desc)
+ return false;
+ if(value_desc.get_value_type()==ValueBase::TYPE_CANVAS)
+ if(!value_desc.get_value().get(Canvas::Handle()))
+ return false;
+ if(
+ value_desc.parent_is_canvas()
+ ||
+ (value_desc.is_value_node() && value_desc.get_value_node()->is_exported())
+ ||
+ (value_desc.get_value_type()==ValueBase::TYPE_CANVAS && !value_desc.get_value().get(Canvas::Handle())->is_inline())
+ )
{
-// if (!value_desc)
-// synfig::info("%s:%d no export because no value_desc", __FILE__, __LINE__);
-// else if (value_desc.parent_is_canvas())
-// synfig::info("%s:%d no export because parent is canvas", __FILE__, __LINE__);
-// else if (value_desc.is_value_node() && value_desc.get_value_node()->is_exported())
-// synfig::info("%s:%d no export because exported value node", __FILE__, __LINE__);
-// else if (value_desc.get_value_type()==ValueBase::TYPE_CANVAS && !value_desc.get_value().get(Canvas::Handle())->is_inline())
-// synfig::info("%s:%d no export because canvas isn't inline", __FILE__, __LINE__);
-
return false;
}
return true;