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/render | |
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/render')
-rw-r--r-- | source/blender/render/intern/source/imagetexture.c | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c index 9376c798c39..5a2ce5a6b89 100644 --- a/source/blender/render/intern/source/imagetexture.c +++ b/source/blender/render/intern/source/imagetexture.c @@ -960,6 +960,30 @@ static void alpha_clip_aniso(ImBuf *ibuf, float minx, float miny, float maxx, fl } } +static void image_mipmap_test(Tex *tex, ImBuf *ibuf) +{ + if (tex->imaflag & TEX_MIPMAP) { + if ((ibuf->flags & IB_fields) == 0) { + + if (ibuf->mipmap[0] && (ibuf->userflags & IB_MIPMAP_INVALID)) { + BLI_lock_thread(LOCK_IMAGE); + if (ibuf->userflags & IB_MIPMAP_INVALID) { + IMB_remakemipmap(ibuf, tex->imaflag & TEX_GAUSS_MIP); + ibuf->userflags &= ~IB_MIPMAP_INVALID; + } + BLI_unlock_thread(LOCK_IMAGE); + } + if (ibuf->mipmap[0] == NULL) { + BLI_lock_thread(LOCK_IMAGE); + if (ibuf->mipmap[0] == NULL) + IMB_makemipmap(ibuf, tex->imaflag & TEX_GAUSS_MIP); + BLI_unlock_thread(LOCK_IMAGE); + } + } + } + +} + static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, float *texvec, float *dxt, float *dyt, TexResult *texres) { TexResult texr; @@ -996,15 +1020,9 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, float *texvec, if ((ibuf == NULL) || ((ibuf->rect == NULL) && (ibuf->rect_float == NULL))) return retval; - // mipmap test - if (tex->imaflag & TEX_MIPMAP) { - if (((ibuf->flags & IB_fields) == 0) && (ibuf->mipmap[0] == NULL)) { - BLI_lock_thread(LOCK_IMAGE); - if (ibuf->mipmap[0] == NULL) IMB_makemipmap(ibuf, tex->imaflag & TEX_GAUSS_MIP); - BLI_unlock_thread(LOCK_IMAGE); - } - } - + /* mipmap test */ + image_mipmap_test(tex, ibuf); + if ((tex->imaflag & TEX_USEALPHA) && ((tex->imaflag & TEX_CALCALPHA) == 0)) texres->talpha = 1; texr.talpha = texres->talpha; @@ -1388,17 +1406,7 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, float *texvec, float *DXT, f return retval; /* mipmap test */ - if (tex->imaflag & TEX_MIPMAP) { - if(ibuf->flags & IB_fields); - else if(ibuf->mipmap[0]==NULL) { - BLI_lock_thread(LOCK_IMAGE); - - if(ibuf->mipmap[0]==NULL) - IMB_makemipmap(ibuf, tex->imaflag & TEX_GAUSS_MIP); - - BLI_unlock_thread(LOCK_IMAGE); - } - } + image_mipmap_test(tex, ibuf); if(tex->imaflag & TEX_USEALPHA) { if(tex->imaflag & TEX_CALCALPHA); |