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.
This commit is contained in:
Michael Natterer
2013-06-22 22:26:46 +02:00
parent 5290963912
commit 31e9cc2ad9
12 changed files with 36 additions and 42 deletions

View File

@ -19,6 +19,7 @@
#include <string.h>
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"

View File

@ -17,6 +17,7 @@
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "display-types.h"

View File

@ -17,6 +17,7 @@
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpconfig/gimpconfig.h"

View File

@ -19,6 +19,7 @@
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "display-types.h"

View File

@ -20,6 +20,7 @@
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include <libgimpmath/gimpmath.h>

View File

@ -17,6 +17,7 @@
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "display-types.h"

View File

@ -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,

View File

@ -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)

View File

@ -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);

View File

@ -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));

View File

@ -49,8 +49,8 @@ struct _GimpForegroundSelectTool
GimpCoords last_coords;
GArray *stroke;
GimpChannel *trimap;
GimpChannel *mask;
GeglBuffer *trimap;
GeglBuffer *mask;
MattingState state;
};

View File

@ -20,6 +20,7 @@
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "tools-types.h"