Commit 3585a41b authored by Emil Velikov's avatar Emil Velikov Committed by Emil Velikov

gbm: implement window_resize

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.

v2: attribute the wegl_window -> wegl_surface rename
Signed-off-by: default avatarEmil Velikov <emil.velikov@collabora.com>
parent 6695ab42
......@@ -205,6 +205,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,
},
};
......@@ -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;
// Everything went fine, so teardown the old window.
wgbm_window_teardown(&backup_self);
return true;
error:
// Nuke the new window and restore the old one.
wgbm_window_teardown(self);
*self = backup_self;
return false;
}
union waffle_native_window*
wgbm_window_get_native(struct wcore_window *wc_self)
......
......@@ -35,6 +35,7 @@ struct gbm_surface;
struct wgbm_window {
struct gbm_surface *gbm_surface;
struct wegl_surface wegl;
struct wcore_config *wc_config;
};
static inline struct wgbm_window*
......@@ -65,5 +66,9 @@ wgbm_window_show(struct wcore_window *wc_self);
bool
wgbm_window_swap_buffers(struct wcore_window *wc_self);
bool
wgbm_window_resize(struct wcore_window *wc_self,
int32_t width, int32_t height);
union waffle_native_window*
wgbm_window_get_native(struct wcore_window *wc_self);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment