aboutsummaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2013-02-28 15:03:04 +0100
committerGerd Hoffmann <kraxel@redhat.com>2013-03-18 10:21:58 +0100
commitc12aeb860c63ba83190f962e2f0a1c5fe18ad3a6 (patch)
tree4ff23dade55c45cee495d330ad2a2c0d305e760d /ui
parentda229ef3b3c5709b01d62e7a6e213b31bca33d16 (diff)
console: rework DisplaySurface handling [dcl/ui side]
Replace the dpy_gfx_resize and dpy_gfx_setdata DisplayChangeListener callbacks with a dpy_gfx_switch callback which notifies the ui code when the framebuffer backing storage changes. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'ui')
-rw-r--r--ui/cocoa.m13
-rw-r--r--ui/console.c8
-rw-r--r--ui/gtk.c15
-rw-r--r--ui/sdl.c10
-rw-r--r--ui/spice-display.c12
-rw-r--r--ui/vnc.c21
6 files changed, 33 insertions, 46 deletions
diff --git a/ui/cocoa.m b/ui/cocoa.m
index b1fb30e7f9..73843f447c 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -988,8 +988,9 @@ static void cocoa_update(DisplayChangeListener *dcl,
[cocoaView setNeedsDisplayInRect:rect];
}
-static void cocoa_resize(DisplayChangeListener *dcl,
- DisplayState *ds)
+static void cocoa_switch(DisplayChangeListener *dcl,
+ DisplayState *ds,
+ DisplaySurface *surface)
{
COCOA_DEBUG("qemu_cocoa: cocoa_resize\n");
@@ -1023,11 +1024,6 @@ static void cocoa_refresh(DisplayChangeListener *dcl,
vga_hw_update();
}
-static void cocoa_setdata(DisplayState *ds)
-{
- [cocoaView updateDataOffset:ds];
-}
-
static void cocoa_cleanup(void)
{
COCOA_DEBUG("qemu_cocoa: cocoa_cleanup\n");
@@ -1037,8 +1033,7 @@ static void cocoa_cleanup(void)
static const DisplayChangeListenerOps dcl_ops = {
.dpy_name = "cocoa",
.dpy_gfx_update = cocoa_update;
- .dpy_gfx_resize = cocoa_resize;
- .dpy_gfx_setdata = cocoa_setdata;
+ .dpy_gfx_switch = cocoa_switch;
.dpy_refresh = cocoa_refresh;
};
diff --git a/ui/console.c b/ui/console.c
index c2ca9e7b93..4541b2c533 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -1372,8 +1372,8 @@ void register_displaychangelistener(DisplayState *ds,
dcl->ds = ds;
QLIST_INSERT_HEAD(&ds->listeners, dcl, next);
gui_setup_refresh(ds);
- if (dcl->ops->dpy_gfx_resize) {
- dcl->ops->dpy_gfx_resize(dcl, ds);
+ if (dcl->ops->dpy_gfx_switch) {
+ dcl->ops->dpy_gfx_switch(dcl, ds, ds->surface);
}
}
@@ -1413,8 +1413,8 @@ void dpy_gfx_replace_surface(DisplayState *s,
s->surface = surface;
QLIST_FOREACH(dcl, &s->listeners, next) {
- if (dcl->ops->dpy_gfx_resize) {
- dcl->ops->dpy_gfx_resize(dcl, s);
+ if (dcl->ops->dpy_gfx_switch) {
+ dcl->ops->dpy_gfx_switch(dcl, s, surface);
}
}
qemu_free_displaysurface(old_surface);
diff --git a/ui/gtk.c b/ui/gtk.c
index b21a94a335..967a36cc4e 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -266,8 +266,9 @@ static void gd_refresh(DisplayChangeListener *dcl,
vga_hw_update();
}
-static void gd_resize(DisplayChangeListener *dcl,
- DisplayState *ds)
+static void gd_switch(DisplayChangeListener *dcl,
+ DisplayState *ds,
+ DisplaySurface *surface)
{
GtkDisplayState *s = container_of(dcl, GtkDisplayState, dcl);
cairo_format_t kind;
@@ -738,7 +739,7 @@ static void gd_menu_zoom_in(GtkMenuItem *item, void *opaque)
s->scale_x += .25;
s->scale_y += .25;
- gd_resize(&s->dcl, s->ds);
+ gd_switch(&s->dcl, s->ds, s->ds->surface);
}
static void gd_menu_zoom_out(GtkMenuItem *item, void *opaque)
@@ -754,7 +755,7 @@ static void gd_menu_zoom_out(GtkMenuItem *item, void *opaque)
s->scale_x = MAX(s->scale_x, .25);
s->scale_y = MAX(s->scale_y, .25);
- gd_resize(&s->dcl, s->ds);
+ gd_switch(&s->dcl, s->ds, s->ds->surface);
}
static void gd_menu_zoom_fixed(GtkMenuItem *item, void *opaque)
@@ -764,7 +765,7 @@ static void gd_menu_zoom_fixed(GtkMenuItem *item, void *opaque)
s->scale_x = 1.0;
s->scale_y = 1.0;
- gd_resize(&s->dcl, s->ds);
+ gd_switch(&s->dcl, s->ds, s->ds->surface);
}
static void gd_menu_zoom_fit(GtkMenuItem *item, void *opaque)
@@ -778,7 +779,7 @@ static void gd_menu_zoom_fit(GtkMenuItem *item, void *opaque)
s->free_scale = FALSE;
}
- gd_resize(&s->dcl, s->ds);
+ gd_switch(&s->dcl, s->ds, s->ds->surface);
gdk_drawable_get_size(gtk_widget_get_window(s->drawing_area), &ww, &wh);
gtk_widget_queue_draw_area(s->drawing_area, 0, 0, ww, wh);
@@ -1287,7 +1288,7 @@ static void gd_create_menus(GtkDisplayState *s)
static const DisplayChangeListenerOps dcl_ops = {
.dpy_name = "gtk",
.dpy_gfx_update = gd_update,
- .dpy_gfx_resize = gd_resize,
+ .dpy_gfx_switch = gd_switch,
.dpy_refresh = gd_refresh,
};
diff --git a/ui/sdl.c b/ui/sdl.c
index fc4dc1b18d..85eefdf4ab 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -117,8 +117,9 @@ static void do_sdl_resize(int width, int height, int bpp)
}
}
-static void sdl_resize(DisplayChangeListener *dcl,
- DisplayState *ds)
+static void sdl_switch(DisplayChangeListener *dcl,
+ DisplayState *ds,
+ DisplaySurface *surface)
{
if (!scaling_active) {
do_sdl_resize(ds_get_width(ds), ds_get_height(ds), 0);
@@ -513,7 +514,7 @@ static void handle_keydown(DisplayState *ds, SDL_Event *ev)
case 0x16: /* 'u' key on US keyboard */
if (scaling_active) {
scaling_active = 0;
- sdl_resize(dcl, ds);
+ sdl_switch(dcl, ds, ds->surface);
vga_hw_invalidate();
vga_hw_update();
}
@@ -856,9 +857,8 @@ static void sdl_cleanup(void)
static const DisplayChangeListenerOps dcl_ops = {
.dpy_name = "sdl",
.dpy_gfx_update = sdl_update,
- .dpy_gfx_resize = sdl_resize,
+ .dpy_gfx_switch = sdl_switch,
.dpy_refresh = sdl_refresh,
- .dpy_gfx_setdata = sdl_setdata,
.dpy_mouse_set = sdl_mouse_warp,
.dpy_cursor_define = sdl_mouse_define,
};
diff --git a/ui/spice-display.c b/ui/spice-display.c
index b2bda23feb..cc2a78e654 100644
--- a/ui/spice-display.c
+++ b/ui/spice-display.c
@@ -367,7 +367,8 @@ void qemu_spice_display_update(SimpleSpiceDisplay *ssd,
qemu_spice_rect_union(&ssd->dirty, &update_area);
}
-void qemu_spice_display_resize(SimpleSpiceDisplay *ssd)
+void qemu_spice_display_switch(SimpleSpiceDisplay *ssd,
+ DisplaySurface *surface)
{
SimpleSpiceUpdate *update;
@@ -589,11 +590,12 @@ static void display_update(DisplayChangeListener *dcl,
qemu_spice_display_update(ssd, x, y, w, h);
}
-static void display_resize(DisplayChangeListener *dcl,
- struct DisplayState *ds)
+static void display_switch(DisplayChangeListener *dcl,
+ struct DisplayState *ds,
+ struct DisplaySurface *surface)
{
SimpleSpiceDisplay *ssd = container_of(dcl, SimpleSpiceDisplay, dcl);
- qemu_spice_display_resize(ssd);
+ qemu_spice_display_switch(ssd, surface);
}
static void display_refresh(DisplayChangeListener *dcl,
@@ -606,7 +608,7 @@ static void display_refresh(DisplayChangeListener *dcl,
static const DisplayChangeListenerOps display_listener_ops = {
.dpy_name = "spice",
.dpy_gfx_update = display_update,
- .dpy_gfx_resize = display_resize,
+ .dpy_gfx_switch = display_switch,
.dpy_refresh = display_refresh,
};
diff --git a/ui/vnc.c b/ui/vnc.c
index a6111d67bf..f8398c344d 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -574,8 +574,9 @@ void *vnc_server_fb_ptr(VncDisplay *vd, int x, int y)
return ptr;
}
-static void vnc_dpy_resize(DisplayChangeListener *dcl,
- DisplayState *ds)
+static void vnc_dpy_switch(DisplayChangeListener *dcl,
+ DisplayState *ds,
+ DisplaySurface *surface)
{
VncDisplay *vd = container_of(dcl, VncDisplay, dcl);
VncState *vs;
@@ -1981,17 +1982,6 @@ static void pixel_format_message (VncState *vs) {
vs->write_pixels = vnc_write_pixels_copy;
}
-static void vnc_dpy_setdata(DisplayChangeListener *dcl,
- DisplayState *ds)
-{
- VncDisplay *vd = container_of(dcl, VncDisplay, dcl);
-
- qemu_pixman_image_unref(vd->guest.fb);
- vd->guest.fb = pixman_image_ref(ds->surface->image);
- vd->guest.format = ds->surface->format;
- vnc_dpy_update(dcl, ds, 0, 0, ds_get_width(ds), ds_get_height(ds));
-}
-
static void vnc_colordepth(VncState *vs)
{
if (vnc_has_feature(vs, VNC_FEATURE_WMVI)) {
@@ -2696,7 +2686,7 @@ static void vnc_init_timer(VncDisplay *vd)
vd->timer_interval = VNC_REFRESH_INTERVAL_BASE;
if (vd->timer == NULL && !QTAILQ_EMPTY(&vd->clients)) {
vd->timer = qemu_new_timer_ms(rt_clock, vnc_refresh, vd);
- vnc_dpy_resize(&vd->dcl, vd->ds);
+ vnc_dpy_switch(&vd->dcl, vd->ds, vd->ds->surface);
vnc_refresh(vd);
}
}
@@ -2836,8 +2826,7 @@ static const DisplayChangeListenerOps dcl_ops = {
.dpy_name = "vnc",
.dpy_gfx_copy = vnc_dpy_copy,
.dpy_gfx_update = vnc_dpy_update,
- .dpy_gfx_resize = vnc_dpy_resize,
- .dpy_gfx_setdata = vnc_dpy_setdata,
+ .dpy_gfx_switch = vnc_dpy_switch,
.dpy_mouse_set = vnc_mouse_set,
.dpy_cursor_define = vnc_dpy_cursor_define,
};