mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 08:00:42 -05:00
cogl-bitmask: Add _cogl_bitmask_set_flags
This adds a _cogl_bitmask_set_flags function which can be used to copy the values from a CoglBitmask to an array of unsigned longs which can be used with the COGL_FLAGS_* macros. The values are or'd in so that in can be used multiple times to combine multiple bitmasks. Reviewed-by: Robert Bragg <robert@linux.intel.com>
This commit is contained in:
parent
d2fd168351
commit
4e760d51f1
@ -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);
|
||||
}
|
||||
|
@ -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 */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user