app: add gimp_paint_core_{set_show_all,get_image_pickable}()

GimpPaintCore operates indipendently of a display, and hence needs
to be explictly told when operating in "show all" mode, affecting
the result of paint tools operating in "sample merged" mode.  Add
gimp_paint_core_set_show_all() for that purpose, and call it,
passing the current display's "show all" mode, in GimpPaintTool.
This controls which pickable (the image itself, or its projection)
is used as the sampling source, as per
GimpPaintCore::saved_proj_buffer, and as returned by the new
gimp_paint_core_get_image_pickable() function.
This commit is contained in:
Ell 2019-09-06 19:56:58 +03:00
parent 6f4122b7b9
commit 2523808e4a
3 changed files with 70 additions and 23 deletions

View File

@ -394,12 +394,18 @@ gimp_paint_core_start (GimpPaintCore *core,
core->undo_buffer = gimp_gegl_buffer_dup (gimp_drawable_get_buffer (drawable));
/* Set the image pickable */
if (! core->show_all)
core->image_pickable = GIMP_PICKABLE (image);
else
core->image_pickable = GIMP_PICKABLE (gimp_image_get_projection (image));
/* Allocate the saved proj structure */
g_clear_object (&core->saved_proj_buffer);
if (core->use_saved_proj)
{
GeglBuffer *buffer = gimp_pickable_get_buffer (GIMP_PICKABLE (image));
GeglBuffer *buffer = gimp_pickable_get_buffer (core->image_pickable);
core->saved_proj_buffer = gimp_gegl_buffer_dup (buffer);
}
@ -537,6 +543,8 @@ gimp_paint_core_finish (GimpPaintCore *core,
gimp_image_undo_group_end (image);
}
core->image_pickable = NULL;
g_clear_object (&core->undo_buffer);
g_clear_object (&core->saved_proj_buffer);
@ -620,6 +628,23 @@ gimp_paint_core_interpolate (GimpPaintCore *core,
paint_options, time);
}
void
gimp_paint_core_set_show_all (GimpPaintCore *core,
gboolean show_all)
{
g_return_if_fail (GIMP_IS_PAINT_CORE (core));
core->show_all = show_all;
}
gboolean
gimp_paint_core_get_show_all (GimpPaintCore *core)
{
g_return_val_if_fail (GIMP_IS_PAINT_CORE (core), FALSE);
return core->show_all;
}
void
gimp_paint_core_set_current_coords (GimpPaintCore *core,
const GimpCoords *coords)
@ -744,6 +769,15 @@ gimp_paint_core_get_paint_buffer (GimpPaintCore *core,
return paint_buffer;
}
GimpPickable *
gimp_paint_core_get_image_pickable (GimpPaintCore *core)
{
g_return_val_if_fail (GIMP_IS_PAINT_CORE (core), NULL);
g_return_val_if_fail (core->image_pickable != NULL, NULL);
return core->image_pickable;
}
GeglBuffer *
gimp_paint_core_get_orig_image (GimpPaintCore *core)
{

View File

@ -40,6 +40,8 @@ struct _GimpPaintCore
gchar *undo_desc; /* undo description */
gboolean show_all; /* whether working in show-all mode */
GimpCoords start_coords; /* the last stroke's endpoint for undo */
GimpCoords cur_coords; /* current coords */
@ -55,6 +57,8 @@ struct _GimpPaintCore
gboolean use_saved_proj; /* keep the unmodified proj around */
GimpPickable *image_pickable; /* the image pickable */
GeglBuffer *undo_buffer; /* pixels which have been modified */
GeglBuffer *saved_proj_buffer; /* proj tiles which have been modified */
GeglBuffer *canvas_buffer; /* the buffer to paint the mask to */
@ -146,6 +150,10 @@ void gimp_paint_core_interpolate (GimpPaintCore *core,
const GimpCoords *coords,
guint32 time);
void gimp_paint_core_set_show_all (GimpPaintCore *core,
gboolean show_all);
gboolean gimp_paint_core_get_show_all (GimpPaintCore *core);
void gimp_paint_core_set_current_coords (GimpPaintCore *core,
const GimpCoords *coords);
void gimp_paint_core_get_current_coords (GimpPaintCore *core,
@ -176,6 +184,8 @@ GeglBuffer * gimp_paint_core_get_paint_buffer (GimpPaintCore *core,
gint *paint_width,
gint *paint_height);
GimpPickable * gimp_paint_core_get_image_pickable (GimpPaintCore *core);
GeglBuffer * gimp_paint_core_get_orig_image (GimpPaintCore *core);
GeglBuffer * gimp_paint_core_get_orig_proj (GimpPaintCore *core);

View File

@ -32,6 +32,7 @@
#include "paint/gimppaintoptions.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
#include "display/gimpdisplayshell-utils.h"
#include "gimppainttool.h"
@ -261,6 +262,8 @@ gimp_paint_tool_paint_start (GimpPaintTool *paint_tool,
if (gimp_paint_tool_paint_use_thread (paint_tool))
gimp_drawable_start_paint (drawable);
gimp_paint_core_set_show_all (core, shell->show_all);
/* Start the paint core */
if (! gimp_paint_core_start (core,
drawable, paint_options, &curr_coords,