Gnash  0.8.11dev
PathParser.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
3 // Free Software Foundation, Inc
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 
19 #ifndef GNASH_PATH_PARSER_H
20 #define GNASH_PATH_PARSER_H
21 
22 #include "Geometry.h"
23 #include <vector>
24 #include <deque>
25 #include "SWFCxForm.h"
26 
27 namespace gnash
28 {
29 
33 {
34  enum fill_type
35  {
38  };
39 
41 
42  UnivocalPath(const Path* path, fill_type filltype)
43  : _path(path),
44  _fill_type(filltype)
45  {
46  }
47 
48  const point& startPoint() const;
49  const point& endPoint() const;
50 
51  const Path* _path;
53 };
54 
57 //
60 class PathParser : boost::noncopyable
61 {
62 public:
65  PathParser(const std::vector<Path>& paths, size_t num_styles);
66 
67  virtual ~PathParser() { }
68 
73  void run(const SWFCxForm& cx, const SWFMatrix& mat);
74 
77  virtual void prepareFill(int fill_style, const SWFCxForm& cx) = 0;
78 
82  virtual void terminateFill(int fill_style) = 0;
83 
88  virtual void fillShape()
89  {
90  }
91 
95  virtual void moveTo(const point& p) = 0;
96 
98  virtual void curveTo(const Edge& curve) = 0;
99 
101  virtual void lineTo(const point& p) = 0;
102 
103 private:
104  std::deque<UnivocalPath>::iterator emitConnecting(std::deque<UnivocalPath>& paths);
105 
106  void append(const UnivocalPath& append_path);
107 
108  void start_shapes(int fill_style, const SWFCxForm& cx);
109 
110  void end_shapes(int fill_style);
111 
112  void reset_shape(const UnivocalPath& append_path);
113 
114  bool closed_shape();
115 
116  void line_to(const Edge& curve);
117 
118  const std::vector<Path>& _paths;
119  const size_t _num_styles;
120  point _shape_origin;
121  point _cur_endpoint;
122 };
123 
124 }
125 
126 #endif // __PATH_PARSER_H
const point & endPoint() const
Definition: PathParser.cpp:36
Definition: PathParser.h:37
virtual void lineTo(const point &p)=0
Draw a straight line to the given point.
fill_type
Definition: PathParser.h:34
virtual void fillShape()
Definition: PathParser.h:88
void run(const SWFCxForm &cx, const SWFMatrix &mat)
Definition: PathParser.cpp:49
virtual void prepareFill(int fill_style, const SWFCxForm &cx)=0
Definition: SWFMatrix.h:53
VGPath path
Definition: testr_gtk.cpp:84
2D Point class
Definition: Point2d.h:38
Color transformation record.
Definition: SWFCxForm.h:35
PathParser(const std::vector< Path > &paths, size_t num_styles)
Definition: PathParser.cpp:41
A subset of a shape, a series of edges sharing a single set of styles.
Definition: Geometry.h:166
Definition: PathParser.h:60
const point & startPoint() const
Definition: PathParser.cpp:30
Definition: PathParser.h:36
Definition: PathParser.h:32
fill_type _fill_type
Definition: PathParser.h:52
virtual void terminateFill(int fill_style)=0
const Path * _path
Definition: PathParser.h:51
virtual void moveTo(const point &p)=0
UnivocalPath(const Path *path, fill_type filltype)
Definition: PathParser.h:42
Definition: GnashKey.h:162
Defines an edge with a control point and an anchor point.
Definition: Geometry.h:44
virtual ~PathParser()
Definition: PathParser.h:67
UnivocalPath()
Definition: PathParser.h:40
virtual void curveTo(const Edge &curve)=0
Draw the given curve using the path pencil.