~ubuntu-branches/ubuntu/karmic/gnash/karmic

« back to all changes in this revision

Viewing changes to backend/PathParser.h

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack
  • Date: 2008-10-13 14:29:49 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20081013142949-f6qdvnu4mn05ltdc
Tags: 0.8.4~~bzr9980-0ubuntu1
* new upstream release 0.8.4 (LP: #240325)
* ship new lib usr/lib/gnash/libmozsdk.so.* in mozilla-plugin-gnash
  - update debian/mozilla-plugin-gnash.install
* ship new lib usr/lib/gnash/libgnashnet.so.* in gnash-common
  - update debian/gnash-common.install
* add basic debian/build_head script to build latest CVS head packages.
  - add debian/build_head
* new sound architecture requires build depend on libsdl1.2-dev
  - update debian/control
* head build script now has been completely migrated to bzr (upstream +
  ubuntu)
  - update debian/build_head
* disable kde gui until klash/qt4 has been fixed; keep kde packages as empty
  packages for now.
  - update debian/rules
  - debian/klash.install
  - debian/klash.links
  - debian/klash.manpages
  - debian/konqueror-plugin-gnash.install
* drop libkonq5-dev build dependency accordingly
  - update debian/control
* don't install headers manually anymore. gnash doesnt provide a -dev
  package after all
  - update debian/rules
* update libs installed in gnash-common; libgnashserver-*.so is not available
  anymore (removed); in turn we add the new libgnashcore-*.so
  - update debian/gnash-common.install
* use -Os for optimization and properly pass CXXFLAGS=$(CFLAGS) to configure
  - update debian/rules
* touch firefox .autoreg in postinst of mozilla plugin
  - update debian/mozilla-plugin-gnash.postinst
* link gnash in ubufox plugins directory for the plugin alternative switcher
  - add debian/mozilla-plugin-gnash.links
* suggest ubufox accordingly
  - update debian/control
* add new required build-depends on libgif-dev
  - update debian/control
* add Xb-Npp-Description and Xb-Npp-File as new plugin database meta data
  - update debian/control

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// 
 
2
//   Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
3
// 
 
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.
 
8
// 
 
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.
 
13
// 
 
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
 
17
 
 
18
#ifndef __PATH_PARSER_H
 
19
#define __PATH_PARSER_H
 
20
 
 
21
 
 
22
#include "shape.h"
 
23
#include <vector>
 
24
#include <deque>
 
25
#include "cxform.h"
 
26
 
 
27
namespace gnash
 
28
{
 
29
 
 
30
/// Wraps a path, indicating whether we consider the left or the right of
 
31
/// the fill.
 
32
struct UnivocalPath
 
33
{
 
34
  enum fill_type
 
35
  {
 
36
    FILL_RIGHT,
 
37
    FILL_LEFT
 
38
  };
 
39
  
 
40
  UnivocalPath() : _path(NULL), _fill_type(FILL_LEFT) {}
 
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;
 
52
  fill_type   _fill_type;
 
53
};
 
54
 
 
55
/// PathParser is a class which aims to efficiently transpose Flash paths into
 
56
/// well formed, single-filled shapes.
 
57
//
 
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
 
61
{
 
62
public:
 
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);
 
66
 
 
67
  virtual ~PathParser() { }
 
68
 
 
69
  /// Runs the path parser, invoking the pure virtual methods where
 
70
  /// appropriate.
 
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);
 
74
 
 
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;
 
78
  
 
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;
 
83
  
 
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()
 
89
  {
 
90
  }
 
91
  
 
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;
 
96
  
 
97
  /// Draw the given curve using the path pencil.
 
98
  virtual void curveTo(const edge& curve) = 0;
 
99
 
 
100
  /// Draw a straight line to the given point.
 
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 cxform& 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