mirror of
https://github.com/qemu/qemu.git
synced 2024-11-25 11:53:39 +08:00
ui/console: Add placeholder flag to message surface
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 <akihiko.odaki@gmail.com> Message-Id: <20210225101316.83940-1-akihiko.odaki@gmail.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
4313739a57
commit
b5a087b071
@ -194,8 +194,8 @@ vhost_user_gpu_handle_display(VhostUserGPU *g, VhostUserGpuMsg *msg)
|
|||||||
con = s->con;
|
con = s->con;
|
||||||
|
|
||||||
if (m->scanout_id == 0 && m->width == 0) {
|
if (m->scanout_id == 0 && m->width == 0) {
|
||||||
s->ds = qemu_create_message_surface(640, 480,
|
s->ds = qemu_create_placeholder_surface(640, 480,
|
||||||
"Guest disabled display.");
|
"Guest disabled display.");
|
||||||
dpy_gfx_replace_surface(con, s->ds);
|
dpy_gfx_replace_surface(con, s->ds);
|
||||||
} else {
|
} else {
|
||||||
s->ds = qemu_create_displaysurface(m->width, m->height);
|
s->ds = qemu_create_displaysurface(m->width, m->height);
|
||||||
|
@ -338,9 +338,9 @@ static void virtio_gpu_disable_scanout(VirtIOGPU *g, int scanout_id)
|
|||||||
|
|
||||||
if (scanout_id == 0) {
|
if (scanout_id == 0) {
|
||||||
/* primary head */
|
/* primary head */
|
||||||
ds = qemu_create_message_surface(scanout->width ?: 640,
|
ds = qemu_create_placeholder_surface(scanout->width ?: 640,
|
||||||
scanout->height ?: 480,
|
scanout->height ?: 480,
|
||||||
"Guest disabled display.");
|
"Guest disabled display.");
|
||||||
}
|
}
|
||||||
dpy_gfx_replace_surface(scanout->con, ds);
|
dpy_gfx_replace_surface(scanout->con, ds);
|
||||||
scanout->resource_id = 0;
|
scanout->resource_id = 0;
|
||||||
|
@ -106,6 +106,7 @@ struct QemuConsoleClass {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#define QEMU_ALLOCATED_FLAG 0x01
|
#define QEMU_ALLOCATED_FLAG 0x01
|
||||||
|
#define QEMU_PLACEHOLDER_FLAG 0x02
|
||||||
|
|
||||||
typedef struct DisplaySurface {
|
typedef struct DisplaySurface {
|
||||||
pixman_format_code_t format;
|
pixman_format_code_t format;
|
||||||
@ -259,8 +260,8 @@ DisplaySurface *qemu_create_displaysurface_from(int width, int height,
|
|||||||
pixman_format_code_t format,
|
pixman_format_code_t format,
|
||||||
int linesize, uint8_t *data);
|
int linesize, uint8_t *data);
|
||||||
DisplaySurface *qemu_create_displaysurface_pixman(pixman_image_t *image);
|
DisplaySurface *qemu_create_displaysurface_pixman(pixman_image_t *image);
|
||||||
DisplaySurface *qemu_create_message_surface(int w, int h,
|
DisplaySurface *qemu_create_placeholder_surface(int w, int h,
|
||||||
const char *msg);
|
const char *msg);
|
||||||
PixelFormat qemu_default_pixelformat(int bpp);
|
PixelFormat qemu_default_pixelformat(int bpp);
|
||||||
|
|
||||||
DisplaySurface *qemu_create_displaysurface(int width, int height);
|
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);
|
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 register_displaychangelistener(DisplayChangeListener *dcl);
|
||||||
void update_displaychangelistener(DisplayChangeListener *dcl,
|
void update_displaychangelistener(DisplayChangeListener *dcl,
|
||||||
uint64_t interval);
|
uint64_t interval);
|
||||||
|
11
ui/console.c
11
ui/console.c
@ -1436,8 +1436,8 @@ DisplaySurface *qemu_create_displaysurface_pixman(pixman_image_t *image)
|
|||||||
return surface;
|
return surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
DisplaySurface *qemu_create_message_surface(int w, int h,
|
DisplaySurface *qemu_create_placeholder_surface(int w, int h,
|
||||||
const char *msg)
|
const char *msg)
|
||||||
{
|
{
|
||||||
DisplaySurface *surface = qemu_create_displaysurface(w, h);
|
DisplaySurface *surface = qemu_create_displaysurface(w, h);
|
||||||
pixman_color_t bg = color_table_rgb[0][QEMU_COLOR_BLACK];
|
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);
|
x+i, y, FONT_WIDTH, FONT_HEIGHT);
|
||||||
qemu_pixman_image_unref(glyph);
|
qemu_pixman_image_unref(glyph);
|
||||||
}
|
}
|
||||||
|
surface->flags |= QEMU_PLACEHOLDER_FLAG;
|
||||||
return surface;
|
return surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1550,7 +1551,7 @@ void register_displaychangelistener(DisplayChangeListener *dcl)
|
|||||||
dcl->ops->dpy_gfx_switch(dcl, con->surface);
|
dcl->ops->dpy_gfx_switch(dcl, con->surface);
|
||||||
} else {
|
} else {
|
||||||
if (!dummy) {
|
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);
|
dcl->ops->dpy_gfx_switch(dcl, dummy);
|
||||||
}
|
}
|
||||||
@ -1998,7 +1999,7 @@ QemuConsole *graphic_console_init(DeviceState *dev, uint32_t head,
|
|||||||
&error_abort);
|
&error_abort);
|
||||||
}
|
}
|
||||||
|
|
||||||
surface = qemu_create_message_surface(width, height, noinit);
|
surface = qemu_create_placeholder_surface(width, height, noinit);
|
||||||
dpy_gfx_replace_surface(s, surface);
|
dpy_gfx_replace_surface(s, surface);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
@ -2027,7 +2028,7 @@ void graphic_console_close(QemuConsole *con)
|
|||||||
if (con->gl) {
|
if (con->gl) {
|
||||||
dpy_gl_scanout_disable(con);
|
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);
|
dpy_gfx_replace_surface(con, surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
ui/vnc.c
2
ui/vnc.c
@ -799,7 +799,7 @@ static void vnc_dpy_switch(DisplayChangeListener *dcl,
|
|||||||
|
|
||||||
if (surface == NULL) {
|
if (surface == NULL) {
|
||||||
if (placeholder == NULL) {
|
if (placeholder == NULL) {
|
||||||
placeholder = qemu_create_message_surface(640, 480, placeholder_msg);
|
placeholder = qemu_create_placeholder_surface(640, 480, placeholder_msg);
|
||||||
}
|
}
|
||||||
surface = placeholder;
|
surface = placeholder;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user