[gimp/goat-invasion: 287/412] pdb: port drawable pixel access API to GEGL



commit d69d2767e298bf9d0792eb1700ec8617d180603e
Author: Michael Natterer <mitch gimp org>
Date:   Tue Mar 27 23:12:59 2012 +0200

    pdb: port drawable pixel access API to GEGL

 app/pdb/drawable-cmds.c       |   46 +++++++-------------------------------
 tools/pdbgen/pdb/drawable.pdb |   48 ++++++++--------------------------------
 2 files changed, 19 insertions(+), 75 deletions(-)
---
diff --git a/app/pdb/drawable-cmds.c b/app/pdb/drawable-cmds.c
index e3e2d82..5803b6e 100644
--- a/app/pdb/drawable-cmds.c
+++ b/app/pdb/drawable-cmds.c
@@ -24,8 +24,6 @@
 #include "pdb-types.h"
 
 #include "base/temp-buf.h"
-#include "base/tile-manager.h"
-#include "base/tile.h"
 #include "config/gimpcoreconfig.h"
 #include "core/gimp.h"
 #include "core/gimpdrawable-foreground-extract.h"
@@ -35,6 +33,7 @@
 #include "core/gimpdrawable.h"
 #include "core/gimpimage.h"
 #include "core/gimpparamspecs.h"
+#include "gegl/gimp-gegl-utils.h"
 #include "plug-in/gimpplugin-cleanup.h"
 #include "plug-in/gimpplugin.h"
 #include "plug-in/gimppluginmanager.h"
@@ -567,25 +566,10 @@ drawable_get_pixel_invoker (GimpProcedure      *procedure,
       if (x_coord < gimp_item_get_width  (GIMP_ITEM (drawable)) &&
           y_coord < gimp_item_get_height (GIMP_ITEM (drawable)))
         {
-          Tile   *tile;
-          guint8 *p;
-          gint    b;
-
-          num_channels = gimp_drawable_bytes (drawable);
-          pixel = g_new (guint8, num_channels);
-
-          tile = tile_manager_get_tile (gimp_drawable_get_tiles (drawable),
-                                        x_coord, y_coord,
-                                        TRUE, TRUE);
-
-          x_coord %= TILE_WIDTH;
-          y_coord %= TILE_HEIGHT;
-
-          p = tile_data_pointer (tile, x_coord, y_coord);
-          for (b = 0; b < num_channels; b++)
-            pixel[b] = p[b];
-
-          tile_release (tile, FALSE);
+          gegl_buffer_sample (gimp_drawable_get_buffer (drawable),
+                              x_coord, y_coord, NULL, pixel,
+                              gimp_drawable_get_format (drawable),
+                              GEGL_SAMPLER_NEAREST, GEGL_ABYSS_NONE);
         }
       else
         success = FALSE;
@@ -632,22 +616,10 @@ drawable_set_pixel_invoker (GimpProcedure      *procedure,
           y_coord < gimp_item_get_height (GIMP_ITEM (drawable)) &&
           num_channels == gimp_drawable_bytes (drawable))
         {
-          Tile   *tile;
-          guint8 *p;
-          gint    b;
-
-          tile = tile_manager_get_tile (gimp_drawable_get_tiles (drawable),
-                                        x_coord, y_coord,
-                                        TRUE, TRUE);
-
-          x_coord %= TILE_WIDTH;
-          y_coord %= TILE_HEIGHT;
-
-          p = tile_data_pointer (tile, x_coord, y_coord);
-          for (b = 0; b < num_channels; b++)
-            *p++ = *pixel++;
-
-          tile_release (tile, TRUE);
+          gegl_buffer_set (gimp_drawable_get_buffer (drawable),
+                           GIMP_GEGL_RECT (x_coord, y_coord, 1, 1),
+                           1.0, gimp_drawable_get_format (drawable),
+                           pixel, GEGL_AUTO_ROWSTRIDE);
         }
       else
         success = FALSE;
diff --git a/tools/pdbgen/pdb/drawable.pdb b/tools/pdbgen/pdb/drawable.pdb
index 5d6db08..c09cb2b 100644
--- a/tools/pdbgen/pdb/drawable.pdb
+++ b/tools/pdbgen/pdb/drawable.pdb
@@ -585,25 +585,10 @@ HELP
   if (x_coord < gimp_item_get_width  (GIMP_ITEM (drawable)) &&
       y_coord < gimp_item_get_height (GIMP_ITEM (drawable)))
     {
-      Tile   *tile;
-      guint8 *p;
-      gint    b;
-
-      num_channels = gimp_drawable_bytes (drawable);
-      pixel = g_new (guint8, num_channels);
-
-      tile = tile_manager_get_tile (gimp_drawable_get_tiles (drawable),
-                                    x_coord, y_coord,
-				    TRUE, TRUE);
-
-      x_coord %= TILE_WIDTH;
-      y_coord %= TILE_HEIGHT;
-
-      p = tile_data_pointer (tile, x_coord, y_coord);
-      for (b = 0; b < num_channels; b++)
-	pixel[b] = p[b];
-
-      tile_release (tile, FALSE);
+      gegl_buffer_sample (gimp_drawable_get_buffer (drawable),
+                          x_coord, y_coord, NULL, pixel,
+                          gimp_drawable_get_format (drawable),
+                          GEGL_SAMPLER_NEAREST, GEGL_ABYSS_NONE);
     }
   else
     success = FALSE;
@@ -647,22 +632,10 @@ HELP
       y_coord < gimp_item_get_height (GIMP_ITEM (drawable)) &&
       num_channels == gimp_drawable_bytes (drawable))
     {
-      Tile   *tile;
-      guint8 *p;
-      gint    b;
-
-      tile = tile_manager_get_tile (gimp_drawable_get_tiles (drawable),
-                                    x_coord, y_coord,
-				    TRUE, TRUE);
-
-      x_coord %= TILE_WIDTH;
-      y_coord %= TILE_HEIGHT;
-
-      p = tile_data_pointer (tile, x_coord, y_coord);
-      for (b = 0; b < num_channels; b++)
-	*p++ = *pixel++;
-
-      tile_release (tile, TRUE);
+      gegl_buffer_set (gimp_drawable_get_buffer (drawable),
+                       GIMP_GEGL_RECT (x_coord, y_coord, 1, 1),
+                       1.0, gimp_drawable_get_format (drawable),
+                       pixel, GEGL_AUTO_ROWSTRIDE);
     }
   else
     success = FALSE;
@@ -933,10 +906,9 @@ CODE
 }
 
 
- headers = qw("base/tile.h"
-              "base/tile-manager.h"
-              "base/temp-buf.h"
+ headers = qw("base/temp-buf.h"
               "config/gimpcoreconfig.h"
+              "gegl/gimp-gegl-utils.h"
               "core/gimp.h"
               "core/gimpdrawable-offset.h"
               "gimppdb-utils.h"



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