clutter/threads: Remove _full functions variant

As they are not used anywhere, in the next commit
we will just remove the whole thing and use glib helpers directly as
there is nothing specific about ClutterThread anymore

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4077>
This commit is contained in:
Bilal Elmoussaoui 2024-10-12 12:26:43 +02:00
parent 40e7998669
commit d92893b6f3
7 changed files with 35 additions and 166 deletions

View File

@ -849,7 +849,7 @@ typedef enum
* @CLUTTER_REPAINT_FLAGS_POST_PAINT: Run the repaint function after * @CLUTTER_REPAINT_FLAGS_POST_PAINT: Run the repaint function after
* painting the stages * painting the stages
* *
* Flags to pass to clutter_threads_add_repaint_func_full(). * Flags to pass to [func@Clutter.threads_add_repaint_func].
*/ */
typedef enum typedef enum
{ {

View File

@ -48,7 +48,6 @@ typedef struct
{ {
GSourceFunc func; GSourceFunc func;
gpointer data; gpointer data;
GDestroyNotify notify;
} ClutterThreadsDispatch; } ClutterThreadsDispatch;
G_DEFINE_QUARK (clutter_pipeline_capability, clutter_pipeline_capability) G_DEFINE_QUARK (clutter_pipeline_capability, clutter_pipeline_capability)
@ -83,25 +82,13 @@ _clutter_threads_dispatch_free (gpointer data)
{ {
ClutterThreadsDispatch *dispatch = data; ClutterThreadsDispatch *dispatch = data;
/* XXX - we cannot hold the thread lock here because the main loop
* might destroy a source while still in the dispatcher function; so
* knowing whether the lock is being held or not is not known a priori.
*
* see bug: http://bugzilla.gnome.org/show_bug.cgi?id=459555
*/
if (dispatch->notify)
dispatch->notify (dispatch->data);
g_free (dispatch); g_free (dispatch);
} }
/** /**
* clutter_threads_add_idle_full: (rename-to clutter_threads_add_idle) * clutter_threads_add_idle: (skip)
* @priority: the priority of the timeout source. Typically this will be in the
* range between #G_PRIORITY_DEFAULT_IDLE and #G_PRIORITY_HIGH_IDLE
* @func: function to call * @func: function to call
* @data: data to pass to the function * @data: data to pass to the function
* @notify: function to call when the idle source is removed
* *
* Adds a function to be called whenever there are no higher priority * Adds a function to be called whenever there are no higher priority
* events pending. If the function returns %FALSE it is automatically * events pending. If the function returns %FALSE it is automatically
@ -172,19 +159,15 @@ _clutter_threads_dispatch_free (gpointer data)
* closure->label = g_object_ref (my_application->label); * closure->label = g_object_ref (my_application->label);
* closure->text = g_strdup (processed_text_to_update_the_label); * closure->text = g_strdup (processed_text_to_update_the_label);
* *
* clutter_threads_add_idle_full (G_PRIORITY_HIGH_IDLE, * clutter_threads_add_idle (update_ui,
* update_ui, * closure);
* closure,
* NULL);
* ``` * ```
* *
* Return value: the ID (greater than 0) of the event source. * Return value: the ID (greater than 0) of the event source.
*/ */
guint guint
clutter_threads_add_idle_full (gint priority, clutter_threads_add_idle (GSourceFunc func,
GSourceFunc func, gpointer data)
gpointer data,
GDestroyNotify notify)
{ {
ClutterThreadsDispatch *dispatch; ClutterThreadsDispatch *dispatch;
@ -193,42 +176,17 @@ clutter_threads_add_idle_full (gint priority,
dispatch = g_new0 (ClutterThreadsDispatch, 1); dispatch = g_new0 (ClutterThreadsDispatch, 1);
dispatch->func = func; dispatch->func = func;
dispatch->data = data; dispatch->data = data;
dispatch->notify = notify;
return g_idle_add_full (priority, return g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
_clutter_threads_dispatch, dispatch, _clutter_threads_dispatch, dispatch,
_clutter_threads_dispatch_free); _clutter_threads_dispatch_free);
} }
/** /**
* clutter_threads_add_idle: (skip) * clutter_threads_add_timeout: (skip)
* @func: function to call
* @data: data to pass to the function
*
* Simple wrapper around clutter_threads_add_idle_full() using the
* default priority.
*
* Return value: the ID (greater than 0) of the event source.
*/
guint
clutter_threads_add_idle (GSourceFunc func,
gpointer data)
{
g_return_val_if_fail (func != NULL, 0);
return clutter_threads_add_idle_full (G_PRIORITY_DEFAULT_IDLE,
func, data,
NULL);
}
/**
* clutter_threads_add_timeout_full: (rename-to clutter_threads_add_timeout)
* @priority: the priority of the timeout source. Typically this will be in the
* range between #G_PRIORITY_DEFAULT and #G_PRIORITY_HIGH.
* @interval: the time between calls to the function, in milliseconds * @interval: the time between calls to the function, in milliseconds
* @func: function to call * @func: function to call
* @data: data to pass to the function * @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 * Sets a function to be called at regular intervals holding the Clutter
* threads lock, with the given priority. The function is called repeatedly * threads lock, with the given priority. The function is called repeatedly
@ -242,16 +200,12 @@ clutter_threads_add_idle (GSourceFunc func,
* implemented, the timing will not be accurate and it will not try to * implemented, the timing will not be accurate and it will not try to
* "keep up" with the interval. * "keep up" with the interval.
* *
* See also clutter_threads_add_idle_full().
*
* Return value: the ID (greater than 0) of the event source. * Return value: the ID (greater than 0) of the event source.
*/ */
guint guint
clutter_threads_add_timeout_full (gint priority, clutter_threads_add_timeout (guint interval,
guint interval, GSourceFunc func,
GSourceFunc func, gpointer data)
gpointer data,
GDestroyNotify notify)
{ {
ClutterThreadsDispatch *dispatch; ClutterThreadsDispatch *dispatch;
@ -260,37 +214,13 @@ clutter_threads_add_timeout_full (gint priority,
dispatch = g_new0 (ClutterThreadsDispatch, 1); dispatch = g_new0 (ClutterThreadsDispatch, 1);
dispatch->func = func; dispatch->func = func;
dispatch->data = data; dispatch->data = data;
dispatch->notify = notify;
return g_timeout_add_full (priority, return g_timeout_add_full (G_PRIORITY_DEFAULT,
interval, interval,
_clutter_threads_dispatch, dispatch, _clutter_threads_dispatch, dispatch,
_clutter_threads_dispatch_free); _clutter_threads_dispatch_free);
} }
/**
* clutter_threads_add_timeout: (skip)
* @interval: the time between calls to the function, in milliseconds
* @func: function to call
* @data: data to pass to the function
*
* Simple wrapper around clutter_threads_add_timeout_full().
*
* Return value: the ID (greater than 0) of the event source.
*/
guint
clutter_threads_add_timeout (guint interval,
GSourceFunc func,
gpointer data)
{
g_return_val_if_fail (func != NULL, 0);
return clutter_threads_add_timeout_full (G_PRIORITY_DEFAULT,
interval,
func, data,
NULL);
}
ClutterContext * ClutterContext *
_clutter_context_get_default (void) _clutter_context_get_default (void)
@ -627,52 +557,6 @@ clutter_threads_remove_repaint_func (guint handle_id)
/** /**
* clutter_threads_add_repaint_func: * clutter_threads_add_repaint_func:
* @func: the function to be called within the paint cycle
* @data: data to be passed to the function, or %NULL
* @notify: function to be called when removing the repaint
* function, or %NULL
*
* Adds a function to be called whenever Clutter is processing a new
* frame.
*
* If the function returns %FALSE it is automatically removed from the
* list of repaint functions and will not be called again.
*
* This function is guaranteed to be called from within the same thread
* that called clutter_main(), and while the Clutter lock is being held;
* the function will be called within the main loop, so it is imperative
* that it does not block, otherwise the frame time budget may be lost.
*
* A repaint function is useful to ensure that an update of the scenegraph
* is performed before the scenegraph is repainted. By default, a repaint
* function added using this function will be invoked prior to the frame
* being processed.
*
* Adding a repaint function does not automatically ensure that a new
* frame will be queued.
*
* When the repaint function is removed (either because it returned %FALSE
* or because clutter_threads_remove_repaint_func() has been called) the
* @notify function will be called, if any is set.
*
* See also: clutter_threads_add_repaint_func_full()
*
* Return value: the ID (greater than 0) of the repaint function. You
* can use the returned integer to remove the repaint function by
* calling clutter_threads_remove_repaint_func().
*/
guint
clutter_threads_add_repaint_func (GSourceFunc func,
gpointer data,
GDestroyNotify notify)
{
return clutter_threads_add_repaint_func_full (CLUTTER_REPAINT_FLAGS_PRE_PAINT,
func,
data, notify);
}
/**
* clutter_threads_add_repaint_func_full:
* @flags: flags for the repaint function * @flags: flags for the repaint function
* @func: the function to be called within the paint cycle * @func: the function to be called within the paint cycle
* @data: data to be passed to the function, or %NULL * @data: data to be passed to the function, or %NULL
@ -707,10 +591,10 @@ clutter_threads_add_repaint_func (GSourceFunc func,
* calling clutter_threads_remove_repaint_func(). * calling clutter_threads_remove_repaint_func().
*/ */
guint guint
clutter_threads_add_repaint_func_full (ClutterRepaintFlags flags, clutter_threads_add_repaint_func (ClutterRepaintFlags flags,
GSourceFunc func, GSourceFunc func,
gpointer data, gpointer data,
GDestroyNotify notify) GDestroyNotify notify)
{ {
ClutterContext *context; ClutterContext *context;
ClutterRepaintFunction *repaint_func; ClutterRepaintFunction *repaint_func;

View File

@ -112,29 +112,14 @@ CLUTTER_EXPORT
guint clutter_threads_add_idle (GSourceFunc func, guint clutter_threads_add_idle (GSourceFunc func,
gpointer data); gpointer data);
CLUTTER_EXPORT CLUTTER_EXPORT
guint clutter_threads_add_idle_full (gint priority,
GSourceFunc func,
gpointer data,
GDestroyNotify notify);
CLUTTER_EXPORT
guint clutter_threads_add_timeout (guint interval, guint clutter_threads_add_timeout (guint interval,
GSourceFunc func, GSourceFunc func,
gpointer data); gpointer data);
CLUTTER_EXPORT CLUTTER_EXPORT
guint clutter_threads_add_timeout_full (gint priority, guint clutter_threads_add_repaint_func (ClutterRepaintFlags flags,
guint interval, GSourceFunc func,
GSourceFunc func, gpointer data,
gpointer data, GDestroyNotify notify);
GDestroyNotify notify);
CLUTTER_EXPORT
guint clutter_threads_add_repaint_func (GSourceFunc func,
gpointer data,
GDestroyNotify notify);
CLUTTER_EXPORT
guint clutter_threads_add_repaint_func_full (ClutterRepaintFlags flags,
GSourceFunc func,
gpointer data,
GDestroyNotify notify);
CLUTTER_EXPORT CLUTTER_EXPORT
void clutter_threads_remove_repaint_func (guint handle_id); void clutter_threads_remove_repaint_func (guint handle_id);

View File

@ -151,9 +151,9 @@ meta_restart (const char *message,
if (message && meta_display_show_restart_message (display, message)) if (message && meta_display_show_restart_message (display, message))
{ {
/* Wait until the stage was painted */ /* Wait until the stage was painted */
clutter_threads_add_repaint_func_full (CLUTTER_REPAINT_FLAGS_POST_PAINT, clutter_threads_add_repaint_func (CLUTTER_REPAINT_FLAGS_POST_PAINT,
restart_message_painted, restart_message_painted,
context, NULL); context, NULL);
} }
else else
{ {

View File

@ -418,10 +418,10 @@ clutter_test_check_actor_at_point (ClutterActor *stage,
clutter_actor_show (stage); clutter_actor_show (stage);
clutter_threads_add_repaint_func_full (CLUTTER_REPAINT_FLAGS_POST_PAINT, clutter_threads_add_repaint_func (CLUTTER_REPAINT_FLAGS_POST_PAINT,
validate_stage, validate_stage,
data, data,
NULL); NULL);
while (!data->was_painted) while (!data->was_painted)
g_main_context_iteration (NULL, TRUE); g_main_context_iteration (NULL, TRUE);

View File

@ -435,10 +435,10 @@ actor_offscreen_redirect (void)
clutter_actor_show (data.stage); clutter_actor_show (data.stage);
clutter_threads_add_repaint_func_full (CLUTTER_REPAINT_FLAGS_POST_PAINT, clutter_threads_add_repaint_func (CLUTTER_REPAINT_FLAGS_POST_PAINT,
run_verify, run_verify,
&data, &data,
NULL); NULL);
while (!data.was_painted) while (!data.was_painted)
g_main_context_iteration (NULL, FALSE); g_main_context_iteration (NULL, FALSE);

View File

@ -215,10 +215,10 @@ texture_fbo (TestConformSimpleFixture *fixture,
clutter_actor_show (state.stage); clutter_actor_show (state.stage);
clutter_threads_add_repaint_func_full (CLUTTER_REPAINT_FLAGS_POST_PAINT, clutter_threads_add_repaint_func (CLUTTER_REPAINT_FLAGS_POST_PAINT,
on_paint, on_paint,
&state, &state,
NULL); NULL);
while (!state.was_painted) while (!state.was_painted)
g_main_context_iteration (NULL, FALSE); g_main_context_iteration (NULL, FALSE);