diff --git a/cogl/cogl-boxed-value.c b/cogl/cogl-boxed-value.c index 47f375a36..b2cb3f320 100644 --- a/cogl/cogl-boxed-value.c +++ b/cogl/cogl-boxed-value.c @@ -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) { diff --git a/cogl/cogl-boxed-value.h b/cogl/cogl-boxed-value.h index dada36f27..d9dd45a0f 100644 --- a/cogl/cogl-boxed-value.h +++ b/cogl/cogl-boxed-value.h @@ -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);