[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50181] branches/soc-2011-tomato/source/ blender: Color management: fix for clone brush

Sergey Sharybin sergey.vfx at gmail.com
Fri Aug 24 15:12:18 CEST 2012


Revision: 50181
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50181
Author:   nazgul
Date:     2012-08-24 13:12:18 +0000 (Fri, 24 Aug 2012)
Log Message:
-----------
Color management: fix for clone brush

It was using ibuf->rect for drawing alpha over, now it's using actual
display buffer.

Modified Paths:
--------------
    branches/soc-2011-tomato/source/blender/editors/space_image/image_draw.c
    branches/soc-2011-tomato/source/blender/imbuf/intern/colormanagement.c

Modified: branches/soc-2011-tomato/source/blender/editors/space_image/image_draw.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_image/image_draw.c	2012-08-24 12:50:54 UTC (rev 50180)
+++ branches/soc-2011-tomato/source/blender/editors/space_image/image_draw.c	2012-08-24 13:12:18 UTC (rev 50181)
@@ -651,22 +651,35 @@
 }
 #endif
 
-static unsigned char *get_alpha_clone_image(Scene *scene, int *width, int *height)
+static unsigned char *get_alpha_clone_image(const bContext *C, Scene *scene, int *width, int *height)
 {
 	Brush *brush = paint_brush(&scene->toolsettings->imapaint.paint);
 	ImBuf *ibuf;
 	unsigned int size, alpha;
+	unsigned char *display_buffer;
 	unsigned char *rect, *cp;
+	void *cache_handle;
 
 	if (!brush || !brush->clone.image)
 		return NULL;
 	
 	ibuf = BKE_image_get_ibuf(brush->clone.image, NULL);
 
-	if (!ibuf || !ibuf->rect)
+	if (!ibuf)
 		return NULL;
 
-	rect = MEM_dupallocN(ibuf->rect);
+	display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle);
+
+	if (!display_buffer) {
+		IMB_display_buffer_release(cache_handle);
+
+		return NULL;
+	}
+
+	rect = MEM_dupallocN(display_buffer);
+
+	IMB_display_buffer_release(cache_handle);
+
 	if (!rect)
 		return NULL;
 
@@ -685,7 +698,7 @@
 	return rect;
 }
 
-static void draw_image_paint_helpers(ARegion *ar, Scene *scene, float zoomx, float zoomy)
+static void draw_image_paint_helpers(const bContext *C, ARegion *ar, Scene *scene, float zoomx, float zoomy)
 {
 	Brush *brush;
 	int x, y, w, h;
@@ -696,7 +709,7 @@
 	if (brush && (brush->imagepaint_tool == PAINT_TOOL_CLONE)) {
 		/* this is not very efficient, but glDrawPixels doesn't allow
 		 * drawing with alpha */
-		clonerect = get_alpha_clone_image(scene, &w, &h);
+		clonerect = get_alpha_clone_image(C, scene, &w, &h);
 
 		if (clonerect) {
 			UI_view2d_to_region_no_clip(&ar->v2d, brush->clone.offset[0], brush->clone.offset[1], &x, &y);
@@ -777,7 +790,7 @@
 
 	/* paint helpers */
 	if (sima->mode == SI_MODE_PAINT)
-		draw_image_paint_helpers(ar, scene, zoomx, zoomy);
+		draw_image_paint_helpers(C, ar, scene, zoomx, zoomy);
 
 
 	/* XXX integrate this code */

Modified: branches/soc-2011-tomato/source/blender/imbuf/intern/colormanagement.c
===================================================================
--- branches/soc-2011-tomato/source/blender/imbuf/intern/colormanagement.c	2012-08-24 12:50:54 UTC (rev 50180)
+++ branches/soc-2011-tomato/source/blender/imbuf/intern/colormanagement.c	2012-08-24 13:12:18 UTC (rev 50181)
@@ -1950,7 +1950,7 @@
 			if (view_flags % 2 == 1) {
 				ColormanageCacheViewSettings view_settings = {0};
 				unsigned char *display_buffer;
-				void *cache_handle;
+				void *cache_handle = NULL;
 				int view_index = view + 1; /* views in configuration are 1-based */
 				float exposure, gamma;
 				int buffer_width;




More information about the Bf-blender-cvs mailing list