mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 06:58:05 +02:00
egl/wayland: Allow EGLSurface to outlive wl_egl_window
According to the EGL spec, it is entirely valid for an EGLSurface to
outlive the native_window it was created from, provided that SwapBuffers
and MakeCurrent return EGL_BAD_NATIVE_WINDOW.
We don't have any facility to error on MakeCurrent, so just make sure we
can bundle on safely through rendering for now, then return
EGL_BAD_NATIVE_WINDOW from SwapBuffers.
Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Simon Ser <contact@emersion.fr>
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2251
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4902
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11979>
(cherry picked from commit 6455ab6e5a)
This commit is contained in:
parent
b14aa26023
commit
39fbc74348
2 changed files with 16 additions and 7 deletions
|
|
@ -535,7 +535,7 @@
|
|||
"description": "egl/wayland: Allow EGLSurface to outlive wl_egl_window",
|
||||
"nominated": true,
|
||||
"nomination_type": 0,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": null
|
||||
},
|
||||
|
|
|
|||
|
|
@ -677,8 +677,9 @@ 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 &&
|
||||
(dri2_surf->base.Width != dri2_surf->wl_win->width ||
|
||||
dri2_surf->base.Height != dri2_surf->wl_win->height)) {
|
||||
|
||||
dri2_surf->base.Width = dri2_surf->wl_win->width;
|
||||
dri2_surf->base.Height = dri2_surf->wl_win->height;
|
||||
|
|
@ -686,8 +687,9 @@ update_buffers(struct dri2_egl_surface *dri2_surf)
|
|||
dri2_surf->dy = dri2_surf->wl_win->dy;
|
||||
}
|
||||
|
||||
if (dri2_surf->base.Width != dri2_surf->wl_win->attached_width ||
|
||||
dri2_surf->base.Height != dri2_surf->wl_win->attached_height) {
|
||||
if (dri2_surf->wl_win &&
|
||||
(dri2_surf->base.Width != dri2_surf->wl_win->attached_width ||
|
||||
dri2_surf->base.Height != dri2_surf->wl_win->attached_height)) {
|
||||
dri2_wl_release_buffers(dri2_surf);
|
||||
}
|
||||
|
||||
|
|
@ -1067,6 +1069,9 @@ dri2_wl_swap_buffers_with_damage(_EGLDisplay *disp,
|
|||
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
|
||||
struct dri2_egl_surface *dri2_surf = dri2_egl_surface(draw);
|
||||
|
||||
if (!dri2_surf->wl_win)
|
||||
return _eglError(EGL_BAD_NATIVE_WINDOW, "dri2_swap_buffers");
|
||||
|
||||
while (dri2_surf->throttle_callback != NULL)
|
||||
if (wl_display_dispatch_queue(dri2_dpy->wl_dpy,
|
||||
dri2_surf->wl_queue) == -1)
|
||||
|
|
@ -1710,8 +1715,9 @@ 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 &&
|
||||
(dri2_surf->base.Width != dri2_surf->wl_win->width ||
|
||||
dri2_surf->base.Height != dri2_surf->wl_win->height)) {
|
||||
|
||||
dri2_wl_release_buffers(dri2_surf);
|
||||
|
||||
|
|
@ -1957,6 +1963,9 @@ dri2_wl_swrast_swap_buffers(_EGLDisplay *disp, _EGLSurface *draw)
|
|||
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
|
||||
struct dri2_egl_surface *dri2_surf = dri2_egl_surface(draw);
|
||||
|
||||
if (!dri2_surf->wl_win)
|
||||
return _eglError(EGL_BAD_NATIVE_WINDOW, "dri2_swap_buffers");
|
||||
|
||||
dri2_dpy->core->swapBuffers(dri2_surf->dri_drawable);
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue