summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Maydell2021-03-04 13:58:50 +0100
committerPeter Maydell2021-03-04 13:58:50 +0100
commitfe352f5c0056b4d21ae033ec49acc0bce9897e53 (patch)
tree5dabd93c86901bac296940d138ed7bb9b1b680df
parentMerge remote-tracking branch 'remotes/dgilbert-gitlab/tags/pull-virtiofs-2021... (diff)
parentvirtio-gpu: Do not distinguish the primary console (diff)
downloadqemu-fe352f5c0056b4d21ae033ec49acc0bce9897e53.tar.gz
qemu-fe352f5c0056b4d21ae033ec49acc0bce9897e53.tar.xz
qemu-fe352f5c0056b4d21ae033ec49acc0bce9897e53.zip
Merge remote-tracking branch 'remotes/kraxel/tags/ui-20210304-pull-request' into staging
ui/console: message surface tweaks. ui/cocoa: bugfixes and cleanups. # gpg: Signature made Thu 04 Mar 2021 08:36:53 GMT # gpg: using RSA key A0328CFFB93A17A79901FE7D4CB6D8EED3E87138 # gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>" [full] # gpg: aka "Gerd Hoffmann <gerd@kraxel.org>" [full] # gpg: aka "Gerd Hoffmann (private) <kraxel@gmail.com>" [full] # Primary key fingerprint: A032 8CFF B93A 17A7 9901 FE7D 4CB6 D8EE D3E8 7138 * remotes/kraxel/tags/ui-20210304-pull-request: virtio-gpu: Do not distinguish the primary console ui/console: Pass placeholder surface to displays ui/console: Add placeholder flag to message surface ui/cocoa: Replace fprintf with error_report configure: Improve OpenGL dependency detections ui/cocoa: Fix stride resolution of pixman image ui/gtk: vte: fix sending multiple characeters ui/cocoa: Remove the uses of full screen APIs Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rwxr-xr-xconfigure37
-rw-r--r--docs/interop/vhost-user.json3
-rw-r--r--hw/display/vhost-user-gpu.c6
-rw-r--r--hw/display/virtio-gpu-3d.c10
-rw-r--r--hw/display/virtio-gpu-base.c3
-rw-r--r--hw/display/virtio-gpu.c9
-rw-r--r--include/ui/console.h10
-rw-r--r--include/ui/egl-helpers.h9
-rw-r--r--include/ui/spice-display.h2
-rw-r--r--meson.build2
-rw-r--r--ui/cocoa.m55
-rw-r--r--ui/console.c28
-rw-r--r--ui/egl-helpers.c8
-rw-r--r--ui/gtk-egl.c6
-rw-r--r--ui/gtk-gl-area.c2
-rw-r--r--ui/gtk.c29
-rw-r--r--ui/meson.build8
-rw-r--r--ui/sdl2-2d.c7
-rw-r--r--ui/sdl2-gl.c4
-rw-r--r--ui/spice-display.c6
-rw-r--r--ui/vnc.c10
21 files changed, 131 insertions, 123 deletions
diff --git a/configure b/configure
index cc435e2503..34fccaa2ba 100755
--- a/configure
+++ b/configure
@@ -394,7 +394,6 @@ u2f="auto"
libusb="$default_feature"
usb_redir="$default_feature"
opengl="$default_feature"
-opengl_dmabuf="no"
cpuid_h="no"
avx2_opt="$default_feature"
capstone="auto"
@@ -3606,14 +3605,24 @@ if $pkg_config gbm; then
fi
if test "$opengl" != "no" ; then
- opengl_pkgs="epoxy gbm"
- if $pkg_config $opengl_pkgs; then
- opengl_cflags="$($pkg_config --cflags $opengl_pkgs)"
- opengl_libs="$($pkg_config --libs $opengl_pkgs)"
+ epoxy=no
+ if $pkg_config epoxy; then
+ cat > $TMPC << EOF
+#include <epoxy/egl.h>
+int main(void) { return 0; }
+EOF
+ if compile_prog "" "" ; then
+ epoxy=yes
+ fi
+ fi
+
+ if test "$epoxy" = "yes" ; then
+ opengl_cflags="$($pkg_config --cflags epoxy)"
+ opengl_libs="$($pkg_config --libs epoxy)"
opengl=yes
else
if test "$opengl" = "yes" ; then
- feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
+ feature_not_found "opengl" "Please install epoxy with EGL"
fi
opengl_cflags=""
opengl_libs=""
@@ -3621,19 +3630,6 @@ if test "$opengl" != "no" ; then
fi
fi
-if test "$opengl" = "yes"; then
- cat > $TMPC << EOF
-#include <epoxy/egl.h>
-#ifndef EGL_MESA_image_dma_buf_export
-# error mesa/epoxy lacks support for dmabufs (mesa 10.6+)
-#endif
-int main(void) { return 0; }
-EOF
- if compile_prog "" "" ; then
- opengl_dmabuf=yes
- fi
-fi
-
##########################################
# libxml2 probe
if test "$libxml2" != "no" ; then
@@ -5836,9 +5832,6 @@ if test "$opengl" = "yes" ; then
echo "CONFIG_OPENGL=y" >> $config_host_mak
echo "OPENGL_CFLAGS=$opengl_cflags" >> $config_host_mak
echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
- if test "$opengl_dmabuf" = "yes" ; then
- echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
- fi
fi
if test "$gbm" = "yes" ; then
diff --git a/docs/interop/vhost-user.json b/docs/interop/vhost-user.json
index feb5fe58ca..b6ade9e493 100644
--- a/docs/interop/vhost-user.json
+++ b/docs/interop/vhost-user.json
@@ -250,7 +250,8 @@
# "type": "gpu",
# "binary": "/usr/libexec/qemu/vhost-user-gpu",
# "tags": [
-# "CONFIG_OPENGL_DMABUF=y"
+# "CONFIG_OPENGL=y",
+# "CONFIG_GBM=y"
# ]
# }
#
diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c
index 4d8cb3525b..a01f9315e1 100644
--- a/hw/display/vhost-user-gpu.c
+++ b/hw/display/vhost-user-gpu.c
@@ -193,10 +193,8 @@ 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) {
- s->ds = qemu_create_message_surface(640, 480,
- "Guest disabled display.");
- dpy_gfx_replace_surface(con, s->ds);
+ if (m->width == 0) {
+ dpy_gfx_replace_surface(con, NULL);
} else {
s->ds = qemu_create_displaysurface(m->width, m->height);
/* replace surface on next update */
diff --git a/hw/display/virtio-gpu-3d.c b/hw/display/virtio-gpu-3d.c
index 0b0c11474d..9eb489077b 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 4a57350917..25f8920fdb 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 2e4a9822b6..c9f5e36fd0 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -325,7 +325,6 @@ 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;
if (scanout->resource_id == 0) {
return;
@@ -336,13 +335,7 @@ 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_message_surface(scanout->width ?: 640,
- scanout->height ?: 480,
- "Guest disabled display.");
- }
- dpy_gfx_replace_surface(scanout->con, ds);
+ dpy_gfx_replace_surface(scanout->con, NULL);
scanout->resource_id = 0;
scanout->ds = NULL;
scanout->width = 0;
diff --git a/include/ui/console.h b/include/ui/console.h
index d30e972d0b..c960b7066c 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/include/ui/egl-helpers.h b/include/ui/egl-helpers.h
index 5b1f7fafe0..f1bf8f97fc 100644
--- a/include/ui/egl-helpers.h
+++ b/include/ui/egl-helpers.h
@@ -3,7 +3,9 @@
#include <epoxy/gl.h>
#include <epoxy/egl.h>
+#ifdef CONFIG_GBM
#include <gbm.h>
+#endif
#include "ui/console.h"
#include "ui/shader.h"
@@ -31,7 +33,7 @@ void egl_texture_blit(QemuGLShader *gls, egl_fb *dst, egl_fb *src, bool flip);
void egl_texture_blend(QemuGLShader *gls, egl_fb *dst, egl_fb *src, bool flip,
int x, int y, double scale_x, double scale_y);
-#ifdef CONFIG_OPENGL_DMABUF
+#ifdef CONFIG_GBM
extern int qemu_egl_rn_fd;
extern struct gbm_device *qemu_egl_rn_gbm_dev;
@@ -48,8 +50,13 @@ void egl_dmabuf_release_texture(QemuDmaBuf *dmabuf);
EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, EGLNativeWindowType win);
+#if defined(CONFIG_X11) || defined(CONFIG_GBM)
+
int qemu_egl_init_dpy_x11(EGLNativeDisplayType dpy, DisplayGLMode mode);
int qemu_egl_init_dpy_mesa(EGLNativeDisplayType dpy, DisplayGLMode mode);
+
+#endif
+
EGLContext qemu_egl_init_ctx(void);
bool qemu_egl_has_dmabuf(void);
diff --git a/include/ui/spice-display.h b/include/ui/spice-display.h
index 4a47ffdd4c..ed298d58f0 100644
--- a/include/ui/spice-display.h
+++ b/include/ui/spice-display.h
@@ -27,7 +27,7 @@
#include "ui/qemu-pixman.h"
#include "ui/console.h"
-#if defined(CONFIG_OPENGL_DMABUF)
+#if defined(CONFIG_OPENGL) && defined(CONFIG_GBM)
# if SPICE_SERVER_VERSION >= 0x000d01 /* release 0.13.1 */
# define HAVE_SPICE_GL 1
# include "ui/egl-helpers.h"
diff --git a/meson.build b/meson.build
index 07bc23129a..81d760d6e8 100644
--- a/meson.build
+++ b/meson.build
@@ -2657,7 +2657,7 @@ summary_info += {'U2F support': u2f.found()}
summary_info += {'libusb': config_host.has_key('CONFIG_USB_LIBUSB')}
summary_info += {'usb net redir': config_host.has_key('CONFIG_USB_REDIR')}
summary_info += {'OpenGL support': config_host.has_key('CONFIG_OPENGL')}
-summary_info += {'OpenGL dmabufs': config_host.has_key('CONFIG_OPENGL_DMABUF')}
+summary_info += {'GBM': config_host.has_key('CONFIG_GBM')}
summary_info += {'libiscsi support': libiscsi.found()}
summary_info += {'libnfs support': libnfs.found()}
if targetos == 'windows'
diff --git a/ui/cocoa.m b/ui/cocoa.m
index 0ef5fdf3b7..f27beb30e6 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -270,7 +270,7 @@ const int mac_to_qkeycode_map[] = {
static int cocoa_keycode_to_qemu(int keycode)
{
if (ARRAY_SIZE(mac_to_qkeycode_map) <= keycode) {
- fprintf(stderr, "(cocoa) warning unknown keycode 0x%x\n", keycode);
+ error_report("(cocoa) warning unknown keycode 0x%x", keycode);
return 0;
}
return mac_to_qkeycode_map[keycode];
@@ -450,19 +450,19 @@ QemuCocoaView *cocoaView;
int w = pixman_image_get_width(pixman_image);
int h = pixman_image_get_height(pixman_image);
int bitsPerPixel = PIXMAN_FORMAT_BPP(pixman_image_get_format(pixman_image));
- int bitsPerComponent = DIV_ROUND_UP(bitsPerPixel, 8) * 2;
+ int stride = pixman_image_get_stride(pixman_image);
CGDataProviderRef dataProviderRef = CGDataProviderCreateWithData(
NULL,
pixman_image_get_data(pixman_image),
- w * 4 * h,
+ stride * h,
NULL
);
CGImageRef imageRef = CGImageCreate(
w, //width
h, //height
- bitsPerComponent, //bitsPerComponent
+ DIV_ROUND_UP(bitsPerPixel, 8) * 2, //bitsPerComponent
bitsPerPixel, //bitsPerPixel
- (w * (bitsPerComponent/2)), //bytesPerRow
+ stride, //bytesPerRow
#ifdef __LITTLE_ENDIAN__
CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB), //colorspace for OS X >= 10.4
kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipFirst,
@@ -585,37 +585,26 @@ QemuCocoaView *cocoaView;
isFullscreen = FALSE;
[self ungrabMouse];
[self setContentDimensions];
- if ([NSView respondsToSelector:@selector(exitFullScreenModeWithOptions:)]) { // test if "exitFullScreenModeWithOptions" is supported on host at runtime
- [self exitFullScreenModeWithOptions:nil];
- } else {
- [fullScreenWindow close];
- [normalWindow setContentView: self];
- [normalWindow makeKeyAndOrderFront: self];
- [NSMenu setMenuBarVisible:YES];
- }
+ [fullScreenWindow close];
+ [normalWindow setContentView: self];
+ [normalWindow makeKeyAndOrderFront: self];
+ [NSMenu setMenuBarVisible:YES];
} else { // switch from desktop to fullscreen
isFullscreen = TRUE;
[normalWindow orderOut: nil]; /* Hide the window */
[self grabMouse];
[self setContentDimensions];
- if ([NSView respondsToSelector:@selector(enterFullScreenMode:withOptions:)]) { // test if "enterFullScreenMode:withOptions" is supported on host at runtime
- [self enterFullScreenMode:[NSScreen mainScreen] withOptions:[NSDictionary dictionaryWithObjectsAndKeys:
- [NSNumber numberWithBool:NO], NSFullScreenModeAllScreens,
- [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:NO], kCGDisplayModeIsStretched, nil], NSFullScreenModeSetting,
- nil]];
- } else {
- [NSMenu setMenuBarVisible:NO];
- fullScreenWindow = [[NSWindow alloc] initWithContentRect:[[NSScreen mainScreen] frame]
- styleMask:NSWindowStyleMaskBorderless
- backing:NSBackingStoreBuffered
- defer:NO];
- [fullScreenWindow setAcceptsMouseMovedEvents: YES];
- [fullScreenWindow setHasShadow:NO];
- [fullScreenWindow setBackgroundColor: [NSColor blackColor]];
- [self setFrame:NSMakeRect(cx, cy, cw, ch)];
- [[fullScreenWindow contentView] addSubview: self];
- [fullScreenWindow makeKeyAndOrderFront:self];
- }
+ [NSMenu setMenuBarVisible:NO];
+ fullScreenWindow = [[NSWindow alloc] initWithContentRect:[[NSScreen mainScreen] frame]
+ styleMask:NSWindowStyleMaskBorderless
+ backing:NSBackingStoreBuffered
+ defer:NO];
+ [fullScreenWindow setAcceptsMouseMovedEvents: YES];
+ [fullScreenWindow setHasShadow:NO];
+ [fullScreenWindow setBackgroundColor: [NSColor blackColor]];
+ [self setFrame:NSMakeRect(cx, cy, cw, ch)];
+ [[fullScreenWindow contentView] addSubview: self];
+ [fullScreenWindow makeKeyAndOrderFront:self];
}
}
@@ -1071,7 +1060,7 @@ QemuCocoaView *cocoaView;
// create a view and add it to the window
cocoaView = [[QemuCocoaView alloc] initWithFrame:NSMakeRect(0.0, 0.0, 640.0, 480.0)];
if(!cocoaView) {
- fprintf(stderr, "(cocoa) can't create a view\n");
+ error_report("(cocoa) can't create a view");
exit(1);
}
@@ -1080,7 +1069,7 @@ QemuCocoaView *cocoaView;
styleMask:NSWindowStyleMaskTitled|NSWindowStyleMaskMiniaturizable|NSWindowStyleMaskClosable
backing:NSBackingStoreBuffered defer:NO];
if(!normalWindow) {
- fprintf(stderr, "(cocoa) can't create window\n");
+ error_report("(cocoa) can't create window");
exit(1);
}
[normalWindow setAcceptsMouseMovedEvents:YES];
diff --git a/ui/console.c b/ui/console.c
index c5d11bc701..171a7bf14b 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];
@@ -1454,6 +1454,7 @@ DisplaySurface *qemu_create_message_surface(int w, int h,
x+i, y, FONT_WIDTH, FONT_HEIGHT);
qemu_pixman_image_unref(glyph);
}
+ surface->flags |= QEMU_PLACEHOLDER_FLAG;
return surface;
}
@@ -1550,7 +1551,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);
}
@@ -1674,11 +1675,26 @@ void dpy_gfx_update_full(QemuConsole *con)
void dpy_gfx_replace_surface(QemuConsole *con,
DisplaySurface *surface)
{
+ static const char placeholder_msg[] = "Display output is not active.";
DisplayState *s = con->ds;
DisplaySurface *old_surface = con->surface;
DisplayChangeListener *dcl;
+ int width;
+ int height;
+
+ if (!surface) {
+ if (old_surface) {
+ width = surface_width(old_surface);
+ height = surface_height(old_surface);
+ } else {
+ width = 640;
+ height = 480;
+ }
+
+ surface = qemu_create_placeholder_surface(width, height, placeholder_msg);
+ }
- assert(old_surface != surface || surface == NULL);
+ assert(old_surface != surface);
con->surface = surface;
QLIST_FOREACH(dcl, &s->listeners, next) {
@@ -1998,7 +2014,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 +2043,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/egl-helpers.c b/ui/egl-helpers.c
index 73fe61f878..6d0cb2b5cb 100644
--- a/ui/egl-helpers.c
+++ b/ui/egl-helpers.c
@@ -140,7 +140,7 @@ void egl_texture_blend(QemuGLShader *gls, egl_fb *dst, egl_fb *src, bool flip,
/* ---------------------------------------------------------------------- */
-#ifdef CONFIG_OPENGL_DMABUF
+#ifdef CONFIG_GBM
int qemu_egl_rn_fd;
struct gbm_device *qemu_egl_rn_gbm_dev;
@@ -287,7 +287,7 @@ void egl_dmabuf_release_texture(QemuDmaBuf *dmabuf)
dmabuf->texture = 0;
}
-#endif /* CONFIG_OPENGL_DMABUF */
+#endif /* CONFIG_GBM */
/* ---------------------------------------------------------------------- */
@@ -315,6 +315,8 @@ EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, EGLNativeWindowType win)
/* ---------------------------------------------------------------------- */
+#if defined(CONFIG_X11) || defined(CONFIG_GBM)
+
/*
* Taken from glamor_egl.h from the Xorg xserver, which is MIT licensed
*
@@ -441,6 +443,8 @@ int qemu_egl_init_dpy_mesa(EGLNativeDisplayType dpy, DisplayGLMode mode)
#endif
}
+#endif
+
bool qemu_egl_has_dmabuf(void)
{
if (qemu_egl_display == EGL_NO_DISPLAY) {
diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c
index 588e7b1bb1..2a2e6d3a17 100644
--- a/ui/gtk-egl.c
+++ b/ui/gtk-egl.c
@@ -208,7 +208,7 @@ void gd_egl_scanout_texture(DisplayChangeListener *dcl,
void gd_egl_scanout_dmabuf(DisplayChangeListener *dcl,
QemuDmaBuf *dmabuf)
{
-#ifdef CONFIG_OPENGL_DMABUF
+#ifdef CONFIG_GBM
egl_dmabuf_import_texture(dmabuf);
if (!dmabuf->texture) {
return;
@@ -224,7 +224,7 @@ void gd_egl_cursor_dmabuf(DisplayChangeListener *dcl,
QemuDmaBuf *dmabuf, bool have_hot,
uint32_t hot_x, uint32_t hot_y)
{
-#ifdef CONFIG_OPENGL_DMABUF
+#ifdef CONFIG_GBM
VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl);
if (dmabuf) {
@@ -252,7 +252,7 @@ void gd_egl_cursor_position(DisplayChangeListener *dcl,
void gd_egl_release_dmabuf(DisplayChangeListener *dcl,
QemuDmaBuf *dmabuf)
{
-#ifdef CONFIG_OPENGL_DMABUF
+#ifdef CONFIG_GBM
egl_dmabuf_release_texture(dmabuf);
#endif
}
diff --git a/ui/gtk-gl-area.c b/ui/gtk-gl-area.c
index 4e8ee88b9b..dd5783fec7 100644
--- a/ui/gtk-gl-area.c
+++ b/ui/gtk-gl-area.c
@@ -219,7 +219,7 @@ void gd_gl_area_scanout_flush(DisplayChangeListener *dcl,
void gd_gl_area_scanout_dmabuf(DisplayChangeListener *dcl,
QemuDmaBuf *dmabuf)
{
-#ifdef CONFIG_OPENGL_DMABUF
+#ifdef CONFIG_GBM
VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl);
gtk_gl_area_make_current(GTK_GL_AREA(vc->gfx.drawing_area));
diff --git a/ui/gtk.c b/ui/gtk.c
index 79dc240120..3edaf041de 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
@@ -657,6 +653,8 @@ static const DisplayChangeListenerOps dcl_gl_area_ops = {
.dpy_has_dmabuf = gd_has_dmabuf,
};
+#ifdef CONFIG_X11
+
static const DisplayChangeListenerOps dcl_egl_ops = {
.dpy_name = "gtk-egl",
.dpy_gfx_update = gd_egl_update,
@@ -679,6 +677,8 @@ static const DisplayChangeListenerOps dcl_egl_ops = {
.dpy_has_dmabuf = gd_has_dmabuf,
};
+#endif
+
#endif /* CONFIG_OPENGL */
/** QEMU Events **/
@@ -797,8 +797,12 @@ static gboolean gd_draw_event(GtkWidget *widget, cairo_t *cr, void *opaque)
/* invoke render callback please */
return FALSE;
} else {
+#ifdef CONFIG_X11
gd_egl_draw(vc);
return TRUE;
+#else
+ abort();
+#endif
}
}
#endif
@@ -1786,7 +1790,16 @@ static gboolean gd_vc_in(VteTerminal *terminal, gchar *text, guint size,
}
}
- qemu_chr_be_write(vc->vte.chr, (uint8_t *)text, (unsigned int)size);
+ int remaining = size;
+ uint8_t* p = (uint8_t *)text;
+ while (remaining > 0) {
+ int can_write = qemu_chr_be_can_write(vc->vte.chr);
+ int written = MIN(remaining, can_write);
+ qemu_chr_be_write(vc->vte.chr, p, written);
+
+ remaining -= written;
+ p += written;
+ }
return TRUE;
}
@@ -2022,6 +2035,7 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, VirtualConsole *vc,
G_CALLBACK(gl_area_realize), vc);
vc->gfx.dcl.ops = &dcl_gl_area_ops;
} else {
+#ifdef CONFIG_X11
vc->gfx.drawing_area = gtk_drawing_area_new();
/*
* gtk_widget_set_double_buffered() was deprecated in 3.14.
@@ -2035,6 +2049,9 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, VirtualConsole *vc,
#pragma GCC diagnostic pop
vc->gfx.dcl.ops = &dcl_egl_ops;
vc->gfx.has_dmabuf = qemu_egl_has_dmabuf();
+#else
+ abort();
+#endif
}
} else
#endif
@@ -2345,8 +2362,10 @@ static void early_gtk_display_init(DisplayOptions *opts)
} else
#endif
{
+#ifdef CONFIG_X11
DisplayGLMode mode = opts->has_gl ? opts->gl : DISPLAYGL_MODE_ON;
gtk_egl_init(mode);
+#endif
}
#endif
}
diff --git a/ui/meson.build b/ui/meson.build
index 156b600a99..e8d3ff41b9 100644
--- a/ui/meson.build
+++ b/ui/meson.build
@@ -45,14 +45,15 @@ endif
if config_host.has_key('CONFIG_OPENGL')
opengl_ss = ss.source_set()
+ opengl_ss.add(gbm)
opengl_ss.add(when: [opengl, pixman, 'CONFIG_OPENGL'],
if_true: files('shader.c', 'console-gl.c', 'egl-helpers.c', 'egl-context.c'))
ui_modules += {'opengl' : opengl_ss}
endif
-if config_host.has_key('CONFIG_OPENGL_DMABUF')
+if config_host.has_key('CONFIG_OPENGL') and gbm.found()
egl_headless_ss = ss.source_set()
- egl_headless_ss.add(when: [opengl, pixman, 'CONFIG_OPENGL_DMABUF'],
+ egl_headless_ss.add(when: [opengl, gbm, pixman, 'CONFIG_OPENGL'],
if_true: files('egl-headless.c'))
ui_modules += {'egl-headless' : egl_headless_ss}
endif
@@ -63,7 +64,8 @@ if gtk.found()
gtk_ss = ss.source_set()
gtk_ss.add(gtk, vte, pixman, files('gtk.c'))
gtk_ss.add(when: x11, if_true: files('x_keymap.c'))
- gtk_ss.add(when: [opengl, 'CONFIG_OPENGL'], if_true: files('gtk-egl.c', 'gtk-gl-area.c'))
+ gtk_ss.add(when: [opengl, 'CONFIG_OPENGL'], if_true: files('gtk-gl-area.c'))
+ gtk_ss.add(when: [x11, opengl, 'CONFIG_OPENGL'], if_true: files('gtk-egl.c'))
ui_modules += {'gtk' : gtk_ss}
endif
diff --git a/ui/sdl2-2d.c b/ui/sdl2-2d.c
index a2ea85127d..bfebbdeaea 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 fd594d7461..a21d2deed9 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 ad93b953a9..d22781a23d 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 16bb3be770..310abc9378 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_message_surface(640, 480, placeholder_msg);
- }
- surface = placeholder;
- }
-
vnc_abort_display_jobs(vd);
vd->ds = surface;