00001
00022
00023
00024
00025
00026 #ifndef __SYNFIG_TARGET_H
00027 #define __SYNFIG_TARGET_H
00028
00029
00030
00031 #include <sigc++/signal.h>
00032 #include "string_decl.h"
00033 #include <utility>
00034
00035 #include <map>
00036 #include <ETL/handle>
00037 #include "renddesc.h"
00038
00039 #include "color.h"
00040 #include "canvas.h"
00041
00042
00043
00045 #define SYNFIG_TARGET_MODULE_EXT public: static const char name__[], version__[], ext__[],cvs_id__[]; static Target *create(const char *filename);
00046
00048 #define SYNFIG_TARGET_SET_NAME(class,x) const char class::name__[]=x
00049
00051 #define SYNFIG_TARGET_SET_EXT(class,x) const char class::ext__[]=x
00052
00054 #define SYNFIG_TARGET_SET_VERSION(class,x) const char class::version__[]=x
00055
00057 #define SYNFIG_TARGET_SET_CVS_ID(class,x) const char class::cvs_id__[]=x
00058
00060 #define SYNFIG_TARGET_INIT(class) synfig::Target* class::create(const char *filename) { return new class(filename); }
00061
00062
00063
00064
00065
00066 namespace synfig {
00067
00068 class Surface;
00069 class RendDesc;
00070 class Canvas;
00071 class ProgressCallback;
00072
00077 class Target : public etl::shared_object
00078 {
00079 public:
00080 typedef etl::handle<Target> Handle;
00081 typedef etl::loose_handle<Target> LooseHandle;
00082 typedef etl::handle<const Target> ConstHandle;
00083
00084
00085
00086
00087
00088 private:
00089
00090 sigc::signal<void> signal_progress_;
00091
00092
00093
00094
00095
00096 public:
00097
00098 sigc::signal<void>& signal_progress() { return signal_progress_; }
00099
00100
00101
00102
00103
00104 public:
00105 typedef Target* (*Factory)(const char *filename);
00106
00108 typedef std::map<String,std::pair<Factory,String> > Book;
00109
00110 typedef std::map<String,String> ExtBook;
00111
00113 static Book* book_;
00114
00116 static ExtBook* ext_book_;
00117
00118 static Book& book();
00119 static ExtBook& ext_book();
00120
00121 static bool subsys_init();
00122 static bool subsys_stop();
00123
00125 RendDesc desc;
00126
00127 etl::handle<Canvas> canvas;
00128
00129 int quality_;
00130 Gamma gamma_;
00131
00132 bool remove_alpha;
00133
00134 bool avoid_time_sync_;
00135
00136 protected:
00137
00138 Target();
00139
00140 public:
00141 virtual ~Target() { }
00142
00143 int get_quality()const { return quality_; }
00144
00145 void set_quality(int q) { quality_=q; }
00146
00147 void set_avoid_time_sync(bool x=true) { avoid_time_sync_=x; }
00148
00149 bool get_avoid_time_sync()const { return avoid_time_sync_; }
00150
00151 bool get_remove_alpha()const { return remove_alpha; }
00152
00153 void set_remove_alpha(bool x=true) { remove_alpha=x; }
00154
00155 Gamma &gamma() { return gamma_; }
00156
00157 const Gamma &gamma()const { return gamma_; }
00158
00159 virtual void set_canvas(etl::handle<Canvas> c);
00160
00161 const etl::handle<Canvas> &get_canvas()const { return canvas; }
00162
00163 RendDesc &rend_desc() { return desc; }
00164 const RendDesc &rend_desc()const { return desc; }
00165
00167 virtual bool render(ProgressCallback *cb=NULL)=0;
00168
00170
00174 virtual bool set_rend_desc(RendDesc *d) { desc=*d; return true; }
00175
00176 virtual bool init() { return true; }
00177
00179 static Handle create(const String &type, const String &filename);
00180 };
00181
00182 };
00183
00184
00185
00186 #include "canvas.h"
00187 #endif