From f764c56d035c611fe897a41c8adbaa7fcf35a651 Mon Sep 17 00:00:00 2001 From: Manish Singh Date: Sat, 3 Jun 2000 18:19:22 +0000 Subject: [PATCH] Be smarter about emitting the "invalidate_preview" signal. comitted using Yosh's account... --Sven --- ChangeLog | 15 +++++++++++++++ app/channel.c | 2 +- app/core/gimpchannel-combine.c | 2 +- app/core/gimpchannel.c | 2 +- app/core/gimpdrawable.c | 10 +++++++--- app/core/gimpdrawable.h | 3 ++- app/core/gimpimage-mask.c | 2 +- app/core/gimpimage-undo-push.c | 8 ++++---- app/core/gimplayer-floating-sel.c | 8 ++++---- app/core/gimplayer.c | 5 +++-- app/drawable.c | 2 +- app/floating_sel.c | 8 ++++---- app/gimage_mask.c | 2 +- app/gimpchannel.c | 2 +- app/gimpdrawable.c | 10 +++++++--- app/gimpdrawable.h | 3 ++- app/gimplayer.c | 5 +++-- app/ink.c | 2 +- app/layer.c | 5 +++-- app/paint/gimpink.c | 2 +- app/paint_core.c | 2 +- app/tools/gimpinktool.c | 2 +- app/tools/ink.c | 2 +- app/tools/paint_core.c | 2 +- app/tools/xinput_airbrush.c | 2 +- app/undo.c | 8 ++++---- app/xinput_airbrush.c | 2 +- 27 files changed, 73 insertions(+), 45 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9e1e1b0d93..a324db8389 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +Sat Jun 3 11:11:58 PDT 2000 Sven Neumann + + * app/channel.c + * app/drawable.c + * app/floating_sel.c + * app/gimage_mask.c + * app/gimpdrawable.[ch] + * app/ink.c + * app/layer.c + * app/paint_core.c + * app/undo.c + * app/xinput_airbrush.c: be smarter about emitting the + "invalidate_preview" signal, so it doesn't slow down + painting and image_map color-corrections. + 2000-06-03 Michael Natterer Sven Neumann diff --git a/app/channel.c b/app/channel.c index 7ce0d32a4d..ed062e1b69 100644 --- a/app/channel.c +++ b/app/channel.c @@ -580,7 +580,7 @@ channel_invalidate_previews (GimpImage* gimage) while (tmp) { channel = (Channel *) tmp->data; - drawable_invalidate_preview (GIMP_DRAWABLE (channel)); + gimp_drawable_invalidate_preview (GIMP_DRAWABLE (channel), TRUE); tmp = g_slist_next (tmp); } } diff --git a/app/core/gimpchannel-combine.c b/app/core/gimpchannel-combine.c index 7ce0d32a4d..ed062e1b69 100644 --- a/app/core/gimpchannel-combine.c +++ b/app/core/gimpchannel-combine.c @@ -580,7 +580,7 @@ channel_invalidate_previews (GimpImage* gimage) while (tmp) { channel = (Channel *) tmp->data; - drawable_invalidate_preview (GIMP_DRAWABLE (channel)); + gimp_drawable_invalidate_preview (GIMP_DRAWABLE (channel), TRUE); tmp = g_slist_next (tmp); } } diff --git a/app/core/gimpchannel.c b/app/core/gimpchannel.c index 7ce0d32a4d..ed062e1b69 100644 --- a/app/core/gimpchannel.c +++ b/app/core/gimpchannel.c @@ -580,7 +580,7 @@ channel_invalidate_previews (GimpImage* gimage) while (tmp) { channel = (Channel *) tmp->data; - drawable_invalidate_preview (GIMP_DRAWABLE (channel)); + gimp_drawable_invalidate_preview (GIMP_DRAWABLE (channel), TRUE); tmp = g_slist_next (tmp); } } diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c index f22c7e9d80..577b3d5358 100644 --- a/app/core/gimpdrawable.c +++ b/app/core/gimpdrawable.c @@ -215,15 +215,19 @@ gimp_drawable_mask_bounds (GimpDrawable *drawable, } void -gimp_drawable_invalidate_preview (GimpDrawable *drawable) +gimp_drawable_invalidate_preview (GimpDrawable *drawable, + gboolean emit_signal) { GimpImage *gimage; g_return_if_fail (GIMP_IS_DRAWABLE (drawable)); drawable->preview_valid = FALSE; - gtk_signal_emit (GTK_OBJECT (drawable), - gimp_drawable_signals[INVALIDATE_PREVIEW]); + + if (emit_signal) + gtk_signal_emit (GTK_OBJECT (drawable), + gimp_drawable_signals[INVALIDATE_PREVIEW]); + gimage = gimp_drawable_gimage (drawable); if (gimage) { diff --git a/app/core/gimpdrawable.h b/app/core/gimpdrawable.h index 21a88e8220..64687b4a1c 100644 --- a/app/core/gimpdrawable.h +++ b/app/core/gimpdrawable.h @@ -45,7 +45,8 @@ gboolean gimp_drawable_mask_bounds (GimpDrawable *, gint *, gint *, gint *, gint *); -void gimp_drawable_invalidate_preview (GimpDrawable *); +void gimp_drawable_invalidate_preview (GimpDrawable *drawable, + gboolean emit_signal); gint gimp_drawable_dirty (GimpDrawable *); gint gimp_drawable_clean (GimpDrawable *); gboolean gimp_drawable_has_alpha (GimpDrawable *); diff --git a/app/core/gimpimage-mask.c b/app/core/gimpimage-mask.c index f16077f733..de5d4603cb 100644 --- a/app/core/gimpimage-mask.c +++ b/app/core/gimpimage-mask.c @@ -285,7 +285,7 @@ gimage_mask_extract (GImage *gimage, tiles->width, tiles->height); /* Invalidate the preview */ - drawable_invalidate_preview (drawable); + gimp_drawable_invalidate_preview (drawable, TRUE); } } /* Otherwise, get the entire active layer */ diff --git a/app/core/gimpimage-undo-push.c b/app/core/gimpimage-undo-push.c index c0d1d6a3da..b9c3e7ae80 100644 --- a/app/core/gimpimage-undo-push.c +++ b/app/core/gimpimage-undo-push.c @@ -1995,7 +1995,7 @@ undo_pop_fs_to_layer (GImage *gimage, { case UNDO: /* Update the preview for the floating sel */ - drawable_invalidate_preview (GIMP_DRAWABLE (fsu->layer)); + gimp_drawable_invalidate_preview (GIMP_DRAWABLE (fsu->layer), TRUE); fsu->layer->fs.drawable = fsu->drawable; gimage->active_layer = fsu->layer; @@ -2013,7 +2013,7 @@ undo_pop_fs_to_layer (GImage *gimage, layer_invalidate_boundary (fsu->layer); /* Update the preview for the gimage and underlying drawable */ - drawable_invalidate_preview (GIMP_DRAWABLE (fsu->layer)); + gimp_drawable_invalidate_preview (GIMP_DRAWABLE (fsu->layer), TRUE); break; case REDO: @@ -2025,7 +2025,7 @@ undo_pop_fs_to_layer (GImage *gimage, GIMP_DRAWABLE (fsu->layer)->height); /* Update the preview for the gimage and underlying drawable */ - drawable_invalidate_preview (GIMP_DRAWABLE (fsu->layer)); + gimp_drawable_invalidate_preview (GIMP_DRAWABLE (fsu->layer), TRUE); /* clear the selection */ layer_invalidate_boundary (fsu->layer); @@ -2035,7 +2035,7 @@ undo_pop_fs_to_layer (GImage *gimage, gimage->floating_sel = NULL; /* Update the fs drawable */ - drawable_invalidate_preview (GIMP_DRAWABLE (fsu->layer)); + gimp_drawable_invalidate_preview (GIMP_DRAWABLE (fsu->layer), TRUE); break; } diff --git a/app/core/gimplayer-floating-sel.c b/app/core/gimplayer-floating-sel.c index 76ad8d06b6..3ec7085511 100644 --- a/app/core/gimplayer-floating-sel.c +++ b/app/core/gimplayer-floating-sel.c @@ -92,7 +92,7 @@ floating_sel_remove (Layer *layer) * because it will not be done until the floating selection is removed, * at which point the obscured drawable's preview will not be declared invalid */ - drawable_invalidate_preview (GIMP_DRAWABLE (layer)); + gimp_drawable_invalidate_preview (GIMP_DRAWABLE (layer), TRUE); /* remove the layer from the gimage */ gimage_remove_layer (gimage, layer); @@ -116,7 +116,7 @@ floating_sel_anchor (Layer *layer) /* Invalidate the previews of the layer that will be composited with the floating section. */ - drawable_invalidate_preview (layer->fs.drawable); + gimp_drawable_invalidate_preview (layer->fs.drawable, TRUE); /* Relax the floating selection */ floating_sel_relax (layer, TRUE); @@ -198,7 +198,7 @@ floating_sel_to_layer (Layer *layer) /* update the fs drawable--this updates the gimage composite preview * as well as the underlying drawable's */ - drawable_invalidate_preview (GIMP_DRAWABLE (layer)); + gimp_drawable_invalidate_preview (GIMP_DRAWABLE (layer), TRUE); /* allocate the undo structure */ fsu = g_new (FStoLayerUndo, 1); @@ -516,7 +516,7 @@ void floating_sel_invalidate (Layer *layer) { /* Invalidate the attached-to drawable's preview */ - drawable_invalidate_preview (layer->fs.drawable); + gimp_drawable_invalidate_preview (layer->fs.drawable, TRUE); /* Invalidate the boundary */ layer->fs.boundary_known = FALSE; diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c index 0159cec60d..ead663e7ab 100644 --- a/app/core/gimplayer.c +++ b/app/core/gimplayer.c @@ -694,7 +694,8 @@ layer_translate_lowlevel (Layer *layer, if (!temporary) { /* invalidate the mask preview */ - drawable_invalidate_preview (GIMP_DRAWABLE (layer->mask)); + gimp_drawable_invalidate_preview (GIMP_DRAWABLE (layer->mask), + FALSE); } } } @@ -1505,7 +1506,7 @@ layer_invalidate_previews (GimpImage *gimage) while (tmp) { layer = (Layer *) tmp->data; - drawable_invalidate_preview (GIMP_DRAWABLE(layer)); + gimp_drawable_invalidate_preview (GIMP_DRAWABLE(layer), TRUE); tmp = g_slist_next (tmp); } } diff --git a/app/drawable.c b/app/drawable.c index 83fc9e2781..dc9210bc16 100644 --- a/app/drawable.c +++ b/app/drawable.c @@ -98,7 +98,7 @@ drawable_update (GimpDrawable *drawable, gdisplays_update_area (gimage, x, y, w, h); /* invalidate the preview */ - gimp_drawable_invalidate_preview (drawable); + gimp_drawable_invalidate_preview (drawable, FALSE); } void diff --git a/app/floating_sel.c b/app/floating_sel.c index 76ad8d06b6..3ec7085511 100644 --- a/app/floating_sel.c +++ b/app/floating_sel.c @@ -92,7 +92,7 @@ floating_sel_remove (Layer *layer) * because it will not be done until the floating selection is removed, * at which point the obscured drawable's preview will not be declared invalid */ - drawable_invalidate_preview (GIMP_DRAWABLE (layer)); + gimp_drawable_invalidate_preview (GIMP_DRAWABLE (layer), TRUE); /* remove the layer from the gimage */ gimage_remove_layer (gimage, layer); @@ -116,7 +116,7 @@ floating_sel_anchor (Layer *layer) /* Invalidate the previews of the layer that will be composited with the floating section. */ - drawable_invalidate_preview (layer->fs.drawable); + gimp_drawable_invalidate_preview (layer->fs.drawable, TRUE); /* Relax the floating selection */ floating_sel_relax (layer, TRUE); @@ -198,7 +198,7 @@ floating_sel_to_layer (Layer *layer) /* update the fs drawable--this updates the gimage composite preview * as well as the underlying drawable's */ - drawable_invalidate_preview (GIMP_DRAWABLE (layer)); + gimp_drawable_invalidate_preview (GIMP_DRAWABLE (layer), TRUE); /* allocate the undo structure */ fsu = g_new (FStoLayerUndo, 1); @@ -516,7 +516,7 @@ void floating_sel_invalidate (Layer *layer) { /* Invalidate the attached-to drawable's preview */ - drawable_invalidate_preview (layer->fs.drawable); + gimp_drawable_invalidate_preview (layer->fs.drawable, TRUE); /* Invalidate the boundary */ layer->fs.boundary_known = FALSE; diff --git a/app/gimage_mask.c b/app/gimage_mask.c index f16077f733..de5d4603cb 100644 --- a/app/gimage_mask.c +++ b/app/gimage_mask.c @@ -285,7 +285,7 @@ gimage_mask_extract (GImage *gimage, tiles->width, tiles->height); /* Invalidate the preview */ - drawable_invalidate_preview (drawable); + gimp_drawable_invalidate_preview (drawable, TRUE); } } /* Otherwise, get the entire active layer */ diff --git a/app/gimpchannel.c b/app/gimpchannel.c index 7ce0d32a4d..ed062e1b69 100644 --- a/app/gimpchannel.c +++ b/app/gimpchannel.c @@ -580,7 +580,7 @@ channel_invalidate_previews (GimpImage* gimage) while (tmp) { channel = (Channel *) tmp->data; - drawable_invalidate_preview (GIMP_DRAWABLE (channel)); + gimp_drawable_invalidate_preview (GIMP_DRAWABLE (channel), TRUE); tmp = g_slist_next (tmp); } } diff --git a/app/gimpdrawable.c b/app/gimpdrawable.c index f22c7e9d80..577b3d5358 100644 --- a/app/gimpdrawable.c +++ b/app/gimpdrawable.c @@ -215,15 +215,19 @@ gimp_drawable_mask_bounds (GimpDrawable *drawable, } void -gimp_drawable_invalidate_preview (GimpDrawable *drawable) +gimp_drawable_invalidate_preview (GimpDrawable *drawable, + gboolean emit_signal) { GimpImage *gimage; g_return_if_fail (GIMP_IS_DRAWABLE (drawable)); drawable->preview_valid = FALSE; - gtk_signal_emit (GTK_OBJECT (drawable), - gimp_drawable_signals[INVALIDATE_PREVIEW]); + + if (emit_signal) + gtk_signal_emit (GTK_OBJECT (drawable), + gimp_drawable_signals[INVALIDATE_PREVIEW]); + gimage = gimp_drawable_gimage (drawable); if (gimage) { diff --git a/app/gimpdrawable.h b/app/gimpdrawable.h index 21a88e8220..64687b4a1c 100644 --- a/app/gimpdrawable.h +++ b/app/gimpdrawable.h @@ -45,7 +45,8 @@ gboolean gimp_drawable_mask_bounds (GimpDrawable *, gint *, gint *, gint *, gint *); -void gimp_drawable_invalidate_preview (GimpDrawable *); +void gimp_drawable_invalidate_preview (GimpDrawable *drawable, + gboolean emit_signal); gint gimp_drawable_dirty (GimpDrawable *); gint gimp_drawable_clean (GimpDrawable *); gboolean gimp_drawable_has_alpha (GimpDrawable *); diff --git a/app/gimplayer.c b/app/gimplayer.c index 0159cec60d..ead663e7ab 100644 --- a/app/gimplayer.c +++ b/app/gimplayer.c @@ -694,7 +694,8 @@ layer_translate_lowlevel (Layer *layer, if (!temporary) { /* invalidate the mask preview */ - drawable_invalidate_preview (GIMP_DRAWABLE (layer->mask)); + gimp_drawable_invalidate_preview (GIMP_DRAWABLE (layer->mask), + FALSE); } } } @@ -1505,7 +1506,7 @@ layer_invalidate_previews (GimpImage *gimage) while (tmp) { layer = (Layer *) tmp->data; - drawable_invalidate_preview (GIMP_DRAWABLE(layer)); + gimp_drawable_invalidate_preview (GIMP_DRAWABLE(layer), TRUE); tmp = g_slist_next (tmp); } } diff --git a/app/ink.c b/app/ink.c index 79f97235d7..e6416a963f 100644 --- a/app/ink.c +++ b/app/ink.c @@ -1115,7 +1115,7 @@ ink_finish (InkTool *ink_tool, GimpDrawable *drawable, int tool_id) /* invalidate the drawable--have to do it here, because * it is not done during the actual painting. */ - drawable_invalidate_preview (drawable); + gimp_drawable_invalidate_preview (drawable, TRUE); } static void diff --git a/app/layer.c b/app/layer.c index 0159cec60d..ead663e7ab 100644 --- a/app/layer.c +++ b/app/layer.c @@ -694,7 +694,8 @@ layer_translate_lowlevel (Layer *layer, if (!temporary) { /* invalidate the mask preview */ - drawable_invalidate_preview (GIMP_DRAWABLE (layer->mask)); + gimp_drawable_invalidate_preview (GIMP_DRAWABLE (layer->mask), + FALSE); } } } @@ -1505,7 +1506,7 @@ layer_invalidate_previews (GimpImage *gimage) while (tmp) { layer = (Layer *) tmp->data; - drawable_invalidate_preview (GIMP_DRAWABLE(layer)); + gimp_drawable_invalidate_preview (GIMP_DRAWABLE(layer), TRUE); tmp = g_slist_next (tmp); } } diff --git a/app/paint/gimpink.c b/app/paint/gimpink.c index 79f97235d7..e6416a963f 100644 --- a/app/paint/gimpink.c +++ b/app/paint/gimpink.c @@ -1115,7 +1115,7 @@ ink_finish (InkTool *ink_tool, GimpDrawable *drawable, int tool_id) /* invalidate the drawable--have to do it here, because * it is not done during the actual painting. */ - drawable_invalidate_preview (drawable); + gimp_drawable_invalidate_preview (drawable, TRUE); } static void diff --git a/app/paint_core.c b/app/paint_core.c index b4c80c9bb2..7ba2135f33 100644 --- a/app/paint_core.c +++ b/app/paint_core.c @@ -912,7 +912,7 @@ paint_core_finish (PaintCore *paint_core, /* invalidate the drawable--have to do it here, because * it is not done during the actual painting. */ - drawable_invalidate_preview (drawable); + gimp_drawable_invalidate_preview (drawable, TRUE); } void diff --git a/app/tools/gimpinktool.c b/app/tools/gimpinktool.c index 79f97235d7..e6416a963f 100644 --- a/app/tools/gimpinktool.c +++ b/app/tools/gimpinktool.c @@ -1115,7 +1115,7 @@ ink_finish (InkTool *ink_tool, GimpDrawable *drawable, int tool_id) /* invalidate the drawable--have to do it here, because * it is not done during the actual painting. */ - drawable_invalidate_preview (drawable); + gimp_drawable_invalidate_preview (drawable, TRUE); } static void diff --git a/app/tools/ink.c b/app/tools/ink.c index 79f97235d7..e6416a963f 100644 --- a/app/tools/ink.c +++ b/app/tools/ink.c @@ -1115,7 +1115,7 @@ ink_finish (InkTool *ink_tool, GimpDrawable *drawable, int tool_id) /* invalidate the drawable--have to do it here, because * it is not done during the actual painting. */ - drawable_invalidate_preview (drawable); + gimp_drawable_invalidate_preview (drawable, TRUE); } static void diff --git a/app/tools/paint_core.c b/app/tools/paint_core.c index b4c80c9bb2..7ba2135f33 100644 --- a/app/tools/paint_core.c +++ b/app/tools/paint_core.c @@ -912,7 +912,7 @@ paint_core_finish (PaintCore *paint_core, /* invalidate the drawable--have to do it here, because * it is not done during the actual painting. */ - drawable_invalidate_preview (drawable); + gimp_drawable_invalidate_preview (drawable, TRUE); } void diff --git a/app/tools/xinput_airbrush.c b/app/tools/xinput_airbrush.c index 0aecb30087..2a4198e2ad 100644 --- a/app/tools/xinput_airbrush.c +++ b/app/tools/xinput_airbrush.c @@ -1062,7 +1062,7 @@ static void /* invalidate the drawable--have to do it here, because * it is not done during the actual painting. */ - drawable_invalidate_preview (drawable); + gimp_drawable_invalidate_preview (drawable, TRUE); } static void diff --git a/app/undo.c b/app/undo.c index c0d1d6a3da..b9c3e7ae80 100644 --- a/app/undo.c +++ b/app/undo.c @@ -1995,7 +1995,7 @@ undo_pop_fs_to_layer (GImage *gimage, { case UNDO: /* Update the preview for the floating sel */ - drawable_invalidate_preview (GIMP_DRAWABLE (fsu->layer)); + gimp_drawable_invalidate_preview (GIMP_DRAWABLE (fsu->layer), TRUE); fsu->layer->fs.drawable = fsu->drawable; gimage->active_layer = fsu->layer; @@ -2013,7 +2013,7 @@ undo_pop_fs_to_layer (GImage *gimage, layer_invalidate_boundary (fsu->layer); /* Update the preview for the gimage and underlying drawable */ - drawable_invalidate_preview (GIMP_DRAWABLE (fsu->layer)); + gimp_drawable_invalidate_preview (GIMP_DRAWABLE (fsu->layer), TRUE); break; case REDO: @@ -2025,7 +2025,7 @@ undo_pop_fs_to_layer (GImage *gimage, GIMP_DRAWABLE (fsu->layer)->height); /* Update the preview for the gimage and underlying drawable */ - drawable_invalidate_preview (GIMP_DRAWABLE (fsu->layer)); + gimp_drawable_invalidate_preview (GIMP_DRAWABLE (fsu->layer), TRUE); /* clear the selection */ layer_invalidate_boundary (fsu->layer); @@ -2035,7 +2035,7 @@ undo_pop_fs_to_layer (GImage *gimage, gimage->floating_sel = NULL; /* Update the fs drawable */ - drawable_invalidate_preview (GIMP_DRAWABLE (fsu->layer)); + gimp_drawable_invalidate_preview (GIMP_DRAWABLE (fsu->layer), TRUE); break; } diff --git a/app/xinput_airbrush.c b/app/xinput_airbrush.c index 0aecb30087..2a4198e2ad 100644 --- a/app/xinput_airbrush.c +++ b/app/xinput_airbrush.c @@ -1062,7 +1062,7 @@ static void /* invalidate the drawable--have to do it here, because * it is not done during the actual painting. */ - drawable_invalidate_preview (drawable); + gimp_drawable_invalidate_preview (drawable, TRUE); } static void