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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3588>
This commit is contained in:
parent
72c2d8913e
commit
b00fcbf948
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 (
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user