[Bf-blender-cvs] [711e2f7] master: Support displaying metadata for images in sequencer preview windows (not backdrop)

Antony Riakiotakis noreply at git.blender.org
Mon May 4 12:18:37 CEST 2015


Commit: 711e2f71a80923e0b1d5acc0b6634c0b326238b6
Author: Antony Riakiotakis
Date:   Mon May 4 12:17:49 2015 +0200
Branches: master
https://developer.blender.org/rB711e2f71a80923e0b1d5acc0b6634c0b326238b6

Support displaying metadata for images in sequencer preview windows (not
backdrop)

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

M	release/scripts/startup/bl_ui/space_sequencer.py
M	source/blender/blenkernel/intern/sequencer.c
M	source/blender/editors/include/ED_screen.h
M	source/blender/editors/screen/area.c
M	source/blender/editors/space_image/image_draw.c
M	source/blender/editors/space_sequencer/sequencer_draw.c
M	source/blender/makesdna/DNA_space_types.h
M	source/blender/makesrna/intern/rna_space.c
M	source/blender/makesrna/intern/rna_userdef.c

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

diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py
index 3aed000..0d512b2 100644
--- a/release/scripts/startup/bl_ui/space_sequencer.py
+++ b/release/scripts/startup/bl_ui/space_sequencer.py
@@ -207,6 +207,7 @@ class SEQUENCER_MT_view(Menu):
         if is_preview:
             if st.display_mode == 'IMAGE':
                 layout.prop(st, "show_safe_areas")
+                layout.prop(st, "show_metadata")
             elif st.display_mode == 'WAVEFORM':
                 layout.prop(st, "show_separate_color")
 
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index d189351..f31d30b 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -2423,6 +2423,7 @@ static ImBuf *input_preprocess(const SeqRenderData *context, Sequence *seq, floa
 			IMB_rectcpy(i, ibuf, t.xofs, t.yofs, c.left, c.bottom, sx, sy);
 			sequencer_imbuf_assign_spaces(scene, i);
 
+			IMB_metadata_copy(i, ibuf);
 			IMB_freeImBuf(ibuf);
 
 			ibuf = i;
@@ -2474,6 +2475,7 @@ static ImBuf *input_preprocess(const SeqRenderData *context, Sequence *seq, floa
 		ImBuf *ibuf_new = BKE_sequence_modifier_apply_stack(context, seq, ibuf, cfra);
 
 		if (ibuf_new != ibuf) {
+			IMB_metadata_copy(ibuf_new, ibuf);
 			IMB_freeImBuf(ibuf);
 			ibuf = ibuf_new;
 		}
@@ -2496,6 +2498,7 @@ static ImBuf *copy_from_ibuf_still(const SeqRenderData *context, Sequence *seq,
 
 	if (ibuf) {
 		rval = IMB_dupImBuf(ibuf);
+		IMB_metadata_copy(rval, ibuf);
 		IMB_freeImBuf(ibuf);
 	}
 
@@ -2509,9 +2512,11 @@ static void copy_to_ibuf_still(const SeqRenderData *context, Sequence *seq, floa
 		/* we have to store a copy, since the passed ibuf
 		 * could be preprocessed afterwards (thereby silently
 		 * changing the cached image... */
-		ibuf = IMB_dupImBuf(ibuf);
+		ImBuf *oibuf = ibuf;
+		ibuf = IMB_dupImBuf(oibuf);
 
 		if (ibuf) {
+			IMB_metadata_copy(ibuf, oibuf);
 			sequencer_imbuf_assign_spaces(context->scene, ibuf);
 		}
 
@@ -2721,7 +2726,7 @@ static ImBuf *seq_render_image_strip(const SeqRenderData *context, Sequence *seq
 		BLI_path_abs(name, G.main->name);
 	}
 
-	flag = IB_rect;
+	flag = IB_rect | IB_metadata;
 	if (seq->alpha_mode == SEQ_ALPHA_PREMUL)
 		flag |= IB_alphamode_premul;
 
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h
index 8de9a7f..7f6679b 100644
--- a/source/blender/editors/include/ED_screen.h
+++ b/source/blender/editors/include/ED_screen.h
@@ -66,7 +66,7 @@ void    ED_region_header_init(struct ARegion *ar);
 void    ED_region_header(const struct bContext *C, struct ARegion *ar);
 void    ED_region_toggle_hidden(struct bContext *C, struct ARegion *ar);
 void    ED_region_info_draw(struct ARegion *ar, const char *text, int block, float fill_color[4]);
-void    ED_region_image_metadata_draw(struct ARegion *ar, struct ImBuf *ibuf, float zoomx, float zoomy);
+void    ED_region_image_metadata_draw(int x, int y, struct ImBuf *ibuf, rctf frame, float zoomx, float zoomy);
 void    ED_region_grid_draw(struct ARegion *ar, float zoomx, float zoomy);
 float	ED_region_blend_factor(struct ARegion *ar);
 void	ED_region_visible_rect(struct ARegion *ar, struct rcti *rect);
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 0bd05b8..89b6d3b 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -2088,7 +2088,7 @@ BLI_INLINE bool metadata_is_valid(ImBuf *ibuf, char *r_str, short index, int off
 	return (IMB_metadata_get_field(ibuf, meta_data_list[index], r_str + offset, MAX_METADATA_STR - offset) && r_str[0]);
 }
 
-static void metadata_draw_imbuf(ImBuf *ibuf, rcti rect, int fontid, const bool is_top)
+static void metadata_draw_imbuf(ImBuf *ibuf, rctf rect, int fontid, const bool is_top)
 {
 	char temp_str[MAX_METADATA_STR];
 	int line_width;
@@ -2192,19 +2192,16 @@ static float metadata_box_height_get(ImBuf *ibuf, int fontid, const bool is_top)
 
 #undef MAX_METADATA_STR
 
-void ED_region_image_metadata_draw(ARegion *ar, ImBuf *ibuf, float zoomx, float zoomy)
+void ED_region_image_metadata_draw(int x, int y, ImBuf *ibuf, rctf frame, float zoomx, float zoomy)
 {
 	float box_y;
-	rcti rect;
-	int x, y;
+	rctf rect;
 	uiStyle *style = UI_style_get_dpi();
 
 	if (!ibuf->metadata)
 		return;
 
 	/* find window pixel coordinates of origin */
-	UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &x, &y);
-
 	glPushMatrix();
 
 	/* offset and zoom using ogl */
@@ -2222,9 +2219,9 @@ void ED_region_image_metadata_draw(ARegion *ar, ImBuf *ibuf, float zoomx, float
 		UI_ThemeColor(TH_METADATA_BG);
 
 		/* set up rect */
-		BLI_rcti_init(&rect, 0, ibuf->x, ibuf->y, ibuf->y + box_y);
+		BLI_rctf_init(&rect, frame.xmin, frame.xmax, frame.ymax, frame.ymax + box_y);
 		/* draw top box */
-		glRecti(rect.xmin, rect.ymin, rect.xmax, rect.ymax);
+		glRectf(rect.xmin, rect.ymin, rect.xmax, rect.ymax);
 
 		BLF_clipping(blf_mono_font, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
 		BLF_enable(blf_mono_font, BLF_CLIPPING);
@@ -2244,9 +2241,9 @@ void ED_region_image_metadata_draw(ARegion *ar, ImBuf *ibuf, float zoomx, float
 		UI_ThemeColor(TH_METADATA_BG);
 
 		/* set up box rect */
-		BLI_rcti_init(&rect, 0, ibuf->x, -box_y, 0);
+		BLI_rctf_init(&rect, frame.xmin, frame.xmax, frame.ymin - box_y, frame.ymin);
 		/* draw top box */
-		glRecti(rect.xmin, rect.ymin, rect.xmax, rect.ymax);
+		glRectf(rect.xmin, rect.ymin, rect.xmax, rect.ymax);
 
 		BLF_clipping(blf_mono_font, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
 		BLF_enable(blf_mono_font, BLF_CLIPPING);
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c
index 04e874b..36419cc 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -848,8 +848,15 @@ void draw_image_main(const bContext *C, ARegion *ar)
 		else
 			draw_image_buffer(C, sima, ar, scene, ibuf, 0.0f, 0.0f, zoomx, zoomy);
 		
-		if (sima->flag & SI_DRAW_METADATA)
-			ED_region_image_metadata_draw(ar, ibuf, zoomx, zoomy);
+		if (sima->flag & SI_DRAW_METADATA) {
+			int x, y;
+			rctf frame;
+
+			BLI_rctf_init(&frame, 0.0f, ibuf->x, 0.0f, ibuf->y);
+			UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &x, &y);
+
+			ED_region_image_metadata_draw(x, y, ibuf, frame, zoomx, zoomy);
+		}
 	}
 
 	ED_space_image_release_buffer(sima, ibuf, lock);
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index abe2e86..0c811ca 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -63,6 +63,7 @@
 #include "ED_markers.h"
 #include "ED_mask.h"
 #include "ED_sequencer.h"
+#include "ED_screen.h"
 #include "ED_space_api.h"
 
 #include "UI_interface.h"
@@ -1068,6 +1069,7 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
 	bool glsl_used = false;
 	const bool draw_gpencil = ((sseq->flag & SEQ_SHOW_GPENCIL) && sseq->gpd);
 	const char *names[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME};
+	bool draw_metadata = false;
 
 	if (G.is_rendering == false && (scene->r.seq_flag & R_SEQ_GL_PREV) == 0) {
 		/* stop all running jobs, except screen one. currently previews frustrate Render
@@ -1303,10 +1305,12 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
 		}
 	}
 	else if (draw_backdrop) {
-		float aspect = BLI_rcti_size_x(&ar->winrct) / (float)BLI_rcti_size_y(&ar->winrct);	
+		float aspect;
 		float image_aspect = viewrect[0] / viewrect[1];
 		float imagex, imagey;
-		
+
+		aspect = BLI_rcti_size_x(&ar->winrct) / (float)BLI_rcti_size_y(&ar->winrct);
+
 		if (aspect >= image_aspect) {
 			imagex = image_aspect / aspect;
 			imagey = 1.0f;
@@ -1315,28 +1319,22 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
 			imagex = 1.0f;
 			imagey = aspect / image_aspect;
 		}
-		
+
 		glTexCoord2f(0.0f, 0.0f); glVertex2f(-imagex, -imagey);
 		glTexCoord2f(0.0f, 1.0f); glVertex2f(-imagex, imagey);
 		glTexCoord2f(1.0f, 1.0f); glVertex2f(imagex, imagey);
 		glTexCoord2f(1.0f, 0.0f); glVertex2f(imagex, -imagey);
 	}
 	else {
+		draw_metadata = ((sseq->flag & SEQ_SHOW_METADATA) != 0);
+
 		glTexCoord2f(0.0f, 0.0f); glVertex2f(v2d->tot.xmin, v2d->tot.ymin);
 		glTexCoord2f(0.0f, 1.0f); glVertex2f(v2d->tot.xmin, v2d->tot.ymax);
 		glTexCoord2f(1.0f, 1.0f); glVertex2f(v2d->tot.xmax, v2d->tot.ymax);
 		glTexCoord2f(1.0f, 0.0f); glVertex2f(v2d->tot.xmax, v2d->tot.ymin);
 	}
 	glEnd();
-	
-	if (draw_backdrop) {
-		glPopMatrix();
-		glMatrixMode(GL_PROJECTION);
-		glPopMatrix();
-		glMatrixMode(GL_MODELVIEW);
-		
-	}
-	
+
 	glBindTexture(GL_TEXTURE_2D, last_texid);
 	glDisable(GL_TEXTURE_2D);
 	if (sseq->mainb == SEQ_DRAW_IMG_IMBUF && sseq->flag & SEQ_USE_ALPHA)
@@ -1352,7 +1350,15 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
 	if (!scope)
 		IMB_freeImBuf(ibuf);
 
+	if (draw_metadata) {
+		ED_region_image_metadata_draw(0.0, 0.0, ibuf, v2d->tot, 1.0, 1.0);
+	}
+
 	if (draw_backdrop) {
+		glPopMatrix();
+		glMatrixMode(GL_PROJECTION);
+		glPopMatrix();
+		glMatrixMode(GL_MODELVIEW);
 		return;
 	}
 
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index 075995c..d6785da 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -534,6 +534,7 @@ typedef enum eSpaceSeq_Flag {
 	SEQ_ALL_WAVEFORMS           = (1 << 7), /* draw all waveforms */
 	SEQ_NO_WAVEFORMS            = (1 << 8), /* draw no waveforms */
 	SEQ_SHOW_SAFE_CENTER        = (1 << 9),
+	SEQ_SHOW_METADATA           = (1 << 10),
 } eSpaceSeq_Flag;
 
 /* sseq->view */
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index b02c69c..2b7ed3d 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -3074,6 +3074,11 @@ static void rna_def_space_sequencer(BlenderRNA *brna)
 	RNA_def_property_ui

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list