gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r10918: Refactor rendering frames dr


From: Sandro Santilli
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r10918: Refactor rendering frames drop mechanism. This is kept disabled by default as it's still not smart enough (doesn't avoid never re-rendering, which is silly)
Date: Mon, 25 May 2009 19:31:02 +0200
User-agent: Bazaar (1.13.1)

------------------------------------------------------------
revno: 10918
committer: Sandro Santilli <address@hidden>
branch nick: trunk
timestamp: Mon 2009-05-25 19:31:02 +0200
message:
  Refactor rendering frames drop mechanism. This is kept disabled by default as 
it's still not smart enough (doesn't avoid never re-rendering, which is silly)
modified:
  gui/gui.cpp
  gui/gui.h
  libcore/movie_root.cpp
  libcore/movie_root.h
=== modified file 'gui/gui.cpp'
--- a/gui/gui.cpp       2009-05-19 22:57:16 +0000
+++ b/gui/gui.cpp       2009-05-25 17:31:02 +0000
@@ -39,10 +39,6 @@
 #include <cstring>
 #include <algorithm> // std::max, std::min
 
-#ifdef SKIP_RENDERING_IF_LATE
-#include "WallClockTimer.h"
-#endif
-
 /// Define this to make sure each frame is fully rendered from ground up
 /// even if no motion has been detected in the movie.
 //#define FORCE_REDRAW 1
@@ -95,10 +91,8 @@
     ,fps_counter_total(0)
     ,fps_timer(0)
     ,fps_timer_interval(0.0)
+    ,frames_dropped(0)
 #endif
-#ifdef SKIP_RENDERING_IF_LATE
-    ,estimatedDisplayTime(0) // milliseconds (will grow later..)
-#endif // SKIP_RENDERING_IF_LATE
     ,_movieDef(0)
     ,_stage(0)
     ,_stopped(false)
@@ -143,10 +137,8 @@
     ,fps_counter_total(0)    
     ,fps_timer(0)
     ,fps_timer_interval(0.0)
+    ,frames_dropped(0)
 #endif        
-#ifdef SKIP_RENDERING_IF_LATE
-    ,estimatedDisplayTime(0) // milliseconds (will grow later..)
-#endif // SKIP_RENDERING_IF_LATE
     ,_movieDef(0)
     ,_stage(0)
     ,_stopped(false)
@@ -174,7 +166,8 @@
     delete _renderer;
 #ifdef GNASH_FPS_DEBUG
     if ( fps_timer_interval ) {
-        std::cerr << "Total frame advances: " << fps_counter_total << 
std::endl;
+        std::cerr << "Total frame advances/drops: "
+                  << fps_counter_total << "/" << frames_dropped << std::endl;
     }
 #endif
 }
@@ -935,10 +928,6 @@
   
 
 
-#ifdef SKIP_RENDERING_IF_LATE
-       WallClockTimer advanceTimer;
-#endif // SKIP_RENDERING_IF_LATE
-
        gnash::movie_root* m = _stage;
        
 // Define REVIEW_ALL_FRAMES to have *all* frames
@@ -964,47 +953,29 @@
 
 
 
+    // TODO: ask stage about doDisplay ?
+    // - if it didn't advance might need to check updateAfterEvent
+    bool doDisplay = true;
+
 #ifdef SKIP_RENDERING_IF_LATE
-
-       boost::uint32_t advanceTime = advanceTimer.elapsed(); // in 
milliseconds !
-
-       boost::uint32_t timeSlot = _interval; // milliseconds between advance 
calls 
-
-       if ( advanceTime+gui->estimatedDisplayTime < timeSlot )
-       {
-               advanceTimer.restart();
-               display(m);
-               boost::uint32_t displayTime = advanceTimer.elapsed();
-
-               if ( displayTime > estimatedDisplayTime)
-               {
-
-                       // Don't update estimatedDisplayTime if it's bigger 
then 
-            // timeSlot*0.8
-                       if (  displayTime < timeSlot*0.8 )
-                       {
-                               // TODO: check for absurdly high values, like 
we can't set
-                               //       estimatedDisplayTime to a value higher 
then FPS, or
-                               //       we'll simply never display...
-                               estimatedDisplayTime = displayTime;
-                       }
-               }
-       }
-       else
-       {
-               log_debug("We're unable to keep up with FPS speed: "
-                       "advanceTime was %u + estimatedDisplayTime (%u) "
-                       "== %u, over a timeSlot of %u",
-                       advanceTime, estimatedDisplayTime,
-                       advanceTime+estimatedDisplayTime, timeSlot);
-               // TODO: increment a counter, we don't want to skip too many 
frames
-       }
-#else // ndef SKIP_RENDERING_IF_LATE
-
-       display(m);
-
+    // We want to skip rendering IFF it's time to advance again.
+    // We'll ask the stage about it
+    if ( _stage->timeToNextFrame() <= 0 )
+    {
+        if ( doDisplay ) // or should it be if advanced ?
+        {
+            // TODO: take note of a frame drop (count them)
+            //log_debug("Frame rendering dropped due to being late");
+#ifdef GNASH_FPS_DEBUG
+            ++frames_dropped;
+#endif
+        }
+        doDisplay = false;
+    }
 #endif // ndef SKIP_RENDERING_IF_LATE
-       
+
+       if (doDisplay) display(m);
+
        if ( ! loops() )
        {
                size_t curframe = m->get_current_frame(); // can be 0 on 
malformed SWF
@@ -1226,9 +1197,11 @@
     //log_debug("Effective frame rate: %0.2f fps", (float)(fps_counter/secs));
     std::cerr << boost::format("Effective frame rate: %0.2f fps "
                                "(min %0.2f, avg %0.2f, max %0.2f, "
-                               "%u frames in %0.1f secs total)") % rate %
+                               "%u frames in %0.1f secs total, "
+                               "dropped %u)") % rate %
                                fps_rate_min % avg % fps_rate_max %
-                               fps_counter_total % secs_total << std::endl;
+                               fps_counter_total % secs_total %
+                               frames_dropped << std::endl;
       
     fps_counter = 0;
     fps_timer = current_timer;

=== modified file 'gui/gui.h'
--- a/gui/gui.h 2009-04-26 17:26:09 +0000
+++ b/gui/gui.h 2009-05-25 17:31:02 +0000
@@ -475,6 +475,7 @@
     
 #ifdef GNASH_FPS_DEBUG
     unsigned int fps_counter;
+
     float fps_rate_min, fps_rate_max;   
 
     // Number of calls to fpsCounterTick, which is also
@@ -489,6 +490,9 @@
     ///
     float fps_timer_interval;
     
+    /// Number of frames rendering of which was dropped
+    unsigned int frames_dropped;
+
     /// \brief
     /// Should be called on every frame advance (including inter-frames caused
     /// by mouse events).
@@ -499,12 +503,6 @@
 
 #endif // def GNASH_FPS_DEBUG
 
-#ifdef SKIP_RENDERING_IF_LATE
-    /// Estimated max number of milliseconds required for a call to ::display
-    /// This should be incremented everytime we take more
-    boost::uint32_t estimatedDisplayTime;
-#endif // SKIP_RENDERING_IF_LATE
-
     VariableMap _flashVars;
 
     boost::intrusive_ptr<movie_definition> _movieDef;

=== modified file 'libcore/movie_root.cpp'
--- a/libcore/movie_root.cpp    2009-05-25 13:28:53 +0000
+++ b/libcore/movie_root.cpp    2009-05-25 17:31:02 +0000
@@ -1084,6 +1084,13 @@
     assert(testInvariant());
 }
 
+int
+movie_root::timeToNextFrame() const
+{
+    unsigned int now = _vm.getTime();
+    int elapsed = now - _lastMovieAdvancement;
+    return _movieAdvancementDelay - elapsed;
+}
 
 void
 movie_root::display()

=== modified file 'libcore/movie_root.h'
--- a/libcore/movie_root.h      2009-04-28 15:22:32 +0000
+++ b/libcore/movie_root.h      2009-05-25 17:31:02 +0000
@@ -369,6 +369,14 @@
     ///
     bool advance();
 
+    /// \brief
+    /// Return the number of milliseconds available before
+    /// it's time to advance the timeline again.
+    //
+    /// Return value can be negative if we're late...
+    ///
+    int timeToNextFrame() const;
+
     /// Entry point for movie advancement
     //
     /// This function does:


reply via email to

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