Fix bugs in previous commit that caused FTBFS in synfig and ETL FTBFS with older...
[synfig.git] / synfig-core / tags / 0.61.09 / src / synfig / target_multi.cpp
1 /* === S Y N F I G ========================================================= */
2 /*!     \file target_multi.cpp
3 **      \brief Template File
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 /* === H E A D E R S ======================================================= */
24
25 #ifdef USING_PCH
26 #       include "pch.h"
27 #else
28 #ifdef HAVE_CONFIG_H
29 #       include <config.h>
30 #endif
31
32 #include "target_multi.h"
33 #include "string.h"
34 #include "surface.h"
35 #include "canvas.h"
36 #include "context.h"
37
38 #endif
39
40 /* === U S I N G =========================================================== */
41
42 using namespace std;
43 using namespace etl;
44 using namespace synfig;
45
46 /* === M A C R O S ========================================================= */
47
48 /* === G L O B A L S ======================================================= */
49
50 /* === P R O C E D U R E S ================================================= */
51
52 /* === M E T H O D S ======================================================= */
53
54 Target_Multi::Target_Multi(Target_Scanline::Handle a,Target_Scanline::Handle b):
55         a(a),
56         b(b)
57 {
58 }
59
60 Target_Multi::~Target_Multi()
61 {
62 }
63
64 void
65 Target_Multi::set_canvas(etl::handle<Canvas> c)
66 {
67         canvas=c;
68         RendDesc desc=canvas->rend_desc();
69         a->set_canvas(c);
70         b->set_canvas(c);
71         set_rend_desc(&desc);
72 }
73
74 bool
75 Target_Multi::set_rend_desc(RendDesc *d)
76 {
77         desc=*d;
78         return a->set_rend_desc(d) && b->set_rend_desc(d);
79 }
80
81 bool
82 Target_Multi::init()
83 {
84         return a->init() && b->init();
85 }
86
87 bool
88 Target_Multi::add_frame(const synfig::Surface *surface)
89 {
90         return a->add_frame(surface) && b->add_frame(surface);
91 }
92
93 bool
94 Target_Multi::start_frame(ProgressCallback *cb)
95 {
96         return a->start_frame(cb) && b->start_frame(cb);
97 }
98
99 void
100 Target_Multi::end_frame()
101 {
102         a->end_frame();
103         b->end_frame();
104 }
105
106 Color *
107 Target_Multi::start_scanline(int scanline)
108 {
109         buffer_a=a->start_scanline(scanline);
110         buffer_b=b->start_scanline(scanline);
111         return buffer_a;
112 }
113
114 bool
115 Target_Multi::end_scanline()
116 {
117         memcpy(buffer_b,buffer_a,sizeof(Color)*desc.get_w());
118         return a->end_scanline() && b->end_scanline();
119 }