gnash-commit
[Top][All Lists]
Advanced

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

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


From: Zou Lunkai
Subject: [Gnash-commit] gnash ChangeLog server/character.h server/dlist...
Date: Thu, 09 Aug 2007 12:18:08 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Zou Lunkai <zoulunkai>  07/08/09 12:18:07

Modified files:
        .              : ChangeLog 
        server         : character.h dlist.cpp sprite_instance.cpp 
                         sprite_instance.h 
        server/parser  : Timeline.h morph2_character_def.cpp 
                         movie_def_impl.h movie_definition.h 
                         sprite_definition.h 
        server/swf     : PlaceObject2Tag.cpp 
        testsuite/misc-ming.all: place_and_remove_object_insane_test.c 

Log message:
        Hopefully improved the old timeline design.
        
        * server/character.h: add a constant 'noRatioValue'.
        * server/dlist.cpp: In function move_display_object(), don't set ratio
          to zero when no ratio value provided by the displaylist tags; In 
function
          reset(), remove all none-referenceable characters.
        * server/parser/timeline.h: revert to 1.3, keep strk's design, use 
std::set
          instead of std::map.
        * server/parser/movie_def_impl.h, movie_definition.h, 
sprite_definition.h:
          update interface of getTimelineDepths().
        * server/parser/morph2_character_def.cpp: set ratio value to zero at 
rendering 
         time when no one is provided. 
        * server/sprite_instance.h: add a member variable is_jumping_back.
        * server/sprite_instance.cpp: reimplement add_display_object(); cleanup 
          goto_frame(); wipe out timeline design 1,2,3; deprecate 
resetDisplayList();
          ready to deprcate 'replace_if_depth_is_occupied '.
        * server/swf/placeObject2Tag.cpp: set ratio to character::NoRatioValue 
instead of
          zero when no ratio provided.
        * testsuite/misc-ming.all/place_and_remove_object_insane_test.c: 
xchecks to  
          checks. should fix bug 20504.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.3972&r2=1.3973
http://cvs.savannah.gnu.org/viewcvs/gnash/server/character.h?cvsroot=gnash&r1=1.86&r2=1.87
http://cvs.savannah.gnu.org/viewcvs/gnash/server/dlist.cpp?cvsroot=gnash&r1=1.74&r2=1.75
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&r1=1.306&r2=1.307
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.h?cvsroot=gnash&r1=1.128&r2=1.129
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/Timeline.h?cvsroot=gnash&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/morph2_character_def.cpp?cvsroot=gnash&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/movie_def_impl.h?cvsroot=gnash&r1=1.50&r2=1.51
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/movie_definition.h?cvsroot=gnash&r1=1.27&r2=1.28
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/sprite_definition.h?cvsroot=gnash&r1=1.26&r2=1.27
http://cvs.savannah.gnu.org/viewcvs/gnash/server/swf/PlaceObject2Tag.cpp?cvsroot=gnash&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/place_and_remove_object_insane_test.c?cvsroot=gnash&r1=1.11&r2=1.12

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.3972
retrieving revision 1.3973
diff -u -b -r1.3972 -r1.3973
--- ChangeLog   9 Aug 2007 06:38:15 -0000       1.3972
+++ ChangeLog   9 Aug 2007 12:18:04 -0000       1.3973
@@ -1,3 +1,24 @@
+2007-08-09 Zou Lunkai <address@hidden>
+       
+       * server/character.h: add a constant 'noRatioValue'.
+       * server/dlist.cpp: In function move_display_object(), don't set ratio
+         to zero when no ratio value provided by the displaylist tags; In 
function
+         reset(), remove all none-referenceable characters.
+       * server/parser/timeline.h: revert to 1.3, keep strk's design, use 
std::set
+         instead of std::map.
+       * server/parser/movie_def_impl.h, movie_definition.h, 
sprite_definition.h:
+         update interface of getTimelineDepths().
+       * server/parser/morph2_character_def.cpp: set ratio value to zero at 
rendering 
+         time when no one is provided. 
+       * server/sprite_instance.h: add a member variable is_jumping_back.
+       * server/sprite_instance.cpp: reimplement add_display_object(); cleanup 
+         goto_frame(); wipe out timeline design 1,2,3; deprecate 
resetDisplayList();
+         ready to deprcate 'replace_if_depth_is_occupied '.
+       * server/swf/placeObject2Tag.cpp: set ratio to character::NoRatioValue 
instead of
+         zero when no ratio provided.
+       * testsuite/misc-ming.all/place_and_remove_object_insane_test.c: 
xchecks to checks.
+         should fix bug 20504. All in all, hopefully improved the old timeline 
design.
+       
 2007-08-09 David Rorex  <address@hidden>
 
        * testsuite/misc-swfc.all: new directory for testcases.

Index: server/character.h
===================================================================
RCS file: /sources/gnash/gnash/server/character.h,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -b -r1.86 -r1.87
--- server/character.h  10 Jul 2007 21:43:00 -0000      1.86
+++ server/character.h  9 Aug 2007 12:18:05 -0000       1.87
@@ -19,7 +19,7 @@
 //
 //
 
-/* $Id: character.h,v 1.86 2007/07/10 21:43:00 strk Exp $ */
+/* $Id: character.h,v 1.87 2007/08/09 12:18:05 zoulunkai Exp $ */
 
 #ifndef GNASH_CHARACTER_H
 #define GNASH_CHARACTER_H
@@ -344,6 +344,9 @@
     /// value should not collide with real depths.  
     static const int noClipDepthValue = -1000000;
 
+       // Maybe it's better to move all these constants to DisplayListTag
+       static const int noRatioValue = -1;
+
     ~character();
 
     character(character* parent, int id)

Index: server/dlist.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/dlist.cpp,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -b -r1.74 -r1.75
--- server/dlist.cpp    24 Jul 2007 13:25:10 -0000      1.74
+++ server/dlist.cpp    9 Aug 2007 12:18:05 -0000       1.75
@@ -263,7 +263,10 @@
        ch->set_depth(depth);
        if ( color_xform ) ch->set_cxform(*color_xform);
        if ( mat ) ch->set_matrix(*mat);
+       if(ratio != character::noRatioValue)
+       {
        ch->set_ratio(ratio);
+       }
        ch->set_clip_depth(clip_depth);
        ch->restart();
 
@@ -367,7 +370,10 @@
        {
                ch->set_matrix(*mat);
        }
+       if(ratio != character::noRatioValue)
+       {
        ch->set_ratio(ratio);
+       }
 }
        
        
@@ -503,7 +509,7 @@
 
        // 1. Find all "timeline depth" for the target frame, querying the
        //    Timeline object in the sprite/movie definition (see 
implementation details)
-       std::map<int, int>  save;
+       std::vector<int>  save;
        movieDef.getTimelineDepths(tgtFrame, save);
 
 //#define GNASH_DEBUG_TIMELINE 1
@@ -517,7 +523,7 @@
 #endif
 
 
-       typedef std::map<int, int>::iterator SeekIter;
+       typedef std::vector<int>::iterator SeekIter;
 
        SeekIter startSeek = save.begin();
         SeekIter endSeek = save.end();
@@ -544,27 +550,18 @@
                        continue;
                }
 
-#if 0 // let's handle this at PlaceObject2 execution time... an instance 
placed by REPLACE tag
-      // in a subsequent frame will be replaced again rather then left 
untouched.
-      // This is to allow later fixing of REPLACE tag to avoid creation of a 
new instance
-      // (see replace_shapes1test.swf and replace_sprites1test.swf)
-
-               // Remove if placed by REPLACE tag in a later frame
-               if ( info->placedByReplaceTag() && info->placedInFrame() > 
tgtFrame )
+               // remove all shapes and morphs, it should be safe and correct.
+               // but suboptimal when considering the invalidated bound.
+               // we need to do this in some corner cases. 
+               if(!di->isActionScriptReferenceable())
                {
-                       // Not to be saved, killing
-                       // [ replace_sprites1test.swf and 
replace_shapes1test.swf seems to not want the replace ... ]
-                       if ( call_unload ) di->unload();
                        it = _characters.erase(it);
                        continue;
                }
-#endif
 
                /// Only remove if not in the save vector, 
-               /// or in the save vector but has a different ratio value
-               SeekIter match = save.find(di_depth);
-               if( match == save.end() || 
-                       ( match != save.end() && match->second != 
di->get_ratio() ))
+               SeekIter match = std::find(startSeek, endSeek, di_depth);
+               if( match == save.end())
                {
                        // Not to be saved, killing
                        if ( call_unload ) di->unload();

Index: server/sprite_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.cpp,v
retrieving revision 1.306
retrieving revision 1.307
diff -u -b -r1.306 -r1.307
--- server/sprite_instance.cpp  8 Aug 2007 20:08:58 -0000       1.306
+++ server/sprite_instance.cpp  9 Aug 2007 12:18:06 -0000       1.307
@@ -73,11 +73,6 @@
 //#define GNASH_DEBUG_TIMELINE 1
 //#define GNASH_DEBUG_REPLACE 1
 
-// Unfed for original design, 2 for second redesign attempt, 3 for third 
redesign attempt
-#define NEW_TIMELINE_DESIGN 3
-
-
-
 // Forward declarations
 static as_object* getMovieClipInterface();
 static void attachMovieClipInterface(as_object& o);
@@ -1723,6 +1718,7 @@
        m_play_state(PLAY),
        m_current_frame(0),
        m_has_looped(false),
+       is_jumping_back(false),
        m_init_actions_executed(),
        m_as_environment(),
        m_has_key_event(false),
@@ -2289,7 +2285,8 @@
                                // TODO: check why this would be any different
                                //       then calling restoreDisplayList(0) 
instead..
                                //       Ah! I think I know..
-                               resetDisplayList();
+                               //resetDisplayList();
+                               restoreDisplayList(0); // seems OK to me.
                        }
 
                        // TODO: Make sure m_current_frame is 0-based during 
execution of DLIST tags
@@ -2373,6 +2370,9 @@
                if (m_has_key_event)
                {
 #ifdef NEW_KEY_LISTENER_LIST_DESIGN
+                       // TODO: Don't do this at every advancement
+                       // OnClip key handlers should be registered at 
construction time, 
+                       // User defined handlers should be registered 
explicitly by Key.addListener();
                        _vm.getRoot().add_key_listener(KeyListener(this, 
KeyListener::ON_CLIP_DEF));
 #else
                        _vm.getRoot().add_key_listener(this);
@@ -2448,113 +2448,6 @@
        };
 }
 
-#if NEW_TIMELINE_DESIGN == 2 // 2nd redesign attempt
-
-/// A DisplayList visitor used to extract timeline instances that
-/// should be removed when rewinding playhead to a given frame
-///
-///
-/// See http://www.gnashdev.org/wiki/index.php/TimelineControl for
-/// more informations.
-///
-class TimelineInstanceFinder {
-
-       std::vector<character*> _toRemove;
-
-       // target frame, 0-based
-       size_t _frame;
-
-public:
-
-       /// @param tgtFrame
-       ///     The frame to which we're rewinding. 0-based.
-       ///
-       TimelineInstanceFinder(size_t tgtFrame)
-               :
-               _frame(tgtFrame)
-       {
-       }
-
-       /// Return a vector of characters to remove
-       std::vector<character*>& toRemove() { return _toRemove; }
-
-       bool operator() (character* ch) 
-       {
-               int depth = ch->get_depth();
-
-               // Timeline instances are always initially placed
-               // at negative depths and we don't want to remove those
-               // moved to different depths, so when depth 0 is
-               // reached our scan is complete.
-               if ( depth >= 0 )
-               {
-#ifdef GNASH_DEBUG_TIMELINE
-                       cout << this << "] Char at depth " << depth << " 
reached, end scan" << endl;
-#endif
-                       return false;
-               }
-
-               TimelineInfo* info = ch->getTimelineInfo();
-               if ( ! info )
-               {
-#ifdef GNASH_DEBUG_TIMELINE
-                       cout << this << "] Char at depth " << depth
-                               << " is not a timeline, will remove" << endl;
-#endif
-                       // non-timeline instances in static depth zone
-                       // needs to be removed
-                       _toRemove.push_back(ch);
-               }
-               else
-               {
-#ifdef GNASH_DEBUG_TIMELINE
-                       cout << this << "] Char at depth " << depth
-                               << " is a timeline instance, placed originally 
in frame "
-                               << info->placedInFrame() << " at depth "
-                               << info->placedAtDepth() << endl;
-#endif
-
-                       // timeline instances created after the target frame
-                       // are always removed (those in the 'dynamic depth zone'
-                       // won't get to this point)
-                       if ( info->placedInFrame() > _frame )
-                       {
-#ifdef GNASH_DEBUG_TIMELINE
-                               cout << this << "] will remove "
-                                       << "(placed after target frame "
-                                       << _frame << ")" << endl;
-#endif
-                               _toRemove.push_back(ch);
-                       }
-
-                       // timeline instances created before or at the target 
frame
-                       // are only removed if they are no more at the original 
depth
-                       else if ( info->placedAtDepth() != depth )
-                       {
-#ifdef GNASH_DEBUG_TIMELINE
-                               cout << this << "] will remove "
-                                       << "(originally at a different depth)"
-                                       << endl;
-#endif
-                               _toRemove.push_back(ch);
-                       }
-
-#ifdef GNASH_DEBUG_TIMELINE
-                       else
-                       {
-                               cout << this << "] will keep "
-                                       << "(none of the above applied)"
-                                       << endl;
-                       }
-#endif
-               }
-
-               return true;
-       }
-};
-
-#endif // NEW_TIMELINE_DESIGN == 2
-
 /*private*/
 void
 sprite_instance::restoreDisplayList(size_t tgtFrame)
@@ -2564,47 +2457,14 @@
        //       for jump-forwards would do
        assert(tgtFrame <= m_current_frame);
 
-#if NEW_TIMELINE_DESIGN == 2 // 2nd redesign attempt
-
-       // 1. Remove from current DisplayList:
-       //      - Timeline instances constructed after target frame are always 
removed.
-       //      - Timeline instances constructed before or at the target frame 
but no more at the original depth are removed.
-       //      - Dynamic instances found in the static depth zone 
-       
-       TimelineInstanceFinder finder(tgtFrame);
-#ifdef GNASH_DEBUG_TIMELINE
-       cout << "TimelineInstanceFinder " << &finder << " created for target 
frame " << tgtFrame << " from frame " << m_current_frame << endl;
-#endif
-       const_cast<DisplayList&>(m_display_list).visitForward(finder);
-       std::vector<character*>& toRemove = finder.toRemove();
-
-#ifdef GNASH_DEBUG_TIMELINE
-       cout << toRemove.size() << " chars found to remove." << endl;
-#endif
-       if ( ! toRemove.empty() )
-       {
-#ifdef GNASH_DEBUG_TIMELINE
-               cout << "Found to remove: " << endl;
-               std::ostream_iterator<as_value> ostrIter(cout, "," ) ;
-               std::copy(toRemove.begin(), toRemove.end(), ostrIter);
-               cout << "Current DisplayList: " << m_display_list << endl;
-#endif
-
-               set_invalidated(); 
-               m_display_list.clear(toRemove, true); // call onUnload
-
-#ifdef GNASH_DEBUG_TIMELINE
-               cout << "DisplayList after removal: " << m_display_list << endl;
-#endif
-       }
-
-#elif NEW_TIMELINE_DESIGN == 3 // 3rd redesign attempt
+       is_jumping_back = true; //remember we are jumping back
 
        // 1. Find all "timeline depth" for the target frame, querying the
        //    Timeline object in the sprite/movie definition (see 
implementation details)
        // 2. Remove step 
        // 2.1 Remove all current dynamic instances found in static depth zone 
        // 2.2 Remove all current timeline instances at a depth NOT in the set 
found in step 1 
+       //  2.3 Remove all non-script-referencable instances, suboptimal!
 
        // TODO: try to optize by avoid calling set_invalidated
        DisplayList newList = m_display_list;
@@ -2617,10 +2477,7 @@
                m_display_list = newList;
        }
 
-#endif // NEW_TIMELINE_DESIGN == 3
-
-
-       // 2. Execute all displaylist tags from first to target frame 
+       // 3. Execute all displaylist tags from first to target frame 
 
        for (size_t f = 0; f<=tgtFrame; ++f)
        {
@@ -2633,6 +2490,7 @@
                execute_frame_tags(f, TAG_DLIST);
        }
 
+       is_jumping_back = false; // finished jumping back
 }
 
 // 0-based frame number !
@@ -2740,7 +2598,8 @@
 
        // Unless the target frame is the next one, stop playback of soundstream
        int stream_id = get_sound_stream_id();
-       if (target_frame_number != m_current_frame+1 && stream_id != -1) {
+    if (target_frame_number != m_current_frame+1 && stream_id != -1) 
+       {
                sound_handler* sh = get_sound_handler();
                if (sh != NULL) sh->stop_sound(stream_id);
                set_sound_stream_id(-1);
@@ -2773,13 +2632,9 @@
        if (target_frame_number < m_current_frame)
        // Go backward to a previous frame
        {
-#ifdef NEW_TIMELINE_DESIGN // new design
                // restoreDisplayList takes care of properly setting the 
m_current_frame variable
                restoreDisplayList(target_frame_number);
                assert(m_current_frame == target_frame_number);
-#else // old design
-
-               set_invalidated(); 
 
   // <UdoG> current design is sub-optimal because it causes unnecessary 
   // redraw. Consider a static graphic that stays at it's position all
@@ -2790,41 +2645,12 @@
   // set_invalidated() call (which currently *is* correct) will cause
   // redraw of the whole sprite even if it doesn't change visually
   // at all.
-
-
-               resetDisplayList();
-               for (size_t f = 0; f<=target_frame_number; f++)
-               {
-                       execute_frame_tags(f, TAG_DLIST);
-               }
-#endif
        }
        else
        // Go forward to a later frame
        {
                // We'd immediately return if target_frame_number == 
m_current_frame
                assert(target_frame_number > m_current_frame);
-
-               // Construct the DisplayList of the target frame
-#ifdef NEW_TIMELINE_DESIGN
-               while (m_current_frame++ < target_frame_number)
-               {
-#ifdef GNASH_DEBUG_TIMELINE
-                       cout << "Executing tags in frame " << m_current_frame 
<< endl;
-#endif
-                       // Second argument requests that only "DisplayList" tags
-                       // are executed. This means NO actions will be
-                       // pushed on m_action_list.
-                       execute_frame_tags(m_current_frame, TAG_DLIST);
-               }
-               --m_current_frame; // as we might h
-               assert(m_current_frame == target_frame_number);
-#ifdef GNASH_DEBUG_TIMELINE
-               cout << "At end of loop, m_current_frame is " << 
m_current_frame << endl;
-#endif
-
-#else // ! defined (NEW_TIMELINE_DESIGN)
-
                for (size_t f = m_current_frame+1; f<=target_frame_number; ++f)
                {
                        // Second argument requests that only "DisplayList" tags
@@ -2832,8 +2658,7 @@
                        // pushed on m_action_list.
                        execute_frame_tags(f, TAG_DLIST);
                }
-#endif
-
+        m_current_frame = target_frame_number;
        }
 
 #if defined(GNASH_DEBUG_TIMELINE)
@@ -2854,14 +2679,7 @@
        // do this, so use execute_frame_tags instead).
        execute_frame_tags(target_frame_number, TAG_ACTION);
 
-#ifndef NEW_TIMELINE_DESIGN
-       //FIXME: set m_current_frame to the target frame;
-       //  I think it's too early to do it here! Later actions in the 
-       //  current frame should also be executed(Zou)
-       m_current_frame = target_frame_number;      
-#else
        assert(m_current_frame == target_frame_number);
-#endif
 
 
        // After entering to advance_sprite() m_current_frame points to frame
@@ -2967,7 +2785,7 @@
                const cxform& color_transform, const matrix& mat,
                int ratio, int clip_depth)
 {
-//         GNASH_REPORT_FUNCTION;
+//GNASH_REPORT_FUNCTION;
        assert(m_def != NULL);
 
        character_def*  cdef = m_def->get_character_def(character_id);
@@ -2982,117 +2800,46 @@
 
        character* existing_char = m_display_list.get_character_at_depth(depth);
 
-       if (existing_char)
-       {
-#ifdef GNASH_DEBUG_PLACE
-               log_debug("Another character exists in depth %d", depth);
-#endif
+    boost::intrusive_ptr<character> ch;
 
-               // If we already have this object on this
-               // plane, then move it instead of replacing it.
-               // NOTE: move_display_object() will take care of NOT moving the
-               //       character if get_accept_anim_moves() returns false.
-               //       ... I guess it's checked inside move_display_object ...
-               if ( existing_char->get_id() == character_id )
+    // Create a new instance and syntetize an instance name if scriptable when:
+    //  (1) target depth is empty 
+    //  (2) we are in jump-back-mode
+    if(!existing_char || is_jumping_back)
                {
-#ifdef GNASH_DEBUG_PLACE
-                       log_debug("Char has same id (%d), moving ", 
character_id);
-#endif
-
-                       // TODO: update name ?
-                       move_display_object(depth, &color_transform,
-                               &mat, ratio, clip_depth);
-                       return NULL;
-               }
-
-
-#if 1 // snipped based on deduction based on testcases:
-      // replace_sprites1test.swf, replace_shapes1test.swf and 
clip_as_button2.swf
-
-               TimelineInfo* info = existing_char->getTimelineInfo();
-               if ( info && info->placedByReplaceTag() && 
info->placedInFrame() > m_current_frame )
-               {
-#ifdef GNASH_DEBUG_PLACE
-                       log_debug("Char was placed by REPLACE tag in frame %d 
(now in frame %d)", info->placedInFrame(), m_current_frame);
-#endif
+        ch = cdef->create_character_instance(this, character_id);
+        ch->setTimelineInfo(depth, m_current_frame, false);
 
-                       if ( existing_char->to_movie() )
+        if(name)
                        {
-#ifdef GNASH_DEBUG_PLACE
-                               log_debug("Char is a sprite, moving");
-#endif
-                               // If it's a sprite we move it.
-                               // See replace_sprites1test.swf
-                               move_display_object(depth, &color_transform, 
&mat, ratio, clip_depth);
+            ch->set_name(name);
                        }
-                       else
+        else if(!name && ch->wantsInstanceName())
                        {
-#ifdef GNASH_DEBUG_PLACE
-                               log_debug("Char is NOT a sprite, replacing");
-#endif
-                               // If it's something else (a shape?) replace it
-                               replace_display_object(character_id, name, 
depth, &color_transform,
-                                               &mat, ratio, clip_depth);
-                       }
-                       return NULL;
+            std::string instance_name = getNextUnnamedInstanceName();
+            ch->set_name(instance_name.c_str());
                }
-#endif
-
-#if 0 // still not sure here...
-               // See loop_test5.swf (maybe should compare against *this* 
ratio instead...
-               if ( existing_char->get_ratio() > 0 )
-               {
-#ifdef GNASH_DEBUG_PLACE
-                       log_debug("Char has ratio==%g (> 0). Replacing it.", 
existing_char->get_ratio());
-#endif
-
-                       replace_display_object(character_id, name, depth, 
&color_transform, &mat,
-                                       ratio, clip_depth);
-                       return NULL;
                }
-#endif
 
-               // If we've been asked NOT to replace existing chars just
-               // return NULL now
-               if ( ! replace_if_depth_is_occupied )
+    bool is_ratio_compatible=true;
+    if(existing_char)
                {
-                       return NULL;
-               }
+     is_ratio_compatible= (ratio == existing_char->get_ratio())
+        || (ratio==character::noRatioValue && existing_char->get_ratio()==0)
+        || (ratio==0 && existing_char->get_ratio()==character::noRatioValue);
        }
-       //printf("%s: character %s, id is %d, count is %d\n", __FUNCTION__, 
existing_char->get_name(), character_id,m_display_list.get_character_count()); 
-
-       assert(cdef);
-       boost::intrusive_ptr<character> ch = 
cdef->create_character_instance(this, character_id);
-       assert(ch.get() != NULL);
 
-       // Make a timeline instance, passing it lifetime information
-       // We're assuming m_current_frame is 0-based, and correct at time of 
tags execution
-       // TODO: make sure this is true when executing tags from goto_frame !
-#ifdef GNASH_DEBUG_TIMELINE
-       cout << " Placing timeline char " << character_id << " at depth " << 
depth << " in frame " << m_current_frame << " of sprite " << getTarget() << 
endl;
-#endif
-       ch->setTimelineInfo(depth, m_current_frame, false);
-
-       if ( name )
-       {
-               ch->set_name(name);
-       }
-       else if ( ch->wantsInstanceName() )
+    // Place a new character if:
+    //  (1)target depth is empty 
+    //  (2)target depth is not empty but the character has a different ratio 
+    // in jump-back-mode.
+    if(!existing_char || (is_jumping_back && !is_ratio_compatible))
        {
-               // MovieClip instances *need* a name, to properly setup
-               // an as_value for them (values are kept by "target path"
-               // reference.  We syntetize an instance name in this case.
-               // TODO: check if we need to do this for other character types
-               std::string instance_name = getNextUnnamedInstanceName();
-               ch->set_name(instance_name.c_str());
-       }
-
        // Attach event handlers (if any).
        for (size_t i = 0, n = event_handlers.size(); i < n; i++)
        {
                swf_event* ev = event_handlers[i];
                ch->add_event_handler(ev->event(), ev->action());
-               //event_handlers[i]->attach_to(*ch);
        }
 
        m_display_list.place_character(
@@ -3103,10 +2850,20 @@
                ratio,
                clip_depth);
 
-#ifndef GNASH_USE_GC
-       assert(ch == NULL || ch->get_ref_count() > 1);
-#endif // ndef GNASH_USE_GC
        return ch.get();
+    }
+    
+    // move the existing charater if has same ratio in jump-back-mode
+    if(existing_char && is_jumping_back && is_ratio_compatible)
+    {
+        // remove the created character from the key listener list,
+        // it might be there(eg. button_character).
+        _vm.getRoot().remove_key_listener(ch.get());
+
+        move_display_object(depth, &color_transform, &mat, ratio, clip_depth);
+    }
+
+    return NULL;
 }
 
 void
@@ -3120,7 +2877,6 @@
                int clip_depth)
 {
        assert(m_def != NULL);
-       //log_msg(_("%s: character %s, id is %d, depth is %d"), __FUNCTION__, 
name, character_id, depth); // FIXME: debugging crap
 
        character_def*  cdef = m_def->get_character_def(character_id);
        if (cdef == NULL)
@@ -3131,57 +2887,28 @@
        }
        assert(cdef);
 
-#define MOVE_NONSHAPES_ON_REPLACE
-#ifdef MOVE_NONSHAPES_ON_REPLACE
        character* existing_char = m_display_list.get_character_at_depth(depth);
        if (existing_char)
        {
-#ifdef GNASH_DEBUG_REPLACE
-               log_debug("Another character exists in depth %d", depth);
-#endif
+        // if the existing character is not a shape, move it instead of replace
                if ( existing_char->isActionScriptReferenceable() )
                {
-#ifdef GNASH_DEBUG_PLACE
-                       log_debug("Char is a scriptable instance, moving rather 
then replace");
-#endif
-                       // If it's a sprite we move it.
-                       // See replace_sprites1test.swf and 
replace_buttons1test.swf
-                       // Note that for buttons, it seems we should also wipe 
out the members !
-                       // Maybe this is not the this we're supposed to do 
here, rather some weird
-                       // simptom from implementation of a proper displaylist 
reconstruction.
-                       // For example, the REPLACE tag might act like a PLACE 
tag when executed
-                       // alone, looking for missing info (character_id, name) 
in the previous 
-                       // PLACE tag affecting this same depth..
-                       //
                        move_display_object(depth, color_transform, mat, ratio, 
clip_depth);
                        return;
                }
-       }
        else
        {
-#ifdef GNASH_DEBUG_REPLACE
-               log_debug("REPLACE: no character exists in depth %d - should 
add ?", depth);
-#endif
-       }
-#endif // MOVE_NONSHAPES_ON_REPLACE
-
-       boost::intrusive_ptr<character> ch = 
cdef->create_character_instance(this,
-                       character_id);
+            boost::intrusive_ptr<character> ch = 
cdef->create_character_instance(this, character_id);
 
-       // Make a timeline instance, passing it lifetime information
-       // We're assuming m_current_frame is 0-based, and correct at time of 
tags execution
-       // TODO: make sure this is true when executing tags from goto_frame !
-#ifdef GNASH_DEBUG_TIMELINE
-       cout << " Replacing timeline char at depth " << depth << " in frame " 
<< m_current_frame << " of sprite " << getTarget() << " with char " << 
character_id << endl;
-#endif
        ch->setTimelineInfo(depth, m_current_frame, true);
 
        replace_display_object(
                ch.get(), name, depth,
                color_transform,
                mat,
-               ratio, clip_depth
-               );
+                ratio, clip_depth);
+        }
+    } // end of if(existing_char)
 }
 
 void sprite_instance::replace_display_object(
@@ -3540,7 +3267,13 @@
        }
 
        // TODO: should variable name be considered case-insensitive ?
+       TextfieldMap::iterator it = _text_variables->find(name);
+       // Don't replace the original textfiled character
+       // TODO: more tests for TextField variables.
+       if ( it == _text_variables->end() )
+       {
        _text_variables->operator[] (name) = ch;
+       }
 }
 
 /* private */

Index: server/sprite_instance.h
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.h,v
retrieving revision 1.128
retrieving revision 1.129
diff -u -b -r1.128 -r1.129
--- server/sprite_instance.h    8 Aug 2007 20:08:59 -0000       1.128
+++ server/sprite_instance.h    9 Aug 2007 12:18:06 -0000       1.129
@@ -476,17 +476,6 @@
        ///
        void    remove_display_object(int depth, int /* id */)
        {
-       character* existing_char = m_display_list.get_character_at_depth(depth);
-               if(existing_char && existing_char->getTimelineInfo())
-               {
-                       // Don't remove characters placed after target frame
-                       /// TODO: Don't remove character placed after the this 
RemoveObject tag
-                       if(m_current_frame <= 
existing_char->getTimelineInfo()->placedInFrame() )
-                       {
-                               return;
-                       }
-               }
-
            set_invalidated();
            m_display_list.remove_display_object(depth);
        }
@@ -892,6 +881,9 @@
        // true if this sprite reached the last frame and restarted
        bool            m_has_looped;
 
+       // true is the sprite is jumping back.
+       bool            is_jumping_back;
+
        // a bit-array class would be ideal for this
        std::vector<bool>       m_init_actions_executed;
 

Index: server/parser/Timeline.h
===================================================================
RCS file: /sources/gnash/gnash/server/parser/Timeline.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- server/parser/Timeline.h    1 Jul 2007 10:54:33 -0000       1.5
+++ server/parser/Timeline.h    9 Aug 2007 12:18:06 -0000       1.6
@@ -25,7 +25,7 @@
 #endif
 
 #include <vector>
-#include <map>
+#include <set>
 #include <boost/thread/mutex.hpp>
 
 namespace gnash
@@ -58,7 +58,7 @@
        /// Construct a Timeline instance 
        Timeline()
        {
-               _frameDepths.push_back(DepthMap());
+               _frameDepths.push_back(DepthSet());
        }
 
        /// Destroy a Timeline instance
@@ -94,7 +94,7 @@
        ///
        void closeFrame()
        {
-               boost::mutex::scoped_lock lock(_frameDepthsMutex);
+               //boost::mutex::scoped_lock lock(_frameDepthsMutex);
 
                // Copy depth set from previous frame
                _frameDepths.push_back(_frameDepths.back());
@@ -106,9 +106,6 @@
        ///     Depth of an instance placed by PlaceObject* tag.
        ///     Assumed to be in the static zone (an assertion would fail 
otherwise).
        ///
-       /// @param ratio
-       /// Ratio of an instance defined by PlaceObject* tag, default to zero.
-       ///
        /// Does NOT lock the mutex as this function is intended to be 
        /// called by a single thread (the loader/parser).
        ///
@@ -116,11 +113,11 @@
        ///     Depth of an instance placed by PlaceObject* tag.
        ///     Assumed to be in the static zone (an assertion would fail 
otherwise).
        ///
-       void addDepth(int depth, int ratio=0)
+       void addDepth(int depth)
        {
                assert(depth < 0 && depth >= -16384); // or should be > -16384 
(not ==?)
 
-               _frameDepths.back().insert(DRPair(depth, ratio));
+               _frameDepths.back().insert(depth);
        }
 
        /// Remove a timeline depth from the current frame 
@@ -166,24 +163,21 @@
        ///     
        ///     
        ///
-       void getFrameDepths(size_t frameno, std::map<int, int>& depths)
+       void getFrameDepths(size_t frameno, std::vector<int>& depths)
        {
                assert(frameno < _frameDepths.size());
 
-               DepthMap& from = _frameDepths[frameno];
-               depths.insert(from.begin(), from.end());
+               DepthSet& from = _frameDepths[frameno];
+               depths.assign(from.begin(), from.end());
        }
 
 private:
 
-       /// A pair of depth value and ratio ralue
-       typedef std::map<int, int>::value_type DRPair;
-
-       /// A set of depth-ratio-pairs in the static zone
-       typedef std::map<int, int> DepthMap;
+       /// A set of depths in the static zone
+       typedef std::set<int> DepthSet;
 
-       /// A vector of depth maps (one for each frame)
-       typedef std::vector<DepthMap> FrameDepths;
+       /// A vector of depth sets (one for each frame)
+       typedef std::vector<DepthSet> FrameDepths;
 
        /// Return the number of frames completely defined
        //
@@ -223,10 +217,10 @@
        for (Timeline::FrameDepths::const_iterator it=t._frameDepths.begin(), 
itEnd=t._frameDepths.end(); it!=itEnd; ++it)
        {
                os << "[";
-               for (Timeline::DepthMap::const_iterator di=it->begin(), 
de=it->end(); di!=de; ++di)
+               for (Timeline::DepthSet::const_iterator di=it->begin(), 
de=it->end(); di!=de; ++di)
                {
-                       if ( di != it->begin() ) os << ", ";
-                       os << "<" << di->first << ", " << di->second << ">";
+                       if ( di != it->begin() ) os << ",";
+                       os << *di;
                }
                os << "]";
                os << "\n";

Index: server/parser/morph2_character_def.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/parser/morph2_character_def.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- server/parser/morph2_character_def.cpp      7 Aug 2007 20:53:10 -0000       
1.12
+++ server/parser/morph2_character_def.cpp      9 Aug 2007 12:18:06 -0000       
1.13
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-/* $Id: morph2_character_def.cpp,v 1.12 2007/08/07 20:53:10 strk Exp $ */
+/* $Id: morph2_character_def.cpp,v 1.13 2007/08/09 12:18:06 zoulunkai Exp $ */
 
 // Based on the public domain morph2.cpp of:
 // Thatcher Ulrich <address@hidden>, Mike Shaver <address@hidden> 2003,
@@ -115,7 +115,7 @@
 //             GNASH_REPORT_FUNCTION;
 
                unsigned int i;
-               float ratio = inst->get_ratio() / 65535.0; 
+               float ratio = (inst->get_ratio()==character::noRatioValue) ? 0 
: inst->get_ratio()/65535.0;
 
                // bounds
                rect    new_bound;

Index: server/parser/movie_def_impl.h
===================================================================
RCS file: /sources/gnash/gnash/server/parser/movie_def_impl.h,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -b -r1.50 -r1.51
--- server/parser/movie_def_impl.h      1 Jul 2007 17:34:59 -0000       1.50
+++ server/parser/movie_def_impl.h      9 Aug 2007 12:18:07 -0000       1.51
@@ -619,9 +619,9 @@
        //
        // TODO: implement in base class ?
        //
-       void addTimelineDepth(int depth, int ratio)
+       void addTimelineDepth(int depth)
        {
-               _timeline.addDepth(depth, ratio);
+               _timeline.addDepth(depth);
        }
 
        // See dox in base class
@@ -637,7 +637,7 @@
        //
        // TODO: implement in base class ?
        //
-       void getTimelineDepths(size_t frameno, std::map<int, int>& depths)
+       void getTimelineDepths(size_t frameno, std::vector<int>& depths)
        {
                _timeline.getFrameDepths(frameno, depths);
        }

Index: server/parser/movie_definition.h
===================================================================
RCS file: /sources/gnash/gnash/server/parser/movie_definition.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- server/parser/movie_definition.h    1 Jul 2007 10:54:34 -0000       1.27
+++ server/parser/movie_definition.h    9 Aug 2007 12:18:07 -0000       1.28
@@ -57,7 +57,7 @@
 
 #include <string>
 #include <memory> // for auto_ptr
-#include <map>
+#include <set> 
 
 // Forward declarations
 namespace gnash {
@@ -578,9 +578,7 @@
        ///     Depth of an instance placed by PlaceObject* tag.
        ///     Assumed to be in the static zone (an assertion would fail 
otherwise).
        ///
-       /// @param ratio
-       /// Ratio of an instance defined by PlaceObject2 tag, ranges from 0 to 
65535
-       virtual void addTimelineDepth(int /*depth*/, int /*ratio*/) {}
+       virtual void addTimelineDepth(int /*depth*/) {}
 
        /// Remove a depth from the timeline depth set in current frame 
        //
@@ -612,7 +610,7 @@
        /// @param depths
        ///     A vector to copy all frame depths to.
        ///
-       virtual void getTimelineDepths(size_t /*frameno*/, std::map<int, int>& 
/*depths*/) 
+       virtual void getTimelineDepths(size_t /*frameno*/, std::vector<int>& 
/*depths*/) 
        {}
     
 };

Index: server/parser/sprite_definition.h
===================================================================
RCS file: /sources/gnash/gnash/server/parser/sprite_definition.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- server/parser/sprite_definition.h   5 Jul 2007 19:29:10 -0000       1.26
+++ server/parser/sprite_definition.h   9 Aug 2007 12:18:07 -0000       1.27
@@ -86,9 +86,9 @@
        //
        // TODO: implement in base class ?
        //
-       void addTimelineDepth(int depth, int ratio)
+       void addTimelineDepth(int depth)
        {
-               _timeline.addDepth(depth, ratio);
+               _timeline.addDepth(depth);
        }
 
        // See dox in base class
@@ -104,7 +104,7 @@
        //
        // TODO: implement in base class ?
        //
-       void getTimelineDepths(size_t frameno, std::map<int, int>& depths)
+       void getTimelineDepths(size_t frameno, std::vector<int>& depths)
        {
                _timeline.getFrameDepths(frameno, depths);
        }

Index: server/swf/PlaceObject2Tag.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/swf/PlaceObject2Tag.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- server/swf/PlaceObject2Tag.cpp      1 Jul 2007 10:54:35 -0000       1.16
+++ server/swf/PlaceObject2Tag.cpp      9 Aug 2007 12:18:07 -0000       1.17
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-/* $Id: PlaceObject2Tag.cpp,v 1.16 2007/07/01 10:54:35 bjacques Exp $ */
+/* $Id: PlaceObject2Tag.cpp,v 1.17 2007/08/09 12:18:07 zoulunkai Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -239,7 +239,10 @@
                m_color_transform.read_rgba(in);
        }
 
-       if (has_ratio) m_ratio = in->read_u16();
+       if (has_ratio) 
+               m_ratio = in->read_u16();
+       else
+               m_ratio = character::noRatioValue;
 
        if (has_name) m_name = in->read_string();
 
@@ -380,7 +383,7 @@
        int ratio = ch->getRatio();
     if ( depth < 0 && depth >= character::staticDepthOffset )
     {
-       m->addTimelineDepth(depth, ratio);
+       m->addTimelineDepth(depth);
     }
     else
     {

Index: testsuite/misc-ming.all/place_and_remove_object_insane_test.c
===================================================================
RCS file: 
/sources/gnash/gnash/testsuite/misc-ming.all/place_and_remove_object_insane_test.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- testsuite/misc-ming.all/place_and_remove_object_insane_test.c       1 Jul 
2007 10:54:59 -0000       1.11
+++ testsuite/misc-ming.all/place_and_remove_object_insane_test.c       9 Aug 
2007 12:18:07 -0000       1.12
@@ -111,9 +111,9 @@
                         check_equals(_root.mc_blue._x, 0); \
                     }else if(counter == 1)  \
                     { \
-                        xcheck_equals(_root.mc_blue._x, 60); \
-                        xcheck_equals(typeof(_root.mc_black), 'undefined'); \
-                        xcheck_equals(typeof(_root.mc_black_name_changed), 
'movieclip'); \
+                        check_equals(_root.mc_blue._x, 60); \
+                        check_equals(typeof(_root.mc_black), 'undefined'); \
+                        check_equals(typeof(_root.mc_black_name_changed), 
'movieclip'); \
                     } ");
   // This one is normal. mc_red._x should *not* be 20 when restart.
   // Note that mc_red has been removed at the 2nd frame, so when




reply via email to

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