From 6a09bf5b52c97668d280357b03720956f83ad79a Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 13 Feb 2012 22:40:19 +0000 Subject: [PATCH] paint-volume: Add a union method for boxes Creating PaintVolume instances is not possible, and it's not recommended anyway. It is, though, necessary to union paint volumes, especially with 2D boxes, in some cases. Clutter should provide a simple convenience function that allows unioning volumes to boxes in a moderately efficient way. https://bugzilla.gnome.org/show_bug.cgi?id=670021 --- clutter/clutter-paint-volume.c | 36 ++++++++++++++++++++++ clutter/clutter-types.h | 2 ++ clutter/clutter.symbols | 1 + doc/reference/clutter/clutter-sections.txt | 1 + 4 files changed, 40 insertions(+) diff --git a/clutter/clutter-paint-volume.c b/clutter/clutter-paint-volume.c index 419b28198..725be7917 100644 --- a/clutter/clutter-paint-volume.c +++ b/clutter/clutter-paint-volume.c @@ -640,6 +640,42 @@ done: pv->is_complete = FALSE; } +/** + * clutter_paint_volume_union_box: + * @pv: a #ClutterPaintVolume + * @box: a #ClutterActorBox to union to @pv + * + * Unions the 2D region represented by @box to a #ClutterPaintVolume. + * + * This function is similar to clutter_paint_volume_union(), but it is + * specific for 2D regions. + * + * Since: 1.10 + */ +void +clutter_paint_volume_union_box (ClutterPaintVolume *pv, + const ClutterActorBox *box) +{ + ClutterPaintVolume volume; + ClutterVertex origin; + + g_return_if_fail (pv != NULL); + g_return_if_fail (box != NULL); + + _clutter_paint_volume_init_static (&volume, pv->actor); + + origin.x = box->x1; + origin.y = box->y1; + origin.z = 0.f; + clutter_paint_volume_set_origin (&volume, &origin); + clutter_paint_volume_set_width (&volume, box->x2 - box->x1); + clutter_paint_volume_set_height (&volume, box->y2 - box->y1); + + clutter_paint_volume_union (pv, &volume); + + clutter_paint_volume_free (&volume); +} + /* The paint_volume setters only update vertices 0, 1, 3 and * 4 since the others can be drived from them. * diff --git a/clutter/clutter-types.h b/clutter/clutter-types.h index ecd0d161f..0ec28afa4 100644 --- a/clutter/clutter-types.h +++ b/clutter/clutter-types.h @@ -279,6 +279,8 @@ void clutter_paint_volume_set_depth (ClutterPaintVolume gfloat clutter_paint_volume_get_depth (const ClutterPaintVolume *pv); void clutter_paint_volume_union (ClutterPaintVolume *pv, const ClutterPaintVolume *another_pv); +void clutter_paint_volume_union_box (ClutterPaintVolume *pv, + const ClutterActorBox *box); gboolean clutter_paint_volume_set_from_allocation (ClutterPaintVolume *pv, ClutterActor *actor); diff --git a/clutter/clutter.symbols b/clutter/clutter.symbols index 87280718c..56c896b31 100644 --- a/clutter/clutter.symbols +++ b/clutter/clutter.symbols @@ -900,6 +900,7 @@ clutter_paint_volume_set_from_allocation clutter_paint_volume_set_height clutter_paint_volume_set_origin clutter_paint_volume_set_width +clutter_paint_volume_union_box clutter_paint_volume_union clutter_param_color_get_type clutter_param_fixed_get_type diff --git a/doc/reference/clutter/clutter-sections.txt b/doc/reference/clutter/clutter-sections.txt index 0b44a415f..59f92e91b 100644 --- a/doc/reference/clutter/clutter-sections.txt +++ b/doc/reference/clutter/clutter-sections.txt @@ -547,6 +547,7 @@ clutter_paint_volume_set_depth clutter_paint_volume_get_depth clutter_paint_volume_set_from_allocation clutter_paint_volume_union +clutter_paint_volume_union_box CLUTTER_TYPE_GEOMETRY