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 / layer_shape.h
1 /* === S Y N F I G ========================================================= */
2 /*!     \file layer_shape.h
3 **      \brief Header file for implementation of the "Shape" layer
4 **
5 **      $Id$
6 **
7 **      \legal
8 **      Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 **      Copyright (c) 2007-2008 Chris Moore
10 **
11 **      This package is free software; you can redistribute it and/or
12 **      modify it under the terms of the GNU General Public License as
13 **      published by the Free Software Foundation; either version 2 of
14 **      the License, or (at your option) any later version.
15 **
16 **      This package is distributed in the hope that it will be useful,
17 **      but WITHOUT ANY WARRANTY; without even the implied warranty of
18 **      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 **      General Public License for more details.
20 **      \endlegal
21 */
22 /* ========================================================================= */
23
24 /* === S T A R T =========================================================== */
25
26 #ifndef __SYNFIG_LAYER_SHAPE_H
27 #define __SYNFIG_LAYER_SHAPE_H
28
29 /* === H E A D E R S ======================================================= */
30
31 #include "layer_composite.h"
32 #include "color.h"
33 #include "vector.h"
34 #include "blur.h"
35
36 #include <vector>
37
38 /* === M A C R O S ========================================================= */
39
40 /* === T Y P E D E F S ===================================================== */
41
42 /* === C L A S S E S & S T R U C T S ======================================= */
43
44 namespace synfig {
45
46 /*!     \class Layer_Shape
47 **      \brief writeme                  */
48 class Layer_Shape : public Layer_Composite, public Layer_NoDeform
49 {
50         SYNFIG_LAYER_MODULE_EXT
51
52         enum WindingStyle
53         {
54             WINDING_NON_ZERO=0,                 //!< less than -1 --> 1;  -1 --> 1;   0 --> 0;   1 --> 1;  greater than 1 --> 1
55             WINDING_EVEN_ODD=1,                 //!< add or subtract multiples of 2 to get into range -1:1, then as above
56
57             WINDING_END=2                               //!< \internal
58         };
59
60 private:
61
62         //internal caching
63         struct Intersector;
64         Intersector     *edge_table;
65
66         //exported data
67         Color                                   color;
68
69         Point   origin;
70         bool    invert;
71         bool    antialias;
72
73         int             blurtype;
74         Real    feather;
75         WindingStyle winding_style;
76
77         std::vector< char >     bytestream;
78
79         //for use in creating the bytestream
80         int                                             lastbyteop;
81         int                                             lastoppos;
82
83 protected:
84
85         Layer_Shape(const Real &a = 1.0, const Color::BlendMethod m = Color::BLEND_COMPOSITE);
86
87 public:
88
89         ~Layer_Shape();
90
91         //! Clears out any data
92         /*!     Also clears out the Intersector
93         */
94         void clear();
95         //void sync();
96
97         void move_to(Real x, Real y);
98         void line_to(Real x, Real y);
99         void conic_to(Real x1, Real y1, Real x, Real y);
100         void conic_to_smooth(Real x, Real y);                           //x1,y1 derived from current tangent
101         void curve_to(Real x1, Real y1, Real x2, Real y2, Real x, Real y);
102         void curve_to_smooth(Real x2, Real y2, Real x, Real y); //x1,y1 derived from current tangent
103         void close();
104         void endpath();
105
106         virtual bool set_param(const String & param, const synfig::ValueBase &value);
107         virtual ValueBase get_param(const String & param)const;
108
109         virtual Vocab get_param_vocab()const;
110
111         virtual Color get_color(Context context, const Point &pos)const;
112         virtual bool accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const;
113         virtual synfig::Layer::Handle hit_check(synfig::Context context, const synfig::Point &point)const;
114         virtual Rect get_bounding_rect()const;
115
116 private:
117         class           PolySpan;
118         bool render_polyspan(Surface *surface,PolySpan &polyspan,
119                                                 Color::BlendMethod method,Color::value_type amount)const;
120         bool render_polyspan(etl::surface<float> *surface,PolySpan &polyspan)const;
121         virtual bool render_shape(Surface *surface,bool useblend,int quality,const RendDesc &renddesc, ProgressCallback *cb)const;
122         virtual bool render_shape(etl::surface<float> *surface,int quality,const RendDesc &renddesc, ProgressCallback *cb)const;
123 }; // END of Layer_Shape
124
125 }; // END of namespace synfig
126 /* === E N D =============================================================== */
127
128 #endif