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 <vector>
23 #include <deque>
24 #include <boost/utility.hpp>
25 #include "Geometry.h"
26 #include "SWFCxForm.h"
27 
28 
29 namespace gnash
30 {
31 
35 {
36  enum fill_type
37  {
40  };
41 
43 
44  UnivocalPath(const Path* path, fill_type filltype)
45  : _path(path),
46  _fill_type(filltype)
47  {
48  }
49 
50  const point& startPoint() const;
51  const point& endPoint() const;
52 
53  const Path* _path;
55 };
56 
59 //
62 class PathParser : boost::noncopyable
63 {
64 public:
67  PathParser(const std::vector<Path>& paths, size_t num_styles);
68 
69  virtual ~PathParser() { }
70 
75  void run(const SWFCxForm& cx, const SWFMatrix& mat);
76 
79  virtual void prepareFill(int fill_style, const SWFCxForm& cx) = 0;
80 
84  virtual void terminateFill(int fill_style) = 0;
85 
90  virtual void fillShape()
91  {
92  }
93 
97  virtual void moveTo(const point& p) = 0;
98 
100  virtual void curveTo(const Edge& curve) = 0;
101 
103  virtual void lineTo(const point& p) = 0;
104 
105 private:
106  std::deque<UnivocalPath>::iterator emitConnecting(std::deque<UnivocalPath>& paths);
107 
108  void append(const UnivocalPath& append_path);
109 
110  void start_shapes(int fill_style, const SWFCxForm& cx);
111 
112  void end_shapes(int fill_style);
113 
114  void reset_shape(const UnivocalPath& append_path);
115 
116  bool closed_shape();
117 
118  void line_to(const Edge& curve);
119 
120  const std::vector<Path>& _paths;
121  const size_t _num_styles;
122  point _shape_origin;
123  point _cur_endpoint;
124 };
125 
126 }
127 
128 #endif // __PATH_PARSER_H
Definition: PathParser.h:39
fill_type
Definition: PathParser.h:36
virtual void fillShape()
Definition: PathParser.h:90
Definition: SWFMatrix.h:53
VGPath path
Definition: testr_gtk.cpp:84
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
const point & startPoint() const
Definition: PathParser.cpp:31
2D Point class
Definition: Point2d.h:38
Color transformation record.
Definition: SWFCxForm.h:34
A subset of a shape, a series of edges sharing a single set of styles.
Definition: Geometry.h:166
Definition: PathParser.h:62
const point & endPoint() const
Definition: PathParser.cpp:37
Definition: PathParser.h:38
Definition: PathParser.h:34
fill_type _fill_type
Definition: PathParser.h:54
const Path * _path
Definition: PathParser.h:53
UnivocalPath(const Path *path, fill_type filltype)
Definition: PathParser.h:44
Definition: GnashKey.h:162
Defines an edge with a control point and an anchor point.
Definition: Geometry.h:44
virtual ~PathParser()
Definition: PathParser.h:69
UnivocalPath()
Definition: PathParser.h:42