[gimp] whitespace and coding style cleanups
- From: Sven Neumann <neo src gnome org>
- To: svn-commits-list gnome org
- Subject: [gimp] whitespace and coding style cleanups
- Date: Thu, 4 Jun 2009 06:19:10 -0400 (EDT)
commit b2fc6d287616d102c072dba27ff07758414410be
Author: Sven Neumann <sven gimp org>
Date: Thu Jun 4 11:13:42 2009 +0200
whitespace and coding style cleanups
---
app/base/tile-cache.c | 146 +++++++++++++++++++++++++----------------------
app/base/tile-cache.h | 13 ++--
app/base/tile-manager.c | 1 +
app/base/tile-swap.c | 63 +++++++++++---------
app/base/tile.c | 9 ++-
5 files changed, 126 insertions(+), 106 deletions(-)
diff --git a/app/base/tile-cache.c b/app/base/tile-cache.c
index 4fb7f87..108a21e 100644
--- a/app/base/tile-cache.c
+++ b/app/base/tile-cache.c
@@ -27,14 +27,11 @@
#include "tile-rowhints.h"
#include "tile-private.h"
+
#define IDLE_SWAPPER_START 1000
#define IDLE_SWAPPER_INTERVAL_MS 20
#define IDLE_SWAPPER_TILES_PER_INTERVAL 10
-static gboolean tile_cache_zorch_next (void);
-static void tile_cache_flush_internal (Tile *tile);
-static gboolean tile_idle_preswap (gpointer data);
-static void tile_verify(void);
typedef struct _TileList
{
@@ -42,6 +39,7 @@ typedef struct _TileList
Tile *last;
} TileList;
+
static gulong cur_cache_size = 0;
static gulong max_cache_size = 0;
static gulong cur_cache_dirty = 0;
@@ -75,6 +73,15 @@ static GMutex *tile_cache_mutex = NULL;
#define PENDING_WRITE(t) ((t)->dirty || (t)->swap_offset == -1)
+
+static gboolean tile_cache_zorch_next (void);
+static void tile_cache_flush_internal (Tile *tile);
+static gboolean tile_idle_preswap (gpointer data);
+#ifdef TILE_PROFILING
+static void tile_verify (void);
+#endif
+
+
void
tile_cache_init (gulong tile_cache_size)
{
@@ -167,9 +174,9 @@ tile_cache_insert (Tile *tile)
{
GTimeVal now;
GTimeVal later;
+
g_get_current_time(&now);
#endif
-
while ((cur_cache_size + tile->size) > max_cache_size)
{
if (! tile_cache_zorch_next ())
@@ -180,7 +187,7 @@ tile_cache_insert (Tile *tile)
}
#ifdef TILE_PROFILING
- g_get_current_time(&later);
+ g_get_current_time (&later);
tile_total_interactive_usec += later.tv_usec - now.tv_usec;
tile_total_interactive_sec += later.tv_sec - now.tv_sec;
@@ -195,7 +202,6 @@ tile_cache_insert (Tile *tile)
tile_total_interactive_usec -= 1000000;
tile_total_interactive_sec++;
}
-
}
#endif
@@ -206,11 +212,12 @@ tile_cache_insert (Tile *tile)
tile->next = NULL;
tile->prev = tile_list.last;
- if(tile_list.last){
+
+ if (tile_list.last)
tile_list.last->next = tile;
- }else{
+ else
tile_list.first = tile;
- }
+
tile_list.last = tile;
tile->cached = TRUE;
idle_delay = 1;
@@ -219,12 +226,11 @@ tile_cache_insert (Tile *tile)
{
cur_cache_dirty += tile->size;
- if(!idle_scan_last)
+ if (! idle_scan_last)
idle_scan_last=tile;
-
- if (!idle_swapper)
- {
+ if (! idle_swapper)
+ {
#ifdef TILE_PROFILING
g_printerr("idle swapper -> started\n");
g_printerr("idle swapper -> waiting");
@@ -274,48 +280,51 @@ tile_cache_flush_internal (Tile *tile)
{
tile->cached = FALSE;
+
if (PENDING_WRITE(tile))
cur_cache_dirty -= tile->size;
+
cur_cache_size -= tile->size;
-
+
if (tile->next)
tile->next->prev = tile->prev;
else
tile_list.last = tile->prev;
-
- if(tile->prev){
+
+ if (tile->prev)
tile->prev->next = tile->next;
- }else{
+ else
tile_list.first = tile->next;
- }
-
- if(tile == idle_scan_last)
+
+ if (tile == idle_scan_last)
idle_scan_last = tile->next;
-
- tile->next = tile->prev = NULL;
+ tile->next = tile->prev = NULL;
}
static gboolean
tile_cache_zorch_next (void)
{
- Tile *tile = tile_list.first;
- if(!tile)return FALSE;
-
+ Tile *tile = tile_list.first;
+
+ if (! tile)
+ return FALSE;
+
#ifdef TILE_PROFILING
tile_total_zorched++;
tile->zorched = TRUE;
- if(PENDING_WRITE(tile))
+
+ if (PENDING_WRITE (tile))
{
tile_total_zorched_swapout++;
tile->zorchout = TRUE;
}
#endif
-
+
tile_cache_flush_internal (tile);
- if (PENDING_WRITE(tile))
+ if (PENDING_WRITE (tile))
{
idle_delay = 1;
tile_swap_out (tile);
@@ -325,6 +334,7 @@ tile_cache_zorch_next (void)
{
g_free (tile->data);
tile->data = NULL;
+
#ifdef TILE_PROFILING
tile_exist_count--;
#endif
@@ -362,46 +372,48 @@ tile_idle_preswap_run (gpointer data)
tile = idle_scan_last;
- while(tile)
+ while (tile)
{
- if(PENDING_WRITE(tile))
+ if (PENDING_WRITE (tile))
{
idle_scan_last = tile->next;
-
+
#ifdef TILE_PROFILING
tile_idle_swapout++;
#endif
tile_swap_out (tile);
- if(!PENDING_WRITE(tile))
+
+ if (! PENDING_WRITE(tile))
cur_cache_dirty -= tile->size;
+
count++;
-
- if(count>=IDLE_SWAPPER_TILES_PER_INTERVAL)
+ if (count >= IDLE_SWAPPER_TILES_PER_INTERVAL)
{
TILE_CACHE_UNLOCK;
return TRUE;
}
}
+
tile = tile->next;
}
-
- g_printerr("\nidle swapper -> stopped\n");
+
+ g_printerr ("\nidle swapper -> stopped\n");
idle_scan_last = NULL;
idle_swapper = 0;
#ifdef TILE_PROFILING
- tile_verify();
+ tile_verify ();
#endif
TILE_CACHE_UNLOCK;
-
+
return FALSE;
}
static gboolean
tile_idle_preswap (gpointer data)
{
-
+
if (idle_delay){
#ifdef TILE_PROFILING
g_printerr(".");
@@ -409,12 +421,12 @@ tile_idle_preswap (gpointer data)
idle_delay = 0;
return TRUE;
}
-
+
#ifdef TILE_PROFILING
- tile_verify();
+ tile_verify ();
g_printerr("\nidle swapper -> running");
#endif
-
+
idle_swapper = g_timeout_add_full (G_PRIORITY_LOW,
IDLE_SWAPPER_INTERVAL_MS,
tile_idle_preswap_run,
@@ -424,41 +436,39 @@ tile_idle_preswap (gpointer data)
#ifdef TILE_PROFILING
static void
-tile_verify(void)
+tile_verify (void)
{
/* scan list linearly, count metrics, compare to running totals */
- gulong local_size=0;
- gulong local_dirty=0;
- gulong acc=0;
- Tile *t = tile_list.first;
+ const Tile *t;
+ gulong local_size = 0;
+ gulong local_dirty = 0;
+ gulong acc = 0;
- while(t)
+ for (t = tile_list.first; t; t = t->next)
{
- local_size+=t->size;
- if(PENDING_WRITE(t))
- local_dirty+=t->size;
- t=t->next;
+ local_size += t->size;
+
+ if (PENDING_WRITE (t))
+ local_dirty += t->size;
}
- if(local_size != cur_cache_size)
- g_printerr("\nCache size mismatch: running=%lu, tested=%lu\n",
- cur_cache_size,local_size);
+ if (local_size != cur_cache_size)
+ g_printerr ("\nCache size mismatch: running=%lu, tested=%lu\n",
+ cur_cache_size,local_size);
- if(local_dirty != cur_cache_dirty)
- g_printerr("\nCache dirty mismatch: running=%lu, tested=%lu\n",
- cur_cache_dirty,local_dirty);
+ if (local_dirty != cur_cache_dirty)
+ g_printerr ("\nCache dirty mismatch: running=%lu, tested=%lu\n",
+ cur_cache_dirty,local_dirty);
/* scan forward from scan list */
- t = idle_scan_last;
- while(t)
+ for (t = idle_scan_last; t; t = t->next)
{
- if(PENDING_WRITE(t))
- acc+=t->size;
- t=t->next;
+ if (PENDING_WRITE (t))
+ acc += t->size;
}
-
- if(acc != local_dirty)
- g_printerr("\nDirty scan follower mismatch: running=%lu, tested=%lu\n",
- acc,local_dirty);
+
+ if (acc != local_dirty)
+ g_printerr ("\nDirty scan follower mismatch: running=%lu, tested=%lu\n",
+ acc,local_dirty);
}
#endif
diff --git a/app/base/tile-cache.h b/app/base/tile-cache.h
index 09ba4e2..ed1e3d5 100644
--- a/app/base/tile-cache.h
+++ b/app/base/tile-cache.h
@@ -19,14 +19,13 @@
#define __TILE_CACHE_H__
-void tile_cache_init (gulong cache_size);
-void tile_cache_exit (void);
+void tile_cache_init (gulong cache_size);
+void tile_cache_exit (void);
-void tile_cache_set_size (gulong cache_size);
-void tile_cache_suspend_idle_swapper(void);
-
-void tile_cache_insert (Tile *tile);
-void tile_cache_flush (Tile *tile);
+void tile_cache_set_size (gulong cache_size);
+void tile_cache_suspend_idle_swapper (void);
+void tile_cache_insert (Tile *tile);
+void tile_cache_flush (Tile *tile);
#endif /* __TILE_CACHE_H__ */
diff --git a/app/base/tile-manager.c b/app/base/tile-manager.c
index 6dd8dab..1186781 100644
--- a/app/base/tile-manager.c
+++ b/app/base/tile-manager.c
@@ -203,6 +203,7 @@ tile_manager_get (TileManager *tm,
new->size = new->ewidth * new->eheight * new->bpp;
new->data = g_new (guchar, new->size);
+
#ifdef TILE_PROFILING
tile_exist_count++;
if (tile_exist_count > tile_exist_peak)
diff --git a/app/base/tile-swap.c b/app/base/tile-swap.c
index 6953867..b65526e 100644
--- a/app/base/tile-swap.c
+++ b/app/base/tile-swap.c
@@ -122,30 +122,30 @@ static gulong tile_total_seek = 0;
/* how many tiles were swapped out under cache pressure but never
swapped back in? This does not count idle swapped tiles, as those
do not contribute to any perceived load or latency */
-static gulong tile_total_wasted_swapout = 0;
+static gulong tile_total_wasted_swapout = 0;
/* total tile flushes under cache pressure */
-gulong tile_total_zorched = 0;
-gulong tile_total_zorched_swapout = 0;
-static gulong tile_total_zorched_swapin = 0;
+gulong tile_total_zorched = 0;
+gulong tile_total_zorched_swapout = 0;
+static gulong tile_total_zorched_swapin = 0;
/* total tiles swapped out to swap file (not total calls to swap out;
this only counts actual flushes to disk) */
-static gulong tile_total_swapout = 0;
-static gulong tile_unique_swapout = 0;
-gulong tile_idle_swapout = 0;
+static gulong tile_total_swapout = 0;
+static gulong tile_unique_swapout = 0;
+gulong tile_idle_swapout = 0;
/* total tiles swapped in from swap file (not total calls to swap in;
this only counts actual tile reads from disk) */
-static gulong tile_total_swapin = 0;
-static gulong tile_unique_swapin = 0;
+static gulong tile_total_swapin = 0;
+static gulong tile_unique_swapin = 0;
/* total dead time spent waiting to read or write */
-static glong tile_total_swapwait_sec = 0;
-static glong tile_total_swapwait_usec = 0;
+static glong tile_total_swapwait_sec = 0;
+static glong tile_total_swapwait_usec = 0;
/* total time spent in tile cache due to cache pressure */
-glong tile_total_interactive_sec = 0;
+glong tile_total_interactive_sec = 0;
glong tile_total_interactive_usec = 0;
#endif
@@ -231,21 +231,25 @@ tile_swap_exit (void)
g_printerr ("\n\nPeak Tile usage: %d Tile structs\n\n",
tile_exist_peak);
- g_printerr ("Total tiles swapped out to disk: %lu\n",tile_total_swapout);
- g_printerr ("Unique tiles swapped out to disk: %lu\n",tile_unique_swapout);
- g_printerr ("Total tiles swapped in from disk: %lu\n",tile_total_swapin);
- g_printerr ("Unique tiles swapped in from disk: %lu\n",tile_unique_swapin);
- g_printerr ("Tiles swapped out by idle swapper: %lu\n",tile_idle_swapout);
- g_printerr ("Total seeks during swapping: %lu\n",tile_total_seek);
+ g_printerr ("Total tiles swapped out to disk: %lu\n", tile_total_swapout);
+ g_printerr ("Unique tiles swapped out to disk: %lu\n", tile_unique_swapout);
+ g_printerr ("Total tiles swapped in from disk: %lu\n", tile_total_swapin);
+ g_printerr ("Unique tiles swapped in from disk: %lu\n", tile_unique_swapin);
+ g_printerr ("Tiles swapped out by idle swapper: %lu\n", tile_idle_swapout);
+ g_printerr ("Total seeks during swapping: %lu\n", tile_total_seek);
g_printerr ("Total time spent in swap: %f seconds\n\n",
- tile_total_swapwait_sec+.000001*tile_total_swapwait_usec);
-
- g_printerr ("Total zorched tiles: %lu\n",tile_total_zorched);
- g_printerr ("Total zorched tiles swapped out: %lu\n",tile_total_zorched_swapout);
- g_printerr ("Total zorched tiles swapped back in: %lu\n",tile_total_zorched_swapin);
- g_printerr ("Total zorched tiles wasted after swapping out: %lu\n",tile_total_wasted_swapout);
+ tile_total_swapwait_sec + 0.000001 * tile_total_swapwait_usec);
+
+ g_printerr ("Total zorched tiles: %lu\n", tile_total_zorched);
+ g_printerr ("Total zorched tiles swapped out: %lu\n",
+ tile_total_zorched_swapout);
+ g_printerr ("Total zorched tiles swapped back in: %lu\n",
+ tile_total_zorched_swapin);
+ g_printerr ("Total zorched tiles wasted after swapping out: %lu\n",
+ tile_total_wasted_swapout);
g_printerr ("Total interactive swap/cache delay: %f seconds\n\n",
- tile_total_interactive_sec+.000001*tile_total_interactive_usec);
+ tile_total_interactive_sec +
+ 0.000001 * tile_total_interactive_usec);
#endif
@@ -271,6 +275,7 @@ tile_swap_exit (void)
gimp_swap_file->fd = -1;
}
#endif
+
g_unlink (gimp_swap_file->filename);
g_free (gimp_swap_file->filename);
@@ -377,8 +382,8 @@ tile_swap_default_in (SwapFile *swap_file,
tile_cache_suspend_idle_swapper();
-#ifdef TILE_PROFILING
- g_get_current_time(&now);
+#ifdef TILE_PROFILING
+ g_get_current_time (&now);
tile_total_swapin++;
if (tile->zorched)
@@ -436,7 +441,7 @@ tile_swap_default_in (SwapFile *swap_file,
}
#ifdef TILE_PROFILING
- g_get_current_time(&later);
+ g_get_current_time (&later);
tile_total_swapwait_usec += later.tv_usec - now.tv_usec;
tile_total_swapwait_sec += later.tv_sec - now.tv_sec;
@@ -547,7 +552,7 @@ tile_swap_default_out (SwapFile *swap_file,
}
#ifdef TILE_PROFILING
- g_get_current_time(&later);
+ g_get_current_time (&later);
tile_total_swapwait_usec += later.tv_usec - now.tv_usec;
tile_total_swapwait_sec += later.tv_sec - now.tv_sec;
diff --git a/app/base/tile.c b/app/base/tile.c
index d011a23..2256110 100644
--- a/app/base/tile.c
+++ b/app/base/tile.c
@@ -42,14 +42,15 @@ static gint tile_count = 0;
static gint tile_share_count = 0;
static gint tile_active_count = 0;
-gint tile_exist_peak = 0;
-gint tile_exist_count = 0;
+gint tile_exist_peak = 0;
+gint tile_exist_count = 0;
#endif
static void tile_destroy (Tile *tile);
+
Tile *
tile_new (gint bpp)
{
@@ -163,6 +164,7 @@ tile_alloc (Tile *tile)
#ifdef TILE_PROFILING
tile_exist_count++;
+
if (tile_exist_count > tile_exist_peak)
tile_exist_peak = tile_exist_count;
#endif
@@ -181,14 +183,17 @@ tile_destroy (Tile *tile)
g_warning ("tried to destroy an attached tile");
return;
}
+
if (tile->data)
{
g_free (tile->data);
tile->data = NULL;
+
#ifdef TILE_PROFILING
tile_exist_count--;
#endif
}
+
if (tile->rowhint)
{
g_slice_free1 (sizeof (TileRowHint) * TILE_HEIGHT, tile->rowhint);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]