mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 03:22:04 +00:00
2008-04-18 Emmanuele Bassi <ebassi@openedhand.com>
Bug #884 - Add clutter_alpha_set_closure * clutter/clutter-alpha.[ch]: Add clutter_alpha_set_closure(), a GClosure variant of clutter_alpha_set_func(), and reimplement the latter as a special case of the former. (#884, Xan López)
This commit is contained in:
parent
e97cba0162
commit
9655f4d58c
@ -1,3 +1,11 @@
|
|||||||
|
2008-04-18 Emmanuele Bassi <ebassi@openedhand.com>
|
||||||
|
|
||||||
|
Bug #884 - Add clutter_alpha_set_closure
|
||||||
|
|
||||||
|
* clutter/clutter-alpha.[ch]: Add clutter_alpha_set_closure(),
|
||||||
|
a GClosure variant of clutter_alpha_set_func(), and reimplement
|
||||||
|
the latter as a special case of the former. (#884, Xan López)
|
||||||
|
|
||||||
2008-04-18 Neil Roberts <neil@o-hand.com>
|
2008-04-18 Neil Roberts <neil@o-hand.com>
|
||||||
|
|
||||||
* clutter/clutter-timeline.c (clutter_timeline_get_progressx):
|
* clutter/clutter-timeline.c (clutter_timeline_get_progressx):
|
||||||
|
@ -72,10 +72,8 @@ struct _ClutterAlphaPrivate
|
|||||||
guint timeline_new_frame_id;
|
guint timeline_new_frame_id;
|
||||||
|
|
||||||
guint32 alpha;
|
guint32 alpha;
|
||||||
|
|
||||||
ClutterAlphaFunc func;
|
GClosure *closure;
|
||||||
gpointer data;
|
|
||||||
GDestroyNotify destroy;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
@ -94,11 +92,28 @@ timeline_new_frame_cb (ClutterTimeline *timeline,
|
|||||||
ClutterAlphaPrivate *priv = alpha->priv;
|
ClutterAlphaPrivate *priv = alpha->priv;
|
||||||
|
|
||||||
/* Update alpha value and notify */
|
/* Update alpha value and notify */
|
||||||
if (priv->func)
|
if (G_LIKELY (priv->closure))
|
||||||
{
|
{
|
||||||
|
GValue params = { 0, };
|
||||||
|
GValue result_value = { 0, };
|
||||||
|
|
||||||
g_object_ref (alpha);
|
g_object_ref (alpha);
|
||||||
|
|
||||||
priv->alpha = priv->func (alpha, priv->data);
|
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_notify (G_OBJECT (alpha), "alpha");
|
||||||
g_object_unref (alpha);
|
g_object_unref (alpha);
|
||||||
@ -159,13 +174,9 @@ clutter_alpha_finalize (GObject *object)
|
|||||||
{
|
{
|
||||||
ClutterAlphaPrivate *priv = CLUTTER_ALPHA (object)->priv;
|
ClutterAlphaPrivate *priv = CLUTTER_ALPHA (object)->priv;
|
||||||
|
|
||||||
if (priv->destroy)
|
if (priv->closure)
|
||||||
{
|
{
|
||||||
priv->destroy (priv->data);
|
g_closure_unref (priv->closure);
|
||||||
|
|
||||||
priv->destroy = NULL;
|
|
||||||
priv->data = NULL;
|
|
||||||
priv->func = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
G_OBJECT_CLASS (clutter_alpha_parent_class)->finalize (object);
|
G_OBJECT_CLASS (clutter_alpha_parent_class)->finalize (object);
|
||||||
@ -252,6 +263,42 @@ clutter_alpha_get_alpha (ClutterAlpha *alpha)
|
|||||||
return alpha->priv->alpha;
|
return alpha->priv->alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* clutter_alpha_set_closure:
|
||||||
|
* @alpha: A #ClutterAlpha
|
||||||
|
* @closure: A #GClosure
|
||||||
|
*
|
||||||
|
* Sets the #GClosure used to compute
|
||||||
|
* the alpha value at each frame of the #ClutterTimeline
|
||||||
|
* bound to @alpha.
|
||||||
|
*
|
||||||
|
* Since: 0.8
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
clutter_alpha_set_closure (ClutterAlpha *alpha,
|
||||||
|
GClosure *closure)
|
||||||
|
{
|
||||||
|
ClutterAlphaPrivate *priv;
|
||||||
|
|
||||||
|
g_return_if_fail (CLUTTER_IS_ALPHA (alpha));
|
||||||
|
g_return_if_fail (closure != NULL);
|
||||||
|
|
||||||
|
priv = alpha->priv;
|
||||||
|
|
||||||
|
if (priv->closure)
|
||||||
|
g_closure_unref (priv->closure);
|
||||||
|
|
||||||
|
priv->closure = g_closure_ref (closure);
|
||||||
|
g_closure_sink (closure);
|
||||||
|
|
||||||
|
if (G_CLOSURE_NEEDS_MARSHAL (closure))
|
||||||
|
{
|
||||||
|
GClosureMarshal marshal = clutter_marshal_UINT__VOID;
|
||||||
|
|
||||||
|
g_closure_set_marshal (closure, marshal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* clutter_alpha_set_func:
|
* clutter_alpha_set_func:
|
||||||
* @alpha: A #ClutterAlpha
|
* @alpha: A #ClutterAlpha
|
||||||
@ -272,22 +319,14 @@ clutter_alpha_set_func (ClutterAlpha *alpha,
|
|||||||
GDestroyNotify destroy)
|
GDestroyNotify destroy)
|
||||||
{
|
{
|
||||||
ClutterAlphaPrivate *priv;
|
ClutterAlphaPrivate *priv;
|
||||||
|
GClosure *closure;
|
||||||
|
|
||||||
g_return_if_fail (CLUTTER_IS_ALPHA (alpha));
|
g_return_if_fail (CLUTTER_IS_ALPHA (alpha));
|
||||||
|
|
||||||
priv = alpha->priv;
|
priv = alpha->priv;
|
||||||
|
|
||||||
if (priv->destroy)
|
closure = g_cclosure_new (G_CALLBACK (func), data, (GClosureNotify) destroy);
|
||||||
{
|
clutter_alpha_set_closure (alpha, closure);
|
||||||
priv->destroy (priv->data);
|
|
||||||
priv->func = NULL;
|
|
||||||
priv->data = NULL;
|
|
||||||
priv->destroy = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
priv->func = func;
|
|
||||||
priv->data = data;
|
|
||||||
priv->destroy = destroy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -133,6 +133,8 @@ void clutter_alpha_set_func (ClutterAlpha *alpha,
|
|||||||
ClutterAlphaFunc func,
|
ClutterAlphaFunc func,
|
||||||
gpointer data,
|
gpointer data,
|
||||||
GDestroyNotify destroy);
|
GDestroyNotify destroy);
|
||||||
|
void clutter_alpha_set_closure (ClutterAlpha *alpha,
|
||||||
|
GClosure *closure);
|
||||||
void clutter_alpha_set_timeline (ClutterAlpha *alpha,
|
void clutter_alpha_set_timeline (ClutterAlpha *alpha,
|
||||||
ClutterTimeline *timeline);
|
ClutterTimeline *timeline);
|
||||||
ClutterTimeline *clutter_alpha_get_timeline (ClutterAlpha *alpha);
|
ClutterTimeline *clutter_alpha_get_timeline (ClutterAlpha *alpha);
|
||||||
|
@ -9,3 +9,4 @@ VOID:VOID
|
|||||||
VOID:OBJECT,POINTER
|
VOID:OBJECT,POINTER
|
||||||
VOID:STRING,UINT
|
VOID:STRING,UINT
|
||||||
BOOLEAN:BOXED
|
BOOLEAN:BOXED
|
||||||
|
UINT:VOID
|
||||||
|
Loading…
Reference in New Issue
Block a user