gimp r26446 - in trunk: . app/base



Author: neo
Date: Fri Aug  8 11:33:18 2008
New Revision: 26446
URL: http://svn.gnome.org/viewvc/gimp?rev=26446&view=rev

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

	* app/base/tile-manager.c: implement
	tile_manager_get_tile_coordinates() by calling
	tile_manager_get_tile_col_row() instead of the other way around.
	Saves two multiplications and divisions for each call of
	tile_manager_get_tile_col_row().



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

Modified: trunk/app/base/tile-manager.c
==============================================================================
--- trunk/app/base/tile-manager.c	(original)
+++ trunk/app/base/tile-manager.c	Fri Aug  8 11:33:18 2008
@@ -581,17 +581,12 @@
   return memsize;
 }
 
-void
-tile_manager_get_tile_coordinates (TileManager *tm,
-                                   Tile        *tile,
-                                   gint        *x,
-                                   gint        *y)
+static inline gint
+tile_manager_locate_tile (TileManager *tm,
+                          Tile        *tile)
 {
   TileLink *tl;
 
-  g_return_if_fail (tm != NULL);
-  g_return_if_fail (x != NULL && y != NULL);
-
   for (tl = tile->tlink; tl; tl = tl->next)
     {
       if (tl->tm == tm)
@@ -601,11 +596,10 @@
   if (G_UNLIKELY (tl == NULL))
     {
       g_warning ("%s: tile not attached to manager", G_STRLOC);
-      return;
+      return 0;
     }
 
-  *x = TILE_WIDTH * (tl->tile_num % tm->ntile_cols);
-  *y = TILE_HEIGHT * (tl->tile_num / tm->ntile_cols);
+  return tl->tile_num;
 }
 
 void
@@ -614,15 +608,35 @@
                                gint        *tile_col,
                                gint        *tile_row)
 {
-  gint tile_x;
-  gint tile_y;
+  gint tile_num;
+
+  g_return_if_fail (tm != NULL);
+  g_return_if_fail (tile != NULL);
+  g_return_if_fail (tile_col != NULL && tile_row != NULL);
+
+  tile_num = tile_manager_locate_tile (tm, tile);
 
-  g_return_if_fail (tm && tile && tile_col && tile_row);
+  *tile_col = tile_num % tm->ntile_cols;
+  *tile_row = tile_num / tm->ntile_cols;
+}
+
+void
+tile_manager_get_tile_coordinates (TileManager *tm,
+                                   Tile        *tile,
+                                   gint        *x,
+                                   gint        *y)
+{
+  gint tile_col;
+  gint tile_row;
+
+  g_return_if_fail (tm != NULL);
+  g_return_if_fail (tile != NULL);
+  g_return_if_fail (x != NULL && y != NULL);
 
-  tile_manager_get_tile_coordinates (tm, tile, &tile_x, &tile_y);
+  tile_manager_get_tile_col_row (tm, tile, &tile_col, &tile_row);
 
-  *tile_col = tile_x / TILE_WIDTH;
-  *tile_row = tile_y / TILE_HEIGHT;
+  *x = TILE_WIDTH  * tile_col;
+  *y = TILE_HEIGHT * tile_row;
 }
 
 void



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