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