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/blenloader/intern/readfile.c
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/blenloader/intern/readfile.c')
-rw-r--r--source/blender/blenloader/intern/readfile.c43
1 files changed, 6 insertions, 37 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 37d2ec787ed..6e64dcc0560 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -1317,9 +1317,8 @@ void blo_make_image_pointer_map(FileData *fd, Main *oldmain)
fd->imamap = oldnewmap_new();
for (; ima; ima = ima->id.next) {
- Link *ibuf = ima->ibufs.first;
- for (; ibuf; ibuf = ibuf->next)
- oldnewmap_insert(fd->imamap, ibuf, ibuf, 0);
+ if (ima->cache)
+ oldnewmap_insert(fd->imamap, ima->cache, ima->cache, 0);
if (ima->gputexture)
oldnewmap_insert(fd->imamap, ima->gputexture, ima->gputexture, 0);
if (ima->rr)
@@ -1355,19 +1354,7 @@ void blo_end_image_pointer_map(FileData *fd, Main *oldmain)
}
for (; ima; ima = ima->id.next) {
- Link *ibuf, *next;
-
- /* this mirrors direct_link_image */
- for (ibuf = ima->ibufs.first; ibuf; ibuf = next) {
- next = ibuf->next;
- if (NULL == newimaadr(fd, ibuf)) { /* so was restored */
- BLI_remlink(&ima->ibufs, ibuf);
- ima->bindcode = 0;
- ima->tpageflag &= ~IMA_GLBIND_IS_DATA;
- ima->gputexture = NULL;
- ima->rr = NULL;
- }
- }
+ ima->cache = newmclipadr(fd, ima->cache);
for (i = 0; i < IMA_MAX_RENDER_SLOT; i++)
ima->renders[i] = newimaadr(fd, ima->renders[i]);
@@ -3281,34 +3268,16 @@ static void lib_link_image(FileData *fd, Main *main)
}
}
-static void link_ibuf_list(FileData *fd, ListBase *lb)
-{
- Link *ln, *prev;
-
- if (lb->first == NULL) return;
-
- lb->first = newimaadr(fd, lb->first);
- ln = lb->first;
- prev = NULL;
- while (ln) {
- ln->next = newimaadr(fd, ln->next);
- ln->prev = prev;
- prev = ln;
- ln = ln->next;
- }
- lb->last = prev;
-}
-
static void direct_link_image(FileData *fd, Image *ima)
{
/* for undo system, pointers could be restored */
if (fd->imamap)
- link_ibuf_list(fd, &ima->ibufs);
+ ima->cache = newmclipadr(fd, ima->cache);
else
- ima->ibufs.first = ima->ibufs.last = NULL;
+ ima->cache = NULL;
/* if not restored, we keep the binded opengl index */
- if (ima->ibufs.first == NULL) {
+ if (!fd->imamap) {
ima->bindcode = 0;
ima->tpageflag &= ~IMA_GLBIND_IS_DATA;
ima->gputexture = NULL;