gimp r26419 - in trunk: . app/base app/core



Author: neo
Date: Thu Aug  7 15:29:02 2008
New Revision: 26419
URL: http://svn.gnome.org/viewvc/gimp?rev=26419&view=rev

Log:
2008-08-07  Sven Neumann  <sven gimp org>

	* app/base/tile-manager.c (tile_manager_invalidate_tile): fixed
	broken copy-on-write code. The old code did not insert the new
	tile in the tile-manager's tile pointer array.

	(tile_manager_map): changed in a similar way as
	tile_manager_invalidate_tile(). This code was not broken, but it
	is easier to read now.

	* app/base/tile-private.h: moved a comment.

	* app/core/gimpselection.c (gimp_selection_extract): removed
	workaround for above bug.



Modified:
   trunk/ChangeLog
   trunk/app/base/tile-manager.c
   trunk/app/base/tile-private.h
   trunk/app/core/gimpselection.c

Modified: trunk/app/base/tile-manager.c
==============================================================================
--- trunk/app/base/tile-manager.c	(original)
+++ trunk/app/base/tile-manager.c	Thu Aug  7 15:29:02 2008
@@ -152,7 +152,7 @@
                   gboolean     wantwrite)
 {
   Tile **tiles;
-  Tile **tile_ptr;
+  Tile  *tile;
   gint   ntiles;
   gint   nrows, ncols;
   gint   right_tile;
@@ -198,15 +198,14 @@
         }
     }
 
-  tile_ptr = &tm->tiles[tile_num];
+  tile = tm->tiles[tile_num];
 
   if (G_UNLIKELY (wantwrite && ! wantread))
     g_warning ("WRITE-ONLY TILE... UNTESTED!");
 
 #ifdef DEBUG_TILE_MANAGER
-  if (G_UNLIKELY ((*tile_ptr)->share_count && (*tile_ptr)->write_count))
-    g_printerr (">> MEEPITY %d,%d <<\n",
-                (*tile_ptr)->share_count, (*tile_ptr)->write_count);
+  if (G_UNLIKELY (tile->share_count && tile->write_count))
+    g_printerr (">> MEEPITY %d,%d <<\n", tile->share_count, tile->write_count);
 #endif
 
   if (wantread)
@@ -221,59 +220,59 @@
               tm->cached_num  = -1;
             }
 
-          if ((*tile_ptr)->share_count > 1)
+          if (tile->share_count > 1)
             {
               /* Copy-on-write required */
-              Tile *new = tile_new ((*tile_ptr)->bpp);
+              Tile *new = tile_new (tile->bpp);
 
-              new->ewidth  = (*tile_ptr)->ewidth;
-              new->eheight = (*tile_ptr)->eheight;
-              new->valid   = (*tile_ptr)->valid;
+              new->ewidth  = tile->ewidth;
+              new->eheight = tile->eheight;
+              new->valid   = tile->valid;
 
               new->size    = new->ewidth * new->eheight * new->bpp;
               new->data    = g_new (guchar, new->size);
 
-              if ((*tile_ptr)->rowhint)
+              if (tile->rowhint)
                 {
                   tile_allocate_rowhints (new);
 
-                  memcpy (new->rowhint, (*tile_ptr)->rowhint,
+                  memcpy (new->rowhint, tile->rowhint,
                           new->eheight * sizeof (TileRowHint));
                 }
 
-              if ((*tile_ptr)->data)
+              if (tile->data)
                 {
-                  memcpy (new->data, (*tile_ptr)->data, new->size);
+                  memcpy (new->data, tile->data, new->size);
                 }
               else
                 {
-                  tile_lock (*tile_ptr);
-                  memcpy (new->data, (*tile_ptr)->data, new->size);
-                  tile_release (*tile_ptr, FALSE);
+                  tile_lock (tile);
+                  memcpy (new->data, tile->data, new->size);
+                  tile_release (tile, FALSE);
                 }
 
-              tile_detach (*tile_ptr, tm, tile_num);
-
+              tile_detach (tile, tm, tile_num);
               tile_attach (new, tm, tile_num);
-              *tile_ptr = new;
+
+              tile = new;
+              tm->tiles[tile_num] = tile;
             }
 
-          (*tile_ptr)->write_count++;
-          (*tile_ptr)->dirty = TRUE;
+          tile->write_count++;
+          tile->dirty = TRUE;
         }
 #ifdef DEBUG_TILE_MANAGER
       else
         {
-          if (G_UNLIKELY ((*tile_ptr)->write_count))
-            g_printerr ("STINK! r/o on r/w tile (%d)\n",
-                        (*tile_ptr)->write_count);
+          if (G_UNLIKELY (tile->write_count))
+            g_printerr ("STINK! r/o on r/w tile (%d)\n", tile->write_count);
         }
 #endif
 
-      tile_lock (*tile_ptr);
+      tile_lock (tile);
     }
 
-  return *tile_ptr;
+  return tile;
 }
 
 Tile *
@@ -335,26 +334,25 @@
       tm->cached_num  = -1;
     }
 
+  if (tile->listhead)
+    tile_cache_flush (tile);
+
   if (G_UNLIKELY (tile->share_count > 1))
     {
-      /* This tile is shared.  Replace it with a new, invalid tile. */
+      /* This tile is shared.  Replace it with a new invalid tile. */
       Tile *new = tile_new (tile->bpp);
 
-      g_print ("invalidating shared tile (executing buggy code!!!)\n");
-
       new->ewidth  = tile->ewidth;
       new->eheight = tile->eheight;
       new->size    = tile->size;
 
       tile_detach (tile, tm, tile_num);
-
       tile_attach (new, tm, tile_num);
+
       tile = new;
+      tm->tiles[tile_num] = tile;
     }
 
-  if (tile->listhead)
-    tile_cache_flush (tile);
-
   tile->valid = FALSE;
 
   if (tile->data)
@@ -413,7 +411,7 @@
                   Tile        *srctile)
 {
   Tile **tiles;
-  Tile **tile_ptr;
+  Tile  *tile;
   gint   ntiles;
   gint   nrows, ncols;
   gint   right_tile;
@@ -468,7 +466,7 @@
         }
     }
 
-  tile_ptr = &tm->tiles[tile_num];
+  tile = tm->tiles[tile_num];
 
 #ifdef DEBUG_TILE_MANAGER
   g_printerr (")");
@@ -477,15 +475,15 @@
   if (G_UNLIKELY (! srctile->valid))
     g_warning("%s: srctile not validated yet!  please report", G_STRLOC);
 
-  if (G_UNLIKELY ((*tile_ptr)->ewidth  != srctile->ewidth  ||
-                  (*tile_ptr)->eheight != srctile->eheight ||
-                  (*tile_ptr)->bpp     != srctile->bpp))
+  if (G_UNLIKELY (tile->ewidth  != srctile->ewidth  ||
+                  tile->eheight != srctile->eheight ||
+                  tile->bpp     != srctile->bpp))
     {
       g_warning ("%s: nonconformant map (%p -> %p)",
-                 G_STRLOC, srctile, *tile_ptr);
+                 G_STRLOC, srctile, tile);
     }
 
-  tile_detach (*tile_ptr, tm, tile_num);
+  tile_detach (tile, tm, tile_num);
 
 #ifdef DEBUG_TILE_MANAGER
   g_printerr (">");
@@ -496,7 +494,8 @@
 #endif
 
   tile_attach (srctile, tm, tile_num);
-  *tile_ptr = srctile;
+
+  tm->tiles[tile_num] = srctile;
 
 #ifdef DEBUG_TILE_MANAGER
   g_printerr ("}\n");

Modified: trunk/app/base/tile-private.h
==============================================================================
--- trunk/app/base/tile-private.h	(original)
+++ trunk/app/base/tile-private.h	Thu Aug  7 15:29:02 2008
@@ -71,8 +71,8 @@
 
   TileLink *tlink;
 
-  Tile     *next;
-  Tile     *prev;       /* List pointers for the tile cache lists */
+  Tile     *next;       /* List pointers for the tile cache lists */
+  Tile     *prev;
   gpointer  listhead;   /* Pointer to the head of the list this tile is on */
 };
 

Modified: trunk/app/core/gimpselection.c
==============================================================================
--- trunk/app/core/gimpselection.c	(original)
+++ trunk/app/core/gimpselection.c	Thu Aug  7 15:29:02 2008
@@ -753,18 +753,7 @@
       else
         {
           /*  Otherwise, do a straight copy  */
-          if (GIMP_IS_DRAWABLE (pickable))
-            {
-              copy_region (&srcPR, &destPR);
-            }
-          else
-            {
-              /*  There's a bug that shows up when shared tiles are
-               *  invalidated. So we don't copy-on-write from the
-               *  projection.
-               */
-              copy_region_nocow (&srcPR, &destPR);
-            }
+          copy_region (&srcPR, &destPR);
         }
 
       /*  If we're cutting, remove either the layer (or floating selection),



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]