moved the code which manipulates gimage->layer_stack and the call to

2003-07-29  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpimage.c (gimp_image_set_active_layer): moved the
	code which manipulates gimage->layer_stack and the call to
	gimp_layer_invalidate_boundary() inside the if(layer != active_layer)
	branch so it is called less often. Fixes the slowness of bug #104440
	for most cases since we don't need to recalculate the selection
	boundary in the next step.

	(gimp_image_set_active_channel): call
	gimp_layer_invalidate_boundary() before setting the active_layer
	to NULL. Fixes stale layer boundary when switching to a channel.

	* app/display/gimpdisplay.c (gimp_display_flush_whenever): when
	there are no updates, we still need to restart the selection.
	Fixes missing layer boundary when switching from a channel to
	a layer.
This commit is contained in:
Michael Natterer
2003-07-29 16:36:56 +00:00
committed by Michael Natterer
parent bd457be1c7
commit 6c0c7fda33
4 changed files with 97 additions and 58 deletions

View File

@ -1,3 +1,21 @@
2003-07-29 Michael Natterer <mitch@gimp.org>
* app/core/gimpimage.c (gimp_image_set_active_layer): moved the
code which manipulates gimage->layer_stack and the call to
gimp_layer_invalidate_boundary() inside the if(layer != active_layer)
branch so it is called less often. Fixes the slowness of bug #104440
for most cases since we don't need to recalculate the selection
boundary in the next step.
(gimp_image_set_active_channel): call
gimp_layer_invalidate_boundary() before setting the active_layer
to NULL. Fixes stale layer boundary when switching to a channel.
* app/display/gimpdisplay.c (gimp_display_flush_whenever): when
there are no updates, we still need to restart the selection.
Fixes missing layer boundary when switching from a channel to
a layer.
2003-07-29 Michael Natterer <mitch@gimp.org> 2003-07-29 Michael Natterer <mitch@gimp.org>
* app/display/gimpdisplayshell-handlers.c * app/display/gimpdisplayshell-handlers.c

View File

@ -2180,18 +2180,18 @@ gimp_image_set_active_layer (GimpImage *gimage,
if (! gimp_container_have (gimage->layers, GIMP_OBJECT (layer))) if (! gimp_container_have (gimage->layers, GIMP_OBJECT (layer)))
layer = (GimpLayer *) gimp_container_get_child_by_index (gimage->layers, 0); layer = (GimpLayer *) gimp_container_get_child_by_index (gimage->layers, 0);
if (layer)
{
/* Configure the layer stack to reflect this change */
gimage->layer_stack = g_slist_remove (gimage->layer_stack, layer);
gimage->layer_stack = g_slist_prepend (gimage->layer_stack, layer);
/* invalidate the selection boundary because of a layer modification */
gimp_layer_invalidate_boundary (layer);
}
if (layer != gimage->active_layer) if (layer != gimage->active_layer)
{ {
if (layer)
{
/* Configure the layer stack to reflect this change */
gimage->layer_stack = g_slist_remove (gimage->layer_stack, layer);
gimage->layer_stack = g_slist_prepend (gimage->layer_stack, layer);
/* Don't cache selection info for the previous active layer */
gimp_layer_invalidate_boundary (layer);
}
gimage->active_layer = layer; gimage->active_layer = layer;
g_signal_emit (gimage, gimp_image_signals[ACTIVE_LAYER_CHANGED], 0); g_signal_emit (gimage, gimp_image_signals[ACTIVE_LAYER_CHANGED], 0);
@ -2233,6 +2233,9 @@ gimp_image_set_active_channel (GimpImage *gimage,
if (gimage->active_layer) if (gimage->active_layer)
{ {
/* Don't cache selection info for the previous active layer */
gimp_layer_invalidate_boundary (gimage->active_layer);
gimage->active_layer = NULL; gimage->active_layer = NULL;
g_signal_emit (gimage, gimp_image_signals[ACTIVE_LAYER_CHANGED], 0); g_signal_emit (gimage, gimp_image_signals[ACTIVE_LAYER_CHANGED], 0);

View File

@ -445,39 +445,48 @@ gimp_display_flush_whenever (GimpDisplay *gdisp,
} }
/* First the updates... */ /* First the updates... */
if (now) if (gdisp->update_areas)
{ {
/* Synchronous */ if (now)
{
/* Synchronous */
GSList *list; GSList *list;
GimpArea *area; GimpArea *area;
for (list = gdisp->update_areas; list; list = g_slist_next (list)) for (list = gdisp->update_areas; list; list = g_slist_next (list))
{ {
/* Paint the area specified by the GimpArea */ /* Paint the area specified by the GimpArea */
area = (GimpArea *) list->data; area = (GimpArea *) list->data;
if ((area->x1 != area->x2) && (area->y1 != area->y2)) if ((area->x1 != area->x2) && (area->y1 != area->y2))
{ {
gimp_display_paint_area (gdisp, gimp_display_paint_area (gdisp,
area->x1, area->x1,
area->y1, area->y1,
(area->x2 - area->x1), (area->x2 - area->x1),
(area->y2 - area->y1)); (area->y2 - area->y1));
} }
} }
}
else
{
/* Asynchronous */
gimp_display_idlerender_init (gdisp);
}
/* Free the update lists */
gdisp->update_areas = gimp_display_area_list_free (gdisp->update_areas);
} }
else else
{ {
/* Asynchronous */ /* if there was nothing to update, we still need to start the
* selection --mitch
if (gdisp->update_areas) */
gimp_display_idlerender_init (gdisp); gimp_display_shell_selection_visibility (shell, GIMP_SELECTION_ON);
} }
/* Free the update lists */
gdisp->update_areas = gimp_display_area_list_free (gdisp->update_areas);
/* Next the displays... */ /* Next the displays... */
gimp_display_shell_flush (shell); gimp_display_shell_flush (shell);

View File

@ -445,39 +445,48 @@ gimp_display_flush_whenever (GimpDisplay *gdisp,
} }
/* First the updates... */ /* First the updates... */
if (now) if (gdisp->update_areas)
{ {
/* Synchronous */ if (now)
{
/* Synchronous */
GSList *list; GSList *list;
GimpArea *area; GimpArea *area;
for (list = gdisp->update_areas; list; list = g_slist_next (list)) for (list = gdisp->update_areas; list; list = g_slist_next (list))
{ {
/* Paint the area specified by the GimpArea */ /* Paint the area specified by the GimpArea */
area = (GimpArea *) list->data; area = (GimpArea *) list->data;
if ((area->x1 != area->x2) && (area->y1 != area->y2)) if ((area->x1 != area->x2) && (area->y1 != area->y2))
{ {
gimp_display_paint_area (gdisp, gimp_display_paint_area (gdisp,
area->x1, area->x1,
area->y1, area->y1,
(area->x2 - area->x1), (area->x2 - area->x1),
(area->y2 - area->y1)); (area->y2 - area->y1));
} }
} }
}
else
{
/* Asynchronous */
gimp_display_idlerender_init (gdisp);
}
/* Free the update lists */
gdisp->update_areas = gimp_display_area_list_free (gdisp->update_areas);
} }
else else
{ {
/* Asynchronous */ /* if there was nothing to update, we still need to start the
* selection --mitch
if (gdisp->update_areas) */
gimp_display_idlerender_init (gdisp); gimp_display_shell_selection_visibility (shell, GIMP_SELECTION_ON);
} }
/* Free the update lists */
gdisp->update_areas = gimp_display_area_list_free (gdisp->update_areas);
/* Next the displays... */ /* Next the displays... */
gimp_display_shell_flush (shell); gimp_display_shell_flush (shell);