[Cogl] [PATCH 3/3] sdl: Wakeup the event blocking immediately if necessary

Robert Bragg robert at sixbynine.org
Thu Jan 31 13:05:07 PST 2013


This looks good to land to me:

Reviewed-by: Robert Bragg <robert at linux.intel.com>

thanks,
- Robert

On Thu, Jan 31, 2013 at 4:53 PM, Neil Roberts <neil at linux.intel.com> wrote:
> It is expected that cogl_sdl_idle() will be called from the
> application immediately before blocking in SDL_WaitEvent. However,
> dispatching the onscreen events may cause more events to be queued. If
> that happens we need to make sure the blocking returns immediately.
> This patch makes it post the dummy event that the application chose in
> order to make that happen.
> ---
>  cogl/cogl-sdl.c | 21 ++++++++++++++++++++-
>  1 file changed, 20 insertions(+), 1 deletion(-)
>
> diff --git a/cogl/cogl-sdl.c b/cogl/cogl-sdl.c
> index b49890f..8e04f16 100644
> --- a/cogl/cogl-sdl.c
> +++ b/cogl/cogl-sdl.c
> @@ -3,7 +3,7 @@
>   *
>   * An object oriented GL/GLES Abstraction/Utility Layer
>   *
> - * Copyright (C) 2012 Intel Corporation.
> + * Copyright (C) 2012, 2013 Intel Corporation.
>   *
>   * This library is free software; you can redistribute it and/or
>   * modify it under the terms of the GNU Lesser General Public
> @@ -80,8 +80,27 @@ cogl_sdl_handle_event (CoglContext *context, SDL_Event *event)
>      winsys->poll_dispatch (context, NULL, 0);
>  }
>
> +static void
> +_cogl_sdl_push_wakeup_event (CoglContext *context)
> +{
> +  SDL_Event wakeup_event;
> +
> +  wakeup_event.type = context->display->renderer->sdl_event_type;
> +
> +  SDL_PushEvent (&wakeup_event);
> +}
> +
>  void
>  cogl_sdl_idle (CoglContext *context)
>  {
>    _cogl_dispatch_onscreen_events (context);
> +
> +  /* It is expected that this will be called from the application
> +   * immediately before blocking in SDL_WaitEvent. However,
> +   * dispatching the onscreen events may cause more events to be
> +   * queued. If that happens we need to make sure the blocking returns
> +   * immediately. We'll post our dummy event to make sure that
> +   * happens */
> +  if (!COGL_TAILQ_EMPTY (&context->onscreen_events_queue))
> +    _cogl_sdl_push_wakeup_event (context);
>  }
> --
> 1.7.11.3.g3c3efa5
>
> _______________________________________________
> Cogl mailing list
> Cogl at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/cogl


More information about the Cogl mailing list