[Bf-blender-cvs] [c48c62a] master: Code Cleanup: replace checks for ima->source with BKE_image_is_animated

Campbell Barton noreply at git.blender.org
Mon Jan 13 19:03:59 CET 2014


Commit: c48c62a8314c51608e7b34ac0df474ce3fca0b02
Author: Campbell Barton
Date:   Tue Jan 14 04:59:58 2014 +1100
https://developer.blender.org/rBc48c62a8314c51608e7b34ac0df474ce3fca0b02

Code Cleanup: replace checks for ima->source with BKE_image_is_animated

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

M	source/blender/blenkernel/BKE_image.h
M	source/blender/blenkernel/intern/image.c
M	source/blender/blenkernel/intern/packedFile.c
M	source/blender/blenkernel/intern/texture.c
M	source/blender/editors/space_image/image_buttons.c
M	source/blender/gpu/intern/gpu_draw.c
M	source/blender/makesrna/intern/rna_image_api.c
M	source/blender/modifiers/intern/MOD_util.c
M	source/blender/nodes/composite/node_composite_tree.c
M	source/blender/render/intern/source/render_texture.c

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

diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h
index b5171f8..3504f8c 100644
--- a/source/blender/blenkernel/BKE_image.h
+++ b/source/blender/blenkernel/BKE_image.h
@@ -236,6 +236,7 @@ float *BKE_image_get_float_pixels_for_frame(struct Image *image, int frame);
 /* Guess offset for the first frame in the sequence */
 int BKE_image_sequence_guess_offset(struct Image *image);
 
+bool BKE_image_is_animated(struct Image *image);
 bool BKE_image_is_dirty(struct Image *image);
 void BKE_image_file_format_set(struct Image *image, int ftype);
 bool BKE_image_has_loaded_ibuf(struct Image *image);
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index c0362e3..3ccc956 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -1010,7 +1010,7 @@ void BKE_image_all_free_anim_ibufs(int cfra)
 	Image *ima;
 
 	for (ima = G.main->image.first; ima; ima = ima->id.next)
-		if (ELEM(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE))
+		if (BKE_image_is_animated(ima))
 			BKE_image_free_anim_ibufs(ima, cfra);
 }
 
@@ -2254,7 +2254,7 @@ static void image_tag_frame_recalc(Image *ima, ImageUser *iuser, void *customdat
 {
 	Image *changed_image = customdata;
 
-	if (ima == changed_image && ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) {
+	if (ima == changed_image && BKE_image_is_animated(ima)) {
 		iuser->flag |= IMA_NEED_FRAME_RECALC;
 	}
 }
@@ -3552,6 +3552,16 @@ int BKE_image_sequence_guess_offset(Image *image)
 	return atoi(num);
 }
 
+/**
+ * Checks the image buffer changes (not keyframed values)
+ *
+ * to see if we need to call #BKE_image_user_check_frame_calc
+ */
+bool BKE_image_is_animated(Image *image)
+{
+	return ELEM(image->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE);
+}
+
 bool BKE_image_is_dirty(Image *image)
 {
 	bool is_dirty = false;
diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c
index 5c2789a..b120ec0 100644
--- a/source/blender/blenkernel/intern/packedFile.c
+++ b/source/blender/blenkernel/intern/packedFile.c
@@ -245,7 +245,7 @@ void packAll(Main *bmain, ReportList *reports)
 				ima->packedfile = newPackedFile(reports, ima->name, ID_BLEND_PATH(bmain, &ima->id));
 				tot ++;
 			}
-			else if (ELEM(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) {
+			else if (BKE_image_is_animated(ima)) {
 				BKE_reportf(reports, RPT_WARNING, "Image '%s' skipped, movies and image sequences not supported",
 				            ima->id.name + 2);
 			}
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index ccbccac..542069d 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -1422,9 +1422,7 @@ void BKE_free_oceantex(struct OceanTex *ot)
 /* ------------------------------------------------------------------------- */
 bool BKE_texture_dependsOnTime(const struct Tex *texture)
 {
-	if (texture->ima &&
-	    ELEM(texture->ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE))
-	{
+	if (texture->ima && BKE_image_is_animated(texture->ima)) {
 		return 1;
 	}
 	else if (texture->adt) {
diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c
index 3ff404d..0034768 100644
--- a/source/blender/editors/space_image/image_buttons.c
+++ b/source/blender/editors/space_image/image_buttons.c
@@ -701,7 +701,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
 					col = uiLayoutColumn(split, FALSE);
 					/* XXX Why only display fields_per_frame only for video image types?
 					 *     And why allow fields for non-video image types at all??? */
-					if (ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) {
+					if (BKE_image_is_animated(ima)) {
 						uiLayout *subsplit = uiLayoutSplit(col, 0.0f, FALSE);
 						uiLayout *subcol = uiLayoutColumn(subsplit, FALSE);
 						uiItemR(subcol, &imaptr, "use_fields", 0, NULL, ICON_NONE);
@@ -717,7 +717,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
 				}
 			}
 
-			if (ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) {
+			if (BKE_image_is_animated(ima)) {
 				uiItemS(layout);
 
 				split = uiLayoutSplit(layout, 0.0f, FALSE);
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index 72547bf..f3f304b 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -1298,7 +1298,7 @@ void GPU_free_images_anim(void)
 
 	if (G.main)
 		for (ima=G.main->image.first; ima; ima=ima->id.next)
-			if (ELEM(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE))
+			if (BKE_image_is_animated(ima))
 				GPU_free_image(ima);
 }
 
diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c
index 71c0fa5..bcf75df 100644
--- a/source/blender/makesrna/intern/rna_image_api.c
+++ b/source/blender/makesrna/intern/rna_image_api.c
@@ -166,7 +166,7 @@ static void rna_Image_unpack(Image *image, ReportList *reports, int method)
 	if (!image->packedfile) {
 		BKE_report(reports, RPT_ERROR, "Image not packed");
 	}
-	else if (image->source == IMA_SRC_SEQUENCE || image->source == IMA_SRC_MOVIE) {
+	else if (BKE_image_is_animated(image)) {
 		BKE_report(reports, RPT_ERROR, "Unpacking movies or image sequences not supported");
 		return;
 	}
diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c
index bde30fb..e205cd6 100644
--- a/source/blender/modifiers/intern/MOD_util.c
+++ b/source/blender/modifiers/intern/MOD_util.c
@@ -66,8 +66,9 @@ void modifier_init_texture(Scene *scene, Tex *tex)
 	if (!tex)
 		return;
 
-	if (tex->ima && ELEM(tex->ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE))
+	if (tex->ima && BKE_image_is_animated(tex->ima)) {
 		BKE_image_user_frame_calc(&tex->iuser, scene->r.cfra, 0);
+	}
 }
 
 void get_texture_coords(MappingInfoModifierData *dmd, Object *ob,
diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c
index 895d57c..39a9f74 100644
--- a/source/blender/nodes/composite/node_composite_tree.c
+++ b/source/blender/nodes/composite/node_composite_tree.c
@@ -366,7 +366,7 @@ int ntreeCompositTagAnimated(bNodeTree *ntree)
 		/* otherwise always tag these node types */
 		if (node->type == CMP_NODE_IMAGE) {
 			Image *ima = (Image *)node->id;
-			if (ima && ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) {
+			if (ima && BKE_image_is_animated(ima)) {
 				nodeUpdate(ntree, node);
 				tagged = 1;
 			}
diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c
index 049d7e5..78b2225 100644
--- a/source/blender/render/intern/source/render_texture.c
+++ b/source/blender/render/intern/source/render_texture.c
@@ -98,7 +98,7 @@ extern struct Render R;
 static void init_render_texture(Render *re, Tex *tex)
 {
 	/* imap test */
-	if (tex->ima && ELEM(tex->ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) {
+	if (tex->ima && BKE_image_is_animated(tex->ima)) {
 		BKE_image_user_frame_calc(&tex->iuser, re ? re->r.cfra : 0, re ? re->flag & R_SEC_FIELD:0);
 	}
 	
@@ -3622,7 +3622,7 @@ Material *RE_init_sample_material(Material *orig_mat, Scene *scene)
 			}
 
 			/* update image sequences and movies */
-			if (tex->ima && ELEM(tex->ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) {
+			if (tex->ima && BKE_image_is_animated(tex->ima)) {
 				BKE_image_user_check_frame_calc(&tex->iuser, (int)scene->r.cfra, 0);
 			}
 		}




More information about the Bf-blender-cvs mailing list