[gegl/gsoc2009-gpu] gegl_buffer_iterator_next(): unlock & unref held tiles when direct access can't be achieved



commit 96c4d83e80c326bae6eb4bbc29f8b033e008f0b8
Author: Jerson Michael Perpetua <jersonperpetua gmail com>
Date:   Sun Aug 23 22:25:31 2009 +0800

    gegl_buffer_iterator_next(): unlock & unref held tiles when direct access can't be achieved

 gegl/buffer/gegl-buffer-iterator.c |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer-iterator.c b/gegl/buffer/gegl-buffer-iterator.c
index 47eeca0..e434a47 100644
--- a/gegl/buffer/gegl-buffer-iterator.c
+++ b/gegl/buffer/gegl-buffer-iterator.c
@@ -169,6 +169,7 @@ gulp:
   if (i->tile != NULL)
     {
       gegl_tile_unlock (i->tile);
+
       g_object_unref (i->tile);
       i->tile = NULL;
 
@@ -640,6 +641,17 @@ gegl_buffer_iterator_next (GeglBufferIterator *iterator)
                 }
               else
                 {
+                  /* unref held tile to prevent lock contention */
+                  if (i->i[no].tile != NULL)
+                    {
+                      gegl_tile_unlock (i->i[no].tile);
+
+                      g_object_unref (i->i[no].tile);
+                      i->i[no].tile = NULL;
+
+                      i->i[no].sub_data = NULL;
+                    }
+
                   i->data[no] = iterator_buf_pool_get (i->roi[no].width,
                                                        i->roi[no].height,
                                                        i->format[no]);
@@ -669,6 +681,17 @@ gegl_buffer_iterator_next (GeglBufferIterator *iterator)
                 }
               else
                 {
+                  /* unref held tile to prevent lock contention */
+                  if (i->i[no].tile != NULL)
+                    {
+                      gegl_tile_unlock (i->i[no].tile);
+
+                      g_object_unref (i->i[no].tile);
+                      i->i[no].tile = NULL;
+
+                      i->i[no].gpu_data = NULL;
+                    }
+
                   i->gpu_data[no] = iterator_gpu_texture_pool_get (
                                       i->roi[no].width,
                                       i->roi[no].height,



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