mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 11:32:04 +00:00
cogl-boxed-value: Add _cogl_boxed_value_copy
This adds a function to copy one boxed value to another. It is assumed that the destination boxed value is totally initialised (so it won't try to free any memory in it). Reviewed-by: Robert Bragg <robert@linux.intel.com>
This commit is contained in:
parent
7068849ae6
commit
436a7a45da
@ -201,6 +201,40 @@ _cogl_boxed_value_set_matrix (CoglBoxedValue *bv,
|
||||
transpose);
|
||||
}
|
||||
|
||||
void
|
||||
_cogl_boxed_value_copy (CoglBoxedValue *dst,
|
||||
const CoglBoxedValue *src)
|
||||
{
|
||||
*dst = *src;
|
||||
|
||||
if (src->count > 1)
|
||||
{
|
||||
switch (src->type)
|
||||
{
|
||||
case COGL_BOXED_NONE:
|
||||
break;
|
||||
|
||||
case COGL_BOXED_INT:
|
||||
dst->v.int_array = g_memdup (src->v.int_array,
|
||||
src->size * src->count * sizeof (int));
|
||||
break;
|
||||
|
||||
case COGL_BOXED_FLOAT:
|
||||
dst->v.float_array = g_memdup (src->v.float_array,
|
||||
src->size *
|
||||
src->count *
|
||||
sizeof (float));
|
||||
break;
|
||||
|
||||
case COGL_BOXED_MATRIX:
|
||||
dst->v.float_array = g_memdup (src->v.float_array,
|
||||
src->size * src->size *
|
||||
src->count * sizeof (float));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_cogl_boxed_value_destroy (CoglBoxedValue *bv)
|
||||
{
|
||||
|
@ -89,6 +89,17 @@ _cogl_boxed_value_set_matrix (CoglBoxedValue *bv,
|
||||
gboolean transpose,
|
||||
const float *value);
|
||||
|
||||
/*
|
||||
* _cogl_boxed_value_copy:
|
||||
* @dst: The destination boxed value
|
||||
* @src: The source boxed value
|
||||
*
|
||||
* This copies @src to @dst. It is assumed that @dst is initialised.
|
||||
*/
|
||||
void
|
||||
_cogl_boxed_value_copy (CoglBoxedValue *dst,
|
||||
const CoglBoxedValue *src);
|
||||
|
||||
void
|
||||
_cogl_boxed_value_destroy (CoglBoxedValue *bv);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user