diff options
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image.c | 11 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image_proj.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_ops.c | 40 | ||||
-rw-r--r-- | source/blender/editors/space_info/info_ops.c | 2 |
4 files changed, 40 insertions, 17 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 47ca3e5ce0c..5b323a0a396 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -250,6 +250,7 @@ void ED_image_undo_restore(bContext *C, ListBase *lb) for (tile = lb->first; tile; tile = tile->next) { short use_float; + bool need_release = true; /* find image based on name, pointer becomes invalid with global undo */ if (ima && strcmp(tile->idname, ima->id.name) == 0) { @@ -268,8 +269,9 @@ void ED_image_undo_restore(bContext *C, ListBase *lb) * matched file name in list of already loaded images */ BKE_image_release_ibuf(ima, ibuf, NULL); + need_release = false; - ibuf = BLI_findstring(&ima->ibufs, tile->ibufname, offsetof(ImBuf, name)); + ibuf = BKE_image_get_ibuf_with_name(ima, tile->ibufname); } if (!ima || !ibuf || !(ibuf->rect || ibuf->rect_float)) { @@ -298,7 +300,12 @@ void ED_image_undo_restore(bContext *C, ListBase *lb) ibuf->userflags |= IB_MIPMAP_INVALID; /* force mipmap recreatiom */ ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID; - BKE_image_release_ibuf(ima, ibuf, NULL); + if (need_release) { + BKE_image_release_ibuf(ima, ibuf, NULL); + } + else { + IMB_freeImBuf(ibuf); + } } IMB_freeImBuf(tmpibuf); diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index d6989c082a1..4b402bc1741 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -542,8 +542,7 @@ static bool project_paint_PickColor(const ProjPaintState *ps, const float pt[2], } ima = project_paint_face_image(ps, ps->dm_mtface, face_index); - ibuf = ima->ibufs.first; /* we must have got the imbuf before getting here */ - if (!ibuf) return 0; + ibuf = BKE_image_get_first_ibuf(ima); /* we must have got the imbuf before getting here */ if (interp) { float x, y; @@ -599,6 +598,7 @@ static bool project_paint_PickColor(const ProjPaintState *ps, const float pt[2], } } } + IMB_freeImBuf(ibuf); return 1; } diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index bda4be40c5c..a2f49af1730 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -63,6 +63,7 @@ #include "IMB_colormanagement.h" #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" +#include "IMB_moviecache.h" #include "RE_pipeline.h" @@ -1628,9 +1629,10 @@ static int image_save_sequence_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); SpaceImage *sima = CTX_wm_space_image(C); - ImBuf *ibuf; + ImBuf *ibuf, *first_ibuf = NULL; int tot = 0; char di[FILE_MAX]; + struct MovieCacheIter *iter; if (sima->image == NULL) return OPERATOR_CANCELLED; @@ -1645,10 +1647,22 @@ static int image_save_sequence_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - /* get total */ - for (ibuf = sima->image->ibufs.first; ibuf; ibuf = ibuf->next) - if (ibuf->userflags & IB_BITMAPDIRTY) - tot++; + /* get total dirty buffers and first dirty buffer which is used for menu */ + ibuf = NULL; + if (sima->image->cache != NULL) { + iter = IMB_moviecacheIter_new(sima->image->cache); + while (!IMB_moviecacheIter_done(iter)) { + ibuf = IMB_moviecacheIter_getImBuf(iter); + if (ibuf->userflags & IB_BITMAPDIRTY) { + if (first_ibuf == NULL) { + first_ibuf = ibuf; + } + tot++; + } + IMB_moviecacheIter_step(iter); + } + IMB_moviecacheIter_free(iter); + } if (tot == 0) { BKE_report(op->reports, RPT_WARNING, "No images have been changed"); @@ -1656,18 +1670,17 @@ static int image_save_sequence_exec(bContext *C, wmOperator *op) } /* get a filename for menu */ - for (ibuf = sima->image->ibufs.first; ibuf; ibuf = ibuf->next) - if (ibuf->userflags & IB_BITMAPDIRTY) - break; - - BLI_split_dir_part(ibuf->name, di, sizeof(di)); + BLI_split_dir_part(first_ibuf->name, di, sizeof(di)); BKE_reportf(op->reports, RPT_INFO, "%d image(s) will be saved in %s", tot, di); - for (ibuf = sima->image->ibufs.first; ibuf; ibuf = ibuf->next) { + iter = IMB_moviecacheIter_new(sima->image->cache); + while (!IMB_moviecacheIter_done(iter)) { + ibuf = IMB_moviecacheIter_getImBuf(iter); + if (ibuf->userflags & IB_BITMAPDIRTY) { char name[FILE_MAX]; BLI_strncpy(name, ibuf->name, sizeof(name)); - + BLI_path_abs(name, bmain->name); if (0 == IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat)) { @@ -1678,7 +1691,10 @@ static int image_save_sequence_exec(bContext *C, wmOperator *op) BKE_reportf(op->reports, RPT_INFO, "Saved %s", ibuf->name); ibuf->userflags &= ~IB_BITMAPDIRTY; } + + IMB_moviecacheIter_step(iter); } + IMB_moviecacheIter_free(iter); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c index 4e367c1d48d..6c76ba64893 100644 --- a/source/blender/editors/space_info/info_ops.c +++ b/source/blender/editors/space_info/info_ops.c @@ -145,7 +145,7 @@ static int pack_all_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(ev // first check for dirty images for (ima = bmain->image.first; ima; ima = ima->id.next) { - if (ima->ibufs.first) { /* XXX FIX */ + if (BKE_image_has_loaded_ibuf(ima)) { /* XXX FIX */ ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL); if (ibuf && (ibuf->userflags & IB_BITMAPDIRTY)) { |