[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34370] trunk/blender/source/blender: Bugfix #25657

Ton Roosendaal ton at blender.org
Mon Jan 17 19:16:11 CET 2011


Revision: 34370
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=34370
Author:   ton
Date:     2011-01-17 18:16:10 +0000 (Mon, 17 Jan 2011)
Log Message:
-----------
Bugfix #25657

Three code fixes for 1 report. User experienced crashes while
painting on float buffer + having preview renders on.

- Texture Nodes: Image was re-allocated without using
  proper thread lock
- Paint code: old convention to free the byte rect from
  a float image as signal to re-create now is a proper
  flag. This keeps image memory unchanged. Nice for render.
- Imbuf: call to make a byte rect from float was freeing
  mipmaps unnecessary.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/sculpt_paint/paint_image.c
    trunk/blender/source/blender/editors/space_image/image_draw.c
    trunk/blender/source/blender/imbuf/IMB_imbuf_types.h
    trunk/blender/source/blender/imbuf/intern/allocimbuf.c
    trunk/blender/source/blender/imbuf/intern/divers.c
    trunk/blender/source/blender/nodes/intern/TEX_nodes/TEX_image.c

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_image.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_image.c	2011-01-17 15:16:08 UTC (rev 34369)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_image.c	2011-01-17 18:16:10 UTC (rev 34370)
@@ -432,7 +432,8 @@
 
 		GPU_free_image(ima); /* force OpenGL reload */
 		if(ibuf->rect_float)
-			imb_freerectImBuf(ibuf); /* force recreate of char rect */
+			ibuf->userflags |= IB_RECT_INVALID; /* force recreate of char rect */
+
 	}
 
 	IMB_freeImBuf(tmpibuf);
@@ -4022,7 +4023,7 @@
 {
 	if(ibuf->rect_float)
 		/* TODO - should just update a portion from imapaintpartial! */
-		imb_freerectImBuf(ibuf); /* force recreate of char rect */
+		ibuf->userflags |= IB_RECT_INVALID; /* force recreate of char rect */
 	
 	if(ibuf->mipmap[0])
 		ibuf->userflags |= IB_MIPMAP_INVALID;

Modified: trunk/blender/source/blender/editors/space_image/image_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_image/image_draw.c	2011-01-17 15:16:08 UTC (rev 34369)
+++ trunk/blender/source/blender/editors/space_image/image_draw.c	2011-01-17 18:16:10 UTC (rev 34370)
@@ -83,7 +83,7 @@
 	   NOTE: if float buffer changes, we have to manually remove the rect
 	*/
 
-	if(ibuf->rect_float && ibuf->rect==NULL) {
+	if(ibuf->rect_float && (ibuf->rect==NULL || (ibuf->userflags & IB_RECT_INVALID)) ) {
 		if(color_manage) {
 			if(ima && ima->source == IMA_SRC_VIEWER)
 				ibuf->profile = IB_PROFILE_LINEAR_RGB;

Modified: trunk/blender/source/blender/imbuf/IMB_imbuf_types.h
===================================================================
--- trunk/blender/source/blender/imbuf/IMB_imbuf_types.h	2011-01-17 15:16:08 UTC (rev 34369)
+++ trunk/blender/source/blender/imbuf/IMB_imbuf_types.h	2011-01-17 18:16:10 UTC (rev 34370)
@@ -137,13 +137,8 @@
 #define IB_BITMAPFONT		(1 << 0)	/* this image is a font */
 #define IB_BITMAPDIRTY		(1 << 1)	/* image needs to be saved is not the same as filename */
 #define IB_MIPMAP_INVALID	(1 << 2)	/* image mipmaps are invalid, need recreate */
+#define IB_RECT_INVALID		(1 << 3)    /* float buffer changed, needs recreation of byte rect */
 
-/* From iff.h. This was once moved away by Frank, now Nzc moves it
- * back. Such is the way it is... It is a long list of defines, and
- * there are a few external defines in the back. Most of the stuff is
- * probably imbuf_intern only. This will need to be merged later
- * on. */
-
 /**
  * \name Imbuf Component flags
  * \brief These flags determine the components of an ImBuf struct.

Modified: trunk/blender/source/blender/imbuf/intern/allocimbuf.c
===================================================================
--- trunk/blender/source/blender/imbuf/intern/allocimbuf.c	2011-01-17 15:16:08 UTC (rev 34369)
+++ trunk/blender/source/blender/imbuf/intern/allocimbuf.c	2011-01-17 18:16:10 UTC (rev 34370)
@@ -277,7 +277,8 @@
 	
 	if(ibuf==NULL) return FALSE;
 	
-	imb_freerectfloatImBuf(ibuf);
+	if(ibuf->rect_float)
+		imb_freerectfloatImBuf(ibuf); /* frees mipmap too, hrm */
 	
 	size = ibuf->x *ibuf->y;
 	size = size *4 *sizeof(float);

Modified: trunk/blender/source/blender/imbuf/intern/divers.c
===================================================================
--- trunk/blender/source/blender/imbuf/intern/divers.c	2011-01-17 15:16:08 UTC (rev 34369)
+++ trunk/blender/source/blender/imbuf/intern/divers.c	2011-01-17 18:16:10 UTC (rev 34370)
@@ -188,6 +188,8 @@
 			}
 		}
 	}
+	/* ensure user flag is reset */
+	ibuf->userflags &= ~IB_RECT_INVALID;
 }
 
 static void imb_float_from_rect_nonlinear(struct ImBuf *ibuf, float *fbuf)

Modified: trunk/blender/source/blender/nodes/intern/TEX_nodes/TEX_image.c
===================================================================
--- trunk/blender/source/blender/nodes/intern/TEX_nodes/TEX_image.c	2011-01-17 15:16:08 UTC (rev 34369)
+++ trunk/blender/source/blender/nodes/intern/TEX_nodes/TEX_image.c	2011-01-17 18:16:10 UTC (rev 34370)
@@ -58,8 +58,14 @@
 			py = (int)( (y-yoff) * ysize );
 		
 			if( (!xsize) || (!ysize) ) return;
-			if( !ibuf->rect_float ) IMB_float_from_rect(ibuf);
 			
+			if( !ibuf->rect_float ) {
+				BLI_lock_thread(LOCK_IMAGE);
+				if( !ibuf->rect_float )
+					IMB_float_from_rect(ibuf);
+				BLI_unlock_thread(LOCK_IMAGE);
+			}
+			
 			while( px < 0 ) px += ibuf->x;
 			while( py < 0 ) py += ibuf->y;
 			while( px >= ibuf->x ) px -= ibuf->x;




More information about the Bf-blender-cvs mailing list