diff options
author | Ton Roosendaal <ton@blender.org> | 2010-12-14 21:02:41 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2010-12-14 21:02:41 +0300 |
commit | 9ac68ad4abf2f4bb4fc92c292170a7cf6c29b319 (patch) | |
tree | 128b666894274882e649418e8af2a81d25ce133f /source/blender/imbuf/intern/filter.c | |
parent | 73ea636abb6f9d4d25155f630ac606973e9bf335 (diff) |
Bugfix #22040
Old bug report:
Image Editor, Painting: crash when texture was visible in
Material or Texture preview. Was caused by paint code
freeing mipmaps. Now replaced with a mipmap tag (to be done
again), and a new mipmap function that doesn't re-allocate.
Diffstat (limited to 'source/blender/imbuf/intern/filter.c')
-rw-r--r-- | source/blender/imbuf/intern/filter.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/source/blender/imbuf/intern/filter.c b/source/blender/imbuf/intern/filter.c index 3c2c276b6e4..13c0e6cf632 100644 --- a/source/blender/imbuf/intern/filter.c +++ b/source/blender/imbuf/intern/filter.c @@ -371,11 +371,48 @@ void IMB_filter_extend(struct ImBuf *ibuf, char *mask) } } +/* threadsafe version, only recreates existing maps */ +void IMB_remakemipmap(ImBuf *ibuf, int use_filter) +{ + ImBuf *hbuf = ibuf; + int curmap = 0; + + ibuf->miptot= 1; + + while(curmap < IB_MIPMAP_LEVELS) { + + if(ibuf->mipmap[curmap]) { + + if(use_filter) { + ImBuf *nbuf= IMB_allocImBuf(hbuf->x, hbuf->y, 32, IB_rect); + IMB_filterN(nbuf, hbuf); + imb_onehalf_no_alloc(ibuf->mipmap[curmap], nbuf); + IMB_freeImBuf(nbuf); + } + else + imb_onehalf_no_alloc(ibuf->mipmap[curmap], hbuf); + } + + ibuf->miptot= curmap+2; + hbuf= ibuf->mipmap[curmap]; + if(hbuf) + hbuf->miplevel= curmap+1; + + if(!hbuf || (hbuf->x <= 2 && hbuf->y <= 2)) + break; + + curmap++; + } +} + +/* frees too (if there) and recreates new data */ void IMB_makemipmap(ImBuf *ibuf, int use_filter) { ImBuf *hbuf = ibuf; int curmap = 0; + imb_freemipmapImBuf(ibuf); + ibuf->miptot= 1; while(curmap < IB_MIPMAP_LEVELS) { |