Gnash  0.8.11dev
PlaceObject2Tag.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 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_SWF_PLACEOBJECT2TAG_H
20 #define GNASH_SWF_PLACEOBJECT2TAG_H
21 
22 #include <string>
23 #include <boost/ptr_container/ptr_vector.hpp>
24 
25 #include "DisplayListTag.h" // for inheritance
26 #include "SWF.h" // for TagType definition
27 #include "SWFMatrix.h" // for composition
28 #include "SWFCxForm.h" // for composition
29 
30 // Forward declarations
31 namespace gnash {
32  class SWFStream;
33  class swf_event;
34  class action_buffer;
35  class movie_definition;
36  class DisplayList;
37  class RunResources;
38 }
39 
40 namespace gnash {
41 namespace SWF {
42 
44 //
86 {
87 public:
88 
89  typedef boost::ptr_vector<action_buffer> ActionBuffers;
90  typedef boost::ptr_vector<swf_event> EventHandlers;
91 
93 
95 
97  void read(SWFStream& in, TagType tag);
98 
100  void executeState(MovieClip* m, DisplayList& dlist) const;
101 
102  static void loader(SWFStream& in, TagType tag, movie_definition& m,
103  const RunResources& r);
104 
105  int getPlaceType() const {
106  return m_has_flags2 & (HAS_CHARACTER_MASK | MOVE_MASK);
107  }
108 
109  std::uint16_t getRatio() const { return _ratio; }
110  int getClipDepth() const { return m_clip_depth; }
111  std::uint16_t getID() const { return _id; }
112  const std::string& getName() const { return m_name; }
113  const SWFMatrix& getMatrix() const { return m_matrix; }
114  const SWFCxForm& getCxform() const { return m_color_transform; }
115  const EventHandlers& getEventHandlers() const { return _eventHandlers; }
116 
117  bool hasClipActions() const { return m_has_flags2 & HAS_CLIP_ACTIONS_MASK; }
118  bool hasClipDepth() const { return m_has_flags2 & HAS_CLIP_DEPTH_MASK; };
119  bool hasName() const { return m_has_flags2 & HAS_NAME_MASK; }
120  bool hasRatio() const { return m_has_flags2 & HAS_RATIO_MASK; }
121  bool hasCxform() const { return m_has_flags2 & HAS_CXFORM_MASK; }
122  bool hasMatrix() const { return m_has_flags2 & HAS_MATRIX_MASK; }
123  bool hasCharacter() const { return m_has_flags2 & HAS_CHARACTER_MASK; }
124 
125  bool hasImage() const { return m_has_flags3 & HAS_IMAGE_MASK; }
126 
127  bool hasClassName() const {
128  return m_has_flags3 & HAS_CLASS_NAME_MASK;
129  }
130 
131  bool hasBitmapCaching() const {
132  return m_has_flags3 & HAS_BITMAP_CACHING_MASK;
133  }
134 
135  bool hasBlendMode() const {
136  return m_has_flags3 & HAS_BLEND_MODE_MASK;
137  }
138 
139  bool hasFilters() const {
140  return m_has_flags3 & HAS_FILTERS_MASK;
141  }
142 
144  //
147  std::uint8_t getBlendMode() const {
148  return _blendMode;
149  }
150 
151 private:
152 
153  // read SWF::PLACEOBJECT
154  void readPlaceObject(SWFStream& in);
155 
156  // read placeObject2 actions
157  void readPlaceActions(SWFStream& in);
158 
159  // read SWF::PLACEOBJECT2
160  void readPlaceObject2(SWFStream& in);
161 
162  // read SWF::PLACEOBJECT3
163  void readPlaceObject3(SWFStream& in);
164 
165  std::uint8_t m_has_flags2;
166  std::uint8_t m_has_flags3;
167  std::uint16_t _id;
168  SWFCxForm m_color_transform;
169  SWFMatrix m_matrix;
170  std::uint16_t _ratio;
171  std::string m_name;
172  int m_clip_depth;
173 
174  std::uint8_t _blendMode;
175 
177  enum PlaceType
178  {
179  REMOVE = 0,
180  MOVE = 1,
181  PLACE = 2,
182  REPLACE = 3
183  };
184 
185  enum has_flags2_mask_e
186  {
187  HAS_CLIP_ACTIONS_MASK = 1 << 7,
188  HAS_CLIP_DEPTH_MASK = 1 << 6,
189  HAS_NAME_MASK = 1 << 5,
190  HAS_RATIO_MASK = 1 << 4,
191  HAS_CXFORM_MASK = 1 << 3,
192  HAS_MATRIX_MASK = 1 << 2,
193  HAS_CHARACTER_MASK = 1 << 1,
194  MOVE_MASK = 1 << 0
195  };
196 
197  enum has_flags3_mask_e
198  {
199  HAS_IMAGE_MASK = 1 << 4,
200  HAS_CLASS_NAME_MASK = 1 << 3,
201  HAS_BITMAP_CACHING_MASK = 1 << 2,
202  HAS_BLEND_MODE_MASK = 1 << 1,
203  HAS_FILTERS_MASK = 1 << 0
204  };
205 
206  const movie_definition& _movie_def;
207 
208  ActionBuffers _actionBuffers;
209 
210  EventHandlers _eventHandlers;
211 };
212 
213 } // namespace gnash::SWF
214 } // namespace gnash
215 
216 
217 #endif // GNASH_SWF_PLACEOBJECT2TAG_H
218 
219 
220 // Local Variables:
221 // mode: C++
222 // indent-tabs-mode: t
223 // End:
bool hasName() const
Definition: PlaceObject2Tag.h:119
bool hasClassName() const
Definition: PlaceObject2Tag.h:127
Client program&#39;s interface to the definition of a movie or sprite.
Definition: movie_definition.h:95
A MovieClip is a container for DisplayObjects.
Definition: MovieClip.h:83
~PlaceObject2Tag()
Definition: PlaceObject2Tag.cpp:480
TagType
SWF tag types. Symbolic names copied from Ming.
Definition: SWF.h:30
bool hasRatio() const
Definition: PlaceObject2Tag.h:120
Definition: SWFMatrix.h:53
void executeState(MovieClip *m, DisplayList &dlist) const
Place/move/whatever our object in the given movie.
Definition: PlaceObject2Tag.cpp:458
const EventHandlers & getEventHandlers() const
Definition: PlaceObject2Tag.h:115
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
int getPlaceType() const
Definition: PlaceObject2Tag.h:105
std::uint16_t getID() const
Definition: PlaceObject2Tag.h:111
Color transformation record.
Definition: SWFCxForm.h:34
SWF Tag PlaceObject (4) or PlaceObject2 (9)
Definition: PlaceObject2Tag.h:85
std::uint16_t getRatio() const
Definition: PlaceObject2Tag.h:109
void read(SWFStream &in, TagType tag)
Read SWF::PLACEOBJECT or SWF::PLACEOBJECT2.
Definition: PlaceObject2Tag.cpp:443
Definition: GnashKey.h:164
DisplayList tag.
Definition: DisplayListTag.h:41
bool hasBlendMode() const
Definition: PlaceObject2Tag.h:135
PlaceObject2Tag(const movie_definition &def)
Definition: PlaceObject2Tag.cpp:45
Class to group together per-run and external resources for Gnash.
Definition: RunResources.h:53
boost::ptr_vector< swf_event > EventHandlers
Definition: PlaceObject2Tag.h:90
bool hasMatrix() const
Definition: PlaceObject2Tag.h:122
bool hasCharacter() const
Definition: PlaceObject2Tag.h:123
const SWFCxForm & getCxform() const
Definition: PlaceObject2Tag.h:114
int getClipDepth() const
Definition: PlaceObject2Tag.h:110
boost::ptr_vector< action_buffer > ActionBuffers
Definition: PlaceObject2Tag.h:89
bool hasClipDepth() const
Definition: PlaceObject2Tag.h:118
std::uint8_t getBlendMode() const
Get an associated blend mode.
Definition: PlaceObject2Tag.h:147
bool hasImage() const
Definition: PlaceObject2Tag.h:125
bool hasBitmapCaching() const
Definition: PlaceObject2Tag.h:131
bool hasClipActions() const
Definition: PlaceObject2Tag.h:117
bool hasCxform() const
Definition: PlaceObject2Tag.h:121
bool hasFilters() const
Definition: PlaceObject2Tag.h:139
static void loader(SWFStream &in, TagType tag, movie_definition &m, const RunResources &r)
Definition: PlaceObject2Tag.cpp:485
Definition: GnashKey.h:159
const std::string & getName() const
Definition: PlaceObject2Tag.h:112
A list of on-stage DisplayObjects, ordered by depth.
Definition: DisplayList.h:64
Definition: GnashKey.h:331
SWF stream wrapper class.
Definition: SWFStream.h:58
const SWFMatrix & getMatrix() const
Definition: PlaceObject2Tag.h:113