synfig-core  1.0.3
cairoimporter.h
Go to the documentation of this file.
1 /* === S Y N F I G ========================================================= */
22 /* ========================================================================= */
23 
24 /* === S T A R T =========================================================== */
25 
26 #ifndef __SYNFIG_CAIROIMPORTER_H
27 #define __SYNFIG_CAIROIMPORTER_H
28 
29 /* === H E A D E R S ======================================================= */
30 
31 #include <cstdio>
32 #include <map>
33 #include <ETL/handle>
34 #include "string.h"
35 #include "time.h"
36 #include "gamma.h"
37 #include "renddesc.h"
38 #include "filesystem.h"
39 
40 #include "cairo.h"
41 
42 /* === M A C R O S ========================================================= */
43 
46 #define SYNFIG_CAIROIMPORTER_MODULE_EXT \
47  public: static const char name__[], version__[], ext__[],cvs_id__[]; \
48  static const bool supports_file_system_wrapper__; \
49  static synfig::CairoImporter *create(const synfig::FileSystem::Identifier &identifier);
50 
52 #define SYNFIG_CAIROIMPORTER_MODULE_CONSTRUCTOR_DERIVED(class, parent) \
53  public: class(const synfig::FileSystem::Identifier &identifier): parent(identifier) { }
54 
56 #define SYNFIG_CAIROIMPORTER_MODULE_CONSTRUCTOR(class) \
57  SYNFIG_CAIROIMPORTER_MODULE_CONSTRUCTOR_DERIVED(class, synfig::CairoImporter)
58 
62 #define SYNFIG_CAIROIMPORTER_MODULE_DECLARATIONS_DERIVED(class, parent) \
63  SYNFIG_CAIROIMPORTER_MODULE_EXT \
64  SYNFIG_CAIROIMPORTER_MODULE_CONSTRUCTOR_DERIVED(class, parent)
65 
69 #define SYNFIG_CAIROIMPORTER_MODULE_DECLARATIONS(class) \
70  SYNFIG_CAIROIMPORTER_MODULE_EXT \
71  SYNFIG_CAIROIMPORTER_MODULE_CONSTRUCTOR(class)
72 
74 #define SYNFIG_CAIROIMPORTER_SET_NAME(class,x) const char class::name__[]=x
75 
77 #define SYNFIG_CAIROIMPORTER_SET_EXT(class,x) const char class::ext__[]=x
78 
80 #define SYNFIG_CAIROIMPORTER_SET_VERSION(class,x) const char class::version__[]=x
81 
83 #define SYNFIG_CAIROIMPORTER_SET_CVS_ID(class,x) const char class::cvs_id__[]=x
84 
86 #define SYNFIG_CAIROIMPORTER_SET_SUPPORTS_FILE_SYSTEM_WRAPPER(class,x) const bool class::supports_file_system_wrapper__=x
87 
90 #define SYNFIG_CAIROIMPORTER_INIT(class) synfig::CairoImporter* class::create(const synfig::FileSystem::Identifier &identifier) { return new class(identifier); }
91 
92 /* === T Y P E D E F S ===================================================== */
93 
94 /* === C L A S S E S & S T R U C T S ======================================= */
95 
96 namespace synfig {
97 
98 class ProgressCallback;
99 
112 class CairoImporter : public etl::shared_object
113 {
114 public:
117  typedef CairoImporter* (*Factory)(const FileSystem::Identifier &identifier);
118 
119  struct BookEntry
120  {
123 
126  factory(factory), supports_file_system_wrapper(supports_file_system_wrapper)
127  { }
128  };
129 
130  typedef std::map<std::string,BookEntry> Book;
131  static Book* book_;
132 
133  static Book& book();
134 
137  static bool subsys_init();
140  static bool subsys_stop();
141 
142  typedef etl::handle<CairoImporter> Handle;
143  typedef etl::loose_handle<CairoImporter> LooseHandle;
144  typedef etl::handle<const CairoImporter> ConstHandle;
145 
146 private:
149  Gamma gamma_;
150 
151 protected:
153 
154 public:
156 
157  Gamma& gamma() { return gamma_; }
158  const Gamma& gamma()const { return gamma_; }
159 
160  virtual ~CairoImporter();
161 
163 
170  virtual bool get_frame(cairo_surface_t *&csurface, const RendDesc &renddesc, Time time, ProgressCallback *callback=NULL)=0;
171  virtual bool get_frame(cairo_surface_t *&csurface, const RendDesc &renddesc,Time time,
172  bool &trimmed __attribute__ ((unused)),
173  unsigned int &width __attribute__ ((unused)),
174  unsigned int &height __attribute__ ((unused)),
175  unsigned int &top __attribute__ ((unused)),
176  unsigned int &left __attribute__ ((unused)),
177  ProgressCallback *callback=NULL)
178  {
179  return get_frame(csurface,renddesc,time,callback);
180  }
181 
183  virtual bool is_animated() { return false; }
184 
187 };
188 
189 }; // END of namespace synfig
190 
191 /* === E N D =============================================================== */
192 
193 #endif