xserver: Branch 'master' - 11 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jul 18 09:38:56 UTC 2023


 composite/compinit.c             |    1 
 composite/compositeext.h         |    2 
 composite/compwindow.c           |    8 +-
 glamor/glamor_composite_glyphs.c |    2 
 glamor/glamor_copy.c             |   26 ++++----
 glamor/glamor_dash.c             |    8 +-
 glamor/glamor_glyphblt.c         |    4 -
 glamor/glamor_image.c            |    4 -
 glamor/glamor_lines.c            |    2 
 glamor/glamor_points.c           |    2 
 glamor/glamor_prepare.c          |   56 +++++++++---------
 glamor/glamor_program.c          |   30 ++++-----
 glamor/glamor_program.h          |    6 -
 glamor/glamor_rects.c            |    4 -
 glamor/glamor_segs.c             |    2 
 glamor/glamor_spans.c            |    4 -
 glamor/glamor_text.c             |   14 ++--
 glamor/glamor_transfer.c         |  101 ++++++++++++---------------------
 glamor/glamor_transfer.h         |   15 ----
 glamor/glamor_transform.c        |   14 ++--
 glamor/glamor_transform.h        |   12 +--
 glamor/glamor_xv.c               |   10 +--
 hw/xwayland/xwayland-glamor.c    |  118 ++++++++++++++++++++++++++++++++++++++-
 hw/xwayland/xwayland-glamor.h    |    2 
 hw/xwayland/xwayland-present.c   |    2 
 hw/xwayland/xwayland-screen.h    |    2 
 26 files changed, 268 insertions(+), 183 deletions(-)

New commits:
commit d6c5999e943e43e800f976a48e774fbef77f5ef2
Author: Michel Dänzer <mdaenzer at redhat.com>
Date:   Fri Jun 23 18:35:46 2023 +0200

    xwayland/glamor: Avoid implicit redirection with depth 32 parent windows
    
    glamor ensures that a depth 32 pixmap backing a depth 24 window contains
    fully opaque alpha channel values for the window's pixels, so we can
    allow this without implicit redirection, saving pixmap storage and
    intermediate copies.

diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index 9ac1aa8d4..c6aa8eb17 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -25,6 +25,8 @@
 
 #include <xwayland-config.h>
 
+#include <compositeext.h>
+
 #define MESA_EGL_NO_X11_HEADERS
 #define EGL_NO_X11
 #include <glamor_egl.h>
@@ -893,6 +895,108 @@ xwl_glamor_allow_commits(struct xwl_window *xwl_window)
         return TRUE;
 }
 
+static void
+xwl_avoid_implicit_redirect(WindowPtr window)
+{
+    ScreenPtr screen = window->drawable.pScreen;
+    WindowOptPtr parent_optional;
+    VisualPtr parent_visual = NULL;
+    VisualPtr window_visual = NULL;
+    DepthPtr depth32 = NULL;
+    int i;
+
+    if (!window->optional)
+        return;
+
+    parent_optional = FindWindowWithOptional(window)->optional;
+    if (window->optional == parent_optional ||
+        window->optional->visual == parent_optional->visual ||
+        CompositeIsImplicitRedirectException(screen, parent_optional->visual,
+                                             window->optional->visual))
+        return;
+
+    for (i = 0; i < screen->numDepths; i++) {
+        if (screen->allowedDepths[i].depth == 32) {
+            depth32 = &screen->allowedDepths[i];
+            break;
+        }
+    }
+
+    if (!depth32)
+        return;
+
+    for (i = 0; i < depth32->numVids; i++) {
+        XID argb_vid = depth32->vids[i];
+
+        if (argb_vid != parent_optional->visual)
+            continue;
+
+        if (!compIsAlternateVisual(screen, argb_vid))
+            break;
+
+        for (i = 0; i < screen->numVisuals; i++) {
+            if (screen->visuals[i].vid == argb_vid) {
+                parent_visual = &screen->visuals[i];
+                break;
+            }
+        }
+    }
+
+    if (!parent_visual)
+        return;
+
+    for (i = 0; i < screen->numVisuals; i++) {
+        if (screen->visuals[i].vid == window->optional->visual) {
+            window_visual = &screen->visuals[i];
+            break;
+        }
+    }
+
+    if ((window_visual->class != TrueColor &&
+         window_visual->class != DirectColor) ||
+        window_visual->redMask != parent_visual->redMask ||
+        window_visual->greenMask != parent_visual->greenMask ||
+        window_visual->blueMask != parent_visual->blueMask ||
+        window_visual->offsetRed != parent_visual->offsetRed ||
+        window_visual->offsetGreen != parent_visual->offsetGreen ||
+        window_visual->offsetBlue != parent_visual->offsetBlue)
+        return;
+
+    CompositeRegisterImplicitRedirectionException(screen, parent_visual->vid, window_visual->vid);
+}
+
+static Bool
+xwl_glamor_create_window(WindowPtr window)
+{
+    ScreenPtr screen = window->drawable.pScreen;
+    struct xwl_screen *xwl_screen = xwl_screen_get(screen);
+    Bool ret;
+
+    if (window->parent)
+        xwl_avoid_implicit_redirect(window);
+
+    screen->CreateWindow = xwl_screen->CreateWindow;
+    ret = (*screen->CreateWindow) (window);
+    xwl_screen->CreateWindow = screen->CreateWindow;
+    screen->CreateWindow = xwl_glamor_create_window;
+
+    return ret;
+}
+
+static void
+xwl_glamor_reparent_window(WindowPtr window, WindowPtr old_parent)
+{
+    ScreenPtr screen = window->drawable.pScreen;
+    struct xwl_screen *xwl_screen = xwl_screen_get(screen);
+
+    xwl_avoid_implicit_redirect(window);
+
+    screen->ReparentWindow = xwl_screen->ReparentWindow;
+    (*screen->ReparentWindow) (window, old_parent);
+    xwl_screen->ReparentWindow = screen->ReparentWindow;
+    screen->ReparentWindow = xwl_glamor_reparent_window;
+}
+
 static Bool
 xwl_glamor_create_screen_resources(ScreenPtr screen)
 {
@@ -907,6 +1011,11 @@ xwl_glamor_create_screen_resources(ScreenPtr screen)
     if (!ret)
         return ret;
 
+    xwl_screen->CreateWindow = screen->CreateWindow;
+    screen->CreateWindow = xwl_glamor_create_window;
+    xwl_screen->ReparentWindow = screen->ReparentWindow;
+    screen->ReparentWindow = xwl_glamor_reparent_window;
+
     if (xwl_screen->rootless) {
         screen->devPrivate =
             fbCreatePixmap(screen, 0, 0, screen->rootDepth, 0);
diff --git a/hw/xwayland/xwayland-screen.h b/hw/xwayland/xwayland-screen.h
index da97d7f1d..94033aabf 100644
--- a/hw/xwayland/xwayland-screen.h
+++ b/hw/xwayland/xwayland-screen.h
@@ -70,12 +70,14 @@ struct xwl_screen {
 
     CreateScreenResourcesProcPtr CreateScreenResources;
     CloseScreenProcPtr CloseScreen;
+    CreateWindowProcPtr CreateWindow;
     RealizeWindowProcPtr RealizeWindow;
     UnrealizeWindowProcPtr UnrealizeWindow;
     DestroyWindowProcPtr DestroyWindow;
     XYToWindowProcPtr XYToWindow;
     SetWindowPixmapProcPtr SetWindowPixmap;
     ChangeWindowAttributesProcPtr ChangeWindowAttributes;
+    ReparentWindowProcPtr ReparentWindow;
     ResizeWindowProcPtr ResizeWindow;
     MoveWindowProcPtr MoveWindow;
 
commit c38442bc305048dc547db711773b642a50c4cb04
Author: Michel Dänzer <mdaenzer at redhat.com>
Date:   Fri Jun 23 18:33:12 2023 +0200

    xwayland/glamor: Require equal pixmap depths in xwl_glamor_check_flip
    
    This will be needed with the next commit: If a child window completely
    obscures a toplevel ancestor of different depth, the child window can
    use page flipping only if the depth of the presented pixmap matches that
    of the window's backing pixmap, or the former may contain pixel values
    which are not suitable for the toplevel window's depth.

diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index 3c03b2523..9ac1aa8d4 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -85,9 +85,14 @@ glamor_egl_screen_init(ScreenPtr screen, struct glamor_context *glamor_ctx)
 }
 
 Bool
-xwl_glamor_check_flip(PixmapPtr pixmap)
+xwl_glamor_check_flip(WindowPtr present_window, PixmapPtr pixmap)
 {
-    struct xwl_screen *xwl_screen = xwl_screen_get(pixmap->drawable.pScreen);
+    ScreenPtr screen = pixmap->drawable.pScreen;
+    struct xwl_screen *xwl_screen = xwl_screen_get(screen);
+    PixmapPtr backing_pixmap = screen->GetWindowPixmap(present_window);
+
+    if (pixmap->drawable.depth != backing_pixmap->drawable.depth)
+        return FALSE;
 
     if (!xwl_glamor_pixmap_get_wl_buffer(pixmap))
         return FALSE;
diff --git a/hw/xwayland/xwayland-glamor.h b/hw/xwayland/xwayland-glamor.h
index 313d7faf1..183fe755a 100644
--- a/hw/xwayland/xwayland-glamor.h
+++ b/hw/xwayland/xwayland-glamor.h
@@ -149,7 +149,7 @@ Bool xwl_glamor_get_drawable_modifiers_and_scanout(DrawablePtr drawable,
                                                    Bool *supports_scanout);
 Bool xwl_glamor_get_drawable_modifiers(DrawablePtr drawable, uint32_t format,
                                        uint32_t *num_modifiers, uint64_t **modifiers);
-Bool xwl_glamor_check_flip(PixmapPtr pixmap);
+Bool xwl_glamor_check_flip(WindowPtr present_window, PixmapPtr pixmap);
 PixmapPtr xwl_glamor_create_pixmap_for_window (struct xwl_window *xwl_window);
 
 #ifdef XV
diff --git a/hw/xwayland/xwayland-present.c b/hw/xwayland/xwayland-present.c
index 42fd0067a..5ede33e4c 100644
--- a/hw/xwayland/xwayland-present.c
+++ b/hw/xwayland/xwayland-present.c
@@ -676,7 +676,7 @@ xwl_present_check_flip(RRCrtcPtr crtc,
     if (!RegionEqual(&present_window->clipList, &present_window->winSize))
         return FALSE;
 
-    if (!xwl_glamor_check_flip(pixmap))
+    if (!xwl_glamor_check_flip(present_window, pixmap))
         return FALSE;
 
     /* Can't flip if the window pixmap doesn't match the xwl_window parent
commit 9fb1f0ef22711d92f4fe8fb8fd01d22636e29910
Author: Michel Dänzer <mdaenzer at redhat.com>
Date:   Fri Jun 23 18:30:07 2023 +0200

    composite: Expose CompositeIsImplicitRedirectException
    
    Make it usable by code outside of the composite layer.

diff --git a/composite/compositeext.h b/composite/compositeext.h
index 5aad0735e..27ce7ce40 100644
--- a/composite/compositeext.h
+++ b/composite/compositeext.h
@@ -41,6 +41,8 @@ extern _X_EXPORT Bool CompositeRegisterImplicitRedirectionException(ScreenPtr pS
 
 
 extern _X_EXPORT Bool compIsAlternateVisual(ScreenPtr pScreen, XID visual);
+Bool CompositeIsImplicitRedirectException(ScreenPtr pScreen,
+                                          XID parentVisual, XID winVisual);
 extern _X_EXPORT RESTYPE CompositeClientWindowType;
 
 #endif                          /* _COMPOSITEEXT_H_ */
diff --git a/composite/compwindow.c b/composite/compwindow.c
index b30da589e..7b4af9ee5 100644
--- a/composite/compwindow.c
+++ b/composite/compwindow.c
@@ -339,9 +339,9 @@ compIsAlternateVisual(ScreenPtr pScreen, XID visual)
     return FALSE;
 }
 
-static Bool
-compIsImplicitRedirectException(ScreenPtr pScreen,
-                                XID parentVisual, XID winVisual)
+Bool
+CompositeIsImplicitRedirectException(ScreenPtr pScreen,
+                                     XID parentVisual, XID winVisual)
 {
     CompScreenPtr cs = GetCompScreen(pScreen);
     int i;
@@ -362,7 +362,7 @@ compImplicitRedirect(WindowPtr pWin, WindowPtr pParent)
         XID winVisual = wVisual(pWin);
         XID parentVisual = wVisual(pParent);
 
-        if (compIsImplicitRedirectException(pScreen, parentVisual, winVisual))
+        if (CompositeIsImplicitRedirectException(pScreen, parentVisual, winVisual))
             return FALSE;
 
         if (winVisual != parentVisual &&
commit ff0c252e57648c375bb7c4bbc1a6bd471606eb4f
Author: Michel Dänzer <mdaenzer at redhat.com>
Date:   Thu Jun 29 10:57:51 2023 +0200

    composite: Free cs->implicitRedirectExceptions in compCloseScreen
    
    Fixes leaking the memory it points to.

diff --git a/composite/compinit.c b/composite/compinit.c
index 5d05ee109..7e324afdc 100644
--- a/composite/compinit.c
+++ b/composite/compinit.c
@@ -59,6 +59,7 @@ compCloseScreen(ScreenPtr pScreen)
     Bool ret;
 
     free(cs->alternateVisuals);
+    free(cs->implicitRedirectExceptions);
 
     pScreen->CloseScreen = cs->CloseScreen;
     pScreen->InstallColormap = cs->InstallColormap;
commit 16aa40f1c807bd2bf469b497e7bc9e3f29541c82
Author: Michel Dänzer <mdaenzer at redhat.com>
Date:   Sat Jun 24 11:47:33 2023 +0200

    glamor: Use DrawablePtr in struct copy_args
    
    Will give better results if the window depth doesn't match the backing
    pixmap depth.

diff --git a/glamor/glamor_copy.c b/glamor/glamor_copy.c
index e5deef87e..58bfa2b0e 100644
--- a/glamor/glamor_copy.c
+++ b/glamor/glamor_copy.c
@@ -26,7 +26,7 @@
 #include "glamor_transform.h"
 
 struct copy_args {
-    PixmapPtr           src_pixmap;
+    DrawablePtr         src_drawable;
     glamor_pixmap_fbo   *src;
     uint32_t            bitplane;
     int                 dx, dy;
@@ -77,7 +77,7 @@ use_copyplane(DrawablePtr drawable, GCPtr gc, glamor_program *prog, void *arg)
     glamor_set_color(drawable, gc->bgPixel, prog->bg_uniform);
 
     /* XXX handle 2 10 10 10 and 1555 formats; presumably the pixmap private knows this? */
-    switch (args->src_pixmap->drawable.depth) {
+    switch (args->src_drawable->depth) {
     case 30:
         glUniform4ui(prog->bitplane_uniform,
                      (args->bitplane >> 20) & 0x3ff,
@@ -401,7 +401,7 @@ glamor_copy_fbo_fbo_draw(DrawablePtr src,
             goto bail_ctx;
     }
 
-    args.src_pixmap = src_pixmap;
+    args.src_drawable = src;
     args.bitplane = bitplane;
 
     /* Set up the vertex buffers for the points */
commit 5371690891f72e28fb29b1221184777260b3c994
Author: Michel Dänzer <mdaenzer at redhat.com>
Date:   Wed Jun 28 16:33:32 2023 +0200

    glamor: Fix up alpha channel if needed in glamor_upload_boxes
    
    It's needed for a depth 24 window backed by a depth 32 pixmap, to make
    sure the window's pixels sample alpha as 1.0.
    
    v2:
    * Make sure glamor_finish_access doesn't pass in a NULL pointer.

diff --git a/glamor/glamor_prepare.c b/glamor/glamor_prepare.c
index 208319628..2bab2b613 100644
--- a/glamor/glamor_prepare.c
+++ b/glamor/glamor_prepare.c
@@ -162,7 +162,8 @@ glamor_finish_access(DrawablePtr drawable)
     if (!priv->prepared)
         return;
 
-    if (priv->pbo) {
+    if (priv->pbo &&
+        !(drawable->depth == 24 && pixmap->drawable.depth == 32)) {
         glBindBuffer(GL_PIXEL_UNPACK_BUFFER, priv->pbo);
         glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
         pixmap->devPrivate.ptr = NULL;
@@ -178,7 +179,11 @@ glamor_finish_access(DrawablePtr drawable)
     RegionUninit(&priv->prepare_region);
 
     if (priv->pbo) {
-        glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
+        if (drawable->depth == 24 && pixmap->drawable.depth == 32)
+            pixmap->devPrivate.ptr = NULL;
+        else
+            glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
+
         glDeleteBuffers(1, &priv->pbo);
         priv->pbo = 0;
     } else {
diff --git a/glamor/glamor_transfer.c b/glamor/glamor_transfer.c
index 80b2e906e..a2727f109 100644
--- a/glamor/glamor_transfer.c
+++ b/glamor/glamor_transfer.c
@@ -39,6 +39,10 @@ glamor_upload_boxes(DrawablePtr drawable, BoxPtr in_boxes, int in_nbox,
     int                         box_index;
     int                         bytes_per_pixel = drawable->bitsPerPixel >> 3;
     const struct glamor_format *f = glamor_format_for_pixmap(pixmap);
+    char *tmp_bits = NULL;
+
+    if (drawable->depth == 24 && pixmap->drawable.depth == 32)
+        tmp_bits = xnfalloc(byte_stride * pixmap->drawable.height);
 
     glamor_make_current(glamor_priv);
 
@@ -63,6 +67,7 @@ glamor_upload_boxes(DrawablePtr drawable, BoxPtr in_boxes, int in_nbox,
             int y1 = MAX(boxes->y1 + dy_dst, box->y1);
             int y2 = MIN(boxes->y2 + dy_dst, box->y2);
 
+            uint32_t *src_line;
             size_t ofs = (y1 - dy_dst + dy_src) * byte_stride;
             ofs += (x1 - dx_dst + dx_src) * bytes_per_pixel;
 
@@ -71,24 +76,42 @@ glamor_upload_boxes(DrawablePtr drawable, BoxPtr in_boxes, int in_nbox,
             if (x2 <= x1 || y2 <= y1)
                 continue;
 
+            src_line = (uint32_t *)(bits + ofs);
+
+            if (tmp_bits) {
+                uint32_t *tmp_line = (uint32_t *)(tmp_bits + ofs);
+                int x, y;
+
+                /* Make sure any sampling of the alpha channel will return 1.0 */
+                for (y = y1; y < y2;
+                     y++, src_line += byte_stride / 4, tmp_line += byte_stride / 4) {
+                    for (x = 0; x < x2 - x1; x++)
+                        tmp_line[x] = src_line[x] | 0xff000000;
+                }
+
+                src_line = (uint32_t *)(tmp_bits + ofs);
+            }
+
             if (glamor_priv->has_unpack_subimage ||
                 x2 - x1 == byte_stride / bytes_per_pixel) {
                 glTexSubImage2D(GL_TEXTURE_2D, 0,
                                 x1 - box->x1, y1 - box->y1,
                                 x2 - x1, y2 - y1,
                                 f->format, f->type,
-                                bits + ofs);
+                                src_line);
             } else {
-                for (; y1 < y2; y1++, ofs += byte_stride)
+                for (; y1 < y2; y1++, src_line += byte_stride / bytes_per_pixel)
                     glTexSubImage2D(GL_TEXTURE_2D, 0,
                                     x1 - box->x1, y1 - box->y1,
                                     x2 - x1, 1,
                                     f->format, f->type,
-                                    bits + ofs);
+                                    src_line);
             }
         }
     }
 
+    free(tmp_bits);
+
     if (glamor_priv->has_unpack_subimage)
         glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
 }
commit 78e0bb500eea2ca8596a092c60a151e246ad7b52
Author: Michel Dänzer <mdaenzer at redhat.com>
Date:   Sat Jun 24 11:39:03 2023 +0200

    glamor: glamor_prep_pixmap_box → glamor_prep_drawable_box
    
    Pass the DrawablePtr directly to glamor_download_boxes. This will allow
    for better results if the window depth doesn't match the backing pixmap
    depth.

diff --git a/glamor/glamor_prepare.c b/glamor/glamor_prepare.c
index f7bb5d254..208319628 100644
--- a/glamor/glamor_prepare.c
+++ b/glamor/glamor_prepare.c
@@ -25,19 +25,21 @@
 #include "glamor_transfer.h"
 
 /*
- * Make a pixmap ready to draw with fb by
+ * Make a drawable ready to draw with fb by
  * creating a PBO large enough for the whole object
  * and downloading all of the FBOs into it.
  */
 
 static Bool
-glamor_prep_pixmap_box(PixmapPtr pixmap, glamor_access_t access, BoxPtr box)
+glamor_prep_drawable_box(DrawablePtr drawable, glamor_access_t access, BoxPtr box)
 {
-    ScreenPtr                   screen = pixmap->drawable.pScreen;
+    ScreenPtr                   screen = drawable->pScreen;
     glamor_screen_private       *glamor_priv = glamor_get_screen_private(screen);
+    PixmapPtr                   pixmap = glamor_get_drawable_pixmap(drawable);
     glamor_pixmap_private       *priv = glamor_get_pixmap_private(pixmap);
     int                         gl_access, gl_usage;
     RegionRec                   region;
+    int                         off_x, off_y;
 
     if (priv->type == GLAMOR_DRM_ONLY)
         return FALSE;
@@ -47,6 +49,11 @@ glamor_prep_pixmap_box(PixmapPtr pixmap, glamor_access_t access, BoxPtr box)
 
     glamor_make_current(glamor_priv);
 
+    glamor_get_drawable_deltas(drawable, pixmap, &off_x, &off_y);
+    box->x1 += off_x;
+    box->x2 += off_x;
+    box->y1 += off_y;
+    box->y2 += off_y;
     RegionInit(&region, box, 1);
 
     /* See if it's already mapped */
@@ -119,7 +126,7 @@ glamor_prep_pixmap_box(PixmapPtr pixmap, glamor_access_t access, BoxPtr box)
         priv->map_access = access;
     }
 
-    glamor_download_boxes(&pixmap->drawable, RegionRects(&region), RegionNumRects(&region),
+    glamor_download_boxes(drawable, RegionRects(&region), RegionNumRects(&region),
                           0, 0, 0, 0, pixmap->devPrivate.ptr, pixmap->devKind);
 
     RegionUninit(&region);
@@ -185,33 +192,26 @@ glamor_finish_access(DrawablePtr drawable)
 Bool
 glamor_prepare_access(DrawablePtr drawable, glamor_access_t access)
 {
-    PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
     BoxRec box;
-    int off_x, off_y;
-
-    glamor_get_drawable_deltas(drawable, pixmap, &off_x, &off_y);
 
-    box.x1 = drawable->x + off_x;
+    box.x1 = drawable->x;
     box.x2 = box.x1 + drawable->width;
-    box.y1 = drawable->y + off_y;
+    box.y1 = drawable->y;
     box.y2 = box.y1 + drawable->height;
-    return glamor_prep_pixmap_box(pixmap, access, &box);
+    return glamor_prep_drawable_box(drawable, access, &box);
 }
 
 Bool
 glamor_prepare_access_box(DrawablePtr drawable, glamor_access_t access,
                          int x, int y, int w, int h)
 {
-    PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
     BoxRec box;
-    int off_x, off_y;
 
-    glamor_get_drawable_deltas(drawable, pixmap, &off_x, &off_y);
-    box.x1 = drawable->x + x + off_x;
+    box.x1 = drawable->x + x;
     box.x2 = box.x1 + w;
-    box.y1 = drawable->y + y + off_y;
+    box.y1 = drawable->y + y;
     box.y2 = box.y1 + h;
-    return glamor_prep_pixmap_box(pixmap, access, &box);
+    return glamor_prep_drawable_box(drawable, access, &box);
 }
 
 /*
commit ff27ffa1c11c690b80e6b9febd182e8c49ec20ae
Author: Michel Dänzer <mdaenzer at redhat.com>
Date:   Sat Jun 24 11:27:21 2023 +0200

    glamor: Eliminate glamor_fini_pixmap
    
    Pass the DrawablePtr directly from glamor_finish_access to
    glamor_upload_boxes. This will allow for better results if the window
    depth doesn't match the backing pixmap depth.

diff --git a/glamor/glamor_prepare.c b/glamor/glamor_prepare.c
index 7600e4f6b..f7bb5d254 100644
--- a/glamor/glamor_prepare.c
+++ b/glamor/glamor_prepare.c
@@ -143,9 +143,10 @@ glamor_prep_pixmap_box(PixmapPtr pixmap, glamor_access_t access, BoxPtr box)
  * if we were writing to it and then unbind it to release the memory
  */
 
-static void
-glamor_fini_pixmap(PixmapPtr pixmap)
+void
+glamor_finish_access(DrawablePtr drawable)
 {
+    PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
     glamor_pixmap_private       *priv = glamor_get_pixmap_private(pixmap);
 
     if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(priv))
@@ -161,7 +162,7 @@ glamor_fini_pixmap(PixmapPtr pixmap)
     }
 
     if (priv->map_access == GLAMOR_ACCESS_RW) {
-        glamor_upload_boxes(&pixmap->drawable,
+        glamor_upload_boxes(drawable,
                             RegionRects(&priv->prepare_region),
                             RegionNumRects(&priv->prepare_region),
                             0, 0, 0, 0, pixmap->devPrivate.ptr, pixmap->devKind);
@@ -213,12 +214,6 @@ glamor_prepare_access_box(DrawablePtr drawable, glamor_access_t access,
     return glamor_prep_pixmap_box(pixmap, access, &box);
 }
 
-void
-glamor_finish_access(DrawablePtr drawable)
-{
-    glamor_fini_pixmap(glamor_get_drawable_pixmap(drawable));
-}
-
 /*
  * Make a picture ready to use with fb.
  */
commit a504f65d89ca44ae4fb58a2ed989876056aff771
Author: Michel Dänzer <mdaenzer at redhat.com>
Date:   Sat Jun 24 11:22:14 2023 +0200

    glamor: Take DrawablePtr instead of PixmapPtr in up/download_boxes
    
    Will allow for better results if the window depth doesn't match the
    backing pixmap depth.

diff --git a/glamor/glamor_composite_glyphs.c b/glamor/glamor_composite_glyphs.c
index c69b940d4..7911e0009 100644
--- a/glamor/glamor_composite_glyphs.c
+++ b/glamor/glamor_composite_glyphs.c
@@ -107,7 +107,7 @@ glamor_copy_glyph(PixmapPtr     glyph_pixmap,
                                       glyph_draw->height,
                                       0, 0, 0x1);
     }
-    glamor_upload_boxes((PixmapPtr) atlas_draw,
+    glamor_upload_boxes(atlas_draw,
                         &box, 1,
                         0, 0,
                         x, y,
diff --git a/glamor/glamor_copy.c b/glamor/glamor_copy.c
index 962dd688b..e5deef87e 100644
--- a/glamor/glamor_copy.c
+++ b/glamor/glamor_copy.c
@@ -255,7 +255,7 @@ glamor_copy_cpu_fbo(DrawablePtr src,
             fbCopy1toN(src, &tmp_pix->drawable, gc, box, nbox, dx, dy,
                        reverse, upsidedown, bitplane, closure);
 
-        glamor_upload_boxes(dst_pixmap, box, nbox, tmp_xoff, tmp_yoff,
+        glamor_upload_boxes(dst, box, nbox, tmp_xoff, tmp_yoff,
                             dst_xoff, dst_yoff, (uint8_t *) tmp_bits,
                             tmp_stride * sizeof(FbBits));
         fbDestroyPixmap(tmp_pix);
@@ -266,7 +266,7 @@ glamor_copy_cpu_fbo(DrawablePtr src,
         int src_xoff, src_yoff;
 
         fbGetDrawable(src, src_bits, src_stride, src_bpp, src_xoff, src_yoff);
-        glamor_upload_boxes(dst_pixmap, box, nbox, src_xoff + dx, src_yoff + dy,
+        glamor_upload_boxes(dst, box, nbox, src_xoff + dx, src_yoff + dy,
                             dst_xoff, dst_yoff,
                             (uint8_t *) src_bits, src_stride * sizeof (FbBits));
     }
@@ -319,7 +319,7 @@ glamor_copy_fbo_cpu(DrawablePtr src,
 
     fbGetDrawable(dst, dst_bits, dst_stride, dst_bpp, dst_xoff, dst_yoff);
 
-    glamor_download_boxes(src_pixmap, box, nbox, src_xoff + dx, src_yoff + dy,
+    glamor_download_boxes(src, box, nbox, src_xoff + dx, src_yoff + dy,
                           dst_xoff, dst_yoff,
                           (uint8_t *) dst_bits, dst_stride * sizeof (FbBits));
     glamor_finish_access(dst);
diff --git a/glamor/glamor_image.c b/glamor/glamor_image.c
index 453ef79ba..1a8e527b6 100644
--- a/glamor/glamor_image.c
+++ b/glamor/glamor_image.c
@@ -76,7 +76,7 @@ glamor_put_image_gl(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
 
     glamor_make_current(glamor_priv);
 
-    glamor_upload_region(pixmap, &region, x, y, (uint8_t *) bits, byte_stride);
+    glamor_upload_region(drawable, &region, x, y, (uint8_t *) bits, byte_stride);
 
     RegionUninit(&region);
     return TRUE;
@@ -124,7 +124,7 @@ glamor_get_image_gl(DrawablePtr drawable, int x, int y, int w, int h,
     box.x2 = x + w;
     box.y1 = y;
     box.y2 = y + h;
-    glamor_download_boxes(pixmap, &box, 1,
+    glamor_download_boxes(drawable, &box, 1,
                           drawable->x + off_x, drawable->y + off_y,
                           -x, -y,
                           (uint8_t *) d, byte_stride);
diff --git a/glamor/glamor_prepare.c b/glamor/glamor_prepare.c
index 835c4ebea..7600e4f6b 100644
--- a/glamor/glamor_prepare.c
+++ b/glamor/glamor_prepare.c
@@ -119,7 +119,7 @@ glamor_prep_pixmap_box(PixmapPtr pixmap, glamor_access_t access, BoxPtr box)
         priv->map_access = access;
     }
 
-    glamor_download_boxes(pixmap, RegionRects(&region), RegionNumRects(&region),
+    glamor_download_boxes(&pixmap->drawable, RegionRects(&region), RegionNumRects(&region),
                           0, 0, 0, 0, pixmap->devPrivate.ptr, pixmap->devKind);
 
     RegionUninit(&region);
@@ -161,7 +161,7 @@ glamor_fini_pixmap(PixmapPtr pixmap)
     }
 
     if (priv->map_access == GLAMOR_ACCESS_RW) {
-        glamor_upload_boxes(pixmap,
+        glamor_upload_boxes(&pixmap->drawable,
                             RegionRects(&priv->prepare_region),
                             RegionNumRects(&priv->prepare_region),
                             0, 0, 0, 0, pixmap->devPrivate.ptr, pixmap->devKind);
diff --git a/glamor/glamor_transfer.c b/glamor/glamor_transfer.c
index 842114235..80b2e906e 100644
--- a/glamor/glamor_transfer.c
+++ b/glamor/glamor_transfer.c
@@ -24,19 +24,20 @@
 #include "glamor_transfer.h"
 
 /*
- * Write a region of bits into a pixmap
+ * Write a region of bits into a drawable's backing pixmap
  */
 void
-glamor_upload_boxes(PixmapPtr pixmap, BoxPtr in_boxes, int in_nbox,
+glamor_upload_boxes(DrawablePtr drawable, BoxPtr in_boxes, int in_nbox,
                     int dx_src, int dy_src,
                     int dx_dst, int dy_dst,
                     uint8_t *bits, uint32_t byte_stride)
 {
-    ScreenPtr                   screen = pixmap->drawable.pScreen;
+    ScreenPtr                   screen = drawable->pScreen;
     glamor_screen_private       *glamor_priv = glamor_get_screen_private(screen);
+    PixmapPtr                   pixmap = glamor_get_drawable_pixmap(drawable);
     glamor_pixmap_private       *priv = glamor_get_pixmap_private(pixmap);
     int                         box_index;
-    int                         bytes_per_pixel = pixmap->drawable.bitsPerPixel >> 3;
+    int                         bytes_per_pixel = drawable->bitsPerPixel >> 3;
     const struct glamor_format *f = glamor_format_for_pixmap(pixmap);
 
     glamor_make_current(glamor_priv);
@@ -97,30 +98,31 @@ glamor_upload_boxes(PixmapPtr pixmap, BoxPtr in_boxes, int in_nbox,
  */
 
 void
-glamor_upload_region(PixmapPtr pixmap, RegionPtr region,
+glamor_upload_region(DrawablePtr drawable, RegionPtr region,
                      int region_x, int region_y,
                      uint8_t *bits, uint32_t byte_stride)
 {
-    glamor_upload_boxes(pixmap, RegionRects(region), RegionNumRects(region),
+    glamor_upload_boxes(drawable, RegionRects(region), RegionNumRects(region),
                         -region_x, -region_y,
                         0, 0,
                         bits, byte_stride);
 }
 
 /*
- * Read stuff from the pixmap FBOs and write to memory
+ * Read stuff from the drawable's backing pixmap FBOs and write to memory
  */
 void
-glamor_download_boxes(PixmapPtr pixmap, BoxPtr in_boxes, int in_nbox,
+glamor_download_boxes(DrawablePtr drawable, BoxPtr in_boxes, int in_nbox,
                       int dx_src, int dy_src,
                       int dx_dst, int dy_dst,
                       uint8_t *bits, uint32_t byte_stride)
 {
-    ScreenPtr screen = pixmap->drawable.pScreen;
+    ScreenPtr screen = drawable->pScreen;
     glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+    PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
     glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
     int box_index;
-    int bytes_per_pixel = pixmap->drawable.bitsPerPixel >> 3;
+    int bytes_per_pixel = drawable->bitsPerPixel >> 3;
     const struct glamor_format *f = glamor_format_for_pixmap(pixmap);
 
     glamor_make_current(glamor_priv);
diff --git a/glamor/glamor_transfer.h b/glamor/glamor_transfer.h
index 26b5a6b0d..17d80a2e9 100644
--- a/glamor/glamor_transfer.h
+++ b/glamor/glamor_transfer.h
@@ -24,18 +24,18 @@
 #define _GLAMOR_TRANSFER_H_
 
 void
-glamor_upload_boxes(PixmapPtr pixmap, BoxPtr in_boxes, int in_nbox,
+glamor_upload_boxes(DrawablePtr drawable, BoxPtr in_boxes, int in_nbox,
                     int dx_src, int dy_src,
                     int dx_dst, int dy_dst,
                     uint8_t *bits, uint32_t byte_stride);
 
 void
-glamor_upload_region(PixmapPtr pixmap, RegionPtr region,
+glamor_upload_region(DrawablePtr drawable, RegionPtr region,
                      int region_x, int region_y,
                      uint8_t *bits, uint32_t byte_stride);
 
 void
-glamor_download_boxes(PixmapPtr pixmap, BoxPtr in_boxes, int in_nbox,
+glamor_download_boxes(DrawablePtr drawable, BoxPtr in_boxes, int in_nbox,
                       int dx_src, int dy_src,
                       int dx_dst, int dy_dst,
                       uint8_t *bits, uint32_t byte_stride);
diff --git a/glamor/glamor_xv.c b/glamor/glamor_xv.c
index dbb490599..a3d6b3bc3 100644
--- a/glamor/glamor_xv.c
+++ b/glamor/glamor_xv.c
@@ -584,15 +584,15 @@ glamor_xv_put_image(glamor_port_private *port_priv,
         half_box.x2 = width >> 1;
         half_box.y2 = (nlines + 1) >> 1;
 
-        glamor_upload_boxes(port_priv->src_pix[0], &full_box, 1,
+        glamor_upload_boxes(&port_priv->src_pix[0]->drawable, &full_box, 1,
                             0, 0, 0, 0,
                             buf + (top * srcPitch), srcPitch);
 
-        glamor_upload_boxes(port_priv->src_pix[1], &half_box, 1,
+        glamor_upload_boxes(&port_priv->src_pix[1]->drawable, &half_box, 1,
                             0, 0, 0, 0,
                             buf + s2offset, srcPitch2);
 
-        glamor_upload_boxes(port_priv->src_pix[2], &half_box, 1,
+        glamor_upload_boxes(&port_priv->src_pix[2]->drawable, &half_box, 1,
                             0, 0, 0, 0,
                             buf + s3offset, srcPitch2);
         break;
@@ -611,11 +611,11 @@ glamor_xv_put_image(glamor_port_private *port_priv,
         half_box.x2 = width;
         half_box.y2 = (nlines + 1) >> 1;
 
-        glamor_upload_boxes(port_priv->src_pix[0], &full_box, 1,
+        glamor_upload_boxes(&port_priv->src_pix[0]->drawable, &full_box, 1,
                             0, 0, 0, 0,
                             buf + (top * srcPitch), srcPitch);
 
-        glamor_upload_boxes(port_priv->src_pix[1], &half_box, 1,
+        glamor_upload_boxes(&port_priv->src_pix[1]->drawable, &half_box, 1,
                             0, 0, 0, 0,
                             buf + s2offset, srcPitch);
         break;
commit 5893de5a2242eca05fc6c5c0a72ef28c0af29f50
Author: Michel Dänzer <mdaenzer at redhat.com>
Date:   Sat Jun 24 10:39:34 2023 +0200

    glamor: Make program APIs take DrawablePtrs instead of PixmapPtrs
    
    Will give better results if the window depth doesn't match the backing
    pixmap depth.

diff --git a/glamor/glamor_copy.c b/glamor/glamor_copy.c
index fa2d783a1..962dd688b 100644
--- a/glamor/glamor_copy.c
+++ b/glamor/glamor_copy.c
@@ -33,12 +33,12 @@ struct copy_args {
 };
 
 static Bool
-use_copyarea(PixmapPtr dst, GCPtr gc, glamor_program *prog, void *arg)
+use_copyarea(DrawablePtr drawable, GCPtr gc, glamor_program *prog, void *arg)
 {
     struct copy_args *args = arg;
     glamor_pixmap_fbo *src = args->src;
 
-    glamor_bind_texture(glamor_get_screen_private(dst->drawable.pScreen),
+    glamor_bind_texture(glamor_get_screen_private(drawable->pScreen),
                         GL_TEXTURE0, src, TRUE);
 
     glUniform2f(prog->fill_offset_uniform, args->dx, args->dy);
@@ -62,19 +62,19 @@ static const glamor_facet glamor_facet_copyarea = {
  */
 
 static Bool
-use_copyplane(PixmapPtr dst, GCPtr gc, glamor_program *prog, void *arg)
+use_copyplane(DrawablePtr drawable, GCPtr gc, glamor_program *prog, void *arg)
 {
     struct copy_args *args = arg;
     glamor_pixmap_fbo *src = args->src;
 
-    glamor_bind_texture(glamor_get_screen_private(dst->drawable.pScreen),
+    glamor_bind_texture(glamor_get_screen_private(drawable->pScreen),
                         GL_TEXTURE0, src, TRUE);
 
     glUniform2f(prog->fill_offset_uniform, args->dx, args->dy);
     glUniform2f(prog->fill_size_inv_uniform, 1.0f/src->width, 1.0f/src->height);
 
-    glamor_set_color(dst, gc->fgPixel, prog->fg_uniform);
-    glamor_set_color(dst, gc->bgPixel, prog->bg_uniform);
+    glamor_set_color(drawable, gc->fgPixel, prog->fg_uniform);
+    glamor_set_color(drawable, gc->bgPixel, prog->bg_uniform);
 
     /* XXX handle 2 10 10 10 and 1555 formats; presumably the pixmap private knows this? */
     switch (args->src_pixmap->drawable.depth) {
@@ -453,7 +453,7 @@ glamor_copy_fbo_fbo_draw(DrawablePtr src,
         args.dy = dy + src_off_y - src_box->y1;
         args.src = glamor_pixmap_fbo_at(src_priv, src_box_index);
 
-        if (!glamor_use_program(dst_pixmap, gc, prog, &args))
+        if (!glamor_use_program(dst, gc, prog, &args))
             goto bail_ctx;
 
         glamor_pixmap_loop(dst_priv, dst_box_index) {
diff --git a/glamor/glamor_dash.c b/glamor/glamor_dash.c
index b53ce5c50..e0fe0e7e0 100644
--- a/glamor/glamor_dash.c
+++ b/glamor/glamor_dash.c
@@ -156,7 +156,7 @@ glamor_dash_setup(DrawablePtr drawable, GCPtr gc)
 
     switch (gc->lineStyle) {
     case LineOnOffDash:
-        prog = glamor_use_program_fill(pixmap, gc,
+        prog = glamor_use_program_fill(drawable, gc,
                                        &glamor_priv->on_off_dash_line_progs,
                                        &glamor_facet_on_off_dash_lines);
         if (!prog)
@@ -175,11 +175,11 @@ glamor_dash_setup(DrawablePtr drawable, GCPtr gc)
                 goto bail;
         }
 
-        if (!glamor_use_program(pixmap, gc, prog, NULL))
+        if (!glamor_use_program(drawable, gc, prog, NULL))
             goto bail;
 
-        glamor_set_color(pixmap, gc->fgPixel, prog->fg_uniform);
-        glamor_set_color(pixmap, gc->bgPixel, prog->bg_uniform);
+        glamor_set_color(drawable, gc->fgPixel, prog->fg_uniform);
+        glamor_set_color(drawable, gc->bgPixel, prog->bg_uniform);
         break;
 
     default:
diff --git a/glamor/glamor_glyphblt.c b/glamor/glamor_glyphblt.c
index 78315ea9b..808e9066b 100644
--- a/glamor/glamor_glyphblt.c
+++ b/glamor/glamor_glyphblt.c
@@ -57,7 +57,7 @@ glamor_poly_glyph_blt_gl(DrawablePtr drawable, GCPtr gc,
 
     glamor_make_current(glamor_priv);
 
-    prog = glamor_use_program_fill(pixmap, gc,
+    prog = glamor_use_program_fill(drawable, gc,
                                    &glamor_priv->poly_glyph_blt_progs,
                                    &glamor_facet_poly_glyph_blt);
     if (!prog)
@@ -188,7 +188,7 @@ glamor_push_pixels_gl(GCPtr gc, PixmapPtr bitmap,
 
     glamor_make_current(glamor_priv);
 
-    prog = glamor_use_program_fill(pixmap, gc,
+    prog = glamor_use_program_fill(drawable, gc,
                                    &glamor_priv->poly_glyph_blt_progs,
                                    &glamor_facet_poly_glyph_blt);
     if (!prog)
diff --git a/glamor/glamor_lines.c b/glamor/glamor_lines.c
index 5d95333fe..ec70804ac 100644
--- a/glamor/glamor_lines.c
+++ b/glamor/glamor_lines.c
@@ -61,7 +61,7 @@ glamor_poly_lines_solid_gl(DrawablePtr drawable, GCPtr gc,
 
     glamor_make_current(glamor_priv);
 
-    prog = glamor_use_program_fill(pixmap, gc,
+    prog = glamor_use_program_fill(drawable, gc,
                                    &glamor_priv->poly_line_program,
                                    &glamor_facet_poly_lines);
 
diff --git a/glamor/glamor_points.c b/glamor/glamor_points.c
index faf6f433b..8f0e4b1da 100644
--- a/glamor/glamor_points.c
+++ b/glamor/glamor_points.c
@@ -66,7 +66,7 @@ glamor_poly_point_gl(DrawablePtr drawable, GCPtr gc, int mode, int npt, DDXPoint
             goto bail;
     }
 
-    if (!glamor_use_program(pixmap, gc, prog, NULL))
+    if (!glamor_use_program(drawable, gc, prog, NULL))
         goto bail;
 
     vbo_ppt = glamor_get_vbo_space(screen, npt * (2 * sizeof (INT16)), &vbo_offset);
diff --git a/glamor/glamor_program.c b/glamor/glamor_program.c
index f361b726e..9ee945d11 100644
--- a/glamor/glamor_program.c
+++ b/glamor/glamor_program.c
@@ -25,9 +25,9 @@
 #include "glamor_program.h"
 
 static Bool
-use_solid(PixmapPtr pixmap, GCPtr gc, glamor_program *prog, void *arg)
+use_solid(DrawablePtr drawable, GCPtr gc, glamor_program *prog, void *arg)
 {
-    return glamor_set_solid(pixmap, gc, TRUE, prog->fg_uniform);
+    return glamor_set_solid(drawable, gc, TRUE, prog->fg_uniform);
 }
 
 const glamor_facet glamor_fill_solid = {
@@ -38,9 +38,9 @@ const glamor_facet glamor_fill_solid = {
 };
 
 static Bool
-use_tile(PixmapPtr pixmap, GCPtr gc, glamor_program *prog, void *arg)
+use_tile(DrawablePtr drawable, GCPtr gc, glamor_program *prog, void *arg)
 {
-    return glamor_set_tiled(pixmap, gc, prog->fill_offset_uniform, prog->fill_size_inv_uniform);
+    return glamor_set_tiled(drawable, gc, prog->fill_offset_uniform, prog->fill_size_inv_uniform);
 }
 
 static const glamor_facet glamor_fill_tile = {
@@ -52,9 +52,9 @@ static const glamor_facet glamor_fill_tile = {
 };
 
 static Bool
-use_stipple(PixmapPtr pixmap, GCPtr gc, glamor_program *prog, void *arg)
+use_stipple(DrawablePtr drawable, GCPtr gc, glamor_program *prog, void *arg)
 {
-    return glamor_set_stippled(pixmap, gc, prog->fg_uniform,
+    return glamor_set_stippled(drawable, gc, prog->fg_uniform,
                                prog->fill_offset_uniform,
                                prog->fill_size_inv_uniform);
 }
@@ -71,11 +71,11 @@ static const glamor_facet glamor_fill_stipple = {
 };
 
 static Bool
-use_opaque_stipple(PixmapPtr pixmap, GCPtr gc, glamor_program *prog, void *arg)
+use_opaque_stipple(DrawablePtr drawable, GCPtr gc, glamor_program *prog, void *arg)
 {
-    if (!use_stipple(pixmap, gc, prog, arg))
+    if (!use_stipple(drawable, gc, prog, arg))
         return FALSE;
-    glamor_set_color(pixmap, gc->bgPixel, prog->bg_uniform);
+    glamor_set_color(drawable, gc->bgPixel, prog->bg_uniform);
     return TRUE;
 }
 
@@ -401,29 +401,29 @@ fail:
 }
 
 Bool
-glamor_use_program(PixmapPtr            pixmap,
+glamor_use_program(DrawablePtr          drawable,
                    GCPtr                gc,
                    glamor_program       *prog,
                    void                 *arg)
 {
     glUseProgram(prog->prog);
 
-    if (prog->prim_use && !prog->prim_use(pixmap, gc, prog, arg))
+    if (prog->prim_use && !prog->prim_use(drawable, gc, prog, arg))
         return FALSE;
 
-    if (prog->fill_use && !prog->fill_use(pixmap, gc, prog, arg))
+    if (prog->fill_use && !prog->fill_use(drawable, gc, prog, arg))
         return FALSE;
 
     return TRUE;
 }
 
 glamor_program *
-glamor_use_program_fill(PixmapPtr               pixmap,
+glamor_use_program_fill(DrawablePtr             drawable,
                         GCPtr                   gc,
                         glamor_program_fill     *program_fill,
                         const glamor_facet      *prim)
 {
-    ScreenPtr                   screen = pixmap->drawable.pScreen;
+    ScreenPtr                   screen = drawable->pScreen;
     glamor_program              *prog = &program_fill->progs[gc->fillStyle];
 
     int                         fill_style = gc->fillStyle;
@@ -441,7 +441,7 @@ glamor_use_program_fill(PixmapPtr               pixmap,
             return NULL;
     }
 
-    if (!glamor_use_program(pixmap, gc, prog, NULL))
+    if (!glamor_use_program(drawable, gc, prog, NULL))
         return NULL;
 
     return prog;
diff --git a/glamor/glamor_program.h b/glamor/glamor_program.h
index 0bd918fff..72bf1fc3f 100644
--- a/glamor/glamor_program.h
+++ b/glamor/glamor_program.h
@@ -50,7 +50,7 @@ typedef enum {
 
 typedef struct _glamor_program glamor_program;
 
-typedef Bool (*glamor_use) (PixmapPtr pixmap, GCPtr gc, glamor_program *prog, void *arg);
+typedef Bool (*glamor_use) (DrawablePtr drawable, GCPtr gc, glamor_program *prog, void *arg);
 
 typedef Bool (*glamor_use_render) (CARD8 op, PicturePtr src, PicturePtr dst, glamor_program *prog);
 
@@ -108,13 +108,13 @@ glamor_build_program(ScreenPtr          screen,
                      const char         *defines);
 
 Bool
-glamor_use_program(PixmapPtr            pixmap,
+glamor_use_program(DrawablePtr          drawable,
                    GCPtr                gc,
                    glamor_program       *prog,
                    void                 *arg);
 
 glamor_program *
-glamor_use_program_fill(PixmapPtr               pixmap,
+glamor_use_program_fill(DrawablePtr             drawable,
                         GCPtr                   gc,
                         glamor_program_fill     *program_fill,
                         const glamor_facet      *prim);
diff --git a/glamor/glamor_rects.c b/glamor/glamor_rects.c
index 8cdad64e4..afe680d1b 100644
--- a/glamor/glamor_rects.c
+++ b/glamor/glamor_rects.c
@@ -70,7 +70,7 @@ glamor_poly_fill_rect_gl(DrawablePtr drawable,
     }
 
     if (glamor_glsl_has_ints(glamor_priv)) {
-        prog = glamor_use_program_fill(pixmap, gc,
+        prog = glamor_use_program_fill(drawable, gc,
                                        &glamor_priv->poly_fill_rect_program,
                                        &glamor_facet_polyfillrect_130);
 
@@ -97,7 +97,7 @@ glamor_poly_fill_rect_gl(DrawablePtr drawable,
     } else {
         int n;
 
-        prog = glamor_use_program_fill(pixmap, gc,
+        prog = glamor_use_program_fill(drawable, gc,
                                        &glamor_priv->poly_fill_rect_program,
                                        &glamor_facet_polyfillrect_120);
 
diff --git a/glamor/glamor_segs.c b/glamor/glamor_segs.c
index 4dfa6553b..78c19ec48 100644
--- a/glamor/glamor_segs.c
+++ b/glamor/glamor_segs.c
@@ -58,7 +58,7 @@ glamor_poly_segment_solid_gl(DrawablePtr drawable, GCPtr gc,
 
     glamor_make_current(glamor_priv);
 
-    prog = glamor_use_program_fill(pixmap, gc,
+    prog = glamor_use_program_fill(drawable, gc,
                                    &glamor_priv->poly_segment_program,
                                    &glamor_facet_poly_segment);
 
diff --git a/glamor/glamor_spans.c b/glamor/glamor_spans.c
index 00a019c7b..dfa37dc07 100644
--- a/glamor/glamor_spans.c
+++ b/glamor/glamor_spans.c
@@ -65,7 +65,7 @@ glamor_fill_spans_gl(DrawablePtr drawable,
     glamor_make_current(glamor_priv);
 
     if (glamor_glsl_has_ints(glamor_priv)) {
-        prog = glamor_use_program_fill(pixmap, gc, &glamor_priv->fill_spans_program,
+        prog = glamor_use_program_fill(drawable, gc, &glamor_priv->fill_spans_program,
                                        &glamor_facet_fillspans_130);
 
         if (!prog)
@@ -90,7 +90,7 @@ glamor_fill_spans_gl(DrawablePtr drawable,
 
         glamor_put_vbo_space(screen);
     } else {
-        prog = glamor_use_program_fill(pixmap, gc, &glamor_priv->fill_spans_program,
+        prog = glamor_use_program_fill(drawable, gc, &glamor_priv->fill_spans_program,
                                        &glamor_facet_fillspans_120);
 
         if (!prog)
diff --git a/glamor/glamor_text.c b/glamor/glamor_text.c
index cf165cad8..a559aea8a 100644
--- a/glamor/glamor_text.c
+++ b/glamor/glamor_text.c
@@ -288,7 +288,7 @@ glamor_poly_text(DrawablePtr drawable, GCPtr gc,
 
     glamor_make_current(glamor_priv);
 
-    prog = glamor_use_program_fill(pixmap, gc, &glamor_priv->poly_text_progs, &glamor_facet_poly_text);
+    prog = glamor_use_program_fill(drawable, gc, &glamor_priv->poly_text_progs, &glamor_facet_poly_text);
 
     if (!prog)
         goto bail;
@@ -346,9 +346,9 @@ static const glamor_facet glamor_facet_image_text = {
 };
 
 static Bool
-use_image_solid(PixmapPtr pixmap, GCPtr gc, glamor_program *prog, void *arg)
+use_image_solid(DrawablePtr drawable, GCPtr gc, glamor_program *prog, void *arg)
 {
-    return glamor_set_solid(pixmap, gc, FALSE, prog->fg_uniform);
+    return glamor_set_solid(drawable, gc, FALSE, prog->fg_uniform);
 }
 
 static const glamor_facet glamor_facet_image_fill = {
@@ -359,11 +359,11 @@ static const glamor_facet glamor_facet_image_fill = {
 };
 
 static Bool
-glamor_te_text_use(PixmapPtr pixmap, GCPtr gc, glamor_program *prog, void *arg)
+glamor_te_text_use(DrawablePtr drawable, GCPtr gc, glamor_program *prog, void *arg)
 {
-    if (!glamor_set_solid(pixmap, gc, FALSE, prog->fg_uniform))
+    if (!glamor_set_solid(drawable, gc, FALSE, prog->fg_uniform))
         return FALSE;
-    glamor_set_color(pixmap, gc->bgPixel, prog->bg_uniform);
+    glamor_set_color(drawable, gc->bgPixel, prog->bg_uniform);
     return TRUE;
 }
 
@@ -461,7 +461,7 @@ glamor_image_text(DrawablePtr drawable, GCPtr gc,
         RegionUninit(&region);
     }
 
-    if (!glamor_use_program(pixmap, gc, prog, NULL))
+    if (!glamor_use_program(drawable, gc, prog, NULL))
         goto bail;
 
     (void) glamor_text(drawable, gc, glamor_font, prog,
diff --git a/glamor/glamor_transform.c b/glamor/glamor_transform.c
index 11a08f7f6..b969bc114 100644
--- a/glamor/glamor_transform.c
+++ b/glamor/glamor_transform.c
@@ -130,7 +130,7 @@ glamor_set_color_depth(ScreenPtr      pScreen,
 }
 
 Bool
-glamor_set_solid(PixmapPtr      pixmap,
+glamor_set_solid(DrawablePtr    drawable,
                  GCPtr          gc,
                  Bool           use_alu,
                  GLint          uniform)
@@ -143,7 +143,7 @@ glamor_set_solid(PixmapPtr      pixmap,
 
     pixel = gc->fgPixel;
 
-    if (!glamor_set_alu(pixmap->drawable.pScreen, alu)) {
+    if (!glamor_set_alu(drawable->pScreen, alu)) {
         switch (gc->alu) {
         case GXclear:
             pixel = 0;
@@ -158,7 +158,7 @@ glamor_set_solid(PixmapPtr      pixmap,
             return FALSE;
         }
     }
-    glamor_set_color(pixmap, pixel, uniform);
+    glamor_set_color(drawable, pixel, uniform);
 
     return TRUE;
 }
@@ -204,12 +204,12 @@ glamor_set_texture(PixmapPtr    texture,
 }
 
 Bool
-glamor_set_tiled(PixmapPtr      pixmap,
+glamor_set_tiled(DrawablePtr    drawable,
                  GCPtr          gc,
                  GLint          offset_uniform,
                  GLint          size_inv_uniform)
 {
-    if (!glamor_set_alu(pixmap->drawable.pScreen, gc->alu))
+    if (!glamor_set_alu(drawable->pScreen, gc->alu))
         return FALSE;
 
     if (!glamor_set_planemask(gc->depth, gc->planemask))
@@ -282,7 +282,7 @@ bail:
 }
 
 Bool
-glamor_set_stippled(PixmapPtr      pixmap,
+glamor_set_stippled(DrawablePtr    drawable,
                     GCPtr          gc,
                     GLint          fg_uniform,
                     GLint          offset_uniform,
@@ -294,7 +294,7 @@ glamor_set_stippled(PixmapPtr      pixmap,
     if (!stipple)
         return FALSE;
 
-    if (!glamor_set_solid(pixmap, gc, TRUE, fg_uniform))
+    if (!glamor_set_solid(drawable, gc, TRUE, fg_uniform))
         return FALSE;
 
     return glamor_set_texture(stipple,
diff --git a/glamor/glamor_transform.h b/glamor/glamor_transform.h
index 28855e3d3..305253310 100644
--- a/glamor/glamor_transform.h
+++ b/glamor/glamor_transform.h
@@ -39,12 +39,12 @@ glamor_set_color_depth(ScreenPtr      pScreen,
                        GLint          uniform);
 
 static inline void
-glamor_set_color(PixmapPtr      pixmap,
+glamor_set_color(DrawablePtr    drawable,
                  CARD32         pixel,
                  GLint          uniform)
 {
-    glamor_set_color_depth(pixmap->drawable.pScreen,
-                           pixmap->drawable.depth, pixel, uniform);
+    glamor_set_color_depth(drawable->pScreen,
+                           drawable->depth, pixel, uniform);
 }
 
 Bool
@@ -60,19 +60,19 @@ glamor_set_texture(PixmapPtr    texture,
                    GLint        size_uniform);
 
 Bool
-glamor_set_solid(PixmapPtr      pixmap,
+glamor_set_solid(DrawablePtr    drawable,
                  GCPtr          gc,
                  Bool           use_alu,
                  GLint          uniform);
 
 Bool
-glamor_set_tiled(PixmapPtr      pixmap,
+glamor_set_tiled(DrawablePtr    drawable,
                  GCPtr          gc,
                  GLint          offset_uniform,
                  GLint          size_uniform);
 
 Bool
-glamor_set_stippled(PixmapPtr      pixmap,
+glamor_set_stippled(DrawablePtr    drawable,
                     GCPtr          gc,
                     GLint          fg_uniform,
                     GLint          offset_uniform,
commit 0ed2d69217402586972410bfe850d989cb57cbcd
Author: Michel Dänzer <mdaenzer at redhat.com>
Date:   Sat Jun 24 11:08:01 2023 +0200

    glamor: Remove unused transfer functions
    
    Never used AFAICT.

diff --git a/glamor/glamor_transfer.c b/glamor/glamor_transfer.c
index e706e0fb4..842114235 100644
--- a/glamor/glamor_transfer.c
+++ b/glamor/glamor_transfer.c
@@ -107,22 +107,6 @@ glamor_upload_region(PixmapPtr pixmap, RegionPtr region,
                         bits, byte_stride);
 }
 
-/*
- * Take the data in the pixmap and stuff it back into the FBO
- */
-void
-glamor_upload_pixmap(PixmapPtr pixmap)
-{
-    BoxRec box;
-
-    box.x1 = 0;
-    box.x2 = pixmap->drawable.width;
-    box.y1 = 0;
-    box.y2 = pixmap->drawable.height;
-    glamor_upload_boxes(pixmap, &box, 1, 0, 0, 0, 0,
-                        pixmap->devPrivate.ptr, pixmap->devKind);
-}
-
 /*
  * Read stuff from the pixmap FBOs and write to memory
  */
@@ -182,37 +166,3 @@ glamor_download_boxes(PixmapPtr pixmap, BoxPtr in_boxes, int in_nbox,
     if (glamor_priv->has_pack_subimage)
         glPixelStorei(GL_PACK_ROW_LENGTH, 0);
 }
-
-/*
- * Read data from the pixmap FBO
- */
-void
-glamor_download_rect(PixmapPtr pixmap, int x, int y, int w, int h, uint8_t *bits)
-{
-    BoxRec      box;
-
-    box.x1 = x;
-    box.x2 = x + w;
-    box.y1 = y;
-    box.y2 = y + h;
-
-    glamor_download_boxes(pixmap, &box, 1, 0, 0, -x, -y,
-                          bits, PixmapBytePad(w, pixmap->drawable.depth));
-}
-
-/*
- * Pull the data from the FBO down to the pixmap
- */
-void
-glamor_download_pixmap(PixmapPtr pixmap)
-{
-    BoxRec      box;
-
-    box.x1 = 0;
-    box.x2 = pixmap->drawable.width;
-    box.y1 = 0;
-    box.y2 = pixmap->drawable.height;
-
-    glamor_download_boxes(pixmap, &box, 1, 0, 0, 0, 0,
-                          pixmap->devPrivate.ptr, pixmap->devKind);
-}
diff --git a/glamor/glamor_transfer.h b/glamor/glamor_transfer.h
index a6137b3ff..26b5a6b0d 100644
--- a/glamor/glamor_transfer.h
+++ b/glamor/glamor_transfer.h
@@ -34,19 +34,10 @@ glamor_upload_region(PixmapPtr pixmap, RegionPtr region,
                      int region_x, int region_y,
                      uint8_t *bits, uint32_t byte_stride);
 
-void
-glamor_upload_pixmap(PixmapPtr pixmap);
-
 void
 glamor_download_boxes(PixmapPtr pixmap, BoxPtr in_boxes, int in_nbox,
                       int dx_src, int dy_src,
                       int dx_dst, int dy_dst,
                       uint8_t *bits, uint32_t byte_stride);
 
-void
-glamor_download_rect(PixmapPtr pixmap, int x, int y, int w, int h, uint8_t *bits);
-
-void
-glamor_download_pixmap(PixmapPtr pixmap);
-
 #endif /* _GLAMOR_TRANSFER_H_ */


More information about the xorg-commit mailing list