[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47578] trunk/blender/source/blender/ editors: Remove checks for valid frame from poll function in clip editor space

Sergey Sharybin sergey.vfx at gmail.com
Thu Jun 7 18:36:30 CEST 2012


Revision: 47578
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47578
Author:   nazgul
Date:     2012-06-07 16:36:19 +0000 (Thu, 07 Jun 2012)
Log Message:
-----------
Remove checks for valid frame from poll function in clip editor space

This results in some buttons not disabled when there's no currently displaying frame,
but this saves lots of cache lookups and threading loks for every frame update.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/include/ED_clip.h
    trunk/blender/source/blender/editors/space_clip/clip_editor.c
    trunk/blender/source/blender/editors/space_clip/tracking_ops.c

Modified: trunk/blender/source/blender/editors/include/ED_clip.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_clip.h	2012-06-07 16:15:24 UTC (rev 47577)
+++ trunk/blender/source/blender/editors/include/ED_clip.h	2012-06-07 16:36:19 UTC (rev 47578)
@@ -47,8 +47,6 @@
 int ED_space_clip_view_clip_poll(struct bContext *C);
 
 int ED_space_clip_tracking_poll(struct bContext *C);
-int ED_space_clip_tracking_size_poll(struct bContext *C);
-int ED_space_clip_tracking_frame_poll(struct bContext *C);
 int ED_space_clip_maskedit_poll(struct bContext *C);
 int ED_space_clip_maskedit_mask_poll(bContext *C);
 

Modified: trunk/blender/source/blender/editors/space_clip/clip_editor.c
===================================================================
--- trunk/blender/source/blender/editors/space_clip/clip_editor.c	2012-06-07 16:15:24 UTC (rev 47577)
+++ trunk/blender/source/blender/editors/space_clip/clip_editor.c	2012-06-07 16:36:19 UTC (rev 47578)
@@ -96,39 +96,6 @@
 	return FALSE;
 }
 
-int ED_space_clip_tracking_size_poll(bContext *C)
-{
-	if (ED_space_clip_tracking_poll(C)) {
-		MovieClip *clip = CTX_data_edit_movieclip(C);
-
-		if (clip) {
-			SpaceClip *sc = CTX_wm_space_clip(C);
-			int width, height;
-
-			BKE_movieclip_get_size(clip, &sc->user, &width, &height);
-
-			return width > 0 && height > 0;
-		}
-	}
-
-	return FALSE;
-}
-
-int ED_space_clip_tracking_frame_poll(bContext *C)
-{
-	if (ED_space_clip_tracking_poll(C)) {
-		MovieClip *clip = CTX_data_edit_movieclip(C);
-
-		if (clip) {
-			SpaceClip *sc = CTX_wm_space_clip(C);
-
-			return BKE_movieclip_has_frame(clip, &sc->user);
-		}
-	}
-
-	return FALSE;
-}
-
 int ED_space_clip_maskedit_poll(bContext *C)
 {
 	SpaceClip *sc = CTX_wm_space_clip(C);

Modified: trunk/blender/source/blender/editors/space_clip/tracking_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_clip/tracking_ops.c	2012-06-07 16:15:24 UTC (rev 47577)
+++ trunk/blender/source/blender/editors/space_clip/tracking_ops.c	2012-06-07 16:36:19 UTC (rev 47578)
@@ -107,6 +107,7 @@
 	int width, height;
 
 	ED_space_clip_size(sc, &width, &height);
+
 	if (!width || !height)
 		return OPERATOR_CANCELLED;
 
@@ -144,7 +145,7 @@
 	/* api callbacks */
 	ot->invoke = add_marker_invoke;
 	ot->exec = add_marker_exec;
-	ot->poll = ED_space_clip_tracking_size_poll;
+	ot->poll = ED_space_clip_tracking_poll;
 
 	/* flags */
 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -638,7 +639,7 @@
 	ot->idname = "CLIP_OT_slide_marker";
 
 	/* api callbacks */
-	ot->poll = ED_space_clip_tracking_size_poll;
+	ot->poll = ED_space_clip_tracking_poll;
 	ot->invoke = slide_marker_invoke;
 	ot->modal = slide_marker_modal;
 
@@ -1308,7 +1309,7 @@
 
 	/* api callbacks */
 	ot->exec = select_groped_exec;
-	ot->poll = ED_space_clip_tracking_size_poll;
+	ot->poll = ED_space_clip_tracking_poll;
 
 	/* flags */
 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1693,7 +1694,7 @@
 	/* api callbacks */
 	ot->exec = track_markers_exec;
 	ot->invoke = track_markers_invoke;
-	ot->poll = ED_space_clip_tracking_frame_poll;
+	ot->poll = ED_space_clip_tracking_poll;
 	ot->modal = track_markers_modal;
 
 	/* flags */
@@ -2134,20 +2135,18 @@
 
 static int set_orientation_poll(bContext *C)
 {
-	if (ED_space_clip_tracking_size_poll(C)) {
-		Scene *scene = CTX_data_scene(C);
-		SpaceClip *sc = CTX_wm_space_clip(C);
-		MovieClip *clip = ED_space_clip(sc);
-		MovieTracking *tracking = &clip->tracking;
-		MovieTrackingObject *tracking_object = BKE_tracking_active_object(tracking);
+	Scene *scene = CTX_data_scene(C);
+	SpaceClip *sc = CTX_wm_space_clip(C);
+	MovieClip *clip = ED_space_clip(sc);
+	MovieTracking *tracking = &clip->tracking;
+	MovieTrackingObject *tracking_object = BKE_tracking_active_object(tracking);
 
-		if (tracking_object->flag & TRACKING_OBJECT_CAMERA) {
-			return TRUE;
-		}
-		else {
-			return OBACT != NULL;
-		}
+	if (tracking_object->flag & TRACKING_OBJECT_CAMERA) {
+		return TRUE;
 	}
+	else {
+		return OBACT != NULL;
+	}
 
 	return FALSE;
 }
@@ -2744,16 +2743,12 @@
 
 static int set_solution_scale_poll(bContext *C)
 {
-	if (ED_space_clip_tracking_size_poll(C)) {
-		SpaceClip *sc = CTX_wm_space_clip(C);
-		MovieClip *clip = ED_space_clip(sc);
-		MovieTracking *tracking = &clip->tracking;
-		MovieTrackingObject *tracking_object = BKE_tracking_active_object(tracking);
+	SpaceClip *sc = CTX_wm_space_clip(C);
+	MovieClip *clip = ED_space_clip(sc);
+	MovieTracking *tracking = &clip->tracking;
+	MovieTrackingObject *tracking_object = BKE_tracking_active_object(tracking);
 
-		return (tracking_object->flag & TRACKING_OBJECT_CAMERA) == 0;
-	}
-
-	return 0;
+	return (tracking_object->flag & TRACKING_OBJECT_CAMERA) == 0;
 }
 
 static int set_solution_scale_exec(bContext *C, wmOperator *op)
@@ -2963,6 +2958,11 @@
 	int framenr = ED_space_clip_clip_framenr(sc);
 	bGPDlayer *layer = NULL;
 
+	if (!ibuf) {
+		BKE_report(op->reports, RPT_ERROR, "Feature detection requires valid clip frame");
+		return OPERATOR_CANCELLED;
+	}
+
 	if (placement != 0) {
 		layer = detect_get_layer(clip);
 		place_outside_layer = placement == 2;
@@ -3003,7 +3003,7 @@
 
 	/* api callbacks */
 	ot->exec = detect_features_exec;
-	ot->poll = ED_space_clip_tracking_frame_poll;
+	ot->poll = ED_space_clip_tracking_poll;
 
 	/* flags */
 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -3156,7 +3156,7 @@
 
 	/* api callbacks */
 	ot->exec = join_tracks_exec;
-	ot->poll = ED_space_clip_tracking_size_poll;
+	ot->poll = ED_space_clip_tracking_poll;
 
 	/* flags */
 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;




More information about the Bf-blender-cvs mailing list