xwayland/present: Redirect surface window as needed for page flips

It's needed when the surface window is a depth 24 descendant of a depth
32 toplevel window.

xwl_source_validate ensures the toplevel window pixmap has valid
contents when a client reads from it, or when the window hierarchy /
geometry changes. It's never called in the normal fullscreen application
case, so there's no GPU copy overhead with that.

v2:
* Don't try to redirect a depth 32 descendant of different-depth
  ancestors, the alpha channel wouldn't be handled correctly.
  (Olivier Fourdan)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1300>
This commit is contained in:
Michel Dänzer 2024-02-15 18:34:13 +01:00 committed by Marge Bot
parent 4495c696b5
commit c7d56b0e29

View File

@ -46,6 +46,7 @@
#include "xwayland-dmabuf.h"
#include "xwayland-glamor.h"
#include "xwayland-glamor-gbm.h"
#include "xwayland-present.h"
#include "xwayland-screen.h"
#include "xwayland-window.h"
#include "xwayland-window-buffers.h"
@ -96,8 +97,12 @@ xwl_glamor_check_flip(WindowPtr present_window, PixmapPtr pixmap)
ScreenPtr screen = pixmap->drawable.pScreen;
PixmapPtr backing_pixmap = screen->GetWindowPixmap(present_window);
if (pixmap->drawable.depth != backing_pixmap->drawable.depth)
return FALSE;
if (pixmap->drawable.depth != backing_pixmap->drawable.depth) {
if (pixmap->drawable.depth == 32)
return FALSE;
return xwl_present_maybe_redirect_window(present_window, pixmap);
}
return TRUE;
}