cogl: Simplify poll_renderer_get_info

As the only info we can pass now is whether we have any idle
closures. Removes the timeout handling which is now is always set to
either 0 or -1 based on whether we have idle closures

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3887>
This commit is contained in:
Bilal Elmoussaoui 2024-07-15 23:09:36 +02:00 committed by Marge Bot
parent 1ceb206897
commit 24c338cc0e
4 changed files with 12 additions and 48 deletions

View File

@ -46,12 +46,8 @@ static gboolean
cogl_glib_source_prepare (GSource *source, int *timeout) cogl_glib_source_prepare (GSource *source, int *timeout)
{ {
CoglGLibSource *cogl_source = (CoglGLibSource *) source; CoglGLibSource *cogl_source = (CoglGLibSource *) source;
int64_t cogl_timeout;
cogl_poll_renderer_get_info (cogl_source->renderer, if (!cogl_poll_renderer_has_idle_closures (cogl_source->renderer))
&cogl_timeout);
if (cogl_timeout == -1)
{ {
*timeout = -1; *timeout = -1;
cogl_source->expiration_time = -1; cogl_source->expiration_time = -1;
@ -59,9 +55,8 @@ cogl_glib_source_prepare (GSource *source, int *timeout)
else else
{ {
/* Round up to ensure that we don't try again too early */ /* Round up to ensure that we don't try again too early */
*timeout = (cogl_timeout + 999) / 1000; *timeout = 999 / 1000;
cogl_source->expiration_time = (g_source_get_time (source) + cogl_source->expiration_time = g_source_get_time (source);
cogl_timeout);
} }
return *timeout == 0; return *timeout == 0;

View File

@ -46,11 +46,7 @@ G_BEGIN_DECLS
* @priority: The priority of the #GSource * @priority: The priority of the #GSource
* *
* Creates a #GSource which handles Cogl's internal system event * Creates a #GSource which handles Cogl's internal system event
* processing. This can be used as a convenience instead of * processing.
* cogl_poll_renderer_get_info() and cogl_poll_renderer_dispatch() in
* applications that are already using the GLib main loop. After this
* is called the #GSource should be attached to the main loop using
* g_source_attach().
* *
* Applications that manually connect to a #CoglRenderer before they * Applications that manually connect to a #CoglRenderer before they
* create a #CoglContext should instead use * create a #CoglContext should instead use
@ -74,11 +70,7 @@ cogl_glib_source_new (CoglContext *context,
* @priority: The priority of the #GSource * @priority: The priority of the #GSource
* *
* Creates a #GSource which handles Cogl's internal system event * Creates a #GSource which handles Cogl's internal system event
* processing. This can be used as a convenience instead of * processing
* cogl_poll_renderer_get_info() and cogl_poll_renderer_dispatch() in
* applications that are already using the GLib main loop. After this
* is called the #GSource should be attached to the main loop using
* g_source_attach().
* *
* Return value: a new #GSource * Return value: a new #GSource
*/ */

View File

@ -37,17 +37,12 @@
#include "cogl/cogl-renderer-private.h" #include "cogl/cogl-renderer-private.h"
#include "cogl/winsys/cogl-winsys-private.h" #include "cogl/winsys/cogl-winsys-private.h"
void gboolean
cogl_poll_renderer_get_info (CoglRenderer *renderer, cogl_poll_renderer_has_idle_closures (CoglRenderer *renderer)
int64_t *timeout)
{ {
g_return_if_fail (COGL_IS_RENDERER (renderer)); g_return_val_if_fail (COGL_IS_RENDERER (renderer), FALSE);
g_return_if_fail (timeout != NULL);
*timeout = -1; return !_cogl_list_empty (&renderer->idle_closures);
if (!_cogl_list_empty (&renderer->idle_closures))
*timeout = 0;
} }
void void

View File

@ -65,29 +65,11 @@ G_BEGIN_DECLS
/** /**
* cogl_poll_renderer_get_info: * cogl_poll_renderer_has_idle_closures:
* @renderer: A #CoglRenderer * @renderer: A #CoglRenderer
* @timeout: A return location for the maximum length of time to wait
* in microseconds, or -1 to wait indefinitely.
*
* Is used to integrate Cogl with an application mainloop that is based
* on the unix poll(2) api (or select() or something equivalent). This
* api should be called whenever an application is about to go idle so
* that Cogl has a chance to describe what file descriptor events it
* needs to be woken up for.
*
* If your application is using the Glib mainloop then you
* should jump to the cogl_glib_source_new() api as a more convenient
* way of integrating Cogl with the mainloop.
*
* @timeout will contain a maximum amount of time to wait in
* microseconds before the application should wake up or -1 if the
* application should wait indefinitely. This can also be 0 if
* Cogl needs to be woken up immediately.
*/ */
COGL_EXPORT void COGL_EXPORT gboolean
cogl_poll_renderer_get_info (CoglRenderer *renderer, cogl_poll_renderer_has_idle_closures (CoglRenderer *renderer);
int64_t *timeout);
/** /**
* cogl_poll_renderer_dispatch: * cogl_poll_renderer_dispatch: