From nobody Wed Nov 27 14:25:13 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1698663006; cv=none; d=zohomail.com; s=zohoarc; b=TNz97XvXrQ7rYWjZrHC85LaLaDtbkKJFnMMzfpwISy5PR0EBJJN+13UaEFTt09E7uKdr5RgesxNYPSuuYx+RzvuMlV2ZRVPxHKj8asPpu3CsQIZVD2bNMyR6q29Shda9RplA1rHlbA7P8uXRHDNzHREzxMpkwsaGohSwjqxeRD8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698663006; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=laHjWLzCritiBmm3tfQnxZN8308Nvvp2FONGgcUqOYE=; b=j6yMn6CmKbZJrmoJ8hhWNxuA1qZhu1/204gxzsB1CsjZx7BBsaEu0MgWnNp1B+l68LkbroBj26TQkI4MGNaTAYF0nusrasCAiiIkW0bEqqSolBrI1c3DKyv1rAhD6zudNf1EajY9Uetau+df4mvQd529KriaQGool9MFAKyxF3s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698663006458316.5218974428575; Mon, 30 Oct 2023 03:50:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qxPpX-0002tZ-8C; Mon, 30 Oct 2023 06:49:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qxPpP-0002bo-Fw for qemu-devel@nongnu.org; Mon, 30 Oct 2023 06:49:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qxPpN-0002dG-Pt for qemu-devel@nongnu.org; Mon, 30 Oct 2023 06:49:03 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-590-RdBH8p5rO8eh76HxXZUIHQ-1; Mon, 30 Oct 2023 06:48:59 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 51B3A881E21; Mon, 30 Oct 2023 10:48:59 +0000 (UTC) Received: from localhost (unknown [10.39.208.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id C1DABC1596C; Mon, 30 Oct 2023 10:48:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698662941; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=laHjWLzCritiBmm3tfQnxZN8308Nvvp2FONGgcUqOYE=; b=IGTZUABippVIZ09zggX8uCEaGHDtnhwsXh8e0ybSR6LmV/0kGFBj82yCFy4uyjFPCoSb3t 9QosOELyQ6JiGXuCP9gq+eO0fD8NVEvnNyy+QZvD4CwtNjIVgTaBrhTdM0otzAa40fXYwz 1zw3Cq3Qbax/2XTRSHfynq8QMXt4ooo= X-MC-Unique: RdBH8p5rO8eh76HxXZUIHQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Maydell , Thomas Huth , BALATON Zoltan , Gerd Hoffmann , "Michael S. Tsirkin" , qemu-ppc@nongnu.org, Markus Armbruster , "Dr. David Alan Gilbert" , qemu-arm@nongnu.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Paolo Bonzini , Eric Blake Subject: [PATCH v7 12/23] virtio-gpu: replace PIXMAN for region/rect test Date: Mon, 30 Oct 2023 14:47:43 +0400 Message-ID: <20231030104755.124188-13-marcandre.lureau@redhat.com> In-Reply-To: <20231030104755.124188-1-marcandre.lureau@redhat.com> References: <20231030104755.124188-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.478, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1698663007437100003 From: Marc-Andr=C3=A9 Lureau Use a simpler implementation for rectangle geometry & intersect, drop the need for (more complex) PIXMAN functions. Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Michael S. Tsirkin --- 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 +#include + +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 =3D x; + rect->y =3D x; + rect->width =3D width; + rect->height =3D height; +} + +static inline void qemu_rect_translate(QemuRect *rect, + int16_t dx, int16_t dy) +{ + rect->x +=3D dx; + rect->y +=3D dy; +} + +static inline bool qemu_rect_intersect(const QemuRect *a, const QemuRect *= b, + QemuRect *res) +{ + int16_t x1, x2, y1, y2; + + x1 =3D MAX(a->x, b->x); + y1 =3D MAX(a->y, b->y); + x2 =3D MIN(a->x + a->width, b->x + b->width); + y2 =3D MIN(a->y + a->height, b->y + b->height); + + if (x1 >=3D x2 || y1 >=3D 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 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 =3D false; bool update_submitted =3D false; int i; @@ -565,34 +566,25 @@ static void virtio_gpu_resource_flush(VirtIOGPU *g, return; } =20 - 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 =3D 0; i < g->parent_obj.conf.max_outputs; i++) { - pixman_region16_t region, finalregion; - pixman_box16_t *extents; + QemuRect rect; =20 if (!(res->scanout_bitmask & (1 << i))) { continue; } scanout =3D &g->parent_obj.scanout[i]; =20 - 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); =20 - pixman_region_intersect(&finalregion, &flush_region, ®ion); - pixman_region_translate(&finalregion, -scanout->x, -scanout->y); - extents =3D 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); } =20 static void virtio_unref_resource(pixman_image_t *image, void *data) --=20 2.41.0