From 4f69cd039c86fb237a9c0d2a9eeb967d542016b7 Mon Sep 17 00:00:00 2001 From: Jehan Date: Thu, 2 Apr 2026 11:40:58 +0200 Subject: [PATCH] app: get rid of some unused internal API. I noticed this yesterday, especially through gimp_image_get_active_array() and gimp_image_get_visible_array() which are looping through MAX_CHANNELS, hence assuming the passed components arrays are of sufficient size. I could have just added some comment to document that we must be careful when calling this, but this is currently completely unused code. So I prefer to just clean it out. If we need something like this in the future, we can just do it better. --- app/core/gimpchannel.c | 12 ------------ app/core/gimpdrawable.c | 16 ---------------- app/core/gimpdrawable.h | 4 ---- app/core/gimpimage.c | 32 -------------------------------- app/core/gimpimage.h | 4 ---- app/core/gimplayer.c | 19 ------------------- 6 files changed, 87 deletions(-) diff --git a/app/core/gimpchannel.c b/app/core/gimpchannel.c index 92599530ee..62f4f5b98d 100644 --- a/app/core/gimpchannel.c +++ b/app/core/gimpchannel.c @@ -142,8 +142,6 @@ static void gimp_channel_convert_type (GimpDrawable *drawable, gboolean push_undo, GimpProgress *progress); static void gimp_channel_invalidate_boundary (GimpDrawable *drawable); -static void gimp_channel_get_active_components (GimpDrawable *drawable, - gboolean *active); static void gimp_channel_set_buffer (GimpDrawable *drawable, gboolean push_undo, @@ -274,7 +272,6 @@ gimp_channel_class_init (GimpChannelClass *klass) drawable_class->convert_type = gimp_channel_convert_type; drawable_class->invalidate_boundary = gimp_channel_invalidate_boundary; - drawable_class->get_active_components = gimp_channel_get_active_components; drawable_class->set_buffer = gimp_channel_set_buffer; klass->boundary = gimp_channel_real_boundary; @@ -943,15 +940,6 @@ gimp_channel_invalidate_boundary (GimpDrawable *drawable) channel->bounds_known = FALSE; } -static void -gimp_channel_get_active_components (GimpDrawable *drawable, - gboolean *active) -{ - /* Make sure that the alpha channel is not valid. */ - active[GRAY] = TRUE; - active[ALPHA_G] = FALSE; -} - static void gimp_channel_set_buffer (GimpDrawable *drawable, gboolean push_undo, diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c index 28c5033e5d..0d1008c10c 100644 --- a/app/core/gimpdrawable.c +++ b/app/core/gimpdrawable.c @@ -323,7 +323,6 @@ gimp_drawable_class_init (GimpDrawableClass *klass) 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; klass->supports_alpha = gimp_drawable_real_supports_alpha; klass->convert_type = gimp_drawable_real_convert_type; @@ -1364,21 +1363,6 @@ gimp_drawable_invalidate_boundary (GimpDrawable *drawable) drawable_class->invalidate_boundary (drawable); } -void -gimp_drawable_get_active_components (GimpDrawable *drawable, - gboolean *active) -{ - GimpDrawableClass *drawable_class; - - g_return_if_fail (GIMP_IS_DRAWABLE (drawable)); - g_return_if_fail (active != NULL); - - drawable_class = GIMP_DRAWABLE_GET_CLASS (drawable); - - if (drawable_class->get_active_components) - drawable_class->get_active_components (drawable, active); -} - GimpComponentMask gimp_drawable_get_active_mask (GimpDrawable *drawable) { diff --git a/app/core/gimpdrawable.h b/app/core/gimpdrawable.h index 25f621a98a..4c5040430d 100644 --- a/app/core/gimpdrawable.h +++ b/app/core/gimpdrawable.h @@ -60,8 +60,6 @@ struct _GimpDrawableClass gint height); void (* update_all) (GimpDrawable *drawable); void (* invalidate_boundary) (GimpDrawable *drawable); - void (* get_active_components) (GimpDrawable *drawable, - gboolean *active); GimpComponentMask (* get_active_mask) (GimpDrawable *drawable); gboolean (* supports_alpha) (GimpDrawable *drawable); void (* convert_type) (GimpDrawable *drawable, @@ -135,8 +133,6 @@ void gimp_drawable_update_all (GimpDrawable *drawa void gimp_drawable_filters_changed (GimpDrawable *drawable); void gimp_drawable_invalidate_boundary (GimpDrawable *drawable); -void gimp_drawable_get_active_components (GimpDrawable *drawable, - gboolean *active); GimpComponentMask gimp_drawable_get_active_mask (GimpDrawable *drawable); gboolean gimp_drawable_supports_alpha (GimpDrawable *drawable); diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c index cdf8a59fcb..5db7d16107 100644 --- a/app/core/gimpimage.c +++ b/app/core/gimpimage.c @@ -3694,22 +3694,6 @@ gimp_image_get_component_active (GimpImage *image, return FALSE; } -void -gimp_image_get_active_array (GimpImage *image, - gboolean *components) -{ - GimpImagePrivate *private; - gint i; - - g_return_if_fail (GIMP_IS_IMAGE (image)); - g_return_if_fail (components != NULL); - - private = GIMP_IMAGE_GET_PRIVATE (image); - - for (i = 0; i < MAX_CHANNELS; i++) - components[i] = private->active[i]; -} - GimpComponentMask gimp_image_get_active_mask (GimpImage *image) { @@ -3794,22 +3778,6 @@ gimp_image_get_component_visible (GimpImage *image, return FALSE; } -void -gimp_image_get_visible_array (GimpImage *image, - gboolean *components) -{ - GimpImagePrivate *private; - gint i; - - g_return_if_fail (GIMP_IS_IMAGE (image)); - g_return_if_fail (components != NULL); - - private = GIMP_IMAGE_GET_PRIVATE (image); - - for (i = 0; i < MAX_CHANNELS; i++) - components[i] = private->visible[i]; -} - GimpComponentMask gimp_image_get_visible_mask (GimpImage *image) { diff --git a/app/core/gimpimage.h b/app/core/gimpimage.h index c3bc0c1004..ead1b8fecd 100644 --- a/app/core/gimpimage.h +++ b/app/core/gimpimage.h @@ -237,8 +237,6 @@ void gimp_image_set_component_active (GimpImage *image, gboolean active); gboolean gimp_image_get_component_active (GimpImage *image, GimpChannelType type); -void gimp_image_get_active_array (GimpImage *image, - gboolean *components); GimpComponentMask gimp_image_get_active_mask (GimpImage *image); void gimp_image_set_component_visible (GimpImage *image, @@ -246,8 +244,6 @@ void gimp_image_set_component_visible (GimpImage *image, gboolean visible); gboolean gimp_image_get_component_visible (GimpImage *image, GimpChannelType type); -void gimp_image_get_visible_array (GimpImage *image, - gboolean *components); GimpComponentMask gimp_image_get_visible_mask (GimpImage *image); diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c index 0a296db643..9950445dbb 100644 --- a/app/core/gimplayer.c +++ b/app/core/gimplayer.c @@ -194,8 +194,6 @@ static void gimp_layer_convert_type (GimpDrawable *drawable, gboolean push_undo, GimpProgress *progress); static void gimp_layer_invalidate_boundary (GimpDrawable *drawable); -static void gimp_layer_get_active_components (GimpDrawable *drawable, - gboolean *active); static GimpComponentMask gimp_layer_get_active_mask (GimpDrawable *drawable); static void gimp_layer_set_buffer (GimpDrawable *drawable, @@ -448,7 +446,6 @@ gimp_layer_class_init (GimpLayerClass *klass) drawable_class->supports_alpha = gimp_layer_supports_alpha; drawable_class->convert_type = gimp_layer_convert_type; drawable_class->invalidate_boundary = gimp_layer_invalidate_boundary; - drawable_class->get_active_components = gimp_layer_get_active_components; drawable_class->get_active_mask = gimp_layer_get_active_mask; drawable_class->set_buffer = gimp_layer_set_buffer; drawable_class->get_bounding_box = gimp_layer_get_bounding_box; @@ -1511,22 +1508,6 @@ gimp_layer_invalidate_boundary (GimpDrawable *drawable) floating_sel_invalidate (layer); } -static void -gimp_layer_get_active_components (GimpDrawable *drawable, - gboolean *active) -{ - GimpLayer *layer = GIMP_LAYER (drawable); - GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable)); - const Babl *format = gimp_drawable_get_format (drawable); - - /* first copy the image active channels */ - gimp_image_get_active_array (image, active); - - if (gimp_drawable_has_alpha (drawable) && - gimp_layer_is_alpha_locked (layer, NULL)) - active[babl_format_get_n_components (format) - 1] = FALSE; -} - static GimpComponentMask gimp_layer_get_active_mask (GimpDrawable *drawable) {