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:
parent
1ceb206897
commit
24c338cc0e
4 changed files with 12 additions and 48 deletions
|
@ -46,12 +46,8 @@ static gboolean
|
|||
cogl_glib_source_prepare (GSource *source, int *timeout)
|
||||
{
|
||||
CoglGLibSource *cogl_source = (CoglGLibSource *) source;
|
||||
int64_t cogl_timeout;
|
||||
|
||||
cogl_poll_renderer_get_info (cogl_source->renderer,
|
||||
&cogl_timeout);
|
||||
|
||||
if (cogl_timeout == -1)
|
||||
if (!cogl_poll_renderer_has_idle_closures (cogl_source->renderer))
|
||||
{
|
||||
*timeout = -1;
|
||||
cogl_source->expiration_time = -1;
|
||||
|
@ -59,9 +55,8 @@ cogl_glib_source_prepare (GSource *source, int *timeout)
|
|||
else
|
||||
{
|
||||
/* Round up to ensure that we don't try again too early */
|
||||
*timeout = (cogl_timeout + 999) / 1000;
|
||||
cogl_source->expiration_time = (g_source_get_time (source) +
|
||||
cogl_timeout);
|
||||
*timeout = 999 / 1000;
|
||||
cogl_source->expiration_time = g_source_get_time (source);
|
||||
}
|
||||
|
||||
return *timeout == 0;
|
||||
|
|
|
@ -46,11 +46,7 @@ G_BEGIN_DECLS
|
|||
* @priority: The priority of the #GSource
|
||||
*
|
||||
* Creates a #GSource which handles Cogl's internal system event
|
||||
* processing. This can be used as a convenience instead of
|
||||
* 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().
|
||||
* processing.
|
||||
*
|
||||
* Applications that manually connect to a #CoglRenderer before they
|
||||
* create a #CoglContext should instead use
|
||||
|
@ -74,11 +70,7 @@ cogl_glib_source_new (CoglContext *context,
|
|||
* @priority: The priority of the #GSource
|
||||
*
|
||||
* Creates a #GSource which handles Cogl's internal system event
|
||||
* processing. This can be used as a convenience instead of
|
||||
* 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().
|
||||
* processing
|
||||
*
|
||||
* Return value: a new #GSource
|
||||
*/
|
||||
|
|
|
@ -37,17 +37,12 @@
|
|||
#include "cogl/cogl-renderer-private.h"
|
||||
#include "cogl/winsys/cogl-winsys-private.h"
|
||||
|
||||
void
|
||||
cogl_poll_renderer_get_info (CoglRenderer *renderer,
|
||||
int64_t *timeout)
|
||||
gboolean
|
||||
cogl_poll_renderer_has_idle_closures (CoglRenderer *renderer)
|
||||
{
|
||||
g_return_if_fail (COGL_IS_RENDERER (renderer));
|
||||
g_return_if_fail (timeout != NULL);
|
||||
g_return_val_if_fail (COGL_IS_RENDERER (renderer), FALSE);
|
||||
|
||||
*timeout = -1;
|
||||
|
||||
if (!_cogl_list_empty (&renderer->idle_closures))
|
||||
*timeout = 0;
|
||||
return !_cogl_list_empty (&renderer->idle_closures);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -65,29 +65,11 @@ G_BEGIN_DECLS
|
|||
|
||||
|
||||
/**
|
||||
* cogl_poll_renderer_get_info:
|
||||
* cogl_poll_renderer_has_idle_closures:
|
||||
* @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_poll_renderer_get_info (CoglRenderer *renderer,
|
||||
int64_t *timeout);
|
||||
COGL_EXPORT gboolean
|
||||
cogl_poll_renderer_has_idle_closures (CoglRenderer *renderer);
|
||||
|
||||
/**
|
||||
* cogl_poll_renderer_dispatch:
|
||||
|
|
Loading…
Reference in a new issue