Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2013-12-13 14:22:08 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2013-12-13 14:30:00 +0400
commitce893552c359d11cfa93709f239a3c93f4cdb244 (patch)
treed9474f190006e89547044c241081f320c44c3a36 /source/blender/editors/sculpt_paint
parent7eab49f8d923ed3992dff1236e30a62f2d70f460 (diff)
Image cache rewrite to using generic movie cache
Summary: Behaves very much the same as cache for Movie Clip datablock: - Image now have `MovieCache *cache` field which replaced legacy `ListBase ibufs`. This allows image datablock to easily keep of image buffers which are owned by itself. This field isn't saved to the file and getting restored on undo steps. However, cache limit is global for movies, sequences and image datablocks now. So overall cached image buffers size will not go above cache limit size in user preferences. - Image buffers which are marked as BITMAPDIRTY will never be freed from the cache. - Added utility function to iterate over image buffers saved in movie cache. - Movie cache cleanup check callback now have ImBuf argument which can be used in a condition of cleanup. - Added some utility functions which replaces legacy ibufs iterations with image cache iteration which happens from inside a lock. - Fixed `image_mem_size()` which was only counting one of the buffers if both float and byte buffer present. Additional notes: - `BKE_image_get_first_ibuf()` is rather stupid, but direct access to ibufs->first was also the same stupid idea. Would consider avoid this function is another project. - There are some places which doesn't look threadsafe, but they already were not so much threadsafe anyway before. So think not a big deal with solving this later. Finally solves infinite memory usage by image sequences! :) Reviewers: brecht, campbellbarton Reviewed By: brecht CC: sebastian_k Differential Revision: http://developer.blender.org/D95
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c11
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c4
2 files changed, 11 insertions, 4 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;
}