diff options
Diffstat (limited to 'source/blender/imbuf/intern/filter.c')
-rw-r--r-- | source/blender/imbuf/intern/filter.c | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/source/blender/imbuf/intern/filter.c b/source/blender/imbuf/intern/filter.c index 3cc266e460e..42f87049c2a 100644 --- a/source/blender/imbuf/intern/filter.c +++ b/source/blender/imbuf/intern/filter.c @@ -29,9 +29,12 @@ * $Id$ */ -#include "BKE_utildefines.h" #include "MEM_guardedalloc.h" +#include "BLI_utildefines.h" + + + #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" #include "IMB_filter.h" @@ -371,16 +374,53 @@ 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) { if(use_filter) { - ImBuf *nbuf= IMB_allocImBuf(hbuf->x, hbuf->y, 32, IB_rect, 0); + ImBuf *nbuf= IMB_allocImBuf(hbuf->x, hbuf->y, 32, IB_rect); IMB_filterN(nbuf, hbuf); ibuf->mipmap[curmap] = IMB_onehalf(nbuf); IMB_freeImBuf(nbuf); |