2
// Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
4
// This program is free software; you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation; either version 3 of the License, or
7
// (at your option) any later version.
9
// This program is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
// GNU General Public License for more details.
14
// You should have received a copy of the GNU General Public License
15
// along with this program; if not, write to the Free Software
16
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
#ifndef __PATH_PARSER_H
19
#define __PATH_PARSER_H
30
/// Wraps a path, indicating whether we consider the left or the right of
40
UnivocalPath() : _path(NULL), _fill_type(FILL_LEFT) {}
42
UnivocalPath(const path* path, fill_type filltype)
48
const point& startPoint() const;
49
const point& endPoint() const;
55
/// PathParser is a class which aims to efficiently transpose Flash paths into
56
/// well formed, single-filled shapes.
58
/// A renderer should utilize this class by subclassing PathParser. The methods
59
/// reimplemented will receive low level path information (e.g., moveTo).
60
class PathParser : boost::noncopyable
63
/// @param paths list of Flash paths to be 'parsed'.
64
/// @param num_styles count of fill styles pointed to by the first argument.
65
PathParser(const std::vector<path>& paths, size_t num_styles);
67
virtual ~PathParser() { }
69
/// Runs the path parser, invoking the pure virtual methods where
71
/// @param cx the color transform that will be passed to prepareFill.
72
/// @param mat the matrix that will be passed to prepareFill.
73
void run(const cxform& cx, const matrix& mat);
75
/// Prepare the fill style for subsequent use for filling one or more shapes.
76
/// @param fill_style fill style number, as indicated by class Path.
77
virtual void prepareFill(int fill_style, const cxform& cx) = 0;
79
/// Terminates the fill style, that is, precludes the fill style from further
80
/// use, which may be freed or otherwise cleaned up. Most renderers should
81
/// fill the paths previously parsed.
82
virtual void terminateFill(int fill_style) = 0;
84
/// Fill a single shape. Implementation is optional, because most renderers
85
/// can handle multiple well-formed, singly-filled shapes and can do the
86
/// render/fill stage during terminateFill(). However, those that can't may
87
/// implement this method.
88
virtual void fillShape()
92
/// Move the path pencil to the given location. Thus a new shape should be
93
/// started. The parser may invoke this method several times for a single
94
/// fill style, creating several shapes.
95
virtual void moveTo(const point& p) = 0;
97
/// Draw the given curve using the path pencil.
98
virtual void curveTo(const edge& curve) = 0;
100
/// Draw a straight line to the given point.
101
virtual void lineTo(const point& p) = 0;
104
std::deque<UnivocalPath>::iterator emitConnecting(std::deque<UnivocalPath>& paths);
106
void append(const UnivocalPath& append_path);
108
void start_shapes(int fill_style, const cxform& cx);
110
void end_shapes(int fill_style);
112
void reset_shape(const UnivocalPath& append_path);
116
void line_to(const edge& curve);
118
const std::vector<path>& _paths;
119
const size_t _num_styles;
126
#endif // __PATH_PARSER_H