From a504f65d89ca44ae4fb58a2ed989876056aff771 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Sat, 24 Jun 2023 11:22:14 +0200 Subject: [PATCH] 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. --- glamor/glamor_composite_glyphs.c | 2 +- glamor/glamor_copy.c | 6 +++--- glamor/glamor_image.c | 4 ++-- glamor/glamor_prepare.c | 4 ++-- glamor/glamor_transfer.c | 22 ++++++++++++---------- glamor/glamor_transfer.h | 6 +++--- glamor/glamor_xv.c | 10 +++++----- 7 files changed, 28 insertions(+), 26 deletions(-) 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, ®ion, x, y, (uint8_t *) bits, byte_stride); + glamor_upload_region(drawable, ®ion, x, y, (uint8_t *) bits, byte_stride); RegionUninit(®ion); 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(®ion), RegionNumRects(®ion), + glamor_download_boxes(&pixmap->drawable, RegionRects(®ion), RegionNumRects(®ion), 0, 0, 0, 0, pixmap->devPrivate.ptr, pixmap->devKind); RegionUninit(®ion); @@ -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;