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:
gnash::readSWFMatrix
SWFMatrix readSWFMatrix(SWFStream &in)
Read a SWFMatrix from input stream.
Definition: TypesParser.cpp:49
action_buffer.h
gnash::SWF::PlaceObject2Tag::hasRatio
bool hasRatio() const
Definition: PlaceObject2Tag.h:120
gnash::SWF::PlaceObject2Tag::hasClassName
bool hasClassName() const
Definition: PlaceObject2Tag.h:127
gnash::SWF::PlaceObject2Tag::hasClipDepth
bool hasClipDepth() const
Definition: PlaceObject2Tag.h:118
TypesParser.h
gnash::SWF::PlaceObject2Tag::hasCharacter
bool hasCharacter() const
Definition: PlaceObject2Tag.h:123
gnash::log_swferror
void log_swferror(StringType msg, Args... args)
Definition: log.h:325
gnash::SWF::TagType
TagType
SWF tag types. Symbolic names copied from Ming.
Definition: SWF.h:31
gnash::arraySize
size_t arraySize(T(&)[N])
Get the size of an array without passing a pointer by mistake.
Definition: GnashAlgorithm.h:58
gnash::DisplayObject::staticDepthOffset
static const int staticDepthOffset
Definition: DisplayObject.h:205
gnash::event_id::LOAD
@ LOAD
Definition: event_id.h:73
gnash::event_id::MOUSE_UP
@ MOUSE_UP
Definition: event_id.h:77
gnash::key::i
@ i
Definition: GnashKey.h:155
LOG_ONCE
#define LOG_ONCE(x)
Definition: log.h:49
_
#define _(String)
Definition: log.h:44
Filters.h
gnash::SWF::PlaceObject2Tag::PlaceObject2Tag
PlaceObject2Tag(const movie_definition &def)
Definition: PlaceObject2Tag.cpp:45
gnash
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:41
gnash::SWF::PlaceObject2Tag::getEventHandlers
const EventHandlers & getEventHandlers() const
Definition: PlaceObject2Tag.h:115
gnash::event_id::ROLL_OVER
@ ROLL_OVER
Definition: event_id.h:65
gnash::SWF::DisplayListTag::_depth
int _depth
Definition: DisplayListTag.h:63
gnash::SWF::PlaceObject2Tag::hasBitmapCaching
bool hasBitmapCaching() const
Definition: PlaceObject2Tag.h:131
gnash::SWF::PlaceObject2Tag::executeState
void executeState(MovieClip *m, DisplayList &dlist) const
Place/move/whatever our object in the given movie.
Definition: PlaceObject2Tag.cpp:458
gnash::SWF::PlaceObject2Tag::~PlaceObject2Tag
~PlaceObject2Tag()
Definition: PlaceObject2Tag.cpp:480
gnash::key::m
@ m
Definition: GnashKey.h:159
utility.h
gnash::SWF::PlaceObject2Tag::hasBlendMode
bool hasBlendMode() const
Definition: PlaceObject2Tag.h:135
gnash::SWF::PlaceObject2Tag::hasCxform
bool hasCxform() const
Definition: PlaceObject2Tag.h:121
gnash::SWF::PlaceObject2Tag::getID
std::uint16_t getID() const
Definition: PlaceObject2Tag.h:111
gnash::SWF::PlaceObject2Tag::hasFilters
bool hasFilters() const
Definition: PlaceObject2Tag.h:139
gnash::SWF::PLACEOBJECT2
@ PLACEOBJECT2
Definition: SWF.h:58
gnash::SWFCxForm
Color transformation record.
Definition: SWFCxForm.h:35
gnash::filter_factory::read
static int read(SWFStream &in, bool read_multiple, Filters *store)
Read one, possibly multiple filters from the stream, and push them into the vector store....
Definition: filter_factory.cpp:41
gnash::MovieClip
A MovieClip is a container for DisplayObjects.
Definition: MovieClip.h:84
PlaceObject2Tag.h
UNUSED
#define UNUSED(x)
Definition: utility.h:113
gnash::DisplayObject::noClipDepthValue
static const int noClipDepthValue
Definition: DisplayObject.h:230
gnash::movie_definition::get_version
virtual int get_version() const =0
gnash::movie_definition
Client program's interface to the definition of a movie or sprite.
Definition: movie_definition.h:96
SWFCxForm.h
IF_VERBOSE_MALFORMED_SWF
#define IF_VERBOSE_MALFORMED_SWF(x)
Definition: log.h:404
gnash::SWF::PlaceObject2Tag::getRatio
std::uint16_t getRatio() const
Definition: PlaceObject2Tag.h:109
gnash::DisplayList
A list of on-stage DisplayObjects, ordered by depth.
Definition: DisplayList.h:65
gnash::SWF::PLACEOBJECT
@ PLACEOBJECT
Definition: SWF.h:36
gnash::event_id::DRAG_OVER
@ DRAG_OVER
Definition: event_id.h:67
gnash::key::r
@ r
Definition: GnashKey.h:164
gnash::event_id::ROLL_OUT
@ ROLL_OUT
Definition: event_id.h:66
gnash::SWF::PlaceObject2Tag::hasMatrix
bool hasMatrix() const
Definition: PlaceObject2Tag.h:122
gnash::SWF::PlaceObject2Tag::getPlaceType
int getPlaceType() const
Definition: PlaceObject2Tag.h:105
gnash::SWF::DisplayListTag
DisplayList tag.
Definition: DisplayListTag.h:42
gnash::event_id::DATA
@ DATA
Definition: event_id.h:81
gnash::event_id::RELEASE
@ RELEASE
Definition: event_id.h:63
gnash::event_id::EventCode
EventCode
The types of events that are handled by DisplayObjects.
Definition: event_id.h:58
GnashAlgorithm.h
gnash::SWFStream::tell
unsigned long tell()
Return our current (byte) position in the input stream.
Definition: SWFStream.cpp:447
gnash::key::code
code
Definition: GnashKey.h:44
MovieClip.h
gnash::key::INVALID
@ INVALID
Definition: GnashKey.h:45
gnash::SWF::PlaceObject2Tag::getClipDepth
int getClipDepth() const
Definition: PlaceObject2Tag.h:110
gnash::Filters
std::vector< std::unique_ptr< BitmapFilter > > Filters
Definition: filter_factory.h:32
DisplayListTag.h
gnash::event_id::UNLOAD
@ UNLOAD
Definition: event_id.h:74
gnash::RunResources
Class to group together per-run and external resources for Gnash.
Definition: RunResources.h:54
gnash::event_id::PRESS
@ PRESS
Definition: event_id.h:62
gnash::SWFMatrix
Definition: SWFMatrix.h:54
gnash::SWF::PlaceObject2Tag::getMatrix
const SWFMatrix & getMatrix() const
Definition: PlaceObject2Tag.h:113
gnash::readCxFormRGBA
SWFCxForm readCxFormRGBA(SWFStream &in)
Read a CxForm with alpha from the input stream.
Definition: TypesParser.cpp:354
gnash::SWFStream::get_tag_end_position
unsigned long get_tag_end_position()
Return the file position of the end of the current tag.
Definition: SWFStream.cpp:497
gnash::SWF::PlaceObject2Tag
SWF Tag PlaceObject (4) or PlaceObject2 (9)
Definition: PlaceObject2Tag.h:86
gnash::SWF::PlaceObject2Tag::loader
static void loader(SWFStream &in, TagType tag, movie_definition &m, const RunResources &r)
Definition: PlaceObject2Tag.cpp:485
swf_event.h
filter_factory.h
IF_VERBOSE_PARSE
#define IF_VERBOSE_PARSE(x)
Definition: log.h:378
DisplayObject.h
gnash::log_parse
void log_parse(StringType msg, Args... args)
Definition: log.h:313
log.h
gnash::SWF::PlaceObject2Tag::EventHandlers
boost::ptr_vector< swf_event > EventHandlers
Definition: PlaceObject2Tag.h:90
gnash::event_id::MOUSE_DOWN
@ MOUSE_DOWN
Definition: event_id.h:76
gnash::event_id::KEY_DOWN
@ KEY_DOWN
Definition: event_id.h:79
gnashconfig.h
SWF.h
gnash::SWFStream::read_u16
std::uint16_t read_u16()
Read a aligned unsigned 16-bit value from the stream.
Definition: SWFStream.cpp:332
RunResources.h
gnash::readCxFormRGB
SWFCxForm readCxFormRGB(SWFStream &in)
Read a RGB CxForm from the input stream.
Definition: TypesParser.cpp:322
gnash::event_id::INITIALIZE
@ INITIALIZE
Definition: event_id.h:72
gnash::event_id::CONSTRUCT
@ CONSTRUCT
Definition: event_id.h:82
gnash::SWFStream
SWF stream wrapper class.
Definition: SWFStream.h:59
gnash::SWF::PlaceObject2Tag::getName
const std::string & getName() const
Definition: PlaceObject2Tag.h:112
gnash::SWF::PlaceObject2Tag::hasName
bool hasName() const
Definition: PlaceObject2Tag.h:119
gnash::event_id::RELEASE_OUTSIDE
@ RELEASE_OUTSIDE
Definition: event_id.h:64
gnash::SWF::PlaceObject2Tag::getBlendMode
std::uint8_t getBlendMode() const
Get an associated blend mode.
Definition: PlaceObject2Tag.h:147
gnash::SWF::PlaceObject2Tag::hasClipActions
bool hasClipActions() const
Definition: PlaceObject2Tag.h:117
gnash::SWFStream::ensureBytes
void ensureBytes(unsigned long needed)
Ensure the requested number of bytes are available for an aligned read in the currently opened tag.
Definition: SWFStream.cpp:50
gnash::event_id::ENTER_FRAME
@ ENTER_FRAME
Definition: event_id.h:75
gnash::key::SWF
@ SWF
Definition: GnashKey.h:331
gnash::log_unimpl
void log_unimpl(StringType msg, Args... args)
Definition: log.h:289
gnash::SWF::PlaceObject2Tag::getCxform
const SWFCxForm & getCxform() const
Definition: PlaceObject2Tag.h:114
gnash::event_id::KEY_UP
@ KEY_UP
Definition: event_id.h:80
gnash::event_id::MOUSE_MOVE
@ MOUSE_MOVE
Definition: event_id.h:78
gnash::SWF::PLACEOBJECT3
@ PLACEOBJECT3
Definition: SWF.h:100
SWFStream.h
test.v
v
Definition: test.py:11
gnash::SWF::PlaceObject2Tag::read
void read(SWFStream &in, TagType tag)
Read SWF::PLACEOBJECT or SWF::PLACEOBJECT2.
Definition: PlaceObject2Tag.cpp:443
gnash::event_id::KEY_PRESS
@ KEY_PRESS
Definition: event_id.h:69
gnash::SWF::PlaceObject2Tag::ActionBuffers
boost::ptr_vector< action_buffer > ActionBuffers
Definition: PlaceObject2Tag.h:89
gnash::SWF::PlaceObject2Tag::hasImage
bool hasImage() const
Definition: PlaceObject2Tag.h:125
gnash::event_id::DRAG_OUT
@ DRAG_OUT
Definition: event_id.h:68
SWFMatrix.h