CVSROOT: /sources/gnash Module name: gnash Changes by: Sandro Santilli <strk> 07/11/09 19:58:03
Modified files: . : ChangeLog server : character.cpp character.h movie_root.cpp movie_root.h sprite_instance.cpp testsuite/misc-ming.all: action_execution_order_test5.c displaylist_depths_test2.c Log message: Apply patch #6263 * server/character.{cpp,h}: Add level argument to queueEvent method * server/movie_root.{cpp,h}: Add level argument to pushAction* * server/sprite_instance.cpp: Push actions with a level * testsuite/misc-ming.all/action_execution_order_test5.c: one XPASS * testsuite/misc-ming.all/displaylist_depths_test2.c: minor additional trace CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4817&r2=1.4818 http://cvs.savannah.gnu.org/viewcvs/gnash/server/character.cpp?cvsroot=gnash&r1=1.61&r2=1.62 http://cvs.savannah.gnu.org/viewcvs/gnash/server/character.h?cvsroot=gnash&r1=1.106&r2=1.107 http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_root.cpp?cvsroot=gnash&r1=1.119&r2=1.120 http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_root.h?cvsroot=gnash&r1=1.85&r2=1.86 http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&r1=1.376&r2=1.377 http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/action_execution_order_test5.c?cvsroot=gnash&r1=1.6&r2=1.7 http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/displaylist_depths_test2.c?cvsroot=gnash&r1=1.8&r2=1.9 Patches: Index: ChangeLog =================================================================== RCS file: /sources/gnash/gnash/ChangeLog,v retrieving revision 1.4817 retrieving revision 1.4818 diff -u -b -r1.4817 -r1.4818 --- ChangeLog 9 Nov 2007 10:34:22 -0000 1.4817 +++ ChangeLog 9 Nov 2007 19:58:02 -0000 1.4818 @@ -1,5 +1,14 @@ 2007-11-09 Sandro Santilli <[EMAIL PROTECTED]> + * server/character.{cpp,h}: Add level argument to queueEvent method + * server/movie_root.{cpp,h}: Add level argument to pushAction* + * server/sprite_instance.cpp: Push actions with a level + * testsuite/misc-ming.all/action_execution_order_test5.c: one XPASS + * testsuite/misc-ming.all/displaylist_depths_test2.c: minor additional + trace + +2007-11-09 Sandro Santilli <[EMAIL PROTECTED]> + * testsuite/misc-ming.all/registerClassTest2.c: Document the test * server/movie_root.cpp (dtor, clear): don't try to cleanup action queue Index: server/character.cpp =================================================================== RCS file: /sources/gnash/gnash/server/character.cpp,v retrieving revision 1.61 retrieving revision 1.62 diff -u -b -r1.61 -r1.62 --- server/character.cpp 6 Nov 2007 15:44:27 -0000 1.61 +++ server/character.cpp 9 Nov 2007 19:58:02 -0000 1.62 @@ -17,7 +17,7 @@ // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // -/* $Id: character.cpp,v 1.61 2007/11/06 15:44:27 udog Exp $ */ +/* $Id: character.cpp,v 1.62 2007/11/09 19:58:02 strk Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -645,7 +645,7 @@ //log_msg(_("Queuing unload event for character %p"), this); //on_event(event_id::UNLOAD); //bool hasEvent = queueEventHandler(event_id::UNLOAD); - queueEvent(event_id::UNLOAD); + queueEvent(event_id::UNLOAD, movie_root::apDOACTION); bool hasEvent = hasEventHandler(event_id::UNLOAD); _unloaded = true; @@ -654,12 +654,12 @@ } void -character::queueEvent(const event_id& id) +character::queueEvent(const event_id& id, int lvl) { movie_root& root = _vm.getRoot(); std::auto_ptr<ExecutableCode> event(new QueuedEvent(boost::intrusive_ptr<character>(this), id)); - root.pushAction(event); + root.pushAction(event, lvl); } bool Index: server/character.h =================================================================== RCS file: /sources/gnash/gnash/server/character.h,v retrieving revision 1.106 retrieving revision 1.107 diff -u -b -r1.106 -r1.107 --- server/character.h 1 Nov 2007 21:54:45 -0000 1.106 +++ server/character.h 9 Nov 2007 19:58:02 -0000 1.107 @@ -19,7 +19,7 @@ // // -/* $Id: character.h,v 1.106 2007/11/01 21:54:45 strk Exp $ */ +/* $Id: character.h,v 1.107 2007/11/09 19:58:02 strk Exp $ */ #ifndef GNASH_CHARACTER_H #define GNASH_CHARACTER_H @@ -966,7 +966,7 @@ /// on_event(id) will be called by execution of the queued /// action /// - void queueEvent(const event_id& id); + void queueEvent(const event_id& id, int lvl); /// Return true if an handler for the given event is defined // Index: server/movie_root.cpp =================================================================== RCS file: /sources/gnash/gnash/server/movie_root.cpp,v retrieving revision 1.119 retrieving revision 1.120 diff -u -b -r1.119 -r1.120 --- server/movie_root.cpp 9 Nov 2007 10:26:10 -0000 1.119 +++ server/movie_root.cpp 9 Nov 2007 19:58:03 -0000 1.120 @@ -45,6 +45,8 @@ #include <boost/algorithm/string/case_conv.hpp> #include <boost/bind.hpp> +//#define GNASH_DEBUG 1 + using namespace std; namespace gnash @@ -85,7 +87,8 @@ m_drag_state(), _allowRescale(true), _invalidated(true), - _disableScripts(false) + _disableScripts(false), + _processingActionLevel(movie_root::apSIZE) { } @@ -105,13 +108,17 @@ void movie_root::clearActionQueue() { - for (ActionQueue::iterator it=_actionQueue.begin(), - itE=_actionQueue.end(); + for (int lvl=0; lvl<apSIZE; ++lvl) + { + ActionQueue& q = _actionQueue[lvl]; + for (ActionQueue::iterator it=q.begin(), + itE=q.end(); it != itE; ++it) { delete *it; } - _actionQueue.clear(); + q.clear(); + } } movie_root::~movie_root() @@ -1175,65 +1182,140 @@ } } -void -movie_root::processActionQueue() +int +movie_root::minPopulatedPriorityQueue() const { + for (int l=0; l<apSIZE; ++l) + { + if ( ! _actionQueue[l].empty() ) return l; + } + return apSIZE; +} + +int +movie_root::processActionQueue(int lvl) +{ + ActionQueue& q = _actionQueue[lvl]; + + assert( minPopulatedPriorityQueue() == lvl ); #ifdef GNASH_DEBUG static unsigned calls=0; ++calls; - bool actionsToProcess = !_actionQueue.empty(); - if ( actionsToProcess ) log_msg(" Processing action queue (call %u)", calls); -#endif - - if ( _disableScripts ) + bool actionsToProcess = !q.empty(); + if ( actionsToProcess ) { - //log_debug(_("Scripts are disabled, global instance list has %d elements"), _liveChars.size()); - /// cleanup anything pushed later.. - clearActionQueue(); - return; + log_debug(" Processing %d actions in priority queue %d (call %u)", q.size(), lvl, calls); } +#endif // _actionQueue may be changed due to actions (appended-to) // this loop might be optimized by using an iterator // and a final call to .clear() - while ( ! _actionQueue.empty() ) + while ( ! q.empty() ) { - ExecutableCode* code = _actionQueue.front(); + ExecutableCode* code = q.front(); code->execute(); - _actionQueue.pop_front(); + q.pop_front(); delete code; + + int minLevel = minPopulatedPriorityQueue(); + if ( minLevel < lvl ) + { +#ifdef GNASH_DEBUG + log_debug(" Actions pushed in priority %d (< %d), restarting the scan (call %u)", minLevel, lvl, calls); +#endif + return minLevel; + } } - assert(_actionQueue.empty()); + assert(q.empty()); #ifdef GNASH_DEBUG - if ( actionsToProcess ) log_msg(" Done processing action queue (call %u)", calls); + if ( actionsToProcess ) + { + log_debug(" Done processing actions in priority queue %d (call %u)", lvl, calls); + } #endif + + return minPopulatedPriorityQueue(); + } void -movie_root::pushAction(std::auto_ptr<ExecutableCode> code) +movie_root::processActionQueue() { - _actionQueue.push_back(code.release()); + if ( _disableScripts ) + { + //log_debug(_("Scripts are disabled, global instance list has %d elements"), _liveChars.size()); + /// cleanup anything pushed later.. + clearActionQueue(); + return; + } + + _processingActionLevel=minPopulatedPriorityQueue(); + while ( _processingActionLevel<apSIZE ) + { + _processingActionLevel = processActionQueue(_processingActionLevel); + } + +} + +void +movie_root::pushAction(std::auto_ptr<ExecutableCode> code, int lvl) +{ + assert(lvl >= 0 && lvl < apSIZE); + + // Immediately execute code targetted at a lower level while processing + // an higher level. + if ( _processingActionLevel < apSIZE && lvl < _processingActionLevel ) + { + code->execute(); + return; + } + + _actionQueue[lvl].push_back(code.release()); } void -movie_root::pushAction(const action_buffer& buf, boost::intrusive_ptr<character> target) +movie_root::pushAction(const action_buffer& buf, boost::intrusive_ptr<character> target, int lvl) { + assert(lvl >= 0 && lvl < apSIZE); #ifdef GNASH_DEBUG log_msg("Pushed action buffer for target %s", target->getTargetPath().c_str()); #endif - _actionQueue.push_back(new GlobalCode(buf, target)); + + std::auto_ptr<ExecutableCode> code ( new GlobalCode(buf, target) ); + + // Immediately execute code targetted at a lower level while processing + // an higher level. + if ( _processingActionLevel < apSIZE && lvl < _processingActionLevel ) + { + code->execute(); + return; + } + + _actionQueue[lvl].push_back(code.release()); } void -movie_root::pushAction(boost::intrusive_ptr<as_function> func, boost::intrusive_ptr<character> target) +movie_root::pushAction(boost::intrusive_ptr<as_function> func, boost::intrusive_ptr<character> target, int lvl) { + assert(lvl >= 0 && lvl < apSIZE); #ifdef GNASH_DEBUG log_msg("Pushed function (event hanlder?) with target %s", target->getTargetPath().c_str()); #endif - _actionQueue.push_back(new FunctionCode(func, target)); + + std::auto_ptr<ExecutableCode> code ( new FunctionCode(func, target) ); + + // Immediately execute code targetted at a lower level while processing + // an higher level. + if ( _processingActionLevel < apSIZE && lvl < _processingActionLevel ) + { + code->execute(); + return; + } + _actionQueue[lvl].push_back(code.release()); } /* private */ @@ -1299,11 +1381,15 @@ } // Mark resources reachable by queued action code - for (ActionQueue::const_iterator i=_actionQueue.begin(), e=_actionQueue.end(); + for (int lvl=0; lvl<apSIZE; ++lvl) + { + const ActionQueue& q = _actionQueue[lvl]; + for (ActionQueue::const_iterator i=q.begin(), e=q.end(); i != e; ++i) { (*i)->markReachableResources(); } + } #ifdef NEW_KEY_LISTENER_LIST_DESIGN // Mark key listeners Index: server/movie_root.h =================================================================== RCS file: /sources/gnash/gnash/server/movie_root.h,v retrieving revision 1.85 retrieving revision 1.86 diff -u -b -r1.85 -r1.86 --- server/movie_root.h 1 Nov 2007 21:54:45 -0000 1.85 +++ server/movie_root.h 9 Nov 2007 19:58:03 -0000 1.86 @@ -15,7 +15,7 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -/* $Id: movie_root.h,v 1.85 2007/11/01 21:54:45 strk Exp $ */ +/* $Id: movie_root.h,v 1.86 2007/11/09 19:58:03 strk Exp $ */ /// \page events_handling Handling of user events /// @@ -536,14 +536,34 @@ bool testInvariant() const; + /// Action priority levels + enum ActionPriorityLevel { + + /// Init actions, Init event handlers + apINIT=0, + + /// Construct event handlers + apCONSTRUCT=1, + + /// EnterFrame event handlers + apENTERFRAME=2, + + /// Frame actions, load handlers, unload handlers + apDOACTION=3, + + /// Last element used to easy computation of size... + apSIZE + + }; + /// Push an executable code to the ActionQueue - void pushAction(std::auto_ptr<ExecutableCode> code); + void pushAction(std::auto_ptr<ExecutableCode> code, int lvl=apDOACTION); /// Push an executable code to the ActionQueue - void pushAction(const action_buffer& buf, boost::intrusive_ptr<character> target); + void pushAction(const action_buffer& buf, boost::intrusive_ptr<character> target, int lvl=apDOACTION); /// Push a function code to the ActionQueue - void pushAction(boost::intrusive_ptr<as_function> func, boost::intrusive_ptr<character> target); + void pushAction(boost::intrusive_ptr<as_function> func, boost::intrusive_ptr<character> target, int lvl=apDOACTION); #ifdef GNASH_USE_GC /// Mark all reachable resources (for GC) @@ -653,7 +673,7 @@ typedef std::list<ExecutableCode*> ActionQueue; - ActionQueue _actionQueue; + ActionQueue _actionQueue[apSIZE]; /// Process all actions in the queue void processActionQueue(); @@ -806,6 +826,19 @@ /// This is set to true if execution of scripts /// aborted due to action limit set or whatever else bool _disableScripts; + + /// Return the priority level of first action queue containing actions. + // + /// Scanned in proprity order (lower first) + /// + int minPopulatedPriorityQueue() const; + + /// Process all actions in the the given queue, till more actions + /// are found in lower levels, in which case we have an earlier + /// return. + int processActionQueue(int lvl); + + int _processingActionLevel; }; Index: server/sprite_instance.cpp =================================================================== RCS file: /sources/gnash/gnash/server/sprite_instance.cpp,v retrieving revision 1.376 retrieving revision 1.377 diff -u -b -r1.376 -r1.377 --- server/sprite_instance.cpp 2 Nov 2007 15:10:42 -0000 1.376 +++ server/sprite_instance.cpp 9 Nov 2007 19:58:03 -0000 1.377 @@ -2148,6 +2148,14 @@ return false; } +#if 0 + if ( id.m_id == event_id::INITIALIZE ) + { + // Construct as ActionScript object. + constructAsScriptObject(); + } +#endif + if ( id.is_button_event() && ! isEnabled() ) { #ifdef GNASH_DEBUG @@ -2339,7 +2347,9 @@ frame_count); #endif - queueEvent(event_id::ENTER_FRAME); + // I'm not sure ENTERFRAME goes in a different queue then DOACTION... + queueEvent(event_id::ENTER_FRAME, movie_root::apDOACTION); + //queueEvent(event_id::ENTER_FRAME, movie_root::apENTERFRAME); // Update current and next frames. if (m_play_state == PLAY) @@ -3363,7 +3373,19 @@ // We *might* avoid this, but better safe then sorry m_def->ensure_frame_loaded(0); + constructAsScriptObject(); + // TODO: should we execute these immediately if jumping + // due to a gotoFrame ? + if ( isDynamic() ) + { on_event(event_id::INITIALIZE); + on_event(event_id::CONSTRUCT); + } + else + { + queueEvent(event_id::INITIALIZE, movie_root::apINIT); + queueEvent(event_id::CONSTRUCT, movie_root::apCONSTRUCT); + } // Now execute frame tags and take care of queuing the LOAD event. // @@ -3384,7 +3406,7 @@ #ifdef GNASH_DEBUG log_debug(_("Queuing ONLOAD event for sprite %s"), getTarget().c_str()); #endif - queueEvent(event_id::LOAD); + queueEvent(event_id::LOAD, movie_root::apDOACTION); } else @@ -3393,7 +3415,7 @@ #ifdef GNASH_DEBUG log_debug(_("Queuing ONLOAD event for sprite %s"), getTarget().c_str()); #endif - queueEvent(event_id::LOAD); + queueEvent(event_id::LOAD, movie_root::apDOACTION); #ifdef GNASH_DEBUG log_debug(_("Executing tags of frame0 in sprite %s"), getTarget().c_str()); @@ -3401,9 +3423,6 @@ execute_frame_tags(0, TAG_DLIST|TAG_ACTION); } - - // Construct as ActionScript object. - constructAsScriptObject(); } /*private*/ @@ -3430,7 +3449,7 @@ } as_function* ctor = def->getRegisteredClass(); - //log_msg(_("Attached sprite's registered class is %p"), (void*)ctor); + log_msg(_("Attached sprite's registered for %s class is %p"), getTarget().c_str(), (void*)ctor); // TODO: builtin constructors are different from user-defined ones // we should likely change that. See also vm/ASHandlers.cpp (construct_object) @@ -3464,15 +3483,6 @@ } } while (0); - // Execute CONSTRUCT event - on_event(event_id::CONSTRUCT); - if (isUnloaded()) - { - log_debug("%s construct event handler unloaded self", getTarget().c_str()); - // TODO: check if we should still execute frame tags (dlist ones in particular) - return; - } - } bool Index: testsuite/misc-ming.all/action_execution_order_test5.c =================================================================== RCS file: /sources/gnash/gnash/testsuite/misc-ming.all/action_execution_order_test5.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -b -r1.6 -r1.7 --- testsuite/misc-ming.all/action_execution_order_test5.c 24 Sep 2007 11:03:12 -0000 1.6 +++ testsuite/misc-ming.all/action_execution_order_test5.c 9 Nov 2007 19:58:03 -0000 1.7 @@ -188,7 +188,7 @@ " _root.check_equals(this._parent.__proto__, MovieClip.prototype);" " _root.check_equals(this._parent.mc11.__proto__, MovieClip.prototype);" // test child __proto__ - " _root.xcheck_equals(this.mc121.__proto__, MovieClip.prototype);"), + " _root.check_equals(this.mc121.__proto__, MovieClip.prototype);"), SWFACTION_INIT); SWFDisplayItem_addAction(it12, // the inner most child Index: testsuite/misc-ming.all/displaylist_depths_test2.c =================================================================== RCS file: /sources/gnash/gnash/testsuite/misc-ming.all/displaylist_depths_test2.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -b -r1.8 -r1.9 --- testsuite/misc-ming.all/displaylist_depths_test2.c 24 Aug 2007 16:07:27 -0000 1.8 +++ testsuite/misc-ming.all/displaylist_depths_test2.c 9 Nov 2007 19:58:03 -0000 1.9 @@ -178,6 +178,8 @@ // this repopulates depth -16381 with a *new* instance "gotoAndStop(4);" + "note('right after gotoAndStop()');" + // static3 doesn't refer to the dynamic object anymore ! "check_equals(typeof(static3.myThing), 'undefined');" _______________________________________________ Gnash-commit mailing list Gnash-commit@gnu.org http://lists.gnu.org/mailman/listinfo/gnash-commit