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
9 ** Copyright (c) 2008 Chris Moore
11 ** This package is free software; you can redistribute it and/or
12 ** modify it under the terms of the GNU General Public License as
13 ** published by the Free Software Foundation; either version 2 of
14 ** the License, or (at your option) any later version.
16 ** This package is distributed in the hope that it will be useful,
17 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ** General Public License for more details.
22 /* ========================================================================= */
24 /* === S T A R T =========================================================== */
26 #ifndef __SYNFIG_TARGET_TILE_H
27 #define __SYNFIG_TARGET_TILE_H
29 /* === H E A D E R S ======================================================= */
33 /* === M A C R O S ========================================================= */
37 /* === T Y P E D E F S ===================================================== */
39 /* === C L A S S E S & S T R U C T S ======================================= */
43 /*! \class Target_Tile
44 ** \brief Render-target
47 class Target_Tile : public Target
56 typedef etl::handle<Target_Tile> Handle;
57 typedef etl::loose_handle<Target_Tile> LooseHandle;
58 typedef etl::handle<const Target_Tile> ConstHandle;
62 //! Renders the canvas to the target
63 virtual bool render(ProgressCallback *cb=NULL);
65 //! Determines which tile needs to be rendered next.
66 /*! Most cases will not have to redefine this function.
67 ** The default should be adequate in nearly all situations.
68 ** \returns The number of tiles left to go <i>plus one</i>.
69 ** This means that whenever this function returns zero,
70 ** there are no more tiles to render and that any value
71 ** in \a x or \a y should be disregarded. */
72 virtual int next_tile(int& x, int& y);
74 virtual int next_frame(Time& time);
76 //! Adds the tile at \a x , \a y contained in \a surface
77 virtual bool add_tile(const synfig::Surface &surface, int x, int y)=0;
79 virtual int total_tiles()const
81 // Width of the image(in tiles)
82 const int tw(rend_desc().get_w()/tile_w_+(rend_desc().get_w()%tile_w_?1:0));
83 const int th(rend_desc().get_h()/tile_h_+(rend_desc().get_h()%tile_h_?1:0));
88 //! Marks the start of a frame
89 /*! \return \c true on success, \c false upon an error.
90 ** \see end_frame(), start_scanline()
92 virtual bool start_frame(ProgressCallback *cb=NULL)=0;
94 //! Marks the end of a frame
95 /*! \see start_frame() */
96 virtual void end_frame()=0;
98 void set_threads(int x) { threads_=x; }
100 int get_threads()const { return threads_; }
102 void set_tile_w(int w) { tile_w_=w; }
104 int get_tile_w()const { return tile_w_; }
106 void set_tile_h(int h) { tile_h_=h; }
108 int get_tile_h()const { return tile_h_; }
110 bool get_clipping()const { return clipping_; }
112 void set_clipping(bool x) { clipping_=x; }
116 bool render_frame_(Context context,ProgressCallback *cb=0);
118 }; // END of class Target_Tile
120 }; // END of namespace synfig
122 /* === E N D =============================================================== */