From nobody Mon Feb 9 23:59:44 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644720432376833.352066670002; Sat, 12 Feb 2022 18:47:12 -0800 (PST) Received: from localhost ([::1]:37402 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nJ4ut-0002jA-27 for importer@patchew.org; Sat, 12 Feb 2022 21:47:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40936) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nJ4qd-00043T-0E for qemu-devel@nongnu.org; Sat, 12 Feb 2022 21:42:47 -0500 Received: from [2607:f8b0:4864:20::432] (port=43566 helo=mail-pf1-x432.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nJ4qa-0000PF-Ih for qemu-devel@nongnu.org; Sat, 12 Feb 2022 21:42:46 -0500 Received: by mail-pf1-x432.google.com with SMTP id d187so23136523pfa.10 for ; Sat, 12 Feb 2022 18:42:44 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c360:8200:d85b:35dd:dae2:b7a9]) by smtp.gmail.com with ESMTPSA id l11sm9128954pjm.23.2022.02.12.18.42.41 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 12 Feb 2022 18:42:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=s14nHJYWUMABjD8z5BWel6EnhPPQ5KGxmb4e3RIkyLE=; b=YvmKTRWTTukN6W7xBbrT6kbErKIHtfhCaoUwXMvlXCdaxyqXkWph79XKBQdA5X1g2z VgZEuWNYV2ohs0aza4pmcMhOs+kAXjfIIY5dwFKp2MCPBfGyf3/809W8Y2Qfk/aCy4xe +FfdQafFpRp8wFaOy9IDmwEowLbwmgq01r4yt+yGUqnMaEFr32ERr3xnIVqWTmvhEECg nxYpcePqnj3UM8HrRJqE+fRZFA3/sYs/8fGuMDedjQLq/2pnNxGXN42QFa5ay+J3Lsew Rd/SfNiC3ckIfkEFTGr9/WTh8FqjOPHFborbTdtPdJm+i7wpRirr9S7NFUuwSnv8wjgG 13WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=s14nHJYWUMABjD8z5BWel6EnhPPQ5KGxmb4e3RIkyLE=; b=FselpHssXP/Luup/USNoi8GNm0L9j8uN5MBtZK+2w2+OWQtZZIx0PNswHtkyo75PST 0fQRyzk/9DbQjzm7c8ABxdab6yev6sNaSS4mkKeg6lMvjdLQXb25bc2H752HYB6Nm4LK /an3lU7EqsS0zihY4pfm/sPj3nSw7hlVqqcEBssVaY8Nrzlj5gPhvZgAd9HXHVnwr2f0 5/eAGKJxwl3FgxHTQjFl2trYH8UtpyinA0WUaSyeuZC0qzOBYaknwyfFT91V97glarp2 AUH2m2nFJ8T874Z3qIXBfrd12anVLXBSK165GWyG4QyrQf3HGZlwidkoqNuqfuq2rx4b Ol0A== X-Gm-Message-State: AOAM530TLqNP5ibOsct/viZE6q22y1tde3qarMLbay4i3p/B8/JVL5X2 G1gWChmC9PHJFRe3PPV6vkbzRRF+e/k= X-Google-Smtp-Source: ABdhPJx8peoAhCHMs1V6KaR6OpOTWe3zvdj+6aEEEQ/EcA9t+aMoqv8+PREEYv+Dt5f5dyyFkKgykw== X-Received: by 2002:a63:41c6:: with SMTP id o189mr6668380pga.414.1644720163088; Sat, 12 Feb 2022 18:42:43 -0800 (PST) From: Akihiko Odaki To: Subject: [PATCH 2/6] Revert "console: save current scanout details" Date: Sun, 13 Feb 2022 11:42:18 +0900 Message-Id: <20220213024222.3548-3-akihiko.odaki@gmail.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220213024222.3548-1-akihiko.odaki@gmail.com> References: <20220213024222.3548-1-akihiko.odaki@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::432 (failed) 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=2607:f8b0:4864:20::432; envelope-from=akihiko.odaki@gmail.com; helo=mail-pf1-x432.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , qemu-devel@nongnu.org, Akihiko Odaki , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644720433194100001 Content-Type: text/plain; charset="utf-8" This reverts commit ebced091854517f063c46ce8e522ebc45e9bccdf. This fixes the compatibility between egl-headless and displays using console_select, most importantly vnc. Signed-off-by: Akihiko Odaki --- include/ui/console.h | 27 ------- ui/console.c | 165 ++++++++++++++----------------------------- 2 files changed, 54 insertions(+), 138 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index f590819880b..eefd7e4dc1f 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -108,17 +108,6 @@ struct QemuConsoleClass { #define QEMU_ALLOCATED_FLAG 0x01 #define QEMU_PLACEHOLDER_FLAG 0x02 =20 -typedef struct ScanoutTexture { - uint32_t backing_id; - bool backing_y_0_top; - uint32_t backing_width; - uint32_t backing_height; - uint32_t x; - uint32_t y; - uint32_t width; - uint32_t height; -} ScanoutTexture; - typedef struct DisplaySurface { pixman_format_code_t format; pixman_image_t *image; @@ -189,22 +178,6 @@ typedef struct QemuDmaBuf { bool draw_submitted; } QemuDmaBuf; =20 -enum display_scanout { - SCANOUT_NONE, - SCANOUT_SURFACE, - SCANOUT_TEXTURE, - SCANOUT_DMABUF, -}; - -typedef struct DisplayScanout { - enum display_scanout kind; - union { - /* DisplaySurface *surface; is kept in QemuConsole */ - ScanoutTexture texture; - QemuDmaBuf *dmabuf; - }; -} DisplayScanout; - typedef struct DisplayState DisplayState; typedef struct DisplayGLCtx DisplayGLCtx; =20 diff --git a/ui/console.c b/ui/console.c index 40eebb6d2cc..78583df9203 100644 --- a/ui/console.c +++ b/ui/console.c @@ -77,7 +77,6 @@ struct QemuConsole { console_type_t console_type; DisplayState *ds; DisplaySurface *surface; - DisplayScanout scanout; int dcls; DisplayGLCtx *gl; int gl_block; @@ -147,7 +146,6 @@ static void dpy_refresh(DisplayState *s); static DisplayState *get_alloc_displaystate(void); static void text_console_update_cursor_timer(void); static void text_console_update_cursor(void *opaque); -static bool displaychangelistener_has_dmabuf(DisplayChangeListener *dcl); =20 static void gui_update(void *opaque) { @@ -483,8 +481,6 @@ static void text_console_resize(QemuConsole *s) TextCell *cells, *c, *c1; int w1, x, y, last_width; =20 - assert(s->scanout.kind =3D=3D SCANOUT_SURFACE); - last_width =3D s->width; s->width =3D surface_width(s->surface) / FONT_WIDTH; s->height =3D surface_height(s->surface) / FONT_HEIGHT; @@ -1056,48 +1052,6 @@ static void console_putchar(QemuConsole *s, int ch) } } =20 -static void displaychangelistener_display_console(DisplayChangeListener *d= cl, - QemuConsole *con) -{ - static const char nodev[] =3D - "This VM has no graphic display device."; - static DisplaySurface *dummy; - - if (!con) { - if (!dcl->ops->dpy_gfx_switch) { - return; - } - if (!dummy) { - dummy =3D qemu_create_placeholder_surface(640, 480, nodev); - } - dcl->ops->dpy_gfx_switch(dcl, dummy); - return; - } - - if (con->scanout.kind =3D=3D SCANOUT_DMABUF && - displaychangelistener_has_dmabuf(dcl)) { - dcl->ops->dpy_gl_scanout_dmabuf(dcl, con->scanout.dmabuf); - } else if (con->scanout.kind =3D=3D SCANOUT_TEXTURE && - dcl->ops->dpy_gl_scanout_texture) { - dcl->ops->dpy_gl_scanout_texture(dcl, - con->scanout.texture.backing_id, - con->scanout.texture.backing_y_0_= top, - con->scanout.texture.backing_widt= h, - con->scanout.texture.backing_heig= ht, - con->scanout.texture.x, - con->scanout.texture.y, - con->scanout.texture.width, - con->scanout.texture.height); - } else if (con->scanout.kind =3D=3D SCANOUT_SURFACE && - dcl->ops->dpy_gfx_switch) { - dcl->ops->dpy_gfx_switch(dcl, con->surface); - } - - dcl->ops->dpy_gfx_update(dcl, 0, 0, - qemu_console_get_width(con, 0), - qemu_console_get_height(con, 0)); -} - void console_select(unsigned int index) { DisplayChangeListener *dcl; @@ -1114,7 +1068,13 @@ void console_select(unsigned int index) if (dcl->con !=3D NULL) { continue; } - displaychangelistener_display_console(dcl, s); + if (dcl->ops->dpy_gfx_switch) { + dcl->ops->dpy_gfx_switch(dcl, s->surface); + } + } + if (s->surface) { + dpy_gfx_update(s, 0, 0, surface_width(s->surface), + surface_height(s->surface)); } } if (ds->have_text) { @@ -1520,6 +1480,9 @@ static bool dpy_gl_compatible_with(QemuConsole *con, = DisplayChangeListener *dcl) =20 void register_displaychangelistener(DisplayChangeListener *dcl) { + static const char nodev[] =3D + "This VM has no graphic display device."; + static DisplaySurface *dummy; QemuConsole *con; =20 assert(!dcl->ds); @@ -1544,7 +1507,16 @@ void register_displaychangelistener(DisplayChangeLis= tener *dcl) } else { con =3D active_console; } - displaychangelistener_display_console(dcl, con); + if (dcl->ops->dpy_gfx_switch) { + if (con) { + dcl->ops->dpy_gfx_switch(dcl, con->surface); + } else { + if (!dummy) { + dummy =3D qemu_create_placeholder_surface(640, 480, nodev); + } + dcl->ops->dpy_gfx_switch(dcl, dummy); + } + } text_console_update_cursor(NULL); } =20 @@ -1625,9 +1597,13 @@ void dpy_gfx_update(QemuConsole *con, int x, int y, = int w, int h) { DisplayState *s =3D con->ds; DisplayChangeListener *dcl; - int width =3D qemu_console_get_width(con, x + w); - int height =3D qemu_console_get_height(con, y + h); + int width =3D w; + int height =3D h; =20 + if (con->surface) { + width =3D surface_width(con->surface); + height =3D surface_height(con->surface); + } x =3D MAX(x, 0); y =3D MAX(y, 0); x =3D MIN(x, width); @@ -1650,10 +1626,12 @@ void dpy_gfx_update(QemuConsole *con, int x, int y,= int w, int h) =20 void dpy_gfx_update_full(QemuConsole *con) { - int w =3D qemu_console_get_width(con, 0); - int h =3D qemu_console_get_height(con, 0); - - dpy_gfx_update(con, 0, 0, w, h); + if (!con->surface) { + return; + } + dpy_gfx_update(con, 0, 0, + surface_width(con->surface), + surface_height(con->surface)); } =20 void dpy_gfx_replace_surface(QemuConsole *con, @@ -1680,7 +1658,6 @@ void dpy_gfx_replace_surface(QemuConsole *con, =20 assert(old_surface !=3D surface); =20 - con->scanout.kind =3D SCANOUT_SURFACE; con->surface =3D surface; QLIST_FOREACH(dcl, &s->listeners, next) { if (con !=3D (dcl->con ? dcl->con : active_console)) { @@ -1856,9 +1833,6 @@ void dpy_gl_scanout_disable(QemuConsole *con) DisplayState *s =3D con->ds; DisplayChangeListener *dcl; =20 - if (con->scanout.kind !=3D SCANOUT_SURFACE) { - con->scanout.kind =3D SCANOUT_NONE; - } QLIST_FOREACH(dcl, &s->listeners, next) { dcl->ops->dpy_gl_scanout_disable(dcl); } @@ -1875,11 +1849,6 @@ void dpy_gl_scanout_texture(QemuConsole *con, DisplayState *s =3D con->ds; DisplayChangeListener *dcl; =20 - con->scanout.kind =3D SCANOUT_TEXTURE; - con->scanout.texture =3D (ScanoutTexture) { - backing_id, backing_y_0_top, backing_width, backing_height, - x, y, width, height - }; QLIST_FOREACH(dcl, &s->listeners, next) { dcl->ops->dpy_gl_scanout_texture(dcl, backing_id, backing_y_0_top, @@ -1894,8 +1863,6 @@ void dpy_gl_scanout_dmabuf(QemuConsole *con, DisplayState *s =3D con->ds; DisplayChangeListener *dcl; =20 - con->scanout.kind =3D SCANOUT_DMABUF; - con->scanout.dmabuf =3D dmabuf; QLIST_FOREACH(dcl, &s->listeners, next) { dcl->ops->dpy_gl_scanout_dmabuf(dcl, dmabuf); } @@ -2022,8 +1989,10 @@ QemuConsole *graphic_console_init(DeviceState *dev, = uint32_t head, s =3D qemu_console_lookup_unused(); if (s) { trace_console_gfx_reuse(s->index); - width =3D qemu_console_get_width(s, 0); - height =3D qemu_console_get_height(s, 0); + if (s->surface) { + width =3D surface_width(s->surface); + height =3D surface_height(s->surface); + } } else { trace_console_gfx_new(); s =3D new_console(ds, GRAPHIC_CONSOLE, head); @@ -2052,8 +2021,13 @@ void graphic_console_close(QemuConsole *con) static const char unplugged[] =3D "Guest display has been unplugged"; DisplaySurface *surface; - int width =3D qemu_console_get_width(con, 640); - int height =3D qemu_console_get_height(con, 480); + int width =3D 640; + int height =3D 480; + + if (con->surface) { + width =3D surface_width(con->surface); + height =3D surface_height(con->surface); + } =20 trace_console_gfx_close(con->index); object_property_set_link(OBJECT(con), "device", NULL, &error_abort); @@ -2205,19 +2179,7 @@ int qemu_console_get_width(QemuConsole *con, int fal= lback) if (con =3D=3D NULL) { con =3D active_console; } - if (con =3D=3D NULL) { - return fallback; - } - switch (con->scanout.kind) { - case SCANOUT_DMABUF: - return con->scanout.dmabuf->width; - case SCANOUT_TEXTURE: - return con->scanout.texture.width; - case SCANOUT_SURFACE: - return surface_width(con->surface); - default: - return fallback; - } + return con ? surface_width(con->surface) : fallback; } =20 int qemu_console_get_height(QemuConsole *con, int fallback) @@ -2225,19 +2187,7 @@ int qemu_console_get_height(QemuConsole *con, int fa= llback) if (con =3D=3D NULL) { con =3D active_console; } - if (con =3D=3D NULL) { - return fallback; - } - switch (con->scanout.kind) { - case SCANOUT_DMABUF: - return con->scanout.dmabuf->height; - case SCANOUT_TEXTURE: - return con->scanout.texture.height; - case SCANOUT_SURFACE: - return surface_height(con->surface); - default: - return fallback; - } + return con ? surface_height(con->surface) : fallback; } =20 static void vc_chr_accept_input(Chardev *chr) @@ -2303,13 +2253,12 @@ static void text_console_do_init(Chardev *chr, Disp= layState *ds) s->total_height =3D DEFAULT_BACKSCROLL; s->x =3D 0; s->y =3D 0; - if (s->scanout.kind !=3D SCANOUT_SURFACE) { - if (active_console && active_console->scanout.kind =3D=3D SCANOUT_= SURFACE) { - g_width =3D qemu_console_get_width(active_console, g_width); - g_height =3D qemu_console_get_height(active_console, g_height); + if (!s->surface) { + if (active_console && active_console->surface) { + g_width =3D surface_width(active_console->surface); + g_height =3D surface_height(active_console->surface); } s->surface =3D qemu_create_displaysurface(g_width, g_height); - s->scanout.kind =3D SCANOUT_SURFACE; } =20 s->hw_ops =3D &text_console_ops; @@ -2368,7 +2317,6 @@ static void vc_chr_open(Chardev *chr, s =3D new_console(NULL, TEXT_CONSOLE, 0); } else { s =3D new_console(NULL, TEXT_CONSOLE_FIXED_SIZE, 0); - s->scanout.kind =3D SCANOUT_SURFACE; s->surface =3D qemu_create_displaysurface(width, height); } =20 @@ -2392,13 +2340,13 @@ static void vc_chr_open(Chardev *chr, =20 void qemu_console_resize(QemuConsole *s, int width, int height) { - DisplaySurface *surface =3D qemu_console_surface(s); + DisplaySurface *surface; =20 assert(s->console_type =3D=3D GRAPHIC_CONSOLE); =20 - if (surface && (surface->flags & QEMU_ALLOCATED_FLAG) && - pixman_image_get_width(surface->image) =3D=3D width && - pixman_image_get_height(surface->image) =3D=3D height) { + if (s->surface && (s->surface->flags & QEMU_ALLOCATED_FLAG) && + pixman_image_get_width(s->surface->image) =3D=3D width && + pixman_image_get_height(s->surface->image) =3D=3D height) { return; } =20 @@ -2408,12 +2356,7 @@ void qemu_console_resize(QemuConsole *s, int width, = int height) =20 DisplaySurface *qemu_console_surface(QemuConsole *console) { - switch (console->scanout.kind) { - case SCANOUT_SURFACE: - return console->surface; - default: - return NULL; - } + return console->surface; } =20 PixelFormat qemu_default_pixelformat(int bpp) --=20 2.32.0 (Apple Git-132)