From b00fcbf948359d7ac246240d36d82a9f341ab988 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Thu, 15 Feb 2024 09:53:27 +0100 Subject: [PATCH] clutter: Remove unused Color APIs Nothing uses them in GNOME Shell, so let us simplify the API a little bit Helps https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3544 Part-of: --- clutter/clutter/clutter-color.c | 115 ------------------ clutter/clutter/clutter-color.h | 19 --- src/tests/clutter/conform/color.c | 38 ------ .../clutter/interactive/test-text-field.c | 2 - 4 files changed, 174 deletions(-) diff --git a/clutter/clutter/clutter-color.c b/clutter/clutter/clutter-color.c index 9259226ef..0e35127cd 100644 --- a/clutter/clutter/clutter-color.c +++ b/clutter/clutter/clutter-color.c @@ -33,93 +33,6 @@ #include "clutter/clutter-private.h" #include "clutter/clutter-debug.h" -/** - * clutter_color_add: - * @a: a #ClutterColor - * @b: a #ClutterColor - * @result: (out caller-allocates): return location for the result - * - * Adds @a to @b and saves the resulting color inside @result. - * - * The alpha channel of @result is set as as the maximum value - * between the alpha channels of @a and @b. - */ -void -clutter_color_add (const ClutterColor *a, - const ClutterColor *b, - ClutterColor *result) -{ - g_return_if_fail (a != NULL); - g_return_if_fail (b != NULL); - g_return_if_fail (result != NULL); - - result->red = CLAMP (a->red + b->red, 0, 255); - result->green = CLAMP (a->green + b->green, 0, 255); - result->blue = CLAMP (a->blue + b->blue, 0, 255); - - result->alpha = MAX (a->alpha, b->alpha); -} - -/** - * clutter_color_subtract: - * @a: a #ClutterColor - * @b: a #ClutterColor - * @result: (out caller-allocates): return location for the result - * - * Subtracts @b from @a and saves the resulting color inside @result. - * - * This function assumes that the components of @a are greater than the - * components of @b; the result is, otherwise, undefined. - * - * The alpha channel of @result is set as the minimum value - * between the alpha channels of @a and @b. - */ -void -clutter_color_subtract (const ClutterColor *a, - const ClutterColor *b, - ClutterColor *result) -{ - g_return_if_fail (a != NULL); - g_return_if_fail (b != NULL); - g_return_if_fail (result != NULL); - - result->red = CLAMP (a->red - b->red, 0, 255); - result->green = CLAMP (a->green - b->green, 0, 255); - result->blue = CLAMP (a->blue - b->blue, 0, 255); - - result->alpha = MIN (a->alpha, b->alpha); -} - -/** - * clutter_color_lighten: - * @color: a #ClutterColor - * @result: (out caller-allocates): return location for the lighter color - * - * Lightens @color by a fixed amount, and saves the changed color - * in @result. - */ -void -clutter_color_lighten (const ClutterColor *color, - ClutterColor *result) -{ - clutter_color_shade (color, 1.3, result); -} - -/** - * clutter_color_darken: - * @color: a #ClutterColor - * @result: (out caller-allocates): return location for the darker color - * - * Darkens @color by a fixed amount, and saves the changed color - * in @result. - */ -void -clutter_color_darken (const ClutterColor *color, - ClutterColor *result) -{ - clutter_color_shade (color, 0.7, result); -} - /** * clutter_color_to_hls: * @color: a #ClutterColor @@ -273,34 +186,6 @@ clutter_color_from_hls (ClutterColor *color, color->blue = floorf (clr[2] * 255.0 + 0.5); } -/** - * clutter_color_shade: - * @color: a #ClutterColor - * @factor: the shade factor to apply - * @result: (out caller-allocates): return location for the shaded color - * - * Shades @color by @factor and saves the modified color into @result. - */ -void -clutter_color_shade (const ClutterColor *color, - gdouble factor, - ClutterColor *result) -{ - float h, l, s; - - g_return_if_fail (color != NULL); - g_return_if_fail (result != NULL); - - clutter_color_to_hls (color, &h, &l, &s); - - l = CLAMP (l * factor, 0.0, 1.0); - s = CLAMP (s * factor, 0.0, 1.0); - - clutter_color_from_hls (result, h, l, s); - - result->alpha = color->alpha; -} - /** * clutter_color_to_pixel: * @color: a #ClutterColor diff --git a/clutter/clutter/clutter-color.h b/clutter/clutter/clutter-color.h index 6570254be..3414354c4 100644 --- a/clutter/clutter/clutter-color.h +++ b/clutter/clutter/clutter-color.h @@ -97,25 +97,6 @@ ClutterColor *clutter_color_copy (const ClutterColor *color); CLUTTER_EXPORT void clutter_color_free (ClutterColor *color); -CLUTTER_EXPORT -void clutter_color_add (const ClutterColor *a, - const ClutterColor *b, - ClutterColor *result); -CLUTTER_EXPORT -void clutter_color_subtract (const ClutterColor *a, - const ClutterColor *b, - ClutterColor *result); -CLUTTER_EXPORT -void clutter_color_lighten (const ClutterColor *color, - ClutterColor *result); -CLUTTER_EXPORT -void clutter_color_darken (const ClutterColor *color, - ClutterColor *result); -CLUTTER_EXPORT -void clutter_color_shade (const ClutterColor *color, - gdouble factor, - ClutterColor *result); - CLUTTER_EXPORT gchar * clutter_color_to_string (const ClutterColor *color); CLUTTER_EXPORT diff --git a/src/tests/clutter/conform/color.c b/src/tests/clutter/conform/color.c index b66d5f63a..8e3d79681 100644 --- a/src/tests/clutter/conform/color.c +++ b/src/tests/clutter/conform/color.c @@ -260,7 +260,6 @@ static void color_operators (void) { ClutterColor op1, op2; - ClutterColor res; clutter_color_from_pixel (&op1, 0xff0000ff); g_assert_cmpuint (op1.red, ==, 0xff); @@ -273,43 +272,6 @@ color_operators (void) g_assert_cmpuint (op2.green, ==, 0xff); g_assert_cmpuint (op2.blue, ==, 0); g_assert_cmpuint (op2.alpha, ==, 0xff); - - if (!g_test_quiet ()) - g_print ("Adding %x, %x; expected result: %x\n", - clutter_color_to_pixel (&op1), - clutter_color_to_pixel (&op2), - 0xffff00ff); - - clutter_color_add (&op1, &op2, &res); - g_assert_cmpuint (clutter_color_to_pixel (&res), ==, 0xffff00ff); - - if (!g_test_quiet ()) - g_print ("Checking alpha channel on color add\n"); - - op1.alpha = 0xdd; - op2.alpha = 0xcc; - clutter_color_add (&op1, &op2, &res); - g_assert_cmpuint (clutter_color_to_pixel (&res), ==, 0xffff00dd); - - clutter_color_from_pixel (&op1, 0xffffffff); - clutter_color_from_pixel (&op2, 0xff00ffff); - - if (!g_test_quiet ()) - g_print ("Subtracting %x, %x; expected result: %x\n", - clutter_color_to_pixel (&op1), - clutter_color_to_pixel (&op2), - 0x00ff00ff); - - clutter_color_subtract (&op1, &op2, &res); - g_assert_cmpuint (clutter_color_to_pixel (&res), ==, 0x00ff00ff); - - if (!g_test_quiet ()) - g_print ("Checking alpha channel on color subtract\n"); - - op1.alpha = 0xdd; - op2.alpha = 0xcc; - clutter_color_subtract (&op1, &op2, &res); - g_assert_cmpuint (clutter_color_to_pixel (&res), ==, 0x00ff00cc); } CLUTTER_TEST_SUITE ( diff --git a/src/tests/clutter/interactive/test-text-field.c b/src/tests/clutter/interactive/test-text-field.c index 5768b07a3..746d46732 100644 --- a/src/tests/clutter/interactive/test-text-field.c +++ b/src/tests/clutter/interactive/test-text-field.c @@ -226,8 +226,6 @@ create_entry (const ClutterColor *color, clutter_actor_set_reactive (retval, TRUE); - clutter_color_darken (color, &selection); - clutter_text_set_editable (CLUTTER_TEXT (retval), TRUE); clutter_text_set_selectable (CLUTTER_TEXT (retval), TRUE); clutter_text_set_activatable (CLUTTER_TEXT (retval), TRUE);