[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [53805] trunk/blender/source/blender: Two threading issues:

Sergey Sharybin sergey.vfx at gmail.com
Tue Jan 15 08:56:42 CET 2013


Revision: 53805
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=53805
Author:   nazgul
Date:     2013-01-15 07:56:38 +0000 (Tue, 15 Jan 2013)
Log Message:
-----------
Two threading issues:

- Drawing masks in image editor requires LOCK_DRAW_IMAGE around
  ED_space_image_get* functions since they'll acquire image buffer.

  Lock is needed because viewers will be modified directly in
  compositor (see commend in draw_image_main)

- Seems that was wrong order of invalidating render result and
  viewer image invalidation happened in Composite node, which
  could easily lead to thread lock.

Modified Paths:
--------------
    trunk/blender/source/blender/compositor/operations/COM_CompositorOperation.cpp
    trunk/blender/source/blender/editors/space_image/space_image.c

Modified: trunk/blender/source/blender/compositor/operations/COM_CompositorOperation.cpp
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_CompositorOperation.cpp	2013-01-15 07:35:32 UTC (rev 53804)
+++ trunk/blender/source/blender/compositor/operations/COM_CompositorOperation.cpp	2013-01-15 07:56:38 UTC (rev 53805)
@@ -91,14 +91,14 @@
 			}
 		}
 
-		BLI_lock_thread(LOCK_DRAW_IMAGE);
-		BKE_image_signal(BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result"), NULL, IMA_SIGNAL_FREE);
-		BLI_unlock_thread(LOCK_DRAW_IMAGE);
-
 		if (re) {
 			RE_ReleaseResult(re);
 			re = NULL;
 		}
+
+		BLI_lock_thread(LOCK_DRAW_IMAGE);
+		BKE_image_signal(BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result"), NULL, IMA_SIGNAL_FREE);
+		BLI_unlock_thread(LOCK_DRAW_IMAGE);
 	}
 	else {
 		if (this->m_outputBuffer) {

Modified: trunk/blender/source/blender/editors/space_image/space_image.c
===================================================================
--- trunk/blender/source/blender/editors/space_image/space_image.c	2013-01-15 07:35:32 UTC (rev 53804)
+++ trunk/blender/source/blender/editors/space_image/space_image.c	2013-01-15 07:56:38 UTC (rev 53805)
@@ -38,6 +38,7 @@
 
 #include "BLI_blenlib.h"
 #include "BLI_math.h"
+#include "BLI_threads.h"
 
 #include "BKE_colortools.h"
 #include "BKE_context.h"
@@ -692,10 +693,25 @@
 	}
 
 	if (mask) {
-		int width, height;
+		Image *image = ED_space_image(sima);
+		int width, height, show_viewer;
 		float aspx, aspy;
+
+		show_viewer = (image && image->source == IMA_SRC_VIEWER);
+
+		if (show_viewer) {
+			/* ED_space_image_get will acquire image buffer which requires
+			 * lock here by the same reason why lock is needed in draw_image_main
+			 */
+			BLI_lock_thread(LOCK_DRAW_IMAGE);
+		}
+
 		ED_space_image_get_size(sima, &width, &height);
 		ED_space_image_get_aspect(sima, &aspx, &aspy);
+
+		if (show_viewer)
+			BLI_unlock_thread(LOCK_DRAW_IMAGE);
+
 		ED_mask_draw_region(mask, ar,
 		                    sima->mask_info.draw_flag, sima->mask_info.draw_type,
 		                    width, height,




More information about the Bf-blender-cvs mailing list