[gimp/goat-invasion: 180/526] app: use gimp_drawable_set_buffer() in a few places



commit 3d3c75b0270918fa84765d26cba0e098d2fd267c
Author: Michael Natterer <mitch gimp org>
Date:   Wed Mar 21 10:10:20 2012 +0100

    app: use gimp_drawable_set_buffer() in a few places

 app/core/gimpchannel.c         |   51 +++++++++++++++++++------------------
 app/core/gimpdrawable-offset.c |   39 ++++++++++++----------------
 app/core/gimpdrawable.c        |   27 ++++++++-----------
 app/core/gimplayer.c           |   55 +++++++++++++++++----------------------
 app/text/gimptextlayer.c       |   13 +++++----
 5 files changed, 85 insertions(+), 100 deletions(-)
---
diff --git a/app/core/gimpchannel.c b/app/core/gimpchannel.c
index d7c603f..e786579 100644
--- a/app/core/gimpchannel.c
+++ b/app/core/gimpchannel.c
@@ -459,32 +459,32 @@ gimp_channel_convert (GimpItem  *item,
 
   if (gimp_drawable_has_alpha (drawable))
     {
-      GeglNode    *flatten;
-      TileManager *new_tiles;
-      GeglBuffer  *buffer;
-      GimpRGB      background;
+      GeglBuffer *new_buffer;
+      GeglNode   *flatten;
+      const Babl *format;
+      GimpRGB     background;
 
-      new_tiles = tile_manager_new (gimp_item_get_width (item),
-                                    gimp_item_get_height (item),
-                                    GIMP_IMAGE_TYPE_BYTES (GIMP_GRAY_IMAGE));
+      format = gimp_drawable_get_format_without_alpha (drawable);
+
+      new_buffer =
+        gimp_gegl_buffer_new (GIMP_GEGL_RECT (0, 0,
+                                              gimp_item_get_width (item),
+                                              gimp_item_get_height (item)),
+                              format);
 
       gimp_rgba_set (&background, 0.0, 0.0, 0.0, 0.0);
       flatten = gimp_gegl_create_flatten_node (&background);
 
-      buffer = gimp_tile_manager_create_buffer (new_tiles,
-                                                gimp_drawable_get_format_without_alpha (drawable));
-
       gimp_drawable_apply_operation_to_buffer (drawable, NULL, NULL,
-                                               flatten, TRUE, buffer);
+                                               flatten, TRUE, new_buffer);
 
       g_object_unref (flatten);
-      g_object_unref (buffer);
 
-      gimp_drawable_set_tiles_full (drawable, FALSE, NULL,
-                                    new_tiles, GIMP_GRAY_IMAGE,
-                                    gimp_item_get_offset_x (item),
-                                    gimp_item_get_offset_y (item));
-      tile_manager_unref (new_tiles);
+      gimp_drawable_set_buffer_full (drawable, FALSE, NULL,
+                                     new_buffer, GIMP_GRAY_IMAGE,
+                                     gimp_item_get_offset_x (item),
+                                     gimp_item_get_offset_y (item));
+      g_object_unref (new_buffer);
     }
 
   if (G_TYPE_FROM_INSTANCE (channel) == GIMP_TYPE_CHANNEL)
@@ -613,16 +613,17 @@ gimp_channel_scale (GimpItem              *item,
   if (channel->bounds_known && channel->empty)
     {
       GimpDrawable *drawable = GIMP_DRAWABLE (item);
-      TileManager  *new_tiles;
+      GeglBuffer   *new_buffer;
 
-      new_tiles = tile_manager_new (new_width, new_height,
-                                    gimp_drawable_bytes (drawable));
+      new_buffer =
+        gimp_gegl_buffer_new (GIMP_GEGL_RECT (0, 0, new_width, new_height),
+                              gimp_drawable_get_format (drawable));
 
-      gimp_drawable_set_tiles_full (drawable,
-                                    gimp_item_is_attached (item), NULL,
-                                    new_tiles, gimp_drawable_type (drawable),
-                                    new_offset_x, new_offset_y);
-      tile_manager_unref (new_tiles);
+      gimp_drawable_set_buffer_full (drawable,
+                                     gimp_item_is_attached (item), NULL,
+                                     new_buffer, gimp_drawable_type (drawable),
+                                     new_offset_x, new_offset_y);
+      g_object_unref (new_buffer);
 
       gimp_channel_clear (GIMP_CHANNEL (item), NULL, FALSE);
     }
diff --git a/app/core/gimpdrawable-offset.c b/app/core/gimpdrawable-offset.c
index 83d9a41..428d0d8 100644
--- a/app/core/gimpdrawable-offset.c
+++ b/app/core/gimpdrawable-offset.c
@@ -27,8 +27,6 @@
 
 #include "core-types.h"
 
-#include "base/tile-manager.h"
-
 #include "gegl/gimp-gegl-utils.h"
 
 #include "gimp.h"
@@ -49,9 +47,8 @@ gimp_drawable_offset (GimpDrawable   *drawable,
                       gint            offset_y)
 {
   GimpItem      *item;
-  TileManager   *new_tiles;
   GeglBuffer    *src_buffer;
-  GeglBuffer    *dest_buffer;
+  GeglBuffer    *new_buffer;
   GeglRectangle  src_rect;
   GeglRectangle  dest_rect;
   gint           width, height;
@@ -86,11 +83,10 @@ gimp_drawable_offset (GimpDrawable   *drawable,
   if (offset_x == 0 && offset_y == 0)
     return;
 
-  new_tiles = tile_manager_new (width, height, gimp_drawable_bytes (drawable));
+  src_buffer = gimp_drawable_get_buffer (drawable);
 
-  src_buffer  = gimp_drawable_get_buffer (drawable);
-  dest_buffer = gimp_tile_manager_create_buffer (new_tiles,
-                                                 gimp_drawable_get_format (drawable));
+  new_buffer = gimp_gegl_buffer_new (GIMP_GEGL_RECT (0, 0, width, height),
+                                     gimp_drawable_get_format (drawable));
 
   if (! wrap_around)
     {
@@ -102,12 +98,12 @@ gimp_drawable_offset (GimpDrawable   *drawable,
           gimp_context_get_background (context, &bg);
 
           color = gimp_gegl_color_new (&bg);
-          gegl_buffer_set_color (dest_buffer, NULL, color);
+          gegl_buffer_set_color (new_buffer, NULL, color);
           g_object_unref (color);
         }
       else
         {
-          gegl_buffer_clear (dest_buffer, NULL);
+          gegl_buffer_clear (new_buffer, NULL);
         }
     }
 
@@ -142,7 +138,7 @@ gimp_drawable_offset (GimpDrawable   *drawable,
     {
       gegl_buffer_copy (src_buffer,
                         GIMP_GEGL_RECT (src_x,  src_y,  width, height),
-                        dest_buffer,
+                        new_buffer,
                         GIMP_GEGL_RECT (dest_x,dest_y,  width, height));
     }
 
@@ -183,9 +179,10 @@ gimp_drawable_offset (GimpDrawable   *drawable,
       if (offset_x != 0 && offset_y != 0)
         {
           gegl_buffer_copy (src_buffer,
-              GIMP_GEGL_RECT (src_x, src_y, ABS(offset_x), ABS(offset_y)),
-              dest_buffer,
-              GIMP_GEGL_RECT (dest_x, dest_y, 0, 0));
+                            GIMP_GEGL_RECT (src_x, src_y,
+                                            ABS (offset_x), ABS (offset_y)),
+                            new_buffer,
+                            GIMP_GEGL_RECT (dest_x, dest_y, 0, 0));
         }
 
       /*  X offset  */
@@ -212,7 +209,7 @@ gimp_drawable_offset (GimpDrawable   *drawable,
               dest_rect.y = 0;
             }
 
-          gegl_buffer_copy (src_buffer, &src_rect, dest_buffer, &dest_rect);
+          gegl_buffer_copy (src_buffer, &src_rect, new_buffer, &dest_rect);
         }
 
       /*  X offset  */
@@ -239,14 +236,12 @@ gimp_drawable_offset (GimpDrawable   *drawable,
               dest_rect.y = dest_y;
             }
 
-          gegl_buffer_copy (src_buffer, &src_rect, dest_buffer, &dest_rect);
+          gegl_buffer_copy (src_buffer, &src_rect, new_buffer, &dest_rect);
         }
     }
 
-  g_object_unref (dest_buffer);
-
-  gimp_drawable_set_tiles (drawable, gimp_item_is_attached (item),
-                           C_("undo-type", "Offset Drawable"), new_tiles,
-                           gimp_drawable_type (drawable));
-  tile_manager_unref (new_tiles);
+  gimp_drawable_set_buffer (drawable, gimp_item_is_attached (item),
+                            C_("undo-type", "Offset Drawable"), new_buffer,
+                            gimp_drawable_type (drawable));
+  g_object_unref (new_buffer);
 }
diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c
index ee85859..293b356 100644
--- a/app/core/gimpdrawable.c
+++ b/app/core/gimpdrawable.c
@@ -542,8 +542,7 @@ gimp_drawable_resize (GimpItem    *item,
                       gint         offset_y)
 {
   GimpDrawable *drawable = GIMP_DRAWABLE (item);
-  GeglBuffer   *dest_buffer;
-  TileManager  *new_tiles;
+  GeglBuffer   *new_buffer;
   gint          new_offset_x;
   gint          new_offset_y;
   gint          copy_x, copy_y;
@@ -572,11 +571,9 @@ gimp_drawable_resize (GimpItem    *item,
                             &copy_width,
                             &copy_height);
 
-  new_tiles = tile_manager_new (new_width, new_height,
-                                gimp_drawable_bytes (drawable));
-
-  dest_buffer = gimp_tile_manager_create_buffer (new_tiles,
-                                                 gimp_drawable_get_format (drawable));
+  new_buffer = gimp_gegl_buffer_new (GIMP_GEGL_RECT (0, 0,
+                                                     new_width, new_height),
+                                     gimp_drawable_get_format (drawable));
 
   if (copy_width  != new_width ||
       copy_height != new_height)
@@ -593,7 +590,7 @@ gimp_drawable_resize (GimpItem    *item,
 
       col = gimp_gegl_color_new (&bg);
 
-      gegl_buffer_set_color (dest_buffer, NULL, col);
+      gegl_buffer_set_color (new_buffer, NULL, col);
       g_object_unref (col);
     }
 
@@ -605,17 +602,15 @@ gimp_drawable_resize (GimpItem    *item,
                                         copy_y - gimp_item_get_offset_y (item),
                                         copy_width,
                                         copy_height),
-                        dest_buffer,
+                        new_buffer,
                         GIMP_GEGL_RECT (copy_x - new_offset_x,
                                         copy_y - new_offset_y, 0, 0));
     }
 
-  g_object_unref (dest_buffer);
-
-  gimp_drawable_set_tiles_full (drawable, gimp_item_is_attached (item), NULL,
-                                new_tiles, gimp_drawable_type (drawable),
-                                new_offset_x, new_offset_y);
-  tile_manager_unref (new_tiles);
+  gimp_drawable_set_buffer_full (drawable, gimp_item_is_attached (item), NULL,
+                                 new_buffer, gimp_drawable_type (drawable),
+                                 new_offset_x, new_offset_y);
+  g_object_unref (new_buffer);
 }
 
 static void
@@ -908,7 +903,7 @@ gimp_drawable_real_push_undo (GimpDrawable *drawable,
 
   if (! tiles)
     {
-      GeglBuffer    *dest_buffer;
+      GeglBuffer *dest_buffer;
 
       tiles = tile_manager_new (width, height, gimp_drawable_bytes (drawable));
 
diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c
index 8f15545..25dacef 100644
--- a/app/core/gimplayer.c
+++ b/app/core/gimplayer.c
@@ -1798,8 +1798,7 @@ gimp_layer_add_alpha (GimpLayer *layer)
 {
   GimpItem      *item;
   GimpDrawable  *drawable;
-  TileManager   *new_tiles;
-  GeglBuffer    *dest_buffer;
+  GeglBuffer    *new_buffer;
   GimpImageType  new_type;
 
   g_return_if_fail (GIMP_IS_LAYER (layer));
@@ -1812,23 +1811,20 @@ gimp_layer_add_alpha (GimpLayer *layer)
 
   new_type = gimp_drawable_type_with_alpha (drawable);
 
-  new_tiles = tile_manager_new (gimp_item_get_width  (item),
-                                gimp_item_get_height (item),
-                                GIMP_IMAGE_TYPE_BYTES (new_type));
-
-  dest_buffer = gimp_tile_manager_create_buffer (new_tiles,
-                                                 gimp_drawable_get_format_with_alpha (GIMP_DRAWABLE (layer)));
+  new_buffer =
+    gimp_gegl_buffer_new (GIMP_GEGL_RECT (0, 0,
+                                          gimp_item_get_width  (item),
+                                          gimp_item_get_height (item)),
+                          gimp_drawable_get_format_with_alpha (drawable));
 
   gegl_buffer_copy (gimp_drawable_get_buffer (drawable), NULL,
-                    dest_buffer, NULL);
-
-  g_object_unref (dest_buffer);
+                    new_buffer, NULL);
 
-  gimp_drawable_set_tiles (GIMP_DRAWABLE (layer),
-                           gimp_item_is_attached (GIMP_ITEM (layer)),
-                           C_("undo-type", "Add Alpha Channel"),
-                           new_tiles, new_type);
-  tile_manager_unref (new_tiles);
+  gimp_drawable_set_buffer (GIMP_DRAWABLE (layer),
+                            gimp_item_is_attached (GIMP_ITEM (layer)),
+                            C_("undo-type", "Add Alpha Channel"),
+                            new_buffer, new_type);
+  g_object_unref (new_buffer);
 }
 
 void
@@ -1836,8 +1832,7 @@ gimp_layer_flatten (GimpLayer   *layer,
                     GimpContext *context)
 {
   GeglNode      *flatten;
-  TileManager   *new_tiles;
-  GeglBuffer    *dest_buffer;
+  GeglBuffer    *new_buffer;
   GimpImageType  new_type;
   GimpRGB        background;
 
@@ -1849,27 +1844,25 @@ gimp_layer_flatten (GimpLayer   *layer,
 
   new_type = gimp_drawable_type_without_alpha (GIMP_DRAWABLE (layer));
 
-  new_tiles = tile_manager_new (gimp_item_get_width  (GIMP_ITEM (layer)),
-                                gimp_item_get_height (GIMP_ITEM (layer)),
-                                GIMP_IMAGE_TYPE_BYTES (new_type));
-
-  dest_buffer = gimp_tile_manager_create_buffer (new_tiles,
-                                                 gimp_drawable_get_format_without_alpha (GIMP_DRAWABLE (layer)));
+  new_buffer =
+    gimp_gegl_buffer_new (GIMP_GEGL_RECT (0, 0,
+                                          gimp_item_get_width  (GIMP_ITEM (layer)),
+                                          gimp_item_get_height (GIMP_ITEM (layer))),
+                          gimp_drawable_get_format_without_alpha (GIMP_DRAWABLE (layer)));
 
   gimp_context_get_background (context, &background);
   flatten = gimp_gegl_create_flatten_node (&background);
 
   gimp_drawable_apply_operation_to_buffer (GIMP_DRAWABLE (layer), NULL, NULL,
-                                           flatten, TRUE, dest_buffer);
+                                           flatten, TRUE, new_buffer);
 
   g_object_unref (flatten);
-  g_object_unref (dest_buffer);
 
-  gimp_drawable_set_tiles (GIMP_DRAWABLE (layer),
-                           gimp_item_is_attached (GIMP_ITEM (layer)),
-                           C_("undo-type", "Remove Alpha Channel"),
-                           new_tiles, new_type);
-  tile_manager_unref (new_tiles);
+  gimp_drawable_set_buffer (GIMP_DRAWABLE (layer),
+                            gimp_item_is_attached (GIMP_ITEM (layer)),
+                            C_("undo-type", "Remove Alpha Channel"),
+                            new_buffer, new_type);
+  g_object_unref (new_buffer);
 }
 
 void
diff --git a/app/text/gimptextlayer.c b/app/text/gimptextlayer.c
index 809c6ec..e207b85 100644
--- a/app/text/gimptextlayer.c
+++ b/app/text/gimptextlayer.c
@@ -33,7 +33,7 @@
 
 #include "text-types.h"
 
-#include "base/tile-manager.h"
+#include "gegl/gimp-gegl-utils.h"
 
 #include "core/gimp.h"
 #include "core/gimp-utils.h"
@@ -590,13 +590,14 @@ gimp_text_layer_render (GimpTextLayer *layer)
       (width  != gimp_item_get_width  (item) ||
        height != gimp_item_get_height (item)))
     {
-      TileManager *new_tiles = tile_manager_new (width, height,
-                                                 gimp_drawable_bytes (drawable));
+      GeglBuffer *new_buffer =
+        gimp_gegl_buffer_new (GIMP_GEGL_RECT (0, 0, width, height),
+                              gimp_drawable_get_format (drawable));
 
-      gimp_drawable_set_tiles (drawable, FALSE, NULL, new_tiles,
-                               gimp_drawable_type (drawable));
+      gimp_drawable_set_buffer (drawable, FALSE, NULL, new_buffer,
+                                gimp_drawable_type (drawable));
 
-      tile_manager_unref (new_tiles);
+      g_object_unref (new_buffer);
 
       if (gimp_layer_get_mask (GIMP_LAYER (layer)))
         {



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