[Bf-blender-cvs] [22150eb4094] master: Animation player: Ensure new frames are displayed while dragging mouse

Sergey Sharybin noreply at git.blender.org
Fri Jul 6 17:15:50 CEST 2018


Commit: 22150eb4094ca4caf8c231ab137dcee9dc445bca
Author: Sergey Sharybin
Date:   Fri Jul 6 17:14:16 2018 +0200
Branches: master
https://developer.blender.org/rB22150eb4094ca4caf8c231ab137dcee9dc445bca

Animation player: Ensure new frames are displayed while dragging mouse

Thanks Campbell for review!

===================================================================

M	source/blender/windowmanager/intern/wm_playanim.c

===================================================================

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;



More information about the Bf-blender-cvs mailing list