mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 18:11:05 -05:00
2008-09-23 Emmanuele Bassi <ebassi@linux.intel.com>
* clutter/clutter-alpha.c: (clutter_alpha_get_alpha): Do not return the cached value but just compute the current alpha value. The use case is pretty much straightforward: stop a timeline, advance it, and retrieve the alpha value before starting the timeline to adjust an animation dependent on the alpha. Caching the alpha value is not needed because the behaviours will always pass the alpha value inside the ::alpha-notify virtual function anyway, so there is no need for them to call clutter_alpha_get_alpha(). This change makes it also possible to reliably unit-test ClutterAlpha. (timeline_new_frame_cb): Call clutter_alpha_get_alpha().
This commit is contained in:
parent
6b51ac4b77
commit
73adac987d
17
ChangeLog
17
ChangeLog
@ -1,3 +1,20 @@
|
||||
2008-09-23 Emmanuele Bassi <ebassi@linux.intel.com>
|
||||
|
||||
* clutter/clutter-alpha.c:
|
||||
(clutter_alpha_get_alpha): Do not return the cached value but
|
||||
just compute the current alpha value. The use case is pretty
|
||||
much straightforward: stop a timeline, advance it, and retrieve
|
||||
the alpha value before starting the timeline to adjust an
|
||||
animation dependent on the alpha. Caching the alpha value is
|
||||
not needed because the behaviours will always pass the alpha
|
||||
value inside the ::alpha-notify virtual function anyway, so
|
||||
there is no need for them to call clutter_alpha_get_alpha().
|
||||
|
||||
This change makes it also possible to reliably unit-test
|
||||
ClutterAlpha.
|
||||
|
||||
(timeline_new_frame_cb): Call clutter_alpha_get_alpha().
|
||||
|
||||
2008-09-23 Tomas Frydrych <tf@linux.intel.com>
|
||||
|
||||
* clutter/clutter-main.c:
|
||||
|
@ -92,32 +92,8 @@ timeline_new_frame_cb (ClutterTimeline *timeline,
|
||||
ClutterAlphaPrivate *priv = alpha->priv;
|
||||
|
||||
/* Update alpha value and notify */
|
||||
if (G_LIKELY (priv->closure))
|
||||
{
|
||||
GValue params = { 0, };
|
||||
GValue result_value = { 0, };
|
||||
|
||||
g_object_ref (alpha);
|
||||
|
||||
g_value_init (&result_value, G_TYPE_UINT);
|
||||
|
||||
g_value_init (¶ms, CLUTTER_TYPE_ALPHA);
|
||||
g_value_set_object (¶ms, alpha);
|
||||
|
||||
g_closure_invoke (priv->closure,
|
||||
&result_value,
|
||||
1,
|
||||
¶ms,
|
||||
NULL);
|
||||
|
||||
priv->alpha = g_value_get_uint (&result_value);
|
||||
|
||||
g_value_unset (&result_value);
|
||||
g_value_unset (¶ms);
|
||||
|
||||
g_object_notify (G_OBJECT (alpha), "alpha");
|
||||
g_object_unref (alpha);
|
||||
}
|
||||
priv->alpha = clutter_alpha_get_alpha (alpha);
|
||||
g_object_notify (G_OBJECT (alpha), "alpha");
|
||||
}
|
||||
|
||||
static void
|
||||
@ -175,9 +151,7 @@ clutter_alpha_finalize (GObject *object)
|
||||
ClutterAlphaPrivate *priv = CLUTTER_ALPHA (object)->priv;
|
||||
|
||||
if (priv->closure)
|
||||
{
|
||||
g_closure_unref (priv->closure);
|
||||
}
|
||||
g_closure_unref (priv->closure);
|
||||
|
||||
G_OBJECT_CLASS (clutter_alpha_parent_class)->finalize (object);
|
||||
}
|
||||
@ -258,9 +232,40 @@ clutter_alpha_init (ClutterAlpha *self)
|
||||
guint32
|
||||
clutter_alpha_get_alpha (ClutterAlpha *alpha)
|
||||
{
|
||||
g_return_val_if_fail (CLUTTER_IS_ALPHA (alpha), FALSE);
|
||||
|
||||
return alpha->priv->alpha;
|
||||
ClutterAlphaPrivate *priv;
|
||||
guint32 retval = 0;
|
||||
|
||||
g_return_val_if_fail (CLUTTER_IS_ALPHA (alpha), 0);
|
||||
|
||||
priv = alpha->priv;
|
||||
|
||||
if (G_LIKELY (priv->closure))
|
||||
{
|
||||
GValue params = { 0, };
|
||||
GValue result_value = { 0, };
|
||||
|
||||
g_object_ref (alpha);
|
||||
|
||||
g_value_init (&result_value, G_TYPE_UINT);
|
||||
|
||||
g_value_init (¶ms, CLUTTER_TYPE_ALPHA);
|
||||
g_value_set_object (¶ms, alpha);
|
||||
|
||||
g_closure_invoke (priv->closure,
|
||||
&result_value,
|
||||
1,
|
||||
¶ms,
|
||||
NULL);
|
||||
|
||||
retval = g_value_get_uint (&result_value);
|
||||
|
||||
g_value_unset (&result_value);
|
||||
g_value_unset (¶ms);
|
||||
|
||||
g_object_unref (alpha);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -318,13 +323,11 @@ clutter_alpha_set_func (ClutterAlpha *alpha,
|
||||
gpointer data,
|
||||
GDestroyNotify destroy)
|
||||
{
|
||||
ClutterAlphaPrivate *priv;
|
||||
GClosure *closure;
|
||||
|
||||
g_return_if_fail (CLUTTER_IS_ALPHA (alpha));
|
||||
g_return_if_fail (func != NULL);
|
||||
|
||||
priv = alpha->priv;
|
||||
|
||||
closure = g_cclosure_new (G_CALLBACK (func), data, (GClosureNotify) destroy);
|
||||
clutter_alpha_set_closure (alpha, closure);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user