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/sprit...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/character.h server/sprit...
Date: Wed, 23 May 2007 16:38:32 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/05/23 16:38:32

Modified files:
        .              : ChangeLog 
        server         : character.h sprite_instance.cpp 

Log message:
                * server/character.h: Extended TimelineInfo to store information
                  about wheter a character was placed by a REPLACE tag.
                * server/sprite_instance.cpp: implemented 3rd redesign attempt
                  for DisplayList reconstruction compile-time enableable by
                  setting NEW_TIMELINE_DESIGN to 3. Defined to 2 by defualt
                  which gives us 2nd redesign attempt. See wiki.
                  3rd redesign is promising and give us lots of unexpected
                  successes, but also some unexpected failures for the new
                  testcases for REPLACE tag.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.3318&r2=1.3319
http://cvs.savannah.gnu.org/viewcvs/gnash/server/character.h?cvsroot=gnash&r1=1.77&r2=1.78
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&r1=1.273&r2=1.274

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.3318
retrieving revision 1.3319
diff -u -b -r1.3318 -r1.3319
--- ChangeLog   23 May 2007 16:30:10 -0000      1.3318
+++ ChangeLog   23 May 2007 16:38:31 -0000      1.3319
@@ -1,5 +1,17 @@
 2007-05-23 Sandro Santilli <address@hidden>
 
+       * server/character.h: Extended TimelineInfo to store information
+         about wheter a character was placed by a REPLACE tag.
+       * server/sprite_instance.cpp: implemented 3rd redesign attempt
+         for DisplayList reconstruction compile-time enableable by
+         setting NEW_TIMELINE_DESIGN to 3. Defined to 2 by defualt
+         which gives us 2nd redesign attempt. See wiki.
+         3rd redesign is promising and give us lots of unexpected
+         successes, but also some unexpected failures for the new
+         testcases for REPLACE tag. 
+
+2007-05-23 Sandro Santilli <address@hidden>
+
        * server/dlist.{cpp,h}: Add new reset() method taking
          enough parameters (I hope) to remove what needs to
          on jump-back; drop obsoleted clear_unaffected function.

Index: server/character.h
===================================================================
RCS file: /sources/gnash/gnash/server/character.h,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -b -r1.77 -r1.78
--- server/character.h  22 May 2007 14:23:51 -0000      1.77
+++ server/character.h  23 May 2007 16:38:31 -0000      1.78
@@ -18,7 +18,7 @@
 //
 //
 
-/* $Id: character.h,v 1.77 2007/05/22 14:23:51 udog Exp $ */
+/* $Id: character.h,v 1.78 2007/05/23 16:38:31 strk Exp $ */
 
 #ifndef GNASH_CHARACTER_H
 #define GNASH_CHARACTER_H
@@ -74,10 +74,15 @@
        /// @param frame
        ///     Frame number in which the instance was placed (0-based)
        ///
-       TimelineInfo(int depth, int frame)
+       /// @param replace
+       ///     True if this object was placed by a REPLACE tag
+       ///     (see PlaceObject2).
+       ///
+       TimelineInfo(int depth, int frame, bool replace)
                :
                _depth(depth),
-               _frame(frame)
+               _frame(frame),
+               _replace(replace)
        {
        }
 
@@ -88,6 +93,10 @@
        /// Return frame number of initial placement (0-based)
        size_t placedInFrame() const { return _frame; }
 
+       /// Return true if this instance replaced an other one at same depth
+       bool placedByReplaceTag() const { return _replace; }
+
+
 private:
 
        /// Original depth
@@ -95,6 +104,9 @@
 
        /// Frame of placement, 0-based
        size_t _frame;
+
+       /// Placed by Replace tag ?
+       bool _replace;
 };
 
 /// Character is a live, stateful instance of a character_def.
@@ -953,15 +965,19 @@
        /// @param frame
        ///     Frame of first placement. 0-based.
        ///
+       /// @param replacing
+       ///     True if this object was placed by a REPLACE tag
+       ///     (see PlaceObject2).
+       ///
        /// NOTE: if we want to compute TimelineInfo records once at
        ///       parse time and reuse pointers we'll just need to take
        ///       a TimelineInfo pointer as parameter, externally owned.
        ///       For now, we'll use a new object for each instance.
        ///
-       void setTimelineInfo(int depth, int frame)
+       void setTimelineInfo(int depth, int frame, bool replacing)
        {
                assert(_timelineInfo.get()==NULL); // don't call twice !
-               _timelineInfo.reset(new TimelineInfo(depth, frame));
+               _timelineInfo.reset(new TimelineInfo(depth, frame, replacing));
        }
 
        /// Return timeline information, if this is a timeline instance

Index: server/sprite_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.cpp,v
retrieving revision 1.273
retrieving revision 1.274
diff -u -b -r1.273 -r1.274
--- server/sprite_instance.cpp  22 May 2007 14:23:51 -0000      1.273
+++ server/sprite_instance.cpp  23 May 2007 16:38:31 -0000      1.274
@@ -50,6 +50,7 @@
 #include "LoadVariablesThread.h" 
 #include "ExecutableCode.h"
 #include "gnash.h" // for point class !
+#include "Timeline.h" // for restoreDisplayList
 
 #include <vector>
 #include <string>
@@ -69,8 +70,10 @@
 namespace gnash {
 
 //#define GNASH_DEBUG 1
-//#define GNASH_DEBUG_TIMELINE 1
-#define NEW_TIMELINE_DESIGN 1
+#define GNASH_DEBUG_TIMELINE 1
+
+// Unfed for original design, 2 for second redesign attempt, 3 for third 
redesign attempt
+#define NEW_TIMELINE_DESIGN 2
 
 
 
@@ -1703,109 +1706,6 @@
        }
 };
 
-/// 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;
-       }
-};
-
 /// A DisplayList visitor used to extract all characters
 //
 /// Script characters are characters created or transformed
@@ -2611,6 +2511,113 @@
        };
 }
 
+#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)
@@ -2620,6 +2627,8 @@
        //       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.
@@ -2652,6 +2661,28 @@
 #endif
        }
 
+#elif NEW_TIMELINE_DESIGN == 3 // 3rd redesign attempt
+
+       // 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 
+
+       // TODO: try to optize by avoid calling set_invalidated
+       DisplayList newList = m_display_list;
+       assert( newList == m_display_list );
+       newList.reset(*m_def, tgtFrame, true);
+       if ( newList != m_display_list )
+       {
+               cout << "Modified DisplayList: " << newList << endl;
+               set_invalidated();
+               m_display_list = newList;
+       }
+
+#endif // NEW_TIMELINE_DESIGN == 3
+
+
        // 2. Execute all displaylist tags from first to target frame 
 
        for (size_t f = 0; f<=tgtFrame; ++f)
@@ -3032,6 +3063,7 @@
 
        if (existing_char)
        {
+               log_debug("Another character exists in depth %d", depth);
 
                // If we already have this object on this
                // plane, then move it instead of replacing it.
@@ -3040,12 +3072,51 @@
                //       ... I guess it's checked inside move_display_object ...
                if ( existing_char->get_id() == character_id )
                {
+                       log_debug("Char has same id (%d), moving ", 
character_id);
+
                        // TODO: update name ?
                        move_display_object(depth, true, color_transform,
                                true, matrix, 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 )
+               {
+                       log_debug("Char was placed by REPLACE tag in frame %d 
(now in frame %d)", info->placedInFrame(), m_current_frame);
+
+                       if ( existing_char->to_movie() )
+                       {
+                               log_debug("Char is a sprite, moving");
+                               // If it's a sprite we move it.
+                               // See replace_sprites1test.swf
+                               move_display_object(depth, true, 
color_transform, true, matrix, ratio, clip_depth);
+                       }
+                       else
+                       {
+                               log_debug("Char is NOT a sprite, replacing");
+                               // If it's something else (a shape?) replace it
+                               replace_display_object(character_id, name, 
depth, true, color_transform, true, matrix, ratio, clip_depth);
+                       }
+                       return NULL;
+               }
+#endif
+
+#if 0 // still not sure here...
+               // See loop_test5.swf (maybe should compare against *this* 
ratio instead...
+               if ( existing_char->get_ratio() > 0 )
+               {
+                       log_debug("Char has ratio==%g (> 0). Replacing it.", 
existing_char->get_ratio());
+
+                       replace_display_object(character_id, name, depth, true, 
color_transform, true, matrix, 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 )
@@ -3065,7 +3136,7 @@
 #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);
+       ch->setTimelineInfo(depth, m_current_frame, false);
 
        if ( name )
        {
@@ -3134,7 +3205,7 @@
 #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);
+       ch->setTimelineInfo(depth, m_current_frame, true);
 
        replace_display_object(
                ch.get(), name, depth,




reply via email to

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