mirror of
https://github.com/brl/mutter.git
synced 2024-11-09 23:46:33 -05:00
cogl-bitmask: Add a return value for the foreach callback
The foreach callback can now return FALSE to stop the iteration. Reviewed-by: Robert Bragg <robert@linux.intel.com>
This commit is contained in:
parent
f4c1ba9ed9
commit
dbc31b70cc
@ -428,13 +428,13 @@ validated:
|
||||
return status;
|
||||
}
|
||||
|
||||
static void
|
||||
static gboolean
|
||||
toggle_enabled_cb (int bit_num, void *user_data)
|
||||
{
|
||||
const CoglBitmask *new_values = user_data;
|
||||
gboolean enabled = _cogl_bitmask_get (new_values, bit_num);
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
_COGL_GET_CONTEXT (ctx, FALSE);
|
||||
|
||||
if (ctx->driver == COGL_DRIVER_GLES2)
|
||||
{
|
||||
@ -454,6 +454,8 @@ toggle_enabled_cb (int bit_num, void *user_data)
|
||||
GE( ctx, glDisableClientState (GL_TEXTURE_COORD_ARRAY) );
|
||||
}
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -231,7 +231,7 @@ _cogl_bitmask_clear_all_in_array (CoglBitmask *bitmask)
|
||||
void
|
||||
_cogl_bitmask_foreach (const CoglBitmask *bitmask,
|
||||
CoglBitmaskForeachFunc func,
|
||||
gpointer user_data)
|
||||
void *user_data)
|
||||
{
|
||||
if (_cogl_bitmask_has_array (bitmask))
|
||||
{
|
||||
@ -251,8 +251,9 @@ _cogl_bitmask_foreach (const CoglBitmask *bitmask,
|
||||
bit += next_bit;
|
||||
mask >>= next_bit;
|
||||
|
||||
func (array_index * sizeof (unsigned long) * 8 + bit - 1,
|
||||
user_data);
|
||||
if (!func (array_index * sizeof (unsigned long) * 8 + bit - 1,
|
||||
user_data))
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -268,7 +269,8 @@ _cogl_bitmask_foreach (const CoglBitmask *bitmask,
|
||||
bit += next_bit;
|
||||
mask >>= next_bit;
|
||||
|
||||
func (bit - 1, user_data);
|
||||
if (!func (bit - 1, user_data))
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -125,7 +125,8 @@ void
|
||||
_cogl_bitmask_xor_bits (CoglBitmask *dst,
|
||||
const CoglBitmask *src);
|
||||
|
||||
typedef void (* CoglBitmaskForeachFunc) (int bit_num, gpointer user_data);
|
||||
/* The foreach function can return FALSE to stop iteration */
|
||||
typedef gboolean (* CoglBitmaskForeachFunc) (int bit_num, void *user_data);
|
||||
|
||||
/*
|
||||
* cogl_bitmask_foreach:
|
||||
@ -138,7 +139,7 @@ typedef void (* CoglBitmaskForeachFunc) (int bit_num, gpointer user_data);
|
||||
void
|
||||
_cogl_bitmask_foreach (const CoglBitmask *bitmask,
|
||||
CoglBitmaskForeachFunc func,
|
||||
gpointer user_data);
|
||||
void *user_data);
|
||||
|
||||
/*
|
||||
* _cogl_bitmask_get:
|
||||
|
@ -19,7 +19,7 @@ typedef struct
|
||||
int *bits;
|
||||
} CheckData;
|
||||
|
||||
static void
|
||||
static gboolean
|
||||
check_bit (int bit_num, void *user_data)
|
||||
{
|
||||
CheckData *data = user_data;
|
||||
@ -29,12 +29,12 @@ check_bit (int bit_num, void *user_data)
|
||||
if (data->bits[i] == bit_num)
|
||||
{
|
||||
data->bits[i] = -1;
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
g_assert_not_reached ();
|
||||
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user