[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r12192: Simplify tag execution.
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r12192: Simplify tag execution. |
Date: |
Thu, 20 May 2010 15:39:13 +0200 |
User-agent: |
Bazaar (2.0.3) |
------------------------------------------------------------
revno: 12192 [merge]
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Thu 2010-05-20 15:39:13 +0200
message:
Simplify tag execution.
Make DoInitAction parsing compatible.
modified:
libcore/ExportableResource.h
libcore/Font.h
libcore/MovieClip.cpp
libcore/parser/SWFMovieDefinition.cpp
libcore/parser/SWFMovieDefinition.h
libcore/parser/movie_definition.h
libcore/parser/sound_definition.h
libcore/parser/sprite_definition.h
libcore/swf/ControlTag.h
libcore/swf/DefineFontTag.h
libcore/swf/DefineSceneAndFrameLabelDataTag.h
libcore/swf/DisplayListTag.h
libcore/swf/DoABCTag.h
libcore/swf/DoActionTag.h
libcore/swf/DoInitActionTag.h
libcore/swf/PlaceObject2Tag.cpp
libcore/swf/PlaceObject2Tag.h
libcore/swf/RemoveObjectTag.cpp
libcore/swf/RemoveObjectTag.h
libcore/swf/ScriptLimitsTag.h
libcore/swf/SetBackgroundColorTag.h
libcore/swf/StartSoundTag.cpp
libcore/swf/StartSoundTag.h
libcore/swf/StreamSoundBlockTag.cpp
libcore/swf/StreamSoundBlockTag.h
libcore/swf/SymbolClassTag.h
libcore/swf/tag_loaders.cpp
libcore/swf/tag_loaders.h
libcore/vm/ASHandlers.cpp
testsuite/misc-ming.all/InitActionTest2.c
=== modified file 'libcore/ExportableResource.h'
--- a/libcore/ExportableResource.h 2010-03-11 01:47:08 +0000
+++ b/libcore/ExportableResource.h 2010-05-20 10:57:04 +0000
@@ -32,7 +32,6 @@
protected:
ExportableResource() {}
virtual ~ExportableResource() {}
-
};
=== modified file 'libcore/Font.h'
--- a/libcore/Font.h 2010-03-11 01:47:08 +0000
+++ b/libcore/Font.h 2010-05-20 10:57:04 +0000
@@ -51,7 +51,8 @@
class kerning_pair
{
public:
- boost::uint16_t m_char0, m_char1;
+ boost::uint16_t m_char0;
+ boost::uint16_t m_char1;
bool operator==(const kerning_pair& k) const
{
@@ -103,7 +104,7 @@
///
/// @param italic
/// Whether to use the italic variant of the font.
- Font(const std::string& name, bool bold=false, bool italic=false);
+ Font(const std::string& name, bool bold = false, bool italic = false);
~Font();
=== modified file 'libcore/MovieClip.cpp'
--- a/libcore/MovieClip.cpp 2010-05-07 09:20:30 +0000
+++ b/libcore/MovieClip.cpp 2010-05-20 09:57:10 +0000
@@ -87,11 +87,6 @@
//
//#define DEBUG_MOUSE_ENTITY_FINDING 1
-namespace {
- inline void executeIfActionTag(const SWF::ControlTag& t, MovieClip* m,
- DisplayList& dlist);
-}
-
// Anonymous namespace for module-private definitions
namespace {
@@ -429,8 +424,7 @@
// and a final call to .clear(), as repeated calls to
// .size() or .end() are no quicker (and probably slower)
// than pop_front(), which is constant time.
- while ( ! action_list.empty() )
- {
+ while (!action_list.empty()) {
const action_buffer* ab = action_list.front();
action_list.pop_front();
@@ -523,12 +517,11 @@
if (!_def) return;
size_t frame_number;
- if ( ! get_frame_number(frame_spec, frame_number) )
- {
+ if (!get_frame_number(frame_spec, frame_number)) {
// No dice.
IF_VERBOSE_ASCODING_ERRORS(
- log_aserror(_("call_frame('%s') -- invalid frame"),
- frame_spec);
+ log_aserror(_("call_frame('%s') -- invalid frame"),
+ frame_spec);
);
return;
}
@@ -546,7 +539,7 @@
PlayList::const_iterator it = playlist->begin();
const PlayList::const_iterator e = playlist->end();
for (; it != e; it++) {
- executeIfActionTag(**it, this, _displayList);
+ (*it)->executeActions(this, _displayList);
}
}
_callingFrameActions = false;
@@ -922,7 +915,7 @@
set_invalidated();
DisplayList tmplist;
- for (size_t f = 0; f<tgtFrame; ++f)
+ for (size_t f = 0; f < tgtFrame; ++f)
{
_currentFrame = f;
executeFrameTags(f, tmplist, SWF::ControlTag::TAG_DLIST);
@@ -947,10 +940,7 @@
assert(typeflags);
const PlayList* playlist = _def->getPlaylist(frame);
- if ( playlist )
- {
- PlayList::const_iterator it = playlist->begin();
- PlayList::const_iterator e = playlist->end();
+ if (playlist) {
IF_VERBOSE_ACTION(
// Use 1-based frame numbers
@@ -959,28 +949,20 @@
getTargetPath());
);
- if ((typeflags & SWF::ControlTag::TAG_DLIST) &&
- (typeflags & SWF::ControlTag::TAG_ACTION) )
- {
- for( ; it != e; it++)
- {
- (*it)->execute(this, dlist);
- }
- }
- else if ( typeflags & SWF::ControlTag::TAG_DLIST )
- {
- for( ; it != e; it++)
- {
- (*it)->execute_state(this, dlist);
- }
- }
- else
- {
- assert(typeflags & SWF::ControlTag::TAG_ACTION);
- for( ; it != e; it++) {
- executeIfActionTag(**it, this, _displayList);
- }
- }
+ // Generally tags should be executed in the order they are found in.
+ for (PlayList::const_iterator it = playlist->begin(),
+ e = playlist->end(); it != e; ++it) {
+
+ if (typeflags & SWF::ControlTag::TAG_DLIST) {
+ (*it)->executeState(this, dlist);
+ }
+
+ if (typeflags & SWF::ControlTag::TAG_ACTION) {
+ (*it)->executeActions(this, _displayList);
+ }
+
+ }
+
}
}
@@ -2285,15 +2267,4 @@
_playState = s;
}
-namespace {
-
-///
-inline void
-executeIfActionTag(const SWF::ControlTag& t, MovieClip* m, DisplayList& dlist)
-{
- if (t.is_action_tag()) t.execute(m, dlist);
-}
-
-}
-
} // namespace gnash
=== modified file 'libcore/parser/SWFMovieDefinition.cpp'
--- a/libcore/parser/SWFMovieDefinition.cpp 2010-01-25 18:52:20 +0000
+++ b/libcore/parser/SWFMovieDefinition.cpp 2010-05-20 10:48:28 +0000
@@ -74,45 +74,45 @@
}
SWFMovieLoader::SWFMovieLoader(SWFMovieDefinition& md)
- :
- _movie_def(md),
- _thread(NULL),
- _barrier(2) // us and the main thread..
+ :
+ _movie_def(md),
+ _thread(NULL),
+ _barrier(2) // us and the main thread..
{
}
SWFMovieLoader::~SWFMovieLoader()
{
- // we should assert _movie_def._loadingCanceled
- // but we're not friend yet (anyone introduce us ?)
- if ( _thread.get() )
- {
- //cout << "Joining thread.." << endl;
- _thread->join();
- }
+ // we should assert _movie_def._loadingCanceled
+ // but we're not friend yet (anyone introduce us ?)
+ if ( _thread.get() )
+ {
+ //cout << "Joining thread.." << endl;
+ _thread->join();
+ }
}
bool
SWFMovieLoader::started() const
{
- boost::mutex::scoped_lock lock(_mutex);
+ boost::mutex::scoped_lock lock(_mutex);
- return _thread.get() != NULL;
+ return _thread.get() != NULL;
}
bool
SWFMovieLoader::isSelfThread() const
{
- boost::mutex::scoped_lock lock(_mutex);
+ boost::mutex::scoped_lock lock(_mutex);
- if (!_thread.get()) {
- return false;
- }
+ if (!_thread.get()) {
+ return false;
+ }
#if BOOST_VERSION < 103500
- boost::thread this_thread;
- return this_thread == *_thread;
+ boost::thread this_thread;
+ return this_thread == *_thread;
#else
- return boost::this_thread::get_id() == _thread->get_id();
+ return boost::this_thread::get_id() == _thread->get_id();
#endif
}
@@ -121,8 +121,8 @@
void
SWFMovieLoader::execute(SWFMovieLoader& ml, SWFMovieDefinition* md)
{
- ml._barrier.wait(); // let _thread assignment happen before going on
- md->read_all_swf();
+ ml._barrier.wait(); // let _thread assignment happen before going on
+ md->read_all_swf();
}
bool
@@ -131,16 +131,16 @@
#ifndef LOAD_MOVIES_IN_A_SEPARATE_THREAD
std::abort();
#endif
- // don't start SWFMovieLoader thread() which rely
- // on boost::thread() returning before they are executed. Therefore,
- // we must employ locking.
- // Those tests do seem a bit redundant, though...
- boost::mutex::scoped_lock lock(_mutex);
+ // don't start SWFMovieLoader thread() which rely
+ // on boost::thread() returning before they are executed. Therefore,
+ // we must employ locking.
+ // Those tests do seem a bit redundant, though...
+ boost::mutex::scoped_lock lock(_mutex);
- _thread.reset(new boost::thread(boost::bind(
+ _thread.reset(new boost::thread(boost::bind(
execute, boost::ref(*this), &_movie_def)));
- _barrier.wait(); // let execution start befor returning
+ _barrier.wait(); // let execution start befor returning
return true;
}
@@ -151,17 +151,17 @@
//
SWFMovieDefinition::SWFMovieDefinition(const RunResources& runResources)
- :
- m_frame_rate(30.0f),
- m_frame_count(0u),
- m_version(0),
- _frames_loaded(0u),
- _waiting_for_frame(0),
- m_loading_sound_stream(-1),
- m_file_length(0),
- m_jpeg_in(0),
- _loader(*this),
- _loadingCanceled(false),
+ :
+ m_frame_rate(30.0f),
+ m_frame_count(0u),
+ m_version(0),
+ _frames_loaded(0u),
+ _waiting_for_frame(0),
+ m_loading_sound_stream(-1),
+ m_file_length(0),
+ m_jpeg_in(0),
+ _loader(*this),
+ _loadingCanceled(false),
_runResources(runResources),
_as3(false)
{
@@ -170,14 +170,14 @@
SWFMovieDefinition::~SWFMovieDefinition()
{
- // Request cancelation of the loading thread
- _loadingCanceled = true;
+ // Request cancelation of the loading thread
+ _loadingCanceled = true;
- // Release frame tags
- for (PlayListMap::iterator i = m_playlist.begin(),
+ // Release frame tags
+ for (PlayListMap::iterator i = m_playlist.begin(),
e = m_playlist.end(); i != e; ++i)
- {
- PlayList& pl = i->second;
+ {
+ PlayList& pl = i->second;
deleteChecked(pl.begin(), pl.end());
}
@@ -186,23 +186,23 @@
void
SWFMovieDefinition::addDisplayObject(int id, SWF::DefinitionTag* c)
{
- assert(c);
- boost::mutex::scoped_lock lock(_dictionaryMutex);
- _dictionary.addDisplayObject(id, c);
+ assert(c);
+ boost::mutex::scoped_lock lock(_dictionaryMutex);
+ _dictionary.addDisplayObject(id, c);
}
SWF::DefinitionTag*
SWFMovieDefinition::getDefinitionTag(int id) const
{
- boost::mutex::scoped_lock lock(_dictionaryMutex);
+ boost::mutex::scoped_lock lock(_dictionaryMutex);
- boost::intrusive_ptr<SWF::DefinitionTag> ch =
+ boost::intrusive_ptr<SWF::DefinitionTag> ch =
_dictionary.getDisplayObject(id);
#ifndef GNASH_USE_GC
- assert(ch == NULL || ch->get_ref_count() > 1);
+ assert(ch == NULL || ch->get_ref_count() > 1);
#endif
- return ch.get();
+ return ch.get();
}
void
@@ -270,10 +270,10 @@
assert(sam);
IF_VERBOSE_PARSE(
log_parse(_("Add sound sample %d assigning id %d"),
- id, sam->m_sound_handler_id);
+ id, sam->m_sound_handler_id);
)
m_sound_samples.insert(std::make_pair(id,
- boost::intrusive_ptr<sound_sample>(sam)));
+ boost::intrusive_ptr<sound_sample>(sam)));
}
// Read header and assign url
@@ -282,87 +282,87 @@
const std::string& url)
{
- _in = in;
-
- // we only read a movie once
- assert(!_str.get());
-
- _url = url.empty() ? "<anonymous>" : url;
-
- boost::uint32_t file_start_pos = _in->tell();
- boost::uint32_t header = _in->read_le32();
- m_file_length = _in->read_le32();
- _swf_end_pos = file_start_pos + m_file_length;
-
- m_version = (header >> 24) & 255;
- if ((header & 0x0FFFFFF) != 0x00535746
- && (header & 0x0FFFFFF) != 0x00535743)
+ _in = in;
+
+ // we only read a movie once
+ assert(!_str.get());
+
+ _url = url.empty() ? "<anonymous>" : url;
+
+ boost::uint32_t file_start_pos = _in->tell();
+ boost::uint32_t header = _in->read_le32();
+ m_file_length = _in->read_le32();
+ _swf_end_pos = file_start_pos + m_file_length;
+
+ m_version = (header >> 24) & 255;
+ if ((header & 0x0FFFFFF) != 0x00535746
+ && (header & 0x0FFFFFF) != 0x00535743)
{
- // ERROR
- log_error(_("gnash::SWFMovieDefinition::read() -- "
- "file does not start with a SWF header"));
- return false;
+ // ERROR
+ log_error(_("gnash::SWFMovieDefinition::read() -- "
+ "file does not start with a SWF header"));
+ return false;
}
- const bool compressed = (header & 255) == 'C';
+ const bool compressed = (header & 255) == 'C';
- IF_VERBOSE_PARSE(
- log_parse(_("version: %d, file_length: %d"), m_version,
m_file_length);
+ IF_VERBOSE_PARSE(
+ log_parse(_("version: %d, file_length: %d"), m_version, m_file_length);
)
- if (m_version > 7)
- {
- log_unimpl(_("SWF%d is not fully supported, trying anyway "
- "but don't expect it to work"), m_version);
- }
+ if (m_version > 7)
+ {
+ log_unimpl(_("SWF%d is not fully supported, trying anyway "
+ "but don't expect it to work"), m_version);
+ }
- if (compressed) {
+ if (compressed) {
#ifndef HAVE_ZLIB_H
- log_error(_("SWFMovieDefinition::read(): unable to read "
- "zipped SWF data; gnash was compiled without zlib
support"));
- return false;
+ log_error(_("SWFMovieDefinition::read(): unable to read "
+ "zipped SWF data; gnash was compiled without zlib support"));
+ return false;
#else
- IF_VERBOSE_PARSE(
- log_parse(_("file is compressed"));
- );
+ IF_VERBOSE_PARSE(
+ log_parse(_("file is compressed"));
+ );
- // Uncompress the input as we read it.
- _in = zlib_adapter::make_inflater(_in);
+ // Uncompress the input as we read it.
+ _in = zlib_adapter::make_inflater(_in);
#endif
}
- assert(_in.get());
-
- _str.reset(new SWFStream(_in.get()));
-
- m_frame_size.read(*_str);
- // If the SWFRect is malformed, SWFRect::read would already
- // print an error. We check again here just to give
- // the error are better context.
- if ( m_frame_size.is_null() )
- {
- IF_VERBOSE_MALFORMED_SWF(
- log_swferror("non-finite movie bounds");
- );
- }
-
- _str->ensureBytes(2 + 2); // frame rate, frame count.
- m_frame_rate = _str->read_u16() / 256.0f;
+ assert(_in.get());
+
+ _str.reset(new SWFStream(_in.get()));
+
+ m_frame_size.read(*_str);
+ // If the SWFRect is malformed, SWFRect::read would already
+ // print an error. We check again here just to give
+ // the error are better context.
+ if ( m_frame_size.is_null() )
+ {
+ IF_VERBOSE_MALFORMED_SWF(
+ log_swferror("non-finite movie bounds");
+ );
+ }
+
+ _str->ensureBytes(2 + 2); // frame rate, frame count.
+ m_frame_rate = _str->read_u16() / 256.0f;
if (!m_frame_rate) {
m_frame_rate = std::numeric_limits<boost::uint16_t>::max();
}
- m_frame_count = _str->read_u16();
-
- // TODO: This seems dangerous, check closely
- if (!m_frame_count) ++m_frame_count;
-
- IF_VERBOSE_PARSE(
- log_parse(_("frame size = %s, frame rate = %f, frames = %d"),
- m_frame_size, m_frame_rate, m_frame_count);
- );
-
- setBytesLoaded(_str->tell());
- return true;
+ m_frame_count = _str->read_u16();
+
+ // TODO: This seems dangerous, check closely
+ if (!m_frame_count) ++m_frame_count;
+
+ IF_VERBOSE_PARSE(
+ log_parse(_("frame size = %s, frame rate = %f, frames = %d"),
+ m_frame_size, m_frame_rate, m_frame_count);
+ );
+
+ setBytesLoaded(_str->tell());
+ return true;
}
// Fire up the loading thread
@@ -370,35 +370,35 @@
SWFMovieDefinition::completeLoad()
{
- // should call this only once
- assert( ! _loader.started() );
+ // should call this only once
+ assert( ! _loader.started() );
- // should call readHeader before this
- assert(_str.get());
+ // should call readHeader before this
+ assert(_str.get());
#ifdef LOAD_MOVIES_IN_A_SEPARATE_THREAD
- // Start the loading frame
- if ( ! _loader.start() )
- {
- log_error(_("Could not start loading thread"));
- return false;
- }
+ // Start the loading frame
+ if ( ! _loader.start() )
+ {
+ log_error(_("Could not start loading thread"));
+ return false;
+ }
- // Wait until 'startup_frames' have been loaded
+ // Wait until 'startup_frames' have been loaded
#if 1
- size_t startup_frames = 0;
+ size_t startup_frames = 0;
#else
- size_t startup_frames = m_frame_count;
+ size_t startup_frames = m_frame_count;
#endif
- ensure_frame_loaded(startup_frames);
+ ensure_frame_loaded(startup_frames);
#else // undef LOAD_MOVIES_IN_A_SEPARATE_THREAD
- read_all_swf();
+ read_all_swf();
#endif
- return true;
+ return true;
}
@@ -406,27 +406,27 @@
bool
SWFMovieDefinition::ensure_frame_loaded(size_t framenum) const
{
- boost::mutex::scoped_lock lock(_frames_loaded_mutex);
+ boost::mutex::scoped_lock lock(_frames_loaded_mutex);
#ifndef LOAD_MOVIES_IN_A_SEPARATE_THREAD
- return (framenum <= _frames_loaded);
+ return (framenum <= _frames_loaded);
#endif
- if ( framenum <= _frames_loaded ) return true;
-
- _waiting_for_frame = framenum;
-
- // TODO: return false on timeout
- _frame_reached_condition.wait(lock);
-
- return ( framenum <= _frames_loaded );
+ if ( framenum <= _frames_loaded ) return true;
+
+ _waiting_for_frame = framenum;
+
+ // TODO: return false on timeout
+ _frame_reached_condition.wait(lock);
+
+ return ( framenum <= _frames_loaded );
}
Movie*
SWFMovieDefinition::createMovie(Global_as& gl, DisplayObject* parent)
{
as_object* o = getObjectWithPrototype(gl, NSV::CLASS_MOVIE_CLIP);
- return new SWFMovie(o, this, parent);
+ return new SWFMovie(o, this, parent);
}
@@ -438,29 +438,29 @@
operator<<(std::ostream& o, const CharacterDictionary& cd)
{
- for (CharacterDictionary::CharacterConstIterator it = cd.begin(),
+ for (CharacterDictionary::CharacterConstIterator it = cd.begin(),
endIt = cd.end(); it != endIt; it++)
- {
- o << std::endl
- << "Character: " << it->first
- << " at address: " << static_cast<void*>(it->second.get());
- }
-
- return o;
+ {
+ o << std::endl
+ << "Character: " << it->first
+ << " at address: " << static_cast<void*>(it->second.get());
+ }
+
+ return o;
}
boost::intrusive_ptr<SWF::DefinitionTag>
CharacterDictionary::getDisplayObject(int id) const
{
CharacterConstIterator it = _map.find(id);
- if ( it == _map.end() )
- {
- IF_VERBOSE_PARSE(
+ if ( it == _map.end() )
+ {
+ IF_VERBOSE_PARSE(
log_parse(_("Could not find char %d, dump is: %s"), id, *this);
- );
- return boost::intrusive_ptr<SWF::DefinitionTag>();
- }
-
+ );
+ return boost::intrusive_ptr<SWF::DefinitionTag>();
+ }
+
return it->second;
}
@@ -468,21 +468,21 @@
CharacterDictionary::addDisplayObject(int id,
boost::intrusive_ptr<SWF::DefinitionTag> c)
{
- _map[id] = c;
+ _map[id] = c;
}
void
SWFMovieDefinition::read_all_swf()
{
- assert(_str.get());
+ assert(_str.get());
#ifdef LOAD_MOVIES_IN_A_SEPARATE_THREAD
- assert( _loader.isSelfThread() );
- assert( _loader.started() );
+ assert( _loader.isSelfThread() );
+ assert( _loader.started() );
#else
- assert( ! _loader.started() );
- assert( ! _loader.isSelfThread() );
+ assert( ! _loader.started() );
+ assert( ! _loader.isSelfThread() );
#endif
SWFParser parser(*_str, this, _runResources);
@@ -523,78 +523,89 @@
// parsing after an exception?
setBytesLoaded(std::min<size_t>(_str->tell(), _swf_end_pos));
- size_t floaded = get_loading_frame();
- if (!m_playlist[floaded].empty())
- {
- IF_VERBOSE_MALFORMED_SWF(
- log_swferror(_("%d control tags are NOT followed by"
- " a SHOWFRAME tag"), m_playlist[floaded].size());
- );
- }
+ size_t floaded = get_loading_frame();
+ if (!m_playlist[floaded].empty())
+ {
+ IF_VERBOSE_MALFORMED_SWF(
+ log_swferror(_("%d control tags are NOT followed by"
+ " a SHOWFRAME tag"), m_playlist[floaded].size());
+ );
+ }
- if ( m_frame_count > floaded )
- {
- IF_VERBOSE_MALFORMED_SWF(
- log_swferror(_("%d frames advertised in header, but only %d "
+ if ( m_frame_count > floaded )
+ {
+ IF_VERBOSE_MALFORMED_SWF(
+ log_swferror(_("%d frames advertised in header, but only %d "
"SHOWFRAME tags found in stream. Pretending we loaded "
"all advertised frames"), m_frame_count, floaded);
- );
- boost::mutex::scoped_lock lock(_frames_loaded_mutex);
- _frames_loaded = m_frame_count;
- // Notify any thread waiting on frame reached condition
- _frame_reached_condition.notify_all();
- }
+ );
+ boost::mutex::scoped_lock lock(_frames_loaded_mutex);
+ _frames_loaded = m_frame_count;
+ // Notify any thread waiting on frame reached condition
+ _frame_reached_condition.notify_all();
+ }
}
size_t
SWFMovieDefinition::get_loading_frame() const
{
- boost::mutex::scoped_lock lock(_frames_loaded_mutex);
- return _frames_loaded;
+ boost::mutex::scoped_lock lock(_frames_loaded_mutex);
+ return _frames_loaded;
}
void
SWFMovieDefinition::incrementLoadedFrames()
{
- boost::mutex::scoped_lock lock(_frames_loaded_mutex);
-
- ++_frames_loaded;
-
- if ( _frames_loaded > m_frame_count )
- {
- IF_VERBOSE_MALFORMED_SWF(
- log_swferror(_("number of SHOWFRAME tags "
- "in SWF stream '%s' (%d) exceeds "
- "the advertised number in header (%d)."),
- get_url(), _frames_loaded,
- m_frame_count);
- )
- }
+ boost::mutex::scoped_lock lock(_frames_loaded_mutex);
+
+ ++_frames_loaded;
+
+ if ( _frames_loaded > m_frame_count )
+ {
+ IF_VERBOSE_MALFORMED_SWF(
+ log_swferror(_("number of SHOWFRAME tags "
+ "in SWF stream '%s' (%d) exceeds "
+ "the advertised number in header (%d)."),
+ get_url(), _frames_loaded,
+ m_frame_count);
+ )
+ }
#ifdef DEBUG_FRAMES_LOAD
- log_debug(_("Loaded frame %u/%u"), _frames_loaded, m_frame_count);
+ log_debug(_("Loaded frame %u/%u"), _frames_loaded, m_frame_count);
#endif
- // signal load of frame if anyone requested it
- // FIXME: _waiting_for_frame needs mutex ?
- if (_waiting_for_frame && _frames_loaded >= _waiting_for_frame )
- {
- // or should we notify_one ?
- // See: http://boost.org/doc/html/condition.html
- _frame_reached_condition.notify_all();
- }
+ // signal load of frame if anyone requested it
+ // FIXME: _waiting_for_frame needs mutex ?
+ if (_waiting_for_frame && _frames_loaded >= _waiting_for_frame )
+ {
+ // or should we notify_one ?
+ // See: http://boost.org/doc/html/condition.html
+ _frame_reached_condition.notify_all();
+ }
}
void
-SWFMovieDefinition::export_resource(const std::string& symbol,
- ExportableResource* res)
+SWFMovieDefinition::exportResource(const std::string& symbol, int id)
{
- // _exportedResources access should be protected by a mutex
- boost::mutex::scoped_lock lock(_exportedResourcesMutex);
-
- // SWF sometimes exports the same thing more than once!
- _exportedResources[symbol] = res;
+ // _exportedResources access should be protected by a mutex
+ boost::mutex::scoped_lock lock(_exportedResourcesMutex);
+
+ ExportableResource* f;
+ if ((f = get_font(id)) || (f = getDefinitionTag(id)) ||
+ (f = get_sound_sample(id))) {
+
+ // SWFs sometimes export the same thing more than once!
+ _exportedResources[symbol] = f;
+ }
+ else {
+ IF_VERBOSE_MALFORMED_SWF(
+ log_swferror(_("don't know how to export resource '%s' "
+ "with id %d (can't find that id)"), symbol, id);
+ );
+ return;
+ }
}
@@ -602,57 +613,57 @@
SWFMovieDefinition::get_exported_resource(const std::string& symbol) const
{
#ifdef DEBUG_EXPORTS
- log_debug("get_exported_resource(%s) called, loading frame:%u",
+ log_debug("get_exported_resource(%s) called, loading frame:%u",
symbol, m_frame_count);
#endif
- // Don't call get_exported_resource() from this movie loader
- assert( ! _loader.isSelfThread() );
-
- // Keep trying until either we found the export or
- // the stream is over, or there is NO frames progress
- // after def_timeout microseconds.
- //
- // Note that the NO frame progress might be due
- // to a circular import chain:
- //
- // A imports B imports A
- //
-
- // Sleep 1/2 of a second between checks
- // NOTE: make sure the nap is enough time for
- // thread execution switch !!
- const unsigned long naptime=500000;
-
- // Timeout after two seconds of NO frames progress
- const unsigned long timeout_ms=2000000;
- const unsigned long def_timeout=timeout_ms/naptime;
-
- unsigned long timeout=def_timeout;
- size_t loading_frame = (size_t)-1; // used to keep track of advancements
-
- for(;;)
- {
+ // Don't call get_exported_resource() from this movie loader
+ assert( ! _loader.isSelfThread() );
+
+ // Keep trying until either we found the export or
+ // the stream is over, or there is NO frames progress
+ // after def_timeout microseconds.
+ //
+ // Note that the NO frame progress might be due
+ // to a circular import chain:
+ //
+ // A imports B imports A
+ //
+
+ // Sleep 1/2 of a second between checks
+ // NOTE: make sure the nap is enough time for
+ // thread execution switch !!
+ const unsigned long naptime=500000;
+
+ // Timeout after two seconds of NO frames progress
+ const unsigned long timeout_ms=2000000;
+ const unsigned long def_timeout=timeout_ms/naptime;
+
+ unsigned long timeout=def_timeout;
+ size_t loading_frame = (size_t)-1; // used to keep track of advancements
+
+ for(;;)
+ {
// we query the loaded frame count before looking
// up the exported resources map because while
// we query the loader keeps parsing more frames.
// and we don't want to giveup w/out having queried
// up to the last frame.
- size_t new_loading_frame = get_loading_frame();
+ size_t new_loading_frame = get_loading_frame();
- // _exportedResources access is thread-safe
- {
- boost::mutex::scoped_lock lock(_exportedResourcesMutex);
- ExportMap::const_iterator it =
_exportedResources.find(symbol);
- if ( it != _exportedResources.end() )
+ // _exportedResources access is thread-safe
+ {
+ boost::mutex::scoped_lock lock(_exportedResourcesMutex);
+ ExportMap::const_iterator it = _exportedResources.find(symbol);
+ if ( it != _exportedResources.end() )
{
#ifdef DEBUG_EXPORTS
- log_debug(" resource found, loading frame:%u",
new_loading_frame);
+ log_debug(" resource found, loading frame:%u",
new_loading_frame);
#endif
return it->second;
}
- }
+ }
// We checked last (or past-last) advertised frame.
// TODO: this check should really be for a parser
@@ -660,8 +671,7 @@
// might advertise less frames then actually
// found in it...
//
- if ( new_loading_frame >= m_frame_count )
- {
+ if (new_loading_frame >= m_frame_count) {
// Update of loading_frame is
// really just for the latter debugging output
loading_frame = new_loading_frame;
@@ -677,54 +687,52 @@
// We made frame progress since last iteration
// so sleep some and try again
- if ( new_loading_frame != loading_frame )
- {
+ if (new_loading_frame != loading_frame) {
#ifdef DEBUG_EXPORTS
- log_debug(_("looking for exported resource: frame load "
- "advancement (from %d to %d)"),
- loading_frame, new_loading_frame);
+ log_debug(_("looking for exported resource: frame load "
+ "advancement (from %d to %d)"),
+ loading_frame, new_loading_frame);
#endif
- loading_frame = new_loading_frame;
- timeout = def_timeout+1;
- }
- else if ( ! --timeout )
- {
+ loading_frame = new_loading_frame;
+ timeout = def_timeout+1;
+ }
+ else if (!--timeout) {
// no progress since last run, and
// timeout reached: give up
- break;
- }
-
- // take a breath to give other threads more time to advance
- gnashSleep(naptime);
-
- }
-
- if ( ! timeout ) // timed out
- {
- log_error("Timeout (%d milliseconds) seeking export symbol %s
in movie %s. "
- "Frames loaded %d/%d",
- timeout_ms/1000, symbol, _url, loading_frame,
m_frame_count);
- }
- else // eof
- {
- assert(loading_frame >= m_frame_count);
- log_error("No export symbol %s found in movie %s. "
- "Frames loaded %d/%d",
- symbol, _url, loading_frame, m_frame_count);
+ break;
+ }
+
+ // take a breath to give other threads more time to advance
+ gnashSleep(naptime);
+
+ }
+
+ // timed out
+ if (!timeout) {
+ log_error("Timeout (%d milliseconds) seeking export symbol %s in "
+ "movie %s. Frames loaded %d/%d", timeout_ms / 1000, symbol,
+ _url, loading_frame, m_frame_count);
+ }
+ else {
+ // eof
+ assert(loading_frame >= m_frame_count);
+ log_error("No export symbol %s found in movie %s. "
+ "Frames loaded %d/%d",
+ symbol, _url, loading_frame, m_frame_count);
//abort();
- }
+ }
- return boost::intrusive_ptr<ExportableResource>(0); // 0
+ return boost::intrusive_ptr<ExportableResource>(0); // 0
}
void
SWFMovieDefinition::add_frame_name(const std::string& n)
{
- boost::mutex::scoped_lock lock1(_namedFramesMutex);
- boost::mutex::scoped_lock lock2(_frames_loaded_mutex);
+ boost::mutex::scoped_lock lock1(_namedFramesMutex);
+ boost::mutex::scoped_lock lock2(_frames_loaded_mutex);
- _namedFrames.insert(std::make_pair(n, _frames_loaded));
+ _namedFrames.insert(std::make_pair(n, _frames_loaded));
}
bool
@@ -733,7 +741,7 @@
{
boost::mutex::scoped_lock lock(_namedFramesMutex);
NamedFrameMap::const_iterator it = _namedFrames.find(label);
- if ( it == _namedFrames.end() ) return false;
+ if (it == _namedFrames.end()) return false;
frame_number = it->second;
return true;
}
@@ -746,16 +754,17 @@
markMappedResources(_bitmaps);
markMappedResources(m_sound_samples);
- {
- boost::mutex::scoped_lock lock(_exportedResourcesMutex);
+ // Mutex scope.
+ {
+ boost::mutex::scoped_lock lock(_exportedResourcesMutex);
markMappedResources(_exportedResources);
- }
+ }
std::for_each(m_import_source_movies.begin(), m_import_source_movies.end(),
boost::mem_fn(&movie_definition::setReachable));
- boost::mutex::scoped_lock lock(_dictionaryMutex);
- _dictionary.markReachableResources();
+ boost::mutex::scoped_lock lock(_dictionaryMutex);
+ _dictionary.markReachableResources();
}
#endif // GNASH_USE_GC
@@ -764,52 +773,55 @@
SWFMovieDefinition::importResources(
boost::intrusive_ptr<movie_definition> source, Imports& imports)
{
- size_t importedSyms=0;
- for (Imports::iterator i=imports.begin(), e=imports.end(); i!=e; ++i)
- {
- int id = i->first;
- const std::string& symbolName = i->second;
-
- boost::intrusive_ptr<ExportableResource> res =
- source->get_exported_resource(symbolName);
-
- if (!res)
- {
- log_error(_("import error: could not find resource '%s'
in "
- "movie '%s'"), symbolName, source->get_url());
- continue;
- }
+ size_t importedSyms = 0;
+
+ // Mutex scope.
+ {
+ boost::mutex::scoped_lock lock(_exportedResourcesMutex);
+
+ for (Imports::iterator i = imports.begin(), e = imports.end(); i != e;
+ ++i) {
+
+ const int id = i->first;
+ const std::string& symbolName = i->second;
+
+ boost::intrusive_ptr<ExportableResource> res =
+ source->get_exported_resource(symbolName);
+
+ if (!res) {
+ log_error(_("import error: could not find resource '%s' in "
+ "movie '%s'"), symbolName, source->get_url());
+ continue;
+ }
#ifdef DEBUG_EXPORTS
- log_debug("Exporting symbol %s imported from source %s",
- symbolName, source->get_url());
-#endif
- export_resource(symbolName, res.get());
-
- if (Font* f = dynamic_cast<Font*>(res.get()))
- {
- // Add this shared font to the currently-loading movie.
- add_font(id, f);
- ++importedSyms;
- }
- else if (SWF::DefinitionTag* ch =
dynamic_cast<SWF::DefinitionTag*>(res.get()))
- {
- // Add this DisplayObject to the loading movie.
- addDisplayObject(id, ch);
- ++importedSyms;
- }
- else
- {
- log_error(_("importResources error: unsupported import of '%s' "
- "from movie '%s' has unknown type"),
+ log_debug("Exporting symbol %s imported from source %s",
symbolName, source->get_url());
+#endif
+ _exportedResources[symbolName] = res.get();
+
+ if (Font* f = dynamic_cast<Font*>(res.get())) {
+ // Add this shared font to the currently-loading movie.
+ add_font(id, f);
+ ++importedSyms;
+ }
+ else if (SWF::DefinitionTag* ch =
+ dynamic_cast<SWF::DefinitionTag*>(res.get())) {
+ // Add this DisplayObject to the loading movie.
+ addDisplayObject(id, ch);
+ ++importedSyms;
+ }
+ else {
+ log_error(_("importResources error: unsupported import of '%s'
"
+ "from movie '%s' has unknown type"),
+ symbolName, source->get_url());
+ }
}
- }
+ }
- if ( importedSyms )
- {
- _importSources.insert(source);
- }
+ if (importedSyms) {
+ _importSources.insert(source);
+ }
}
namespace {
=== modified file 'libcore/parser/SWFMovieDefinition.h'
--- a/libcore/parser/SWFMovieDefinition.h 2010-03-11 01:47:08 +0000
+++ b/libcore/parser/SWFMovieDefinition.h 2010-05-20 10:57:04 +0000
@@ -245,8 +245,7 @@
}
// See docs in movie_definition.h
- virtual void export_resource(const std::string& symbol,
- ExportableResource* res);
+ virtual void exportResource(const std::string& symbol, int id);
/// Get the named exported resource, if we expose it.
//
@@ -445,6 +444,7 @@
typedef std::map<std::string, boost::intrusive_ptr<ExportableResource>,
StringNoCaseLessThan > ExportMap;
+
ExportMap _exportedResources;
// Mutex protecting access to _exportedResources
=== modified file 'libcore/parser/movie_definition.h'
--- a/libcore/parser/movie_definition.h 2010-03-10 16:13:07 +0000
+++ b/libcore/parser/movie_definition.h 2010-05-20 10:38:42 +0000
@@ -405,8 +405,7 @@
///
/// The default implementation is a no-op
///
- virtual void export_resource(const std::string& /*symbol*/,
- ExportableResource* /*res*/)
+ virtual void exportResource(const std::string& /*symbol*/, int /*id*/)
{
}
=== modified file 'libcore/parser/sound_definition.h'
--- a/libcore/parser/sound_definition.h 2010-03-11 01:47:08 +0000
+++ b/libcore/parser/sound_definition.h 2010-05-20 10:57:04 +0000
@@ -43,18 +43,14 @@
/// of the identified sound_sample. This *might* be the reason why
/// it is a ref-counted thing (hard to belive...).
///
-///
-/// QUESTION: why is this a resource ?
-/// does it really need to be ref-counted ?
-///
/// @todo move definition to sound_handler.h and possibly nest
/// inside sound_handler itself ?
-/// @todo work out why this is a resource, what a resource is useful for,
-/// and if it really needs access to a sound_handler rather than
-/// belonging to it.
+//
+/// This is a resource because it can be exported.
class sound_sample: public ExportableResource
{
public:
+
int m_sound_handler_id;
sound_sample(int id, const RunResources& r)
=== modified file 'libcore/parser/sprite_definition.h'
--- a/libcore/parser/sprite_definition.h 2010-03-11 01:47:08 +0000
+++ b/libcore/parser/sprite_definition.h 2010-05-20 10:38:42 +0000
@@ -196,10 +196,9 @@
/// Delegate call to associated root movie
- virtual void export_resource(const std::string& sym,
- ExportableResource* res)
+ virtual void exportResource(const std::string& sym, int id)
{
- m_movie_def.export_resource(sym, res);
+ m_movie_def.exportResource(sym, id);
}
/// Delegate call to associated root movie
=== modified file 'libcore/swf/ControlTag.h'
--- a/libcore/swf/ControlTag.h 2010-05-07 09:20:30 +0000
+++ b/libcore/swf/ControlTag.h 2010-05-20 09:57:10 +0000
@@ -48,24 +48,22 @@
{
}
- /// Execute this tag, whatever it is.
- //
- /// The default does nothing.
- virtual void execute(MovieClip* /*m*/, DisplayList& /*dlist*/) const
- {
- }
-
- /// Execute this tag but only if it's a "state" tag.
- //
- /// State tags include all tags except action tags.
- virtual void execute_state(MovieClip* /*m*/, DisplayList& /*dlist*/)
const
- {
- }
-
- /// Return true if this is an action tag.
+ /// Execute Action tags
//
- /// The default returns false.
- virtual bool is_action_tag() const { return false; }
+ /// Not all tags that have ActionScript code are considered Action tags.
+ virtual void executeActions(MovieClip* /*m*/, DisplayList& /*dlist*/) const
+ {
+ }
+
+ /// Execute "state" or "DisplayList" tags
+ //
+ /// State tags exist to control the state of MovieClips along the
timeline.
+ /// They are executed even for skipped frames so that the state is
+ /// consistent at each frame. Some tags are considered state tags even
+ /// though they only contain ActionScript, e.g. the DoInitAction tag.
+ virtual void executeState(MovieClip* /*m*/, DisplayList& /*dlist*/)
const
+ {
+ }
};
=== modified file 'libcore/swf/DefineFontTag.h'
--- a/libcore/swf/DefineFontTag.h 2010-03-11 01:47:08 +0000
+++ b/libcore/swf/DefineFontTag.h 2010-05-20 10:57:04 +0000
@@ -123,7 +123,8 @@
const RunResources& r);
/// Read a DefineFont tag.
- void readDefineFont(SWFStream& in, movie_definition& m, const
RunResources& r);
+ void readDefineFont(SWFStream& in, movie_definition& m,
+ const RunResources& r);
/// Read a DefineFont2 or DefineFont3 tag.
void readDefineFont2Or3(SWFStream& in, movie_definition& m,
=== modified file 'libcore/swf/DefineSceneAndFrameLabelDataTag.h'
--- a/libcore/swf/DefineSceneAndFrameLabelDataTag.h 2010-03-11 01:47:08
+0000
+++ b/libcore/swf/DefineSceneAndFrameLabelDataTag.h 2010-05-20 09:57:10
+0000
@@ -40,7 +40,7 @@
public:
/// TODO: implement this.
- virtual void execute(MovieClip* /*m*/, DisplayList& /* dlist */) const
+ virtual void executeState(MovieClip* /*m*/, DisplayList& /* dlist */)
const
{
log_unimpl("DefineSceneAndFrameLabelDataTag");
}
=== modified file 'libcore/swf/DisplayListTag.h'
--- a/libcore/swf/DisplayListTag.h 2010-03-10 16:13:07 +0000
+++ b/libcore/swf/DisplayListTag.h 2010-05-20 09:57:10 +0000
@@ -43,28 +43,23 @@
DisplayListTag(int depth)
:
- m_depth(depth)
+ _depth(depth)
{}
virtual ~DisplayListTag() {}
- virtual void execute(MovieClip* m, DisplayList& dlist) const=0;
-
- void execute_state(MovieClip* m, DisplayList& dlist) const
- {
- execute(m, dlist);
- }
+ /// All DisplayList tags are state tags.
+ virtual void executeState(MovieClip* m, DisplayList& dlist) const = 0;
/// Return the depth affected by this DisplayList tag
//
/// NOTE: the returned depth is always in the
/// static depth zone (DisplayObject::staticDepthOffset .. -1)
- ///
- int getDepth() const { return m_depth; }
+ int getDepth() const { return _depth; }
protected:
- int m_depth;
+ int _depth;
};
=== modified file 'libcore/swf/DoABCTag.h'
--- a/libcore/swf/DoABCTag.h 2010-03-11 01:47:08 +0000
+++ b/libcore/swf/DoABCTag.h 2010-05-20 09:57:10 +0000
@@ -42,7 +42,7 @@
{
public:
- virtual void execute(MovieClip* m, DisplayList& /* dlist */) const
+ virtual void executeActions(MovieClip* m, DisplayList& /* dlist */) const
{
if (!_abc) {
@@ -63,12 +63,6 @@
mach->execute();
}
- // Tell the caller that we are an action tag.
- virtual bool is_action_tag() const
- {
- return true;
- }
-
void read(SWFStream* /*in*/)
{
}
=== modified file 'libcore/swf/DoActionTag.h'
--- a/libcore/swf/DoActionTag.h 2010-01-01 17:48:26 +0000
+++ b/libcore/swf/DoActionTag.h 2010-05-20 09:57:10 +0000
@@ -42,20 +42,12 @@
/// Read a DoAction block from the stream
//
- void read(SWFStream& in)
- {
- m_buf.read(in, in.get_tag_end_position());
- }
-
- virtual void execute(MovieClip* m, DisplayList& /* dlist */) const
- {
- m->add_action_buffer(&m_buf);
- }
-
- // Tell the caller that we are an action tag.
- virtual bool is_action_tag() const
- {
- return true;
+ void read(SWFStream& in) {
+ m_buf.read(in, in.get_tag_end_position());
+ }
+
+ virtual void executeActions(MovieClip* m, DisplayList& /* dlist */)
const {
+ m->add_action_buffer(&m_buf);
}
static void loader(SWFStream& in, TagType tag, movie_definition& m,
=== modified file 'libcore/swf/DoInitActionTag.h'
--- a/libcore/swf/DoInitActionTag.h 2010-05-10 08:22:56 +0000
+++ b/libcore/swf/DoInitActionTag.h 2010-05-20 12:17:21 +0000
@@ -48,20 +48,15 @@
read(in);
}
- virtual void execute_state(MovieClip* m, DisplayList& /*dlist*/) const
- {
- m->execute_init_action_buffer(_buf, _cid);
- }
-
- virtual void execute(MovieClip* m, DisplayList& /*dlist*/) const
- {
- m->execute_init_action_buffer(_buf, _cid);
- }
-
- // Tell the caller that we are an action tag.
- virtual bool is_action_tag() const
- {
- return true;
+ /// Execute 'state' tags.
+ //
+ /// State tags change the current state of a MovieClip. They are executed
+ /// even for skipped frames to ensure that the state is consistent.
+ //
+ /// Even though DoInitAction tags contain ActionScript, they are considered
+ /// to be state tags. They are executed only once.
+ virtual void executeState(MovieClip* m, DisplayList& /*dlist*/) const {
+ m->execute_init_action_buffer(_buf, _cid);
}
static void loader(SWFStream& in, TagType tag, movie_definition& m,
@@ -70,21 +65,31 @@
if (m.isAS3()) {
IF_VERBOSE_MALFORMED_SWF(
log_swferror("SWF contains DoInitAction tag, but is an "
- "AS3 SWF!");
+ "AS3 SWF!");
);
throw ParserException("DoInitAction tag found in AS3 SWF!");
}
in.ensureBytes(2);
const boost::uint16_t cid = in.read_u16();
-
- // Tags should only be executed for exported characters, though
- // it doesn't matter if the export is known during parsing.
+
+ if (!m.getDefinitionTag(cid)) {
+ IF_VERBOSE_MALFORMED_SWF(
+ log_swferror("SWF contains DoInitAction tag for an unknown"
+ "id. This will not be executed.");
+ );
+ return;
+ }
+
+ // Tags should only be executed for already parsed character ids.
+ //
+ // If this is true, there is no need to parse or store the tag. If
+ // it's not true, this check will have to be done at runtime.
DoInitActionTag* da = new DoInitActionTag(in, m, cid);
- IF_VERBOSE_PARSE (
- log_parse(_(" tag %d: do_init_action_loader"), tag);
- log_parse(_(" -- init actions for sprite %d"), cid);
+ IF_VERBOSE_PARSE(
+ log_parse(_(" tag %d: do_init_action_loader"), tag);
+ log_parse(_(" -- init actions for sprite %d"), cid);
);
m.addControlTag(da); // ownership transferred
=== modified file 'libcore/swf/PlaceObject2Tag.cpp'
--- a/libcore/swf/PlaceObject2Tag.cpp 2010-03-11 01:47:08 +0000
+++ b/libcore/swf/PlaceObject2Tag.cpp 2010-05-20 09:57:10 +0000
@@ -41,7 +41,7 @@
// Original place_object tag; very simple.
in.ensureBytes(2 + 2);
_id = in.read_u16();
- m_depth = in.read_u16() + DisplayObject::staticDepthOffset;
+ _depth = in.read_u16() + DisplayObject::staticDepthOffset;
// PlaceObject doesn't know about masks.
m_clip_depth = DisplayObject::noClipDepthValue;
@@ -64,7 +64,7 @@
IF_VERBOSE_PARSE
(
log_parse(_(" PLACEOBJECT: depth=%d(%d) char=%d"),
- m_depth, m_depth - DisplayObject::staticDepthOffset,
+ _depth, _depth - DisplayObject::staticDepthOffset,
_id);
if (hasMatrix()) log_parse(" SWFMatrix: %s", m_matrix);
if (hasCxform()) log_parse(_(" cxform: %s"), m_color_transform);
@@ -260,7 +260,7 @@
// PlaceObject2 specific flags
m_has_flags2 = in.read_u8();
- m_depth = in.read_u16()+DisplayObject::staticDepthOffset;
+ _depth = in.read_u16()+DisplayObject::staticDepthOffset;
if ( hasCharacter( ))
{
@@ -306,7 +306,7 @@
IF_VERBOSE_PARSE (
log_parse(_(" PLACEOBJECT2: depth = %d (%d)"),
- m_depth, m_depth-DisplayObject::staticDepthOffset);
+ _depth, _depth-DisplayObject::staticDepthOffset);
if ( hasCharacter() ) log_parse(_(" char id = %d"), _id);
if ( hasMatrix() )
{
@@ -341,7 +341,7 @@
boost::uint8_t bitmask = 0;
std::string className;
- m_depth = in.read_u16() + DisplayObject::staticDepthOffset;
+ _depth = in.read_u16() + DisplayObject::staticDepthOffset;
// This is documented to be here, but real instances of
// tags with either className or hasImage defined are rare to
@@ -418,8 +418,8 @@
IF_VERBOSE_PARSE (
- log_parse(_(" PLACEOBJECT3: depth = %d (%d)"), m_depth,
- m_depth - DisplayObject::staticDepthOffset);
+ log_parse(_(" PLACEOBJECT3: depth = %d (%d)"), _depth,
+ _depth - DisplayObject::staticDepthOffset);
if (hasCharacter()) log_parse(_(" char id = %d"), _id);
if (hasMatrix()) log_parse(_(" SWFMatrix: %s"), m_matrix);
if (hasCxform()) log_parse(_(" cxform: %d"), m_color_transform);
@@ -456,25 +456,25 @@
/// Place/move/whatever our object in the given movie.
void
-PlaceObject2Tag::execute(MovieClip* m, DisplayList& dlist) const
+PlaceObject2Tag::executeState(MovieClip* m, DisplayList& dlist) const
{
- switch ( getPlaceType() )
- {
+ switch (getPlaceType()) {
+
case PLACE:
m->add_display_object(this, dlist);
- break;
+ break;
case MOVE:
m->move_display_object(this, dlist);
- break;
+ break;
case REPLACE:
m->replace_display_object(this, dlist);
- break;
+ break;
case REMOVE:
m->remove_display_object(this, dlist);
- break;
+ break;
}
}
=== modified file 'libcore/swf/PlaceObject2Tag.h'
--- a/libcore/swf/PlaceObject2Tag.h 2010-03-11 01:47:08 +0000
+++ b/libcore/swf/PlaceObject2Tag.h 2010-05-20 09:57:10 +0000
@@ -107,7 +107,7 @@
void read(SWFStream& in, TagType tag);
/// Place/move/whatever our object in the given movie.
- void execute(MovieClip* m, DisplayList& dlist) const;
+ void executeState(MovieClip* m, DisplayList& dlist) const;
static void loader(SWFStream& in, TagType tag, movie_definition& m,
const RunResources& r);
@@ -115,6 +115,7 @@
int getPlaceType() const {
return m_has_flags2 & (HAS_CHARACTER_MASK | MOVE_MASK);
}
+
int getRatio() const { return m_ratio; }
int getClipDepth() const { return m_clip_depth; }
int getID() const { return _id; }
=== modified file 'libcore/swf/RemoveObjectTag.cpp'
--- a/libcore/swf/RemoveObjectTag.cpp 2010-03-11 01:47:08 +0000
+++ b/libcore/swf/RemoveObjectTag.cpp 2010-05-20 09:57:10 +0000
@@ -33,24 +33,25 @@
{
assert(tag == SWF::REMOVEOBJECT || tag == SWF::REMOVEOBJECT2);
- if (tag == SWF::REMOVEOBJECT)
- {
- // Older SWF's allow multiple objects at the same depth;
- // this m_id disambiguates. Later SWF's just use one
+ if (tag == SWF::REMOVEOBJECT) {
+ // Older SWFs allow multiple objects at the same depth;
+ // this m_id disambiguates. Later SWFs just use one
// object per depth.
+ //
+ // NB Gnash has never used this!
in.ensureBytes(2);
- m_id = in.read_u16();
+ _id = in.read_u16();
}
in.ensureBytes(2);
- m_depth = in.read_u16() + DisplayObject::staticDepthOffset;
+ _depth = in.read_u16() + DisplayObject::staticDepthOffset;
}
void
-RemoveObjectTag::execute(MovieClip* m, DisplayList& dlist) const
+RemoveObjectTag::executeState(MovieClip* m, DisplayList& dlist) const
{
m->set_invalidated();
- dlist.removeDisplayObject(m_depth);
+ dlist.removeDisplayObject(_depth);
}
/* public static */
@@ -65,9 +66,8 @@
int depth = t->getDepth();
- IF_VERBOSE_PARSE
- (
- log_parse(_(" remove_object_2(%d)"), depth);
+ IF_VERBOSE_PARSE(
+ log_parse(_(" remove_object_2(%d)"), depth);
);
// Ownership transferred to movie_definition
=== modified file 'libcore/swf/RemoveObjectTag.h'
--- a/libcore/swf/RemoveObjectTag.h 2010-01-25 18:52:20 +0000
+++ b/libcore/swf/RemoveObjectTag.h 2010-05-20 09:57:10 +0000
@@ -37,32 +37,29 @@
/// SWF Tag RemoveObject (5) or RemoveObject2 (28)
//
-/// The RemoveObject tag removes the DisplayObject instance at the specified
depth.
-///
-/// TODO: make this and PlaceObject2Tag subclasses of DisplayListTag (subclass
of ControlTag)
-///
+/// The RemoveObject tag removes the DisplayObject instance at the
+/// specified depth.
class RemoveObjectTag : public DisplayListTag
{
public:
RemoveObjectTag()
:
- DisplayListTag(-1),
- m_id(-1)
+ DisplayListTag(-1)
{}
/// Read SWF::REMOVEOBJECT or SWF::REMOVEOBJECT2
void read(SWFStream& in, TagType tag);
/// Remove object at specified depth from MovieClip DisplayList.
- void execute(MovieClip* m, DisplayList& dlist) const;
+ void executeState(MovieClip* m, DisplayList& dlist) const;
static void loader(SWFStream& in, TagType tag, movie_definition& m,
const RunResources& r);
private:
- int m_id;
+ int _id;
};
=== modified file 'libcore/swf/ScriptLimitsTag.h'
--- a/libcore/swf/ScriptLimitsTag.h 2010-03-11 01:47:08 +0000
+++ b/libcore/swf/ScriptLimitsTag.h 2010-05-20 09:57:10 +0000
@@ -38,8 +38,8 @@
virtual ~ScriptLimitsTag() {}
- virtual void execute(MovieClip* m, DisplayList& /*dl*/) const
- {
+ virtual void executeState(MovieClip* m, DisplayList& /*dl*/) const {
+
log_debug("Setting script limits: recursion %s, timeout %s",
_recursionLimit, _timeoutLimit);
getRoot(*getObject(m)).setScriptLimits(_recursionLimit, _timeoutLimit);
=== modified file 'libcore/swf/SetBackgroundColorTag.h'
--- a/libcore/swf/SetBackgroundColorTag.h 2010-03-11 01:47:08 +0000
+++ b/libcore/swf/SetBackgroundColorTag.h 2010-05-20 09:57:10 +0000
@@ -71,22 +71,15 @@
/// Tag header is assumed to have been read already
///
/// Can throw ParserException on premature end of input stream
- ///
SetBackgroundColorTag(SWFStream& in)
- {
+ {
read(in);
}
- void execute(MovieClip* m, DisplayList& /*dlist*/) const
- {
+ void executeState(MovieClip* m, DisplayList& /*dlist*/) const {
m->set_background_color(m_color);
}
- void execute_state(MovieClip* m, DisplayList& dlist) const
- {
- execute(m, dlist);
- }
-
/// Set background color tag loader (SWF::SETBACKGROUNDCOLOR)
static void loader(SWFStream& in, TagType tag, movie_definition& m,
const RunResources& /*r*/)
=== modified file 'libcore/swf/StartSoundTag.cpp'
--- a/libcore/swf/StartSoundTag.cpp 2010-01-01 17:48:26 +0000
+++ b/libcore/swf/StartSoundTag.cpp 2010-05-20 09:57:10 +0000
@@ -73,22 +73,18 @@
}
void
-StartSoundTag::execute(MovieClip* m, DisplayList& /* dlist */) const
+StartSoundTag::executeActions(MovieClip* m, DisplayList& /* dlist */) const
{
- sound::sound_handler* handler =
getRunResources(*getObject(m)).soundHandler();
+ sound::sound_handler* handler =
+ getRunResources(*getObject(m)).soundHandler();
- if (handler)
- {
- if (_soundInfo.stopPlayback)
- {
+ if (handler) {
+ if (_soundInfo.stopPlayback) {
//log_debug("Execute StartSoundTag with 'stop playback' flag on");
handler->stop_sound(m_handler_id);
}
- else
- {
-
- //log_debug("Execute StartSoundTag with 'stop playback' flag OFF");
+ else {
const sound::SoundEnvelopes* env =
_soundInfo.envelopes.empty() ? 0 : &_soundInfo.envelopes;
@@ -99,7 +95,7 @@
!_soundInfo.noMultiple, // allow multiple instances ?
_soundInfo.inPoint,
_soundInfo.outPoint
- );
+ );
}
}
}
=== modified file 'libcore/swf/StartSoundTag.h'
--- a/libcore/swf/StartSoundTag.h 2010-03-10 16:37:25 +0000
+++ b/libcore/swf/StartSoundTag.h 2010-05-20 09:57:10 +0000
@@ -73,7 +73,8 @@
public:
- void execute(MovieClip* /* m */, DisplayList& /* dlist */) const;
+ // This is not a state tag.
+ void executeActions(MovieClip* /* m */, DisplayList& /* dlist */) const;
/// Load a SWF::STARTSOUND tag.
static void loader(SWFStream& in, TagType tag, movie_definition& m,
=== modified file 'libcore/swf/StreamSoundBlockTag.cpp'
--- a/libcore/swf/StreamSoundBlockTag.cpp 2010-01-01 17:48:26 +0000
+++ b/libcore/swf/StreamSoundBlockTag.cpp 2010-05-20 09:57:10 +0000
@@ -31,7 +31,7 @@
namespace SWF {
void
-StreamSoundBlockTag::execute(MovieClip* m, DisplayList& /*dlist*/) const
+StreamSoundBlockTag::executeActions(MovieClip* m, DisplayList& /*dlist*/) const
{
sound::sound_handler* handler =
getRunResources(*getObject(m)).soundHandler();
=== modified file 'libcore/swf/StreamSoundBlockTag.h'
--- a/libcore/swf/StreamSoundBlockTag.h 2010-01-25 18:52:20 +0000
+++ b/libcore/swf/StreamSoundBlockTag.h 2010-05-20 09:57:10 +0000
@@ -68,15 +68,12 @@
boost::uint16_t getStreamId() const { return m_handler_id; }
/// Start the associated block of sound
- void execute(MovieClip* m, DisplayList& dlist) const;
+ void executeActions(MovieClip* m, DisplayList& dlist) const;
/// Load an SWF::SOUNDSTREAMBLOCK (19) tag.
static void loader(SWFStream& in, TagType tag, movie_definition& m,
const RunResources& r);
- /// Not a "state" (DisplayList?) tag, so doesn't need to provide
- /// execute_state
-
private:
/// Create a ControlTag playing the given sample when executed.
=== modified file 'libcore/swf/SymbolClassTag.h'
--- a/libcore/swf/SymbolClassTag.h 2010-03-11 01:47:08 +0000
+++ b/libcore/swf/SymbolClassTag.h 2010-05-20 09:57:10 +0000
@@ -42,7 +42,7 @@
{
public:
- virtual void execute(MovieClip* m, DisplayList& /* dlist */) const
+ virtual void executeActions(MovieClip* m, DisplayList& /* dlist */)
const
{
VM& vm = getVM(*getObject(m));
abc::Machine* mach = vm.getMachine();
@@ -50,12 +50,6 @@
mach->instantiateClass(_rootClass, vm.getGlobal());
}
- // Tell the caller that we are an action tag.
- virtual bool is_action_tag() const
- {
- return true;
- }
-
static void loader(SWFStream& in, TagType tag, movie_definition& m,
const RunResources& /*r*/)
{
=== modified file 'libcore/swf/tag_loaders.cpp'
--- a/libcore/swf/tag_loaders.cpp 2010-03-11 01:47:08 +0000
+++ b/libcore/swf/tag_loaders.cpp 2010-05-20 10:38:42 +0000
@@ -48,7 +48,6 @@
#include "MediaHandler.h"
#include "SimpleBuffer.h"
#include "sound_handler.h"
-#include "ExportableResource.h"
#include "MovieFactory.h"
#include "RunResources.h"
#include "Renderer.h"
@@ -799,14 +798,14 @@
//
+// Load an export tag (for exposing internal resources of m)
void export_loader(SWFStream& in, TagType tag, movie_definition& m,
const RunResources& /*r*/)
- // Load an export tag (for exposing internal resources of m)
{
assert(tag == SWF::EXPORTASSETS); // 56
in.ensureBytes(2);
- int count = in.read_u16();
+ const boost::uint16_t count = in.read_u16();
IF_VERBOSE_PARSE(
log_parse(_(" export: count = %d"), count);
@@ -825,10 +824,8 @@
}
);
-
// Read the exports.
- for (int i = 0; i < count; i++)
- {
+ for (size_t i = 0; i < count; ++i) {
in.ensureBytes(2);
boost::uint16_t id = in.read_u16();
std::string symbolName;
@@ -838,21 +835,8 @@
log_parse(_(" export: id = %d, name = %s"), id, symbolName);
);
- // Fonts, DisplayObjects and sounds can be exported.
- ExportableResource* f;
- if ((f = m.get_font(id)) ||
- (f = m.getDefinitionTag(id)) ||
- (f = m.get_sound_sample(id))) {
-
- m.export_resource(symbolName, f);
- }
- else {
- IF_VERBOSE_MALFORMED_SWF(
- log_swferror(_("don't know how to export resource '%s' "
- "with id %d (can't find that id)"),
- symbolName, id);
- );
- }
+ m.exportResource(symbolName, id);
+
}
}
=== modified file 'libcore/swf/tag_loaders.h'
--- a/libcore/swf/tag_loaders.h 2010-01-11 06:41:38 +0000
+++ b/libcore/swf/tag_loaders.h 2010-05-20 10:21:58 +0000
@@ -27,7 +27,7 @@
// Forward declarations
namespace gnash {
- class movie_definition;
+ class movie_definition;
class RunResources;
}
@@ -78,7 +78,8 @@
// end_tag doesn't actually need to exist.
// TODO: drop this loader ?
-void end_loader(SWFStream& in, TagType tag, movie_definition&, const
RunResources&)
+inline void end_loader(SWFStream& in, TagType tag, movie_definition&,
+ const RunResources&)
{
assert(tag == SWF::END); // 0
assert(in.tell() == in.get_tag_end_position());
=== modified file 'libcore/vm/ASHandlers.cpp'
--- a/libcore/vm/ASHandlers.cpp 2010-05-19 17:57:13 +0000
+++ b/libcore/vm/ASHandlers.cpp 2010-05-20 10:19:03 +0000
@@ -2209,24 +2209,20 @@
std::string target_path;
std::string frame_var;
- DisplayObject * target = NULL;
- if( env.parse_path(target_frame, target_path, frame_var) )
- {
+ DisplayObject* target = 0;
+ if (env.parse_path(target_frame, target_path, frame_var)) {
target = env.find_target(target_path);
}
- else
- {
+ else {
frame_var = target_frame;
target = env.get_target();
}
- MovieClip *target_sprite = target ? target->to_movie() : NULL;
- if(target_sprite)
- {
+ MovieClip* target_sprite = target ? target->to_movie() : 0;
+ if (target_sprite) {
target_sprite->call_frame_actions(frame_var);
}
- else
- {
+ else {
IF_VERBOSE_ASCODING_ERRORS (
log_aserror(_("Couldn't find target_sprite \"%s\" in ActionCallFrame!"
" target frame actions will not be called..."), target_path);
@@ -2266,26 +2262,23 @@
std::string target_path;
std::string frame_var;
- DisplayObject * target = NULL;
- if( env.parse_path(target_frame, target_path, frame_var) )
- {
+ DisplayObject* target = NULL;
+ if (env.parse_path(target_frame, target_path, frame_var)) {
target = env.find_target(target_path);
}
- if ( ! target ) // 4.11 would make parse_path above return true,
- // we should check if a sprite named '4' is supposed to
work
- // in that case
- {
+ // 4.11 would make parse_path above return true,
+ // we should check if a sprite named '4' is supposed to work
+ // in that case
+ if (!target) {
target = env.get_target();
frame_var = target_frame;
}
MovieClip *target_sprite = target ? target->to_movie() : NULL;
- if(target_sprite)
- {
+ if (target_sprite) {
size_t frame_number;
- if ( ! target_sprite->get_frame_number(frame_var, frame_number) )
- {
+ if (!target_sprite->get_frame_number(frame_var, frame_number)) {
IF_VERBOSE_ASCODING_ERRORS(
log_aserror(_("Frame spec found on stack "
"at ActionGotoExpression doesn't evaluate "
@@ -2297,8 +2290,7 @@
target_sprite->goto_frame(frame_number);
target_sprite->setPlayState(state);
}
- else
- {
+ else {
IF_VERBOSE_ASCODING_ERRORS (
log_aserror(_("Couldn't find target sprite \"%s\" in "
"ActionGotoExpression. Will not go to target frame..."),
=== modified file 'testsuite/misc-ming.all/InitActionTest2.c'
--- a/testsuite/misc-ming.all/InitActionTest2.c 2010-05-10 08:34:18 +0000
+++ b/testsuite/misc-ming.all/InitActionTest2.c 2010-05-20 12:31:34 +0000
@@ -12,7 +12,7 @@
main(int argc, char** argv)
{
SWFMovie mo;
- SWFMovieClip mc4, mc5, dejagnuclip;
+ SWFMovieClip mc4, mc5, mc6, dejagnuclip;
SWFDisplayItem it;
SWFInitAction ia;
@@ -51,34 +51,34 @@
SWFMovie_nextFrame(mo);
// Check in next frame:
- xcheck(mo, "_global.val4 == undefined");
+ check(mo, "_global.val4 == undefined");
// Frame 4
SWFMovie_nextFrame(mo);
// Action is before export tag.
- xcheck(mo, "_global.val4 == undefined");
+ check(mo, "_global.val4 == undefined");
SWFMovie_addExport(mo, (SWFBlock)mc4, "export4");
SWFMovie_writeExports(mo);
- xcheck(mo, "_global.val4 == undefined");
+ check(mo, "_global.val4 == undefined");
// Frame 4
SWFMovie_nextFrame(mo);
- xcheck(mo, "_global.val4 == undefined");
+ check(mo, "_global.val4 == undefined");
// Add it again
SWFMovie_add(mo, (SWFBlock)mc4);
- xcheck(mo, "_global.val4 == undefined");
+ check(mo, "_global.val4 == undefined");
// Frame 5
SWFMovie_nextFrame(mo);
- xcheck(mo, "_global.val4 == undefined");
+ check(mo, "_global.val4 == undefined");
// Add it again, export it again:
SWFMovie_add(mo, (SWFBlock)mc4);
SWFMovie_addExport(mo, (SWFBlock)mc4, "export4");
SWFMovie_writeExports(mo);
- xcheck(mo, "_global.val4 == undefined");
+ check(mo, "_global.val4 == undefined");
// Frame 6
SWFMovie_nextFrame(mo);
@@ -88,7 +88,7 @@
ia = newSWFInitAction_withId(
newSWFAction("_global.val4 = 'mc4a';"), 4);
SWFMovie_add(mo, (SWFBlock)ia);
- xcheck(mo, "_global.val4 == 'mc4a'");
+ check(mo, "_global.val4 == 'mc4a'");
// Frame 7
SWFMovie_nextFrame(mo);
@@ -98,8 +98,8 @@
SWFMovie_addExport(mo, (SWFBlock)mc5, "export5");
SWFMovie_writeExports(mo);
- // Action is before InitAction, but this does not matter. As long as it's
- // in the same frame it will work.
+ // Action is written before InitAction, but this does not matter. As
+ // long as it's in the same frame it will work.
check(mo, "_global.val5 == 'mc5'");
ia = newSWFInitAction_withId(
@@ -107,6 +107,32 @@
SWFMovie_add(mo, (SWFBlock)ia);
check(mo, "_global.val5 == 'mc5'");
+ // Frame 8
+ SWFMovie_nextFrame(mo);
+
+ // Add new MovieClip and export.
+ mc6 = newSWFMovieClip();
+ SWFMovie_addExport(mo, (SWFBlock)mc6, "export6");
+ SWFMovie_writeExports(mo);
+
+ // Skip next frame
+ add_actions(mo, "gotoAndStop(10);");
+
+ // Frame 9
+ SWFMovie_nextFrame(mo);
+
+ // This frame is skipped but contains init actions.
+ ia = newSWFInitAction_withId(
+ newSWFAction("trace('mc6'); _global.val6 = 'mc6';"), 6);
+ SWFMovie_add(mo, (SWFBlock)ia);
+ add_actions(mo, "fail('Actions in skipped frame executed!');");
+
+ // Frame 10
+ SWFMovie_nextFrame(mo);
+
+ // Check that the skipped InitActions are executed.
+ check(mo, "_global.val6 == 'mc6'");
+
add_actions(mo, "stop();");
puts("Saving " OUTPUT_FILENAME );
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r12192: Simplify tag execution.,
Benjamin Wolsey <=