[gimp] Bug 702369 - foreground selection doesnt work with image precision >8 bit
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 702369 - foreground selection doesnt work with image precision >8 bit
- Date: Sat, 22 Jun 2013 20:31:16 +0000 (UTC)
commit 31e9cc2ad91864be909b44afca05a379274a21a3
Author: Michael Natterer <mitch gimp org>
Date: Sat Jun 22 22:26:46 2013 +0200
Bug 702369 - foreground selection doesnt work with image precision >8 bit
This removes the obsolete check which makes the tool fail from
gimp_display_shell_set_mask(). Also change the foreground select tool
and the display mask from using GimpChannel to GeglBuffer, because
that's what it needs, simply buffers. Most changed files simply newly
include <gegl.h> because a GeglBuffer appeared in two headers.
app/actions/windows-commands.c | 1 +
app/display/gimpdisplayshell-expose.c | 1 +
app/display/gimpdisplayshell-filter.c | 1 +
app/display/gimpdisplayshell-grab.c | 1 +
app/display/gimpdisplayshell-items.c | 1 +
app/display/gimpdisplayshell-progress.c | 1 +
app/display/gimpdisplayshell-render.c | 4 +--
app/display/gimpdisplayshell.c | 6 +--
app/display/gimpdisplayshell.h | 4 +-
app/tools/gimpforegroundselecttool.c | 53 +++++++++++++------------------
app/tools/gimpforegroundselecttool.h | 4 +-
app/tools/gimptool-progress.c | 1 +
12 files changed, 36 insertions(+), 42 deletions(-)
---
diff --git a/app/actions/windows-commands.c b/app/actions/windows-commands.c
index b82fdfb..f7ff19c 100644
--- a/app/actions/windows-commands.c
+++ b/app/actions/windows-commands.c
@@ -19,6 +19,7 @@
#include <string.h>
+#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
diff --git a/app/display/gimpdisplayshell-expose.c b/app/display/gimpdisplayshell-expose.c
index b60ef13..710e876 100644
--- a/app/display/gimpdisplayshell-expose.c
+++ b/app/display/gimpdisplayshell-expose.c
@@ -17,6 +17,7 @@
#include "config.h"
+#include <gegl.h>
#include <gtk/gtk.h>
#include "display-types.h"
diff --git a/app/display/gimpdisplayshell-filter.c b/app/display/gimpdisplayshell-filter.c
index a491ba6..1ec53fb 100644
--- a/app/display/gimpdisplayshell-filter.c
+++ b/app/display/gimpdisplayshell-filter.c
@@ -17,6 +17,7 @@
#include "config.h"
+#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpconfig/gimpconfig.h"
diff --git a/app/display/gimpdisplayshell-grab.c b/app/display/gimpdisplayshell-grab.c
index 2ca9c1a..d9dec38 100644
--- a/app/display/gimpdisplayshell-grab.c
+++ b/app/display/gimpdisplayshell-grab.c
@@ -19,6 +19,7 @@
#include "config.h"
+#include <gegl.h>
#include <gtk/gtk.h>
#include "display-types.h"
diff --git a/app/display/gimpdisplayshell-items.c b/app/display/gimpdisplayshell-items.c
index 17d63c4..c92ff5b 100644
--- a/app/display/gimpdisplayshell-items.c
+++ b/app/display/gimpdisplayshell-items.c
@@ -20,6 +20,7 @@
#include "config.h"
+#include <gegl.h>
#include <gtk/gtk.h>
#include <libgimpmath/gimpmath.h>
diff --git a/app/display/gimpdisplayshell-progress.c b/app/display/gimpdisplayshell-progress.c
index cc05260..bca0bcb 100644
--- a/app/display/gimpdisplayshell-progress.c
+++ b/app/display/gimpdisplayshell-progress.c
@@ -17,6 +17,7 @@
#include "config.h"
+#include <gegl.h>
#include <gtk/gtk.h>
#include "display-types.h"
diff --git a/app/display/gimpdisplayshell-render.c b/app/display/gimpdisplayshell-render.c
index 03d137c..4ed04ff 100644
--- a/app/display/gimpdisplayshell-render.c
+++ b/app/display/gimpdisplayshell-render.c
@@ -146,13 +146,11 @@ gimp_display_shell_render (GimpDisplayShell *shell,
cairo_surface_mark_dirty (shell->mask_surface);
- buffer = gimp_drawable_get_buffer (shell->mask);
-
stride = cairo_image_surface_get_stride (shell->mask_surface);
data = cairo_image_surface_get_data (shell->mask_surface);
data += mask_src_y * stride + mask_src_x * 4;
- gegl_buffer_get (buffer,
+ gegl_buffer_get (shell->mask,
GEGL_RECTANGLE ((x + viewport_offset_x) * window_scale,
(y + viewport_offset_y) * window_scale,
w * window_scale,
diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c
index a881e53..897c3ef 100644
--- a/app/display/gimpdisplayshell.c
+++ b/app/display/gimpdisplayshell.c
@@ -1823,13 +1823,11 @@ gimp_display_shell_set_highlight (GimpDisplayShell *shell,
**/
void
gimp_display_shell_set_mask (GimpDisplayShell *shell,
- GimpDrawable *mask,
+ GeglBuffer *mask,
const GimpRGB *color)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
- g_return_if_fail (mask == NULL ||
- (GIMP_IS_DRAWABLE (mask) &&
- babl_format_get_bytes_per_pixel (gimp_drawable_get_format (mask)) == 1));
+ g_return_if_fail (mask == NULL || GEGL_IS_BUFFER (mask));
g_return_if_fail (mask == NULL || color != NULL);
if (mask)
diff --git a/app/display/gimpdisplayshell.h b/app/display/gimpdisplayshell.h
index 50f1823..c4c57a9 100644
--- a/app/display/gimpdisplayshell.h
+++ b/app/display/gimpdisplayshell.h
@@ -186,7 +186,7 @@ struct _GimpDisplayShell
gdouble rotate_drag_angle;
gpointer scroll_info;
- GimpDrawable *mask;
+ GeglBuffer *mask;
GimpRGB mask_color;
GimpMotionBuffer *motion_buffer;
@@ -272,7 +272,7 @@ void gimp_display_shell_resume (GimpDisplayShell *shell);
void gimp_display_shell_set_highlight (GimpDisplayShell *shell,
const GdkRectangle *highlight);
void gimp_display_shell_set_mask (GimpDisplayShell *shell,
- GimpDrawable *mask,
+ GeglBuffer *mask,
const GimpRGB *color);
diff --git a/app/tools/gimpforegroundselecttool.c b/app/tools/gimpforegroundselecttool.c
index bca38f5..0c0ad81 100644
--- a/app/tools/gimpforegroundselecttool.c
+++ b/app/tools/gimpforegroundselecttool.c
@@ -32,9 +32,9 @@
#include "tools-types.h"
+#include "gegl/gimp-gegl-mask.h"
+
#include "core/gimp.h"
-#include "core/gimpchannel-combine.h"
-#include "core/gimpchannel-select.h"
#include "core/gimpdrawable-foreground-extract.h"
#include "core/gimpimage.h"
#include "core/gimplayer.h"
@@ -223,13 +223,13 @@ gimp_foreground_select_tool_finalize (GObject *object)
GimpForegroundSelectTool *fg_select = GIMP_FOREGROUND_SELECT_TOOL (object);
if (fg_select->stroke)
- g_warning ("%s: stroke should be NULL at this point", G_STRLOC);
+ g_warning ("%s: stroke should be NULL at this point", G_STRLOC);
if (fg_select->mask)
- g_warning ("%s: mask should be NULL at this point", G_STRLOC);
+ g_warning ("%s: mask should be NULL at this point", G_STRLOC);
if (fg_select->trimap)
- g_warning ("%s: mask should be NULL at this point", G_STRLOC);
+ g_warning ("%s: mask should be NULL at this point", G_STRLOC);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@@ -510,16 +510,16 @@ gimp_foreground_select_tool_motion (GimpTool *tool,
}
static void
-gimp_foreground_select_tool_get_area (GimpChannel *mask,
- gint *x1,
- gint *y1,
- gint *x2,
- gint *y2)
+gimp_foreground_select_tool_get_area (GeglBuffer *mask,
+ gint *x1,
+ gint *y1,
+ gint *x2,
+ gint *y2)
{
gint width;
gint height;
- gimp_channel_bounds (mask, x1, y1, x2, y2);
+ gimp_gegl_mask_bounds (mask, x1, y1, x2, y2);
width = *x2 - *x1;
height = *y2 - *y1;
@@ -618,13 +618,12 @@ gimp_foreground_select_tool_select (GimpFreeSelectTool *free_sel,
points,
TRUE);
- fg_select->trimap = gimp_channel_new (image,
- gimp_image_get_width (image),
- gimp_image_get_height (image),
- "foreground-extraction",NULL);
+ fg_select->trimap = gegl_buffer_new (GEGL_RECTANGLE (0, 0,
+ gimp_image_get_width (image),
+ gimp_image_get_height (image)),
+ gimp_image_get_mask_format (image));
- gimp_scan_convert_render_value (scan_convert,
- gimp_drawable_get_buffer (GIMP_DRAWABLE (fg_select->trimap)),
+ gimp_scan_convert_render_value (scan_convert, fg_select->trimap,
0, 0, 1.0);
gimp_scan_convert_free (scan_convert);
@@ -646,7 +645,7 @@ gimp_foreground_select_tool_set_trimap (GimpForegroundSelectTool *fg_select,
gimp_foreground_select_options_get_mask_color (options, &color);
gimp_display_shell_set_mask (gimp_display_get_shell (display),
- GIMP_DRAWABLE (fg_select->trimap), &color);
+ fg_select->trimap, &color);
gimp_tool_control_set_tool_cursor (tool->control,
GIMP_TOOL_CURSOR_PAINTBRUSH);
@@ -674,7 +673,7 @@ gimp_foreground_select_tool_set_preview (GimpForegroundSelectTool *fg_select,
gimp_foreground_select_options_get_mask_color (options, &color);
gimp_rgb_set_alpha (&color, 1.0);
gimp_display_shell_set_mask (gimp_display_get_shell (display),
- GIMP_DRAWABLE (fg_select->mask), &color);
+ fg_select->mask, &color);
gimp_tool_control_set_tool_cursor (tool->control,
GIMP_TOOL_CURSOR_PAINTBRUSH);
@@ -749,7 +748,7 @@ gimp_foreground_select_tool_preview (GimpForegroundSelectTool *fg_select,
_("Computing alpha of unknown pixels"),
FALSE);
- trimap_buffer = gimp_drawable_get_buffer (GIMP_DRAWABLE (fg_select->trimap));
+ trimap_buffer = fg_select->trimap;
drawable_buffer = gimp_drawable_get_buffer (drawable);
gegl = gegl_node_new ();
@@ -804,15 +803,11 @@ gimp_foreground_select_tool_preview (GimpForegroundSelectTool *fg_select,
g_object_unref (processor);
- fg_select->mask = gimp_channel_new_from_buffer (buffer, image,
- "preview-mask", NULL);
+ fg_select->mask = buffer;
gimp_foreground_select_tool_set_preview (fg_select, display);
g_object_unref (gegl);
-
- if (buffer)
- g_object_unref (buffer);
}
static void
@@ -822,15 +817,12 @@ gimp_foreground_select_tool_apply (GimpForegroundSelectTool *fg_select,
GimpTool *tool = GIMP_TOOL (fg_select);
GimpImage *image = gimp_display_get_image (display);
GimpLayer *layer = gimp_image_get_active_layer (image);
- GeglBuffer *buffer;
GimpLayerMask *layer_mask;
GimpRGB color = { 0.0, 0.0, 0.0, GIMP_OPACITY_OPAQUE };
g_return_if_fail (fg_select->mask != NULL);
- buffer = gimp_drawable_get_buffer (GIMP_DRAWABLE (fg_select->mask));
-
- layer_mask = gimp_layer_mask_new_from_buffer (buffer, image,
+ layer_mask = gimp_layer_mask_new_from_buffer (fg_select->mask, image,
"mask", &color);
gimp_layer_add_mask (layer, layer_mask, TRUE, NULL);
@@ -878,8 +870,7 @@ gimp_foreground_select_tool_stroke_paint (GimpForegroundSelectTool *fg_select
GIMP_JOIN_ROUND, GIMP_CAP_ROUND, 10.0,
0.0, NULL);
- gimp_scan_convert_compose_value (scan_convert,
- gimp_drawable_get_buffer (GIMP_DRAWABLE (fg_select->trimap)),
+ gimp_scan_convert_compose_value (scan_convert, fg_select->trimap,
0, 0,
gimp_foreground_select_options_get_opacity (options));
diff --git a/app/tools/gimpforegroundselecttool.h b/app/tools/gimpforegroundselecttool.h
index f2e2982..31a8974 100644
--- a/app/tools/gimpforegroundselecttool.h
+++ b/app/tools/gimpforegroundselecttool.h
@@ -49,8 +49,8 @@ struct _GimpForegroundSelectTool
GimpCoords last_coords;
GArray *stroke;
- GimpChannel *trimap;
- GimpChannel *mask;
+ GeglBuffer *trimap;
+ GeglBuffer *mask;
MattingState state;
};
diff --git a/app/tools/gimptool-progress.c b/app/tools/gimptool-progress.c
index 1f2a136..703356e 100644
--- a/app/tools/gimptool-progress.c
+++ b/app/tools/gimptool-progress.c
@@ -20,6 +20,7 @@
#include "config.h"
+#include <gegl.h>
#include <gtk/gtk.h>
#include "tools-types.h"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]