[gegl] buffer: Implement emission of 'changed' signal on GeglBuffer



commit b423d8fca1b00c6f3342c5b20a2c46b71555d7dc
Author: Jon Nordby <jononor gmail com>
Date:   Sun May 6 03:38:47 2012 +0200

    buffer: Implement emission of 'changed' signal on GeglBuffer
    
    The signal has existed for a long time, but was not emitted.
    The buffer-source operation relies on this for proper operation.

 gegl/buffer/gegl-buffer-access.c   |   12 ++++++++++++
 gegl/buffer/gegl-buffer-iterator.c |   14 +++++++++-----
 gegl/buffer/gegl-buffer-private.h  |    8 +++++++-
 gegl/buffer/gegl-buffer.c          |   13 +++++++++++++
 4 files changed, 41 insertions(+), 6 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer-access.c b/gegl/buffer/gegl-buffer-access.c
index d77a162..d32bc43 100644
--- a/gegl/buffer/gegl-buffer-access.c
+++ b/gegl/buffer/gegl-buffer-access.c
@@ -560,6 +560,18 @@ gegl_buffer_set_unlocked (GeglBuffer          *buffer,
                           const void          *src,
                           gint                 rowstride)
 {
+    gegl_buffer_set_unlocked_no_notify(buffer, rect, format, src, rowstride);
+    gegl_buffer_emit_changed_signal(buffer, rect);
+}
+
+
+void
+gegl_buffer_set_unlocked_no_notify (GeglBuffer          *buffer,
+                          const GeglRectangle *rect,
+                          const Babl          *format,
+                          const void          *src,
+                          gint                 rowstride)
+{
   if (format == NULL)
     format = buffer->soft_format;
 
diff --git a/gegl/buffer/gegl-buffer-iterator.c b/gegl/buffer/gegl-buffer-iterator.c
index 6c2e0c8..191c148 100644
--- a/gegl/buffer/gegl-buffer-iterator.c
+++ b/gegl/buffer/gegl-buffer-iterator.c
@@ -405,8 +405,14 @@ gegl_buffer_iterator_stop (GeglBufferIterator *iterator)
             found = TRUE;
             break;
           }
-      if (!found)
+      if (!found) {
         gegl_buffer_unlock (i->buffer[no]);
+
+        if (i->flags[no] & GEGL_BUFFER_WRITE) {
+          gegl_buffer_emit_changed_signal(i->buffer[no], &(i->rect[no]));
+        }
+      }
+
     }
 
   for (no=0; no<i->iterators; no++)
@@ -476,10 +482,8 @@ gegl_buffer_iterator_next (GeglBufferIterator *iterator)
 
                   ensure_buf (i, no);
 
-  /* XXX: should perhaps use _set_unlocked, and keep the lock in the
-   * iterator.
-   */
-                  gegl_buffer_set (i->buffer[no], &(i->roi[no]), 0, i->format[no], i->buf[no], GEGL_AUTO_ROWSTRIDE); /* XXX: use correct level */
+                  /* Change notification is done in gegl_buffer_iterator_stop */
+                  gegl_buffer_set_unlocked_no_notify (i->buffer[no], &(i->roi[no]), i->format[no], i->buf[no], GEGL_AUTO_ROWSTRIDE); /* XXX: use correct level */
                 }
             }
         }
diff --git a/gegl/buffer/gegl-buffer-private.h b/gegl/buffer/gegl-buffer-private.h
index 7886a8a..3f786c7 100644
--- a/gegl/buffer/gegl-buffer-private.h
+++ b/gegl/buffer/gegl-buffer-private.h
@@ -107,6 +107,11 @@ void              gegl_buffer_set_unlocked (GeglBuffer          *buffer,
                                             const Babl          *format,
                                             const void          *src,
                                             gint                 rowstride);
+void              gegl_buffer_set_unlocked_no_notify (GeglBuffer  *buffer,
+                                              const GeglRectangle *rect,
+                                              const Babl          *format,
+                                              const void          *src,
+                                              gint                 rowstride);
 void              gegl_buffer_get_unlocked (GeglBuffer          *buffer,
                                             gdouble              scale,
                                             const GeglRectangle *rect,
@@ -126,7 +131,8 @@ void            gegl_buffer_sampler           (GeglBuffer     *buffer,
                                                const Babl     *format,
                                                gpointer        sampler);
 
-
+void            gegl_buffer_emit_changed_signal(GeglBuffer *buffer,
+                                                const GeglRectangle *rect);
 
 /* the instance size of a GeglTile is a bit large, and should if possible be
  * trimmed down
diff --git a/gegl/buffer/gegl-buffer.c b/gegl/buffer/gegl-buffer.c
index 10b0c9e..358d114 100644
--- a/gegl/buffer/gegl-buffer.c
+++ b/gegl/buffer/gegl-buffer.c
@@ -1347,3 +1347,16 @@ gboolean gegl_buffer_unlock (GeglBuffer *buffer)
   g_mutex_unlock (buffer->tile_storage->mutex);
   return ret;
 }
+
+void gegl_buffer_emit_changed_signal(GeglBuffer *buffer, const GeglRectangle *rect)
+{
+  GeglRectangle copy;
+
+  if (rect == NULL) {
+    copy = *gegl_buffer_get_extent (buffer);
+  } else {
+    copy = *rect;
+  }
+
+  g_signal_emit(buffer, gegl_buffer_signals[CHANGED], 0, &copy, NULL);
+}



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