Gnash  0.8.11dev
ShapeRecord.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 
20 #ifndef GNASH_SWF_SHAPERECORD_H
21 #define GNASH_SWF_SHAPERECORD_H
22 
23 #include "Geometry.h"
24 #include "LineStyle.h"
25 #include "FillStyle.h"
26 #include "SWFRect.h"
27 
28 #include <vector>
29 
30 
31 namespace gnash {
32  class movie_definition;
33  class RunResources;
34 }
35 
36 namespace gnash {
37 namespace SWF {
38 
39 
40 
41 class Subshape {
42 
43 public:
44  typedef std::vector<FillStyle> FillStyles;
45  typedef std::vector<LineStyle> LineStyles;
46  typedef std::vector<Path> Paths;
47 
48  const FillStyles& fillStyles() const {
49  return _fillStyles;
50  }
51 
53  return _fillStyles;
54  }
55 
56  const LineStyles& lineStyles() const {
57  return _lineStyles;
58  }
59 
61  return _lineStyles;
62  }
63 
64  const Paths& paths() const {
65  return _paths;
66  }
67 
68  Paths& paths() {
69  return _paths;
70  }
71 
73  //
77  return _paths.back();
78  }
79 
80  void addFillStyle(const FillStyle& fs);
81 
82  void addPath(const Path& path) {
83  _paths.push_back(path);
84  }
85 
86  void addLineStyle(const LineStyle& ls) {
87  _lineStyles.push_back(ls);
88  }
89 
90  void clear() {
91  _fillStyles.clear();
92  _lineStyles.clear();
93  _paths.clear();
94  }
95 
96  SWFRect computeBounds(int swfVersion) const;
97 
98 private:
99  FillStyles _fillStyles;
100  LineStyles _lineStyles;
101  Paths _paths;
102 };
103 
104 
105 
107 //
110 //
116 //
119 //
127 {
128 public:
132  typedef std::vector<Subshape> Subshapes;
133 
135  //
137  //
140  ShapeRecord();
141 
143  //
146  const RunResources& r);
147 
148 
149  ~ShapeRecord();
150 
152  //
155  void read(SWFStream& in, SWF::TagType tag, movie_definition& m,
156  const RunResources& r);
157 
158  const Subshapes& subshapes() const {
159  return _subshapes;
160  }
161 
162  void addSubshape(const Subshape& subshape) {
163  _subshapes.push_back(subshape);
164  }
165 
166  const SWFRect& getBounds() const {
167  return _bounds;
168  }
169 
171  //
173  void setLerp(const ShapeRecord& a, const ShapeRecord& b,
174  const double ratio);
175 
177  void clear();
178 
179  void setBounds(const SWFRect& bounds) {
180  _bounds = bounds;
181  }
182 
183  bool pointTest(boost::int32_t x, boost::int32_t y,
184  const SWFMatrix& wm) const {
185  for (SWF::ShapeRecord::Subshapes::const_iterator it = _subshapes.begin(),
186  end = _subshapes.end(); it != end; ++it) {
187 
188  if (geometry::pointTest(it->paths(), it->lineStyles(), x, y, wm)) {
189  return true;
190  }
191  }
192  return false;
193  }
194 
195 private:
196 
197  unsigned readStyleChange(SWFStream& in, size_t num_fill_bits, size_t numStyles);
198 
200  enum ShapeRecordFlags {
201  SHAPE_END = 0x00,
202  SHAPE_MOVE = 0x01,
203  SHAPE_FILLSTYLE0_CHANGE = 0x02,
204  SHAPE_FILLSTYLE1_CHANGE = 0x04,
205  SHAPE_LINESTYLE_CHANGE = 0x08,
206  SHAPE_HAS_NEW_STYLES = 0x10
207  };
208 
209  SWFRect _bounds;
210  Subshapes _subshapes;
211 };
212 
213 std::ostream& operator<<(std::ostream& o, const ShapeRecord& sh);
214 
215 } // namespace SWF
216 } // namespace gnash
217 
218 #endif
Definition: GnashKey.h:147
void clear()
Reset all shape data.
Definition: ShapeRecord.cpp:154
void addFillStyle(const FillStyle &fs)
Definition: ShapeRecord.cpp:161
const LineStyles & lineStyles() const
Definition: ShapeRecord.h:56
const FillStyles & fillStyles() const
Definition: ShapeRecord.h:48
Client program's interface to the definition of a movie or sprite.
Definition: movie_definition.h:95
bool pointTest(const std::vector< Path > &paths, const std::vector< LineStyle > &lineStyles, boost::int32_t x, boost::int32_t y, const SWFMatrix &wm)
Definition: Geometry.cpp:125
void addPath(const Path &path)
Definition: ShapeRecord.h:82
ShapeRecord()
Construct a ShapeRecord.
Definition: ShapeRecord.cpp:145
Path & currentPath()
For DynamicShape.
Definition: ShapeRecord.h:76
std::vector< FillStyle > FillStyles
Definition: ShapeRecord.h:44
TagType
SWF tag types. Symbolic names copied from Ming.
Definition: SWF.h:30
bool pointTest(boost::int32_t x, boost::int32_t y, const SWFMatrix &wm) const
Definition: ShapeRecord.h:183
Definition: SWFMatrix.h:53
~ShapeRecord()
Definition: ShapeRecord.cpp:149
VGPath path
Definition: testr_gtk.cpp:84
std::vector< Path > Paths
Definition: ShapeRecord.h:46
void setLerp(const ShapeRecord &a, const ShapeRecord &b, const double ratio)
Set to the lerp of two ShapeRecords.
Definition: ShapeRecord.cpp:198
Definition: ShapeRecord.h:41
Definition: GnashKey.h:161
const SWFRect & getBounds() const
Definition: ShapeRecord.h:166
Subshape::Paths Paths
Definition: ShapeRecord.h:131
const Paths & paths() const
Definition: ShapeRecord.h:64
Definition: GnashKey.h:164
LineStyles & lineStyles()
Definition: ShapeRecord.h:60
std::ostream & operator<<(std::ostream &o, const ShapeRecord &sh)
Definition: ShapeRecord.cpp:659
FillStyles & fillStyles()
Definition: ShapeRecord.h:52
void read(SWFStream &in, SWF::TagType tag, movie_definition &m, const RunResources &r)
Parse path data from a SWFStream.
Definition: ShapeRecord.cpp:289
Class to group together per-run and external resources for Gnash.
Definition: RunResources.h:43
FillStyle describes the various fill styles for shapes.
Definition: FillStyle.h:281
void clear()
Definition: ShapeRecord.h:90
A subset of a shape, a series of edges sharing a single set of styles.
Definition: Geometry.h:166
boost::int32_t x
Definition: BitmapData_as.cpp:434
Definition: GnashKey.h:148
SWFRect computeBounds(int swfVersion) const
Find the bounds of this subhape, and return them in a rectangle.
Definition: ShapeRecord.cpp:169
void addLineStyle(const LineStyle &ls)
Definition: ShapeRecord.h:86
std::vector< LineStyle > LineStyles
Definition: ShapeRecord.h:45
void setBounds(const SWFRect &bounds)
Definition: ShapeRecord.h:179
For the outside of outline shapes, or just bare lines.
Definition: LineStyle.h:49
boost::int32_t y
Definition: BitmapData_as.cpp:435
const Subshapes & subshapes() const
Definition: ShapeRecord.h:158
Rectangle class, see swf defined rectangle record.
Definition: SWFRect.h:44
Paths & paths()
Definition: ShapeRecord.h:68
pixel_iterator< T > end(GnashImage &im)
Definition: ImageIterators.h:198
std::vector< Subshape > Subshapes
Definition: ShapeRecord.h:132
Definition: GnashKey.h:159
Holds information needed to draw a shape.
Definition: ShapeRecord.h:126
Subshape::LineStyles LineStyles
Definition: ShapeRecord.h:130
Definition: GnashKey.h:331
SWF stream wrapper class.
Definition: SWFStream.h:58
void addSubshape(const Subshape &subshape)
Definition: ShapeRecord.h:162
Subshape::FillStyles FillStyles
Definition: ShapeRecord.h:129