[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ./ChangeLog server/impl.cpp server/movie_...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ./ChangeLog server/impl.cpp server/movie_... |
Date: |
Tue, 09 May 2006 10:41:44 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Branch:
Changes by: Sandro Santilli <address@hidden> 06/05/09 10:41:44
Modified files:
. : ChangeLog
server : impl.cpp movie_def_impl.cpp movie_def_impl.h
movie_definition.h sprite_definition.h
Log message:
* server/impl.cpp: (define_shape_loader) symbolic names for
tag types
* server/movie_def_impl.cpp, server/movie_def_impl.h:
new CharacterDictionary class.
* server/movie_definition.h: updated doxygen comments.
* server/sprite_definition.h: update doxygen comments.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/ChangeLog.diff?tr1=1.280&tr2=1.281&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/impl.cpp.diff?tr1=1.33&tr2=1.34&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/movie_def_impl.cpp.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/movie_def_impl.h.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/movie_definition.h.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/sprite_definition.h.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
Patches:
Index: gnash/ChangeLog
diff -u gnash/ChangeLog:1.280 gnash/ChangeLog:1.281
--- gnash/ChangeLog:1.280 Tue May 9 10:32:14 2006
+++ gnash/ChangeLog Tue May 9 10:41:43 2006
@@ -1,5 +1,11 @@
2006-05-09 Sandro Santilli <address@hidden>
+ * server/impl.cpp: (define_shape_loader) symbolic names for
+ tag types
+ * server/movie_def_impl.cpp, server/movie_def_impl.h:
+ new CharacterDictionary class.
+ * server/movie_definition.h: updated doxygen comments.
+ * server/sprite_definition.h: update doxygen comments.
* configure.ac: added misc-ming.all directory's Makefile;
fixed name of debian package for gtk2 (libgtk2-dev => libgtk2.0-dev)
* testsuite/Makefile.am: added misc-ming.all subdir,
Index: gnash/server/impl.cpp
diff -u gnash/server/impl.cpp:1.33 gnash/server/impl.cpp:1.34
--- gnash/server/impl.cpp:1.33 Mon May 8 21:12:24 2006
+++ gnash/server/impl.cpp Tue May 9 10:41:43 2006
@@ -1263,11 +1263,11 @@
IF_VERBOSE_PARSE(log_msg(" FIXME: tagtype = %d\n", tag_type));
}
-void define_shape_loader(stream* in, int tag_type, movie_definition* m)
+void define_shape_loader(stream* in, int tag_type, movie_definition* m)
{
- assert(tag_type == 2
- || tag_type == 22
- || tag_type == 32);
+ assert(tag_type == SWF::DEFINESHAPE
+ || tag_type == SWF::DEFINESHAPE2
+ || tag_type == SWF::DEFINESHAPE3);
uint16_t character_id = in->read_u16();
IF_VERBOSE_PARSE(log_msg(" shape_loader: id = %d\n", character_id));
Index: gnash/server/movie_def_impl.cpp
diff -u gnash/server/movie_def_impl.cpp:1.3 gnash/server/movie_def_impl.cpp:1.4
--- gnash/server/movie_def_impl.cpp:1.3 Mon May 8 21:12:24 2006
+++ gnash/server/movie_def_impl.cpp Tue May 9 10:41:44 2006
@@ -231,11 +231,12 @@
void movie_def_impl::add_character(int character_id, character_def* c)
{
- assert(c);
- m_characters.add(character_id, c);
+ assert(c);
+ _dictionary.add_character(character_id, c);
}
-character_def* movie_def_impl::get_character_def(int character_id)
+character_def*
+movie_def_impl::get_character_def(int character_id)
{
#ifndef NDEBUG
// make sure character_id is resolved
@@ -246,10 +247,9 @@
}
#endif // not NDEBUG
- smart_ptr<character_def> ch;
- m_characters.get(character_id, &ch);
- assert(ch == NULL || ch->get_ref_count() > 1);
- return ch.get_ptr();
+ smart_ptr<character_def> ch = _dictionary.get_character(character_id);
+ assert(ch == NULL || ch->get_ref_count() > 1);
+ return ch.get_ptr(); // mm... why don't we return the smart_ptr?
}
void movie_def_impl::add_font(int font_id, font* f)
@@ -479,14 +479,28 @@
get_owned_fonts(&fonts);
fontlib::output_cached_data(out, fonts, this, options);
- // Write character data.
- {for (hash<int, smart_ptr<character_def> >::iterator it =
m_characters.begin();
+ // Write character data.
+ {
+
+ for ( CharacterDictionary::iterator
+ it = _dictionary.begin(), itEnd = _dictionary.end();
+ it != itEnd;
+ ++it )
+ {
+ out->write_le16(it->first);
+ it->second->output_cached_data(out, options);
+ }
+
+#if 0
+ for (hash<int, smart_ptr<character_def> >::iterator it =
m_characters.begin();
it != m_characters.end();
++it)
{
out->write_le16(it->first);
it->second->output_cached_data(out, options);
- }}
+ }
+#endif
+ }
out->write_le16((int16_t) -1); // end of characters marker
}
@@ -533,8 +547,8 @@
int16_t id = in->read_le16();
if (id == (int16_t) -1) { break; } // done
- smart_ptr<character_def> ch;
- m_characters.get(id, &ch);
+ smart_ptr<character_def> ch = _dictionary.get_character(id);
+ //m_characters.get(id, &ch);
if (ch != NULL)
{
ch->input_cached_data(in);
@@ -569,6 +583,23 @@
}
+//
+// CharacterDictionary
+//
+
+smart_ptr<character_def>
+CharacterDictionary::get_character(int id)
+{
+ container::iterator it = _map.find(id);
+ if ( it == _map.end() ) return smart_ptr<character_def>();
+ else return it->second;
+}
+
+void
+CharacterDictionary::add_character(int id, smart_ptr<character_def> c)
+{
+ _map[id] = c;
+}
} // namespace gnash
Index: gnash/server/movie_def_impl.h
diff -u gnash/server/movie_def_impl.h:1.2 gnash/server/movie_def_impl.h:1.3
--- gnash/server/movie_def_impl.h:1.2 Sun May 7 19:40:43 2006
+++ gnash/server/movie_def_impl.h Tue May 9 10:41:44 2006
@@ -50,51 +50,107 @@
#include "character_def.h" // for smart_ptr visibility of dtor
#include "bitmap_character_def.h" // for smart_ptr visibility of dtor
#include "resource.h" // for smart_ptr visibility of dtor
+#include <map> // for CharacterDictionary
namespace gnash
{
- // Forward declarations
- class import_info;
- struct movie_def_impl;
- struct movie_root;
- struct import_visitor; // in gnash.h
+// Forward declarations
+class import_info;
+struct movie_def_impl;
+struct movie_root;
+
+//
+// Helper for movie_def_impl
+//
+
+class import_info
+{
+ friend class movie_def_impl;
+
+ tu_string m_source_url;
+ int m_character_id;
+ tu_string m_symbol;
+
+ import_info()
+ :
+ m_character_id(-1)
+ {
+ }
+
+ import_info(const char* source, int id, const char* symbol)
+ :
+ m_source_url(source),
+ m_character_id(id),
+ m_symbol(symbol)
+ {
+ }
+};
+
+/// The Characters dictionary associated with each SWF file.
+//
+/// This is a set of Characters defined by define tags and
+/// getting assigned a unique ID.
+///
+class CharacterDictionary
+{
+
+public:
+
+ /// The container used by this dictionary
//
- // Helper for movie_def_impl
+ /// It contains pairs of 'int' and 'smart_ptr<character_def>'
+ ///
+ typedef std::map< int, smart_ptr<character_def> > container;
+ //typedef hash< int, smart_ptr<character_def> >container;
+
+ typedef container::iterator iterator;
+
+ typedef container::const_iterator const_iterator;
+
+ /// Get the Character with the given id
//
- class import_info
- {
- friend class movie_def_impl;
+ /// returns a NULL if the id is unknown.
+ ///
+ smart_ptr<character_def> get_character(int id);
- tu_string m_source_url;
- int m_character_id;
- tu_string m_symbol;
+ /// Add a Character assigning it the given id
+ //
+ /// replaces any existing character with the same id
+ ///
+ void add_character(int id, smart_ptr<character_def> c);
- import_info()
- :
- m_character_id(-1)
- {
- }
+ /// Return an iterator to the first dictionary element
+ iterator begin() { return _map.begin(); }
- import_info(const char* source, int id, const char* symbol)
- :
- m_source_url(source),
- m_character_id(id),
- m_symbol(symbol)
- {
- }
- };
+ /// Return a const_iterator to the first dictionary element
+ const_iterator begin() const { return _map.begin(); }
+
+ /// Return an iterator to one-past last dictionary element
+ iterator end() { return _map.end(); }
+
+ /// Return a const_iterator to one-past last dictionary element
+ const_iterator end() const { return _map.end(); }
+
+private:
+
+ container _map;
+
+};
/// Immutable definition of a movie's contents.
//
/// It cannot be played directly, and does not hold
/// current state; for that you need to call create_instance()
-/// to get a movie_instance (movie_interface).
+/// to get a movie instance (gnash::movie_interface).
///
class movie_def_impl : public movie_definition
{
- hash<int, smart_ptr<character_def> > m_characters;
+ /// Characters Dictionary, could be a separate class
+ //hash<int, smart_ptr<character_def> > m_characters;
+ CharacterDictionary _dictionary;
+
hash<int, smart_ptr<font> > m_fonts;
hash<int, smart_ptr<bitmap_character_def> > m_bitmap_characters;
hash<int, smart_ptr<sound_sample> > m_sound_samples;
@@ -254,6 +310,11 @@
void add_character(int character_id, character_def* c);
+ /// \brief
+ /// Return a character from the dictionary
+ /// NOTE: call add_ref() on the return or put in a smart_ptr<>
+ /// TODO: return a smart_ptr<> directly...
+ ///
character_def* get_character_def(int character_id);
/// Returns 0-based frame #
Index: gnash/server/movie_definition.h
diff -u gnash/server/movie_definition.h:1.2 gnash/server/movie_definition.h:1.3
--- gnash/server/movie_definition.h:1.2 Sun May 7 12:19:06 2006
+++ gnash/server/movie_definition.h Tue May 9 10:41:44 2006
@@ -47,11 +47,16 @@
/// A Movie instance is defined by the gnash::movie_interface class.
///
/// A Movie instance exposes the ActionScript
-/// Object base interface (gnash::as_object_interface),
+/// Object base interface (gnash::as_object),
/// thus it can manage gnash::as_value members.
///
/// The implementation of SWF parsing for a Movie definition
/// is found in gnash::movie_def_impl::read.
+/// Note that movie_definition is also used as a base class
+/// to sprite_definition, which is a sub-movie defined in an SWF
+/// file. This seems to be the only reason to have a
+/// movie_def_impl class, being the top-level definition of
+/// a movie (the one with a CharacterDictionary in it).
///
@@ -168,6 +173,16 @@
virtual const std::vector<execute_tag*>& get_playlist(int
frame_number) = 0;
virtual const std::vector<execute_tag*>* get_init_actions(int
frame_number) = 0;
virtual smart_ptr<resource> get_exported_resource(const tu_string&
symbol) = 0;
+
+
+ /// \brief
+ /// Get a character from the dictionary.
+ ///
+ /// Note that only top-level movies (those belonging to a single
+ /// SWF stream) have a characters dictionary, thus our
+ /// movie_def_impl. The other derived class, sprite_definition
+ /// will seek for characters in it's base movie_def_impl.
+ ///
virtual character_def* get_character_def(int id) = 0;
virtual bool get_labeled_frame(const char* label, int* frame_number)
= 0;
Index: gnash/server/sprite_definition.h
diff -u gnash/server/sprite_definition.h:1.3
gnash/server/sprite_definition.h:1.4
--- gnash/server/sprite_definition.h:1.3 Sun May 7 12:19:06 2006
+++ gnash/server/sprite_definition.h Tue May 9 10:41:44 2006
@@ -76,7 +76,7 @@
private:
- /// parent movie.
+ /// Top-level movie (the one with a character_def)
movie_definition* m_movie_def;
/// movie control events for each frame.
@@ -96,7 +96,7 @@
virtual float get_frame_rate() const { return
m_movie_def->get_frame_rate(); }
virtual int get_loading_frame() const { return m_loading_frame; }
virtual int get_version() const { return
m_movie_def->get_version(); }
- virtual void add_character(int id, character_def* ch) {
log_error("add_character tag appears in sprite tags!\n"); }
+
virtual void add_font(int id, font* ch) { log_error("add_font tag
appears in sprite tags!\n"); }
virtual font* get_font(int id) { return m_movie_def->get_font(id); }
virtual void set_jpeg_loader(jpeg::input* j_in) { assert(0); }
@@ -118,11 +118,31 @@
virtual void add_import(const char* source_url, int id, const char*
symbol) { assert(0); }
virtual void visit_imported_movies(import_visitor* v) { assert(0); }
virtual void resolve_import(const char* source_url,
movie_definition* d) { assert(0); }
+
+ /// \brief
+ /// Get a character_def from this Sprite's parent
+ /// CharacterDictionary. NOTE that calling this
+ /// method on the leaf Sprite of a movie_definition
+ /// hierarchy will result in a recursive scan of
+ /// all parents until the top-level movie_definition
+ /// (movie_def_impl) is found.
+ ///
virtual character_def* get_character_def(int id)
{
return m_movie_def->get_character_def(id);
}
+ /// Calls to this function should only be made when
+ /// an invalid SWF is being read, as it would mean
+ /// that a Definition tag is been found as part of
+ /// a Sprite definition
+ ///
+ virtual void add_character(int id, character_def* ch)
+ {
+ log_error("add_character tag appears in sprite tags!\n");
+ }
+
+
virtual void generate_font_bitmaps() { assert(0); }
virtual void output_cached_data(tu_file* out,
- [Gnash-commit] gnash ./ChangeLog server/impl.cpp server/movie_...,
Sandro Santilli <=