From 38912ee4d9d7c74aa78a9dffcfc9e687232d8302 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Sat, 6 Nov 2010 20:00:39 +0000 Subject: [PATCH] Deprecate ClutterFrameSource The FrameSource API hasn't been used internally since 1.0; since it's not part of the paint clock, it is of limited use. --- clutter/clutter-frame-source.c | 89 ++++++++++++++++++++++++++++ clutter/clutter-frame-source.h | 4 ++ clutter/clutter-main.c | 103 +++------------------------------ clutter/clutter-main.h | 3 + clutter/clutter-private.h | 11 ++++ 5 files changed, 115 insertions(+), 95 deletions(-) diff --git a/clutter/clutter-frame-source.c b/clutter/clutter-frame-source.c index 517829e73..5492377cb 100644 --- a/clutter/clutter-frame-source.c +++ b/clutter/clutter-frame-source.c @@ -29,6 +29,7 @@ #include "clutter-frame-source.h" #include "clutter-timeout-interval.h" +#include "clutter-private.h" typedef struct _ClutterFrameSource ClutterFrameSource; @@ -85,6 +86,8 @@ static GSourceFuncs clutter_frame_source_funcs = * Return value: the ID (greater than 0) of the event source. * * Since: 0.8 + * + * Deprecated: 1.6 */ guint clutter_frame_source_add_full (gint priority, @@ -124,6 +127,8 @@ clutter_frame_source_add_full (gint priority, * Return value: the ID (greater than 0) of the event source. * * Since: 0.8 + * + * Deprecated: 1.6 */ guint clutter_frame_source_add (guint fps, @@ -164,3 +169,87 @@ clutter_frame_source_dispatch (GSource *source, return _clutter_timeout_interval_dispatch (&frame_source->timeout, callback, user_data); } + +/** + * clutter_threads_add_frame_source_full: + * @priority: the priority of the frame source. Typically this will be in the + * range between %G_PRIORITY_DEFAULT and %G_PRIORITY_HIGH. + * @fps: the number of times per second to call the function + * @func: function to call + * @data: data to pass to the function + * @notify: function to call when the timeout source is removed + * + * Sets a function to be called at regular intervals holding the Clutter + * threads lock, with the given priority. The function is called repeatedly + * until it returns %FALSE, at which point the timeout is automatically + * removed and the function will not be called again. The @notify function + * is called when the timeout is removed. + * + * This function is similar to clutter_threads_add_timeout_full() + * except that it will try to compensate for delays. For example, if + * @func takes half the interval time to execute then the function + * will be called again half the interval time after it finished. In + * contrast clutter_threads_add_timeout_full() would not fire until a + * full interval after the function completes so the delay between + * calls would be @interval * 1.5. This function does not however try + * to invoke the function multiple times to catch up missing frames if + * @func takes more than @interval ms to execute. + * + * See also clutter_threads_add_idle_full(). + * + * Rename to: clutter_threads_add_frame_source + * + * Return value: the ID (greater than 0) of the event source. + * + * Since: 0.8 + * + * Deprecated: 1.6 + */ +guint +clutter_threads_add_frame_source_full (gint priority, + guint fps, + GSourceFunc func, + gpointer data, + GDestroyNotify notify) +{ + ClutterThreadsDispatch *dispatch; + + g_return_val_if_fail (func != NULL, 0); + + dispatch = g_slice_new (ClutterThreadsDispatch); + dispatch->func = func; + dispatch->data = data; + dispatch->notify = notify; + + return clutter_frame_source_add_full (priority, + fps, + _clutter_threads_dispatch, dispatch, + _clutter_threads_dispatch_free); +} + +/** + * clutter_threads_add_frame_source: (skip) + * @fps: the number of times per second to call the function + * @func: function to call + * @data: data to pass to the function + * + * Simple wrapper around clutter_threads_add_frame_source_full(). + * + * Return value: the ID (greater than 0) of the event source. + * + * Since: 0.8 + * + * Deprecated: 1.6 + */ +guint +clutter_threads_add_frame_source (guint fps, + GSourceFunc func, + gpointer data) +{ + g_return_val_if_fail (func != NULL, 0); + + return clutter_threads_add_frame_source_full (G_PRIORITY_DEFAULT, + fps, + func, data, + NULL); +} diff --git a/clutter/clutter-frame-source.h b/clutter/clutter-frame-source.h index 157be3e62..2a5a35ed4 100644 --- a/clutter/clutter-frame-source.h +++ b/clutter/clutter-frame-source.h @@ -32,6 +32,8 @@ G_BEGIN_DECLS +#ifndef CLUTTER_DISABLE_DEPRECATED + guint clutter_frame_source_add (guint fps, GSourceFunc func, gpointer data); @@ -42,6 +44,8 @@ guint clutter_frame_source_add_full (gint priority, gpointer data, GDestroyNotify notify); +#endif /* CLUTTER_DISABLE_DEPRECATED */ + G_END_DECLS #endif /* __CLUTTER_FRAME_SOURCE_H__ */ diff --git a/clutter/clutter-main.c b/clutter/clutter-main.c index e1dbdf13d..6ae2f33ba 100644 --- a/clutter/clutter-main.c +++ b/clutter/clutter-main.c @@ -1046,15 +1046,8 @@ clutter_threads_set_lock_functions (GCallback enter_fn, clutter_threads_unlock = leave_fn; } -typedef struct -{ - GSourceFunc func; - gpointer data; - GDestroyNotify notify; -} ClutterThreadsDispatch; - -static gboolean -clutter_threads_dispatch (gpointer data) +gboolean +_clutter_threads_dispatch (gpointer data) { ClutterThreadsDispatch *dispatch = data; gboolean ret = FALSE; @@ -1069,8 +1062,8 @@ clutter_threads_dispatch (gpointer data) return ret; } -static void -clutter_threads_dispatch_free (gpointer data) +void +_clutter_threads_dispatch_free (gpointer data) { ClutterThreadsDispatch *dispatch = data; @@ -1197,8 +1190,8 @@ clutter_threads_add_idle_full (gint priority, dispatch->notify = notify; return g_idle_add_full (priority, - clutter_threads_dispatch, dispatch, - clutter_threads_dispatch_free); + _clutter_threads_dispatch, dispatch, + _clutter_threads_dispatch_free); } /** @@ -1273,8 +1266,8 @@ clutter_threads_add_timeout_full (gint priority, return g_timeout_add_full (priority, interval, - clutter_threads_dispatch, dispatch, - clutter_threads_dispatch_free); + _clutter_threads_dispatch, dispatch, + _clutter_threads_dispatch_free); } /** @@ -1302,86 +1295,6 @@ clutter_threads_add_timeout (guint interval, NULL); } -/** - * clutter_threads_add_frame_source_full: - * @priority: the priority of the frame source. Typically this will be in the - * range between #G_PRIORITY_DEFAULT and #G_PRIORITY_HIGH. - * @fps: the number of times per second to call the function - * @func: function to call - * @data: data to pass to the function - * @notify: function to call when the timeout source is removed - * - * Sets a function to be called at regular intervals holding the Clutter - * threads lock, with the given priority. The function is called repeatedly - * until it returns %FALSE, at which point the timeout is automatically - * removed and the function will not be called again. The @notify function - * is called when the timeout is removed. - * - * This function is similar to clutter_threads_add_timeout_full() - * except that it will try to compensate for delays. For example, if - * @func takes half the interval time to execute then the function - * will be called again half the interval time after it finished. In - * contrast clutter_threads_add_timeout_full() would not fire until a - * full interval after the function completes so the delay between - * calls would be @interval * 1.5. This function does not however try - * to invoke the function multiple times to catch up missing frames if - * @func takes more than @interval ms to execute. - * - * See also clutter_threads_add_idle_full(). - * - * Rename to: clutter_threads_add_frame_source - * - * Return value: the ID (greater than 0) of the event source. - * - * Since: 0.8 - */ -guint -clutter_threads_add_frame_source_full (gint priority, - guint fps, - GSourceFunc func, - gpointer data, - GDestroyNotify notify) -{ - ClutterThreadsDispatch *dispatch; - - g_return_val_if_fail (func != NULL, 0); - - dispatch = g_slice_new (ClutterThreadsDispatch); - dispatch->func = func; - dispatch->data = data; - dispatch->notify = notify; - - return clutter_frame_source_add_full (priority, - fps, - clutter_threads_dispatch, dispatch, - clutter_threads_dispatch_free); -} - -/** - * clutter_threads_add_frame_source: (skip) - * @fps: the number of times per second to call the function - * @func: function to call - * @data: data to pass to the function - * - * Simple wrapper around clutter_threads_add_frame_source_full(). - * - * Return value: the ID (greater than 0) of the event source. - * - * Since: 0.8 - */ -guint -clutter_threads_add_frame_source (guint fps, - GSourceFunc func, - gpointer data) -{ - g_return_val_if_fail (func != NULL, 0); - - return clutter_threads_add_frame_source_full (G_PRIORITY_DEFAULT, - fps, - func, data, - NULL); -} - /** * clutter_threads_enter: * diff --git a/clutter/clutter-main.h b/clutter/clutter-main.h index f5fe11b62..33336fd7c 100644 --- a/clutter/clutter-main.h +++ b/clutter/clutter-main.h @@ -124,6 +124,8 @@ guint clutter_threads_add_timeout_full (gint priority, GSourceFunc func, gpointer data, GDestroyNotify notify); + +#ifndef CLUTTER_DISABLE_DEPRECATED guint clutter_threads_add_frame_source (guint fps, GSourceFunc func, gpointer data); @@ -132,6 +134,7 @@ guint clutter_threads_add_frame_source_full (gint priority, GSourceFunc func, gpointer data, GDestroyNotify notify); +#endif /* CLUTTER_DISABLE_DEPRECATED */ guint clutter_threads_add_repaint_func (GSourceFunc func, gpointer data, diff --git a/clutter/clutter-private.h b/clutter/clutter-private.h index d3dfe04c3..8cf48c57b 100644 --- a/clutter/clutter-private.h +++ b/clutter/clutter-private.h @@ -149,6 +149,17 @@ struct _ClutterMainContext ClutterSettings *settings; }; +/* shared between clutter-main.c and clutter-frame-source.c */ +typedef struct +{ + GSourceFunc func; + gpointer data; + GDestroyNotify notify; +} ClutterThreadsDispatch; + +gboolean _clutter_threads_dispatch (gpointer data); +void _clutter_threads_dispatch_free (gpointer data); + #define CLUTTER_CONTEXT() (_clutter_context_get_default ()) ClutterMainContext *_clutter_context_get_default (void); gboolean _clutter_context_is_initialized (void);