From: BALATON Zoltan <balaton@eik.bme.hu>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: qemu-devel@nongnu.org, qemu-ppc@nongnu.org,
"Peter Maydell" <peter.maydell@linaro.org>,
"Dr. David Alan Gilbert" <dave@treblig.org>,
"Eric Blake" <eblake@redhat.com>,
"Gerd Hoffmann" <kraxel@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
qemu-arm@nongnu.org, "Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Markus Armbruster" <armbru@redhat.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Thomas Huth" <thuth@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>
Subject: Re: [PATCH v6 12/23] virtio-gpu: replace PIXMAN for region/rect test
Date: Wed, 25 Oct 2023 22:54:26 +0200 (CEST) [thread overview]
Message-ID: <151fc11c-df21-51e6-f12c-e926e8764dc4@eik.bme.hu> (raw)
In-Reply-To: <20231025190818.3278423-13-marcandre.lureau@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 4958 bytes --]
On Wed, 25 Oct 2023, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> Use a simpler implementation for rectangle geometry & intersect, drop
> the need for (more complex) PIXMAN functions.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> Acked-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> include/ui/rect.h | 59 +++++++++++++++++++++++++++++++++++++++++
> hw/display/virtio-gpu.c | 30 ++++++++-------------
> 2 files changed, 70 insertions(+), 19 deletions(-)
> create mode 100644 include/ui/rect.h
>
> diff --git a/include/ui/rect.h b/include/ui/rect.h
> new file mode 100644
> index 0000000000..94898f92d0
> --- /dev/null
> +++ b/include/ui/rect.h
> @@ -0,0 +1,59 @@
> +/*
> + * SPDX-License-Identifier: GPL-2.0-or-later
> + */
> +#ifndef QEMU_RECT_H
> +#define QEMU_RECT_H
> +
> +#include <stdint.h>
> +#include <stdbool.h>
> +
> +typedef struct QemuRect {
> + int16_t x;
> + int16_t y;
> + uint16_t width;
> + uint16_t height;
> +} QemuRect;
> +
> +static inline void qemu_rect_init(QemuRect *rect,
> + int16_t x, int16_t y,
> + uint16_t width, uint16_t height)
> +{
> + rect->x = x;
> + rect->y = x;
> + rect->width = width;
> + rect->height = height;
> +}
> +
> +static inline void qemu_rect_translate(QemuRect *rect,
> + int16_t dx, int16_t dy)
> +{
> + rect->x += dx;
> + rect->y += dy;
> +}
> +
> +static inline bool qemu_rect_intersect(const QemuRect *a, const QemuRect *b,
> + QemuRect *res)
> +{
> + int16_t x1, x2, y1, y2;
> +
> + x1 = MAX(a->x, b->x);
> + y1 = MAX(a->y, b->y);
> + x2 = MIN(a->x + a->width, b->x + b->width);
> + y2 = MIN(a->y + a->height, b->y + b->height);
> +
> + if (x1 >= x2 || y1 >= y2) {
> + if (res) {
> + qemu_rect_init(res, 0, 0, 0, 0);
> + }
> +
> + return false;
> + }
> +
> + if (res) {
> + qemu_rect_init(res, x1, y1, x2 - x1, y2 - y1);
> + }
> +
> + return true;
> +}
> +
> +#endif
Maybe you could move these to pixman-minimal.h as well implementing the
missing pixman_region funcs so no need to change the callers? But I don't
mind either way.
Regards,
BALATON Zoltan
> diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
> index 4265316cbb..a8e767245f 100644
> --- a/hw/display/virtio-gpu.c
> +++ b/hw/display/virtio-gpu.c
> @@ -16,6 +16,7 @@
> #include "qemu/iov.h"
> #include "sysemu/cpus.h"
> #include "ui/console.h"
> +#include "ui/rect.h"
> #include "trace.h"
> #include "sysemu/dma.h"
> #include "sysemu/sysemu.h"
> @@ -503,7 +504,7 @@ static void virtio_gpu_resource_flush(VirtIOGPU *g,
> struct virtio_gpu_simple_resource *res;
> struct virtio_gpu_resource_flush rf;
> struct virtio_gpu_scanout *scanout;
> - pixman_region16_t flush_region;
> + QemuRect flush_rect;
> bool within_bounds = false;
> bool update_submitted = false;
> int i;
> @@ -565,34 +566,25 @@ static void virtio_gpu_resource_flush(VirtIOGPU *g,
> return;
> }
>
> - pixman_region_init_rect(&flush_region,
> - rf.r.x, rf.r.y, rf.r.width, rf.r.height);
> + qemu_rect_init(&flush_rect, rf.r.x, rf.r.y, rf.r.width, rf.r.height);
> for (i = 0; i < g->parent_obj.conf.max_outputs; i++) {
> - pixman_region16_t region, finalregion;
> - pixman_box16_t *extents;
> + QemuRect rect;
>
> if (!(res->scanout_bitmask & (1 << i))) {
> continue;
> }
> scanout = &g->parent_obj.scanout[i];
>
> - pixman_region_init(&finalregion);
> - pixman_region_init_rect(®ion, scanout->x, scanout->y,
> - scanout->width, scanout->height);
> + qemu_rect_init(&rect, scanout->x, scanout->y,
> + scanout->width, scanout->height);
>
> - pixman_region_intersect(&finalregion, &flush_region, ®ion);
> - pixman_region_translate(&finalregion, -scanout->x, -scanout->y);
> - extents = pixman_region_extents(&finalregion);
> /* work out the area we need to update for each console */
> - dpy_gfx_update(g->parent_obj.scanout[i].con,
> - extents->x1, extents->y1,
> - extents->x2 - extents->x1,
> - extents->y2 - extents->y1);
> -
> - pixman_region_fini(®ion);
> - pixman_region_fini(&finalregion);
> + if (qemu_rect_intersect(&flush_rect, &rect, &rect)) {
> + qemu_rect_translate(&rect, -scanout->x, -scanout->y);
> + dpy_gfx_update(g->parent_obj.scanout[i].con,
> + rect.x, rect.y, rect.width, rect.height);
> + }
> }
> - pixman_region_fini(&flush_region);
> }
>
> static void virtio_unref_resource(pixman_image_t *image, void *data)
>
next prev parent reply other threads:[~2023-10-25 20:55 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-25 19:07 [PATCH v6 00/23] Make Pixman an optional dependency marcandre.lureau
2023-10-25 19:07 ` [PATCH v6 01/23] build-sys: add a "pixman" feature marcandre.lureau
2023-10-25 19:07 ` [PATCH v6 02/23] build-sys: drop needless warning pragmas for old pixman marcandre.lureau
2023-10-26 5:21 ` Thomas Huth
2023-10-25 19:07 ` [PATCH v6 03/23] ui: compile out some qemu-pixman functions when !PIXMAN marcandre.lureau
2023-10-25 19:07 ` [PATCH v6 04/23] ui: add pixman-minimal.h marcandre.lureau
2023-10-25 19:07 ` [PATCH v6 05/23] vl: drop needless -spice checks marcandre.lureau
2023-10-26 5:23 ` Thomas Huth
2023-10-25 19:08 ` [PATCH v6 06/23] qemu-options: define -vnc only #ifdef CONFIG_VNC marcandre.lureau
2023-10-26 5:24 ` Thomas Huth
2023-10-25 19:08 ` [PATCH v6 07/23] vl: simplify display_remote logic marcandre.lureau
2023-10-26 5:29 ` Thomas Huth
2023-10-25 19:08 ` [PATCH v6 08/23] vl: move display early init before default devices marcandre.lureau
2023-10-26 5:31 ` Thomas Huth
2023-10-25 19:08 ` [PATCH v6 09/23] ui/console: allow to override the default VC marcandre.lureau
2023-10-26 5:35 ` Thomas Huth
2023-10-27 12:53 ` Andrea Bolognani
2023-10-27 16:38 ` Daniel P. Berrangé
2023-10-25 19:08 ` [PATCH v6 10/23] ui/vc: console-vc requires PIXMAN marcandre.lureau
2023-10-25 19:08 ` [PATCH v6 11/23] qmp/hmp: disable screendump if PIXMAN is missing marcandre.lureau
2023-10-25 19:08 ` [PATCH v6 12/23] virtio-gpu: replace PIXMAN for region/rect test marcandre.lureau
2023-10-25 20:54 ` BALATON Zoltan [this message]
2023-10-26 7:24 ` Marc-André Lureau
2023-10-25 19:08 ` [PATCH v6 13/23] ui/console: when PIXMAN is unavailable, don't draw placeholder msg marcandre.lureau
2023-10-25 19:08 ` [PATCH v6 14/23] vhost-user-gpu: skip VHOST_USER_GPU_UPDATE when !PIXMAN marcandre.lureau
2023-10-25 20:58 ` BALATON Zoltan
2023-10-26 8:03 ` Marc-André Lureau
2023-10-25 19:08 ` [PATCH v6 15/23] ui/gl: opengl doesn't require PIXMAN marcandre.lureau
2023-10-26 5:39 ` Thomas Huth
2023-10-26 8:09 ` Marc-André Lureau
2023-10-26 8:45 ` Thomas Huth
2023-10-30 10:24 ` Marc-André Lureau
2023-10-25 19:08 ` [PATCH v6 16/23] ui/vnc: VNC requires PIXMAN marcandre.lureau
2023-10-26 5:40 ` Thomas Huth
2023-10-25 19:08 ` [PATCH v6 17/23] ui/spice: SPICE/QXL " marcandre.lureau
2023-10-25 19:08 ` [PATCH v6 18/23] ui/gtk: -display gtk " marcandre.lureau
2023-10-25 19:08 ` [PATCH v6 19/23] ui/dbus: do not require PIXMAN marcandre.lureau
2023-10-25 19:08 ` [PATCH v6 20/23] arm/kconfig: XLNX_ZYNQMP_ARM depends on PIXMAN marcandre.lureau
2023-10-25 19:08 ` [PATCH v6 21/23] hw/sm501: allow compiling without PIXMAN marcandre.lureau
2023-10-25 21:02 ` BALATON Zoltan
2023-10-25 19:08 ` [PATCH v6 22/23] hw/display: make ATI_VGA depend on PIXMAN marcandre.lureau
2023-10-25 21:05 ` BALATON Zoltan
2023-10-26 14:41 ` Marc-André Lureau
2023-10-25 19:08 ` [PATCH v6 23/23] build-sys: make pixman actually optional marcandre.lureau
2023-10-26 5:42 ` Thomas Huth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=151fc11c-df21-51e6-f12c-e926e8764dc4@eik.bme.hu \
--to=balaton@eik.bme.hu \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=dave@treblig.org \
--cc=eblake@redhat.com \
--cc=kraxel@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).