-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:
parent
fe637a504c
commit
ce812e481d
@ -135,7 +135,7 @@ void Button_Message_initial(void)
|
|||||||
|
|
||||||
Display_cursor();
|
Display_cursor();
|
||||||
|
|
||||||
while(!Get_input() && !Mouse_K && !Key) SDL_Delay(20);
|
while(!Mouse_K && !Key) if(!Get_input()) SDL_Delay(20);
|
||||||
if (Mouse_K)
|
if (Mouse_K)
|
||||||
Wait_end_of_click();
|
Wait_end_of_click();
|
||||||
|
|
||||||
|
|||||||
20
engine.c
20
engine.c
@ -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
|
else
|
||||||
// même pour les trucs asynchrones, par exemple le spray.
|
{
|
||||||
|
// 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
|
// Gestion de la souris
|
||||||
|
|
||||||
|
|||||||
39
operatio.c
39
operatio.c
@ -39,6 +39,9 @@
|
|||||||
#define M_PI 3.14159265358979323846
|
#define M_PI 3.14159265358979323846
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/// Time (in SDL ticks) when the next airbrush drawing should be done. Also used for discontinuous freehand drawing.
|
||||||
|
Uint32 Airbrush_next_time;
|
||||||
|
|
||||||
void Start_operation_stack(word new_operation)
|
void Start_operation_stack(word new_operation)
|
||||||
{
|
{
|
||||||
Brush_rotation_center_is_defined=0;
|
Brush_rotation_center_is_defined=0;
|
||||||
@ -300,7 +303,7 @@ void Freehand_mode2_1_0(void)
|
|||||||
Operation_push(Paintbrush_X);
|
Operation_push(Paintbrush_X);
|
||||||
Operation_push(Paintbrush_Y);
|
Operation_push(Paintbrush_Y);
|
||||||
Print_coordinates();
|
Print_coordinates();
|
||||||
SDL_Delay(20);
|
Airbrush_next_time = SDL_GetTicks() + Airbrush_delay*10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -319,18 +322,22 @@ void Freehand_mode2_1_2(void)
|
|||||||
|
|
||||||
if ( (start_x!=Paintbrush_X) || (start_y!=Paintbrush_Y) )
|
if ( (start_x!=Paintbrush_X) || (start_y!=Paintbrush_Y) )
|
||||||
{
|
{
|
||||||
Hide_cursor();
|
|
||||||
// On affiche définitivement le pinceau
|
|
||||||
Display_paintbrush(Paintbrush_X,Paintbrush_Y,Fore_color,0);
|
|
||||||
Display_cursor();
|
|
||||||
Print_coordinates();
|
Print_coordinates();
|
||||||
SDL_Delay(20);
|
if (SDL_GetTicks()>Airbrush_next_time)
|
||||||
|
{
|
||||||
|
Airbrush_next_time+=Airbrush_delay*10;
|
||||||
|
Hide_cursor();
|
||||||
|
// On affiche définitivement le pinceau
|
||||||
|
Display_paintbrush(Paintbrush_X,Paintbrush_Y,Fore_color,0);
|
||||||
|
Display_cursor();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Operation_push(Paintbrush_X);
|
Operation_push(Paintbrush_X);
|
||||||
Operation_push(Paintbrush_Y);
|
Operation_push(Paintbrush_Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------
|
||||||
|
|
||||||
void Freehand_mode2_2_0(void)
|
void Freehand_mode2_2_0(void)
|
||||||
// Opération : OPERATION_DISCONTINUOUS_DRAW
|
// Opération : OPERATION_DISCONTINUOUS_DRAW
|
||||||
@ -342,12 +349,12 @@ void Freehand_mode2_2_0(void)
|
|||||||
Init_start_operation();
|
Init_start_operation();
|
||||||
Backup();
|
Backup();
|
||||||
Shade_table=Shade_table_right;
|
Shade_table=Shade_table_right;
|
||||||
// On affiche définitivement le pinceau
|
|
||||||
Display_paintbrush(Paintbrush_X,Paintbrush_Y,Back_color,0);
|
|
||||||
Operation_push(Paintbrush_X);
|
Operation_push(Paintbrush_X);
|
||||||
Operation_push(Paintbrush_Y);
|
Operation_push(Paintbrush_Y);
|
||||||
Print_coordinates();
|
Print_coordinates();
|
||||||
SDL_Delay(20);
|
Airbrush_next_time = SDL_GetTicks() + Airbrush_delay*10;
|
||||||
|
// On affiche définitivement le pinceau
|
||||||
|
Display_paintbrush(Paintbrush_X,Paintbrush_Y,Back_color,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -366,12 +373,15 @@ void Freehand_mode2_2_2(void)
|
|||||||
|
|
||||||
if ( (start_x!=Paintbrush_X) || (start_y!=Paintbrush_Y) )
|
if ( (start_x!=Paintbrush_X) || (start_y!=Paintbrush_Y) )
|
||||||
{
|
{
|
||||||
Hide_cursor();
|
|
||||||
// On affiche définitivement le pinceau
|
|
||||||
Display_paintbrush(Paintbrush_X,Paintbrush_Y,Back_color,0);
|
|
||||||
Display_cursor();
|
|
||||||
Print_coordinates();
|
Print_coordinates();
|
||||||
SDL_Delay(20);
|
if (SDL_GetTicks()>Airbrush_next_time)
|
||||||
|
{
|
||||||
|
Airbrush_next_time+=Airbrush_delay*10;
|
||||||
|
Hide_cursor();
|
||||||
|
// On affiche définitivement le pinceau
|
||||||
|
Display_paintbrush(Paintbrush_X,Paintbrush_Y,Back_color,0);
|
||||||
|
Display_cursor();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Operation_push(Paintbrush_X);
|
Operation_push(Paintbrush_X);
|
||||||
@ -2042,7 +2052,6 @@ void Curve_3_points_12_11(void)
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////// OPERATION_AIRBRUSH
|
///////////////////////////////////////////////////////////// OPERATION_AIRBRUSH
|
||||||
|
|
||||||
Uint32 Airbrush_next_time;
|
|
||||||
void Airbrush_1_0(void)
|
void Airbrush_1_0(void)
|
||||||
//
|
//
|
||||||
// Opération : OPERATION_AIRBRUSH
|
// Opération : OPERATION_AIRBRUSH
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user