diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/windowmanager/intern/wm_playanim.c | 52 |
1 files changed, 31 insertions, 21 deletions
diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index d9d5bf901ca..b4f2435ee2d 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -132,6 +132,9 @@ typedef struct PlayState { /* restarts player for file drop */ char dropped_file[FILE_MAX]; + + bool need_frame_update; + int frame_cursor_x; } PlayState; /* for debugging */ @@ -548,8 +551,18 @@ static void update_sound_fps(void) #endif } -static void change_frame(PlayState *ps, int cx) +static void tag_change_frame(PlayState *ps, int cx) +{ + ps->need_frame_update = true; + ps->frame_cursor_x = cx; +} + +static void change_frame(PlayState *ps) { + if (!ps->need_frame_update) { + return; + } + int sizex, sizey; int i, i_last; @@ -559,7 +572,7 @@ static void change_frame(PlayState *ps, int cx) playanim_window_get_size(&sizex, &sizey); i_last = ((struct PlayAnimPict *)picsbase.last)->frame; - i = (i_last * cx) / sizex; + i = (i_last * ps->frame_cursor_x) / sizex; CLAMP(i, 0, i_last); #ifdef WITH_AUDASPACE @@ -600,6 +613,8 @@ static void change_frame(PlayState *ps, int cx) ps->sstep = true; ps->wait2 = false; ps->next_frame = 0; + + ps->need_frame_update = false; } static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void) @@ -951,7 +966,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void) if (type == GHOST_kEventButtonDown) { if (inside_window) { g_WS.qual |= WS_QUAL_LMOUSE; - change_frame(ps, cx); + tag_change_frame(ps, cx); } } else @@ -996,7 +1011,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void) GHOST_ScreenToClient(g_WS.ghost_window, cd->x, cd->y, &cx, &cy); - change_frame(ps, cx); + tag_change_frame(ps, cx); } break; } @@ -1428,23 +1443,18 @@ static char *wm_main_playanim_intern(int argc, const char **argv) ps.next_frame = ps.direction; - while ((hasevent = GHOST_ProcessEvents(g_WS.ghost_system, ps.wait2))) { - if (hasevent) { - GHOST_DispatchEvents(g_WS.ghost_system); - } - /* Note, this still draws for mousemoves on pause */ - if (ps.wait2) { - if (hasevent) { - if (ibuf) { - while (pupdate_time()) PIL_sleep_ms(1); - ptottime -= swaptime; - playanim_toscreen(&ps, ps.picture, ibuf, ps.fontid, ps.fstep); - } - } - } - if (ps.go == false) { - break; - } + while ((hasevent = GHOST_ProcessEvents(g_WS.ghost_system, 0))) { + GHOST_DispatchEvents(g_WS.ghost_system); + } + if (ps.go == false) { + break; + } + change_frame(&ps); + if (!hasevent) { + PIL_sleep_ms(1); + } + if (ps.wait2) { + continue; } ps.wait2 = ps.sstep; |