gegl r2194 - in trunk: . gegl/buffer



Author: ok
Date: Fri Apr 18 21:37:52 2008
New Revision: 2194
URL: http://svn.gnome.org/viewvc/gegl?rev=2194&view=rev

Log:
* gegl/buffer/gegl-tile-handler-cache.h: moved instance struct ..
* gegl/buffer/gegl-tile-handler-cache.c: .. to c file since it is all
private and we do not expect subclasses any time soon.
(dispose): only dispose tiles belonging to this cache instance
* gegl/buffer/gegl-tile-handler-log.c: (command): improved formatting.
* gegl/buffer/gegl-tile-storage.c: (gegl_tile_storage_constructor):
added GEGL_TILE_LOG as an environment flag to turn on the commands
communicated to the backend.
* gegl/buffer/gegl-tile.c:
(gegl_tile_store): bail early if rev==stored_rev.


Modified:
   trunk/ChangeLog
   trunk/gegl/buffer/gegl-tile-handler-cache.c
   trunk/gegl/buffer/gegl-tile-handler-cache.h
   trunk/gegl/buffer/gegl-tile-handler-log.c
   trunk/gegl/buffer/gegl-tile-storage.c
   trunk/gegl/buffer/gegl-tile.c

Modified: trunk/gegl/buffer/gegl-tile-handler-cache.c
==============================================================================
--- trunk/gegl/buffer/gegl-tile-handler-cache.c	(original)
+++ trunk/gegl/buffer/gegl-tile-handler-cache.c	Fri Apr 18 21:37:52 2008
@@ -35,6 +35,18 @@
 static gint    cache_hits = 0;
 static gint    cache_misses = 0;
 
+struct _GeglTileHandlerCache
+{
+  GeglTileHandler parent_instance;
+  GSList *free_list;
+
+/*  GQueue     *queue;
+  gint        size;
+  gint        wash_percentage;
+  gint        hits;
+  gint        misses;*/
+};
+
 void gegl_tile_cache_init (void)
 {
   if (cache_queue == NULL)
@@ -91,24 +103,47 @@
 }
 
 static void
+queue_each (gpointer itm,
+            gpointer userdata)
+{
+  CacheItem *item = itm;
+  if (item->handler == userdata)
+    {
+      GeglTileHandlerCache *cache = userdata;
+      cache->free_list = g_slist_prepend (cache->free_list, item);
+      
+    }
+}
+
+static void
 dispose (GObject *object)
 {
   GeglTileHandlerCache *cache;
   CacheItem        *item;
   cache = (GeglTileHandlerCache *) object;
+  GSList *iter;
 
   if (0)
     g_printerr ("Disposing tile-cache of size %i, hits: %i misses: %i  hit percentage:%f)\n",
                 cache_size, cache_hits, cache_misses,
                 cache_hits * 100.0 / (cache_hits + cache_misses));
 
-  /* FIXME: only throw out this cache's items */
-  while ((item = g_queue_pop_head (cache_queue)))
+  /* only throw out items belonging to this cache instance
+     (XXX: should probably have a local list for that)*/
+
+  cache->free_list = NULL;
+  g_queue_foreach (cache_queue, queue_each, cache);
+  for (iter = cache->free_list; iter; iter = g_slist_next (iter))
     {
-      g_object_unref (item->tile);
-      g_slice_free (CacheItem, item);
+        item = iter->data;
+        if (item->tile)
+          g_object_unref (item->tile);
+        g_queue_remove (cache_queue, item);
+        g_slice_free (CacheItem, item);
     }
-  /* FIXME: if queue is empty destroy global queue */
+  g_slist_free (cache->free_list);
+  cache->free_list = NULL;
+#endif
 
   G_OBJECT_CLASS (gegl_tile_handler_cache_parent_class)->dispose (object);
 }
@@ -123,7 +158,7 @@
   GeglTileSource       *source = GEGL_HANDLER (tile_store)->source;
   GeglTile         *tile     = NULL;
 
-  if(0)g_print ("%f%% hit:%i miss:%i  \r", cache_hits*100.0/(cache_hits+cache_misses), cache_hits, cache_misses);
+  if(0)g_print ("\r%f%% hit:%i miss:%i  %i]", cache_hits*100.0/(cache_hits+cache_misses), cache_hits, cache_misses, g_queue_get_length (cache_queue));
 
   tile = gegl_tile_handler_cache_get_tile (cache, x, y, z);
   if (tile)
@@ -142,7 +177,6 @@
   return tile;
 }
 
-
 static gpointer
 command (GeglTileSource  *tile_store,
          GeglTileCommand  command,
@@ -157,7 +191,14 @@
   /* FIXME: replace with switch */
   switch (command)
     {
+      case GEGL_TILE_SET:
+        /* nothing to do */
+        break;
       case GEGL_TILE_GET:
+        /* XXX: we should perhaps store a NIL result, and place the empty
+         * generator after the cache, this would have to be possible to disable
+         * to work in sync operation with backend.
+         */
         return get_tile (tile_store, x, y, z);
       case GEGL_TILE_IS_CACHED:
         return (gpointer)gegl_tile_handler_cache_has_tile (cache, x, y, z);
@@ -177,6 +218,8 @@
         }
       case GEGL_TILE_VOID:
         gegl_tile_handler_cache_void (cache, x, y, z);
+        if (z!=0)
+          return (void*)0xdead700;
         /* fallthrough */
       default:
         break;

Modified: trunk/gegl/buffer/gegl-tile-handler-cache.h
==============================================================================
--- trunk/gegl/buffer/gegl-tile-handler-cache.h	(original)
+++ trunk/gegl/buffer/gegl-tile-handler-cache.h	Fri Apr 18 21:37:52 2008
@@ -32,16 +32,6 @@
 typedef struct _GeglTileHandlerCache      GeglTileHandlerCache;
 typedef struct _GeglTileHandlerCacheClass GeglTileHandlerCacheClass;
 
-struct _GeglTileHandlerCache
-{
-  GeglTileHandler parent_instance;
-
-/*  GQueue     *queue;
-  gint        size;
-  gint        wash_percentage;
-  gint        hits;
-  gint        misses;*/
-};
 
 struct _GeglTileHandlerCacheClass
 {

Modified: trunk/gegl/buffer/gegl-tile-handler-log.c
==============================================================================
--- trunk/gegl/buffer/gegl-tile-handler-log.c	(original)
+++ trunk/gegl/buffer/gegl-tile-handler-log.c	Fri Apr 18 21:37:52 2008
@@ -32,12 +32,12 @@
   "get",
   "is_cached",
   "exist",
-  "void",
+  "-", /*void*/
   "void tl", 
   "void tr", 
   "void bl",
   "void br",
-  "undo start group",
+  "flush",
   "last command",
   "eeek",
   NULL
@@ -59,11 +59,16 @@
   switch (command)
     {
       case GEGL_TILE_IDLE:
+        /* idle messages clutter logging output */
         break;
       default:
-        g_print ("(%s %p %p %i,%i,%i => %s)", 
-          commands[command], (void *) gegl_tile_source, data, x, y, z,
-          result?"1":"0");
+        if (result)
+        g_print ("(%s %p %p %iÂ%iÂ%i â%p)", 
+          commands[command], (void *) ((gint)gegl_tile_source&0xffff), (void*)((gint)data&0xffff), x, y, z,
+          result);
+        else
+        g_print ("(%s %p %p %iÂ%iÂ%i â)", 
+          commands[command], (void *) ((gint)gegl_tile_source&0xffff), data, x, y, z);
     }
   return result;
 }

Modified: trunk/gegl/buffer/gegl-tile-storage.c
==============================================================================
--- trunk/gegl/buffer/gegl-tile-storage.c	(original)
+++ trunk/gegl/buffer/gegl-tile-storage.c	Fri Apr 18 21:37:52 2008
@@ -225,7 +225,8 @@
 
   g_object_unref (handler->source); /* eeek */
 
-  if (g_getenv("GEGL_LOG_TILE_BACKEND"))
+  if (g_getenv("GEGL_LOG_TILE_BACKEND")||
+      g_getenv("GEGL_TILE_LOG"))
     gegl_tile_handler_chain_add (tile_handler_chain, g_object_new (GEGL_TYPE_TILE_HANDLER_LOG, NULL));
 
 

Modified: trunk/gegl/buffer/gegl-tile.c
==============================================================================
--- trunk/gegl/buffer/gegl-tile.c	(original)
+++ trunk/gegl/buffer/gegl-tile.c	Fri Apr 18 21:37:52 2008
@@ -396,12 +396,14 @@
 
 gboolean gegl_tile_store (GeglTile *tile)
 {
+  if (gegl_tile_is_stored (tile))
+    return TRUE;
   if (tile->tile_storage == NULL)
     return FALSE;
   return gegl_tile_source_set_tile (GEGL_TILE_SOURCE (tile->tile_storage),
-                                tile->storage_x,
-                                tile->storage_y,
-                                tile->storage_z, tile);
+                                    tile->storage_x,
+                                    tile->storage_y,
+                                    tile->storage_z, tile);
 }
 
 /* compute the tile indice of a coordinate



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