Commit 8a5f5023 authored by Alexandros Frantzis's avatar Alexandros Frantzis

surfaceless_egl: Implement resize functionality

Add support for the waffle_window_resize() function when using the EGL
surfaceless platform. This is achieved by recreating the backing pbuffer
with the new size, and rebinding it to the current context.
Signed-off-by: Alexandros Frantzis's avatarAlexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: default avatarEmil Velikov <emil.velikov@collabora.com>
parent 64c429f5
......@@ -138,6 +138,7 @@ static const struct wcore_platform_vtbl sl_platform_vtbl = {
.create = sl_window_create,
.destroy = sl_window_destroy,
.show = sl_window_show,
.resize = sl_window_resize,
.swap_buffers = wegl_surface_swap_buffers,
.get_native = NULL, // unsupported by platform
},
......
......@@ -28,8 +28,10 @@
#include "wcore_attrib_list.h"
#include "wcore_error.h"
#include "wcore_tinfo.h"
#include "wegl_config.h"
#include "wegl_util.h"
#include "sl_display.h"
#include "sl_platform.h"
......@@ -78,6 +80,8 @@ sl_window_create(struct wcore_platform *wc_plat,
if (!ok)
goto error;
self->wc_config = wc_config;
return &self->wegl.wcore;
error:
......@@ -90,3 +94,37 @@ sl_window_show(struct wcore_window *wc_self)
{
return true;
}
bool
sl_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 sl_window *self = sl_window(wegl_surface(wc_self));
struct wegl_surface new_wegl;
struct wcore_context *wc_ctx;
struct wcore_tinfo *tinfo;
bool ok = true;
// Create a new pbuffer for the resized window.
ok = wegl_pbuffer_init(&new_wegl, self->wc_config, width, height);
if (!ok)
return false;
tinfo = wcore_tinfo_get();
wc_ctx = tinfo->current_context;
ok = wegl_make_current(wc_plat, wc_dpy, &new_wegl.wcore, wc_ctx);
if (!ok)
goto error;
// Everything went fine, so teardown the old pbuffer, and set the new one.
wegl_surface_teardown(&self->wegl);
self->wegl = new_wegl;
return true;
error:
wegl_surface_teardown(&new_wegl);
return false;
}
......@@ -33,6 +33,7 @@ struct wcore_platform;
struct sl_window {
struct wegl_surface wegl;
struct wcore_config *wc_config;
};
DEFINE_CONTAINER_CAST_FUNC(sl_window,
......@@ -51,3 +52,7 @@ sl_window_destroy(struct wcore_window *wc_self);
bool
sl_window_show(struct wcore_window *wc_self);
bool
sl_window_resize(struct wcore_window *wc_self,
int32_t width, int32_t height);
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