From 83963c36977d7ddb68048c8df51540bf5b37420a Mon Sep 17 00:00:00 2001 From: scott Date: Fri, 10 Jul 1998 04:33:21 +0000 Subject: [PATCH] A few tile tweaks (stuff I messed up on the frist commit) --sg --- ChangeLog | 2 ++ app/base/tile.c | 2 +- app/core/gimpimage-undo-push.c | 5 +++-- app/paint_core.c | 9 +++++++-- app/tile.c | 2 +- app/tools/paint_core.c | 9 +++++++-- app/undo.c | 5 +++-- 7 files changed, 24 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 14cb629712..13e30c2678 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ Thu Jul 9 21:23:46 1998 Scott Goehring + * paint_core.c tile.c undo.c: tile tweaks. + * tile.c tile_manager.c tile_cache.c tile.h tile_manager.h tile_manager_pvt.h tile_pvt.h: completely redid tile management. diff --git a/app/base/tile.c b/app/base/tile.c index f08ebbd317..90b54eec9f 100644 --- a/app/base/tile.c +++ b/app/base/tile.c @@ -76,7 +76,7 @@ tile_lock (Tile *tile) TILE_MUTEX_LOCK (tile); tile->ref_count += 1; - if (tile->ref_count++ == 1) + if (tile->ref_count == 1) { if (tile->listhead) { diff --git a/app/core/gimpimage-undo-push.c b/app/core/gimpimage-undo-push.c index 5aefd741b4..b7deea7280 100644 --- a/app/core/gimpimage-undo-push.c +++ b/app/core/gimpimage-undo-push.c @@ -613,15 +613,16 @@ undo_pop_image (GImage *gimage, { for (j = x; j < image_undo->x2; j += (TILE_WIDTH - (j % TILE_WIDTH))) { - src_tile = tile_manager_get_tile (tiles, j, i, 0, TRUE, TRUE); + src_tile = tile_manager_get_tile (tiles, j, i, 0, FALSE, FALSE); if (src_tile->valid == TRUE) { + src_tile = tile_manager_get_tile (tiles, j, i, 0, TRUE, TRUE); dest_tile = tile_manager_get_tile (drawable_data (image_undo->drawable), j, i, 0, TRUE, TRUE); swap_pixels (src_tile->data, dest_tile->data, (src_tile->ewidth * src_tile->eheight * src_tile->bpp)); tile_release (dest_tile, TRUE); + tile_release (src_tile, TRUE); } - tile_release (src_tile, TRUE); } } } diff --git a/app/paint_core.c b/app/paint_core.c index 544a553b42..417fe75636 100644 --- a/app/paint_core.c +++ b/app/paint_core.c @@ -615,6 +615,7 @@ paint_core_get_orig_image (paint_core, drawable, x1, y1, x2, y2) PixelRegion srcPR, destPR; Tile *undo_tile; int h; + int refd; int pixelwidth; unsigned char * s, * d; void * pr; @@ -638,9 +639,12 @@ paint_core_get_orig_image (paint_core, drawable, x1, y1, x2, y2) for (pr = pixel_regions_register (2, &srcPR, &destPR); pr != NULL; pr = pixel_regions_process (pr)) { /* If the undo tile corresponding to this location is valid, use it */ - undo_tile = tile_manager_get_tile (undo_tiles, srcPR.x, srcPR.y, 0, TRUE, FALSE); + undo_tile = tile_manager_get_tile (undo_tiles, srcPR.x, srcPR.y, 0, FALSE, FALSE); if (undo_tile->valid == TRUE) { + refd = 1; + undo_tile = tile_manager_get_tile (undo_tiles, srcPR.x, srcPR.y, 0, TRUE, FALSE); + tile_lock (undo_tile->valid); s = undo_tile->data + srcPR.rowstride * (srcPR.y % TILE_HEIGHT) + srcPR.bytes * (srcPR.x % TILE_WIDTH); } @@ -659,7 +663,8 @@ paint_core_get_orig_image (paint_core, drawable, x1, y1, x2, y2) d += destPR.rowstride; } - tile_release (undo_tile, FALSE); + if (refd) + tile_release (undo_tile, FALSE); } return orig_buf; diff --git a/app/tile.c b/app/tile.c index f08ebbd317..90b54eec9f 100644 --- a/app/tile.c +++ b/app/tile.c @@ -76,7 +76,7 @@ tile_lock (Tile *tile) TILE_MUTEX_LOCK (tile); tile->ref_count += 1; - if (tile->ref_count++ == 1) + if (tile->ref_count == 1) { if (tile->listhead) { diff --git a/app/tools/paint_core.c b/app/tools/paint_core.c index 544a553b42..417fe75636 100644 --- a/app/tools/paint_core.c +++ b/app/tools/paint_core.c @@ -615,6 +615,7 @@ paint_core_get_orig_image (paint_core, drawable, x1, y1, x2, y2) PixelRegion srcPR, destPR; Tile *undo_tile; int h; + int refd; int pixelwidth; unsigned char * s, * d; void * pr; @@ -638,9 +639,12 @@ paint_core_get_orig_image (paint_core, drawable, x1, y1, x2, y2) for (pr = pixel_regions_register (2, &srcPR, &destPR); pr != NULL; pr = pixel_regions_process (pr)) { /* If the undo tile corresponding to this location is valid, use it */ - undo_tile = tile_manager_get_tile (undo_tiles, srcPR.x, srcPR.y, 0, TRUE, FALSE); + undo_tile = tile_manager_get_tile (undo_tiles, srcPR.x, srcPR.y, 0, FALSE, FALSE); if (undo_tile->valid == TRUE) { + refd = 1; + undo_tile = tile_manager_get_tile (undo_tiles, srcPR.x, srcPR.y, 0, TRUE, FALSE); + tile_lock (undo_tile->valid); s = undo_tile->data + srcPR.rowstride * (srcPR.y % TILE_HEIGHT) + srcPR.bytes * (srcPR.x % TILE_WIDTH); } @@ -659,7 +663,8 @@ paint_core_get_orig_image (paint_core, drawable, x1, y1, x2, y2) d += destPR.rowstride; } - tile_release (undo_tile, FALSE); + if (refd) + tile_release (undo_tile, FALSE); } return orig_buf; diff --git a/app/undo.c b/app/undo.c index 5aefd741b4..b7deea7280 100644 --- a/app/undo.c +++ b/app/undo.c @@ -613,15 +613,16 @@ undo_pop_image (GImage *gimage, { for (j = x; j < image_undo->x2; j += (TILE_WIDTH - (j % TILE_WIDTH))) { - src_tile = tile_manager_get_tile (tiles, j, i, 0, TRUE, TRUE); + src_tile = tile_manager_get_tile (tiles, j, i, 0, FALSE, FALSE); if (src_tile->valid == TRUE) { + src_tile = tile_manager_get_tile (tiles, j, i, 0, TRUE, TRUE); dest_tile = tile_manager_get_tile (drawable_data (image_undo->drawable), j, i, 0, TRUE, TRUE); swap_pixels (src_tile->data, dest_tile->data, (src_tile->ewidth * src_tile->eheight * src_tile->bpp)); tile_release (dest_tile, TRUE); + tile_release (src_tile, TRUE); } - tile_release (src_tile, TRUE); } } }