[gimp] app: in gimp_drawable_edit_fill(), make trivial alpha-only fill a NOP
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: in gimp_drawable_edit_fill(), make trivial alpha-only fill a NOP
- Date: Mon, 31 Dec 2018 09:41:03 +0000 (UTC)
commit 6384ff01b62f1371759bb40bf68ed648f6f34bdc
Author: Ell <ell_se yahoo com>
Date: Mon Dec 31 04:26:25 2018 -0500
app: in gimp_drawable_edit_fill(), make trivial alpha-only fill a NOP
In gimp_drawable_edit_fill(), if the fill only affects the alpha
channel, and if the drawable has no alpha channel, or the alpha
channel is masked out, do nothing, instead of unnecessarily
performing the fill, which has no effect.
app/core/gimpdrawable-edit.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/app/core/gimpdrawable-edit.c b/app/core/gimpdrawable-edit.c
index 8b7494d0f4..3456d0bf8a 100644
--- a/app/core/gimpdrawable-edit.c
+++ b/app/core/gimpdrawable-edit.c
@@ -157,7 +157,8 @@ gimp_drawable_edit_fill (GimpDrawable *drawable,
GimpFillOptions *options,
const gchar *undo_desc)
{
- gint x, y, width, height;
+ GimpContext *context = GIMP_CONTEXT (options);
+ gint x, y, width, height;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
@@ -169,6 +170,16 @@ gimp_drawable_edit_fill (GimpDrawable *drawable,
return; /* nothing to do, but the fill succeeded */
}
+ if (gimp_layer_mode_is_alpha_only (gimp_context_get_paint_mode (context)))
+ {
+ if (! gimp_drawable_has_alpha (drawable) ||
+ ! (gimp_drawable_get_active_mask (drawable) &
+ GIMP_COMPONENT_MASK_ALPHA))
+ {
+ return; /* nothing to do, but the fill succeeded */
+ }
+ }
+
if (! undo_desc)
undo_desc = gimp_fill_options_get_undo_desc (options);
@@ -180,12 +191,10 @@ gimp_drawable_edit_fill (GimpDrawable *drawable,
else
{
GeglBuffer *buffer;
- GimpContext *context;
gdouble opacity;
GimpLayerMode mode;
GimpLayerMode composite_mode;
- context = GIMP_CONTEXT (options);
opacity = gimp_context_get_opacity (context);
mode = gimp_context_get_paint_mode (context);
composite_mode = gimp_layer_mode_get_paint_composite_mode (mode);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]