gimp r26757 - in trunk: . app/base



Author: neo
Date: Mon Aug 25 13:00:28 2008
New Revision: 26757
URL: http://svn.gnome.org/viewvc/gimp?rev=26757&view=rev

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

	* app/base/tile-private.h: provide a macro version of
	tile_data_pointer().

	* app/base/tile.c (tile_data_pointer): turned into a wrapper
	around the TILE_DATA_POINTER() macro.

	* app/base/tile-manager.c (read_pixel_data) (read_pixel_data_1)
	(write_pixel_data) (write_pixel_data_1): access tile struct
	members directly and use the new macro to access the tile data.



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

Modified: trunk/app/base/tile-manager.c
==============================================================================
--- trunk/app/base/tile-manager.c	(original)
+++ trunk/app/base/tile-manager.c	Mon Aug 25 13:00:28 2008
@@ -679,21 +679,21 @@
   for (y = y1; y <= y2; y += TILE_HEIGHT - (y % TILE_HEIGHT))
     for (x = x1; x <= x2; x += TILE_WIDTH - (x % TILE_WIDTH))
       {
-        Tile         *t = tile_manager_get_tile (tm, x, y, TRUE, FALSE);
-        const guchar *s = tile_data_pointer (t, x, y);
-        guchar       *d = buffer + stride * (y - y1) + tm->bpp * (x - x1);
+        Tile         *tile = tile_manager_get_tile (tm, x, y, TRUE, FALSE);
+        const guchar *s    = TILE_DATA_POINTER (tile, x, y);
+        guchar       *d    = buffer + stride * (y - y1) + tm->bpp * (x - x1);
         guint         rows, cols;
         guint         srcstride;
 
-        rows = tile_eheight (t) - y % TILE_HEIGHT;
+        rows = tile->eheight - y % TILE_HEIGHT;
         if (rows > (y2 - y + 1))
           rows = y2 - y + 1;
 
-        cols = tile_ewidth (t) - x % TILE_WIDTH;
+        cols = tile->ewidth - x % TILE_WIDTH;
         if (cols > (x2 - x + 1))
           cols = x2 - x + 1;
 
-        srcstride = tile_ewidth (t) * tile_bpp (t);
+        srcstride = tile->ewidth * tile->bpp;
 
         while (rows--)
           {
@@ -703,7 +703,7 @@
             d += stride;
           }
 
-        tile_release (t, FALSE);
+        tile_release (tile, FALSE);
       }
 }
 
@@ -721,21 +721,21 @@
   for (y = y1; y <= y2; y += TILE_HEIGHT - (y % TILE_HEIGHT))
     for (x = x1; x <= x2; x += TILE_WIDTH - (x % TILE_WIDTH))
       {
-        Tile         *t = tile_manager_get_tile (tm, x, y, TRUE, TRUE);
-        const guchar *s = buffer + stride * (y - y1) + tm->bpp * (x - x1);
-        guchar       *d = tile_data_pointer (t, x, y);
+        Tile         *tile = tile_manager_get_tile (tm, x, y, TRUE, TRUE);
+        const guchar *s    = buffer + stride * (y - y1) + tm->bpp * (x - x1);
+        guchar       *d    = TILE_DATA_POINTER (tile, x, y);
         guint         rows, cols;
         guint         dststride;
 
-        rows = tile_eheight (t) - y % TILE_HEIGHT;
+        rows = tile->eheight - y % TILE_HEIGHT;
         if (rows > (y2 - y + 1))
           rows = y2 - y + 1;
 
-        cols = tile_ewidth (t) - x % TILE_WIDTH;
+        cols = tile->ewidth - x % TILE_WIDTH;
         if (cols > (x2 - x + 1))
           cols = x2 - x + 1;
 
-        dststride = tile_ewidth (t) * tile_bpp (t);
+        dststride = tile->ewidth * tile->bpp;
 
         while (rows--)
           {
@@ -745,7 +745,7 @@
             d += dststride;
           }
 
-        tile_release (t, TRUE);
+        tile_release (tile, TRUE);
       }
 }
 
@@ -783,7 +783,7 @@
     }
 
   {
-    const guchar *src = tile_data_pointer (tm->cached_tile, x, y);
+    const guchar *src = TILE_DATA_POINTER (tm->cached_tile, x, y);
 
     switch (tm->bpp)
       {
@@ -806,7 +806,7 @@
                     const guchar *buffer)
 {
   Tile   *tile = tile_manager_get_tile (tm, x, y, TRUE, TRUE);
-  guchar *dest = tile_data_pointer (tile, x, y);
+  guchar *dest = TILE_DATA_POINTER (tile, x, y);
 
   switch (tm->bpp)
     {

Modified: trunk/app/base/tile-private.h
==============================================================================
--- trunk/app/base/tile-private.h	(original)
+++ trunk/app/base/tile-private.h	Mon Aug 25 13:00:28 2008
@@ -77,4 +77,11 @@
 };
 
 
+/*  tile_data_pointer() as a macro so that it can be inlined  */
+
+#define TILE_DATA_POINTER(tile,x,y) \
+  ((tile)->data + \
+   (((y) % TILE_HEIGHT) * (tile)->ewidth + ((x) % TILE_WIDTH)) * (tile)->bpp)
+
+
 #endif /* __TILE_PRIVATE_H__ */

Modified: trunk/app/base/tile.c
==============================================================================
--- trunk/app/base/tile.c	(original)
+++ trunk/app/base/tile.c	Mon Aug 25 13:00:28 2008
@@ -53,7 +53,7 @@
 #endif
 
 
-static void tile_destroy (Tile *tile);
+static void  tile_destroy (Tile *tile);
 
 
 Tile *
@@ -333,9 +333,7 @@
                    gint  xoff,
                    gint  yoff)
 {
-  gsize offset = (yoff % TILE_HEIGHT) * tile->ewidth + (xoff % TILE_WIDTH);
-
-  return (gpointer) (tile->data + offset * tile->bpp);
+  return TILE_DATA_POINTER (tile, xoff, yoff);
 }
 
 gint



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