gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash/server dlist.cpp movie.h movie_def_impl.c...


From: Vitaly Alexeev
Subject: [Gnash-commit] gnash/server dlist.cpp movie.h movie_def_impl.c...
Date: Wed, 14 Jun 2006 13:02:50 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Vitaly Alexeev <alexeev>        06/06/14 13:02:50

Modified files:
        server         : dlist.cpp movie.h movie_def_impl.cpp 
                         movie_root.cpp movie_root.h sprite_instance.cpp 
                         sprite_instance.h 

Log message:
        fix  event execution sequence bug

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/server/dlist.cpp?cvsroot=gnash&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie.h?cvsroot=gnash&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_def_impl.cpp?cvsroot=gnash&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_root.cpp?cvsroot=gnash&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_root.h?cvsroot=gnash&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.h?cvsroot=gnash&r1=1.5&r2=1.6

Patches:
Index: dlist.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/dlist.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- dlist.cpp   7 Jun 2006 03:03:21 -0000       1.11
+++ dlist.cpp   14 Jun 2006 13:02:50 -0000      1.12
@@ -199,7 +199,9 @@
 
        // do the frame1 actions (if applicable) and the "onClipEvent (load)"
        // event.
-       ch->on_event_load();
+
+//     ch->on_event_load();
+       ch->execute_frame_tags(0);      // create dlist only
 
        //log_msg("After adding, list is:");
        //dump(std::cout);
@@ -245,7 +247,9 @@
 
                // do the frame1 actions (if applicable) and the
                // "onClipEvent (load)" event.
-               ch->on_event_load();
+
+               //      ch->on_event_load();
+               ch->execute_frame_tags(0);      // create dlist only
        }
        else
        {

Index: movie.h
===================================================================
RCS file: /sources/gnash/gnash/server/movie.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- movie.h     13 Jun 2006 13:22:08 -0000      1.8
+++ movie.h     14 Jun 2006 13:02:50 -0000      1.9
@@ -382,10 +382,11 @@
        /// actions on this event.
        //
        ///
-       virtual void    on_event_load()
-       {
-               on_event(event_id::LOAD);
-       }
+
+//     virtual void    on_event_load()
+//     {
+//             on_event(event_id::LOAD);
+//     }
 
        // as_object_interface stuff
        virtual void set_member(

Index: movie_def_impl.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/movie_def_impl.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- movie_def_impl.cpp  7 Jun 2006 03:03:21 -0000       1.9
+++ movie_def_impl.cpp  14 Jun 2006 13:02:50 -0000      1.10
@@ -593,6 +593,9 @@
     // (or is it a member?)
 
     m->add_ref();
+
+               root_movie->execute_frame_tags(0); // create _root dlist
+
     return m;
 }
 

Index: movie_root.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/movie_root.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- movie_root.cpp      12 Jun 2006 17:23:51 -0000      1.3
+++ movie_root.cpp      14 Jun 2006 13:02:50 -0000      1.4
@@ -49,9 +49,9 @@
 //#include "fontlib.h"
 //#include "font.h"
 #include "log.h"
-//#include "sprite_instance.h"
+#include "sprite_instance.h"
 #include "render.h"
-#include "tu_random.h" //vv
+#include "tu_random.h"
 
 using namespace std;
 
@@ -72,7 +72,7 @@
     m_mouse_y(0),
     m_mouse_buttons(0),
     m_userdata(NULL),
-    m_on_event_load_called(false),
+//    m_on_event_load_called(false),
     m_on_event_xmlsocket_ondata_called(false),
     m_on_event_xmlsocket_onxml_called(false),
     m_on_event_load_progress_called(false)
@@ -182,20 +182,20 @@
 movie_root::advance(float delta_time)
 {
 //            GNASH_REPORT_FUNCTION;
-       //vv
        // Vitaly: random should go continuously that:
        // 1. after restart of the player the situation has not repeated
        // 2. by different machines the random gave different numbers
        tu_random::next_random();
 
-    if (m_on_event_load_called == false)
-        {
+//     if (m_on_event_load_called == false)
+//        {
             // Must do loading events.  For child sprites this is
             // done by the dlist, but root movies don't get added
             // to a dlist, so we do it here.
-            m_on_event_load_called = true;
-            m_movie->on_event_load();
-        }
+//            m_on_event_load_called = true;
+//            m_movie->on_event_load();
+//        }
+
 #if 0
     // Must check the socket connection for data
     if (m_on_event_xmlsocket_ondata_called == true) {
@@ -223,20 +223,22 @@
         }
     }
                        
-                       
-    m_timer += delta_time;
-    // @@ TODO handle multi-frame catch-up stuff
-    // here, and make it optional.  Make
-    // movie::advance() a fixed framerate w/ no
-    // dt.
-
     // Handle the mouse.
     m_mouse_button_state.m_topmost_entity =
         m_movie->get_topmost_mouse_entity(PIXELS_TO_TWIPS(m_mouse_x), 
PIXELS_TO_TWIPS(m_mouse_y));
     m_mouse_button_state.m_mouse_button_state_current = (m_mouse_buttons & 1);
     generate_mouse_button_events(&m_mouse_button_state);
 
-    m_movie->advance(delta_time);
+// m_movie->advance(delta_time);
+
+               // Vitaly:
+               // onload event for root movieclip is executed after frame 1 
actions.
+               // onload event for child movieclip is executed before frame 1 
actions.
+               // that's why advance for root movieclip and child movieclip 
are different.
+    m_timer += delta_time;
+               sprite_instance* current_root = (sprite_instance*) 
m_movie.get_ptr();
+               assert(current_root);
+               current_root->advance_root(delta_time);
 }
 
 

Index: movie_root.h
===================================================================
RCS file: /sources/gnash/gnash/server/movie_root.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- movie_root.h        25 May 2006 11:55:25 -0000      1.2
+++ movie_root.h        14 Jun 2006 13:02:50 -0000      1.3
@@ -71,7 +71,7 @@
        void *                  m_userdata;
 
        mouse_button_state      m_mouse_button_state;
-       bool                    m_on_event_load_called;
+//     bool                    m_on_event_load_called;
 
        // Flags for event handlers
        bool                    m_on_event_xmlsocket_ondata_called;

Index: sprite_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- sprite_instance.cpp 7 Jun 2006 03:03:21 -0000       1.8
+++ sprite_instance.cpp 14 Jun 2006 13:02:50 -0000      1.9
@@ -363,7 +363,9 @@
        m_time_remainder(0),
        m_update_frame(true),
        m_has_looped(false),
-       m_accept_anim_moves(true)
+       m_accept_anim_moves(true),
+       m_on_event_load_called(false),
+       m_frame_time(0.0f)
 {
        assert(m_def != NULL);
        assert(m_root != NULL);
@@ -379,6 +381,10 @@
            {
                *p = false;
            }
+
+       assert(m_root);
+       m_frame_time = 1.0f / m_root->get_frame_rate(); // cache
+       m_time_remainder = m_frame_time;
 }
 
 sprite_instance::~sprite_instance()
@@ -1103,6 +1109,80 @@
            m_as_environment.set_variable(path, val, empty_with_stack);
 }
 
+
+void sprite_instance::advance_sprite(float delta_time)
+{
+       // mouse drag.
+       character::do_mouse_drag();
+
+       if (m_on_event_load_called)
+       {
+               on_event(event_id::ENTER_FRAME);
+       }
+
+       // Update current and next frames.
+       if (m_play_state == PLAY)
+       {
+               int prev_frame = m_current_frame;
+               if (m_on_event_load_called)
+               {
+                       increment_frame_and_check_for_loop();
+               }
+
+               // Execute the current frame's tags.
+               // execute_frame_tags(0) already executed in dlist.cpp
+               if (m_current_frame != prev_frame)
+               {
+                       execute_frame_tags(m_current_frame);
+               }
+       }
+
+       do_actions();
+
+       // Advance everything in the display list.
+       m_display_list.advance(delta_time);
+}
+
+// _root movieclip advance
+void sprite_instance::advance_root(float delta_time)
+{
+       m_time_remainder += delta_time;
+
+       // Check for the end of frame
+       if (m_time_remainder >= m_frame_time)
+       {
+               m_time_remainder -= m_frame_time;
+               advance_sprite(delta_time);
+
+               if (m_on_event_load_called == false)
+               {
+                       on_event(event_id::LOAD);       // root onload
+                       m_on_event_load_called = true;
+               }
+
+               m_time_remainder = fmod(m_time_remainder, m_frame_time);
+       }
+}
+
+// child movieclip advance
+void sprite_instance::advance(float delta_time)
+{
+//     GNASH_REPORT_FUNCTION;
+
+       // Vitaly:
+       // child movieclip frame rate is the same the root movieclip frame rate
+       // that's why it is not needed to analyze 'm_time_remainder' 
+       if (m_on_event_load_called == false)
+       {
+               on_event(event_id::LOAD);       // clip onload
+       }
+       
+       advance_sprite(delta_time);
+
+       m_on_event_load_called = true;
+}
+
+#if 0
 void sprite_instance::advance(float delta_time)
 {
 //     GNASH_REPORT_FUNCTION;
@@ -1162,6 +1242,7 @@
        // with no dt.
        m_time_remainder = fmod(m_time_remainder, frame_time);
 }
+#endif
 
 /* virtual public, reimplemented from gnash::movie */
 void sprite_instance::execute_frame_tags(int frame,

Index: sprite_instance.h
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- sprite_instance.h   29 May 2006 12:49:34 -0000      1.5
+++ sprite_instance.h   14 Jun 2006 13:02:50 -0000      1.6
@@ -189,6 +189,8 @@
        virtual movie*  get_topmost_mouse_entity(float x, float y);
 
        virtual void    advance(float delta_time);
+       virtual void    advance_root(float delta_time);
+       virtual void    advance_sprite(float delta_time);
 
        /// Execute the tags associated with the specified frame.
        /// frame is 0-based
@@ -411,12 +413,13 @@
        /// loads.  frame1 tags and actions are executed (even
        /// before advance() is called).  Then the onLoad event
        /// is triggered.
-       virtual void    on_event_load()
-       {
-           execute_frame_tags(0);
-           do_actions();
-           on_event(event_id::LOAD);
-       }
+
+//     virtual void    on_event_load()
+//     {
+//         execute_frame_tags(0);
+//         do_actions();
+//         on_event(event_id::LOAD);
+//     }
 
        /// Do the events that happen when there is XML data waiting
        /// on the XML socket connection.
@@ -509,6 +512,9 @@
        /// Increment m_current_frame, and take care of looping.
        void increment_frame_and_check_for_loop();
 
+       bool m_on_event_load_called;
+       float   m_frame_time;
+
 };
 
 




reply via email to

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