[gimp] app: add boolean "mask_inverted" to GimpDisplayShell
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add boolean "mask_inverted" to GimpDisplayShell
- Date: Wed, 11 Jun 2014 19:37:19 +0000 (UTC)
commit 21a8f9c96b7ef37c1f30f5a9c78dea49a92d14e0
Author: Michael Natterer <mitch gimp org>
Date: Wed Jun 11 21:33:57 2014 +0200
app: add boolean "mask_inverted" to GimpDisplayShell
and to gimp_display_shell_set_mask(). It allows to choose whether the
mask is drawn inverted, instead of always drawing it inverted.
app/display/gimpdisplayshell-render.c | 25 +++++++++++++------------
app/display/gimpdisplayshell.c | 11 +++++++----
app/display/gimpdisplayshell.h | 4 +++-
app/tools/gimpforegroundselecttool.c | 6 +++---
4 files changed, 26 insertions(+), 20 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-render.c b/app/display/gimpdisplayshell-render.c
index 8956f28..cab202f 100644
--- a/app/display/gimpdisplayshell-render.c
+++ b/app/display/gimpdisplayshell-render.c
@@ -205,8 +205,6 @@ gimp_display_shell_render (GimpDisplayShell *shell,
if (shell->mask)
{
- gint mask_height;
-
if (! shell->mask_surface)
{
shell->mask_surface =
@@ -231,21 +229,24 @@ gimp_display_shell_render (GimpDisplayShell *shell,
data, stride,
GEGL_ABYSS_CLAMP);
- /* invert the mask so what is *not* the foreground object is masked */
- mask_height = scaled_height;
- while (mask_height--)
+ if (shell->mask_inverted)
{
- gint mask_width = scaled_width;
- guchar *d = data;
+ gint mask_height = scaled_height;
- while (mask_width--)
+ while (mask_height--)
{
- guchar inv = 255 - *d;
+ gint mask_width = scaled_width;
+ guchar *d = data;
- *d++ = inv;
- }
+ while (mask_width--)
+ {
+ guchar inv = 255 - *d;
- data += stride;
+ *d++ = inv;
+ }
+
+ data += stride;
+ }
}
}
diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c
index d66a87d..b174a5a 100644
--- a/app/display/gimpdisplayshell.c
+++ b/app/display/gimpdisplayshell.c
@@ -1918,15 +1918,16 @@ gimp_display_shell_set_highlight (GimpDisplayShell *shell,
* @shell: a #GimpDisplayShell
* @mask: a #GimpDrawable (1 byte per pixel)
* @color: the color to use for drawing the mask
+ * @inverted: #TRUE if the mask should be drawn inverted
*
- * Previews a selection (used by the foreground selection tool).
- * Pixels that are not selected (> 127) in the mask are tinted with
- * the given color.
+ * Previews an image-sized mask. Depending on @inverted, pixels that
+ * are selected or not selected are tinted with the given color.
**/
void
gimp_display_shell_set_mask (GimpDisplayShell *shell,
GeglBuffer *mask,
- const GimpRGB *color)
+ const GimpRGB *color,
+ gboolean inverted)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (mask == NULL || GEGL_IS_BUFFER (mask));
@@ -1943,5 +1944,7 @@ gimp_display_shell_set_mask (GimpDisplayShell *shell,
if (mask)
shell->mask_color = *color;
+ shell->mask_inverted = inverted;
+
gimp_display_shell_expose_full (shell);
}
diff --git a/app/display/gimpdisplayshell.h b/app/display/gimpdisplayshell.h
index d459b8a..b49e02c 100644
--- a/app/display/gimpdisplayshell.h
+++ b/app/display/gimpdisplayshell.h
@@ -191,6 +191,7 @@ struct _GimpDisplayShell
GeglBuffer *mask;
GimpRGB mask_color;
+ gboolean mask_inverted;
GimpMotionBuffer *motion_buffer;
@@ -281,7 +282,8 @@ void gimp_display_shell_set_highlight (GimpDisplayShell *shell,
const GdkRectangle *highlight);
void gimp_display_shell_set_mask (GimpDisplayShell *shell,
GeglBuffer *mask,
- const GimpRGB *color);
+ const GimpRGB *color,
+ gboolean inverted);
#endif /* __GIMP_DISPLAY_SHELL_H__ */
diff --git a/app/tools/gimpforegroundselecttool.c b/app/tools/gimpforegroundselecttool.c
index 7f5d8b1..372a715 100644
--- a/app/tools/gimpforegroundselecttool.c
+++ b/app/tools/gimpforegroundselecttool.c
@@ -944,7 +944,7 @@ gimp_foreground_select_tool_halt (GimpForegroundSelectTool *fg_select)
if (tool->display)
gimp_display_shell_set_mask (gimp_display_get_shell (tool->display),
- NULL, NULL);
+ NULL, NULL, FALSE);
gimp_tool_control_set_tool_cursor (tool->control,
GIMP_TOOL_CURSOR_FREE_SELECT);
@@ -1006,7 +1006,7 @@ gimp_foreground_select_tool_set_trimap (GimpForegroundSelectTool *fg_select)
gimp_foreground_select_options_get_mask_color (options, &color);
gimp_display_shell_set_mask (gimp_display_get_shell (tool->display),
- fg_select->trimap, &color);
+ fg_select->trimap, &color, TRUE);
gimp_tool_control_set_tool_cursor (tool->control,
GIMP_TOOL_CURSOR_PAINTBRUSH);
@@ -1034,7 +1034,7 @@ gimp_foreground_select_tool_set_preview (GimpForegroundSelectTool *fg_select)
gimp_foreground_select_options_get_mask_color (options, &color);
gimp_display_shell_set_mask (gimp_display_get_shell (tool->display),
- fg_select->mask, &color);
+ fg_select->mask, &color, TRUE);
gimp_tool_control_set_tool_cursor (tool->control,
GIMP_TOOL_CURSOR_PAINTBRUSH);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]