[waffle] [PATCH 03/12] core: store current context in wcore_display

Emil Velikov emil.l.velikov at gmail.com
Fri Jan 8 04:15:18 PST 2016


On 6 January 2016 at 21:56, Frank Henigman <fjhenigman at google.com> wrote:
> For core functions that need to know the current context, like the
> forthcoming wflinfo-like function.
>
> Signed-off-by: Frank Henigman <fjhenigman at google.com>
> ---
>  src/waffle/api/waffle_gl_misc.c | 11 +++++++----
>  src/waffle/core/wcore_display.c |  1 +
>  src/waffle/core/wcore_display.h |  2 ++
>  3 files changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/src/waffle/api/waffle_gl_misc.c b/src/waffle/api/waffle_gl_misc.c
> index 138974d..4161ce8 100644
> --- a/src/waffle/api/waffle_gl_misc.c
> +++ b/src/waffle/api/waffle_gl_misc.c
> @@ -94,10 +94,13 @@ waffle_make_current(
>      if (!api_check_entry(obj_list, len))
>          return false;
>
> -    return api_platform->vtbl->make_current(api_platform,
> -                                            wc_dpy,
> -                                            wc_window,
> -                                            wc_ctx);
> +    bool ok = api_platform->vtbl->make_current(api_platform,
> +                                               wc_dpy,
> +                                               wc_window,
> +                                               wc_ctx);
> +    if (ok)
> +        wc_dpy->current_context = wc_ctx;
> +    return ok;
>  }
>
>  WAFFLE_API void*
> diff --git a/src/waffle/core/wcore_display.c b/src/waffle/core/wcore_display.c
> index 18262c3..bcaeacb 100644
> --- a/src/waffle/core/wcore_display.c
> +++ b/src/waffle/core/wcore_display.c
> @@ -52,6 +52,7 @@ wcore_display_init(struct wcore_display *self,
>      mtx_unlock(&mutex);
>
>      self->platform = platform;
> +    self->current_context = NULL;
We calloc the struct so we should need this ?

>
>      if (self->api.display_id == 0) {
>          fprintf(stderr, "waffle: error: internal counter wrapped to 0\n");
> diff --git a/src/waffle/core/wcore_display.h b/src/waffle/core/wcore_display.h
> index 6e374e3..1ccff6f 100644
> --- a/src/waffle/core/wcore_display.h
> +++ b/src/waffle/core/wcore_display.h
> @@ -37,12 +37,14 @@
>  extern "C" {
>  #endif
>
> +struct wcore_context;
>  struct wcore_display;
>  struct wcore_platform;
>  union waffle_native_display;
>
>  struct wcore_display {
>      struct api_object api;
> +    struct wcore_context *current_context;
Not 100% if wcore_display is the "right" struct, but keeping a
reference in waffle sounds great imho. The alternative (using every
permutation of GetCurrentContext) does feel like an overkill.

-Emil


More information about the waffle mailing list