1 /* === S Y N F I G ========================================================= */
2 /*! \file target_tile.h
3 ** \brief Template Header
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_TILE_H
26 #define __SYNFIG_TARGET_TILE_H
28 /* === H E A D E R S ======================================================= */
32 /* === M A C R O S ========================================================= */
36 /* === T Y P E D E F S ===================================================== */
38 /* === C L A S S E S & S T R U C T S ======================================= */
42 /*! \class Target_Tile
43 ** \brief Render-target
46 class Target_Tile : public Target
55 typedef etl::handle<Target_Tile> Handle;
56 typedef etl::loose_handle<Target_Tile> LooseHandle;
57 typedef etl::handle<const Target_Tile> ConstHandle;
61 //! Renders the canvas to the target
62 virtual bool render(ProgressCallback *cb=NULL);
64 //! Determines which tile needs to be rendered next.
65 /*! Most cases will not have to redefine this function.
66 ** The default should be adequate in nearly all situations.
67 ** \returns The number of tiles left to go <i>plus one</i>.
68 ** This means that whenever this function returns zero,
69 ** there are no more tiles to render and that any value
70 ** in \a x or \a y should be disregarded. */
71 virtual int next_tile(int& x, int& y);
73 virtual int next_frame(Time& time);
75 //! Adds the tile at \a x , \a y contained in \a surface
76 virtual bool add_tile(const synfig::Surface &surface, int x, int y)=0;
78 virtual int total_tiles()const
80 // Width of the image(in tiles)
81 const int tw(rend_desc().get_w()/tile_w_+(rend_desc().get_w()%tile_w_?1:0));
82 const int th(rend_desc().get_h()/tile_h_+(rend_desc().get_h()%tile_h_?1:0));
87 //! Marks the start of a frame
88 /*! \return \c true on success, \c false upon an error.
89 ** \see end_frame(), start_scanline()
91 virtual bool start_frame(ProgressCallback *cb=NULL)=0;
93 //! Marks the end of a frame
94 /*! \see start_frame() */
95 virtual void end_frame()=0;
97 void set_threads(int x) { threads_=x; }
99 int get_threads()const { return threads_; }
101 void set_tile_w(int w) { tile_w_=w; }
103 int get_tile_w()const { return tile_w_; }
105 void set_tile_h(int h) { tile_h_=h; }
107 int get_tile_h()const { return tile_h_; }
109 bool get_clipping()const { return clipping_; }
111 void set_clipping(bool x) { clipping_=x; }
115 bool render_frame_(Context context,ProgressCallback *cb=0);
117 }; // END of class Target_Tile
119 }; // END of namespace synfig
121 /* === E N D =============================================================== */