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.
This commit is contained in:
Emmanuele Bassi 2010-11-06 20:00:39 +00:00
parent 9ac2f5cba5
commit 38912ee4d9
5 changed files with 115 additions and 95 deletions

View File

@ -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);
}

View File

@ -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__ */

View File

@ -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:
*

View File

@ -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,

View File

@ -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);