gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog gui/Player.cpp gui/Player.h gui...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog gui/Player.cpp gui/Player.h gui...
Date: Mon, 01 Oct 2007 21:47:05 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/10/01 21:47:05

Modified files:
        .              : ChangeLog 
        gui            : Player.cpp Player.h gui.cpp gui.h 

Log message:
                * gui/gui.{cpp,h}: add movie_definition and movie_root members,
                  add _started member to postpone kick-start 
(movie_root::setRootMovie
                  call) in case we started in "stop" mode [ fixed bug #21212 ].
                  Avoid notifying mouse and key events to the core lib if in 
stop
                  mode.
                * gui/Player.{cpp,h}: update use of the Gui class.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4493&r2=1.4494
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/Player.cpp?cvsroot=gnash&r1=1.66&r2=1.67
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/Player.h?cvsroot=gnash&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gui.cpp?cvsroot=gnash&r1=1.102&r2=1.103
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gui.h?cvsroot=gnash&r1=1.66&r2=1.67

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.4493
retrieving revision 1.4494
diff -u -b -r1.4493 -r1.4494
--- ChangeLog   1 Oct 2007 16:51:18 -0000       1.4493
+++ ChangeLog   1 Oct 2007 21:47:03 -0000       1.4494
@@ -1,5 +1,14 @@
 2007-10-01 Sandro Santilli <address@hidden>
 
+       * gui/gui.{cpp,h}: add movie_definition and movie_root members,
+         add _started member to postpone kick-start (movie_root::setRootMovie
+         call) in case we started in "stop" mode [ fixed bug #21212 ].
+         Avoid notifying mouse and key events to the core lib if in stop
+         mode.
+       * gui/Player.{cpp,h}: update use of the Gui class.
+
+2007-10-01 Sandro Santilli <address@hidden>
+
        * server/vm/ActionExec.cpp: cleanups in opcode guard code.
 
 2007-10-01 Benjamin Wolsey <address@hidden>

Index: gui/Player.cpp
===================================================================
RCS file: /sources/gnash/gnash/gui/Player.cpp,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -b -r1.66 -r1.67
--- gui/Player.cpp      7 Sep 2007 00:11:26 -0000       1.66
+++ gui/Player.cpp      1 Oct 2007 21:47:04 -0000       1.67
@@ -55,17 +55,15 @@
 
 /*static private*/
 void
-Player::setFlashVars(gnash::sprite_instance& m, const std::string& varstr)
+Player::setFlashVars(const std::string& varstr)
 {
-       gnash::sprite_instance* si = m.get_root_movie();
-       assert(si);
-
-       typedef sprite_instance::VariableMap maptype;
+       typedef Gui::VariableMap maptype;
 
        maptype vars;
        URL::parse_querystring(varstr, vars);
 
-       si->setVariables(vars);
+       _gui->addFlashVars(vars);
+       //si->setVariables(vars);
 }
 
 Player::Player()
@@ -239,8 +237,6 @@
 Player::run(int argc, char* argv[], const char* infile, const char* url)
 {
     
-       bool background = true;
-
        assert(tu_types_validate());
 
        // Call this at run() time, so the caller has
@@ -313,8 +309,7 @@
 
     movie_root& root = VM::init(*_movie_def).getRoot();
 
-    std::auto_ptr<movie_instance> mr ( _movie_def->create_movie_instance() );
-    sprite_instance* m = mr.get();
+    _gui->setStage(&root);
 
     // Start loader thread
     _movie_def->completeLoad();
@@ -326,7 +321,7 @@
        // todo: use a case-insensitive string type
        if ( it->first == "flashvars" || it->first == "FlashVars" )
        {
-               setFlashVars(*m, it->second);
+               setFlashVars(it->second);
                continue;
        }
 
@@ -336,11 +331,10 @@
     }
 
     // Parse querystring
-    setFlashVars(*m, URL(_url).querystring());
+    setFlashVars(URL(_url).querystring());
+
+    _gui->setMovieDefinition(_movie_def);
 
-    root.setRootMovie( mr.release() ); // will construct the instance
-    root.set_display_viewport(0, 0, width, height);
-    root.set_background_alpha(background ? 1.0f : 0.05f);
 
     if (!delay) {
       delay = (unsigned int) (1000 / movie_fps) ; // milliseconds per frame

Index: gui/Player.h
===================================================================
RCS file: /sources/gnash/gnash/gui/Player.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- gui/Player.h        31 Jul 2007 19:29:43 -0000      1.17
+++ gui/Player.h        1 Oct 2007 21:47:04 -0000       1.18
@@ -151,7 +151,7 @@
        ///
        std::auto_ptr<Gui> getGui();
 
-       static void setFlashVars(sprite_instance& m, const std::string& varstr);
+       void setFlashVars(const std::string& varstr);
 
        static void fs_callback(sprite_instance* movie,
                        const char* command, const char* args);

Index: gui/gui.cpp
===================================================================
RCS file: /sources/gnash/gnash/gui/gui.cpp,v
retrieving revision 1.102
retrieving revision 1.103
diff -u -b -r1.102 -r1.103
--- gui/gui.cpp 27 Sep 2007 12:04:26 -0000      1.102
+++ gui/gui.cpp 1 Oct 2007 21:47:04 -0000       1.103
@@ -88,8 +88,7 @@
     _depth(16),
     _interval(0),
     _renderer(NULL),
-    _redraw_flag(true),
-    _stopped(false)
+    _redraw_flag(true)
 #ifdef GNASH_FPS_DEBUG
     ,fps_counter(0)
     ,fps_counter_total(0)
@@ -99,6 +98,10 @@
 #ifdef SKIP_RENDERING_IF_LATE
     ,estimatedDisplayTime(0) // milliseconds (will grow later..)
 #endif // SKIP_RENDERING_IF_LATE
+    ,_movieDef(0)
+    ,_stage(0)
+    ,_stopped(false)
+    ,_started(false)
 {
 //    GNASH_REPORT_FUNCTION;
 }
@@ -114,8 +117,7 @@
     _depth(depth),
     _interval(0),
     _renderer(NULL),
-    _redraw_flag(true),
-    _stopped(false)
+    _redraw_flag(true)
 #ifdef GNASH_FPS_DEBUG
     ,fps_counter(0)    
     ,fps_counter_total(0)    
@@ -125,6 +127,10 @@
 #ifdef SKIP_RENDERING_IF_LATE
     ,estimatedDisplayTime(0) // milliseconds (will grow later..)
 #endif // SKIP_RENDERING_IF_LATE
+    ,_movieDef(0)
+    ,_stage(0)
+    ,_stopped(false)
+    ,_started(false)
 {
 }
 
@@ -147,7 +153,9 @@
 Gui::menu_restart()
 {
 //    GNASH_REPORT_FUNCTION;
-       get_current_root()->restart();
+       _stage->restart();
+
+    // TODO: see ::start() for a clean way to restart (including setting flash 
vars)
 }
 
 void
@@ -161,14 +169,13 @@
        if ( VM::isInitialized() )
        {
 
-               movie_root& m = VM::get().getRoot();
-
-               movie_definition* md = m.get_movie_definition();
-
-               float swfwidth = md->get_width_pixels();
-               float swfheight = md->get_height_pixels();
+               float swfwidth = _movieDef->get_width_pixels();
+               float swfheight = _movieDef->get_height_pixels();
 
-               m.set_display_viewport(0, 0, width, height);
+               if ( _stage && _started )
+               {
+                       _stage->set_display_viewport(0, 0, width, height);
+               }
 
                // set new scale value
                _xscale = width / swfwidth;
@@ -290,7 +297,11 @@
 void
 Gui::notify_mouse_moved(int x, int y) 
 {
-       movie_root* m = get_current_root();
+       movie_root* m = _stage;
+
+    if ( ! _started ) return;
+
+    if ( _stopped ) return;
 
 #ifdef DEBUG_MOUSE_COORDINATES
        log_msg(_("mouse @ %d,%d"), x, y);
@@ -313,9 +324,13 @@
 void
 Gui::notify_mouse_clicked(bool mouse_pressed, int mask) 
 {
-       movie_root* m = get_current_root();
+       movie_root* m = _stage;
        assert(m);
 
+    if ( ! _started ) return;
+
+    if ( _stopped ) return;
+
        if ( m->notify_mouse_clicked(mouse_pressed, mask) )
        {
                // any action triggered by the
@@ -327,7 +342,10 @@
 void
 Gui::refresh_view()
 {
-       movie_root* m = get_current_root();
+       movie_root* m = _stage;
+
+    if ( ! _started ) return;
+
        assert(m);
        _redraw_flag=true;
        display(m);
@@ -337,14 +355,7 @@
 void
 Gui::notify_key_event(gnash::key::code k, int modifier, bool pressed) 
 {
-       movie_root* m = get_current_root();
-
-       if ( m->notify_key_event(k, pressed) )
-       {
-               // any action triggered by the
-               // event required screen refresh
-               display(m);
-       }
+       movie_root* m = _stage;
 
        /* Handle GUI shortcuts */
        if (!pressed) return;
@@ -378,11 +389,26 @@
                        break;
                }
        }
+
+    if ( ! _started ) return;
+
+    if ( _stopped ) return;
+
+       if ( m->notify_key_event(k, pressed) )
+       {
+               // any action triggered by the
+               // event required screen refresh
+               display(m);
+       }
+
 }
 
 bool
 Gui::display(movie_root* m)
 {
+    assert(m == _stage); // why taking this arg ??
+
+    assert(_started);
 
        InvalidatedRanges changed_ranges;
        bool redraw_flag;
@@ -501,12 +527,62 @@
        return true;
 }
 
+void
+Gui::play()
+{
+    if ( ! _stopped ) return;
+
+    _stopped = false;
+    if ( ! _started ) start();
+}
+
+void
+Gui::stop()
+{
+    if ( _stopped ) return;
+
+    _stopped = true;
+}
+
+void
+Gui::pause()
+{
+    if ( _stopped )
+    {
+        play();
+    }
+    else _stopped = true;
+}
+
+void
+Gui::start()
+{
+    assert ( ! _started );
+    if ( _stopped )
+    {
+        log_debug("Gui is in stop mode, won't start application");
+        return;
+    }
+
+    std::auto_ptr<movie_instance> mr ( _movieDef->create_movie_instance() );
+    mr->setVariables(_flashVars);
+
+    _stage->setRootMovie( mr.release() ); // will construct the instance
+    _stage->set_display_viewport(0, 0, _width, _height);
+
+    bool background = true; // ??
+    _stage->set_background_alpha(background ? 1.0f : 0.05f);
+
+
+    _started = true;
+}
+
 bool
-Gui::advance_movie(Gui* gui)
+Gui::advanceMovie()
 {
-       assert(gui);
+       if ( isStopped() ) return true;
 
-       if ( gui->isStopped() ) return true;
+    if ( ! _started ) start();
   
 //     GNASH_REPORT_FUNCTION;
 
@@ -514,10 +590,10 @@
        WallClockTimer advanceTimer;
 #endif // SKIP_RENDERING_IF_LATE
 
-       gnash::movie_root* m = gnash::get_current_root();
+       gnash::movie_root* m = _stage;
        
 #ifdef GNASH_FPS_DEBUG
-       gui->fpsCounterTick(); // will be a no-op if fps_timer_interval is zero
+       fpsCounterTick(); // will be a no-op if fps_timer_interval is zero
 #endif
 
 // Define REVIEW_ALL_FRAMES to have *all* frames
@@ -542,15 +618,15 @@
 
        uint32_t advanceTime = advanceTimer.elapsed(); // in milliseconds !
 
-       uint32_t timeSlot = gui->_interval; // milliseconds between advance 
calls 
+       uint32_t timeSlot = _interval; // milliseconds between advance calls 
 
        if ( advanceTime+gui->estimatedDisplayTime < timeSlot )
        {
                advanceTimer.restart();
-               gui->display(m);
+               display(m);
                uint32_t displayTime = advanceTimer.elapsed();
 
-               if ( displayTime > gui->estimatedDisplayTime)
+               if ( displayTime > estimatedDisplayTime)
                {
                        //log_debug("Display took %6.6g seconds over %6.6g 
available for each frame", displayTime, timeSlot);
 
@@ -560,7 +636,7 @@
                                // TODO: check for absurdly high values, like 
we can't set
                                //       estimatedDisplayTime to a value higher 
then FPS, or
                                //       we'll simply never display...
-                               gui->estimatedDisplayTime = displayTime;
+                               estimatedDisplayTime = displayTime;
                        }
                }
        }
@@ -569,23 +645,23 @@
                log_debug("We're unable to keep up with FPS speed: "
                        "advanceTime was %u + estimatedDisplayTime (%u) "
                        "== %u, over a timeSlot of %u",
-                       advanceTime, gui->estimatedDisplayTime,
-                       advanceTime+gui->estimatedDisplayTime, timeSlot);
+                       advanceTime, estimatedDisplayTime,
+                       advanceTime+estimatedDisplayTime, timeSlot);
                // TODO: increment a counter, we don't want to skip too many 
frames
        }
 #else // ndef SKIP_RENDERING_IF_LATE
 
-       gui->display(m);
+       display(m);
 
 #endif // ndef SKIP_RENDERING_IF_LATE
        
-       if ( ! gui->loops() )
+       if ( ! loops() )
        {
                size_t curframe = m->get_current_frame(); // can be 0 on 
malformed SWF
                gnash::sprite_instance* si = m->get_root_movie();
                if (curframe + 1 >= si->get_frame_count())
                {
-                       gui->quit(); 
+                       quit(); 
                }
        }
 
@@ -747,6 +823,30 @@
 }
 #endif
 
+void
+Gui::addFlashVars(Gui::VariableMap& from)
+{
+    for (VariableMap::iterator i=from.begin(), ie=from.end(); i!=ie; ++i)
+    {
+        _flashVars[i->first] = i->second;
+    }
+}
+
+void
+Gui::setMovieDefinition(movie_definition* md)
+{
+    assert(!_movieDef);
+    _movieDef = md;
+}
+
+void
+Gui::setStage(movie_root* stage)
+{
+    assert(stage);
+    assert(!_stage);
+    _stage = stage;
+}
+
 // end of namespace
 }
 

Index: gui/gui.h
===================================================================
RCS file: /sources/gnash/gnash/gui/gui.h,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -b -r1.66 -r1.67
--- gui/gui.h   26 Sep 2007 08:35:08 -0000      1.66
+++ gui/gui.h   1 Oct 2007 21:47:04 -0000       1.67
@@ -30,8 +30,10 @@
 #include "snappingrange.h"  // for InvalidatedRanges
 #include "gnash.h" // for gnash::key::code type
 #include "tree.hh" // for tree
+#include "smart_ptr.h"
 
 #include <string>
+#include <map>
 
 // Define the following macro if you want to skip rendering
 // when late on FPS time.
@@ -195,11 +197,16 @@
     /// @param height The desired height in pixels.
     void resize_view(int width, int height);
 
-
     /// \brief
     /// Advances the movie to the next frame. This is to take place after the
     /// interval specified in the call to setInterval().
-    static bool advance_movie(Gui* gui);
+    bool advanceMovie();
+
+    /// Convenience static wrapper around advanceMovie for callbacks happiness.
+    static bool advance_movie(Gui* gui)
+    {
+        return gui->advanceMovie();
+    }
 
     /// Force immediate redraw
     ///
@@ -209,19 +216,26 @@
     //
     /// When in stop mode the application won't be advanced.
     ///
-    void stop() { _stopped=true; }
+    void stop();
 
     /// Put the application in "play" mode
     //
-    /// When in stop mode the application will be advanced as usual.
+    /// When in play mode the application will be advanced as usual.
     ///
-    void play() { _stopped=false; }
+    void play();
 
     /// Toggle between "stop" and "play" mode
     //
     /// See stop() and play()
     ///
-    void pause() { _stopped = !_stopped; }
+    void pause();
+
+    /// Start the movie
+    //
+    /// This function will create an instance of the registered top-level 
+    /// movie definition, set variables into it and place it to the stage.
+    ///
+    void start();
 
     /// See stop(), play() and pause()
     bool isStopped() const { return _stopped; }
@@ -266,6 +280,17 @@
     ///
     std::auto_ptr<InfoTree> getMovieInfo() const;
 
+    typedef std::map<std::string, std::string> VariableMap;
+
+    /// Add variables to set into instances of the top-level movie definition
+    void addFlashVars(VariableMap& vars);
+
+    /// Set the definition of top-level movie
+    void setMovieDefinition(movie_definition* md);
+
+    /// Set the stage to advance/display
+    void setStage(movie_root* stage);
+
 protected:
 
     /// Default constructor. Initialises members to safe defaults.
@@ -317,8 +342,6 @@
     /// window size did change.
     bool            _redraw_flag;
 
-    bool            _stopped;
-
 private:
 
     bool display(movie_root* m);
@@ -355,6 +378,18 @@
     uint32_t estimatedDisplayTime;
 #endif // SKIP_RENDERING_IF_LATE
 
+    VariableMap _flashVars;
+
+    boost::intrusive_ptr<movie_definition> _movieDef;
+
+    movie_root* _stage;
+
+    /// True if the application has been put into "stop" mode
+    bool            _stopped;
+
+    /// True if the application didn't start yet
+    bool            _started;
+
 };
 
 /// Named constructors




reply via email to

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