[gimp/goat-invasion: 218/401] app: turn the drawable's shadow tiles into a shadow buffer



commit 4af0d7c26f5e266043ca453d92b1fcf236b96ceb
Author: Michael Natterer <mitch gimp org>
Date:   Thu Mar 22 19:10:12 2012 +0100

    app: turn the drawable's shadow tiles into a shadow buffer

 app/core/gimpdrawable-operation.c |   10 ++-----
 app/core/gimpdrawable-private.h   |    2 +-
 app/core/gimpdrawable-process.c   |   13 ++++++---
 app/core/gimpdrawable-shadow.c    |   55 ++++++++++++++++++-------------------
 app/core/gimpdrawable-shadow.h    |    6 ++--
 app/core/gimpdrawable.c           |    6 ++--
 app/core/gimpimagemap.c           |   44 +++++++++++++-----------------
 app/pdb/drawable-cmds.c           |    4 +-
 app/plug-in/gimpplugin-cleanup.c  |   12 ++++----
 app/plug-in/gimpplugin-message.c  |   17 +++++++++---
 tools/pdbgen/pdb/drawable.pdb     |    4 +-
 11 files changed, 88 insertions(+), 85 deletions(-)
---
diff --git a/app/core/gimpdrawable-operation.c b/app/core/gimpdrawable-operation.c
index df2572e..0528c64 100644
--- a/app/core/gimpdrawable-operation.c
+++ b/app/core/gimpdrawable-operation.c
@@ -59,19 +59,15 @@ gimp_drawable_apply_operation (GimpDrawable *drawable,
                                   &rect.width, &rect.height))
     return;
 
-  dest_buffer =
-    gimp_tile_manager_create_buffer (gimp_drawable_get_shadow_tiles (drawable),
-                                     gimp_drawable_get_format (drawable));
+  dest_buffer = gimp_drawable_get_shadow_buffer (drawable);
 
   gimp_apply_operation (gimp_drawable_get_buffer (drawable),
                         progress, undo_desc,
                         operation, linear,
                         dest_buffer, &rect);
 
-  g_object_unref (dest_buffer);
-
-  gimp_drawable_merge_shadow_tiles (drawable, TRUE, undo_desc);
-  gimp_drawable_free_shadow_tiles (drawable);
+  gimp_drawable_merge_shadow_buffer (drawable, TRUE, undo_desc);
+  gimp_drawable_free_shadow_buffer (drawable);
 
   gimp_drawable_update (drawable, rect.x, rect.y, rect.width, rect.height);
 
diff --git a/app/core/gimpdrawable-private.h b/app/core/gimpdrawable-private.h
index 46c557d..fe3981b 100644
--- a/app/core/gimpdrawable-private.h
+++ b/app/core/gimpdrawable-private.h
@@ -23,7 +23,7 @@ struct _GimpDrawablePrivate
   const Babl    *format; /* format of drawable      */
 
   GeglBuffer    *buffer; /* buffer for drawable data */
-  TileManager   *shadow; /* shadow buffer tiles      */
+  GeglBuffer    *shadow; /* shadow buffer            */
 
   GeglNode      *source_node;
   GeglNode      *buffer_source_node;
diff --git a/app/core/gimpdrawable-process.c b/app/core/gimpdrawable-process.c
index 1e787db..57bfb99 100644
--- a/app/core/gimpdrawable-process.c
+++ b/app/core/gimpdrawable-process.c
@@ -25,6 +25,8 @@
 #include "base/pixel-processor.h"
 #include "base/pixel-region.h"
 
+#include "gegl/gimp-gegl-utils.h"
+
 #include "gimpdrawable.h"
 #include "gimpdrawable-process.h"
 #include "gimpdrawable-shadow.h"
@@ -47,17 +49,20 @@ gimp_drawable_process (GimpDrawable       *drawable,
 
   if (gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
     {
-      PixelRegion srcPR, destPR;
+      GeglBuffer  *dest_buffer;
+      PixelRegion  srcPR, destPR;
+
+      dest_buffer = gimp_drawable_get_shadow_buffer (drawable);
 
       pixel_region_init (&srcPR, gimp_drawable_get_tiles (drawable),
                          x, y, width, height, FALSE);
-      pixel_region_init (&destPR, gimp_drawable_get_shadow_tiles (drawable),
+      pixel_region_init (&destPR, gimp_gegl_buffer_get_tiles (dest_buffer),
                          x, y, width, height, TRUE);
 
       pixel_regions_process_parallel (func, data, 2, &srcPR, &destPR);
 
-      gimp_drawable_merge_shadow_tiles (drawable, TRUE, undo_desc);
-      gimp_drawable_free_shadow_tiles (drawable);
+      gimp_drawable_merge_shadow_buffer (drawable, TRUE, undo_desc);
+      gimp_drawable_free_shadow_buffer (drawable);
 
       gimp_drawable_update (drawable, x, y, width, height);
     }
diff --git a/app/core/gimpdrawable-shadow.c b/app/core/gimpdrawable-shadow.c
index d60af5c..96b1d10 100644
--- a/app/core/gimpdrawable-shadow.c
+++ b/app/core/gimpdrawable-shadow.c
@@ -21,34 +21,36 @@
 
 #include "core-types.h"
 
-#include "base/pixel-region.h"
-#include "base/tile-manager.h"
+#include "gegl/gimp-gegl-utils.h"
 
 #include "gimpdrawable.h"
 #include "gimpdrawable-private.h"
 #include "gimpdrawable-shadow.h"
 
 
-TileManager *
-gimp_drawable_get_shadow_tiles (GimpDrawable *drawable)
+GeglBuffer *
+gimp_drawable_get_shadow_buffer (GimpDrawable *drawable)
 {
-  GimpItem *item;
+  GimpItem   *item;
+  gint        width;
+  gint        height;
+  const Babl *format;
 
   g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
 
   item = GIMP_ITEM (drawable);
 
+  width  = gimp_item_get_width  (item);
+  height = gimp_item_get_height (item);
+  format = gimp_drawable_get_format (drawable);
+
   if (drawable->private->shadow)
     {
-      gint width  = gimp_item_get_width  (item);
-      gint height = gimp_item_get_height (item);
-      gint bytes  = gimp_drawable_bytes (drawable);
-
-      if ((width  != tile_manager_width  (drawable->private->shadow)) ||
-          (height != tile_manager_height (drawable->private->shadow)) ||
-          (bytes  != tile_manager_bpp    (drawable->private->shadow)))
+      if ((width  != gegl_buffer_get_width  (drawable->private->shadow)) ||
+          (height != gegl_buffer_get_height (drawable->private->shadow)) ||
+          (format != gegl_buffer_get_format (drawable->private->shadow)))
         {
-          gimp_drawable_free_shadow_tiles (drawable);
+          gimp_drawable_free_shadow_buffer (drawable);
         }
       else
         {
@@ -56,36 +58,35 @@ gimp_drawable_get_shadow_tiles (GimpDrawable *drawable)
         }
     }
 
-  drawable->private->shadow = tile_manager_new (gimp_item_get_width  (item),
-                                                gimp_item_get_height (item),
-                                                gimp_drawable_bytes (drawable));
+  drawable->private->shadow =
+    gimp_gegl_buffer_new (GIMP_GEGL_RECT (0, 0, width, height), format);
 
   return drawable->private->shadow;
 }
 
 void
-gimp_drawable_free_shadow_tiles (GimpDrawable *drawable)
+gimp_drawable_free_shadow_buffer (GimpDrawable *drawable)
 {
   g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
 
   if (drawable->private->shadow)
     {
-      tile_manager_unref (drawable->private->shadow);
+      g_object_unref (drawable->private->shadow);
       drawable->private->shadow = NULL;
     }
 }
 
 void
-gimp_drawable_merge_shadow_tiles (GimpDrawable *drawable,
-                                  gboolean      push_undo,
-                                  const gchar  *undo_desc)
+gimp_drawable_merge_shadow_buffer (GimpDrawable *drawable,
+                                   gboolean      push_undo,
+                                   const gchar  *undo_desc)
 {
   gint x, y;
   gint width, height;
 
   g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
   g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
-  g_return_if_fail (drawable->private->shadow != NULL);
+  g_return_if_fail (GEGL_IS_BUFFER (drawable->private->shadow));
 
   /*  A useful optimization here is to limit the update to the
    *  extents of the selection mask, as it cannot extend beyond
@@ -93,16 +94,14 @@ gimp_drawable_merge_shadow_tiles (GimpDrawable *drawable,
    */
   if (gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
     {
-      TileManager *tiles = tile_manager_ref (drawable->private->shadow);
-      PixelRegion  shadowPR;
-
-      pixel_region_init (&shadowPR, tiles, x, y, width, height, FALSE);
+      GeglBuffer *buffer = g_object_ref (drawable->private->shadow);
 
-      gimp_drawable_apply_region (drawable, &shadowPR,
+      gimp_drawable_apply_buffer (drawable, buffer,
+                                  GIMP_GEGL_RECT (x, y, width, height),
                                   push_undo, undo_desc,
                                   GIMP_OPACITY_OPAQUE, GIMP_REPLACE_MODE,
                                   NULL, NULL, x, y);
 
-      tile_manager_unref (tiles);
+      g_object_unref (buffer);
     }
 }
diff --git a/app/core/gimpdrawable-shadow.h b/app/core/gimpdrawable-shadow.h
index cbc229a..c495607 100644
--- a/app/core/gimpdrawable-shadow.h
+++ b/app/core/gimpdrawable-shadow.h
@@ -21,10 +21,10 @@
 #define __GIMP_DRAWABLE_SHADOW_H__
 
 
-TileManager * gimp_drawable_get_shadow_tiles   (GimpDrawable *drawable);
-void          gimp_drawable_free_shadow_tiles  (GimpDrawable *drawable);
+GeglBuffer * gimp_drawable_get_shadow_buffer   (GimpDrawable *drawable);
+void         gimp_drawable_free_shadow_buffer  (GimpDrawable *drawable);
 
-void          gimp_drawable_merge_shadow_tiles (GimpDrawable *drawable,
+void         gimp_drawable_merge_shadow_buffer (GimpDrawable *drawable,
                                                 gboolean      push_undo,
                                                 const gchar  *undo_desc);
 
diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c
index e4b68aa..e650b571 100644
--- a/app/core/gimpdrawable.c
+++ b/app/core/gimpdrawable.c
@@ -294,7 +294,7 @@ gimp_drawable_finalize (GObject *object)
       drawable->private->buffer = NULL;
     }
 
-  gimp_drawable_free_shadow_tiles (drawable);
+  gimp_drawable_free_shadow_buffer (drawable);
 
   if (drawable->private->source_node)
     {
@@ -316,7 +316,7 @@ gimp_drawable_get_memsize (GimpObject *object,
   gint64        memsize  = 0;
 
   memsize += gimp_gegl_buffer_get_memsize (gimp_drawable_get_buffer (drawable));
-  memsize += tile_manager_get_memsize (drawable->private->shadow, FALSE);
+  memsize += gimp_gegl_buffer_get_memsize (drawable->private->shadow);
 
   *gui_size += gimp_preview_cache_get_memsize (drawable->private->preview_cache);
 
@@ -355,7 +355,7 @@ gimp_drawable_removed (GimpItem *item)
 {
   GimpDrawable *drawable = GIMP_DRAWABLE (item);
 
-  gimp_drawable_free_shadow_tiles (drawable);
+  gimp_drawable_free_shadow_buffer (drawable);
 
   if (GIMP_ITEM_CLASS (parent_class)->removed)
     GIMP_ITEM_CLASS (parent_class)->removed (item);
diff --git a/app/core/gimpimagemap.c b/app/core/gimpimagemap.c
index bd0ac94..ac5627b 100644
--- a/app/core/gimpimagemap.c
+++ b/app/core/gimpimagemap.c
@@ -237,7 +237,7 @@ gimp_image_map_finalize (GObject *object)
 
   if (image_map->drawable)
     {
-      gimp_drawable_free_shadow_tiles (image_map->drawable);
+      gimp_drawable_free_shadow_buffer (image_map->drawable);
 
       g_object_unref (image_map->drawable);
       image_map->drawable = NULL;
@@ -410,14 +410,11 @@ gimp_image_map_apply (GimpImageMap        *image_map,
 
   if (image_map->operation)
     {
-      const Babl *format = gimp_drawable_get_format (image_map->drawable);
       GeglBuffer *input_buffer;
       GeglBuffer *output_buffer;
 
-      input_buffer = image_map->undo_buffer;
-
-      output_buffer =
-        gimp_tile_manager_create_buffer (gimp_drawable_get_shadow_tiles (image_map->drawable), format);
+      input_buffer  = image_map->undo_buffer;
+      output_buffer = gimp_drawable_get_shadow_buffer (image_map->drawable);
 
       if (! image_map->gegl)
         {
@@ -505,11 +502,13 @@ gimp_image_map_apply (GimpImageMap        *image_map,
 
       image_map->processor = gegl_node_new_processor (image_map->output,
                                                       &rect);
-
-      g_object_unref (output_buffer);
     }
   else
     {
+      GeglBuffer *output_buffer;
+
+      output_buffer = gimp_drawable_get_shadow_buffer (image_map->drawable);
+
       /*  Configure the src from the drawable data  */
       pixel_region_init (&image_map->srcPR,
                          gimp_gegl_buffer_get_tiles (image_map->undo_buffer),
@@ -519,7 +518,7 @@ gimp_image_map_apply (GimpImageMap        *image_map,
 
       /*  Configure the dest as the shadow buffer  */
       pixel_region_init (&image_map->destPR,
-                         gimp_drawable_get_shadow_tiles (image_map->drawable),
+                         gimp_gegl_buffer_get_tiles (output_buffer),
                          rect.x, rect.y,
                          rect.width, rect.height,
                          TRUE);
@@ -745,8 +744,9 @@ gimp_image_map_do (GimpImageMap *image_map)
        */
       for (i = 0; i < 16; i++)
         {
-          PixelRegion srcPR;
-          gint        x, y, w, h;
+          GeglBuffer  *src_buffer;
+          PixelRegion  srcPR;
+          gint         x, y, w, h;
 
           if (image_map->timer)
             g_timer_continue (image_map->timer);
@@ -770,9 +770,10 @@ gimp_image_map_do (GimpImageMap *image_map)
                                  &image_map->srcPR,
                                  &image_map->destPR);
 
+          src_buffer = gimp_drawable_get_shadow_buffer (image_map->drawable);
 
           pixel_region_init (&srcPR,
-                             gimp_drawable_get_shadow_tiles (image_map->drawable),
+                             gimp_gegl_buffer_get_tiles (src_buffer),
                              x, y, w, h, FALSE);
 
           gimp_drawable_apply_region (image_map->drawable, &srcPR,
@@ -819,10 +820,7 @@ gimp_image_map_data_written (GObject             *operation,
                              const GeglRectangle *extent,
                              GimpImageMap        *image_map)
 {
-  GimpImage   *image;
-  PixelRegion  srcPR;
-
-  image = gimp_item_get_image (GIMP_ITEM (image_map->drawable));
+  GimpImage *image = gimp_item_get_image (GIMP_ITEM (image_map->drawable));
 
   if (! gimp_channel_is_empty (gimp_image_get_mask (image)))
     {
@@ -837,19 +835,15 @@ gimp_image_map_data_written (GObject             *operation,
     }
 
   /* Apply the result of the gegl graph. */
-  pixel_region_init (&srcPR,
-                     gimp_drawable_get_shadow_tiles (image_map->drawable),
-                     extent->x,
-                     extent->y,
-                     extent->width,
-                     extent->height,
-                     FALSE);
-
-  gimp_drawable_apply_region (image_map->drawable, &srcPR,
+  gimp_drawable_apply_buffer (image_map->drawable,
+                              gimp_drawable_get_shadow_buffer (image_map->drawable),
+                              GIMP_GEGL_RECT (extent->x, extent->y,
+                                              extent->width, extent->height),
                               FALSE, NULL,
                               GIMP_OPACITY_OPAQUE, GIMP_REPLACE_MODE,
                               NULL, NULL,
                               extent->x, extent->y);
+
   gimp_drawable_update (image_map->drawable,
                         extent->x, extent->y,
                         extent->width, extent->height);
diff --git a/app/pdb/drawable-cmds.c b/app/pdb/drawable-cmds.c
index c9c2887..e3e2d82 100644
--- a/app/pdb/drawable-cmds.c
+++ b/app/pdb/drawable-cmds.c
@@ -476,7 +476,7 @@ drawable_merge_shadow_invoker (GimpProcedure      *procedure,
           if (gimp->plug_in_manager->current_plug_in)
             undo_desc = gimp_plug_in_get_undo_desc (gimp->plug_in_manager->current_plug_in);
 
-          gimp_drawable_merge_shadow_tiles (drawable, undo, undo_desc);
+          gimp_drawable_merge_shadow_buffer (drawable, undo, undo_desc);
         }
       else
         success = FALSE;
@@ -505,7 +505,7 @@ drawable_free_shadow_invoker (GimpProcedure      *procedure,
         gimp_plug_in_cleanup_remove_shadow (gimp->plug_in_manager->current_plug_in,
                                             drawable);
 
-      gimp_drawable_free_shadow_tiles (drawable);
+      gimp_drawable_free_shadow_buffer (drawable);
     }
 
   return gimp_procedure_get_return_values (procedure, success,
diff --git a/app/plug-in/gimpplugin-cleanup.c b/app/plug-in/gimpplugin-cleanup.c
index 6d3c476..03f2190 100644
--- a/app/plug-in/gimpplugin-cleanup.c
+++ b/app/plug-in/gimpplugin-cleanup.c
@@ -57,7 +57,7 @@ struct _GimpPlugInCleanupItem
   GimpItem *item;
   gint      item_ID;
 
-  gboolean  shadow_tiles;
+  gboolean  shadow_buffer;
 };
 
 
@@ -157,7 +157,7 @@ gimp_plug_in_cleanup_add_shadow (GimpPlugIn   *plug_in,
                                                   cleanup);
     }
 
-  cleanup->shadow_tiles = TRUE;
+  cleanup->shadow_buffer = TRUE;
 
   return TRUE;
 }
@@ -178,7 +178,7 @@ gimp_plug_in_cleanup_remove_shadow (GimpPlugIn   *plug_in,
   if (! cleanup)
     return FALSE;
 
-  if (! cleanup->shadow_tiles)
+  if (! cleanup->shadow_buffer)
     return FALSE;
 
   proc_frame->item_cleanups = g_list_remove (proc_frame->item_cleanups,
@@ -332,15 +332,15 @@ gimp_plug_in_cleanup_item (GimpPlugInProcFrame   *proc_frame,
 {
   GimpItem *item = cleanup->item;
 
-  if (cleanup->shadow_tiles)
+  if (cleanup->shadow_buffer)
     {
       GimpProcedure *proc = proc_frame->procedure;
 
       GIMP_LOG (SHADOW_TILES,
-                "Freeing shadow tiles of drawable '%s' on behalf of '%s'.",
+                "Freeing shadow buffer of drawable '%s' on behalf of '%s'.",
                 gimp_object_get_name (item),
                 gimp_plug_in_procedure_get_label (GIMP_PLUG_IN_PROCEDURE (proc)));
 
-      gimp_drawable_free_shadow_tiles (GIMP_DRAWABLE (item));
+      gimp_drawable_free_shadow_buffer (GIMP_DRAWABLE (item));
     }
 }
diff --git a/app/plug-in/gimpplugin-message.c b/app/plug-in/gimpplugin-message.c
index a144519..23c5b21 100644
--- a/app/plug-in/gimpplugin-message.c
+++ b/app/plug-in/gimpplugin-message.c
@@ -32,6 +32,8 @@
 #include "base/tile.h"
 #include "base/tile-manager.h"
 
+#include "gegl/gimp-gegl-utils.h"
+
 #include "core/gimp.h"
 #include "core/gimpdrawable.h"
 #include "core/gimpdrawable-shadow.h"
@@ -190,6 +192,7 @@ gimp_plug_in_handle_tile_put (GimpPlugIn *plug_in,
   GPTileData      *tile_info;
   GimpWireMessage  msg;
   GimpDrawable    *drawable;
+  GeglBuffer      *buffer;
   TileManager     *tm;
   Tile            *tile;
 
@@ -257,12 +260,13 @@ gimp_plug_in_handle_tile_put (GimpPlugIn *plug_in,
 
   if (tile_info->shadow)
     {
+
       /*  don't check whether the drawable is a group or locked here,
        *  the plugin will get a proper error message when it tries to
        *  merge the shadow tiles, which is much better than just
        *  killing it.
        */
-      tm = gimp_drawable_get_shadow_tiles (drawable);
+      buffer = gimp_drawable_get_shadow_buffer (drawable);
 
       gimp_plug_in_cleanup_add_shadow (plug_in, drawable);
     }
@@ -291,9 +295,11 @@ gimp_plug_in_handle_tile_put (GimpPlugIn *plug_in,
           return;
         }
 
-      tm = gimp_drawable_get_tiles (drawable);
+      buffer = gimp_drawable_get_buffer (drawable);
     }
 
+  tm = gimp_gegl_buffer_get_tiles (buffer);
+
   tile = tile_manager_get (tm, tile_info->tile_num, TRUE, TRUE);
 
   if (! tile)
@@ -335,6 +341,7 @@ gimp_plug_in_handle_tile_get (GimpPlugIn *plug_in,
   GPTileData       tile_data;
   GimpWireMessage  msg;
   GimpDrawable    *drawable;
+  GeglBuffer      *buffer;
   TileManager     *tm;
   Tile            *tile;
 
@@ -367,15 +374,17 @@ gimp_plug_in_handle_tile_get (GimpPlugIn *plug_in,
 
   if (request->shadow)
     {
-      tm = gimp_drawable_get_shadow_tiles (drawable);
+      buffer = gimp_drawable_get_shadow_buffer (drawable);
 
       gimp_plug_in_cleanup_add_shadow (plug_in, drawable);
     }
   else
     {
-      tm = gimp_drawable_get_tiles (drawable);
+      buffer = gimp_drawable_get_buffer (drawable);
     }
 
+  tm = gimp_gegl_buffer_get_tiles (buffer);
+
   tile = tile_manager_get (tm, request->tile_num, TRUE, FALSE);
 
   if (! tile)
diff --git a/tools/pdbgen/pdb/drawable.pdb b/tools/pdbgen/pdb/drawable.pdb
index f6201ac..5d6db08 100644
--- a/tools/pdbgen/pdb/drawable.pdb
+++ b/tools/pdbgen/pdb/drawable.pdb
@@ -49,7 +49,7 @@ HELP
       if (gimp->plug_in_manager->current_plug_in)
         undo_desc = gimp_plug_in_get_undo_desc (gimp->plug_in_manager->current_plug_in);
 
-      gimp_drawable_merge_shadow_tiles (drawable, undo, undo_desc);
+      gimp_drawable_merge_shadow_buffer (drawable, undo, undo_desc);
     }
   else
     success = FALSE;
@@ -83,7 +83,7 @@ HELP
     gimp_plug_in_cleanup_remove_shadow (gimp->plug_in_manager->current_plug_in,
                                         drawable);
 
-  gimp_drawable_free_shadow_tiles (drawable);
+  gimp_drawable_free_shadow_buffer (drawable);
 }
 CODE
     );



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