gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/dlist.cpp server/dlist.h...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/dlist.cpp server/dlist.h...
Date: Tue, 02 Jan 2007 03:43:12 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/01/02 03:43:12

Modified files:
        .              : ChangeLog 
        server         : dlist.cpp dlist.h sprite_instance.cpp 
                         sprite_instance.h 
        testsuite/misc-ming.all: place_and_remove_object_test.c 

Log message:
                * server/dlist.{h,cpp}: added clear_except() function
                  to remove all but a specified set of character
                  instances from the list; deprecated clear_unaffected()
                  method.
                * server/sprite_instance.{h,cpp}: take note of which
                  character instances are created by execution of first
                  frame tags and exclude them from the DisplayList cleanup
                  performed at each restart. Simplifies the advance_sprite
                  pretty much.
                * testsuite/misc-ming.all/place_and_remove_object_test.c:
                  don't expect any failure.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2027&r2=1.2028
http://cvs.savannah.gnu.org/viewcvs/gnash/server/dlist.cpp?cvsroot=gnash&r1=1.41&r2=1.42
http://cvs.savannah.gnu.org/viewcvs/gnash/server/dlist.h?cvsroot=gnash&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&r1=1.117&r2=1.118
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.h?cvsroot=gnash&r1=1.52&r2=1.53
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/place_and_remove_object_test.c?cvsroot=gnash&r1=1.3&r2=1.4

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2027
retrieving revision 1.2028
diff -u -b -r1.2027 -r1.2028
--- ChangeLog   2 Jan 2007 01:50:56 -0000       1.2027
+++ ChangeLog   2 Jan 2007 03:43:12 -0000       1.2028
@@ -1,5 +1,19 @@
 2007-01-01 Sandro Santilli <address@hidden>
 
+       * server/dlist.{h,cpp}: added clear_except() function
+         to remove all but a specified set of character
+         instances from the list; deprecated clear_unaffected()
+         method.
+       * server/sprite_instance.{h,cpp}: take note of which
+         character instances are created by execution of first
+         frame tags and exclude them from the DisplayList cleanup 
+         performed at each restart. Simplifies the advance_sprite
+         pretty much.
+       * testsuite/misc-ming.all/place_and_remove_object_test.c:
+         don't expect any failure.
+
+2007-01-01 Sandro Santilli <address@hidden>
+
        * server/as_function.cpp (getPrototype):
          added check for 'prototype' member overwrite (debugging).
        * server/swf_function.{h,cpp}: provide variable 'super' in

Index: server/dlist.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/dlist.cpp,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -b -r1.41 -r1.42
--- server/dlist.cpp    9 Dec 2006 22:59:53 -0000       1.41
+++ server/dlist.cpp    2 Jan 2007 03:43:12 -0000       1.42
@@ -427,6 +427,35 @@
        }
 }
        
+void
+DisplayList::clear_except(std::vector<character*>& exclude)
+{
+       //GNASH_REPORT_FUNCTION;
+
+       for (iterator it = _characters.begin(), itEnd = _characters.end(); it 
!= itEnd; )
+       {
+               DisplayItem& di = *it;
+
+               bool is_affected = false;
+               for (size_t i=0, n=exclude.size(); i<n; ++i)
+               {
+                       if (exclude[i] == di.get())
+                       {
+                               is_affected = true;
+                               break;
+                       }
+               }
+
+               if (is_affected == false)
+               {
+                       di->on_event(event_id::UNLOAD);
+                       it = _characters.erase(it);
+                       continue;
+               }
+               it++;
+       }
+}
+       
 // reset the references to the display list.
 void
 DisplayList::reset()

Index: server/dlist.h
===================================================================
RCS file: /sources/gnash/gnash/server/dlist.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- server/dlist.h      1 Dec 2006 10:22:58 -0000       1.20
+++ server/dlist.h      2 Jan 2007 03:43:12 -0000       1.21
@@ -127,6 +127,17 @@
        /// on each item still present
        void clear();
 
+       /// \brief
+       /// Clear all characters in the display list except the ones
+       /// contained in the given vector.
+       //
+       /// @param exclude
+       ///     A vector containing character instances to keep.
+       ///     Any instance not found in the vector will be removed
+       ///     from the displaylist.
+       ///
+       void clear_except(std::vector<character*>& exclude);
+
        // It is executed only before the second and the subsequent
        // execution of execute_frame_tags(0) for sprite_instance
        // with frame count > 1.
@@ -134,6 +145,11 @@
        // of frames 2,... and not displayed in the 1-st frame.
        // Macromedia Flash does not call remove display object tag
        // for 1-st frame
+       //
+       // @deprecated
+       //
+       // TODO: remove this method
+       //
        void clear_unaffected(std::vector<uint16>& affected_depths);
 
        /// \brief

Index: server/sprite_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.cpp,v
retrieving revision 1.117
retrieving revision 1.118
diff -u -b -r1.117 -r1.118
--- server/sprite_instance.cpp  28 Dec 2006 01:44:09 -0000      1.117
+++ server/sprite_instance.cpp  2 Jan 2007 03:43:12 -0000       1.118
@@ -1093,6 +1093,11 @@
 //------------------------------------------------
 
 
+/// A DisplayList visitor used to compute its overall height.
+//
+/// TODO: this seems bogus actually, as it will just return
+///       the height of the tallest character in the list !!
+///
 class HeightFinder {
 public:
        float _h;
@@ -1110,6 +1115,11 @@
        }
 };
 
+/// A DisplayList visitor used to compute its overall width.
+//
+/// TODO: this seems bogus actually, as it will just return
+///       the width of the widest character in the list !!
+///
 class WidthFinder {
 public:
        float _w;
@@ -1127,6 +1137,31 @@
        }
 };
 
+/// A DisplayList visitor used to collect character pointers into a vector
+//
+class CharsAdder {
+
+       std::vector<character*>& _chars;
+
+public:
+
+       /// Initialize by passing the vector to be initialized
+       //
+       /// Consider using DisplayList::size() to reserve the
+       /// appropriate number of slots in the vector !
+       ///
+       CharsAdder(std::vector<character*>& chars)
+               :
+               _chars(chars)
+       {}
+
+       bool operator() (character* ch)
+       {
+               _chars.push_back(ch);
+               return true;
+       }
+};
+
 //------------------------------------------------
 // sprite_instance
 //------------------------------------------------
@@ -2082,42 +2117,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)
                {
-                       // Macromedia Flash does not call remove display object 
tag
-                       // for 1-st frame therefore we should do it for it :-)
-                       if (m_current_frame == 0 && frame_count > 1)
-                       {
-                               set_invalidated();
-
-                               // affected depths
-                               const PlayList& playlist = 
m_def->get_playlist(0);
-                               std::vector<uint16> affected_depths;
-                               for (unsigned int i = 0; i < playlist.size(); 
i++)
-                               {
-                                       uint16 depth = 
(playlist[i]->get_depth_id_of_replace_or_add_tag()) >> 16;
-                                       if (depth != 0)
-                                       {
-                                               
affected_depths.push_back(depth);
-                                       }
-                               }
-
-                               if (affected_depths.size() > 0)
-                               {
-                                       
m_display_list.clear_unaffected(affected_depths);                               
        
-                               }
-                               else
-                               {
-                                       m_display_list.clear();
-                               }
-                               
-                       }
-                       // TODO: fix this:
-                       // removing the 'else' here fixes elvis.swf,
-                       // keeping it in fixes testsuite/samples/loop_test.swf
-                       // AND bombgame.swf
-                       //else
-                       //{
                                execute_frame_tags(m_current_frame);
-                       //}
                }
        }
 #ifdef GNASH_DEBUG
@@ -2201,6 +2201,11 @@
 
        assert(frame < m_def->get_frame_count());
 
+       if ( frame == 0 && has_looped() )
+       {
+               m_display_list.clear_except(_init_chars);
+       }
+
        // Execute this frame's init actions, if necessary.
        if (m_init_actions_executed[frame] == false)
        {
@@ -2253,6 +2258,16 @@
                        std::bind2nd(std::mem_fun(&execute_tag::execute), 
this));
        }
 
+       if ( frame == 0 && ! has_looped() )
+       {
+               _init_chars.reserve(m_display_list.size());
+               CharsAdder adder(_init_chars);
+               // the const_cast is just to avoid defining a const version
+               // of DisplayList::visitForward, CharsAdder will NOT
+               // modify the DisplayList elements in any way
+               const_cast<DisplayList&>(m_display_list).visitForward(adder);
+       }
+
        testInvariant();
 }
 

Index: server/sprite_instance.h
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.h,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -b -r1.52 -r1.53
--- server/sprite_instance.h    28 Dec 2006 01:44:09 -0000      1.52
+++ server/sprite_instance.h    2 Jan 2007 03:43:12 -0000       1.53
@@ -17,7 +17,7 @@
 // 
 //
 
-/* $Id: sprite_instance.h,v 1.52 2006/12/28 01:44:09 strk Exp $ */
+/* $Id: sprite_instance.h,v 1.53 2007/01/02 03:43:12 strk Exp $ */
 
 // Stateful live Sprite instance
 
@@ -226,7 +226,24 @@
        virtual void    advance_sprite(float delta_time);
 
        /// Execute the tags associated with the specified frame.
-       /// frame is 0-based
+       //
+       /// Execution of 1st frame tags is specially handled:
+       ///
+       /// - After executing them for the first time
+       ///   the _init_chars vector is initialized.
+       ///
+       /// - Before subsequent executions (loop mode)
+       ///   the DisplayList is cleared of all but chars
+       ///   in the _init_chars vector.
+       ///
+       /// @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);
 
 
@@ -662,6 +679,14 @@
        ///
        static bool sameEvents(const Events& eventsMap, const SWFEventsVector& 
eventsVect);
 
+       /// \brief
+       /// Characters placed to the DisplayList by control tags in first frame.
+       //
+       /// These are the only ones that do not get automatically removed from
+       /// the DisplayList on restart. See execute_frame_tags.
+       ///
+       std::vector<character*> _init_chars;
+
 protected:
 
        /// \brief

Index: testsuite/misc-ming.all/place_and_remove_object_test.c
===================================================================
RCS file: 
/sources/gnash/gnash/testsuite/misc-ming.all/place_and_remove_object_test.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- testsuite/misc-ming.all/place_and_remove_object_test.c      31 Dec 2006 
00:29:39 -0000      1.3
+++ testsuite/misc-ming.all/place_and_remove_object_test.c      2 Jan 2007 
03:43:12 -0000       1.4
@@ -73,8 +73,8 @@
        it = SWFMovie_add(mo, (SWFBlock)sh1);  //add a red square to the 1st 
frame at depth 3
        SWFDisplayItem_setDepth(it, 3); 
        SWFDisplayItem_setName(it, "sh1");
-       xcheck(mo, "_root.sh1 != undefined");
-       xcheck_equals(mo, "_root.sh2",  "undefined");
+       check(mo, "_root.sh1 != undefined");
+       check_equals(mo, "_root.sh2",  "undefined");
        SWFMovie_nextFrame(mo);        
        
        SWFMovie_remove(mo, it);          //remove the red square at the 2nd 
frame




reply via email to

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