Documentation for target_scanline.h
[synfig.git] / synfig-core / src / synfig / target_scanline.h
1 /* === S Y N F I G ========================================================= */
2 /*!     \file target_scanline.h
3 **      \brief Template Header for the Target Scanline class
4 **
5 **      $Id$
6 **
7 **      \legal
8 **      Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 **
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.
14 **
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.
19 **      \endlegal
20 */
21 /* ========================================================================= */
22
23 /* === S T A R T =========================================================== */
24
25 #ifndef __SYNFIG_TARGET_SCANLINE_H
26 #define __SYNFIG_TARGET_SCANLINE_H
27
28 /* === H E A D E R S ======================================================= */
29
30 #include "target.h"
31
32 /* === M A C R O S ========================================================= */
33
34 /* === T Y P E D E F S ===================================================== */
35
36 /* === C L A S S E S & S T R U C T S ======================================= */
37
38 namespace synfig {
39
40 /*!     \class Target_Scanline
41 **      \brief This is a Target class that implements the render fucntion
42 * for a line by line render procedure
43 */
44 class Target_Scanline : public Target
45 {
46         //! Number of threads to use
47         int threads_;
48         //! Current frame being rendered
49         int curr_frame_;
50
51 public:
52         typedef etl::handle<Target_Scanline> Handle;
53         typedef etl::loose_handle<Target_Scanline> LooseHandle;
54         typedef etl::handle<const Target_Scanline> ConstHandle;
55         //! Default constructor (threads = 2 current frame = 0)
56         Target_Scanline();
57
58         //! Renders the canvas to the target
59         virtual bool render(ProgressCallback *cb=NULL);
60
61         //! Marks the start of a frame
62         /*! \return \c true on success, \c false upon an error.
63         **      \see end_frame(), start_scanline()
64         */
65         virtual bool start_frame(ProgressCallback *cb=NULL)=0;
66         //! Returns the number of peniding frames to render. If it is zero it
67         //! stops rendering frames.
68         //! \todo Fix the calculation of frames to really render the last frame
69         //! When start frame= 1f and end frame = 1f it just render one frame (at 1f)
70         //! When start frame= 1f and end frame = 2f it just render one frame (at 1f)
71         //! which is a bug.
72         virtual int next_frame(Time& time);
73
74         //! Marks the end of a frame
75         /*! \see start_frame() */
76         virtual void end_frame()=0;
77
78         //! Marks the start of a scanline
79         /*!     \param scanline Which scanline is going to be rendered.
80         **      \return The address where the target wants the scanline
81         **              to be written.
82         **      \warning Must be called after start_frame()
83         **      \see end_scanline(), start_frame()
84         */
85         virtual Color * start_scanline(int scanline)=0;
86
87         //! Marks the end of a scanline
88         /*! Takes the data that was put at the address returned to by start_scanline()
89         **      and does whatever it is supposed to do with it.
90         **      \return \c true on success, \c false on failure.
91         **      \see start_scanline()
92         */
93         virtual bool end_scanline()=0;
94         //! Sets the number of threads
95         void set_threads(int x) { threads_=x; }
96         //! Gets the number of threads
97         int get_threads()const { return threads_; }
98         //! Puts the rendered surface onto the target.
99         bool add_frame(const synfig::Surface *surface);
100 private:
101 }; // END of class Target_Scanline
102
103 }; // END of namespace synfig
104
105 /* === E N D =============================================================== */
106
107 #endif