more updates
[synfig.git] / synfig-core / trunk / src / synfig / layer_shape.h
1 /* === S I N F 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 Robert B. Quattlebaum Jr.
9 **
10 **      This software and associated documentation
11 **      are CONFIDENTIAL and PROPRIETARY property of
12 **      the above-mentioned copyright holder.
13 **
14 **      You may not copy, print, publish, or in any
15 **      other way distribute this software without
16 **      a prior written agreement with
17 **      the copyright holder.
18 **      \endlegal
19 */
20 /* ========================================================================= */
21
22 /* === S T A R T =========================================================== */
23
24 #ifndef __SINFG_LAYER_SHAPE_H
25 #define __SINFG_LAYER_SHAPE_H
26
27 /* === H E A D E R S ======================================================= */
28
29 #include "layer_composite.h"
30 #include "color.h"
31 #include "vector.h"
32 #include "blur.h"
33
34 #include <vector>
35
36 /* === M A C R O S ========================================================= */
37
38 /* === T Y P E D E F S ===================================================== */
39
40 /* === C L A S S E S & S T R U C T S ======================================= */
41
42 namespace sinfg {
43         
44 /*!     \class Layer_Shape
45 **      \beief writeme                  */
46 class Layer_Shape : public Layer_Composite, public Layer_NoDeform
47 {
48         SINFG_LAYER_MODULE_EXT
49         
50 private:
51         
52         //internal cacheing
53         struct Intersector;
54         Intersector     *edge_table;
55         
56         //exported data
57         Color                                   color;
58         
59         Point   offset;
60         bool    invert;
61         bool    antialias;
62         
63         int             blurtype;
64         Real    feather;
65         
66         std::vector< char >     bytestream;
67         
68         //for use in creating the bytestream
69         int                                             lastbyteop;
70         int                                             lastoppos;
71
72 protected:
73
74         Layer_Shape(const Real &a = 1.0, const Color::BlendMethod m = Color::BLEND_COMPOSITE);
75
76 public:
77
78         ~Layer_Shape();
79
80         //! Clears out any data
81         /*!     Also clears out the Intersector
82         */
83         void clear();
84         //void sync();
85
86         void move_to(Real x, Real y);
87         void line_to(Real x, Real y);
88         void conic_to(Real x1, Real y1, Real x, Real y);
89         void conic_to_smooth(Real x, Real y);                           //x1,y1 derived from current tangent
90         void curve_to(Real x1, Real y1, Real x2, Real y2, Real x, Real y);
91         void curve_to_smooth(Real x2, Real y2, Real x, Real y); //x1,y1 derived from current tangent
92         void close();
93         void endpath();
94
95         virtual bool set_param(const String & param, const sinfg::ValueBase &value);
96         virtual ValueBase get_param(const String & param)const;
97         
98         virtual Vocab get_param_vocab()const;
99
100         virtual Color get_color(Context context, const Point &pos)const;
101         virtual bool accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const;
102         virtual sinfg::Layer::Handle hit_check(sinfg::Context context, const sinfg::Point &point)const;
103         virtual Rect get_bounding_rect()const;
104
105 private:
106         class           PolySpan;
107         bool render_polyspan(Surface *surface,PolySpan &polyspan,
108                                                 Color::BlendMethod method,Color::value_type amount)const;
109         bool render_polyspan(etl::surface<float> *surface,PolySpan &polyspan)const;
110         virtual bool render_shape(Surface *surface,bool useblend,int quality,const RendDesc &renddesc, ProgressCallback *cb)const;
111         virtual bool render_shape(etl::surface<float> *surface,int quality,const RendDesc &renddesc, ProgressCallback *cb)const;
112 }; // END of Layer_Shape
113
114 }; // END of namespace sinfg
115 /* === E N D =============================================================== */
116
117 #endif