Gnash 0.8.10dev
PlaceObject2Tag.h
Go to the documentation of this file.
00001 // 
00002 //   Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
00003 // 
00004 // This program is free software; you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation; either version 3 of the License, or
00007 // (at your option) any later version.
00008 // 
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 // 
00014 // You should have received a copy of the GNU General Public License
00015 // along with this program; if not, write to the Free Software
00016 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00017 
00018 #ifndef GNASH_SWF_PLACEOBJECT2TAG_H
00019 #define GNASH_SWF_PLACEOBJECT2TAG_H
00020 
00021 #include <string>
00022 #include <boost/ptr_container/ptr_vector.hpp>
00023 
00024 #include "DisplayListTag.h" // for inheritance
00025 #include "SWF.h" // for TagType definition
00026 #include "SWFMatrix.h" // for composition
00027 #include "SWFCxForm.h" // for composition 
00028 
00029 // Forward declarations
00030 namespace gnash {
00031     class SWFStream;
00032     class swf_event;
00033     class action_buffer;
00034     class movie_definition;
00035         class DisplayList;
00036     class RunResources;
00037 }
00038 
00039 namespace gnash {
00040 namespace SWF {
00041 
00043 //
00084 class PlaceObject2Tag : public DisplayListTag
00085 {
00086 public:
00087 
00088     typedef boost::ptr_vector<action_buffer> ActionBuffers;
00089     typedef boost::ptr_vector<swf_event> EventHandlers;
00090 
00091     PlaceObject2Tag(const movie_definition& def);
00092 
00093     ~PlaceObject2Tag();
00094 
00096     void read(SWFStream& in, TagType tag);
00097 
00099     void executeState(MovieClip* m, DisplayList& dlist) const;
00100 
00101     static void loader(SWFStream& in, TagType tag, movie_definition& m,
00102             const RunResources& r);
00103 
00104     int getPlaceType() const { 
00105         return m_has_flags2 & (HAS_CHARACTER_MASK | MOVE_MASK);
00106     } 
00107 
00108     boost::uint16_t getRatio() const { return _ratio; }
00109     int getClipDepth() const { return m_clip_depth; }
00110     boost::uint16_t getID() const { return _id; }
00111     const std::string& getName() const { return m_name; }
00112     const SWFMatrix& getMatrix() const { return m_matrix; }
00113     const SWFCxForm& getCxform() const { return m_color_transform; }
00114     const EventHandlers& getEventHandlers() const { return _eventHandlers; }
00115     
00116     bool hasClipActions() const { return m_has_flags2 & HAS_CLIP_ACTIONS_MASK; }
00117     bool hasClipDepth()   const { return m_has_flags2 & HAS_CLIP_DEPTH_MASK; };
00118     bool hasName()        const { return m_has_flags2 & HAS_NAME_MASK; }
00119     bool hasRatio()       const { return m_has_flags2 & HAS_RATIO_MASK; }
00120     bool hasCxform()      const { return m_has_flags2 & HAS_CXFORM_MASK; }
00121     bool hasMatrix()      const { return m_has_flags2 & HAS_MATRIX_MASK; }
00122     bool hasCharacter()   const { return m_has_flags2 & HAS_CHARACTER_MASK; }
00123 
00124     bool hasImage() const { return m_has_flags3 & HAS_IMAGE_MASK; }
00125 
00126     bool hasClassName() const {
00127         return m_has_flags3 & HAS_CLASS_NAME_MASK;
00128     }
00129 
00130     bool hasBitmapCaching() const { 
00131         return m_has_flags3 & HAS_BITMAP_CACHING_MASK;
00132     }
00133 
00134     bool hasBlendMode() const {
00135         return m_has_flags3 & HAS_BLEND_MODE_MASK;
00136     }
00137 
00138     bool hasFilters() const {
00139         return m_has_flags3 & HAS_FILTERS_MASK;
00140     }
00141 
00143     //
00146     boost::uint8_t getBlendMode() const {
00147         return _blendMode;
00148     }
00149 
00150 private:
00151 
00152     // read SWF::PLACEOBJECT 
00153     void readPlaceObject(SWFStream& in);
00154 
00155     // read placeObject2 actions
00156     void readPlaceActions(SWFStream& in);
00157 
00158     // read SWF::PLACEOBJECT2 
00159     void readPlaceObject2(SWFStream& in);
00160 
00161     // read SWF::PLACEOBJECT3
00162     void readPlaceObject3(SWFStream& in);
00163 
00164     boost::uint8_t m_has_flags2;
00165     boost::uint8_t m_has_flags3;
00166     boost::uint16_t _id;
00167     SWFCxForm  m_color_transform;
00168     SWFMatrix  m_matrix;
00169     boost::uint16_t _ratio;
00170     std::string m_name;
00171     int     m_clip_depth;
00172     
00173     boost::uint8_t _blendMode;
00174 
00176     enum PlaceType
00177     {
00178         REMOVE  = 0, 
00179         MOVE    = 1,
00180         PLACE   = 2,
00181         REPLACE = 3
00182     };
00183 
00184     enum has_flags2_mask_e
00185     {
00186         HAS_CLIP_ACTIONS_MASK = 1 << 7,
00187         HAS_CLIP_DEPTH_MASK   = 1 << 6,
00188         HAS_NAME_MASK         = 1 << 5,
00189         HAS_RATIO_MASK        = 1 << 4,
00190         HAS_CXFORM_MASK       = 1 << 3,
00191         HAS_MATRIX_MASK       = 1 << 2,
00192         HAS_CHARACTER_MASK    = 1 << 1,
00193         MOVE_MASK             = 1 << 0
00194     };
00195 
00196     enum has_flags3_mask_e
00197     {
00198         HAS_IMAGE_MASK          = 1 << 4,
00199         HAS_CLASS_NAME_MASK     = 1 << 3,
00200         HAS_BITMAP_CACHING_MASK = 1 << 2,
00201         HAS_BLEND_MODE_MASK     = 1 << 1,
00202         HAS_FILTERS_MASK        = 1 << 0
00203     };
00204 
00205     const movie_definition& _movie_def;
00206 
00207     ActionBuffers _actionBuffers;
00208 
00209     EventHandlers _eventHandlers;
00210 };
00211 
00212 } // namespace gnash::SWF
00213 } // namespace gnash
00214 
00215 
00216 #endif // GNASH_SWF_PLACEOBJECT2TAG_H
00217 
00218 
00219 // Local Variables:
00220 // mode: C++
00221 // indent-tabs-mode: t
00222 // End: