synfig-core  1.0.3
target.h
Go to the documentation of this file.
1 /* === S Y N F I G ========================================================= */
23 /* ========================================================================= */
24 
25 /* === S T A R T =========================================================== */
26 
27 #ifndef __SYNFIG_TARGET_H
28 #define __SYNFIG_TARGET_H
29 
30 /* === H E A D E R S ======================================================= */
31 
32 #include <sigc++/signal.h>
33 #include "string.h"
34 #include <utility>
35 #include <map>
36 #include <ETL/handle>
37 #include "renddesc.h"
38 #include "color.h"
39 #include "canvas.h"
40 #include "targetparam.h"
41 
42 /* === M A C R O S ========================================================= */
43 
46 #define SYNFIG_TARGET_MODULE_EXT \
47  public: static const char name__[], version__[], ext__[], cvs_id__[];\
48  static Target* create (const char *filename, synfig::TargetParam p);
49 
51 #define SYNFIG_TARGET_SET_NAME(class,x) const char class::name__[]=x
52 
54 #define SYNFIG_TARGET_SET_EXT(class,x) const char class::ext__[]=x
55 
57 #define SYNFIG_TARGET_SET_VERSION(class,x) const char class::version__[]=x
58 
60 #define SYNFIG_TARGET_SET_CVS_ID(class,x) const char class::cvs_id__[]=x
61 
65 #define SYNFIG_TARGET_INIT(class) \
66  synfig::Target* class::create (const char *filename, \
67  synfig::TargetParam p) \
68  { return new class(filename, p); }
69 
70 /* === T Y P E D E F S ===================================================== */
71 
72 /* === C L A S S E S & S T R U C T S ======================================= */
73 
74 namespace synfig {
75 
76 class Surface;
77 class CairoSurface;
78 class RendDesc;
79 class Canvas;
80 class ProgressCallback;
81 struct TargetParam;
82 
84 {
89 }; // END enum TargetAlphaMode
90 
101 class Target : public etl::shared_object
102 {
103 public:
104  typedef etl::handle<Target> Handle;
105  typedef etl::loose_handle<Target> LooseHandle;
106  typedef etl::handle<const Target> ConstHandle;
107 
108  /*
109  -- ** -- S I G N A L S -------------------------------------------------------
110  */
111 
112 private:
113 
114  sigc::signal<void> signal_progress_;
115 
116  /*
117  -- ** -- S I G N A L I N T E R F A C E -------------------------------------
118  */
119 
120 public:
121 
122  sigc::signal<void>& signal_progress() { return signal_progress_; }
123 
124  /*
125  -- ** -- C O N S T R U C T O R S ---------------------------------------------
126  */
127 
128 public:
130 
133  typedef Target* (*Factory)(const char *filename, TargetParam p);
134 
135  struct BookEntry
136  {
140  };
141 
143  typedef std::map<String,BookEntry> Book;
144 
146  typedef std::map<String,String> ExtBook;
147 
149  static Book* book_;
150 
153 
154  static Book& book();
155  static ExtBook& ext_book();
156 
159  static bool subsys_init();
161  static bool subsys_stop();
162 
165 
167 
170  etl::handle<Canvas> canvas;
171 
173  int quality_;
176 
179 
182 
185 
186 protected:
188  Target();
189 
190 public:
191  virtual ~Target() { }
193  int get_quality()const { return quality_; }
195  void set_quality(int q) { quality_=q; }
197  void set_avoid_time_sync(bool x=true) { avoid_time_sync_=x; }
199  bool get_avoid_time_sync()const { return avoid_time_sync_; }
201 
207  Gamma &gamma() { return gamma_; }
209  const Gamma &gamma()const { return gamma_; }
211  virtual void set_canvas(etl::handle<Canvas> c);
213  const etl::handle<Canvas> &get_canvas()const { return canvas; }
215  RendDesc &rend_desc() { return desc; }
217  const RendDesc &rend_desc()const { return desc; }
219 
225  virtual bool set_rend_desc(RendDesc *d) { desc=*d; return true; }
227  virtual bool render(ProgressCallback *cb=NULL)=0;
229 
232  virtual bool init(ProgressCallback *cb=NULL) { (void)cb; return true; }
233 
235  static Handle create(const String &type, const String &filename,
236  synfig::TargetParam params);
237 
239 
244  virtual int next_frame(Time& time);
245 }; // END of class Target
246 
247 }; // END of namespace synfig
248 
249 /* === E N D =============================================================== */
250 
251 #endif