[waffle] [PATCH 4/4] gbm: implement window_resize

Emil Velikov emil.l.velikov at gmail.com
Tue Jun 14 21:11:57 UTC 2016


On 16 May 2016 at 11:48, Emil Velikov <emil.l.velikov at gmail.com> wrote:
> From: Emil Velikov <emil.velikov at collabora.com>
>
> Reuse the existing init/teardown functions to create a new window and
> nuke the old one on success.
>
> Note: as we need the original config, we keep a reference to it in
> struct wcore_config. Ideally there will be a generic way to query it.
>
> Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
> ---
>  src/waffle/gbm/wgbm_platform.c |  1 +
>  src/waffle/gbm/wgbm_window.c   | 43 ++++++++++++++++++++++++++++++++++++++++++
>  src/waffle/gbm/wgbm_window.h   |  5 +++++
>  3 files changed, 49 insertions(+)
>
> diff --git a/src/waffle/gbm/wgbm_platform.c b/src/waffle/gbm/wgbm_platform.c
> index 5e36534..f4147af 100644
> --- a/src/waffle/gbm/wgbm_platform.c
> +++ b/src/waffle/gbm/wgbm_platform.c
> @@ -210,6 +210,7 @@ static const struct wcore_platform_vtbl wgbm_platform_vtbl = {
>          .destroy = wgbm_window_destroy,
>          .show = wgbm_window_show,
>          .swap_buffers = wgbm_window_swap_buffers,
> +        .resize = wgbm_window_resize,
>          .get_native = wgbm_window_get_native,
>      },
>  };
> diff --git a/src/waffle/gbm/wgbm_window.c b/src/waffle/gbm/wgbm_window.c
> index 12ae197..d9dcba0 100644
> --- a/src/waffle/gbm/wgbm_window.c
> +++ b/src/waffle/gbm/wgbm_window.c
> @@ -32,8 +32,10 @@
>
>  #include "wcore_attrib_list.h"
>  #include "wcore_error.h"
> +#include "wcore_tinfo.h"
>
>  #include "wegl_config.h"
> +#include "wegl_util.h"
>
>  #include "wgbm_config.h"
>  #include "wgbm_display.h"
> @@ -92,6 +94,7 @@ wgbm_window_init(struct wgbm_window *self,
>      if (!ok)
>          return false;
>
> +    self->wc_config = wc_config;
>      return true;
>  }
>
> @@ -155,6 +158,46 @@ wgbm_window_swap_buffers(struct wcore_window *wc_self)
>      return true;
>  }
>
> +bool
> +wgbm_window_resize(struct wcore_window *wc_self,
> +                   int32_t width, int32_t height)
> +{
> +    struct wcore_display *wc_dpy = wc_self->display;
> +    struct wcore_platform *wc_plat = wc_self->display->platform;
> +    struct wgbm_window *self = wgbm_window(wc_self);
> +    struct wgbm_window backup_self;
> +    struct wcore_context *wc_ctx;
> +    struct wcore_tinfo *tinfo;
> +    bool ok = true;
> +
> +    // Backup the old window/surface so that we can restore it upon failure.
> +    backup_self = *self;
> +
> +    ok = wgbm_window_init(self, wc_plat, self->wc_config, width, height);
> +    if (!ok)
> +        goto error;
> +
> +    tinfo = wcore_tinfo_get();
> +    wc_ctx = tinfo->current_context;
> +
> +    // XXX: Can/should we use waffle_make_current() here ?
> +    ok = wegl_make_current(wc_plat, wc_dpy, wc_self, wc_ctx);
> +    if (!ok)
> +        goto error;
> +
> +    // We don't need to set current_display or current_window
> +    tinfo->current_context = wc_ctx;
> +
Self note: in 99.99% of the time we won't need the above line. Thus we
could drop the XXX: comment a couple of lines before it.

Note for all: I'm wondering if some drivers won't have odd behaviour
if waffle_window_resize() is called where wc_ctx = NULL. Not 100%
familiar if the spec ensures that things are sane.

Any ideas ?

Emil


More information about the waffle mailing list