Commit ceed8eae authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

removed #if 0'ed old display update hackery. Don't flush the displays here

2002-02-10  Michael Natterer  <mitch@gimp.org>

	* app/undo.c: removed #if 0'ed old display update hackery. Don't
	flush the displays here at all and include nothing from
	"display/".

	* app/undo_history.c
	* app/gui/edit-commands.c: call gdisplays_flush() if undo_pop() or
	undo_redo() return TRUE.

	* app/core/gimpimage-contiguous-region.[ch]: allow a contiguous
	transparent region to be selected/filled (#71058).

	* app/core/gimpdrawable-bucket-fill.[ch]
	* app/core/gimpimage-mask-select.[ch]: take a boolean
	fill_transparent/select_transparent parameter and pass it to the
	contiguous region funcion.

	* app/display/gimpdisplayshell-dnd.c: pass
	fill_transparent == FALSE to bucket_fill_full because we fill the
	whole drawable anyway here.

	* app/tools/gimpbucketfilltool.c
	* app/tools/gimpbycolorselecttool.c
	* app/tools/gimpfuzzyselecttool.c
	* app/tools/selection_options.[ch]: added toggle buttons to the
	tool options and pass the value to the fill and select core
	functions.

	* tools/pdbgen/pdb/misc_tools.pdb
	* tools/pdbgen/pdb/selection_tools.pdb: hardcode
	"select_transparent" to FALSE to get the old behaviour. Should
	export the new feature to plug-ins however.

	* app/pdb/misc_tools_cmds.c
	* app/pdb/selection_tools_cmds.c: regenerated.
parent e12f5361
2002-02-10 Michael Natterer <mitch@gimp.org>
* app/undo.c: removed #if 0'ed old display update hackery. Don't
flush the displays here at all and include nothing from
"display/".
* app/undo_history.c
* app/gui/edit-commands.c: call gdisplays_flush() if undo_pop() or
undo_redo() return TRUE.
* app/core/gimpimage-contiguous-region.[ch]: allow a contiguous
transparent region to be selected/filled (#71058).
* app/core/gimpdrawable-bucket-fill.[ch]
* app/core/gimpimage-mask-select.[ch]: take a boolean
fill_transparent/select_transparent parameter and pass it to the
contiguous region funcion.
* app/display/gimpdisplayshell-dnd.c: pass
fill_transparent == FALSE to bucket_fill_full because we fill the
whole drawable anyway here.
* app/tools/gimpbucketfilltool.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpfuzzyselecttool.c
* app/tools/selection_options.[ch]: added toggle buttons to the
tool options and pass the value to the fill and select core
functions.
* tools/pdbgen/pdb/misc_tools.pdb
* tools/pdbgen/pdb/selection_tools.pdb: hardcode
"select_transparent" to FALSE to get the old behaviour. Should
export the new feature to plug-ins however.
* app/pdb/misc_tools_cmds.c
* app/pdb/selection_tools_cmds.c: regenerated.
2002-02-09 Sven Neumann <sven@gimp.org>
 
* app/tools/gimptoolmodule.[ch]
......
......@@ -78,7 +78,10 @@ edit_undo_cmd_callback (GtkWidget *widget,
GimpImage *gimage;
return_if_no_image (gimage, data);
undo_pop (gimage);
if (undo_pop (gimage))
{
gdisplays_flush ();
}
}
void
......@@ -88,7 +91,10 @@ edit_redo_cmd_callback (GtkWidget *widget,
GimpImage *gimage;
return_if_no_image (gimage, data);
undo_redo (gimage);
if (undo_redo (gimage))
{
gdisplays_flush ();
}
}
void
......
......@@ -217,6 +217,7 @@ gimp_image_mask_select_fuzzy (GimpImage *gimage,
gint x,
gint y,
gint threshold,
gboolean select_transparent,
ChannelOps op,
gboolean antialias,
gboolean feather,
......@@ -232,6 +233,7 @@ gimp_image_mask_select_fuzzy (GimpImage *gimage,
sample_merged,
antialias,
threshold,
select_transparent,
x, y);
gimp_image_mask_select_channel (gimage,
......@@ -252,6 +254,7 @@ gimp_image_mask_select_by_color (GimpImage *gimage,
gboolean sample_merged,
const GimpRGB *color,
gint threshold,
gboolean select_transparent,
ChannelOps op,
gboolean antialias,
gboolean feather,
......@@ -268,6 +271,7 @@ gimp_image_mask_select_by_color (GimpImage *gimage,
sample_merged,
antialias,
threshold,
select_transparent,
color);
gimp_image_mask_select_channel (gimage,
......
......@@ -65,6 +65,7 @@ void gimp_image_mask_select_fuzzy (GimpImage *gimage,
gint x,
gint y,
gint threshold,
gboolean select_transparent,
ChannelOps op,
gboolean antialias,
gboolean feather,
......@@ -76,6 +77,7 @@ void gimp_image_mask_select_by_color (GimpImage *gimage,
gboolean sample_merged,
const GimpRGB *color,
gint threshold,
gboolean select_transparent,
ChannelOps op,
gboolean antialias,
gboolean feather,
......
......@@ -79,6 +79,7 @@ gimp_drawable_bucket_fill (GimpDrawable *drawable,
BucketFillMode fill_mode,
gint paint_mode,
gdouble opacity,
gboolean fill_transparent,
gdouble threshold,
gboolean sample_merged,
gdouble x,
......@@ -126,6 +127,7 @@ gimp_drawable_bucket_fill (GimpDrawable *drawable,
&color, pattern,
paint_mode, opacity,
TRUE /* do seed fill */,
fill_transparent,
threshold, sample_merged,
x, y);
}
......@@ -138,6 +140,7 @@ gimp_drawable_bucket_fill_full (GimpDrawable *drawable,
gint paint_mode,
gdouble opacity,
gboolean do_seed_fill,
gboolean fill_transparent,
gdouble threshold,
gboolean sample_merged,
gdouble x,
......@@ -233,6 +236,7 @@ gimp_drawable_bucket_fill_full (GimpDrawable *drawable,
sample_merged,
TRUE,
(gint) threshold,
fill_transparent,
(gint) x,
(gint) y);
......
......@@ -24,6 +24,7 @@ void gimp_drawable_bucket_fill (GimpDrawable *drawable,
BucketFillMode fill_mode,
gint paint_mode,
gdouble opacity,
gboolean fill_transparent,
gdouble threshold,
gboolean sample_merged,
gdouble x,
......@@ -36,6 +37,7 @@ void gimp_drawable_bucket_fill_full (GimpDrawable *drawable,
gint paint_mode,
gdouble opacity,
gboolean do_seed_fill,
gboolean fill_transparent,
gdouble threshold,
gboolean sample_merged,
gdouble x,
......
......@@ -43,7 +43,8 @@ static gint is_pixel_sufficiently_different (guchar *col1,
gboolean antialias,
gint threshold,
gint bytes,
gboolean has_alpha);
gboolean has_alpha,
gboolean select_transparent);
static void ref_tiles (TileManager *src,
TileManager *mask,
Tile **s_tile,
......@@ -57,8 +58,9 @@ static gint find_contiguous_segment (guchar *col,
PixelRegion *mask,
gint width,
gint bytes,
gboolean has_alpha,
gboolean antialias,
gboolean has_alpha,
gboolean select_transparent,
gboolean antialias,
gint threshold,
gint initial,
gint *start,
......@@ -66,6 +68,7 @@ static gint find_contiguous_segment (guchar *col,
static void find_contiguous_region_helper (PixelRegion *mask,
PixelRegion *src,
gboolean has_alpha,
gboolean select_transparent,
gboolean antialias,
gint threshold,
gboolean indexed,
......@@ -78,10 +81,11 @@ static void find_contiguous_region_helper (PixelRegion *mask,
GimpChannel *
gimp_image_contiguous_region_by_seed (GimpImage *gimage,
GimpDrawable *drawable,
GimpDrawable *drawable,
gboolean sample_merged,
gboolean antialias,
gint threshold,
gboolean select_transparent,
gint x,
gint y)
{
......@@ -116,11 +120,12 @@ gimp_image_contiguous_region_by_seed (GimpImage *gimage,
}
indexed = gimp_drawable_is_indexed (drawable);
bytes = gimp_drawable_bytes (drawable);
if (indexed)
{
bytes = has_alpha ? 4 : 3;
}
mask = gimp_channel_new_mask (gimage, srcPR.w, srcPR.h);
pixel_region_init (&maskPR, gimp_drawable_data (GIMP_DRAWABLE (mask)),
0, 0,
......@@ -131,10 +136,27 @@ gimp_image_contiguous_region_by_seed (GimpImage *gimage,
tile = tile_manager_get_tile (srcPR.tiles, x, y, TRUE, FALSE);
if (tile)
{
start = tile_data_pointer (tile, x%TILE_WIDTH, y%TILE_HEIGHT);
start = tile_data_pointer (tile, x % TILE_WIDTH, y % TILE_HEIGHT);
if (has_alpha)
{
if (select_transparent)
{
/* don't select transparent regions if the start pixel isn't
* fully transparent
*/
if (start[bytes - 1] > 0)
select_transparent = FALSE;
}
}
else
{
select_transparent = FALSE;
}
find_contiguous_region_helper (&maskPR, &srcPR, has_alpha, antialias,
threshold, bytes, x, y, start);
find_contiguous_region_helper (&maskPR, &srcPR, has_alpha,
select_transparent, antialias, threshold,
bytes, x, y, start);
tile_release (tile, FALSE);
}
......@@ -148,6 +170,7 @@ gimp_image_contiguous_region_by_color (GimpImage *gimage,
gboolean sample_merged,
gboolean antialias,
gint threshold,
gboolean select_transparent,
const GimpRGB *color)
{
/* Scan over the gimage's active layer, finding pixels within the specified
......@@ -205,6 +228,21 @@ gimp_image_contiguous_region_by_color (GimpImage *gimage,
FALSE);
}
if (has_alpha)
{
if (select_transparent)
{
/* don't select transparancy if "color" isn't fully transparent
*/
if (col[3] > 0)
select_transparent = FALSE;
}
}
else
{
select_transparent = FALSE;
}
if (indexed)
{
/* indexed colors are always RGB or RGBA */
......@@ -251,7 +289,8 @@ gimp_image_contiguous_region_by_color (GimpImage *gimage,
antialias,
threshold,
color_bytes,
has_alpha);
has_alpha,
select_transparent);
idata += bytes;
}
......@@ -273,7 +312,8 @@ is_pixel_sufficiently_different (guchar *col1,
gboolean antialias,
gint threshold,
gint bytes,
gboolean has_alpha)
gboolean has_alpha,
gboolean select_transparent)
{
gint diff;
gint max;
......@@ -284,18 +324,26 @@ is_pixel_sufficiently_different (guchar *col1,
alpha = (has_alpha) ? bytes - 1 : bytes;
/* if there is an alpha channel, never select transparent regions */
if (has_alpha && col2[alpha] == 0)
if (! select_transparent && has_alpha && col2[alpha] == 0)
return 0;
/* fuzzy_select had a "for (b = 0; b < _bytes_; b++)" loop. however
* i'm quite sure "b < alpha" is correct for both tools --Mitch
*/
for (b = 0; b < alpha; b++)
if (select_transparent && has_alpha)
{
diff = col1[b] - col2[b];
diff = abs (diff);
if (diff > max)
max = diff;
max = col1[alpha] - col2[alpha];
max = abs (max);
}
else
{
/* fuzzy_select had a "for (b = 0; b < _bytes_; b++)" loop. however
* i'm quite sure "b < alpha" is correct for both tools --Mitch
*/
for (b = 0; b < alpha; b++)
{
diff = col1[b] - col2[b];
diff = abs (diff);
if (diff > max)
max = diff;
}
}
if (antialias && threshold > 0)
......@@ -348,8 +396,9 @@ find_contiguous_segment (guchar *col,
PixelRegion *mask,
gint width,
gint bytes,
gboolean has_alpha,
gboolean antialias,
gboolean has_alpha,
gboolean select_transparent,
gboolean antialias,
gint threshold,
gint initial,
gint *start,
......@@ -365,7 +414,8 @@ find_contiguous_segment (guchar *col,
/* check the starting pixel */
if (! (diff = is_pixel_sufficiently_different (col, s, antialias,
threshold, bytes, has_alpha)))
threshold, bytes, has_alpha,
select_transparent)))
{
tile_release (s_tile, FALSE);
tile_release (m_tile, TRUE);
......@@ -382,7 +432,8 @@ find_contiguous_segment (guchar *col,
ref_tiles (src->tiles, mask->tiles, &s_tile, &m_tile, *start, src->y, &s, &m);
diff = is_pixel_sufficiently_different (col, s, antialias,
threshold, bytes, has_alpha);
threshold, bytes, has_alpha,
select_transparent);
if ((*m-- = diff))
{
s -= bytes;
......@@ -401,7 +452,8 @@ find_contiguous_segment (guchar *col,
ref_tiles (src->tiles, mask->tiles, &s_tile, &m_tile, *end, src->y, &s, &m);
diff = is_pixel_sufficiently_different (col, s, antialias,
threshold, bytes, has_alpha);
threshold, bytes, has_alpha,
select_transparent);
if ((*m++ = diff))
{
s += bytes;
......@@ -419,6 +471,7 @@ static void
find_contiguous_region_helper (PixelRegion *mask,
PixelRegion *src,
gboolean has_alpha,
gboolean select_transparent,
gboolean antialias,
gint threshold,
gboolean indexed,
......@@ -432,10 +485,12 @@ find_contiguous_region_helper (PixelRegion *mask,
Tile *tile;
if (threshold == 0) threshold = 1;
if (x < 0 || x >= src->w) return;
if (y < 0 || y >= src->h) return;
if (threshold == 0)
threshold = 1;
tile = tile_manager_get_tile (mask->tiles, x, y, TRUE, FALSE);
val = *(guchar *)(tile_data_pointer (tile,
x % TILE_WIDTH, y % TILE_HEIGHT));
......@@ -454,14 +509,17 @@ find_contiguous_region_helper (PixelRegion *mask,
if (! find_contiguous_segment (col, src, mask, src->w,
src->bytes, has_alpha,
antialias, threshold, x, &start, &end))
select_transparent, antialias, threshold,
x, &start, &end))
return;
for (i = start + 1; i < end; i++)
{
find_contiguous_region_helper (mask, src, has_alpha, antialias,
threshold, indexed, i, y - 1, col);
find_contiguous_region_helper (mask, src, has_alpha, antialias,
threshold, indexed, i, y + 1, col);
find_contiguous_region_helper (mask, src, has_alpha, select_transparent,
antialias, threshold, indexed,
i, y - 1, col);
find_contiguous_region_helper (mask, src, has_alpha, select_transparent,
antialias, threshold, indexed,
i, y + 1, col);
}
}
......@@ -25,6 +25,7 @@ GimpChannel * gimp_image_contiguous_region_by_seed (GimpImage *gimage,
gboolean sample_merged,
gboolean antialias,
gint threshold,
gboolean select_transparent,
gint x,
gint y);
......@@ -33,6 +34,7 @@ GimpChannel * gimp_image_contiguous_region_by_color (GimpImage *gimage,
gboolean sample_merged,
gboolean antialias,
gint threshold,
gboolean select_transparent,
const GimpRGB *color);
......
......@@ -217,6 +217,7 @@ gimp_image_mask_select_fuzzy (GimpImage *gimage,
gint x,
gint y,
gint threshold,
gboolean select_transparent,
ChannelOps op,
gboolean antialias,
gboolean feather,
......@@ -232,6 +233,7 @@ gimp_image_mask_select_fuzzy (GimpImage *gimage,
sample_merged,
antialias,
threshold,
select_transparent,
x, y);
gimp_image_mask_select_channel (gimage,
......@@ -252,6 +254,7 @@ gimp_image_mask_select_by_color (GimpImage *gimage,
gboolean sample_merged,
const GimpRGB *color,
gint threshold,
gboolean select_transparent,
ChannelOps op,
gboolean antialias,
gboolean feather,
......@@ -268,6 +271,7 @@ gimp_image_mask_select_by_color (GimpImage *gimage,
sample_merged,
antialias,
threshold,
select_transparent,
color);
gimp_image_mask_select_channel (gimage,
......
......@@ -65,6 +65,7 @@ void gimp_image_mask_select_fuzzy (GimpImage *gimage,
gint x,
gint y,
gint threshold,
gboolean select_transparent,
ChannelOps op,
gboolean antialias,
gboolean feather,
......@@ -76,6 +77,7 @@ void gimp_image_mask_select_by_color (GimpImage *gimage,
gboolean sample_merged,
const GimpRGB *color,
gint threshold,
gboolean select_transparent,
ChannelOps op,
gboolean antialias,
gboolean feather,
......
......@@ -47,8 +47,6 @@
#include "core/gimpparasite.h"
#include "core/gimpparasitelist.h"
#include "display/gimpdisplay-foreach.h"
#include "tools/gimpbycolorselecttool.h"
#include "tools/gimptool.h"
#include "tools/gimpdrawtool.h"
......@@ -453,53 +451,6 @@ pop_stack (GimpImage *gimage,
if (status && ! in_group)
{
#ifdef __GNUC__
#warning FIXME: investigate why display update was done here
#endif
#if 0
GimpDisplay *gdisp;
gint x, y;
/* Flush any image updates and displays */
gdisp = gimp_context_get_display (gimp_get_user_context (gimage->gimp));
if (gdisp)
{
GimpDisplayShell *shell;
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
if (shell->gdisp->disp_xoffset || shell->gdisp->disp_yoffset)
{
gdk_drawable_get_size (shell->canvas->window, &x, &y);
if (shell->gdisp->disp_yoffset)
{
gimp_display_shell_add_expose_area (shell,
0, 0,
shell->gdisp->disp_width,
shell->gdisp->disp_yoffset);
gimp_display_shell_add_expose_area (shell,
0, shell->gdisp->disp_yoffset + y,
shell->gdisp->disp_width,
shell->gdisp->disp_height);
}
if (shell->gdisp->disp_xoffset)
{
gimp_display_shell_add_expose_area (shell,
0, 0,
shell->gdisp->disp_xoffset,
shell->gdisp->disp_height);
gimp_display_shell_add_expose_area (shell,
shell->gdisp->disp_xoffset + x, 0,
shell->gdisp->disp_width,
shell->gdisp->disp_height);
}
}
}
#endif
/* If the mode_changed flag was set */
if (mode_changed)
{
......@@ -536,8 +487,6 @@ pop_stack (GimpImage *gimage,
gimp_image_undo_event (gimage,
(state == UNDO)? UNDO_POPPED : UNDO_REDO);
gdisplays_flush ();
return TRUE;
}
}
......
......@@ -117,7 +117,7 @@ gimp_display_shell_bucket_fill (GimpImage *gimage,
gimp_context_get_paint_mode (context),
gimp_context_get_opacity (context),
FALSE /* no seed fill */,
0.0, FALSE, 0.0, 0.0 /* seed fill params */);
FALSE, 0.0, FALSE, 0.0, 0.0 /* fill params */);
gdisplays_flush ();
}
......
......@@ -78,7 +78,10 @@ edit_undo_cmd_callback (GtkWidget *widget,
GimpImage *gimage;
return_if_no_image (gimage, data);
undo_pop (gimage);
if (undo_pop (gimage))
{
gdisplays_flush ();
}
}
void
......@@ -88,7 +91,10 @@ edit_redo_cmd_callback (GtkWidget *widget,
GimpImage *gimage;
return_if_no_image (gimage, data);
undo_redo (gimage);
if (undo_redo (gimage))
{
gdisplays_flush ();
}
}
void
......
......@@ -282,6 +282,7 @@ bucket_fill_invoker (Gimp *gimp,
{
gimp_drawable_bucket_fill (drawable, fill_mode,
paint_mode, opacity / 100.0,
FALSE /* don't fill transparent */,
threshold, sample_merged, x, y);
}
}
......
......@@ -96,7 +96,9 @@ by_color_select_invoker (Gimp *gimp,
sample_merged,
&color,
threshold,
operation, antialias,
FALSE /* don't select transparent */,
operation,
antialias,
feather,
feather_radius,
feather_radius);
......@@ -436,6 +438,7 @@ fuzzy_select_invoker (Gimp *gimp,
sample_merged,
x, y,
threshold,
FALSE /* don't select transparent */,
operation,
antialias,
feather,
......
......@@ -33,8 +33,6 @@
#include "core/gimpimage-mask.h"
#include "core/gimptoolinfo.h"
#include "pdb/procedural_db.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplay-foreach.h"
......@@ -53,6 +51,10 @@ struct _BucketOptions
{
PaintOptions paint_options;