Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef GNASH_SPRITE_DEFINITION_H
00022 #define GNASH_SPRITE_DEFINITION_H
00023
00024
00025 #include <boost/intrusive_ptr.hpp>
00026 #include <boost/cstdint.hpp>
00027 #include <string>
00028 #include <map>
00029 #include "smart_ptr.h"
00030 #include "movie_definition.h"
00031 #include "log.h"
00032 #include "SWFRect.h"
00033 #include "StringPredicates.h"
00034
00035
00036 namespace gnash {
00037 class SWFStream;
00038 class as_function;
00039 class RunResources;
00040 }
00041
00042 namespace gnash
00043 {
00044
00045
00051 class sprite_definition : public movie_definition
00052 {
00053
00054 public:
00055
00058
00069 sprite_definition(movie_definition& m, SWFStream& in,
00070 const RunResources& runResources, boost::uint16_t id);
00071
00073 ~sprite_definition();
00074
00076
00085 void registerClass(as_function* the_class);
00086
00088 as_function* getRegisteredClass() const
00089 {
00090 return registeredClass.get();
00091 }
00092
00093 virtual void incrementLoadedFrames() {
00094 ++m_loading_frame;
00095 }
00096
00097
00098 virtual size_t get_width_pixels() const { return 1; }
00099
00100
00101 virtual size_t get_height_pixels() const { return 1; }
00102
00103
00104 virtual size_t get_frame_count() const { return m_frame_count; }
00105
00110 virtual size_t get_bytes_total() const
00111 {
00112 return m_movie_def.get_bytes_total();
00113 }
00114
00119 virtual size_t get_bytes_loaded() const
00120 {
00121 return m_movie_def.get_bytes_loaded();
00122 }
00123
00124 virtual float get_frame_rate() const
00125 {
00126 return m_movie_def.get_frame_rate();
00127 }
00128
00129 const SWFRect& get_frame_size() const
00130 {
00131 abort();
00132 static const SWFRect unused;
00133 return unused;
00134 }
00135
00136
00137 virtual size_t get_loading_frame() const { return m_loading_frame; }
00138
00139 virtual int get_version() const
00140 {
00141 return m_movie_def.get_version();
00142 }
00143
00145 virtual void add_font(int , Font* )
00146 {
00147 IF_VERBOSE_MALFORMED_SWF (
00148 log_swferror(_("add_font tag appears in sprite tags"));
00149 );
00150 }
00151
00153 virtual Font* get_font(int id) const
00154 {
00155 return m_movie_def.get_font(id);
00156 }
00157
00159 virtual CachedBitmap* getBitmap(int id) const
00160 {
00161 return m_movie_def.getBitmap(id);
00162 }
00163
00165 virtual void addBitmap(int , boost::intrusive_ptr<CachedBitmap> )
00166 {
00167 IF_VERBOSE_MALFORMED_SWF (
00168 log_swferror(_("add_bitmap_SWF::DefinitionTag appears in sprite tags"));
00169 );
00170 }
00171
00173 virtual sound_sample* get_sound_sample(int id) const
00174 {
00175 return m_movie_def.get_sound_sample(id);
00176 }
00177
00179 virtual void add_sound_sample(int id, sound_sample* sam)
00180 {
00181
00182
00183
00184 m_movie_def.add_sound_sample(id,sam);
00185 }
00186
00187
00188 virtual void set_loading_sound_stream_id(int id)
00189 {
00190 _loadingSoundStream = id;
00191 }
00192
00193
00194 virtual int get_loading_sound_stream_id() const
00195 {
00196 return _loadingSoundStream;
00197 }
00198
00199 virtual boost::uint16_t exportID(const std::string& symbol) const {
00200 return m_movie_def.exportID(symbol);
00201 }
00202
00203 virtual void registerExport(const std::string& s, boost::uint16_t id) {
00204 m_movie_def.registerExport(s, id);
00205 }
00206
00211 virtual SWF::DefinitionTag* getDefinitionTag(boost::uint16_t id) const
00212 {
00213 return m_movie_def.getDefinitionTag(id);
00214 }
00215
00217 virtual void addDisplayObject(boost::uint16_t id, SWF::DefinitionTag* c)
00218 {
00219 m_movie_def.addDisplayObject(id, c);
00220 }
00221
00222
00223
00224
00225
00226
00227 virtual DisplayObject* createDisplayObject(Global_as& gl,
00228 DisplayObject* parent) const;
00229
00230
00231 virtual void addControlTag(SWF::ControlTag* c)
00232 {
00233 m_playlist[m_loading_frame].push_back(c);
00234 }
00235
00236 private:
00237
00238 void read(SWFStream& in, const RunResources& runResources);
00239
00242 movie_definition& m_movie_def;
00243
00244 typedef std::map<size_t, PlayList> PlayListMap;
00245
00247 PlayListMap m_playlist;
00248
00249
00250 typedef std::map<std::string, size_t, StringNoCaseLessThan> NamedFrameMap;
00251 NamedFrameMap _namedFrames;
00252
00253 size_t m_frame_count;
00254
00255
00256 size_t m_loading_frame;
00257
00258
00259 virtual void add_frame_name(const std::string& name);
00260
00261
00262 bool get_labeled_frame(const std::string& label, size_t& frame_number)
00263 const;
00264
00266 const PlayList* getPlaylist(size_t frame_number) const
00267 {
00268
00269
00270
00271
00272 PlayListMap::const_iterator it = m_playlist.find(frame_number);
00273 if ( it == m_playlist.end() ) return NULL;
00274 else return &(it->second);
00275 }
00276
00277 virtual const std::string& get_url() const
00278 {
00279 return m_movie_def.get_url();
00280 }
00281
00286 virtual bool ensure_frame_loaded(size_t framenum) const
00287 {
00288
00289 while ( m_loading_frame < framenum )
00290 {
00291 log_debug(_("sprite_definition: "
00292 "loading of frame %d requested "
00293 "(we are at %d/%d)"),
00294 framenum, m_loading_frame, m_frame_count);
00295
00296 return false;
00297 }
00298 return true;
00299 }
00300
00304
00308 boost::intrusive_ptr<as_function> registeredClass;
00309
00310 int _loadingSoundStream;
00311
00312 protected:
00313
00314
00315 #ifdef GNASH_USE_GC
00316
00317
00321 void markReachableResources() const;
00322 #endif // GNASH_USE_GC
00323 };
00324
00325
00326 }
00327
00328 #endif // GNASH_SPRITE_H