mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2025-12-12 17:58:53 +01:00
add force refresh screen period
Signed-off-by: Vincent-FK <vincent.buso@funkey-project.com>
This commit is contained in:
parent
43d2eb62c9
commit
41288c5c25
@ -57,6 +57,7 @@
|
|||||||
|
|
||||||
#define REMOVE_TEST_FUNKEY
|
#define REMOVE_TEST_FUNKEY
|
||||||
#define FUNKEY_ALL_POLLEVENT_DELAY 30 //ms
|
#define FUNKEY_ALL_POLLEVENT_DELAY 30 //ms
|
||||||
|
#define PERIOD_FORCE_REFRESH 1000 //ms
|
||||||
|
|
||||||
#define FPS 30 // TODO: set in conf file
|
#define FPS 30 // TODO: set in conf file
|
||||||
|
|
||||||
@ -102,25 +103,31 @@ void RetroFE::render( )
|
|||||||
//SDL_RenderClear( SDL::getRenderer( ) );
|
//SDL_RenderClear( SDL::getRenderer( ) );
|
||||||
SDL_FillRect(SDL::getWindow( ), NULL, SDL_MapRGB(SDL::getWindow( )->format, 0, 0, 0));
|
SDL_FillRect(SDL::getWindow( ), NULL, SDL_MapRGB(SDL::getWindow( )->format, 0, 0, 0));
|
||||||
|
|
||||||
|
#ifdef DEBUG_FPS
|
||||||
uint32_t draw_ticks = SDL_GetTicks();
|
uint32_t draw_ticks = SDL_GetTicks();
|
||||||
|
#endif //DEBUG_FPS
|
||||||
if ( currentPage_ )
|
if ( currentPage_ )
|
||||||
{
|
{
|
||||||
currentPage_->draw( );
|
currentPage_->draw( );
|
||||||
}
|
}
|
||||||
|
#ifdef DEBUG_FPS
|
||||||
int draw_time = SDL_GetTicks()-draw_ticks;
|
int draw_time = SDL_GetTicks()-draw_ticks;
|
||||||
//printf("draw time: %dms\n", draw_time);
|
//printf("draw time: %dms\n", draw_time);
|
||||||
|
#endif //DEBUG_FPS
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef DEBUG_FPS
|
||||||
// DEBUG: Average draw time over FPS*5 frames
|
// DEBUG: Average draw time over FPS*5 frames
|
||||||
static int avg_draw_time = 0;
|
static int avg_draw_time = 0;
|
||||||
static int avg_draw_time_nb_vals = 0;
|
static int avg_draw_time_nb_vals = 0;
|
||||||
avg_draw_time += draw_time;
|
avg_draw_time += draw_time;
|
||||||
avg_draw_time_nb_vals++;
|
avg_draw_time_nb_vals++;
|
||||||
if(avg_draw_time_nb_vals >= FPS*5){
|
if(avg_draw_time_nb_vals >= FPS*5){
|
||||||
DEBUG_FPS_PRINTF("Average draw time: %dms\n", avg_draw_time/avg_draw_time_nb_vals);
|
printf("Average draw time: %dms\n", avg_draw_time/avg_draw_time_nb_vals);
|
||||||
avg_draw_time=0;
|
avg_draw_time=0;
|
||||||
avg_draw_time_nb_vals=0;
|
avg_draw_time_nb_vals=0;
|
||||||
}
|
}
|
||||||
|
#endif //DEBUG_FPS
|
||||||
|
|
||||||
//SDL_RenderPresent( SDL::getRenderer( ) );
|
//SDL_RenderPresent( SDL::getRenderer( ) );
|
||||||
//SDL_Flip(SDL::getWindow( ));
|
//SDL_Flip(SDL::getWindow( ));
|
||||||
@ -434,6 +441,13 @@ void RetroFE::run( )
|
|||||||
}
|
}
|
||||||
|
|
||||||
float preloadTime = 0;
|
float preloadTime = 0;
|
||||||
|
int current_sdl_ticks = 0;
|
||||||
|
int process_time = 0;
|
||||||
|
|
||||||
|
// Force refresh variables
|
||||||
|
#ifdef PERIOD_FORCE_REFRESH
|
||||||
|
int ticks_last_refresh = 0;
|
||||||
|
#endif //PERIOD_FORCE_REFRESH
|
||||||
|
|
||||||
// Initialize video
|
// Initialize video
|
||||||
bool videoEnable = true;
|
bool videoEnable = true;
|
||||||
@ -1063,30 +1077,29 @@ void RetroFE::run( )
|
|||||||
SDL_Delay( static_cast<unsigned int>( sleepTime ) );
|
SDL_Delay( static_cast<unsigned int>( sleepTime ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if previous update of page needed to be rendered
|
// ------- Check if previous update of page needed to be rendered -------
|
||||||
if(!currentPage_->isIdle( ) || splashMode){
|
if(!currentPage_->isIdle( ) || splashMode){
|
||||||
must_render = true;
|
must_render = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle current pages updates
|
// Force refresh variables
|
||||||
|
#ifdef PERIOD_FORCE_REFRESH
|
||||||
|
if(SDL_GetTicks() - ticks_last_refresh > PERIOD_FORCE_REFRESH){
|
||||||
|
must_render = true;
|
||||||
|
//printf("force render\n");
|
||||||
|
}
|
||||||
|
#endif //PERIOD_FORCE_REFRESH
|
||||||
|
|
||||||
|
// ------- Handle current pages updates -------
|
||||||
if ( currentPage_ )
|
if ( currentPage_ )
|
||||||
{
|
{
|
||||||
#ifndef REMOVE_TEST_FUNKEY
|
|
||||||
if (!splashMode)
|
|
||||||
{
|
|
||||||
attract_.update( deltaTime, *currentPage_ );
|
|
||||||
}
|
|
||||||
if ( menuMode_ )
|
|
||||||
{
|
|
||||||
attract_.reset( );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
currentPage_->update( deltaTime );
|
currentPage_->update( deltaTime );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Real render here
|
// ------- Real render here -------
|
||||||
if(must_render){
|
if(must_render){
|
||||||
render( );
|
render( );
|
||||||
|
ticks_last_refresh = SDL_GetTicks();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user