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

@ -34,41 +34,45 @@ typedef struct _GimpPaintCoreClass GimpPaintCoreClass;
struct _GimpPaintCore
{
GimpObject parent_instance;
GimpObject parent_instance;
gint ID; /* unique instance ID */
gint ID; /* unique instance ID */
gchar *undo_desc; /* undo description */
gchar *undo_desc; /* undo description */
GimpCoords start_coords; /* the last stroke's endpoint for undo */
gboolean show_all; /* whether working in show-all mode */
GimpCoords cur_coords; /* current coords */
GimpCoords last_coords; /* last coords */
GimpCoords start_coords; /* the last stroke's endpoint for undo */
GimpVector2 last_paint; /* last point that was painted */
GimpCoords cur_coords; /* current coords */
GimpCoords last_coords; /* last coords */
gdouble distance; /* distance traveled by brush */
gdouble pixel_dist; /* distance in pixels */
GimpVector2 last_paint; /* last point that was painted */
gint x1, y1; /* undo extents in image coords */
gint x2, y2; /* undo extents in image coords */
gdouble distance; /* distance traveled by brush */
gdouble pixel_dist; /* distance in pixels */
gboolean use_saved_proj; /* keep the unmodified proj around */
gint x1, y1; /* undo extents in image coords */
gint x2, y2; /* undo extents in image coords */
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 */
GeglBuffer *paint_buffer; /* the buffer to paint pixels to */
gint paint_buffer_x;
gint paint_buffer_y;
gboolean use_saved_proj; /* keep the unmodified proj around */
GeglBuffer *mask_buffer; /* the target drawable's mask */
gint mask_x_offset;
gint mask_y_offset;
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 */
GeglBuffer *paint_buffer; /* the buffer to paint pixels to */
gint paint_buffer_x;
gint paint_buffer_y;
GeglBuffer *mask_buffer; /* the target drawable's mask */
gint mask_x_offset;
gint mask_y_offset;
GimpApplicator *applicator;
GArray *stroke_buffer;
GArray *stroke_buffer;
};
struct _GimpPaintCoreClass
@ -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,