[gimp/goat-invasion: 134/234] app: port all implementations of GimpProjectable::get_opacity_at() to Gegl
- From: Ãyvind KolÃs <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/goat-invasion: 134/234] app: port all implementations of GimpProjectable::get_opacity_at() to Gegl
- Date: Fri, 23 Mar 2012 12:04:39 +0000 (UTC)
commit 7442354dea0ca86db50e4c3134210bfcf369e238
Author: Michael Natterer <mitch gimp org>
Date: Sun Mar 18 19:56:56 2012 +0100
app: port all implementations of GimpProjectable::get_opacity_at() to Gegl
app/core/gimpchannel.c | 30 ++++++++++++++++--------------
app/core/gimplayer.c | 23 +++++++++--------------
2 files changed, 25 insertions(+), 28 deletions(-)
---
diff --git a/app/core/gimpchannel.c b/app/core/gimpchannel.c
index 18e5494..039c835 100644
--- a/app/core/gimpchannel.c
+++ b/app/core/gimpchannel.c
@@ -969,32 +969,34 @@ gimp_channel_get_opacity_at (GimpPickable *pickable,
gint y)
{
GimpChannel *channel = GIMP_CHANNEL (pickable);
- Tile *tile;
- gint val;
+ guchar value;
/* Some checks to cut back on unnecessary work */
if (channel->bounds_known)
{
- if (channel->empty)
- return 0;
- else if (x < channel->x1 || x >= channel->x2 ||
- y < channel->y1 || y >= channel->y2)
- return 0;
+ if (channel->empty ||
+ x < channel->x1 ||
+ x >= channel->x2 ||
+ y < channel->y1 ||
+ y >= channel->y2)
+ {
+ return 0;
+ }
}
else
{
if (x < 0 || x >= gimp_item_get_width (GIMP_ITEM (channel)) ||
y < 0 || y >= gimp_item_get_height (GIMP_ITEM (channel)))
- return 0;
+ {
+ return 0;
+ }
}
- tile = tile_manager_get_tile (gimp_drawable_get_tiles (GIMP_DRAWABLE (channel)),
- x, y,
- TRUE, FALSE);
- val = *(guchar *) (tile_data_pointer (tile, x, y));
- tile_release (tile, FALSE);
+ gegl_buffer_sample (gimp_drawable_get_read_buffer (GIMP_DRAWABLE (channel)),
+ x, y, NULL, &value, babl_format ("Y u8"),
+ GEGL_SAMPLER_NEAREST);
- return val;
+ return value;
}
static gboolean
diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c
index 22a1368..c8402e1 100644
--- a/app/core/gimplayer.c
+++ b/app/core/gimplayer.c
@@ -962,8 +962,7 @@ gimp_layer_get_opacity_at (GimpPickable *pickable,
gint y)
{
GimpLayer *layer = GIMP_LAYER (pickable);
- Tile *tile;
- gint val = 0;
+ guchar value;
if (x >= 0 && x < gimp_item_get_width (GIMP_ITEM (layer)) &&
y >= 0 && y < gimp_item_get_height (GIMP_ITEM (layer)) &&
@@ -978,26 +977,22 @@ gimp_layer_get_opacity_at (GimpPickable *pickable,
/* Otherwise, determine if the alpha value at
* the given point is non-zero
*/
- tile = tile_manager_get_tile (gimp_drawable_get_tiles (GIMP_DRAWABLE (layer)),
- x, y, TRUE, FALSE);
-
- val = * ((const guchar *) tile_data_pointer (tile, x, y) +
- tile_bpp (tile) - 1);
+ gegl_buffer_sample (gimp_drawable_get_read_buffer (GIMP_DRAWABLE (layer)),
+ x, y, NULL, &value, babl_format ("A u8"),
+ GEGL_SAMPLER_NEAREST);
if (layer->mask)
{
- gint mask_val;
+ gint mask_value;
- mask_val = gimp_pickable_get_opacity_at (GIMP_PICKABLE (layer->mask),
- x, y);
+ mask_value = gimp_pickable_get_opacity_at (GIMP_PICKABLE (layer->mask),
+ x, y);
- val = val * mask_val / 255;
+ value = value * mask_value / 255;
}
-
- tile_release (tile, FALSE);
}
- return val;
+ return value;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]