Fix bugs in previous commit that caused FTBFS in synfig and ETL FTBFS with older...
[synfig.git] / synfig-core / tags / synfig_0_61_06 / src / synfig / layer_shape.h
1 /* === S Y N F I G ========================================================= */
2 /*!     \file layer_shape.h
3 **      \brief Template Header
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_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 **      \brief writeme                  */
47 class Layer_Shape : public Layer_Composite, public Layer_NoDeform
48 {
49         SYNFIG_LAYER_MODULE_EXT
50
51         enum WindingStyle
52         {
53             WINDING_NON_ZERO=0,                 //!< less than -1 --> 1;  -1 --> 1;   0 --> 0;   1 --> 1;  greater than 1 --> 1
54             WINDING_EVEN_ODD=1,                 //!< add or subtract multiples of 2 to get into range -1:1, then as above
55
56             WINDING_END=2                               //!< \internal
57         };
58
59 private:
60
61         //internal cacheing
62         struct Intersector;
63         Intersector     *edge_table;
64
65         //exported data
66         Color                                   color;
67
68         Point   offset;
69         bool    invert;
70         bool    antialias;
71
72         int             blurtype;
73         Real    feather;
74         WindingStyle winding_style;
75
76         std::vector< char >     bytestream;
77
78         //for use in creating the bytestream
79         int                                             lastbyteop;
80         int                                             lastoppos;
81
82 protected:
83
84         Layer_Shape(const Real &a = 1.0, const Color::BlendMethod m = Color::BLEND_COMPOSITE);
85
86 public:
87
88         ~Layer_Shape();
89
90         //! Clears out any data
91         /*!     Also clears out the Intersector
92         */
93         void clear();
94         //void sync();
95
96         void move_to(Real x, Real y);
97         void line_to(Real x, Real y);
98         void conic_to(Real x1, Real y1, Real x, Real y);
99         void conic_to_smooth(Real x, Real y);                           //x1,y1 derived from current tangent
100         void curve_to(Real x1, Real y1, Real x2, Real y2, Real x, Real y);
101         void curve_to_smooth(Real x2, Real y2, Real x, Real y); //x1,y1 derived from current tangent
102         void close();
103         void endpath();
104
105         virtual bool set_param(const String & param, const synfig::ValueBase &value);
106         virtual ValueBase get_param(const String & param)const;
107
108         virtual Vocab get_param_vocab()const;
109
110         virtual Color get_color(Context context, const Point &pos)const;
111         virtual bool accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const;
112         virtual synfig::Layer::Handle hit_check(synfig::Context context, const synfig::Point &point)const;
113         virtual Rect get_bounding_rect()const;
114
115 private:
116         class           PolySpan;
117         bool render_polyspan(Surface *surface,PolySpan &polyspan,
118                                                 Color::BlendMethod method,Color::value_type amount)const;
119         bool render_polyspan(etl::surface<float> *surface,PolySpan &polyspan)const;
120         virtual bool render_shape(Surface *surface,bool useblend,int quality,const RendDesc &renddesc, ProgressCallback *cb)const;
121         virtual bool render_shape(etl::surface<float> *surface,int quality,const RendDesc &renddesc, ProgressCallback *cb)const;
122 }; // END of Layer_Shape
123
124 }; // END of namespace synfig
125 /* === E N D =============================================================== */
126
127 #endif