From patchwork Thu Feb 25 01:36:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 12103091 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0BD3FC433E0 for ; Thu, 25 Feb 2021 01:39:29 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8698464EF1 for ; Thu, 25 Feb 2021 01:39:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8698464EF1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:51076 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lF5cl-0000Vf-J7 for qemu-devel@archiver.kernel.org; Wed, 24 Feb 2021 20:39:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40088) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lF5Zk-0007F4-Ty for qemu-devel@nongnu.org; Wed, 24 Feb 2021 20:36:20 -0500 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]:38600) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lF5Zj-0004pQ-1f for qemu-devel@nongnu.org; Wed, 24 Feb 2021 20:36:20 -0500 Received: by mail-pj1-x1035.google.com with SMTP id l18so2565936pji.3 for ; Wed, 24 Feb 2021 17:36:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8oxkoxN//QQLuaW0dfZteKbaDZnub+kYtwDVQhHQUgY=; b=WZ3Nn3Yl0+IkhiUL+r+33f7DAs8H2jkrhE6R1vylhf7DDLbg5luYw2ekTsmji6kH8D F9YbP6pfOM1zqAz3+WdQRFiK+Al22kML1emlERtlRWQpok3bhPGTZxNqaCvNEaMJogWw Sfcw4Iy/vkONsSF+LRka9CGPnmCAk7oRTX44n52k6upvqyuWIIoRN3hOHiP/SB8fjGpJ C/Mcpxx8uyxmm976d8QGv0zeHsZrcOaviEftk6fnSxPAGqJTGuYqYn8Tu7GCwENNrQ3S FDqTA6DsfpZYvNoI8E7F0s5HFM8wbN30E98XXZorsF3ePj7qHgFjCVkbQ6gcqVxlZxxX 7Dgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8oxkoxN//QQLuaW0dfZteKbaDZnub+kYtwDVQhHQUgY=; b=FbfUwQaGoUlqzifDXNtyBCuONUzqHmA0/xJqjr9q6AKHh7KWTazU0vGMvu0K4O+M9D tmzIyDzm32+Jr3py5qG/Hvgf2G7C7EnWNz0OVtfAW3T7KieMIIiOed4BqOdVWS3MmrrE a7aKsKjgpARWGJPUsJKe9OhpUKC7seWBU+xNpPt+WmQJf/c4cJo9Vw3KigGayLwwrmAS m/hsyxrOETFUK0gnwZsgu6cPiAM0YXOAL/KUFbwnQM6A9TxCaMjwAAVB7pCspBxLN2u1 1iy84t04omFHhqnCvz1NLXToW1ZmeK9dDzX0wi4eHaGyiC6aMaQ1Jn2jZ0zHnb85Rbbu Zr7g== X-Gm-Message-State: AOAM530sJIlOnOshqI1cer6X3Za1+9ddj6pSYxcaMpOMnlqJKasBQlWD 33xXyzBxHe9rrWXQsneZBP3M6yO+Hlon4w== X-Google-Smtp-Source: ABdhPJxDC63gjeTxNlmKIZlIyRm/gcwq1DfHQSriHLAx4FAxmZNjFCR6IH6XuY4YbitGM0Ij3ngiFw== X-Received: by 2002:a17:90a:4306:: with SMTP id q6mr741423pjg.138.1614216977221; Wed, 24 Feb 2021 17:36:17 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c360:8200:29a8:515b:7b7:9008]) by smtp.gmail.com with ESMTPSA id 137sm3817135pgb.80.2021.02.24.17.36.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Feb 2021 17:36:16 -0800 (PST) From: Akihiko Odaki To: Subject: [PATCH v3 1/3] ui/console: Add placeholder flag to message surface Date: Thu, 25 Feb 2021 10:36:07 +0900 Message-Id: <20210225013609.73388-1-akihiko.odaki@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210224110656.5pctwd7hdpvqi2na@sirius.home.kraxel.org> References: <20210224110656.5pctwd7hdpvqi2na@sirius.home.kraxel.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1035; envelope-from=akihiko.odaki@gmail.com; helo=mail-pj1-x1035.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S . Tsirkin" , qemu Developers , Akihiko Odaki , Gerd Hoffmann Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The surfaces created with former qemu_create_message_surface did not display the content from the guest and always contained simple messages describing the reason. A display backend may want to hide the window showing such a surface. This change renames the function to qemu_create_placeholder_surface, and adds "placeholder" flag; the display can check the flag to decide to do anything special like hiding the window. Signed-off-by: Akihiko Odaki --- hw/display/vhost-user-gpu.c | 4 ++-- hw/display/virtio-gpu.c | 6 +++--- include/ui/console.h | 10 ++++++++-- ui/console.c | 10 +++++----- ui/vnc.c | 2 +- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c index 4d8cb3525bf..3e911da795e 100644 --- a/hw/display/vhost-user-gpu.c +++ b/hw/display/vhost-user-gpu.c @@ -194,8 +194,8 @@ vhost_user_gpu_handle_display(VhostUserGPU *g, VhostUserGpuMsg *msg) con = s->con; if (m->scanout_id == 0 && m->width == 0) { - s->ds = qemu_create_message_surface(640, 480, - "Guest disabled display."); + s->ds = qemu_create_placeholder_surface(640, 480, + "Guest disabled display."); dpy_gfx_replace_surface(con, s->ds); } else { s->ds = qemu_create_displaysurface(m->width, m->height); diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 2e4a9822b6a..c1f17bec17e 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -338,9 +338,9 @@ static void virtio_gpu_disable_scanout(VirtIOGPU *g, int scanout_id) if (scanout_id == 0) { /* primary head */ - ds = qemu_create_message_surface(scanout->width ?: 640, - scanout->height ?: 480, - "Guest disabled display."); + ds = qemu_create_placeholder_surface(scanout->width ?: 640, + scanout->height ?: 480, + "Guest disabled display."); } dpy_gfx_replace_surface(scanout->con, ds); scanout->resource_id = 0; diff --git a/include/ui/console.h b/include/ui/console.h index d30e972d0b5..c960b7066cc 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -106,6 +106,7 @@ struct QemuConsoleClass { }; #define QEMU_ALLOCATED_FLAG 0x01 +#define QEMU_PLACEHOLDER_FLAG 0x02 typedef struct DisplaySurface { pixman_format_code_t format; @@ -259,8 +260,8 @@ DisplaySurface *qemu_create_displaysurface_from(int width, int height, pixman_format_code_t format, int linesize, uint8_t *data); DisplaySurface *qemu_create_displaysurface_pixman(pixman_image_t *image); -DisplaySurface *qemu_create_message_surface(int w, int h, - const char *msg); +DisplaySurface *qemu_create_placeholder_surface(int w, int h, + const char *msg); PixelFormat qemu_default_pixelformat(int bpp); DisplaySurface *qemu_create_displaysurface(int width, int height); @@ -281,6 +282,11 @@ static inline int is_buffer_shared(DisplaySurface *surface) return !(surface->flags & QEMU_ALLOCATED_FLAG); } +static inline int is_placeholder(DisplaySurface *surface) +{ + return surface->flags & QEMU_PLACEHOLDER_FLAG; +} + void register_displaychangelistener(DisplayChangeListener *dcl); void update_displaychangelistener(DisplayChangeListener *dcl, uint64_t interval); diff --git a/ui/console.c b/ui/console.c index c5d11bc7017..0caa39a6ed3 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1436,8 +1436,8 @@ DisplaySurface *qemu_create_displaysurface_pixman(pixman_image_t *image) return surface; } -DisplaySurface *qemu_create_message_surface(int w, int h, - const char *msg) +DisplaySurface *qemu_create_placeholder_surface(int w, int h, + const char *msg) { DisplaySurface *surface = qemu_create_displaysurface(w, h); pixman_color_t bg = color_table_rgb[0][QEMU_COLOR_BLACK]; @@ -1550,7 +1550,7 @@ void register_displaychangelistener(DisplayChangeListener *dcl) dcl->ops->dpy_gfx_switch(dcl, con->surface); } else { if (!dummy) { - dummy = qemu_create_message_surface(640, 480, nodev); + dummy = qemu_create_placeholder_surface(640, 480, nodev); } dcl->ops->dpy_gfx_switch(dcl, dummy); } @@ -1998,7 +1998,7 @@ QemuConsole *graphic_console_init(DeviceState *dev, uint32_t head, &error_abort); } - surface = qemu_create_message_surface(width, height, noinit); + surface = qemu_create_placeholder_surface(width, height, noinit); dpy_gfx_replace_surface(s, surface); return s; } @@ -2027,7 +2027,7 @@ void graphic_console_close(QemuConsole *con) if (con->gl) { dpy_gl_scanout_disable(con); } - surface = qemu_create_message_surface(width, height, unplugged); + surface = qemu_create_placeholder_surface(width, height, unplugged); dpy_gfx_replace_surface(con, surface); } diff --git a/ui/vnc.c b/ui/vnc.c index 16bb3be770b..4d2151272e5 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -799,7 +799,7 @@ static void vnc_dpy_switch(DisplayChangeListener *dcl, if (surface == NULL) { if (placeholder == NULL) { - placeholder = qemu_create_message_surface(640, 480, placeholder_msg); + placeholder = qemu_create_placeholder_surface(640, 480, placeholder_msg); } surface = placeholder; } From patchwork Thu Feb 25 01:36:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 12103089 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C766AC433E0 for ; Thu, 25 Feb 2021 01:39:20 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1F4E364EF1 for ; Thu, 25 Feb 2021 01:39:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1F4E364EF1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:50392 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lF5cd-0000C7-2y for qemu-devel@archiver.kernel.org; Wed, 24 Feb 2021 20:39:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40112) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lF5Zx-0007J6-0G for qemu-devel@nongnu.org; Wed, 24 Feb 2021 20:36:34 -0500 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]:52425) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lF5Zr-0004sq-3R for qemu-devel@nongnu.org; Wed, 24 Feb 2021 20:36:32 -0500 Received: by mail-pj1-x102e.google.com with SMTP id kr16so2529588pjb.2 for ; Wed, 24 Feb 2021 17:36:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=A5FQVryJkKp6u0IFNKShPGPlugCcW1tPLd28cMt7h/g=; b=gdzxWGmMRqLI0saU92/iPkVm/osz6b9NFOG7n2lkYNL1NbVqk+Y6DjxZNA/+M5eL/1 3IcRsG+6HxoajqKZE6qDeWdiy6yJeyMBzr8xc2AlP8gc+VsAGCUQ1QjzUBw97NmNdfll FPZ8A/z6bs32OzBiwVlhgeSqHHx+iHoKhFZHy13HYgcsEoBa+pJlnXZHcsPFz6v0TsJy Df6LKfAJhwPfRMm6cYPop7QNpPYgbMkOK+ZXywEIVXerIbzWFIiiK+47JJGVV1pkgjzq SAXYk7SynUj3GjvSQcw5IGbeMqEgZdA+QILbhggc04NMVGBbYHMHWIBKsQlgPIhJ0jop heZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=A5FQVryJkKp6u0IFNKShPGPlugCcW1tPLd28cMt7h/g=; b=YqAXcjkStPvDLNeKuHNa1TGa7dJf626ADQqlxfTaoAqYZ1VJDVJvX0KBqRacyQBXjS tg3+TRyO5YuYjcWF+78qOQ5qsIRG2amx08ixzT3tlr3umDkUE898htAzhxe2HoqX8yKe 6P7o54DVPzaaiIvmTzQ4dfqs7m8k3hyPRi7U9UfObBopJVnT2BSjo5qskZV2rNoBJO80 e3uFIekKlm1QsT0UtzRUyPAEUVGW5JoMSXnJwNfAkLuSf1vRfH5DItn+2VTBnQsXN9IL UguBIXUjvM1Q55lxaK6BEa33hhG8LiR183icFiufcKRGGZ/eqaG9yUquNVVg9hiSoiGi CAaA== X-Gm-Message-State: AOAM531mgRFbN+ihPAkF7ZqVX38Ucv9bdlMOMqe2RCi7660ZH7a9FoVS qV+9ZJRoBiG0ImmfYdBtNYeXIMADp8piCQ== X-Google-Smtp-Source: ABdhPJzhsq689qJPuZVzTltruaPBleR+6bVyv1H2DCnU7+vhjghb5Ufx138GUIMcMDV/KLau+Lu8LA== X-Received: by 2002:a17:90a:5d87:: with SMTP id t7mr741049pji.175.1614216984282; Wed, 24 Feb 2021 17:36:24 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c360:8200:29a8:515b:7b7:9008]) by smtp.gmail.com with ESMTPSA id 137sm3817135pgb.80.2021.02.24.17.36.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Feb 2021 17:36:23 -0800 (PST) From: Akihiko Odaki To: Subject: [PATCH v3 2/3] ui/console: Pass placeholder surface to displays Date: Thu, 25 Feb 2021 10:36:08 +0900 Message-Id: <20210225013609.73388-2-akihiko.odaki@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210225013609.73388-1-akihiko.odaki@gmail.com> References: <20210224110656.5pctwd7hdpvqi2na@sirius.home.kraxel.org> <20210225013609.73388-1-akihiko.odaki@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=akihiko.odaki@gmail.com; helo=mail-pj1-x102e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S . Tsirkin" , qemu Developers , Akihiko Odaki , Gerd Hoffmann Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" ui/console used to accept NULL as graphic console surface, but its semantics was inconsistent among displays: - cocoa and gtk-egl perform NULL dereference. - egl-headless, spice and spice-egl do nothing. - gtk releases underlying resources. - sdl2-2d and sdl2-gl destroys the window. - vnc shows a message, "Display output is not active." Fortunately, only virtio-gpu and virtio-gpu-3d assign NULL so we can study them to figure out the desired behavior. They assign NULL *except* for the primary display when the device is realized, reset, or its scanout is disabled. This effectively destroys windows for the (uninitialized) secondary displays. To implement the consistent behavior of display device realization/reset, this change embeds it to the operation switching the surface. When NULL was given as a new surface when switching, ui/console will instead passes a placeholder down to each display listeners. sdl destroys the window for a secondary console if its surface is a placeholder. The other displays simply shows the placeholder. Signed-off-by: Akihiko Odaki --- ui/console.c | 45 +++++++++++++++++++++++++++++++-------------- ui/gtk.c | 4 ---- ui/sdl2-2d.c | 7 ++----- ui/sdl2-gl.c | 4 ++-- ui/spice-display.c | 6 +++--- ui/vnc.c | 10 ---------- 6 files changed, 38 insertions(+), 38 deletions(-) diff --git a/ui/console.c b/ui/console.c index 0caa39a6ed3..75e54651b5b 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1088,6 +1088,29 @@ static void console_putchar(QemuConsole *s, int ch) } } +static void dpy_gfx_switch(DisplayChangeListener *dcl, DisplaySurface *surface) +{ + static DisplaySurface *placeholder; + static const char placeholder_msg[] = "Display output is not active."; + DisplaySurface *broadcast; + + if (!dcl->ops->dpy_gfx_switch) { + return; + } + + if (surface) { + broadcast = surface; + } else { + if (!placeholder) { + placeholder = qemu_create_placeholder_surface(640, 480, placeholder_msg); + } + + broadcast = placeholder; + } + + dcl->ops->dpy_gfx_switch(dcl, broadcast); +} + void console_select(unsigned int index) { DisplayChangeListener *dcl; @@ -1104,9 +1127,7 @@ void console_select(unsigned int index) if (dcl->con != NULL) { continue; } - if (dcl->ops->dpy_gfx_switch) { - dcl->ops->dpy_gfx_switch(dcl, s->surface); - } + dpy_gfx_switch(dcl, s->surface); } if (s->surface) { dpy_gfx_update(s, 0, 0, surface_width(s->surface), @@ -1545,15 +1566,13 @@ void register_displaychangelistener(DisplayChangeListener *dcl) } else { con = active_console; } - if (dcl->ops->dpy_gfx_switch) { - if (con) { - dcl->ops->dpy_gfx_switch(dcl, con->surface); - } else { - if (!dummy) { - dummy = qemu_create_placeholder_surface(640, 480, nodev); - } - dcl->ops->dpy_gfx_switch(dcl, dummy); + if (con) { + dpy_gfx_switch(dcl, con->surface); + } else { + if (!dummy) { + dummy = qemu_create_placeholder_surface(640, 480, nodev); } + dpy_gfx_switch(dcl, dummy); } text_console_update_cursor(NULL); } @@ -1685,9 +1704,7 @@ void dpy_gfx_replace_surface(QemuConsole *con, if (con != (dcl->con ? dcl->con : active_console)) { continue; } - if (dcl->ops->dpy_gfx_switch) { - dcl->ops->dpy_gfx_switch(dcl, surface); - } + dpy_gfx_switch(dcl, surface); } qemu_free_displaysurface(old_surface); } diff --git a/ui/gtk.c b/ui/gtk.c index 79dc2401203..a4a5f981e2a 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -567,10 +567,6 @@ static void gd_switch(DisplayChangeListener *dcl, } vc->gfx.ds = surface; - if (!surface) { - return; - } - if (surface->format == PIXMAN_x8r8g8b8) { /* * PIXMAN_x8r8g8b8 == CAIRO_FORMAT_RGB24 diff --git a/ui/sdl2-2d.c b/ui/sdl2-2d.c index a2ea85127d5..bfebbdeaea8 100644 --- a/ui/sdl2-2d.c +++ b/ui/sdl2-2d.c @@ -32,14 +32,11 @@ void sdl2_2d_update(DisplayChangeListener *dcl, int x, int y, int w, int h) { struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl); - DisplaySurface *surf = qemu_console_surface(dcl->con); + DisplaySurface *surf = scon->surface; SDL_Rect rect; size_t surface_data_offset; assert(!scon->opengl); - if (!surf) { - return; - } if (!scon->texture) { return; } @@ -75,7 +72,7 @@ void sdl2_2d_switch(DisplayChangeListener *dcl, scon->texture = NULL; } - if (!new_surface) { + if (is_placeholder(new_surface) && qemu_console_get_index(dcl->con)) { sdl2_window_destroy(scon); return; } diff --git a/ui/sdl2-gl.c b/ui/sdl2-gl.c index fd594d74611..a21d2deed91 100644 --- a/ui/sdl2-gl.c +++ b/ui/sdl2-gl.c @@ -86,7 +86,7 @@ void sdl2_gl_switch(DisplayChangeListener *dcl, scon->surface = new_surface; - if (!new_surface) { + if (is_placeholder(new_surface) && qemu_console_get_index(dcl->con)) { qemu_gl_fini_shader(scon->gls); scon->gls = NULL; sdl2_window_destroy(scon); @@ -112,7 +112,7 @@ void sdl2_gl_refresh(DisplayChangeListener *dcl) assert(scon->opengl); graphic_hw_update(dcl->con); - if (scon->updates && scon->surface) { + if (scon->updates && scon->real_window) { scon->updates = 0; sdl2_gl_render_surface(scon); } diff --git a/ui/spice-display.c b/ui/spice-display.c index 6f32b66a6e7..222c7c20a2a 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -388,7 +388,7 @@ void qemu_spice_display_switch(SimpleSpiceDisplay *ssd, SimpleSpiceUpdate *update; bool need_destroy; - if (surface && ssd->surface && + if (ssd->surface && surface_width(surface) == pixman_image_get_width(ssd->surface) && surface_height(surface) == pixman_image_get_height(ssd->surface) && surface_format(surface) == pixman_image_get_format(ssd->surface)) { @@ -410,8 +410,8 @@ void qemu_spice_display_switch(SimpleSpiceDisplay *ssd, /* full mode switch */ trace_qemu_spice_display_surface(ssd->qxl.id, - surface ? surface_width(surface) : 0, - surface ? surface_height(surface) : 0, + surface_width(surface), + surface_height(surface), false); memset(&ssd->dirty, 0, sizeof(ssd->dirty)); diff --git a/ui/vnc.c b/ui/vnc.c index 4d2151272e5..310abc93781 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -790,20 +790,10 @@ static bool vnc_check_pageflip(DisplaySurface *s1, static void vnc_dpy_switch(DisplayChangeListener *dcl, DisplaySurface *surface) { - static const char placeholder_msg[] = - "Display output is not active."; - static DisplaySurface *placeholder; VncDisplay *vd = container_of(dcl, VncDisplay, dcl); bool pageflip = vnc_check_pageflip(vd->ds, surface); VncState *vs; - if (surface == NULL) { - if (placeholder == NULL) { - placeholder = qemu_create_placeholder_surface(640, 480, placeholder_msg); - } - surface = placeholder; - } - vnc_abort_display_jobs(vd); vd->ds = surface; From patchwork Thu Feb 25 01:36:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 12103093 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9AD6CC433E0 for ; Thu, 25 Feb 2021 01:39:57 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1098864EC4 for ; Thu, 25 Feb 2021 01:39:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1098864EC4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:52552 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lF5dD-00019K-RB for qemu-devel@archiver.kernel.org; Wed, 24 Feb 2021 20:39:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40124) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lF5Zz-0007Jp-0s for qemu-devel@nongnu.org; Wed, 24 Feb 2021 20:36:35 -0500 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]:34403) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lF5Zw-0004u6-Tt for qemu-devel@nongnu.org; Wed, 24 Feb 2021 20:36:34 -0500 Received: by mail-pl1-x62f.google.com with SMTP id ba1so2322425plb.1 for ; Wed, 24 Feb 2021 17:36:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oEUljLDlicyF+K7oIs4yg0PWicD1HtbRXU5+ExPpqM0=; b=ZoJvd2jW3nO5+B/PpJogVx3zeat4YpJb5qzYnvfg211IncVUDazWpFPVItZzJbTYVf 01a2Hmea37c4G95aJBJP/1XurVJ4RY+HQGtw9sqHU5DFYMmG6uBm0b1hNdmPKGOjElUg 08ixLT2n+4LQqbcxCH7ddebtoR1rikgW6DTMLRozAZ8s/oDw/ArngAy/2h8uQ4Gomuwb XI4rsLP3vOyPzBDnJPqBZ42akWdQiDbwbwMlRzZz5oZW8cEsAS6SNYIqcsOxtYUcSqPt PaijyAumnC71cwafKcDLUIna7cSu2cJRsCeukHO4WQXIqxe++aSigV95anoQIUtFWYdb qriw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oEUljLDlicyF+K7oIs4yg0PWicD1HtbRXU5+ExPpqM0=; b=tTHRgriVphXeKl2+84gmUsNRg3eiN79Bp2S2XcHLXTyJrEL1LKWKfVl6udyoDKkvym QqvhPSydu/aUYWdkA4+/p8I3FabGKhDx72T72gufOIyMpMAw3FDRSUI0o6WdyeF9HXu5 pLRF0OPZTLRICNemveg9jIdpHOBlyE+VSSTGl0iXZm8L1YJdjRnezA3t10ZoOenRhemd yH+QJtB7Om3F70oJQBlBtUBvFD0A/atky0UbuVkiJ5F78r6heWGYIS8q/vCbSWenzuIh YPueOus6Gv/nM8mrodya6FTzJZ4tuROQG1ILCgOINgQm74ayb9SYR+ZGx6TxL8kiBgIw stoQ== X-Gm-Message-State: AOAM53247lm4cAhwcWXB7VgV+l7jkwfMnOWfQ6Zt7jLrqvAhxOF6iU2K QhqSJR3KVvAllQt4iYAbbr24ZBEcW3esig== X-Google-Smtp-Source: ABdhPJzEkBtA9VgyQFpMgKAqlehNult2QX80NY+VmMDcFk752JZJvnuquS3ULWdWxRUhgsnxZm5xmQ== X-Received: by 2002:a17:903:228a:b029:da:d645:ab58 with SMTP id b10-20020a170903228ab02900dad645ab58mr871574plh.25.1614216989750; Wed, 24 Feb 2021 17:36:29 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c360:8200:29a8:515b:7b7:9008]) by smtp.gmail.com with ESMTPSA id 137sm3817135pgb.80.2021.02.24.17.36.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Feb 2021 17:36:29 -0800 (PST) From: Akihiko Odaki To: Subject: [PATCH v3 3/3] virtio-gpu: Do not distinguish the primary console Date: Thu, 25 Feb 2021 10:36:09 +0900 Message-Id: <20210225013609.73388-3-akihiko.odaki@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210225013609.73388-1-akihiko.odaki@gmail.com> References: <20210224110656.5pctwd7hdpvqi2na@sirius.home.kraxel.org> <20210225013609.73388-1-akihiko.odaki@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=akihiko.odaki@gmail.com; helo=mail-pl1-x62f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S . Tsirkin" , qemu Developers , Akihiko Odaki , Gerd Hoffmann Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" In the past, virtio-gpu set NULL as the surface for the secondary consoles to hide its window. The distinction is now handled in ui/console and the display backends and virtio-gpu does no longer have to do that. Signed-off-by: Akihiko Odaki --- hw/display/vhost-user-gpu.c | 2 +- hw/display/virtio-gpu-3d.c | 10 +++------- hw/display/virtio-gpu-base.c | 3 --- hw/display/virtio-gpu.c | 12 +++++------- 4 files changed, 9 insertions(+), 18 deletions(-) diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c index 3e911da795e..cb729ed5bc4 100644 --- a/hw/display/vhost-user-gpu.c +++ b/hw/display/vhost-user-gpu.c @@ -193,7 +193,7 @@ vhost_user_gpu_handle_display(VhostUserGPU *g, VhostUserGpuMsg *msg) s = &g->parent_obj.scanout[m->scanout_id]; con = s->con; - if (m->scanout_id == 0 && m->width == 0) { + if (m->width == 0) { s->ds = qemu_create_placeholder_surface(640, 480, "Guest disabled display."); dpy_gfx_replace_surface(con, s->ds); diff --git a/hw/display/virtio-gpu-3d.c b/hw/display/virtio-gpu-3d.c index 0b0c11474dd..9eb489077b1 100644 --- a/hw/display/virtio-gpu-3d.c +++ b/hw/display/virtio-gpu-3d.c @@ -179,10 +179,8 @@ static void virgl_cmd_set_scanout(VirtIOGPU *g, info.width, info.height, ss.r.x, ss.r.y, ss.r.width, ss.r.height); } else { - if (ss.scanout_id != 0) { - dpy_gfx_replace_surface( - g->parent_obj.scanout[ss.scanout_id].con, NULL); - } + dpy_gfx_replace_surface( + g->parent_obj.scanout[ss.scanout_id].con, NULL); dpy_gl_scanout_disable(g->parent_obj.scanout[ss.scanout_id].con); } g->parent_obj.scanout[ss.scanout_id].resource_id = ss.resource_id; @@ -595,9 +593,7 @@ void virtio_gpu_virgl_reset(VirtIOGPU *g) virgl_renderer_reset(); for (i = 0; i < g->parent_obj.conf.max_outputs; i++) { - if (i != 0) { - dpy_gfx_replace_surface(g->parent_obj.scanout[i].con, NULL); - } + dpy_gfx_replace_surface(g->parent_obj.scanout[i].con, NULL); dpy_gl_scanout_disable(g->parent_obj.scanout[i].con); } } diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index 4a57350917c..25f8920fdb6 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -193,9 +193,6 @@ virtio_gpu_base_device_realize(DeviceState *qdev, for (i = 0; i < g->conf.max_outputs; i++) { g->scanout[i].con = graphic_console_init(DEVICE(g), i, &virtio_gpu_ops, g); - if (i > 0) { - dpy_gfx_replace_surface(g->scanout[i].con, NULL); - } } return true; diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index c1f17bec17e..f6c86cb75c6 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -325,7 +325,7 @@ static void virtio_gpu_disable_scanout(VirtIOGPU *g, int scanout_id) { struct virtio_gpu_scanout *scanout = &g->parent_obj.scanout[scanout_id]; struct virtio_gpu_simple_resource *res; - DisplaySurface *ds = NULL; + DisplaySurface *ds; if (scanout->resource_id == 0) { return; @@ -336,12 +336,10 @@ static void virtio_gpu_disable_scanout(VirtIOGPU *g, int scanout_id) res->scanout_bitmask &= ~(1 << scanout_id); } - if (scanout_id == 0) { - /* primary head */ - ds = qemu_create_placeholder_surface(scanout->width ?: 640, - scanout->height ?: 480, - "Guest disabled display."); - } + /* primary head */ + ds = qemu_create_placeholder_surface(scanout->width ?: 640, + scanout->height ?: 480, + "Guest disabled display."); dpy_gfx_replace_surface(scanout->con, ds); scanout->resource_id = 0; scanout->ds = NULL;