[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [57972] branches/soc-2013-paint/source/ blender/editors/sculpt_paint: Utilize the old undo push code to only actually push undo tiles that

Antony Riakiotakis kalast at gmail.com
Wed Jul 3 21:49:55 CEST 2013


Revision: 57972
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57972
Author:   psy-fi
Date:     2013-07-03 19:49:54 +0000 (Wed, 03 Jul 2013)
Log Message:
-----------
Utilize the old undo push code to only actually push undo tiles that
contains pixels that changed. Still haven't fixed original pixels being different than the
original image, coming soon. This will also fix drag dot undo.

Modified Paths:
--------------
    branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image.c
    branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image_proj.c
    branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_intern.h

Modified: branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image.c
===================================================================
--- branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image.c	2013-07-03 19:35:04 UTC (rev 57971)
+++ branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image.c	2013-07-03 19:49:54 UTC (rev 57972)
@@ -353,6 +353,15 @@
 	undo_paint_push_end(UNDO_PAINT_IMAGE);
 }
 
+void image_undo_invalidate(void)
+{
+	UndoImageTile *tile;
+	ListBase *lb = undo_paint_push_get_list(UNDO_PAINT_IMAGE);
+
+	for (tile = lb->first; tile; tile = tile->next)
+		tile->valid = false;
+}
+
 /* Imagepaint Partial Redraw & Dirty Region */
 
 void imapaint_clear_partial_redraw(void)
@@ -556,12 +565,9 @@
 /* restore painting image to previous state. Used for anchored and drag-dot style brushes*/
 static void paint_stroke_restore(bContext *C)
 {
-	UndoImageTile *tile;
 	ListBase *lb = undo_paint_push_get_list(UNDO_PAINT_IMAGE);
 	image_undo_restore(C, lb);
-
-	for (tile = lb->first; tile; tile = tile->next)
-		tile->valid = false;
+	image_undo_invalidate();
 }
 
 static void paint_stroke_update_step(bContext *C, struct PaintStroke *stroke, PointerRNA *itemptr)

Modified: branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image_proj.c
===================================================================
--- branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image_proj.c	2013-07-03 19:35:04 UTC (rev 57971)
+++ branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image_proj.c	2013-07-03 19:49:54 UTC (rev 57972)
@@ -3306,22 +3306,19 @@
 	}
 }
 
-static void project_paint_undo_push(ProjPaintState *UNUSED(ps))
+static void project_paint_undo_end(ProjPaintState *ps)
 {
-#if 0
 	/* build undo data from original pixel colors */
 	if (U.uiflag & USER_GLOBALUNDO) {
 		ProjPixel *projPixel;
 		ImBuf *tmpibuf = NULL, *tmpibuf_float = NULL;
 		LinkNode *pixel_node;
-		void *tilerect;
 		MemArena *arena = ps->arena_mt[0]; /* threaded arena re-used for non threaded case */
 
 		int bucket_tot = (ps->buckets_x * ps->buckets_y); /* we could get an X/Y but easier to loop through all possible buckets */
 		int bucket_index;
-		int tile_index;
 		int a;
-		int x_round, y_round;
+		//int x_round, y_round;
 		int x_tile, y_tile;
 		int is_float = -1;
 
@@ -3330,6 +3327,9 @@
 		int last_image_index = -1;
 		int last_tile_width = 0;
 
+		/* first invalidate all undo rectangles */
+		image_undo_invalidate();
+
 		for (a = 0, last_projIma = ps->projImages; a < ps->image_tot; a++, last_projIma++) {
 			int size = sizeof(void **) * IMAPAINT_TILE_NUMBER(last_projIma->ibuf->x) * IMAPAINT_TILE_NUMBER(last_projIma->ibuf->y);
 			last_projIma->undoRect = (void **) BLI_memarena_alloc(arena, size);
@@ -3365,29 +3365,11 @@
 					x_tile =  projPixel->x_px >> IMAPAINT_TILE_BITS;
 					y_tile =  projPixel->y_px >> IMAPAINT_TILE_BITS;
 
-					x_round = x_tile * IMAPAINT_TILE_SIZE;
-					y_round = y_tile * IMAPAINT_TILE_SIZE;
+					//x_round = x_tile * IMAPAINT_TILE_SIZE;
+					//y_round = y_tile * IMAPAINT_TILE_SIZE;
 
-					tile_index = x_tile + y_tile * last_tile_width;
-
-					if (last_projIma->undoRect[tile_index] == NULL) {
-						/* add the undo tile from the modified image, then write the original colors back into it */
-						tilerect = last_projIma->undoRect[tile_index] = image_undo_push_tile(last_projIma->ima, last_projIma->ibuf, is_float ? (&tmpibuf_float) : (&tmpibuf), x_tile, y_tile, NULL);
-					}
-					else {
-						tilerect = last_projIma->undoRect[tile_index];
-					}
-
-					/* This is a BIT ODD, but overwrite the undo tiles image info with this pixels original color
-					 * because allocating the tiles along the way slows down painting */
-
-					if (is_float) {
-						float *rgba_fp = (float *)tilerect + (((projPixel->x_px - x_round) + (projPixel->y_px - y_round) * IMAPAINT_TILE_SIZE)) * 4;
-						copy_v4_v4(rgba_fp, projPixel->origColor.f);
-					}
-					else {
-						((unsigned int *)tilerect)[(projPixel->x_px - x_round) + (projPixel->y_px - y_round) * IMAPAINT_TILE_SIZE] = projPixel->origColor.uint;
-					}
+					/* validate the tile here */
+					image_undo_find_tile(last_projIma->ima, last_projIma->ibuf, x_tile, y_tile, NULL, true);
 				}
 			}
 		}
@@ -3395,7 +3377,6 @@
 		if (tmpibuf) IMB_freeImBuf(tmpibuf);
 		if (tmpibuf_float) IMB_freeImBuf(tmpibuf_float);
 	}
-#endif
 }
 
 
@@ -3405,7 +3386,7 @@
 	ProjPaintImage *projIma;
 
 	image_undo_remove_masks();
-	project_paint_undo_push(ps);
+	project_paint_undo_end(ps);
 
 	/* dereference used image buffers */
 	for (a = 0, projIma = ps->projImages; a < ps->image_tot; a++, projIma++) {
@@ -4178,10 +4159,6 @@
 
 	if (project_paint_op(ps, prev_pos, pos))
 		ps->need_redraw = true;
-
-	if ((ps->brush->flag & BRUSH_RESTORE_MESH) ||
-	    (ps->brush->flag & BRUSH_ANCHORED))
-		project_paint_undo_push(ps);
 }
 
 

Modified: branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_intern.h
===================================================================
--- branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_intern.h	2013-07-03 19:35:04 UTC (rev 57971)
+++ branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_intern.h	2013-07-03 19:49:54 UTC (rev 57972)
@@ -146,6 +146,7 @@
 void image_undo_remove_masks(void);
 void image_undo_restore(struct bContext *C, struct ListBase *lb);
 void image_undo_free(struct ListBase *lb);
+void image_undo_invalidate(void);
 void imapaint_image_update(struct SpaceImage *sima, struct Image *image, struct ImBuf *ibuf, short texpaint);
 struct ImagePaintPartialRedraw *get_imapaintpartial(void);
 void set_imapaintpartial(struct ImagePaintPartialRedraw *ippr);




More information about the Bf-blender-cvs mailing list