-Bring back the adaptive sleeping in the main engine. Still using static 20ms sleep in idle waiting loops (when mouse doesn't move)

-Discontinuous freehand now uses an asynchronous method for delaying. It is sensitive to the delay set in the airbrush/spray menu.


git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@802 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Adrien Destugues
2009-05-12 22:16:05 +00:00
parent fe637a504c
commit ce812e481d
3 changed files with 43 additions and 18 deletions

View File

@@ -895,8 +895,24 @@ void Main_handler(void)
}
}
}
else SDL_Delay(20); // S'il n'y a pas d'évènement, on ne gère pas tout ça et on attend un peu. La partie en dessous doit être exécutée quand
// même pour les trucs asynchrones, par exemple le spray.
else
{
// No event : we go asleep for a while, but we try to get waked up at constant intervals of time
// no matter the machine speed or system load. The time is fixed to 10ms (that should be about a cpu slice on most systems)
// This allows nice smooth mouse movement.
const int delay = 10;
Uint32 debut;
debut = SDL_GetTicks();
// Première attente : le complément de "delay" millisecondes
SDL_Delay(delay - (debut % delay));
// Si ça ne suffit pas, on complète par des attentes successives de "1ms".
// (Remarque, Windows arrondit généralement aux 10ms supérieures)
while ( SDL_GetTicks()/delay <= debut/delay)
{
SDL_Delay(1);
}
}
// Gestion de la souris