Commit 52e40bce authored by Michael Natterer's avatar Michael Natterer 😴

pdb: port drawable pixel access API to GEGL

parent ee97c1f4
...@@ -24,8 +24,6 @@ ...@@ -24,8 +24,6 @@
#include "pdb-types.h" #include "pdb-types.h"
#include "base/temp-buf.h" #include "base/temp-buf.h"
#include "base/tile-manager.h"
#include "base/tile.h"
#include "config/gimpcoreconfig.h" #include "config/gimpcoreconfig.h"
#include "core/gimp.h" #include "core/gimp.h"
#include "core/gimpdrawable-foreground-extract.h" #include "core/gimpdrawable-foreground-extract.h"
...@@ -35,6 +33,7 @@ ...@@ -35,6 +33,7 @@
#include "core/gimpdrawable.h" #include "core/gimpdrawable.h"
#include "core/gimpimage.h" #include "core/gimpimage.h"
#include "core/gimpparamspecs.h" #include "core/gimpparamspecs.h"
#include "gegl/gimp-gegl-utils.h"
#include "plug-in/gimpplugin-cleanup.h" #include "plug-in/gimpplugin-cleanup.h"
#include "plug-in/gimpplugin.h" #include "plug-in/gimpplugin.h"
#include "plug-in/gimppluginmanager.h" #include "plug-in/gimppluginmanager.h"
...@@ -567,25 +566,10 @@ drawable_get_pixel_invoker (GimpProcedure *procedure, ...@@ -567,25 +566,10 @@ drawable_get_pixel_invoker (GimpProcedure *procedure,
if (x_coord < gimp_item_get_width (GIMP_ITEM (drawable)) && if (x_coord < gimp_item_get_width (GIMP_ITEM (drawable)) &&
y_coord < gimp_item_get_height (GIMP_ITEM (drawable))) y_coord < gimp_item_get_height (GIMP_ITEM (drawable)))
{ {
Tile *tile; gegl_buffer_sample (gimp_drawable_get_buffer (drawable),
guint8 *p; x_coord, y_coord, NULL, pixel,
gint b; gimp_drawable_get_format (drawable),
GEGL_SAMPLER_NEAREST, GEGL_ABYSS_NONE);
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);
} }
else else
success = FALSE; success = FALSE;
...@@ -632,22 +616,10 @@ drawable_set_pixel_invoker (GimpProcedure *procedure, ...@@ -632,22 +616,10 @@ drawable_set_pixel_invoker (GimpProcedure *procedure,
y_coord < gimp_item_get_height (GIMP_ITEM (drawable)) && y_coord < gimp_item_get_height (GIMP_ITEM (drawable)) &&
num_channels == gimp_drawable_bytes (drawable)) num_channels == gimp_drawable_bytes (drawable))
{ {
Tile *tile; gegl_buffer_set (gimp_drawable_get_buffer (drawable),
guint8 *p; GIMP_GEGL_RECT (x_coord, y_coord, 1, 1),
gint b; 1.0, gimp_drawable_get_format (drawable),
pixel, GEGL_AUTO_ROWSTRIDE);
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);
} }
else else
success = FALSE; success = FALSE;
......
...@@ -585,25 +585,10 @@ HELP ...@@ -585,25 +585,10 @@ HELP
if (x_coord < gimp_item_get_width (GIMP_ITEM (drawable)) && if (x_coord < gimp_item_get_width (GIMP_ITEM (drawable)) &&
y_coord < gimp_item_get_height (GIMP_ITEM (drawable))) y_coord < gimp_item_get_height (GIMP_ITEM (drawable)))
{ {
Tile *tile; gegl_buffer_sample (gimp_drawable_get_buffer (drawable),
guint8 *p; x_coord, y_coord, NULL, pixel,
gint b; gimp_drawable_get_format (drawable),
GEGL_SAMPLER_NEAREST, GEGL_ABYSS_NONE);
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);
} }
else else
success = FALSE; success = FALSE;
...@@ -647,22 +632,10 @@ HELP ...@@ -647,22 +632,10 @@ HELP
y_coord < gimp_item_get_height (GIMP_ITEM (drawable)) && y_coord < gimp_item_get_height (GIMP_ITEM (drawable)) &&
num_channels == gimp_drawable_bytes (drawable)) num_channels == gimp_drawable_bytes (drawable))
{ {
Tile *tile; gegl_buffer_set (gimp_drawable_get_buffer (drawable),
guint8 *p; GIMP_GEGL_RECT (x_coord, y_coord, 1, 1),
gint b; 1.0, gimp_drawable_get_format (drawable),
pixel, GEGL_AUTO_ROWSTRIDE);
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);
} }
else else
success = FALSE; success = FALSE;
...@@ -933,10 +906,9 @@ CODE ...@@ -933,10 +906,9 @@ CODE
} }
@headers = qw("base/tile.h" @headers = qw("base/temp-buf.h"
"base/tile-manager.h"
"base/temp-buf.h"
"config/gimpcoreconfig.h" "config/gimpcoreconfig.h"
"gegl/gimp-gegl-utils.h"
"core/gimp.h" "core/gimp.h"
"core/gimpdrawable-offset.h" "core/gimpdrawable-offset.h"
"gimppdb-utils.h" "gimppdb-utils.h"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment