CVSROOT: /sources/gnash Module name: gnash Changes by: Sandro Santilli <strk> 07/09/19 06:36:29
Modified files: . : ChangeLog gui : gui.cpp gui.h Log message: * gui/gui.{cpp,h}: draft an attempt at skipping rendering when late of fps timer. It's experimental, and disabled by default. Define SKIP_RENDERING_IF_LATE in gui.h to try it out. CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4344&r2=1.4345 http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gui.cpp?cvsroot=gnash&r1=1.96&r2=1.97 http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gui.h?cvsroot=gnash&r1=1.62&r2=1.63 Patches: Index: ChangeLog =================================================================== RCS file: /sources/gnash/gnash/ChangeLog,v retrieving revision 1.4344 retrieving revision 1.4345 diff -u -b -r1.4344 -r1.4345 --- ChangeLog 19 Sep 2007 02:17:38 -0000 1.4344 +++ ChangeLog 19 Sep 2007 06:36:28 -0000 1.4345 @@ -1,3 +1,10 @@ +2007-09-19 Sandro Santilli <[EMAIL PROTECTED]> + + * gui/gui.{cpp,h}: draft an attempt at skipping rendering + when late of fps timer. It's experimental, and disabled + by default. Define SKIP_RENDERING_IF_LATE in gui.h to + try it out. + 2007-09-19 Markus Gothe <[EMAIL PROTECTED]> * configure.ac: Fixed typo. Index: gui/gui.cpp =================================================================== RCS file: /sources/gnash/gnash/gui/gui.cpp,v retrieving revision 1.96 retrieving revision 1.97 diff -u -b -r1.96 -r1.97 --- gui/gui.cpp 12 Sep 2007 10:57:05 -0000 1.96 +++ gui/gui.cpp 19 Sep 2007 06:36:28 -0000 1.97 @@ -37,6 +37,10 @@ #include <cstdio> #include <cstring> +#ifdef SKIP_RENDERING_IF_LATE +#include <boost/timer.hpp> +#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 @@ -71,10 +75,6 @@ // as the mouse moves //#define DEBUG_MOUSE_COORDINATES 1 - -// Define this to N for only rendering 1/N frames -//#define RENDER_ONE_FRAME_EVERY 50 - namespace gnash { Gui::Gui() : @@ -95,6 +95,9 @@ ,fps_timer(0) ,fps_timer_interval(0.0) #endif +#ifdef SKIP_RENDERING_IF_LATE + ,estimatedDisplayTime(0.001) // will grow later.. +#endif // SKIP_RENDERING_IF_LATE { // GNASH_REPORT_FUNCTION; } @@ -118,6 +121,9 @@ ,fps_timer(0) ,fps_timer_interval(0.0) #endif +#ifdef SKIP_RENDERING_IF_LATE + ,estimatedDisplayTime(0.001) // will grow later.. +#endif // SKIP_RENDERING_IF_LATE { } @@ -426,9 +432,10 @@ setInvalidatedRegions(changed_ranges); #endif + // TODO: should this be called even if we're late ? beforeRendering(); - // render the frame. + // Render the frame, if not late. // It's up to the GUI/renderer combination // to do any clipping, if desired. m->display(); @@ -483,6 +490,10 @@ // GNASH_REPORT_FUNCTION; +#ifdef SKIP_RENDERING_IF_LATE + boost::timer advanceTimer; +#endif // SKIP_RENDERING_IF_LATE + gnash::movie_root* m = gnash::get_current_root(); #ifdef GNASH_FPS_DEBUG @@ -507,16 +518,42 @@ #endif -#if RENDER_ONE_FRAME_EVERY - static unsigned call=0; - if ( ++call % RENDER_ONE_FRAME_EVERY == 0 ) +#ifdef SKIP_RENDERING_IF_LATE + + double advanceTime = advanceTimer.elapsed(); // in seconds ! + + double timeSlot = gui->_interval/1000.0; // seconds between advance calls (TODO: compute once) + + if ( advanceTime+gui->estimatedDisplayTime < timeSlot ) { - call=0; + advanceTimer.restart(); gui->display(m); + double displayTime = advanceTimer.elapsed(); + + if ( displayTime > gui->estimatedDisplayTime) + { + //log_debug("Display took %6.6g seconds over %6.6g available for each frame", displayTime, timeSlot); + + // 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... + gui->estimatedDisplayTime = displayTime; } -#else + } + } + else + { + //log_debug("We're unable to keep up with FPS speed: advanceTime was %g + estimatedDisplayTime (%g) == %g, over a timeSlot of %g", advanceTime, gui->estimatedDisplayTime, advanceTime+gui->estimatedDisplayTime, timeSlot); + // TODO: increment a counter, we don't want to skip too many frames + } +#else // ndef SKIP_RENDERING_IF_LATE + gui->display(m); -#endif + +#endif // ndef SKIP_RENDERING_IF_LATE if ( ! gui->loops() ) { Index: gui/gui.h =================================================================== RCS file: /sources/gnash/gnash/gui/gui.h,v retrieving revision 1.62 retrieving revision 1.63 diff -u -b -r1.62 -r1.63 --- gui/gui.h 12 Sep 2007 10:57:05 -0000 1.62 +++ gui/gui.h 19 Sep 2007 06:36:28 -0000 1.63 @@ -33,6 +33,11 @@ #include <string> +// Define the following macro if you want to skip rendering +// when late on FPS time. +// This is an experimental feature, so it's off by default +//#define SKIP_RENDERING_IF_LATE + // Forward declarations namespace gnash { @@ -339,6 +344,12 @@ #endif // def GNASH_FPS_DEBUG +#ifdef SKIP_RENDERING_IF_LATE + /// Estimated max number of seconds required for a call to ::display + /// This should be incremented everytime we take more + double estimatedDisplayTime; +#endif // SKIP_RENDERING_IF_LATE + }; /// Named constructors _______________________________________________ Gnash-commit mailing list Gnash-commit@gnu.org http://lists.gnu.org/mailman/listinfo/gnash-commit