synfig-core  1.0.3
layer_shape.h
Go to the documentation of this file.
1 /* === S Y N F I G ========================================================= */
23 /* ========================================================================= */
24 
25 /* === S T A R T =========================================================== */
26 
27 #ifndef __SYNFIG_LAYER_SHAPE_H
28 #define __SYNFIG_LAYER_SHAPE_H
29 
30 /* === H E A D E R S ======================================================= */
31 
32 #include "layer_composite.h"
33 #include <synfig/color.h>
34 #include <synfig/vector.h>
35 #include <synfig/blur.h>
36 
37 #include <vector>
38 
39 /* === M A C R O S ========================================================= */
40 
41 /* === T Y P E D E F S ===================================================== */
42 
43 /* === C L A S S E S & S T R U C T S ======================================= */
44 
45 namespace synfig {
46 
50 {
52 
53  enum WindingStyle
54  {
55  WINDING_NON_ZERO=0,
56  WINDING_EVEN_ODD=1,
57 
58  WINDING_END=2
59  };
60 
61 private:
62 
63  //internal caching
64  struct Intersector;
65  Intersector *edge_table;
66 protected:
81 private:
82  std::vector< char > bytestream;
83 
84  //for use in creating the bytestream
85  int lastbyteop;
86  int lastoppos;
87 
88 protected:
89 
90  Layer_Shape(const Real &a = 1.0, const Color::BlendMethod m = Color::BLEND_COMPOSITE);
91 
92 public:
93 
94  ~Layer_Shape();
95 
97 
99  void clear();
100  //void sync();
101 
102  void move_to(Real x, Real y);
103  void line_to(Real x, Real y);
104  void conic_to(Real x1, Real y1, Real x, Real y);
105  void conic_to_smooth(Real x, Real y); //x1,y1 derived from current tangent
106  void curve_to(Real x1, Real y1, Real x2, Real y2, Real x, Real y);
107  void curve_to_smooth(Real x2, Real y2, Real x, Real y); //x1,y1 derived from current tangent
108  void close();
109  void endpath();
110 
111  virtual bool set_param(const String & param, const synfig::ValueBase &value);
112  virtual ValueBase get_param(const String & param)const;
113 
114  virtual Vocab get_param_vocab()const;
115 
116  virtual Color get_color(Context context, const Point &pos)const;
117  virtual bool accelerated_render(Context context, Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const;
118  virtual bool accelerated_cairorender(Context context, cairo_t *cr, int quality, const RendDesc &renddesc, ProgressCallback *cb)const;
119  virtual synfig::Layer::Handle hit_check(synfig::Context context, const synfig::Point &point)const;
120  virtual Rect get_bounding_rect()const;
121  //This function translates Shape primitives to Cairo primitives. Currently only supported move_to and line_to.
122  bool shape_to_cairo(cairo_t* cr)const;
123  bool feather_cairo_surface(cairo_surface_t* surface, RendDesc renddesc, int quality)const;
124 
125 private:
126  class PolySpan;
127  bool render_polyspan(
128  Surface *surface,
129  PolySpan &polyspan,
130  Color::value_type amount,
131  Color::BlendMethod blend_method,
132  const Color &color,
133  bool invert,
134  bool antialias,
135  WindingStyle winding_style) const;
136  bool render_polyspan(etl::surface<float> *surface,PolySpan &polyspan)const;
137  virtual bool render_shape(Surface *surface,bool useblend,int quality,const RendDesc &renddesc, ProgressCallback *cb)const;
138  virtual bool render_shape(etl::surface<float> *surface,int quality,const RendDesc &renddesc, ProgressCallback *cb)const;
139 }; // END of Layer_Shape
140 
141 }; // END of namespace synfig
142 /* === E N D =============================================================== */
143 
144 #endif