Image cache rewrite to using generic movie cache
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 13 Dec 2013 10:22:08 +0000 (16:22 +0600)
committerSergey Sharybin <sergey.vfx@gmail.com>
Fri, 13 Dec 2013 10:30:00 +0000 (16:30 +0600)
commitce893552c359d11cfa93709f239a3c93f4cdb244
treed9474f190006e89547044c241081f320c44c3a36
parent7eab49f8d923ed3992dff1236e30a62f2d70f460
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
14 files changed:
source/blender/blenkernel/BKE_image.h
source/blender/blenkernel/intern/image.c
source/blender/blenkernel/intern/seqcache.c
source/blender/blenloader/intern/readfile.c
source/blender/editors/sculpt_paint/paint_image.c
source/blender/editors/sculpt_paint/paint_image_proj.c
source/blender/editors/space_image/image_ops.c
source/blender/editors/space_info/info_ops.c
source/blender/gpu/intern/gpu_draw.c
source/blender/imbuf/IMB_moviecache.h
source/blender/imbuf/intern/moviecache.c
source/blender/makesdna/DNA_image_types.h
source/blender/makesrna/intern/rna_image.c
source/blender/render/intern/source/imagetexture.c