1 /* === S Y N F I G ========================================================= */
2 /*! \file target_scanline.h
3 ** \brief Template Header for the Target Scanline class
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_SCANLINE_H
26 #define __SYNFIG_TARGET_SCANLINE_H
28 /* === H E A D E R S ======================================================= */
32 /* === M A C R O S ========================================================= */
34 /* === T Y P E D E F S ===================================================== */
36 /* === C L A S S E S & S T R U C T S ======================================= */
40 /*! \class Target_Scanline
41 ** \brief This is a Target class that implements the render fucntion
42 * for a line by line render procedure
44 class Target_Scanline : public Target
46 //! Number of threads to use
48 //! Current frame being rendered
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)
58 //! Renders the canvas to the target
59 virtual bool render(ProgressCallback *cb=NULL);
61 //! Marks the start of a frame
62 /*! \return \c true on success, \c false upon an error.
63 ** \see end_frame(), start_scanline()
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)
72 virtual int next_frame(Time& time);
74 //! Marks the end of a frame
75 /*! \see start_frame() */
76 virtual void end_frame()=0;
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
82 ** \warning Must be called after start_frame()
83 ** \see end_scanline(), start_frame()
85 virtual Color * start_scanline(int scanline)=0;
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()
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);
101 }; // END of class Target_Scanline
103 }; // END of namespace synfig
105 /* === E N D =============================================================== */