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  {
39  FILL_LEFT
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
path
VGPath path
Definition: testr_gtk.cpp:84
gnash::UnivocalPath::fill_type
fill_type
Definition: PathParser.h:37
gnash::Path::ap
point ap
Start point of the path.
Definition: Geometry.h:179
gnash::UnivocalPath::startPoint
const point & startPoint() const
Definition: PathParser.cpp:31
gnash::PathParser::curveTo
virtual void curveTo(const Edge &curve)=0
Draw the given curve using the path pencil.
gnash::PathParser::prepareFill
virtual void prepareFill(int fill_style, const SWFCxForm &cx)=0
gnash::key::i
@ i
Definition: GnashKey.h:155
_
#define _(String)
Definition: log.h:44
Geometry.h
gnash
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:41
gnash::UnivocalPath::FILL_RIGHT
@ FILL_RIGHT
Definition: PathParser.h:38
PathParser.h
gnash::SWFCxForm
Color transformation record.
Definition: SWFCxForm.h:35
gnash::UnivocalPath
Definition: PathParser.h:35
SWFCxForm.h
gnash::log_error
void log_error(StringType msg, Args... args)
Definition: log.h:283
gnash::renderer::opengl::for_each
void for_each(C &container, R(T::*pmf)(const A &), const A &arg)
Definition: Renderer_ogl.cpp:690
gnash::PathParser::moveTo
virtual void moveTo(const point &p)=0
gnash::UnivocalPath::endPoint
const point & endPoint() const
Definition: PathParser.cpp:37
gnash::PathParser::fillShape
virtual void fillShape()
Definition: PathParser.h:90
gnash::Path
A subset of a shape, a series of edges sharing a single set of styles.
Definition: Geometry.h:167
gnash::UnivocalPath::_fill_type
fill_type _fill_type
Definition: PathParser.h:54
gnash::PathParser::~PathParser
virtual ~PathParser()
Definition: PathParser.h:69
gnash::PathParser::terminateFill
virtual void terminateFill(int fill_style)=0
gnash::key::p
@ p
Definition: GnashKey.h:162
gnash::point
geometry::Point2d point
Definition: Point2d.h:143
gnash::key::_1
@ _1
Definition: GnashKey.h:95
gnash::SWFMatrix
Definition: SWFMatrix.h:54
gnash::geometry::Point2d
2D Point class
Definition: Point2d.h:39
gnash::UnivocalPath::_path
const Path * _path
Definition: PathParser.h:53
log.h
gnash::UnivocalPath::UnivocalPath
UnivocalPath()
Definition: PathParser.h:42
gnash::PathParser::run
void run(const SWFCxForm &cx, const SWFMatrix &mat)
Definition: PathParser.cpp:50
gnash::UnivocalPath::UnivocalPath
UnivocalPath(const Path *path, fill_type filltype)
Definition: PathParser.h:44
gnash::image::end
pixel_iterator< T > end(GnashImage &im)
Definition: ImageIterators.h:198
gnash::PathParser::PathParser
PathParser(const std::vector< Path > &paths, size_t num_styles)
Definition: PathParser.cpp:42
gnash::PathParser
Definition: PathParser.h:63
gnash::Edge
Defines an edge with a control point and an anchor point.
Definition: Geometry.h:45
gnash::Path::m_edges
std::vector< Edge > m_edges
Edges forming the path.
Definition: Geometry.h:182
gnash::UnivocalPath::FILL_LEFT
@ FILL_LEFT
Definition: PathParser.h:39
gnash::PathParser::lineTo
virtual void lineTo(const point &p)=0
Draw a straight line to the given point.