ui/console: message surface tweaks.
ui/cocoa: bugfixes and cleanups. -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEoDKM/7k6F6eZAf59TLbY7tPocTgFAmBAnCUACgkQTLbY7tPo cTj0dA//ZLetPdIEfGHmNMsGGw1/atXXWtyX3/W2WlNLgGda3lhRqcL0Zyqx0LV6 b4uzPB65ySY/BkSuRlMorZ+GRyTiNWOc+6nieMFdFOPCC7XmNvbVSf+oDspLeuDy zfxqasEI6PUyLiA+HVjyD+VeI3QbQSGJ9WmkeZTR9Rwivh8koawXcndAjsGSED92 W0piI+iXuWxbT+mny3IbZXGNLqQI0bdDUeJFnBxZeYD4TY9R937ZsV6FNmLgUlPD gPTZP0YsrKqhYPaOYYy2U1YYreR6Qxbdmdg7jyroX/n4n4CIUx3f8eDc7aCKhkkC kIPwukP748KznkJWHTqSM6fhtJPj27LE0vX0vH0bMM5FolMhKWEMRCV0UhT8Y6z+ UqB3cRqB+r0vBMOaP+DyWyb8W4zWulPtdZr11KWv6x3Jv8+G5yC3ZUfuzpOUxHjT Q/l6tZmwnS/1ZXCuAyB/sZzzfiDlf7tv31QF2KrDeuvTdEb9oHqivkaxhJzbsUXD WkvoN858b+1jRCLCra2vjhNbKvEujlP2dlCpjOPUQFZ9pYx57WxcS7dNHZv2+nem +6m4RVeihZf8SZpaJQz2Xl3ZBecX8C2MMrsq3O+7TjWY4T45IltjXq31rMEBv3NQ F47AxY+P5RHzKb3Rq61HqXw+jvxNlslG0tPk/mz9pCgPE3efpQM= =TxNe -----END PGP SIGNATURE----- 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>
This commit is contained in:
commit
fe352f5c00
37
configure
vendored
37
configure
vendored
@ -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
|
||||
|
@ -250,7 +250,8 @@
|
||||
# "type": "gpu",
|
||||
# "binary": "/usr/libexec/qemu/vhost-user-gpu",
|
||||
# "tags": [
|
||||
# "CONFIG_OPENGL_DMABUF=y"
|
||||
# "CONFIG_OPENGL=y",
|
||||
# "CONFIG_GBM=y"
|
||||
# ]
|
||||
# }
|
||||
#
|
||||
|
@ -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 */
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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'
|
||||
|
55
ui/cocoa.m
55
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];
|
||||
|
28
ui/console.c
28
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;
|
||||
|
||||
assert(old_surface != surface || surface == NULL);
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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));
|
||||
|
29
ui/gtk.c
29
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
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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));
|
||||
|
10
ui/vnc.c
10
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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user