actor: Clean up the debug node for out-of-band transforms

Enclose the check inside a #ifdef CLUTTER_ENABLE_DEBUG ... #endif, so
that we can compile it out; also, use g_string_append() instead of the
g_string_append_printf() function, given that we're just concatenating
strings.
This commit is contained in:
Emmanuele Bassi 2012-01-13 16:21:15 +00:00
parent f2a4aee412
commit 7c14ba7d37

View File

@ -2869,35 +2869,52 @@ clutter_actor_paint (ClutterActor *self)
if (priv->enable_model_view_transform) if (priv->enable_model_view_transform)
{ {
CoglMatrix matrix; CoglMatrix matrix;
/* XXX: It could be better to cache the modelview with the actor /* XXX: It could be better to cache the modelview with the actor
* instead of progressively building up the transformations on * instead of progressively building up the transformations on
* the matrix stack every time we paint. */ * the matrix stack every time we paint. */
cogl_get_modelview_matrix (&matrix); cogl_get_modelview_matrix (&matrix);
_clutter_actor_apply_modelview_transform (self, &matrix); _clutter_actor_apply_modelview_transform (self, &matrix);
cogl_set_modelview_matrix (&matrix);
#ifdef CLUTTER_ENABLE_DEBUG
/* Catch when out-of-band transforms have been made by actors not as part /* Catch when out-of-band transforms have been made by actors not as part
* of an apply_transform vfunc... */ * of an apply_transform vfunc... */
if (G_UNLIKELY (clutter_debug_flags & CLUTTER_DEBUG_OOB_TRANSFORMS)) if (G_UNLIKELY (clutter_debug_flags & CLUTTER_DEBUG_OOB_TRANSFORMS))
{ {
CoglMatrix expected_matrix; CoglMatrix expected_matrix;
_clutter_actor_get_relative_transformation_matrix (self, NULL, _clutter_actor_get_relative_transformation_matrix (self, NULL,
&expected_matrix); &expected_matrix);
if (!cogl_matrix_equal (&matrix, &expected_matrix)) if (!cogl_matrix_equal (&matrix, &expected_matrix))
{ {
ClutterActor *parent = self; GString *buf = g_string_sized_new (1024);
GString *parents = g_string_new (""); ClutterActor *parent;
while ((parent = clutter_actor_get_parent (parent)))
g_string_append_printf (parents, "->%s", G_OBJECT_TYPE_NAME (parent)); parent = self;
while (parent != NULL)
{
g_string_append (buf, _clutter_actor_get_debug_name (parent));
if (parent->priv->parent_actor != NULL)
g_string_append (buf, "->");
parent = parent->priv->parent_actor;
}
g_warning ("Unexpected transform found when painting actor " g_warning ("Unexpected transform found when painting actor "
"\"%s\". This will be caused by one of the actor's " "\"%s\". This will be caused by one of the actor's "
"ancestors (%s) using the Cogl API directly to transform " "ancestors (%s) using the Cogl API directly to transform "
"children instead of using ::apply_transform().", "children instead of using ::apply_transform().",
_clutter_actor_get_debug_name (self), _clutter_actor_get_debug_name (self),
parents->str); buf->str);
g_string_free (parents, TRUE);
g_string_free (buf, TRUE);
} }
} }
#endif /* CLUTTER_ENABLE_DEBUG */
cogl_set_modelview_matrix (&matrix);
} }
if (priv->has_clip) if (priv->has_clip)