[Bf-blender-cvs] [544f6dd] gooseberry: Animation scrubbing - optimization attempt

Antony Riakiotakis noreply at git.blender.org
Fri Apr 24 16:59:20 CEST 2015


Commit: 544f6dd9b6978e221b1c9ae9305d615bc0742a81
Author: Antony Riakiotakis
Date:   Fri Apr 24 16:58:59 2015 +0200
Branches: gooseberry
https://developer.blender.org/rB544f6dd9b6978e221b1c9ae9305d615bc0742a81

Animation scrubbing - optimization attempt

Experiment for animators to try - only do full notification of scene at
end of scrubbing, do only manual area update instead like we do for
animation. Also skip audio update unless we do audio scrubbing.

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

M	source/blender/editors/animation/anim_ops.c
M	source/blender/editors/include/ED_screen.h
M	source/blender/editors/screen/area.c
M	source/blender/editors/screen/screen_ops.c

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

diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c
index 47eafcb..22eda47 100644
--- a/source/blender/editors/animation/anim_ops.c
+++ b/source/blender/editors/animation/anim_ops.c
@@ -90,10 +90,11 @@ static int change_frame_poll(bContext *C)
 }
 
 /* Set the new frame number */
-static void change_frame_apply(bContext *C, wmOperator *op)
+static void change_frame_apply(bContext *C, wmOperator *op, bool final)
 {
 	Main *bmain = CTX_data_main(C);
 	Scene *scene = CTX_data_scene(C);
+	ARegion *ar_op = CTX_wm_region(C);
 	int frame = RNA_int_get(op->ptr, "frame");
 	bool do_snap = RNA_boolean_get(op->ptr, "snap");
 
@@ -107,8 +108,46 @@ static void change_frame_apply(bContext *C, wmOperator *op)
 	SUBFRA = 0.0f;
 	
 	/* do updates */
-	BKE_sound_seek_scene(bmain, scene);
-	WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
+
+	if (final) {
+		BKE_sound_seek_scene(bmain, scene);
+		WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
+	}
+	else
+	{
+		bScreen *screen = CTX_wm_screen(C);
+		wmWindowManager *wm = CTX_wm_manager(C);
+		wmWindow *window;
+		ScrArea *sa;
+		/* since we follow drawflags, we can't send notifier but tag regions ourselves */
+		/* only do audio if scrubbing */
+		if (scene->audio.flag & AUDIO_SCRUB)
+			BKE_sound_seek_scene(bmain, scene);
+
+		ED_update_for_newframe(bmain, scene, 1);
+
+		for (window = wm->windows.first; window; window = window->next) {
+			for (sa = window->screen->areabase.first; sa; sa = sa->next) {
+				ARegion *ar;
+				for (ar = sa->regionbase.first; ar; ar = ar->next) {
+					bool redraw = false;
+					if (ar == ar_op) {
+						redraw = true;
+					}
+					else if (ED_match_region_with_redraws(sa->spacetype, ar->regiontype, screen->redraws_flag)) {
+						redraw = true;
+					}
+
+					if (redraw) {
+						ED_region_tag_redraw(ar);
+					}
+				}
+
+				if (ED_match_area_with_refresh(sa->spacetype, SPACE_TIME))
+					ED_area_tag_refresh(sa);
+			}
+		}
+	}
 }
 
 /* ---- */
@@ -116,8 +155,7 @@ static void change_frame_apply(bContext *C, wmOperator *op)
 /* Non-modal callback for running operator without user input */
 static int change_frame_exec(bContext *C, wmOperator *op)
 {
-	change_frame_apply(C, op);
-
+	change_frame_apply(C, op, true);
 	return OPERATOR_FINISHED;
 }
 
@@ -174,7 +212,7 @@ static int change_frame_invoke(bContext *C, wmOperator *op, const wmEvent *event
 
 	change_frame_seq_preview_begin(C, event);
 
-	change_frame_apply(C, op);
+	change_frame_apply(C, op, false);
 	
 	/* add temp handler */
 	WM_event_add_modal_handler(C, op);
@@ -190,16 +228,20 @@ static void change_frame_cancel(bContext *C, wmOperator *UNUSED(op))
 /* Modal event handling of frame changing */
 static int change_frame_modal(bContext *C, wmOperator *op, const wmEvent *event)
 {
+	Main *bmain = CTX_data_main(C);
+	Scene *scene = CTX_data_scene(C);
 	int ret = OPERATOR_RUNNING_MODAL;
 	/* execute the events */
 	switch (event->type) {
 		case ESCKEY:
+			WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
+			BKE_sound_seek_scene(bmain, scene);
 			ret = OPERATOR_FINISHED;
 			break;
 
 		case MOUSEMOVE:
 			RNA_int_set(op->ptr, "frame", frame_from_event(C, event));
-			change_frame_apply(C, op);
+			change_frame_apply(C, op, false);
 			break;
 		
 		case LEFTMOUSE: 
@@ -208,8 +250,11 @@ static int change_frame_modal(bContext *C, wmOperator *op, const wmEvent *event)
 			/* we check for either mouse-button to end, as checking for ACTIONMOUSE (which is used to init 
 			 * the modal op) doesn't work for some reason
 			 */
-			if (event->val == KM_RELEASE)
+			if (event->val == KM_RELEASE) {
+				WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
+				BKE_sound_seek_scene(bmain, scene);
 				ret = OPERATOR_FINISHED;
+			}
 			break;
 
 		case LEFTCTRLKEY:
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h
index b22221b..3950ff1 100644
--- a/source/blender/editors/include/ED_screen.h
+++ b/source/blender/editors/include/ED_screen.h
@@ -74,6 +74,9 @@ void    ED_region_draw_backdrop_view3d(const struct bContext *C, struct Object *
 float	ED_region_blend_factor(struct ARegion *ar);
 void	ED_region_visible_rect(struct ARegion *ar, struct rcti *rect);
 
+int ED_match_area_with_refresh(int spacetype, int refresh);
+int ED_match_region_with_redraws(int spacetype, int regiontype, int redraws);
+
 
 /* spaces */
 void    ED_spacetypes_keymap(struct wmKeyConfig *keyconf);
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 4eab5e5..b7ad698 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -516,6 +516,100 @@ void ED_region_do_draw(bContext *C, ARegion *ar)
  * maybe silly, but let's try for now
  * to keep these tags protected
  * ********************************** */
+int ED_match_area_with_refresh(int spacetype, int refresh)
+{
+	switch (spacetype) {
+		case SPACE_TIME:
+			if (refresh & SPACE_TIME)
+				return 1;
+			break;
+	}
+
+	return 0;
+}
+
+int ED_match_region_with_redraws(int spacetype, int regiontype, int redraws)
+{
+	if (regiontype == RGN_TYPE_WINDOW) {
+
+		switch (spacetype) {
+			case SPACE_VIEW3D:
+				if (redraws & TIME_ALL_3D_WIN)
+					return 1;
+				break;
+			case SPACE_IPO:
+			case SPACE_ACTION:
+			case SPACE_NLA:
+				if (redraws & TIME_ALL_ANIM_WIN)
+					return 1;
+				break;
+			case SPACE_TIME:
+				/* if only 1 window or 3d windows, we do timeline too */
+				if (redraws & (TIME_ALL_ANIM_WIN | TIME_REGION | TIME_ALL_3D_WIN))
+					return 1;
+				break;
+			case SPACE_BUTS:
+				if (redraws & TIME_ALL_BUTS_WIN)
+					return 1;
+				break;
+			case SPACE_SEQ:
+				if (redraws & (TIME_SEQ | TIME_ALL_ANIM_WIN))
+					return 1;
+				break;
+			case SPACE_NODE:
+				if (redraws & (TIME_NODES))
+					return 1;
+				break;
+			case SPACE_IMAGE:
+				if (redraws & TIME_ALL_IMAGE_WIN)
+					return 1;
+				break;
+			case SPACE_CLIP:
+				if (redraws & TIME_CLIPS)
+					return 1;
+				break;
+
+		}
+	}
+	else if (regiontype == RGN_TYPE_CHANNELS) {
+		switch (spacetype) {
+			case SPACE_IPO:
+			case SPACE_ACTION:
+			case SPACE_NLA:
+				if (redraws & TIME_ALL_ANIM_WIN)
+					return 1;
+				break;
+		}
+	}
+	else if (regiontype == RGN_TYPE_UI) {
+		if (spacetype == SPACE_CLIP) {
+			/* Track Preview button is on Properties Editor in SpaceClip,
+			 * and it's very common case when users want it be refreshing
+			 * during playback, so asking people to enable special option
+			 * for this is a bit tricky, so add exception here for refreshing
+			 * Properties Editor for SpaceClip always */
+			return 1;
+		}
+
+		if (redraws & TIME_ALL_BUTS_WIN)
+			return 1;
+	}
+	else if (regiontype == RGN_TYPE_HEADER) {
+		if (spacetype == SPACE_TIME)
+			return 1;
+	}
+	else if (regiontype == RGN_TYPE_PREVIEW) {
+		switch (spacetype) {
+			case SPACE_SEQ:
+				if (redraws & (TIME_SEQ | TIME_ALL_ANIM_WIN))
+					return 1;
+				break;
+			case SPACE_CLIP:
+				return 1;
+		}
+	}
+	return 0;
+}
 
 void ED_region_tag_redraw(ARegion *ar)
 {
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index cd5057a..18845e9 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -3319,101 +3319,6 @@ static void SCREEN_OT_header_toolbox(wmOperatorType *ot)
 
 /* ****************** anim player, with timer ***************** */
 
-static int match_area_with_refresh(int spacetype, int refresh)
-{
-	switch (spacetype) {
-		case SPACE_TIME:
-			if (refresh & SPACE_TIME)
-				return 1;
-			break;
-	}
-	
-	return 0;
-}
-
-static int match_region_with_redraws(int spacetype, int regiontype, int redraws)
-{
-	if (regiontype == RGN_TYPE_WINDOW) {
-		
-		switch (spacetype) {
-			case SPACE_VIEW3D:
-				if (redraws & TIME_ALL_3D_WIN)
-					return 1;
-				break;
-			case SPACE_IPO:
-			case SPACE_ACTION:
-			case SPACE_NLA:
-				if (redraws & TIME_ALL_ANIM_WIN)
-					return 1;
-				break;
-			case SPACE_TIME:
-				/* if only 1 window or 3d windows, we do timeline too */
-				if (redraws & (TIME_ALL_ANIM_WIN | TIME_REGION | TIME_ALL_3D_WIN))
-					return 1;
-				break;
-			case SPACE_BUTS:
-				if (redraws & TIME_ALL_BUTS_WIN)
-					return 1;
-				break;
-			case SPACE_SEQ:
-				if (redraws & (TIME_SEQ | TIME_ALL_ANIM_WIN))
-					return 1;
-				break;
-			case SPACE_NODE:
-				if (redraws & (TIME_NODES))
-					return 1;
-				break;
-			case SPACE_IMAGE:
-				if (redraws & TIME_ALL_IMAGE_WIN)
-					return 1;
-				break;
-			case SPACE_CLIP:
-				if (redraws & TIME_CLIPS)
-					return 1;
-				break;
-				
-		}
-	}
-	else if (regiontype == RGN_TYPE_CHANNELS) {
-		switch (spacetype) {
-			case SPACE_IPO:
-			case SPACE_ACTION:
-			case SPACE_NLA:
-				if (redraws & TIME_ALL_ANIM_WIN)
-					return 1;
-				break;
-		}
-	}
-	else if (regiontype == RGN_TYPE_UI) {
-		if (spacetype == SPACE_CLIP) {
-			/* Track Preview button is on Properties Editor in SpaceClip,
-			 * and it's very common case when users want it be refreshing
-			 * during playback, so asking people to enable special option
-			 * for this is a bit tricky, so add exception here for refreshing
-			 * Properties Editor for SpaceClip always */
-			return 1;
-		}
-
-		if (redraws & TIME_ALL_BUTS_WIN)
-			return 1;
-	}
-	else if (regiontype == RGN_TYPE_HEADER) {
-		if (spacetype == SPACE_TIME)
-			return 1;
-	}
-	else if (regiontype == RGN_TYPE_PREVIEW) {
-		switch (spacetype) {
-			case SPACE_SEQ:
-				if (redraws & (TIME_SEQ | TIME_ALL_ANIM_WIN))
-					return 1;
-				break;
-			case SPACE_CLIP:
-				return 1;
-		}
-	}
-	return 0;
-}
-
 //#define PROFILE_AUDIO_SYNCH
 
 static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
@@ -3542,7 +3447,7 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv
 					if (ar == sad->ar) {
 						redraw = true;
 					}
-					else if (match_region_with_redraws(sa->spacetype, ar->regiontype, sad->redraws)) {
+					else if (ED_match_region_with_redraws(sa->spacetype, ar->regiontype, sad->redraws)) {
 						redraw = true;
 					}
 
@@ -3568,7 +3473,7 @@ static int screen_animation_step(bContext *C, wmOpera

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list