mirror of
https://github.com/brl/mutter.git
synced 2025-06-14 01:09:30 +00:00
[cogl-color] Adds a cogl_color_equal() function
CoglColors shouldn't be compared using memcmp since they may contain uninitialized padding bytes. The prototype is also suitable for passing to g_hash_table_new as the key_equal_func. _cogl_pango_display_list_add_texture now uses this instead of memcmp.
This commit is contained in:
@ -25,6 +25,8 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "cogl.h"
|
||||
#include "cogl-color.h"
|
||||
#include "cogl-fixed.h"
|
||||
@ -184,3 +186,16 @@ cogl_set_source_color4f (float red,
|
||||
cogl_color_set_from_4f (&c, red, green, blue, alpha);
|
||||
cogl_set_source_color (&c);
|
||||
}
|
||||
|
||||
gboolean
|
||||
cogl_color_equal (gconstpointer v1, gconstpointer v2)
|
||||
{
|
||||
const guint32 *c1 = v1, *c2 = v2;
|
||||
|
||||
g_return_val_if_fail (v1 != NULL, FALSE);
|
||||
g_return_val_if_fail (v2 != NULL, FALSE);
|
||||
|
||||
/* XXX: We don't compare the padding */
|
||||
return *c1 == *c2 ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user