xserver: Branch 'server-1.20-branch' - 6 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Sep 30 15:16:23 UTC 2020


 glamor/glamor_rects.c            |   18 ++++++++++++++----
 hw/xfree86/ramdac/xf86CursorRD.c |    3 +++
 hw/xwayland/xwayland-present.c   |    8 ++++++++
 hw/xwayland/xwayland.c           |   13 -------------
 present/present_wnmd.c           |    8 ++++----
 5 files changed, 29 insertions(+), 21 deletions(-)

New commits:
commit d108c2c82cba242ea5998d7c91254d90d3a5db71
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Fri Sep 11 11:30:18 2020 +0200

    xwayland: Do not discard frame callbacks on allow commits
    
    Currently, when a X11 client (usually the X11 window manager from a
    Wayland compositor) changes the value of the X11 property
    `_XWAYLAND_ALLOW_COMMITS` from `false` to `true`, all pending frame
    callbacks on the window are discarded so that the commit occurs
    immediately.
    
    Weston uses that mechanism to prevent the content of the window from
    showing before it's ready when mapping the window initially, but
    discarding the pending frame callbacks has no effect on the initial
    mapping of the X11 window since at that point there cannot be any frame
    callback on a surface which hasn't been committed yet anyway.
    
    However, discarding pending frame callbacks can be problematic if we
    were to use the same `_XWAYLAND_ALLOW_COMMITS` mechanism to prevent
    damages to be posted before the X11 toplevel is updated completely
    (including the window decorations from the X11 window manager).
    
    Remove the portion of code discarding the pending frame callback,
    Xwayland should always wait for a pending frame callback if there's one
    before posting new damages.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Reviewed-by: Pekka Paalanen <pekka.paalanen at collabora.com>
    Reviewed-by: Michel Dänzer <mdaenzer at redhat.com>
    https://gitlab.freedesktop.org/xorg/xserver/merge_requests/333
    (cherry picked from commit 66da95a172c4941b75ffedcdaa0138c0a48f11fb)

diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c
index d02934cd5..a69188c0f 100644
--- a/hw/xwayland/xwayland.c
+++ b/hw/xwayland/xwayland.c
@@ -193,8 +193,6 @@ static void
 xwl_window_property_allow_commits(struct xwl_window *xwl_window,
                                   PropertyStateRec *propstate)
 {
-    Bool old_allow_commits = xwl_window->allow_commits;
-
     switch (propstate->state) {
     case PropertyNewValue:
         xwl_window_set_allow_commits_from_property(xwl_window, propstate->prop);
@@ -207,17 +205,6 @@ xwl_window_property_allow_commits(struct xwl_window *xwl_window,
     default:
         break;
     }
-
-    /* If allow_commits turned from off to on, discard any frame
-     * callback we might be waiting for so that a new buffer is posted
-     * immediately through block_handler() if there is damage to post.
-     */
-    if (!old_allow_commits && xwl_window->allow_commits) {
-        if (xwl_window->frame_callback) {
-            wl_callback_destroy(xwl_window->frame_callback);
-            xwl_window->frame_callback = NULL;
-        }
-    }
 }
 
 static void
commit 174cb91d82d643f78d8ba2b9999312b9d7dea98c
Author: Michel Dänzer <mdaenzer at redhat.com>
Date:   Mon Sep 7 18:40:34 2020 +0200

    present/wnmd: Remove dead check from present_wnmd_check_flip
    
    present_wnmd_toplvl_pixmap_window returns a window with the same window
    pixmap, so the check could never fail.
    
    Reviewed-by: Roman Gilg <subdiff at gmail.com>
    (cherry picked from commit b6b1161fd7ac409156fb69439897bcabdeacf393)

diff --git a/present/present_wnmd.c b/present/present_wnmd.c
index 6a3d1035b..35ea12968 100644
--- a/present/present_wnmd.c
+++ b/present/present_wnmd.c
@@ -270,10 +270,6 @@ present_wnmd_check_flip(RRCrtcPtr           crtc,
     if (!screen_priv->wnmd_info->flip)
         return FALSE;
 
-    /* Can't flip redirected child windows */
-    if (screen->GetWindowPixmap(window) != screen->GetWindowPixmap(toplvl_window))
-        return FALSE;
-
     /* Source pixmap must align with window exactly */
     if (x_off || y_off)
         return FALSE;
commit 51ee6e5ceb0cacc8e2fa225ad5391ffb159e36a0
Author: Michel Dänzer <mdaenzer at redhat.com>
Date:   Mon Sep 7 18:39:17 2020 +0200

    xwayland: Check window pixmap in xwl_present_check_flip2
    
    We can only flip if the window pixmap matches that of the toplevel
    window. Doing so regardless could cause the toplevel window pixmap to
    get destroyed while it was still referenced by the window, resulting in
    use-after-free and likely a crash.
    
    Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1033
    Reviewed-by: Olivier Fourdan <ofourdan at redhat.com>
    Reviewed-by: Roman Gilg <subdiff at gmail.com>
    (cherry picked from commit 4c25356d6cd908c5030c70e712076dff318ac00d)

diff --git a/hw/xwayland/xwayland-present.c b/hw/xwayland/xwayland-present.c
index 6076f6498..d177abdd8 100644
--- a/hw/xwayland/xwayland-present.c
+++ b/hw/xwayland/xwayland-present.c
@@ -421,10 +421,18 @@ xwl_present_check_flip2(RRCrtcPtr crtc,
                         PresentFlipReason *reason)
 {
     struct xwl_window *xwl_window = xwl_window_from_window(present_window);
+    ScreenPtr screen = pixmap->drawable.pScreen;
 
     if (!xwl_window)
         return FALSE;
 
+    /* Can't flip if the window pixmap doesn't match the xwl_window parent
+     * window's, e.g. because a client redirected this window or one of its
+     * parents.
+     */
+    if (screen->GetWindowPixmap(xwl_window->window) != screen->GetWindowPixmap(present_window))
+        return FALSE;
+
     /*
      * We currently only allow flips of windows, that have the same
      * dimensions as their xwl_window parent window. For the case of
commit f4006d795cb199bf7deeb00f542c592db6a5becb
Author: Michel Dänzer <mdaenzer at redhat.com>
Date:   Mon Sep 7 18:35:10 2020 +0200

    present/wnmd: Can't use page flipping for windows clipped by children
    
    Noticed this was missing while working on the following fix.
    
    v2:
    * Dropped present_wnmd_can_window_flip hunk (that function is never
      called, will be cleaned up in a follow-up MR).
    
    Reviewed-by: Olivier Fourdan <ofourdan at redhat.com> # v1
    Reviewed-by: Roman Gilg <subdiff at gmail.com>
    (cherry picked from commit 7ac303c7b1e3b1be79ba3648e217798683e65a99)

diff --git a/present/present_wnmd.c b/present/present_wnmd.c
index 32c4d55f1..6a3d1035b 100644
--- a/present/present_wnmd.c
+++ b/present/present_wnmd.c
@@ -291,6 +291,10 @@ present_wnmd_check_flip(RRCrtcPtr           crtc,
     if ( !RegionEqual(&window->winSize, &toplvl_window->winSize) )
         return FALSE;
 
+    /* Can't flip if window clipped by children */
+    if (!RegionEqual(&window->clipList, &window->winSize))
+        return FALSE;
+
     /* Ask the driver for permission */
     if (screen_priv->wnmd_info->check_flip2) {
         if (!(*screen_priv->wnmd_info->check_flip2) (crtc, window, pixmap, sync_flip, reason)) {
commit 1e84fda2020b12a83c6b9c6d31ab84f993c6176c
Author: Michel Dänzer <mdaenzer at redhat.com>
Date:   Tue Sep 1 11:24:57 2020 +0200

    xfree86: Take second reference for SavedCursor in xf86CursorSetCursor
    
    The same pointer is kept in CurrentCursor as well, therefore two
    RefCursor calls are needed.
    
    Fixes use-after-free after switching VTs.
    
    Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1067
    (cherry picked from commit 919f1f46fc67dae93b2b3f278fcbfc77af34ec58)

diff --git a/hw/xfree86/ramdac/xf86CursorRD.c b/hw/xfree86/ramdac/xf86CursorRD.c
index ee1d98916..02dab36fe 100644
--- a/hw/xfree86/ramdac/xf86CursorRD.c
+++ b/hw/xfree86/ramdac/xf86CursorRD.c
@@ -334,6 +334,9 @@ xf86CursorSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCurs,
         ScreenPriv->HotY = cursor->bits->yhot;
 
         if (!infoPtr->pScrn->vtSema) {
+            cursor = RefCursor(cursor);
+            if (ScreenPriv->SavedCursor)
+                FreeCursor(ScreenPriv->SavedCursor, None);
             ScreenPriv->SavedCursor = cursor;
             return;
         }
commit 8c3c8bda2c44fb3d62b954b02b08e3b1771ef5bc
Author: Michel Dänzer <mdaenzer at redhat.com>
Date:   Tue Aug 25 17:26:56 2020 +0200

    glamor: Fix glamor_poly_fill_rect_gl xRectangle::width/height handling
    
    (Using GLSL 1.30 or newer)
    
    The width/height members of xRectangle are unsigned, but they were
    being interpreted as signed when converting to floating point for the
    vertex shader, producing incorrect drawing for values > 32767.
    
    v2:
    * Use separate GL_UNSIGNED_SHORT vertex attribute for width/height.
      (Eric Anholt)
    
    Reviewed-by: Eric Anholt <eric at anholt.net>
    (cherry picked from commit 032af35657aa95c6bbdb74ff8c72e535b9b56cfa)

diff --git a/glamor/glamor_rects.c b/glamor/glamor_rects.c
index 6cbb040c1..ae4fe8bcc 100644
--- a/glamor/glamor_rects.c
+++ b/glamor/glamor_rects.c
@@ -27,8 +27,10 @@
 static const glamor_facet glamor_facet_polyfillrect_130 = {
     .name = "poly_fill_rect",
     .version = 130,
-    .vs_vars = "attribute vec4 primitive;\n",
-    .vs_exec = ("       vec2 pos = primitive.zw * vec2(gl_VertexID&1, (gl_VertexID&2)>>1);\n"
+    .source_name = "size",
+    .vs_vars = "attribute vec2 primitive;\n"
+               "attribute vec2 size;\n",
+    .vs_exec = ("       vec2 pos = size * vec2(gl_VertexID&1, (gl_VertexID&2)>>1);\n"
                 GLAMOR_POS(gl_Position, (primitive.xy + pos))),
 };
 
@@ -81,9 +83,14 @@ glamor_poly_fill_rect_gl(DrawablePtr drawable,
 
         glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
         glVertexAttribDivisor(GLAMOR_VERTEX_POS, 1);
-        glVertexAttribPointer(GLAMOR_VERTEX_POS, 4, GL_SHORT, GL_FALSE,
+        glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_SHORT, GL_FALSE,
                               4 * sizeof (short), vbo_offset);
 
+        glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+        glVertexAttribDivisor(GLAMOR_VERTEX_SOURCE, 1);
+        glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_UNSIGNED_SHORT, GL_FALSE,
+                              4 * sizeof (short), vbo_offset + 2 * sizeof (short));
+
         memcpy(v, prect, nrect * sizeof (xRectangle));
 
         glamor_put_vbo_space(screen);
@@ -156,8 +163,11 @@ glamor_poly_fill_rect_gl(DrawablePtr drawable,
 
 bail:
     glDisable(GL_SCISSOR_TEST);
-    if (glamor_priv->glsl_version >= 130)
+    if (glamor_priv->glsl_version >= 130) {
+        glVertexAttribDivisor(GLAMOR_VERTEX_SOURCE, 0);
+        glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
         glVertexAttribDivisor(GLAMOR_VERTEX_POS, 0);
+    }
     glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
 
     return ret;


More information about the xorg-commit mailing list