[Mesa-dev] [PATCH] wayland/egl: initialize window surface size to window size

Juan A. Suarez Romero jasuarez at igalia.com
Thu May 31 15:44:56 UTC 2018


When creating a windows surface with eglCreatesWindowSurface(), the
width and height returned by eglQuerySurface(EGL_{WIDTH,HEIGHT}) is
invalid until buffers are updated (like calling glClear()).

Likewise, on top of above resizing the Wayland window and quering again
the surface size, returns the old size, until buffers are updated again.

This commit fixes this situation, returning in both cases the right
surface size, without requiring updating the buffers.

This fixes the following OpenGL CTS tests when runnig in Wayland:

- dEQP-EGL.functional.color_clears.*
- dEQP-EGL.functional.resize.surface_size.*

CC: Daniel Stone <daniel at fooishbar.org>
---
 src/egl/drivers/dri2/platform_wayland.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
index 63da21cdf55..f86c6dd1e52 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -198,6 +198,8 @@ resize_callback(struct wl_egl_window *wl_win, void *data)
    struct dri2_egl_display *dri2_dpy =
       dri2_egl_display(dri2_surf->base.Resource.Display);
 
+   dri2_surf->base.Width = wl_win->width;
+   dri2_surf->base.Height = wl_win->height;
    dri2_dpy->flush->invalidate(dri2_surf->dri_drawable);
 }
 
@@ -255,6 +257,12 @@ dri2_wl_create_window_surface(_EGLDriver *drv, _EGLDisplay *disp,
       goto cleanup_surf;
    }
 
+   dri2_surf->base.Width = window->width;
+   dri2_surf->base.Height = window->height;
+
+   window->attached_width = dri2_surf->base.Width;
+   window->attached_height = dri2_surf->base.Height;
+
    visual_idx = dri2_wl_visual_idx_from_config(dri2_dpy, config);
    assert(visual_idx != -1);
 
@@ -574,8 +582,8 @@ update_buffers(struct dri2_egl_surface *dri2_surf)
    struct dri2_egl_display *dri2_dpy =
       dri2_egl_display(dri2_surf->base.Resource.Display);
 
-   if (dri2_surf->base.Width != dri2_surf->wl_win->width ||
-       dri2_surf->base.Height != dri2_surf->wl_win->height) {
+   if (dri2_surf->wl_win->attached_width != dri2_surf->wl_win->width ||
+       dri2_surf->wl_win->attached_height != dri2_surf->wl_win->height) {
 
       dri2_wl_release_buffers(dri2_surf);
 
@@ -1629,8 +1637,8 @@ swrast_update_buffers(struct dri2_egl_surface *dri2_surf)
    if (dri2_surf->back)
       return 0;
 
-   if (dri2_surf->base.Width != dri2_surf->wl_win->width ||
-       dri2_surf->base.Height != dri2_surf->wl_win->height) {
+   if (dri2_surf->wl_win->attached_width != dri2_surf->wl_win->width ||
+       dri2_surf->wl_win->attached_height != dri2_surf->wl_win->height) {
 
       dri2_wl_release_buffers(dri2_surf);
 
-- 
2.17.0



More information about the mesa-dev mailing list