gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash/server execute_tag.h sprite_instance.cpp ...


From: Sandro Santilli
Subject: [Gnash-commit] gnash/server execute_tag.h sprite_instance.cpp ...
Date: Mon, 12 Feb 2007 14:00:05 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/02/12 14:00:05

Modified files:
        server         : execute_tag.h sprite_instance.cpp 
                         sprite_instance.h 

Log message:
                * server/execute_tag.h: doxygen documentation,
                  add new execute_action() function.
                * server/sprite_instance.{cpp,h}: changed signature
                  of execute_frame_tags() to allow executions of
                  action tags only.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/server/execute_tag.h?cvsroot=gnash&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&r1=1.155&r2=1.156
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.h?cvsroot=gnash&r1=1.63&r2=1.64

Patches:
Index: execute_tag.h
===================================================================
RCS file: /sources/gnash/gnash/server/execute_tag.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- execute_tag.h       22 Dec 2006 09:39:43 -0000      1.7
+++ execute_tag.h       12 Feb 2007 14:00:05 -0000      1.8
@@ -40,26 +40,45 @@
 class execute_tag
 {
 public:
+
        virtual ~execute_tag()
        {
        }
 
+       /// Execute this tag
        virtual void execute(sprite_instance* /*m*/)
        {
        }
 
+       /// Execute this tag but only if controls the DisplayList 
        virtual void execute_state(sprite_instance* /*m*/)
        {
        }
 
-       // Is the 'frame' arg is really needed ?
+       /// Execute this tag but only if it is an action tag
+       void execute_action(sprite_instance* m)
+       {
+               if ( is_action_tag() ) execute(m);
+       }
+
+       /// Execute the reverse version of this (state) tag.
+       //
+       /// Reverse execution is only meaningful for state tegs.
+       ///
+       /// @param m
+       ///
+       /// @param frame
+       ///
        virtual void execute_state_reverse(sprite_instance* m, int /*frame*/)
        {
+               // is the 'frame' arg is really needed ?
                execute_state(m);
        }
 
+       /// Return true if this is a RemoveObject tag
        virtual bool    is_remove_tag() const { return false; }
 
+       /// Return true if this is an action tag.
        virtual bool    is_action_tag() const { return false; }
 
        /// \brief

Index: sprite_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.cpp,v
retrieving revision 1.155
retrieving revision 1.156
diff -u -b -r1.155 -r1.156
--- sprite_instance.cpp 11 Feb 2007 22:19:14 -0000      1.155
+++ sprite_instance.cpp 12 Feb 2007 14:00:05 -0000      1.156
@@ -216,11 +216,6 @@
                return;
        }
 
-       // MOVE THIS CODE TO dlist.cpp, and have sprite_instance::construct
-       // call execute_frame_tags(0, false)
-       //sprite_instance* newsprite = 
dynamic_cast<sprite_instance*>(newch.get());
-       //if ( newsprite ) newsprite->construct();
-
        newch->setDynamic();
 
        /// Properties must be copied *after* the call to attachCharacter
@@ -2424,7 +2419,7 @@
                // First time execute_frame_tags(0) executed in 
dlist.cpp(child) or movie_def_impl(root)
                if (m_current_frame != (size_t)prev_frame)
                {
-                       execute_frame_tags(m_current_frame);
+                       execute_frame_tags(m_current_frame, 
TAG_DLIST|TAG_ACTION);
                }
        }
 #ifdef GNASH_DEBUG
@@ -2466,13 +2461,13 @@
                {
                        for (size_t f = m_executing_frame+1; f<m_current_frame; 
++f)
                        {
-                               execute_frame_tags(f, true);
+                               execute_frame_tags(f, TAG_DLIST);
                        } 
                }
                m_action_list.clear();
                
                // extract the target frame actions
-               execute_frame_tags(m_current_frame, false);
+               execute_frame_tags(m_current_frame, TAG_DLIST|TAG_ACTION);
                // store the target frame actions to m_goto_frame_action_list
                m_goto_frame_action_list = m_action_list; 
                m_action_list.clear(); 
@@ -2533,7 +2528,7 @@
 
 // 0-based frame number !
 void
-sprite_instance::execute_frame_tags(size_t frame, bool state_only)
+sprite_instance::execute_frame_tags(size_t frame, int typeflags)
 {
        testInvariant();
 
@@ -2601,21 +2596,17 @@
        IF_VERBOSE_ACTION(
                // Use 1-based frame numbers
                log_action("Executing " SIZET_FMT " tags in frame "
-                       SIZET_FMT "/" SIZET_FMT " of sprite %s %s",
+                       SIZET_FMT "/" SIZET_FMT " of sprite %s",
                        playlist.size(), frame+1, get_frame_count(),
-                       getTargetPath().c_str(),
-                       state_only ? "(state only)" : "" );
+                       getTargetPath().c_str());
        );
 
-       if (state_only)
-       {
-               std::for_each(playlist.begin(), playlist.end(),
-                       std::bind2nd(std::mem_fun(&execute_tag::execute_state), 
this));
-       }
-       else
+       for (PlayList::const_iterator it=playlist.begin(), itEnd=playlist.end();
+                       it != itEnd; ++it)
        {
-               std::for_each(playlist.begin(), playlist.end(),
-                       std::bind2nd(std::mem_fun(&execute_tag::execute), 
this));
+               execute_tag* tag = *it;
+               if ( typeflags & TAG_DLIST ) tag->execute_state(this);
+               if ( typeflags & TAG_ACTION ) tag->execute_action(this);
        }
 
        if ( frame == 0 && ! has_looped() )
@@ -2755,10 +2746,10 @@
                // Construct the DisplayList of the target frame
                for (size_t f = m_current_frame+1; f<target_frame_number; ++f)
                {
-                       // Second argument requests that only "state" tags
+                       // Second argument requests that only "DisplayList" tags
                        // are executed. This means NO actions will be
                        // pushed on m_action_list.
-                       execute_frame_tags(f, true);
+                       execute_frame_tags(f, TAG_DLIST);
                }
 
        }
@@ -2769,8 +2760,7 @@
 
        // Get the actions of target frame.(We don't have a direct way to
        // do this, so use execute_frame_tags instead).
-       execute_frame_tags(target_frame_number, false);
-
+       execute_frame_tags(target_frame_number, TAG_ACTION|TAG_DLIST);
 
        //FIXME: set m_current_frame to the target frame;
        //  I think it's too early to do it here! Later actions in the 
@@ -3441,7 +3431,7 @@
 sprite_instance::construct()
 {
        on_event(event_id::CONSTRUCT);
-       execute_frame_tags(0, false);   
+       execute_frame_tags(0, TAG_DLIST|TAG_ACTION);    
 
        sprite_definition* def = dynamic_cast<sprite_definition*>(m_def.get());
 

Index: sprite_instance.h
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.h,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -b -r1.63 -r1.64
--- sprite_instance.h   9 Feb 2007 00:19:07 -0000       1.63
+++ sprite_instance.h   12 Feb 2007 14:00:05 -0000      1.64
@@ -17,7 +17,7 @@
 // 
 //
 
-/* $Id: sprite_instance.h,v 1.63 2007/02/09 00:19:07 strk Exp $ */
+/* $Id: sprite_instance.h,v 1.64 2007/02/12 14:00:05 strk Exp $ */
 
 // Stateful live Sprite instance
 
@@ -102,6 +102,19 @@
                STOP
        };
 
+       /// Type of execute tags
+       //
+       /// TODO: move to execute_tag.h ?
+       ///
+       enum control_tag_type
+       {
+               /// Action tag
+               TAG_ACTION = 1<<0,
+
+               /// DisplayList tag
+               TAG_DLIST  = 1<<1
+       };
+
        virtual void has_keypress_event();
 
        /// \brief
@@ -217,26 +230,6 @@
        //virtual void  advance_root(float delta_time);
        virtual void    advance_sprite(float delta_time);
 
-       /// Execute the tags associated with the specified frame.
-       //
-       /// Execution of 1st frame tags is specially handled:
-       ///
-       /// - After executing them for the first time
-       ///   the DisplayList state is saved.
-       ///
-       /// - Before subsequent executions (loop mode)
-       ///   the DisplayList is restored from saved state.
-       ///
-       /// @param frame
-       ///     Frame number. 0-based
-       ///
-       /// @param state_only
-       ///     If false (the default), all tags are executed.
-       ///     If true, only 'state' tags are executed (place,move,replace).
-       ///     Note that 'action' tags are NOT 'state' tags.
-       ///
-       void execute_frame_tags(size_t frame, bool state_only = false);
-
 
        /// Execute the tags associated with the specified frame,
        /// IN REVERSE.
@@ -710,6 +703,25 @@
 
 protected:
 
+       /// Execute the tags associated with the specified frame.
+       //
+       /// Execution of 1st frame tags is specially handled:
+       ///
+       /// - After executing them for the first time
+       ///   the DisplayList state is saved.
+       ///
+       /// - Before subsequent executions (loop mode)
+       ///   the DisplayList is restored from saved state.
+       ///
+       /// @param frame
+       ///     Frame number. 0-based
+       ///
+       /// @param typeflags
+       ///     Which kind of control tags we want to execute. 
+       ///     See control_tag_type enum.
+       ///
+       void execute_frame_tags(size_t frame, int 
typeflags=TAG_DLIST|TAG_ACTION); // bool state_only = false;
+
        /// \brief
        /// This is either sprite_definition (for sprites defined by
        /// DefineSprite tag) or movie_def_impl (for the top-level movie).




reply via email to

[Prev in Thread] Current Thread [Next in Thread]