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:
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <gegl.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
#include "libgimpwidgets/gimpwidgets.h"
|
#include "libgimpwidgets/gimpwidgets.h"
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <gegl.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
#include "display-types.h"
|
#include "display-types.h"
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <gegl.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
#include "libgimpconfig/gimpconfig.h"
|
#include "libgimpconfig/gimpconfig.h"
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <gegl.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
#include "display-types.h"
|
#include "display-types.h"
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <gegl.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
#include <libgimpmath/gimpmath.h>
|
#include <libgimpmath/gimpmath.h>
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <gegl.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
#include "display-types.h"
|
#include "display-types.h"
|
||||||
|
@ -146,13 +146,11 @@ gimp_display_shell_render (GimpDisplayShell *shell,
|
|||||||
|
|
||||||
cairo_surface_mark_dirty (shell->mask_surface);
|
cairo_surface_mark_dirty (shell->mask_surface);
|
||||||
|
|
||||||
buffer = gimp_drawable_get_buffer (shell->mask);
|
|
||||||
|
|
||||||
stride = cairo_image_surface_get_stride (shell->mask_surface);
|
stride = cairo_image_surface_get_stride (shell->mask_surface);
|
||||||
data = cairo_image_surface_get_data (shell->mask_surface);
|
data = cairo_image_surface_get_data (shell->mask_surface);
|
||||||
data += mask_src_y * stride + mask_src_x * 4;
|
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,
|
GEGL_RECTANGLE ((x + viewport_offset_x) * window_scale,
|
||||||
(y + viewport_offset_y) * window_scale,
|
(y + viewport_offset_y) * window_scale,
|
||||||
w * window_scale,
|
w * window_scale,
|
||||||
|
@ -1823,13 +1823,11 @@ gimp_display_shell_set_highlight (GimpDisplayShell *shell,
|
|||||||
**/
|
**/
|
||||||
void
|
void
|
||||||
gimp_display_shell_set_mask (GimpDisplayShell *shell,
|
gimp_display_shell_set_mask (GimpDisplayShell *shell,
|
||||||
GimpDrawable *mask,
|
GeglBuffer *mask,
|
||||||
const GimpRGB *color)
|
const GimpRGB *color)
|
||||||
{
|
{
|
||||||
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
||||||
g_return_if_fail (mask == NULL ||
|
g_return_if_fail (mask == NULL || GEGL_IS_BUFFER (mask));
|
||||||
(GIMP_IS_DRAWABLE (mask) &&
|
|
||||||
babl_format_get_bytes_per_pixel (gimp_drawable_get_format (mask)) == 1));
|
|
||||||
g_return_if_fail (mask == NULL || color != NULL);
|
g_return_if_fail (mask == NULL || color != NULL);
|
||||||
|
|
||||||
if (mask)
|
if (mask)
|
||||||
|
@ -186,7 +186,7 @@ struct _GimpDisplayShell
|
|||||||
gdouble rotate_drag_angle;
|
gdouble rotate_drag_angle;
|
||||||
gpointer scroll_info;
|
gpointer scroll_info;
|
||||||
|
|
||||||
GimpDrawable *mask;
|
GeglBuffer *mask;
|
||||||
GimpRGB mask_color;
|
GimpRGB mask_color;
|
||||||
|
|
||||||
GimpMotionBuffer *motion_buffer;
|
GimpMotionBuffer *motion_buffer;
|
||||||
@ -272,7 +272,7 @@ void gimp_display_shell_resume (GimpDisplayShell *shell);
|
|||||||
void gimp_display_shell_set_highlight (GimpDisplayShell *shell,
|
void gimp_display_shell_set_highlight (GimpDisplayShell *shell,
|
||||||
const GdkRectangle *highlight);
|
const GdkRectangle *highlight);
|
||||||
void gimp_display_shell_set_mask (GimpDisplayShell *shell,
|
void gimp_display_shell_set_mask (GimpDisplayShell *shell,
|
||||||
GimpDrawable *mask,
|
GeglBuffer *mask,
|
||||||
const GimpRGB *color);
|
const GimpRGB *color);
|
||||||
|
|
||||||
|
|
||||||
|
@ -32,9 +32,9 @@
|
|||||||
|
|
||||||
#include "tools-types.h"
|
#include "tools-types.h"
|
||||||
|
|
||||||
|
#include "gegl/gimp-gegl-mask.h"
|
||||||
|
|
||||||
#include "core/gimp.h"
|
#include "core/gimp.h"
|
||||||
#include "core/gimpchannel-combine.h"
|
|
||||||
#include "core/gimpchannel-select.h"
|
|
||||||
#include "core/gimpdrawable-foreground-extract.h"
|
#include "core/gimpdrawable-foreground-extract.h"
|
||||||
#include "core/gimpimage.h"
|
#include "core/gimpimage.h"
|
||||||
#include "core/gimplayer.h"
|
#include "core/gimplayer.h"
|
||||||
@ -223,13 +223,13 @@ gimp_foreground_select_tool_finalize (GObject *object)
|
|||||||
GimpForegroundSelectTool *fg_select = GIMP_FOREGROUND_SELECT_TOOL (object);
|
GimpForegroundSelectTool *fg_select = GIMP_FOREGROUND_SELECT_TOOL (object);
|
||||||
|
|
||||||
if (fg_select->stroke)
|
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)
|
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)
|
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);
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
@ -510,16 +510,16 @@ gimp_foreground_select_tool_motion (GimpTool *tool,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_foreground_select_tool_get_area (GimpChannel *mask,
|
gimp_foreground_select_tool_get_area (GeglBuffer *mask,
|
||||||
gint *x1,
|
gint *x1,
|
||||||
gint *y1,
|
gint *y1,
|
||||||
gint *x2,
|
gint *x2,
|
||||||
gint *y2)
|
gint *y2)
|
||||||
{
|
{
|
||||||
gint width;
|
gint width;
|
||||||
gint height;
|
gint height;
|
||||||
|
|
||||||
gimp_channel_bounds (mask, x1, y1, x2, y2);
|
gimp_gegl_mask_bounds (mask, x1, y1, x2, y2);
|
||||||
|
|
||||||
width = *x2 - *x1;
|
width = *x2 - *x1;
|
||||||
height = *y2 - *y1;
|
height = *y2 - *y1;
|
||||||
@ -618,13 +618,12 @@ gimp_foreground_select_tool_select (GimpFreeSelectTool *free_sel,
|
|||||||
points,
|
points,
|
||||||
TRUE);
|
TRUE);
|
||||||
|
|
||||||
fg_select->trimap = gimp_channel_new (image,
|
fg_select->trimap = gegl_buffer_new (GEGL_RECTANGLE (0, 0,
|
||||||
gimp_image_get_width (image),
|
gimp_image_get_width (image),
|
||||||
gimp_image_get_height (image),
|
gimp_image_get_height (image)),
|
||||||
"foreground-extraction",NULL);
|
gimp_image_get_mask_format (image));
|
||||||
|
|
||||||
gimp_scan_convert_render_value (scan_convert,
|
gimp_scan_convert_render_value (scan_convert, fg_select->trimap,
|
||||||
gimp_drawable_get_buffer (GIMP_DRAWABLE (fg_select->trimap)),
|
|
||||||
0, 0, 1.0);
|
0, 0, 1.0);
|
||||||
gimp_scan_convert_free (scan_convert);
|
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_foreground_select_options_get_mask_color (options, &color);
|
||||||
gimp_display_shell_set_mask (gimp_display_get_shell (display),
|
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_control_set_tool_cursor (tool->control,
|
||||||
GIMP_TOOL_CURSOR_PAINTBRUSH);
|
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_foreground_select_options_get_mask_color (options, &color);
|
||||||
gimp_rgb_set_alpha (&color, 1.0);
|
gimp_rgb_set_alpha (&color, 1.0);
|
||||||
gimp_display_shell_set_mask (gimp_display_get_shell (display),
|
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_control_set_tool_cursor (tool->control,
|
||||||
GIMP_TOOL_CURSOR_PAINTBRUSH);
|
GIMP_TOOL_CURSOR_PAINTBRUSH);
|
||||||
@ -749,7 +748,7 @@ gimp_foreground_select_tool_preview (GimpForegroundSelectTool *fg_select,
|
|||||||
_("Computing alpha of unknown pixels"),
|
_("Computing alpha of unknown pixels"),
|
||||||
FALSE);
|
FALSE);
|
||||||
|
|
||||||
trimap_buffer = gimp_drawable_get_buffer (GIMP_DRAWABLE (fg_select->trimap));
|
trimap_buffer = fg_select->trimap;
|
||||||
drawable_buffer = gimp_drawable_get_buffer (drawable);
|
drawable_buffer = gimp_drawable_get_buffer (drawable);
|
||||||
|
|
||||||
gegl = gegl_node_new ();
|
gegl = gegl_node_new ();
|
||||||
@ -804,15 +803,11 @@ gimp_foreground_select_tool_preview (GimpForegroundSelectTool *fg_select,
|
|||||||
|
|
||||||
g_object_unref (processor);
|
g_object_unref (processor);
|
||||||
|
|
||||||
fg_select->mask = gimp_channel_new_from_buffer (buffer, image,
|
fg_select->mask = buffer;
|
||||||
"preview-mask", NULL);
|
|
||||||
|
|
||||||
gimp_foreground_select_tool_set_preview (fg_select, display);
|
gimp_foreground_select_tool_set_preview (fg_select, display);
|
||||||
|
|
||||||
g_object_unref (gegl);
|
g_object_unref (gegl);
|
||||||
|
|
||||||
if (buffer)
|
|
||||||
g_object_unref (buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -822,15 +817,12 @@ gimp_foreground_select_tool_apply (GimpForegroundSelectTool *fg_select,
|
|||||||
GimpTool *tool = GIMP_TOOL (fg_select);
|
GimpTool *tool = GIMP_TOOL (fg_select);
|
||||||
GimpImage *image = gimp_display_get_image (display);
|
GimpImage *image = gimp_display_get_image (display);
|
||||||
GimpLayer *layer = gimp_image_get_active_layer (image);
|
GimpLayer *layer = gimp_image_get_active_layer (image);
|
||||||
GeglBuffer *buffer;
|
|
||||||
GimpLayerMask *layer_mask;
|
GimpLayerMask *layer_mask;
|
||||||
GimpRGB color = { 0.0, 0.0, 0.0, GIMP_OPACITY_OPAQUE };
|
GimpRGB color = { 0.0, 0.0, 0.0, GIMP_OPACITY_OPAQUE };
|
||||||
|
|
||||||
g_return_if_fail (fg_select->mask != NULL);
|
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 (fg_select->mask, image,
|
||||||
|
|
||||||
layer_mask = gimp_layer_mask_new_from_buffer (buffer, image,
|
|
||||||
"mask", &color);
|
"mask", &color);
|
||||||
|
|
||||||
gimp_layer_add_mask (layer, layer_mask, TRUE, NULL);
|
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,
|
GIMP_JOIN_ROUND, GIMP_CAP_ROUND, 10.0,
|
||||||
0.0, NULL);
|
0.0, NULL);
|
||||||
|
|
||||||
gimp_scan_convert_compose_value (scan_convert,
|
gimp_scan_convert_compose_value (scan_convert, fg_select->trimap,
|
||||||
gimp_drawable_get_buffer (GIMP_DRAWABLE (fg_select->trimap)),
|
|
||||||
0, 0,
|
0, 0,
|
||||||
gimp_foreground_select_options_get_opacity (options));
|
gimp_foreground_select_options_get_opacity (options));
|
||||||
|
|
||||||
|
@ -49,8 +49,8 @@ struct _GimpForegroundSelectTool
|
|||||||
|
|
||||||
GimpCoords last_coords;
|
GimpCoords last_coords;
|
||||||
GArray *stroke;
|
GArray *stroke;
|
||||||
GimpChannel *trimap;
|
GeglBuffer *trimap;
|
||||||
GimpChannel *mask;
|
GeglBuffer *mask;
|
||||||
MattingState state;
|
MattingState state;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <gegl.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
#include "tools-types.h"
|
#include "tools-types.h"
|
||||||
|
Reference in New Issue
Block a user