[gimp/gimp-2-10] app: add gimp_paint_core_{set_show_all, get_image_pickable}()



commit 86ecd4d04f1f6c11fec65ff6557c3835638cf368
Author: Ell <ell_se yahoo com>
Date:   Fri Sep 6 19:56:58 2019 +0300

    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.
    
    (cherry picked from commit 2523808e4a821250cdd2e35a0e7aee3f0505e1c8)

 app/paint/gimppaintcore.c       | 36 ++++++++++++++++++++++++++-
 app/paint/gimppaintcore.h       | 54 ++++++++++++++++++++++++-----------------
 app/tools/gimppainttool-paint.c |  3 +++
 3 files changed, 70 insertions(+), 23 deletions(-)
---
diff --git a/app/paint/gimppaintcore.c b/app/paint/gimppaintcore.c
index c497f6c785..94f684bf43 100644
--- a/app/paint/gimppaintcore.c
+++ b/app/paint/gimppaintcore.c
@@ -393,12 +393,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);
     }
@@ -536,6 +542,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);
 
@@ -619,6 +627,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)
@@ -743,6 +768,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)
 {
diff --git a/app/paint/gimppaintcore.h b/app/paint/gimppaintcore.h
index 7f3eee1893..6e7f4d4c4b 100644
--- a/app/paint/gimppaintcore.h
+++ b/app/paint/gimppaintcore.h
@@ -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);
 
diff --git a/app/tools/gimppainttool-paint.c b/app/tools/gimppainttool-paint.c
index ffb0f7518e..cecaacd0a0 100644
--- a/app/tools/gimppainttool-paint.c
+++ b/app/tools/gimppainttool-paint.c
@@ -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,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]