[gimp/goat-invasion: 54/73] app: make sure TileManagers and the GeglBuffers backed by them are in sync



commit 840b3c4d4dd043076082f1b85f67a508c971f66f
Author: Michael Natterer <mitch gimp org>
Date:   Thu Mar 15 19:56:35 2012 +0100

    app: make sure TileManagers and the GeglBuffers backed by them are in sync
    
    by adding gegl_buffer_flush() and gegl_tile_source_reinit() in the
    drawable's buffer and tiles API, and at some half-ported places that
    mix legacy and gegl code.

 app/core/gimpdrawable-offset.c |    2 ++
 app/core/gimpdrawable.c        |   10 ++++++++++
 app/core/gimpmaskundo.c        |    2 --
 app/gegl/gimp-gegl-utils.c     |    8 ++++++++
 app/gegl/gimp-gegl-utils.h     |    2 ++
 5 files changed, 22 insertions(+), 2 deletions(-)
---
diff --git a/app/core/gimpdrawable-offset.c b/app/core/gimpdrawable-offset.c
index b9e9472..8623421 100644
--- a/app/core/gimpdrawable-offset.c
+++ b/app/core/gimpdrawable-offset.c
@@ -241,6 +241,8 @@ gimp_drawable_offset (GimpDrawable   *drawable,
     {
       /*  Otherwise, fill the vacated regions  */
 
+      gegl_buffer_flush (dest_buffer);
+
       if (fill_type == GIMP_OFFSET_BACKGROUND)
         {
           GimpRGB color;
diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c
index c154d56..79289f0 100644
--- a/app/core/gimpdrawable.c
+++ b/app/core/gimpdrawable.c
@@ -1507,9 +1507,14 @@ gimp_drawable_get_read_buffer (GimpDrawable *drawable)
 {
   g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
 
+  if (drawable->private->write_buffer)
+    gegl_buffer_flush (drawable->private->write_buffer);
+
   if (! drawable->private->read_buffer)
     drawable->private->read_buffer = gimp_drawable_create_buffer (drawable,
                                                                   FALSE);
+  else
+    gimp_gegl_buffer_refetch_tiles (drawable->private->read_buffer);
 
   return drawable->private->read_buffer;
 }
@@ -1522,6 +1527,8 @@ gimp_drawable_get_write_buffer (GimpDrawable *drawable)
   if (! drawable->private->write_buffer)
     drawable->private->write_buffer = gimp_drawable_create_buffer (drawable,
                                                                    TRUE);
+  else
+    gimp_gegl_buffer_refetch_tiles (drawable->private->write_buffer);
 
   return drawable->private->write_buffer;
 }
@@ -1531,6 +1538,9 @@ gimp_drawable_get_tiles (GimpDrawable *drawable)
 {
   g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
 
+  if (drawable->private->write_buffer)
+    gegl_buffer_flush (drawable->private->write_buffer);
+
   return GIMP_DRAWABLE_GET_CLASS (drawable)->get_tiles (drawable);
 }
 
diff --git a/app/core/gimpmaskundo.c b/app/core/gimpmaskundo.c
index 28ee611..449a3fb 100644
--- a/app/core/gimpmaskundo.c
+++ b/app/core/gimpmaskundo.c
@@ -150,8 +150,6 @@ gimp_mask_undo_pop (GimpUndo            *undo,
       gegl_buffer_copy (mask_undo->buffer, NULL,
                         gimp_drawable_get_write_buffer (drawable), &dest_rect);
 
-      gegl_buffer_flush (gimp_drawable_get_write_buffer (drawable));
-
       g_object_unref (mask_undo->buffer);
     }
 
diff --git a/app/gegl/gimp-gegl-utils.c b/app/gegl/gimp-gegl-utils.c
index 0eaed57..c9d1d54 100644
--- a/app/gegl/gimp-gegl-utils.c
+++ b/app/gegl/gimp-gegl-utils.c
@@ -170,3 +170,11 @@ gimp_tile_manager_create_buffer (TileManager *tm,
 
   return buffer;
 }
+
+void
+gimp_gegl_buffer_refetch_tiles (GeglBuffer *buffer)
+{
+  g_return_if_fail (GEGL_IS_BUFFER (buffer));
+
+  gegl_tile_source_reinit (GEGL_TILE_SOURCE (buffer));
+}
diff --git a/app/gegl/gimp-gegl-utils.h b/app/gegl/gimp-gegl-utils.h
index 01b17c4..01e5b8b 100644
--- a/app/gegl/gimp-gegl-utils.h
+++ b/app/gegl/gimp-gegl-utils.h
@@ -33,5 +33,7 @@ const gchar * gimp_interpolation_to_gegl_filter (GimpInterpolationType  interpol
 GeglBuffer  * gimp_tile_manager_create_buffer   (TileManager           *tm,
                                                  gboolean               write);
 
+void          gimp_gegl_buffer_refetch_tiles    (GeglBuffer            *buffer);
+
 
 #endif /* __GIMP_GEGL_UTILS_H__ */



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