gegl r2253 - in trunk: . gegl/buffer gegl/operation operations/common



Author: ok
Date: Sun Apr 27 22:20:06 2008
New Revision: 2253
URL: http://svn.gnome.org/viewvc/gegl?rev=2253&view=rev

Log:
* gegl/buffer/gegl-buffer.c: added signal "changed" which is relaying
for the storage's changed signal. (might not work entirely correctly
with sub buffers.)
* gegl/buffer/gegl-tile-storage.c: added signal "changed"
* gegl/buffer/gegl-tile-backend-file.c:
(load_index): emit changed signal on storage for tiles that have
changed in the index.
* gegl/operation/gegl-operation.[ch]: (gegl_operation_invalidate):
added a function to allow an operation to invalidate a region that it
already has provided.
* operations/common/open-buffer.c: propagate changed from the buffer
to the node.


Modified:
   trunk/ChangeLog
   trunk/gegl/buffer/gegl-buffer.c
   trunk/gegl/buffer/gegl-tile-backend-file.c
   trunk/gegl/buffer/gegl-tile-storage.c
   trunk/gegl/operation/gegl-operation.c
   trunk/gegl/operation/gegl-operation.h
   trunk/operations/common/open-buffer.c

Modified: trunk/gegl/buffer/gegl-buffer.c
==============================================================================
--- trunk/gegl/buffer/gegl-buffer.c	(original)
+++ trunk/gegl/buffer/gegl-buffer.c	Sun Apr 27 22:20:06 2008
@@ -92,6 +92,13 @@
   PROP_PATH
 };
 
+enum {
+  CHANGED,
+  LAST_SIGNAL
+};
+
+guint gegl_buffer_signals[LAST_SIGNAL] = { 0 };
+
 static GeglBuffer * gegl_buffer_new_from_format (const void *babl_format,
                                                  gint        x,
                                                  gint        y,
@@ -376,6 +383,13 @@
 
 void babl_backtrack (void);
 
+static void storage_changed (GeglTileStorage     *storage,
+                             const GeglRectangle *rect,
+                             gpointer             userdata)
+{
+  g_signal_emit_by_name (GEGL_BUFFER (userdata), "changed", rect, NULL);
+}
+
 static GObject *
 gegl_buffer_constructor (GType                  type,
                          guint                  n_params,
@@ -451,6 +465,9 @@
                         NULL);
           g_object_unref (source);
 
+          g_signal_connect (storage, "changed",
+                            G_CALLBACK(storage_changed), buffer);
+
           g_assert (source);
           backend = gegl_buffer_backend (GEGL_BUFFER (source));
           g_assert (backend);
@@ -759,6 +776,17 @@
                                    g_param_spec_string ("path", "Path",
                                                         "URI to where the buffer is stored",
                                      NULL, G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
+
+  gegl_buffer_signals[CHANGED] =
+        g_signal_new ("changed",
+                  G_TYPE_FROM_CLASS (gobject_class),
+                  G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
+                  0,
+                  NULL, NULL,
+                  g_cclosure_marshal_VOID__BOXED,
+                  G_TYPE_NONE, 1,
+                  GEGL_TYPE_RECTANGLE);
+
 }
 
 static void

Modified: trunk/gegl/buffer/gegl-tile-backend-file.c
==============================================================================
--- trunk/gegl/buffer/gegl-tile-backend-file.c	(original)
+++ trunk/gegl/buffer/gegl-tile-backend-file.c	Sun Apr 27 22:20:06 2008
@@ -30,6 +30,7 @@
 #include "gegl-buffer-index.h"
 
 #include "gegl-debug.h"
+#include "gegl-types.h"
 
 /*#define HACKED_GIO_WITH_READWRITE 1*/
 
@@ -724,12 +725,22 @@
             }
           else
             {
+              GeglRectangle rect;
               g_hash_table_remove (self->index, existing);
-              g_free (existing);
               gegl_tile_source_invalidated (GEGL_TILE_SOURCE (backend->storage),
                                             existing->tile.x,
                                             existing->tile.y,
                                             existing->tile.z);
+
+              if (existing->tile.z == 0)
+                {
+                  rect.width = self->header.tile_width;
+                  rect.height = self->header.tile_height;
+                  rect.x = existing->tile.x * self->header.tile_width;
+                  rect.y = existing->tile.y * self->header.tile_height;
+                }
+              g_free (existing);
+              g_signal_emit_by_name (backend->storage, "changed", &rect, NULL);
             }
         }
         g_hash_table_insert (self->index, iter->data, iter->data);
@@ -750,8 +761,8 @@
 {
   GeglTileBackendFile *self = GEGL_TILE_BACKEND_FILE (user_data);
  
-  if (event_type == G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT)
-  /*if (event_type == G_FILE_MONITOR_EVENT_CHANGED)*/
+  /*if (event_type == G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT)*/
+  if (event_type == G_FILE_MONITOR_EVENT_CHANGED)
     { 
       load_index (self);
     }

Modified: trunk/gegl/buffer/gegl-tile-storage.c
==============================================================================
--- trunk/gegl/buffer/gegl-tile-storage.c	(original)
+++ trunk/gegl/buffer/gegl-tile-storage.c	Sun Apr 27 22:20:06 2008
@@ -29,7 +29,8 @@
 #include "gegl-tile-handler-zoom.h"
 #include "gegl-tile-handler-cache.h"
 #include "gegl-tile-handler-log.h"
-
+#include "gegl-types.h"
+#include "gegl-utils.h"
 
 
 G_DEFINE_TYPE (GeglTileStorage, gegl_tile_storage, GEGL_TYPE_TILE_HANDLER_CHAIN)
@@ -52,6 +53,14 @@
   PROP_PATH
 };
 
+enum
+{
+  CHANGED,
+  LAST_SIGNAL
+};
+
+guint gegl_tile_storage_signals[LAST_SIGNAL] = { 0 };
+
 static void
 get_property (GObject    *gobject,
               guint       property_id,
@@ -332,6 +341,17 @@
                                    g_param_spec_pointer ("format", "format", "babl format",
                                                          G_PARAM_READWRITE |
                                                          G_PARAM_CONSTRUCT));
+
+  gegl_tile_storage_signals[CHANGED] =
+        g_signal_new ("changed",
+                  G_TYPE_FROM_CLASS (gobject_class),
+                  G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
+                  0,
+                  NULL, NULL,
+                  g_cclosure_marshal_VOID__BOXED,
+                  G_TYPE_NONE, 1,
+                  GEGL_TYPE_RECTANGLE);
+
 }
 
 static void

Modified: trunk/gegl/operation/gegl-operation.c
==============================================================================
--- trunk/gegl/operation/gegl-operation.c	(original)
+++ trunk/gegl/operation/gegl-operation.c	Sun Apr 27 22:20:06 2008
@@ -406,3 +406,18 @@
   return pad->format;
 }
 
+
+void
+gegl_operation_invalidate (GeglOperation       *operation,
+                           const GeglRectangle *roi)
+{
+  GeglNode *node = NULL;
+
+  if (!operation)
+    return;
+
+  g_return_if_fail (GEGL_IS_OPERATION (operation));
+  node = operation->node;
+
+  gegl_node_invalidated (node, roi);
+}

Modified: trunk/gegl/operation/gegl-operation.h
==============================================================================
--- trunk/gegl/operation/gegl-operation.h	(original)
+++ trunk/gegl/operation/gegl-operation.h	Sun Apr 27 22:20:06 2008
@@ -217,10 +217,12 @@
 
 /* internal utility functions used by gegl, these should not be used
  * externally */
-gboolean gegl_operation_calc_source_regions  (GeglOperation *operation,
-                                              gpointer       context_id);
-void     gegl_operation_vector_prop_changed  (GeglVector    *vector,
-                                              GeglOperation *operation);
+gboolean gegl_operation_calc_source_regions  (GeglOperation       *operation,
+                                              gpointer             context_id);
+void     gegl_operation_vector_prop_changed  (GeglVector          *vector,
+                                              GeglOperation       *operation);
+void     gegl_operation_invalidate            (GeglOperation       *operation,
+                                               const GeglRectangle *roi);
 
 G_END_DECLS
 

Modified: trunk/operations/common/open-buffer.c
==============================================================================
--- trunk/operations/common/open-buffer.c	(original)
+++ trunk/operations/common/open-buffer.c	Sun Apr 27 22:20:06 2008
@@ -26,22 +26,35 @@
 
 #include "gegl-chant.h"
 
-static GeglRectangle
-get_bounding_box (GeglOperation *operation)
+static void buffer_changed (GeglBuffer          *buffer,
+                            const GeglRectangle *rect,
+                            gpointer             userdata)
 {
-  GeglRectangle result = {0,0,0,0};
-  GeglChantO   *o = GEGL_CHANT_PROPERTIES (operation);
-  GeglBuffer   *buffer = o->chant_data; /* since we only have one member
-                                         * of extra state data we want to
-                                         * carry we use the chant_data provided
-                                         * for all chanted ops.
-                                         */
+  gegl_operation_invalidate (GEGL_OPERATION (userdata), rect);
+}
 
+static GeglBuffer *ensure_buffer (GeglOperation *operation)
+{
+  GeglChantO   *o = GEGL_CHANT_PROPERTIES (operation);
+  GeglBuffer   *buffer = o->chant_data; 
+  if (buffer)
+    return buffer;
   if (!buffer)
     {
       buffer = gegl_buffer_open (o->path);
       o->chant_data = buffer;
     }
+  g_signal_connect (buffer, "changed",
+                    G_CALLBACK(buffer_changed), operation);
+  return buffer;
+}
+
+static GeglRectangle
+get_bounding_box (GeglOperation *operation)
+{
+  GeglRectangle result = {0,0,0,0};
+  GeglBuffer   *buffer = ensure_buffer (operation);
+
   result = *gegl_buffer_get_extent (GEGL_BUFFER (buffer));
   return result;
 }
@@ -60,14 +73,8 @@
          const gchar         *output_pad,
          const GeglRectangle *result)
 {
-  GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
-  GeglBuffer *buffer = o->chant_data;
+  GeglBuffer *buffer = ensure_buffer (operation);
 
-  if (!buffer)
-    {
-      buffer = gegl_buffer_open (o->path);
-      o->chant_data = buffer;
-    }
   if (buffer)
     {
       g_object_ref (buffer); /* Add an extra reference, since



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