diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2013-02-28 15:03:04 +0100 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2013-03-18 10:21:58 +0100 |
commit | c12aeb860c63ba83190f962e2f0a1c5fe18ad3a6 (patch) | |
tree | 4ff23dade55c45cee495d330ad2a2c0d305e760d | |
parent | da229ef3b3c5709b01d62e7a6e213b31bca33d16 (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>
-rw-r--r-- | hw/qxl.c | 9 | ||||
-rw-r--r-- | include/ui/console.h | 7 | ||||
-rw-r--r-- | include/ui/spice-display.h | 3 | ||||
-rw-r--r-- | ui/cocoa.m | 13 | ||||
-rw-r--r-- | ui/console.c | 8 | ||||
-rw-r--r-- | ui/gtk.c | 15 | ||||
-rw-r--r-- | ui/sdl.c | 10 | ||||
-rw-r--r-- | ui/spice-display.c | 12 | ||||
-rw-r--r-- | ui/vnc.c | 21 |
9 files changed, 43 insertions, 55 deletions
@@ -1875,13 +1875,14 @@ static void display_update(DisplayChangeListener *dcl, } } -static void display_resize(DisplayChangeListener *dcl, - struct DisplayState *ds) +static void display_switch(DisplayChangeListener *dcl, + struct DisplayState *ds, + struct DisplaySurface *surface) { PCIQXLDevice *qxl = container_of(dcl, PCIQXLDevice, ssd.dcl); if (qxl->mode == QXL_MODE_VGA) { - qemu_spice_display_resize(&qxl->ssd); + qemu_spice_display_switch(&qxl->ssd, surface); } } @@ -1902,7 +1903,7 @@ static void display_refresh(DisplayChangeListener *dcl, static DisplayChangeListenerOps display_listener_ops = { .dpy_name = "spice/qxl", .dpy_gfx_update = display_update, - .dpy_gfx_resize = display_resize, + .dpy_gfx_switch = display_switch, .dpy_refresh = display_refresh, }; diff --git a/include/ui/console.h b/include/ui/console.h index 63e6e662c7..c8f0050cd6 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -156,10 +156,9 @@ typedef struct DisplayChangeListenerOps { void (*dpy_gfx_update)(DisplayChangeListener *dcl, struct DisplayState *s, int x, int y, int w, int h); - void (*dpy_gfx_resize)(DisplayChangeListener *dcl, - struct DisplayState *s); - void (*dpy_gfx_setdata)(DisplayChangeListener *dcl, - struct DisplayState *s); + void (*dpy_gfx_switch)(DisplayChangeListener *dcl, + struct DisplayState *s, + struct DisplaySurface *new_surface); void (*dpy_gfx_copy)(DisplayChangeListener *dcl, struct DisplayState *s, int src_x, int src_y, int dst_x, int dst_y, int w, int h); diff --git a/include/ui/spice-display.h b/include/ui/spice-display.h index f2752aa25a..82f8246650 100644 --- a/include/ui/spice-display.h +++ b/include/ui/spice-display.h @@ -117,7 +117,8 @@ void qemu_spice_display_init_common(SimpleSpiceDisplay *ssd, DisplayState *ds); void qemu_spice_display_update(SimpleSpiceDisplay *ssd, int x, int y, int w, int h); -void qemu_spice_display_resize(SimpleSpiceDisplay *ssd); +void qemu_spice_display_switch(SimpleSpiceDisplay *ssd, + DisplaySurface *surface); void qemu_spice_display_refresh(SimpleSpiceDisplay *ssd); void qemu_spice_cursor_refresh_unlocked(SimpleSpiceDisplay *ssd); 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); @@ -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, }; @@ -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, }; @@ -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, }; |