diff --git a/cogl/cogl-bitmask.c b/cogl/cogl-bitmask.c index ec69625db..5e2ff92c2 100644 --- a/cogl/cogl-bitmask.c +++ b/cogl/cogl-bitmask.c @@ -260,3 +260,14 @@ _cogl_bitmask_foreach (const CoglBitmask *bitmask, COGL_FLAGS_FOREACH_END; } } + +void +_cogl_bitmask_set_flags_array (const CoglBitmask *bitmask, + unsigned long *flags) +{ + const GArray *array = (const GArray *) *bitmask; + int i; + + for (i = 0; i < array->len; i++) + flags[i] |= g_array_index (array, unsigned long, i); +} diff --git a/cogl/cogl-bitmask.h b/cogl/cogl-bitmask.h index e36a55112..479ac4a18 100644 --- a/cogl/cogl-bitmask.h +++ b/cogl/cogl-bitmask.h @@ -101,6 +101,9 @@ _cogl_bitmask_set_range_in_array (CoglBitmask *bitmask, void _cogl_bitmask_clear_all_in_array (CoglBitmask *bitmask); +void +_cogl_bitmask_set_flags_array (const CoglBitmask *bitmask, + unsigned long *flags); /* * cogl_bitmask_set_bits: * @dst: The bitmask to modify @@ -233,7 +236,24 @@ _cogl_bitmask_clear_all (CoglBitmask *bitmask) *bitmask = _cogl_bitmask_from_bits (0); } +/* + * _cogl_bitmask_set_flags: + * @bitmask: A pointer to a bitmask + * @flags: An array of flags + * + * Bitwise or's the bits from @bitmask into the flags array (see + * cogl-flags) pointed to by @flags. + */ +static inline void +_cogl_bitmask_set_flags (const CoglBitmask *bitmask, + unsigned long *flags) +{ + if (_cogl_bitmask_has_array (bitmask)) + return _cogl_bitmask_set_flags_array (bitmask, flags); + else + flags[0] |= _cogl_bitmask_to_bits (bitmask); +} + G_END_DECLS #endif /* __COGL_BITMASK_H */ -