1 /* === S Y N F I G ========================================================= */
3 ** \brief Target Class Implementation
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
10 ** This package is free software; you can redistribute it and/or
11 ** modify it under the terms of the GNU General Public License as
12 ** published by the Free Software Foundation; either version 2 of
13 ** the License, or (at your option) any later version.
15 ** This package is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ** General Public License for more details.
21 /* ========================================================================= */
23 /* === S T A R T =========================================================== */
25 #ifndef __SYNFIG_TARGET_H
26 #define __SYNFIG_TARGET_H
28 /* === H E A D E R S ======================================================= */
30 #include "string_decl.h"
36 //#include "general.h"
40 /* === M A C R O S ========================================================= */
43 #define SYNFIG_TARGET_MODULE_EXT public: static const char name__[], version__[], ext__[],cvs_id__[]; static Target *create(const char *filename);
45 //! Sets the name of the target
46 #define SYNFIG_TARGET_SET_NAME(class,x) const char class::name__[]=x
49 #define SYNFIG_TARGET_SET_EXT(class,x) const char class::ext__[]=x
51 //! Sets the version of the target
52 #define SYNFIG_TARGET_SET_VERSION(class,x) const char class::version__[]=x
54 //! Sets the CVS ID of the target
55 #define SYNFIG_TARGET_SET_CVS_ID(class,x) const char class::cvs_id__[]=x
58 #define SYNFIG_TARGET_INIT(class) synfig::Target* class::create(const char *filename) { return new class(filename); }
60 /* === T Y P E D E F S ===================================================== */
62 /* === C L A S S E S & S T R U C T S ======================================= */
69 class ProgressCallback;
72 ** \brief Render-target
75 class Target : public etl::shared_object
78 typedef etl::handle<Target> Handle;
79 typedef etl::loose_handle<Target> LooseHandle;
80 typedef etl::handle<const Target> ConstHandle;
82 typedef Target* (*Factory)(const char *filename);
84 //! A type for a map of targets, indexed by the name of the Target
85 typedef std::map<String,std::pair<Factory,String> > Book;
87 typedef std::map<String,String> ExtBook;
89 //! Target Book, indexed by the target's name
92 //! Map of target names indexed by associated file extension
93 static ExtBook* ext_book_;
96 static ExtBook& ext_book();
98 static bool subsys_init();
99 static bool subsys_stop();
101 //! Adjusted Render description set by set_rend_desc()
104 etl::handle<Canvas> canvas;
111 bool avoid_time_sync_;
118 virtual ~Target() { }
120 int get_quality()const { return quality_; }
122 void set_quality(int q) { quality_=q; }
124 void set_avoid_time_sync(bool x=true) { avoid_time_sync_=x; }
126 bool get_avoid_time_sync()const { return avoid_time_sync_; }
128 bool get_remove_alpha()const { return remove_alpha; }
130 void set_remove_alpha(bool x=true) { remove_alpha=x; }
132 Gamma &gamma() { return gamma_; }
134 const Gamma &gamma()const { return gamma_; }
136 virtual void set_canvas(etl::handle<Canvas> c);
138 const etl::handle<Canvas> &get_canvas()const { return canvas; }
140 RendDesc &rend_desc() { return desc; }
141 const RendDesc &rend_desc()const { return desc; }
143 //! Renders the canvas to the target
144 virtual bool render(ProgressCallback *cb=NULL)=0;
146 //! Sets the RendDesc for the Target to \a desc.
147 /*! If there are any parts of \a desc that the render target
148 ** is not capable of doing, the render target will adjust
149 ** \a desc to fit it's needs.
151 virtual bool set_rend_desc(RendDesc *d) { desc=*d; return true; }
153 virtual bool init() { return true; }
155 //! Creates a new Target described by \a type, outputing to a file described by \a filename.
156 static Handle create(const String &type, const String &filename);
157 }; // END of class Target
159 }; // END of namespace synfig
161 /* === E N D =============================================================== */