Fix bugs in previous commit that caused FTBFS in synfig and ETL FTBFS with older...
[synfig.git] / synfig-core / tags / synfig_0_61_03 / synfig-core / src / synfig / layer_shape.h
1 /* === S Y N F I G ========================================================= */
2 /*!     \file layer_shape.h
3 **      \brief Template Header
4 **
5 **      $Id: layer_shape.h,v 1.2 2005/01/24 03:08:18 darco Exp $
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_LAYER_SHAPE_H
26 #define __SYNFIG_LAYER_SHAPE_H
27
28 /* === H E A D E R S ======================================================= */
29
30 #include "layer_composite.h"
31 #include "color.h"
32 #include "vector.h"
33 #include "blur.h"
34
35 #include <vector>
36
37 /* === M A C R O S ========================================================= */
38
39 /* === T Y P E D E F S ===================================================== */
40
41 /* === C L A S S E S & S T R U C T S ======================================= */
42
43 namespace synfig {
44         
45 /*!     \class Layer_Shape
46 **      \beief writeme                  */
47 class Layer_Shape : public Layer_Composite, public Layer_NoDeform
48 {
49         SYNFIG_LAYER_MODULE_EXT
50         
51 private:
52         
53         //internal cacheing
54         struct Intersector;
55         Intersector     *edge_table;
56         
57         //exported data
58         Color                                   color;
59         
60         Point   offset;
61         bool    invert;
62         bool    antialias;
63         
64         int             blurtype;
65         Real    feather;
66         
67         std::vector< char >     bytestream;
68         
69         //for use in creating the bytestream
70         int                                             lastbyteop;
71         int                                             lastoppos;
72
73 protected:
74
75         Layer_Shape(const Real &a = 1.0, const Color::BlendMethod m = Color::BLEND_COMPOSITE);
76
77 public:
78
79         ~Layer_Shape();
80
81         //! Clears out any data
82         /*!     Also clears out the Intersector
83         */
84         void clear();
85         //void sync();
86
87         void move_to(Real x, Real y);
88         void line_to(Real x, Real y);
89         void conic_to(Real x1, Real y1, Real x, Real y);
90         void conic_to_smooth(Real x, Real y);                           //x1,y1 derived from current tangent
91         void curve_to(Real x1, Real y1, Real x2, Real y2, Real x, Real y);
92         void curve_to_smooth(Real x2, Real y2, Real x, Real y); //x1,y1 derived from current tangent
93         void close();
94         void endpath();
95
96         virtual bool set_param(const String & param, const synfig::ValueBase &value);
97         virtual ValueBase get_param(const String & param)const;
98         
99         virtual Vocab get_param_vocab()const;
100
101         virtual Color get_color(Context context, const Point &pos)const;
102         virtual bool accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const;
103         virtual synfig::Layer::Handle hit_check(synfig::Context context, const synfig::Point &point)const;
104         virtual Rect get_bounding_rect()const;
105
106 private:
107         class           PolySpan;
108         bool render_polyspan(Surface *surface,PolySpan &polyspan,
109                                                 Color::BlendMethod method,Color::value_type amount)const;
110         bool render_polyspan(etl::surface<float> *surface,PolySpan &polyspan)const;
111         virtual bool render_shape(Surface *surface,bool useblend,int quality,const RendDesc &renddesc, ProgressCallback *cb)const;
112         virtual bool render_shape(etl::surface<float> *surface,int quality,const RendDesc &renddesc, ProgressCallback *cb)const;
113 }; // END of Layer_Shape
114
115 }; // END of namespace synfig
116 /* === E N D =============================================================== */
117
118 #endif