[gimp] app: add gimp_drawable_update_all()



commit 3e5cbb03d904ac59dbeb64d5a6d453c1a829ae90
Author: Ell <ell_se yahoo com>
Date:   Mon Jun 10 03:42:07 2019 -0400

    app: add gimp_drawable_update_all()
    
    Add a new GimpDrawable::update_all() virtual function, and a
    corresponding gimp_drawable_update_all() function, which updates
    the full contents of the drawable.  Unlike calling
    `gimp_drawable_update (drawable, 0, 0, -1, -1)`, which updates the
    entire drawable area, gimp_drawable_update_all() only updates the
    area that has actual content.  While the default implentation does
    simply update the entire drawable area, GimpGroupLayer overrides
    this function to recursively update its child layers, rather than
    the its entire area.

 app/core/gimpdrawable.c   | 17 +++++++++++++++++
 app/core/gimpdrawable.h   |  2 ++
 app/core/gimpgrouplayer.c | 25 +++++++++++++++++++++++++
 3 files changed, 44 insertions(+)
---
diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c
index 16110eeaa8..71168b9ab8 100644
--- a/app/core/gimpdrawable.c
+++ b/app/core/gimpdrawable.c
@@ -169,6 +169,8 @@ static gint64  gimp_drawable_real_estimate_memsize (GimpDrawable      *drawable,
                                                     gint               width,
                                                     gint               height);
 
+static void       gimp_drawable_real_update_all    (GimpDrawable      *drawable);
+
 static GimpComponentMask
                 gimp_drawable_real_get_active_mask (GimpDrawable      *drawable);
 
@@ -286,6 +288,7 @@ gimp_drawable_class_init (GimpDrawableClass *klass)
   klass->format_changed           = NULL;
   klass->alpha_changed            = NULL;
   klass->estimate_memsize         = gimp_drawable_real_estimate_memsize;
+  klass->update_all               = gimp_drawable_real_update_all;
   klass->invalidate_boundary      = NULL;
   klass->get_active_components    = NULL;
   klass->get_active_mask          = gimp_drawable_real_get_active_mask;
@@ -809,6 +812,12 @@ gimp_drawable_real_estimate_memsize (GimpDrawable      *drawable,
   return (gint64) babl_format_get_bytes_per_pixel (format) * width * height;
 }
 
+static void
+gimp_drawable_real_update_all (GimpDrawable *drawable)
+{
+  gimp_drawable_update (drawable, 0, 0, -1, -1);
+}
+
 static GimpComponentMask
 gimp_drawable_real_get_active_mask (GimpDrawable *drawable)
 {
@@ -1121,6 +1130,14 @@ gimp_drawable_update (GimpDrawable *drawable,
     }
 }
 
+void
+gimp_drawable_update_all (GimpDrawable *drawable)
+{
+  g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
+
+  GIMP_DRAWABLE_GET_CLASS (drawable)->update_all (drawable);
+}
+
 void
 gimp_drawable_invalidate_boundary (GimpDrawable *drawable)
 {
diff --git a/app/core/gimpdrawable.h b/app/core/gimpdrawable.h
index 93fa100a26..fe4c286e23 100644
--- a/app/core/gimpdrawable.h
+++ b/app/core/gimpdrawable.h
@@ -58,6 +58,7 @@ struct _GimpDrawableClass
                                            GimpComponentType     component_type,
                                            gint                  width,
                                            gint                  height);
+  void          (* update_all)            (GimpDrawable         *drawable);
   void          (* invalidate_boundary)   (GimpDrawable         *drawable);
   void          (* get_active_components) (GimpDrawable         *drawable,
                                            gboolean             *active);
@@ -127,6 +128,7 @@ void            gimp_drawable_update             (GimpDrawable       *drawable,
                                                   gint                y,
                                                   gint                width,
                                                   gint                height);
+void            gimp_drawable_update_all         (GimpDrawable       *drawable);
 
 void           gimp_drawable_invalidate_boundary (GimpDrawable       *drawable);
 void         gimp_drawable_get_active_components (GimpDrawable       *drawable,
diff --git a/app/core/gimpgrouplayer.c b/app/core/gimpgrouplayer.c
index 438535c480..347496c350 100644
--- a/app/core/gimpgrouplayer.c
+++ b/app/core/gimpgrouplayer.c
@@ -124,6 +124,7 @@ static gint64      gimp_group_layer_estimate_memsize (GimpDrawable      *drawabl
                                                       GimpComponentType  component_type,
                                                       gint               width,
                                                       gint               height);
+static void            gimp_group_layer_update_all   (GimpDrawable      *drawable);
 
 static void            gimp_group_layer_translate    (GimpLayer       *layer,
                                                       gint             offset_x,
@@ -286,6 +287,7 @@ gimp_group_layer_class_init (GimpGroupLayerClass *klass)
   item_class->transform_desc             = C_("undo-type", "Transform Layer Group");
 
   drawable_class->estimate_memsize       = gimp_group_layer_estimate_memsize;
+  drawable_class->update_all             = gimp_group_layer_update_all;
   drawable_class->get_source_node        = gimp_group_layer_get_source_node;
 
   layer_class->opacity_changed           = gimp_group_layer_opacity_changed;
@@ -746,6 +748,29 @@ gimp_group_layer_estimate_memsize (GimpDrawable      *drawable,
                                                                width, height);
 }
 
+static void
+gimp_group_layer_update_all (GimpDrawable *drawable)
+{
+  GimpGroupLayerPrivate *private = GET_PRIVATE (drawable);
+  GList                 *list;
+
+  /*  redirect stack updates to the drawable, rather than to the projection  */
+  private->direct_update++;
+
+  for (list = gimp_item_stack_get_item_iter (GIMP_ITEM_STACK (private->children));
+       list;
+       list = g_list_next (list))
+    {
+      GimpFilter *child = list->data;
+
+      if (gimp_filter_get_active (child))
+        gimp_drawable_update_all (GIMP_DRAWABLE (child));
+    }
+
+  /*  redirect stack updates back to the projection  */
+  private->direct_update--;
+}
+
 static void
 gimp_group_layer_translate (GimpLayer *layer,
                             gint       offset_x,


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