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