[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [48111] trunk/blender/source/blender/ editors: Cleanup up space clip API:

Sergey Sharybin sergey.vfx at gmail.com
Wed Jun 20 12:29:00 CEST 2012


Revision: 48111
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48111
Author:   nazgul
Date:     2012-06-20 10:28:51 +0000 (Wed, 20 Jun 2012)
Log Message:
-----------
Cleanup up space clip API:

- Remove clip/mask specific size/aspect getters, they shall just
  use the same size/aspect ratio.
- Made size getter (and some other public functions) accept context
  instead of SpaceClip. Currently only SpaceClip is being get from
  this context, but later it'll be helpful when adding support of
  editing mask without opening clip in clip editor (in this case
  using render resolution for mask would be ideal, but this
  requires knowing scene in size getter).
- Rearrange some functions in clip_editor.c for easier navigation
  in the file.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/include/ED_clip.h
    trunk/blender/source/blender/editors/mask/mask_edit.c
    trunk/blender/source/blender/editors/mask/mask_select.c
    trunk/blender/source/blender/editors/space_clip/clip_draw.c
    trunk/blender/source/blender/editors/space_clip/clip_editor.c
    trunk/blender/source/blender/editors/space_clip/clip_intern.h
    trunk/blender/source/blender/editors/space_clip/clip_ops.c
    trunk/blender/source/blender/editors/space_clip/clip_utils.c
    trunk/blender/source/blender/editors/space_clip/space_clip.c
    trunk/blender/source/blender/editors/space_clip/tracking_ops.c
    trunk/blender/source/blender/editors/space_clip/tracking_select.c
    trunk/blender/source/blender/editors/transform/transform.c
    trunk/blender/source/blender/editors/transform/transform_conversions.c

Modified: trunk/blender/source/blender/editors/include/ED_clip.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_clip.h	2012-06-20 10:03:02 UTC (rev 48110)
+++ trunk/blender/source/blender/editors/include/ED_clip.h	2012-06-20 10:28:51 UTC (rev 48111)
@@ -42,6 +42,8 @@
 struct wmEvent;
 
 /*  ** clip_editor.c ** */
+
+/* common poll functions */
 int ED_space_clip_poll(struct bContext *C);
 
 int ED_space_clip_view_clip_poll(struct bContext *C);
@@ -50,33 +52,29 @@
 int ED_space_clip_maskedit_poll(struct bContext *C);
 int ED_space_clip_maskedit_mask_poll(bContext *C);
 
-struct MovieClip *ED_space_clip_get_clip(struct SpaceClip *sc);
-void ED_space_clip_set_clip(struct bContext *C, struct bScreen *screen, struct SpaceClip *sc, struct MovieClip *clip);
+void ED_space_clip_get_size(const struct bContext *C, int *width, int *height);
+void ED_space_clip_get_zoom(const struct bContext *C, float *zoomx, float *zoomy);
+void ED_space_clip_get_aspect(struct SpaceClip *sc, float *aspx, float *aspy);
+void ED_space_clip_get_aspect_dimension_aware(struct SpaceClip *sc, float *aspx, float *aspy);
 
-void ED_space_clip_get_zoom(struct SpaceClip *sc, ARegion *ar, float *zoomx, float *zoomy);
-
-void ED_space_clip_get_clip_size(struct SpaceClip *sc, int *width, int *height);
-void ED_space_clip_get_clip_aspect(struct SpaceClip *sc, float *aspx, float *aspy);
-void ED_space_clip_get_clip_aspect_dimension_aware(struct SpaceClip *sc, float *aspx, float *aspy);
-
 int ED_space_clip_get_clip_frame_number(struct SpaceClip *sc);
 
 struct ImBuf *ED_space_clip_get_buffer(struct SpaceClip *sc);
 struct ImBuf *ED_space_clip_get_stable_buffer(struct SpaceClip *sc, float loc[2], float *scale, float *angle);
 
 void ED_clip_update_frame(const struct Main *mainp, int cfra);
-int ED_clip_view_selection(struct SpaceClip *sc, struct ARegion *ar, int fit);
+int ED_clip_view_selection(const struct bContext *C, struct ARegion *ar, int fit);
 
 void ED_clip_point_undistorted_pos(SpaceClip *sc, const float co[2], float r_co[2]);
 void ED_clip_point_stable_pos(const struct bContext *C, float x, float y, float *xr, float *yr);
-void ED_clip_point_stable_pos__reverse(SpaceClip *sc, ARegion *ar, const float co[2], float r_co[2]);
+void ED_clip_point_stable_pos__reverse(const struct bContext *C, const float co[2], float r_co[2]);
 void ED_clip_mouse_pos(const struct bContext *C, struct wmEvent *event, float co[2]);
 
 int ED_space_clip_check_show_trackedit(struct SpaceClip *sc);
 int ED_space_clip_check_show_maskedit(struct SpaceClip *sc);
 
-void ED_space_clip_get_mask_size(struct SpaceClip *sc, int *width, int *height);
-void ED_space_clip_get_mask_aspect(struct SpaceClip *sc, float *aspx, float *aspy);
+struct MovieClip *ED_space_clip_get_clip(struct SpaceClip *sc);
+void ED_space_clip_set_clip(struct bContext *C, struct bScreen *screen, struct SpaceClip *sc, struct MovieClip *clip);
 
 struct Mask *ED_space_clip_get_mask(struct SpaceClip *sc);
 void ED_space_clip_set_mask(struct bContext *C, struct SpaceClip *sc, struct Mask *mask);

Modified: trunk/blender/source/blender/editors/mask/mask_edit.c
===================================================================
--- trunk/blender/source/blender/editors/mask/mask_edit.c	2012-06-20 10:03:02 UTC (rev 48110)
+++ trunk/blender/source/blender/editors/mask/mask_edit.c	2012-06-20 10:28:51 UTC (rev 48111)
@@ -121,7 +121,7 @@
 		co[0] = x;
 		co[1] = y;
 		BKE_mask_coord_to_movieclip(sc->clip, &sc->user, co, co);
-		ED_clip_point_stable_pos__reverse(sc, ar, co, co);
+		ED_clip_point_stable_pos__reverse(C, co, co);
 	}
 	else {
 		/* possible other spaces from which mask editing is available */
@@ -137,8 +137,7 @@
 	ScrArea *sa = CTX_wm_area(C);
 	if (sa && sa->spacedata.first) {
 		if (sa->spacetype == SPACE_CLIP) {
-			SpaceClip *sc = sa->spacedata.first;
-			ED_space_clip_get_mask_size(sc, width, height);
+			ED_space_clip_get_size(C, width, height);
 			return;
 		}
 		else if (sa->spacetype == SPACE_SEQ) {
@@ -159,7 +158,7 @@
 	SpaceClip *sc = CTX_wm_space_clip(C);
 
 	if (sc) {
-		ED_space_clip_get_mask_aspect(sc, aspx, aspy);
+		ED_space_clip_get_aspect(sc, aspx, aspy);
 	}
 	else {
 		/* possible other spaces from which mask editing is available */
@@ -173,13 +172,12 @@
 	SpaceClip *sc = CTX_wm_space_clip(C);
 
 	if (sc) {
-		ARegion *ar = CTX_wm_region(C);
 		int width, height;
 		float zoomx, zoomy, aspx, aspy;
 
-		ED_space_clip_get_clip_size(sc, &width, &height);
-		ED_space_clip_get_zoom(sc, ar, &zoomx, &zoomy);
-		ED_space_clip_get_clip_aspect(sc, &aspx, &aspy);
+		ED_space_clip_get_size(C, &width, &height);
+		ED_space_clip_get_zoom(C, &zoomx, &zoomy);
+		ED_space_clip_get_aspect(sc, &aspx, &aspy);
 
 		*scalex = ((float)width * aspx) * zoomx;
 		*scaley = ((float)height * aspy) * zoomy;

Modified: trunk/blender/source/blender/editors/mask/mask_select.c
===================================================================
--- trunk/blender/source/blender/editors/mask/mask_select.c	2012-06-20 10:03:02 UTC (rev 48110)
+++ trunk/blender/source/blender/editors/mask/mask_select.c	2012-06-20 10:28:51 UTC (rev 48111)
@@ -581,8 +581,6 @@
 	MaskLayer *masklay;
 	int i;
 
-	SpaceClip *sc = CTX_wm_space_clip(C);
-	ARegion *ar = CTX_wm_region(C);
 	int x, y, radius, width, height, mode, change = FALSE;
 	float zoomx, zoomy, offset[2], ellipse[2];
 
@@ -595,8 +593,8 @@
 
 	/* TODO - make generic! - this is SpaceClip only! */
 	/* compute ellipse and position in unified coordinates */
-	ED_space_clip_get_clip_size(sc, &width, &height);
-	ED_space_clip_get_zoom(sc, ar, &zoomx, &zoomy);
+	ED_space_clip_get_size(C, &width, &height);
+	ED_space_clip_get_zoom(C, &zoomx, &zoomy);
 	width = height = MAX2(width, height);
 
 	ellipse[0] = width * zoomx / radius;

Modified: trunk/blender/source/blender/editors/space_clip/clip_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_clip/clip_draw.c	2012-06-20 10:03:02 UTC (rev 48110)
+++ trunk/blender/source/blender/editors/space_clip/clip_draw.c	2012-06-20 10:28:51 UTC (rev 48111)
@@ -1408,20 +1408,24 @@
 	glPopMatrix();
 }
 
-void clip_draw_main(SpaceClip *sc, ARegion *ar, Scene *scene)
+void clip_draw_main(const bContext *C, ARegion *ar)
 {
+	SpaceClip *sc = CTX_wm_space_clip(C);
 	MovieClip *clip = ED_space_clip_get_clip(sc);
+	Scene *scene = CTX_data_scene(C);
 	ImBuf *ibuf;
 	int width, height;
 	float zoomx, zoomy;
 
+	ED_space_clip_get_size(C, &width, &height);
+	ED_space_clip_get_zoom(C, &zoomx, &zoomy);
+
 	/* if no clip, nothing to do */
-	if (!clip)
+	if (!clip) {
+		ED_region_grid_draw(ar, zoomx, zoomy);
 		return;
+	}
 
-	ED_space_clip_get_clip_size(sc, &width, &height);
-	ED_space_clip_get_zoom(sc, ar, &zoomx, &zoomy);
-
 	if (sc->flag & SC_SHOW_STABLE) {
 		float smat[4][4], ismat[4][4];
 

Modified: trunk/blender/source/blender/editors/space_clip/clip_editor.c
===================================================================
--- trunk/blender/source/blender/editors/space_clip/clip_editor.c	2012-06-20 10:03:02 UTC (rev 48110)
+++ trunk/blender/source/blender/editors/space_clip/clip_editor.c	2012-06-20 10:28:51 UTC (rev 48111)
@@ -122,90 +122,12 @@
 	return FALSE;
 }
 
-/* ******** editing functions ******** */
+/* ******** common editing functions ******** */
 
-void ED_space_clip_set_clip(bContext *C, bScreen *screen, SpaceClip *sc, MovieClip *clip)
+void ED_space_clip_get_size(const bContext *C, int *width, int *height)
 {
-	MovieClip *old_clip;
+	SpaceClip *sc = CTX_wm_space_clip(C);
 
-	if (!screen && C)
-		screen = CTX_wm_screen(C);
-
-	old_clip = sc->clip;
-	sc->clip = clip;
-
-	if (sc->clip && sc->clip->id.us == 0)
-		sc->clip->id.us = 1;
-
-	if (screen && sc->view == SC_VIEW_CLIP) {
-		ScrArea *area;
-		SpaceLink *sl;
-
-		for (area = screen->areabase.first; area; area = area->next) {
-			for (sl = area->spacedata.first; sl; sl = sl->next) {
-				if (sl->spacetype == SPACE_CLIP) {
-					SpaceClip *cur_sc = (SpaceClip *) sl;
-
-					if (cur_sc != sc && cur_sc->view != SC_VIEW_CLIP) {
-						if (cur_sc->clip == old_clip || cur_sc->clip == NULL) {
-							cur_sc->clip = clip;
-						}
-					}
-				}
-			}
-		}
-	}
-
-	if (C)
-		WM_event_add_notifier(C, NC_MOVIECLIP | NA_SELECTED, sc->clip);
-}
-
-MovieClip *ED_space_clip_get_clip(SpaceClip *sc)
-{
-	return sc->clip;
-}
-
-Mask *ED_space_clip_get_mask(SpaceClip *sc)
-{
-	return sc->mask;
-}
-
-ImBuf *ED_space_clip_get_buffer(SpaceClip *sc)
-{
-	if (sc->clip) {
-		ImBuf *ibuf;
-
-		ibuf = BKE_movieclip_get_postprocessed_ibuf(sc->clip, &sc->user, sc->postproc_flag);
-
-		if (ibuf && (ibuf->rect || ibuf->rect_float))
-			return ibuf;
-
-		if (ibuf)
-			IMB_freeImBuf(ibuf);
-	}
-
-	return NULL;
-}
-
-ImBuf *ED_space_clip_get_stable_buffer(SpaceClip *sc, float loc[2], float *scale, float *angle)
-{
-	if (sc->clip) {
-		ImBuf *ibuf;
-
-		ibuf = BKE_movieclip_get_stable_ibuf(sc->clip, &sc->user, loc, scale, angle, sc->postproc_flag);
-
-		if (ibuf && (ibuf->rect || ibuf->rect_float))
-			return ibuf;
-
-		if (ibuf)
-			IMB_freeImBuf(ibuf);
-	}
-
-	return NULL;
-}
-
-void ED_space_clip_get_clip_size(SpaceClip *sc, int *width, int *height)
-{
 	if (!sc->clip) {
 		*width = *height = 0;
 	}
@@ -214,41 +136,26 @@
 	}
 }
 
-void ED_space_clip_get_mask_size(SpaceClip *sc, int *width, int *height)
+void ED_space_clip_get_zoom(const bContext *C, float *zoomx, float *zoomy)
 {
-	/* quite the same as ED_space_clip_size, but it also runs aspect correction on output resolution
-	 * this is needed because mask should be rasterized with exactly the same resolution as
-	 * currently displaying frame and it doesn't have access to aspect correction currently
-	 * used for display. (sergey)
-	 */
+	ARegion *ar = CTX_wm_region(C);
+	int width, height;
 
-	if (!sc->mask) {
-		*width = 0;
-		*height = 0;
-	} else {
-		float aspx, aspy;
+	ED_space_clip_get_size(C, &width, &height);
 
-		ED_space_clip_get_clip_size(sc, width, height);
-		ED_space_clip_get_clip_aspect(sc, &aspx, &aspy);
-
-		*width *= aspx;
-		*height *= aspy;
-	}
+	*zoomx = (float)(ar->winrct.xmax - ar->winrct.xmin + 1) / (float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin) * width);
+	*zoomy = (float)(ar->winrct.ymax - ar->winrct.ymin + 1) / (float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin) * height);
 }
 
-void ED_space_clip_get_mask_aspect(SpaceClip *sc, float *aspx, float *aspy)
+void ED_space_clip_get_aspect(SpaceClip *sc, float *aspx, float *aspy)
 {

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list