Code Cleanup: replace checks for ima->source with BKE_image_is_animated
authorCampbell Barton <ideasman42@gmail.com>
Mon, 13 Jan 2014 17:59:58 +0000 (04:59 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 13 Jan 2014 17:59:58 +0000 (04:59 +1100)
source/blender/blenkernel/BKE_image.h
source/blender/blenkernel/intern/image.c
source/blender/blenkernel/intern/packedFile.c
source/blender/blenkernel/intern/texture.c
source/blender/editors/space_image/image_buttons.c
source/blender/gpu/intern/gpu_draw.c
source/blender/makesrna/intern/rna_image_api.c
source/blender/modifiers/intern/MOD_util.c
source/blender/nodes/composite/node_composite_tree.c
source/blender/render/intern/source/render_texture.c

index b5171f8e0c2b4169213492387cda286222c93968..3504f8c93a8a392da4ed05936573acdd52ac5172 100644 (file)
@@ -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);
index c0362e3aaf36b120eecebf4ebad0a7103666cdd3..3ccc95635a39f3f5a3f692b615837e8e806d0321 100644 (file)
@@ -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;
index 5c2789a2c1c18e2735160fb73975765c983a8b33..b120ec0d1f1dbbeb598f0e3eadac67d98d44b3ec 100644 (file)
@@ -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);
                        }
index ccbccac85cf8c3038208736d05df3e884068479c..542069d9b878e0c8774286772a01b44ee3c69c3f 100644 (file)
@@ -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) {
index 3ff404d38a9dd73ef90f6ea19da64942e3c325e4..003476882f76d5406c272b52370fcc39b002f13f 100644 (file)
@@ -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);
index 72547bf801e8bfe8003b81e0247bbcdda31ccbd8..f3f304b0e0443e392b85cf376fe7098d3d889bd5 100644 (file)
@@ -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);
 }
 
index 71c0fa5584c328f0dd9894f9bc42a62814107e2a..bcf75df31ed6bfcc51035694437537e47f0a3289 100644 (file)
@@ -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;
        }
index bde30fb23ae35ae6b09edea75c1f5ed824982770..e205cd6b12ddc0456af6b9c3153b814497079166 100644 (file)
@@ -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,
index 895d57c74f2aef7941fc43e93c652fe5c67f4ae8..39a9f74dea4cfe5810a2f5d97ccf7ed9f3586ced 100644 (file)
@@ -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;
                        }
index 049d7e5a7327a5ff1ce472b32030c15d8be6cb75..78b222549d985658049e61c6961259bc1d812117 100644 (file)
@@ -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);
                        }
                }