Add some inline rgba functions

These are trivial enough to inline everywhere.
This commit is contained in:
Matthias Clasen 2024-04-15 22:32:51 -04:00
parent e583e823b5
commit 0e5f7601e4
2 changed files with 36 additions and 18 deletions

View File

@ -98,9 +98,9 @@ gdk_rgba_free (GdkRGBA *rgba)
* Returns: %TRUE if the @rgba is clear
*/
gboolean
gdk_rgba_is_clear (const GdkRGBA *rgba)
(gdk_rgba_is_clear) (const GdkRGBA *rgba)
{
return rgba->alpha < ((float) 0x00ff / (float) 0xffff);
return _gdk_rgba_is_clear (rgba);
}
/**
@ -115,9 +115,9 @@ gdk_rgba_is_clear (const GdkRGBA *rgba)
* Returns: %TRUE if the @rgba is opaque
*/
gboolean
gdk_rgba_is_opaque (const GdkRGBA *rgba)
(gdk_rgba_is_opaque) (const GdkRGBA *rgba)
{
return rgba->alpha > ((float)0xff00 / (float)0xffff);
return _gdk_rgba_is_opaque (rgba);
}
#define SKIP_WHITESPACES(s) while (*(s) == ' ') (s)++;
@ -368,21 +368,10 @@ gdk_rgba_hash (gconstpointer p)
* Returns: %TRUE if the two colors compare equal
*/
gboolean
gdk_rgba_equal (gconstpointer p1,
gconstpointer p2)
(gdk_rgba_equal) (gconstpointer p1,
gconstpointer p2)
{
const GdkRGBA *rgba1, *rgba2;
rgba1 = p1;
rgba2 = p2;
if (rgba1->red == rgba2->red &&
rgba1->green == rgba2->green &&
rgba1->blue == rgba2->blue &&
rgba1->alpha == rgba2->alpha)
return TRUE;
return FALSE;
return _gdk_rgba_equal (p1, p2);
}
/**

View File

@ -43,5 +43,34 @@
gboolean gdk_rgba_parser_parse (GtkCssParser *parser,
GdkRGBA *rgba);
#define gdk_rgba_is_clear(rgba) _gdk_rgba_is_clear (rgba)
#define gdk_rgba_is_opaque(rgba) _gdk_rgba_is_opaque (rgba)
#define gdk_rgba_equal(p1, p2) _gdk_rgba_equal (p1, p2)
static inline gboolean
_gdk_rgba_is_clear (const GdkRGBA *rgba)
{
return rgba->alpha < ((float) 0x00ff / (float) 0xffff);
}
static inline gboolean
_gdk_rgba_is_opaque (const GdkRGBA *rgba)
{
return rgba->alpha > ((float)0xff00 / (float)0xffff);
}
static inline gboolean
_gdk_rgba_equal (gconstpointer p1,
gconstpointer p2)
{
const GdkRGBA *rgba1 = p1;
const GdkRGBA *rgba2 = p2;
return rgba1->red == rgba2->red &&
rgba1->green == rgba2->green &&
rgba1->blue == rgba2->blue &&
rgba1->alpha == rgba2->alpha;
}
G_END_DECLS