[gimp/gimp-2-10] app: add gimp_drawable_update_all()
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] app: add gimp_drawable_update_all()
- Date: Mon, 10 Jun 2019 07:56:00 +0000 (UTC)
commit 854374b2ced5ab4b1db8e130a5513c5a30657172
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.
(cherry picked from commit 3e5cbb03d904ac59dbeb64d5a6d453c1a829ae90)
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 3b78b147aa..7c9544bb03 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);
@@ -285,6 +287,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;
@@ -801,6 +804,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)
{
@@ -1111,6 +1120,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 41b9c6dbd1..4227df098d 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);
@@ -126,6 +127,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 ada2232068..20b0db9163 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,
@@ -285,6 +286,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;
@@ -745,6 +747,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]