DisplayState interface change
PATCH 1/1 DisplayState interface change
Hi all,
this patch changes the DisplayState interface adding support for multiple frontends at the same time (sdl and vnc) and implements most of the benefit of the shared_buf patch without the added complexity.
Currently DisplayState is managed by sdl (or vnc) and sdl (or vnc) is also responsible for allocating the data and setting the depth. Vga.c (or another backend) will do any necessary conversion.
The idea is to change it so that is vga.c (or another backend) that fully manages the DisplayState interface allocating data and setting the depth (either 16 or 32 bit, if the guest uses a different resolution or is in text mode, vga.c (or another backend) is in charge of doing the conversion seamlessly).
The other idea is that DisplayState supports *multiple* frontends like sdl and vnc; each of them can register some callbacks to be called when a display event occurs.
---
console.c +181 -58
@@ -190,7 +190,7 @@ {unsigned int r, g, b, color; -switch (ds->depth) { +switch (ds->surface->pf.bits_per_pixel) {#if 0 case 8 : r = (rgba >>16 ) &0xff ;
@@ -227,9 +227,9 @@uint8_t *d, *d1;int x, y, bpp; - bpp = (ds->depth +7 ) >>3 ; - d1 = ds->data + - ds->linesize * posy + bpp * posx; + bpp = (ds->surface->pf.bits_per_pixel +7 ) >>3 ; + d1 = ds->surface->data + + ds->surface->linesize * posy + bpp * posx;for (y =0 ; y < height; y++) { d = d1;switch (bpp) {
@@ -252,7 +252,7 @@ }break ; } - d1 += ds->linesize; + d1 += ds->surface->linesize; } }
@@ -263,27 +263,27 @@uint8_t *d;int wb, y, bpp; - bpp = (ds->depth +7 ) >>3 ; + bpp = (ds->surface->pf.bits_per_pixel +7 ) >>3 ; wb = w * bpp;if (yd <= ys) { - s = ds->data + - ds->linesize * ys + bpp * xs; - d = ds->data + - ds->linesize * yd + bpp * xd; + s = ds->surface->data + + ds->surface->linesize * ys + bpp * xs; + d = ds->surface->data + + ds->surface->linesize * yd + bpp * xd;for (y =0 ; y < h; y++) {memmove (d, s, wb); - d += ds->linesize; - s += ds->linesize; + d += ds->surface->linesize; + s += ds->surface->linesize; } }else { - s = ds->data + - ds->linesize * (ys + h -1 ) + bpp * xs; - d = ds->data + - ds->linesize * (yd + h -1 ) + bpp * xd; + s = ds->surface->data + + ds->surface->linesize * (ys + h -1 ) + bpp * xs; + d = ds->surface->data + + ds->surface->linesize * (yd + h -1 ) + bpp * xd;for (y =0 ; y < h; y++) {memmove (d, s, wb); - d -= ds->linesize; - s -= ds->linesize; + d -= ds->surface->linesize; + s -= ds->surface->linesize; } } }
@@ -373,7 +373,7 @@static inline unsigned int col_expand (DisplayState *ds,unsigned int col) { -switch (ds->depth) { +switch (ds->surface->pf.bits_per_pixel) {case 8 : col |= col <<8 ; col |= col <<16 ;
@@ -443,13 +443,13 @@ bgcol = color_table[t_attrib->bold][t_attrib->bgcol]; } - bpp = (ds->depth +7 ) >>3 ; - d = ds->data + - ds->linesize * y *FONT_HEIGHT + bpp * x *FONT_WIDTH ; - linesize = ds->linesize; + bpp = (ds->surface->pf.bits_per_pixel +7 ) >>3 ; + d = ds->surface->data + + ds->surface->linesize * y *FONT_HEIGHT + bpp * x *FONT_WIDTH ; + linesize = ds->surface->linesize; font_ptr = vgafont16 +FONT_HEIGHT * ch; xorcol = bgcol ^ fgcol; -switch (ds->depth) { +switch (ds->surface->pf.bits_per_pixel) {case 8 :for (i =0 ; i <FONT_HEIGHT ; i++) { font_data = *font_ptr++;
@@ -543,7 +543,7 @@int y1, y2;if (s == active_console) { -if (!s->ds->depth) { +if (!s->ds->surface->pf.bits_per_pixel) {text_update_xy (s, x, y);return ; }
@@ -570,7 +570,7 @@if (s == active_console) {int x = s->x; -if (!s->ds->depth) { +if (!s->ds->surface->pf.depth) { s->cursor_invalidate =1 ;return ; }
@@ -604,7 +604,7 @@if (s != active_console)return ; -if (!s->ds->depth) { +if (!s->ds->surface->pf.bits_per_pixel) { s->text_x[0 ] =0 ; s->text_y[0 ] =0 ; s->text_x[1 ] = s->width -1 ;
@@ -613,7 +613,7 @@return ; } -vga_fill_rect (s->ds,0 ,0 , s->ds->width, s->ds->height, +vga_fill_rect (s->ds,0 ,0 , s->ds->surface->width, s->ds->surface->height, color_table[0 ][COLOR_BLACK ]); y1 = s->y_displayed;for (y =0 ; y < s->height; y++) {
@@ -626,7 +626,7 @@if (++y1 == s->total_height) y1 =0 ; } -dpy_update (s->ds,0 ,0 , s->ds->width, s->ds->height); +dpy_update (s->ds,0 ,0 , s->ds->surface->width, s->ds->surface->height);console_show_cursor (s,1 ); }
@@ -689,7 +689,7 @@ c++; }if (s == active_console && s->y_displayed == s->y_base) { -if (!s->ds->depth) { +if (!s->ds->surface->pf.bits_per_pixel) { s->text_x[0 ] =0 ; s->text_y[0 ] =0 ; s->text_x[1 ] = s->width -1 ;
@@ -1044,12 +1044,15 @@if (index >=MAX_CONSOLES )return ; + active_console->g_width = active_console->ds->surface->width; + active_console->g_height = active_console->ds->surface->height; s = consoles[index];if (s) { +DisplayState *ds = s->ds; active_console = s; -if (s->console_type !=TEXT_CONSOLE && s->g_width && s->g_height - && (s->g_width != s->ds->width || s->g_height != s->ds->height)) -dpy_resize (s->ds, s->g_width, s->g_height); + ds->surface =qemu_resizeDisplaySurface (ds->surface, s->g_width, + s->g_height,32 ,4 * s->g_width); +dpy_resize (s->ds);vga_hw_invalidate (); } }
@@ -1158,15 +1161,6 @@ {TextConsole *s = (TextConsole *) opaque; -if (s->g_width != s->ds->width || s->g_height != s->ds->height) { -if (s->console_type ==TEXT_CONSOLE_FIXED_SIZE ) -dpy_resize (s->ds, s->g_width, s->g_height); -else { - s->g_width = s->ds->width; - s->g_height = s->ds->height; -text_console_resize (s); - } - }console_refresh (s); }
@@ -1247,6 +1241,11 @@return s; } +int is_active_console (QEMUConsole *s) +{ +return (active_console == s); +} +int is_graphic_console (void ) {return active_console && active_console->console_type ==GRAPHIC_CONSOLE ;
@@ -1302,8 +1301,8 @@ s->total_height =DEFAULT_BACKSCROLL ; s->x =0 ; s->y =0 ; - width = s->ds->width; - height = s->ds->height; + width = s->ds->surface->width; + height = s->ds->surface->height;if (p !=0 ) { width =strtoul (p, (char **)&p,10 );if (*p =='C' ) {
@@ -1346,13 +1345,12 @@void qemu_console_resize (QEMUConsole *console,int width,int height) { -if (console->g_width != width || console->g_height != height - || !console->ds->data) { - console->g_width = width; - console->g_height = height; -if (active_console == console) { -dpy_resize (console->ds, width, height); - } + console->g_width = width; + console->g_height = height; +if (active_console == console) { +DisplayState *ds = console->ds; + ds->surface =qemu_resizeDisplaySurface (ds->surface, width, height,32 ,4 * width); +dpy_resize (console->ds); } }
@@ -1360,12 +1358,137 @@ int dst_x, int dst_y, int w, int h) { if (active_console == console) { - if (console->ds->dpy_copy) - console->ds->dpy_copy(console->ds, - src_x, src_y, dst_x, dst_y, w, h); - else { -/* TODO */ - console->ds->dpy_update (console->ds, dst_x, dst_y, w, h); - } + dpy_copy(console->ds, src_x, src_y, dst_x, dst_y, w, h); } } + +static PixelFormat qemu_default_pixelformat (int bpp) +{ +PixelFormat pf; + +memset (&pf,0x00 ,sizeof (PixelFormat)); + + pf.bits_per_pixel = bpp; + pf.bytes_per_pixel = bpp /8 ; + pf.depth = bpp ==32 ?24 : bpp; + +switch (bpp) { +case 8 : + pf.rmask =0x000000E0 ; + pf.gmask =0x0000001C ; + pf.bmask =0x00000003 ; + pf.rmax =7 ; + pf.gmax =7 ; + pf.bmax =3 ; + pf.rshift =5 ; + pf.gshift =2 ; + pf.bshift =0 ; +break ; +case 16 : + pf.rmask =0x0000F800 ; + pf.gmask =0x000007E0 ; + pf.bmask =0x0000001F ; + pf.rmax =31 ; + pf.gmax =63 ; + pf.bmax =31 ; + pf.rshift =11 ; + pf.gshift =5 ; + pf.bshift =0 ; +break ; +case 24 : +case 32 : + pf.rmask =0x00FF0000 ; + pf.gmask =0x0000FF00 ; + pf.bmask =0x000000FF ; + pf.rmax =255 ; + pf.gmax =255 ; + pf.bmax =255 ; + pf.rshift =16 ; + pf.gshift =8 ; + pf.bshift =0 ; +break ; +default : +break ; + } +return pf; +} + +DisplaySurface *qemu_createDisplaySurface (int width,int height,int bpp,int linesize) +{ +DisplaySurface *surface = (DisplaySurface *)qemu_mallocz (sizeof (DisplaySurface)); +if (surface ==NULL ) { +fprintf (stderr,"qemu_createDisplaySurface: malloc failed\n" ); +exit (1 ); + } + + surface->width = width; + surface->height = height; + surface->linesize = linesize; + surface->pf =qemu_default_pixelformat (bpp); +#ifdef WORDS_BIGENDIAN + surface->flags =QEMU_ALLOCATED_FLAG |QEMU_BIG_ENDIAN_FLAG ; +#else + surface->flags =QEMU_ALLOCATED_FLAG ; +#endif + surface->data = (uint8_t *)qemu_mallocz (surface->linesize * surface->height); +if (surface->data ==NULL ) { +fprintf (stderr,"qemu_createDisplaySurface: malloc failed\n" ); +exit (1 ); + } + +return surface; +} + +DisplaySurface *qemu_resizeDisplaySurface (DisplaySurface *surface, +int width,int height,int bpp,int linesize) +{ + surface->width = width; + surface->height = height; + surface->linesize = linesize; + surface->pf =qemu_default_pixelformat (bpp); +if (surface->flags &QEMU_ALLOCATED_FLAG ) + surface->data = (uint8_t *)qemu_reallocz (surface->data, surface->linesize * surface->height); +else + surface->data = (uint8_t *)qemu_mallocz (surface->linesize * surface->height); +if (surface->data ==NULL ) { +fprintf (stderr,"qemu_createDisplaySurface: malloc failed\n" ); +exit (1 ); + } +#ifdef WORDS_BIGENDIAN + surface->flags =QEMU_ALLOCATED_FLAG |QEMU_BIG_ENDIAN_FLAG ; +#else + surface->flags =QEMU_ALLOCATED_FLAG ; +#endif + +return surface; +} + +DisplaySurface *qemu_createDisplaySurfaceFrom (int width,int height,int bpp, +int linesize,uint8_t *data) +{ +DisplaySurface *surface = (DisplaySurface *)qemu_mallocz (sizeof (DisplaySurface)); +if (surface ==NULL ) { +fprintf (stderr,"qemu_createDisplaySurface: malloc failed\n" ); +exit (1 ); + } + + surface->width = width; + surface->height = height; + surface->linesize = linesize; + surface->pf =qemu_default_pixelformat (bpp); +#ifdef WORDS_BIGENDIAN + surface->flags =QEMU_BIG_ENDIAN_FLAG ; +#endif + surface->data = data; + +return surface; +} + +void qemu_freeDisplaySurface (DisplaySurface *surface) +{ +if (surface ==NULL ) +return ; +if (surface->flags &QEMU_ALLOCATED_FLAG ) +qemu_free (surface->data); +qemu_free (surface); +}
console.h +109 -15
160 lines not on this page · raw message
curses.c +20 -18
@@ -97,13 +97,13 @@ } } -static void curses_resize (DisplayState *ds,int w,int h) +static void curses_resize (DisplayState *ds) { -if (w == gwidth && h == gheight) +if (ds->surface->width == gwidth && ds->surface->height == gheight)return ; - gwidth = w; - gheight = h; + gwidth = ds->surface->width; + gheight = ds->surface->height;curses_calc_pad (); }
@@ -169,8 +169,8 @@clear ();refresh ();curses_calc_pad (); - ds->width =FONT_WIDTH * width; - ds->height =FONT_HEIGHT * height; + ds->surface->width =FONT_WIDTH * width; + ds->surface->height =FONT_HEIGHT * height;vga_hw_invalidate (); invalidate =0 ; }
@@ -197,8 +197,8 @@refresh ();curses_calc_pad ();curses_update (ds,0 ,0 , width, height); - ds->width =FONT_WIDTH * width; - ds->height =FONT_HEIGHT * height; + ds->surface->width =FONT_WIDTH * width; + ds->surface->height =FONT_HEIGHT * height; continue; }#endif
@@ -338,6 +338,7 @@void curses_display_init (DisplayState *ds,int full_screen) { +DisplayChangeListener *dcl;#ifndef _WIN32if (!isatty (1 )) {fprintf (stderr,"We need a terminal output\n" );
@@ -357,18 +358,19 @@#endif #endif - ds->data = (void *) screen; - ds->linesize =0 ; - ds->depth =0 ; - ds->width =640 ; - ds->height =400 ; - ds->dpy_update = curses_update; - ds->dpy_resize = curses_resize; - ds->dpy_refresh = curses_refresh; - ds->dpy_text_cursor = curses_cursor_position; + dcl = (DisplayChangeListener *)qemu_mallocz (sizeof (DisplayChangeListener)); +if (!dcl) +exit (1 ); + dcl->dpy_update = curses_update; + dcl->dpy_resize = curses_resize; + dcl->dpy_refresh = curses_refresh; + dcl->dpy_text_cursor = curses_cursor_position; +register_displaychangelistener (ds, dcl); +qemu_freeDisplaySurface (ds->surface); + ds->surface =qemu_createDisplaySurfaceFrom (80 ,25 ,0 ,0 , (uint8_t *) screen); invalidate =1 ;/* Standard VGA initial text mode dimensions */ -curses_resize (ds,80 ,25 ); +curses_resize (ds); }
hw/blizzard.c +9 -9
@@ -166,7 +166,7 @@ s->my[1 ] = s->data.y + s->data.dy; bypp[0 ] = s->bpp; - bypp[1 ] = (s->state->depth +7 ) >>3 ; + bypp[1 ] = (s->state->surface->pf.bits_per_pixel +7 ) >>3 ; bypl[0 ] = bypp[0 ] * s->data.pitch; bypl[1 ] = bypp[1 ] * s->x; bypl[2 ] = bypp[0 ] * s->data.dx;
@@ -895,7 +895,7 @@if (!s->enable)return ; -if (s->x != s->state->width || s->y != s->state->height) { +if (s->x != s->state->surface->width || s->y != s->state->surface->height) { s->invalidate =1 ;qemu_console_resize (s->console, s->x, s->y); }
@@ -904,8 +904,8 @@ s->invalidate =0 ;if (s->blank) { - bypp = (s->state->depth +7 ) >>3 ; -memset (s->state->data,0 , bypp * s->x * s->y); + bypp = (s->state->surface->pf.bits_per_pixel +7 ) >>3 ; +memset (s->state->surface->data,0 , bypp * s->x * s->y);return ; }
@@ -918,12 +918,12 @@if (s->mx[1 ] <= s->mx[0 ])return ; - bypp = (s->state->depth +7 ) >>3 ; + bypp = (s->state->surface->pf.bits_per_pixel +7 ) >>3 ; bypl = bypp * s->x; bwidth = bypp * (s->mx[1 ] - s->mx[0 ]); y = s->my[0 ]; src = s->fb + bypl * y + bypp * s->mx[0 ]; - dst = s->state->data + bypl * y + bypp * s->mx[0 ]; + dst = s->state->surface->data + bypl * y + bypp * s->mx[0 ];for (; y < s->my[1 ]; y ++, src += bypl, dst += bypl)memcpy (dst, src, bwidth);
@@ -940,8 +940,8 @@struct blizzard_s *s = (struct blizzard_s *) opaque;blizzard_update_display (opaque); -if (s && s->state->data) -ppm_save (filename, s->state->data, s->x, s->y, s->state->linesize); +if (s && s->state->surface->data) +ppm_save (filename, s->state->surface->data, s->x, s->y, s->state->surface->linesize); }#define DEPTH 8
@@ -962,7 +962,7 @@ s->state = ds; s->fb =qemu_malloc (0x180000 ); -switch (s->state->depth) { +switch (s->state->surface->pf.bits_per_pixel) {case 0 : s->line_fn_tab[0 ] = s->line_fn_tab[1 ] =qemu_mallocz (sizeof (blizzard_fn_t) *0x10 );
hw/cirrus_vga.c +11 -17
@@ -788,22 +788,16 @@if (BLTUNSAFE (s))return 0 ; -if (s->ds->dpy_copy) { -cirrus_do_copy (s, s->cirrus_blt_dstaddr - s->start_addr, - s->cirrus_blt_srcaddr - s->start_addr, - s->cirrus_blt_width, s->cirrus_blt_height); - }else { - (*s->cirrus_rop) (s, s->vram_ptr + - (s->cirrus_blt_dstaddr & s->cirrus_addr_mask), - s->vram_ptr + - (s->cirrus_blt_srcaddr & s->cirrus_addr_mask), - s->cirrus_blt_dstpitch, s->cirrus_blt_srcpitch, - s->cirrus_blt_width, s->cirrus_blt_height); + (*s->cirrus_rop) (s, s->vram_ptr + + (s->cirrus_blt_dstaddr & s->cirrus_addr_mask), + s->vram_ptr + + (s->cirrus_blt_srcaddr & s->cirrus_addr_mask), + s->cirrus_blt_dstpitch, s->cirrus_blt_srcpitch, + s->cirrus_blt_width, s->cirrus_blt_height); -cirrus_invalidate_region (s, s->cirrus_blt_dstaddr, - s->cirrus_blt_dstpitch, s->cirrus_blt_width, - s->cirrus_blt_height); - } +cirrus_invalidate_region (s, s->cirrus_blt_dstaddr, + s->cirrus_blt_dstpitch, s->cirrus_blt_width, + s->cirrus_blt_height);return 1 ; }
@@ -2321,9 +2315,9 @@ color1 = s->rgb_to_pixel (c6_to_8 (palette[0xf *3 ]),c6_to_8 (palette[0xf *3 +1 ]),c6_to_8 (palette[0xf *3 +2 ])); - bpp = ((s->ds->depth +7 ) >>3 ); + bpp = ((s->ds->surface->pf.bits_per_pixel +7 ) >>3 ); d1 += x1 * bpp; -switch (s->ds->depth) { +switch (s->ds->surface->pf.bits_per_pixel) {default :break ;case 8 :
hw/g364fb.c +6 -6
@@ -72,7 +72,7 @@static void g364fb_draw_graphic (G364State *s,int full_update) { -switch (s->ds->depth) { +switch (s->ds->surface->pf.bits_per_pixel) {case 8 :g364fb_draw_graphic8 (s, full_update);break ;
@@ -86,7 +86,7 @@g364fb_draw_graphic32 (s, full_update);break ;default : -printf ("g364fb: unknown depth %d\n" , s->ds->depth); +printf ("g364fb: unknown depth %d\n" , s->ds->surface->pf.bits_per_pixel);return ; }
@@ -101,11 +101,11 @@if (!full_update)return ; - w = s->scr_width * ((s->ds->depth +7 ) >>3 ); - d = s->ds->data; + w = s->scr_width * ((s->ds->surface->pf.bits_per_pixel +7 ) >>3 ); + d = s->ds->surface->data;for (i =0 ; i < s->scr_height; i++) {memset (d,0 , w); - d += s->ds->linesize; + d += s->ds->surface->linesize; }dpy_update (s->ds,0 ,0 , s->scr_width, s->scr_height);
@@ -131,7 +131,7 @@ s->graphic_mode = graphic_mode; full_update =1 ; } -if (s->scr_width != s->ds->width || s->scr_height != s->ds->height) { +if (s->scr_width != s->ds->surface->width || s->scr_height != s->ds->surface->height) {qemu_console_resize (s->console, s->scr_width, s->scr_height); full_update =1 ; }
hw/g364fb_template.h +2 -2
@@ -28,7 +28,7 @@ data_buffer = s->vram_buffer; w_display = s->scr_width *PIXEL_WIDTH /8 ; - data_display = s->ds->data; + data_display = s->ds->surface->data;for (i =0 ; i < s->scr_height; i++) { dd = data_display;for (j =0 ; j < s->scr_width; j++, dd +=PIXEL_WIDTH /8 , data_buffer++) {
@@ -38,6 +38,6 @@ s->palette[index][1 ], s->palette[index][2]); } - data_display += s->ds->linesize; + data_display += s->ds->surface->linesize; } }
hw/jazz_led.c +14 -14
@@ -155,8 +155,8 @@uint8_t *d;int x, bpp; - bpp = (ds->depth +7 ) >>3 ; - d = ds->data + ds->linesize * posy + bpp * posx1; + bpp = (ds->surface->pf.bits_per_pixel +7 ) >>3 ; + d = ds->surface->data + ds->surface->linesize * posy + bpp * posx1;switch (bpp) {case 1 :for (x = posx1; x <= posx2; x++) {
@@ -184,25 +184,25 @@uint8_t *d;int y, bpp; - bpp = (ds->depth +7 ) >>3 ; - d = ds->data + ds->linesize * posy1 + bpp * posx; + bpp = (ds->surface->pf.bits_per_pixel +7 ) >>3 ; + d = ds->surface->data + ds->surface->linesize * posy1 + bpp * posx;switch (bpp) {case 1 :for (y = posy1; y <= posy2; y++) { *((uint8_t *)d) = color; - d += ds->linesize; + d += ds->surface->linesize; }break ;case 2 :for (y = posy1; y <= posy2; y++) { *((uint16_t *)d) = color; - d += ds->linesize; + d += ds->surface->linesize; }break ;case 4 :for (y = posy1; y <= posy2; y++) { *((uint32_t *)d) = color; - d += ds->linesize; + d += ds->surface->linesize; }break ; }
@@ -218,17 +218,17 @@if (s->state &REDRAW_BACKGROUND ) {/* clear screen */ - bpp = (ds->depth +7 ) >>3 ; - d1 = ds->data; -for (y =0 ; y < ds->height; y++) { -memset (d1,0x00 , ds->width * bpp); - d1 += ds->linesize; + bpp = (ds->surface->pf.bits_per_pixel +7 ) >>3 ; + d1 = ds->surface->data; +for (y =0 ; y < ds->surface->height; y++) { +memset (d1,0x00 , ds->surface->width * bpp); + d1 += ds->surface->linesize; } }if (s->state &REDRAW_SEGMENTS ) {/* set colors according to bpp */ -switch (ds->depth) { +switch (ds->surface->pf.bits_per_pixel) {case 8 : color_segment =rgb_to_pixel8 (0xaa ,0xaa ,0xaa ); color_led =rgb_to_pixel8 (0x00 ,0xff ,0x00 );
@@ -272,7 +272,7 @@ } s->state =REDRAW_NONE ; -dpy_update (ds,0 ,0 , ds->width, ds->height); +dpy_update (ds,0 ,0 , ds->surface->width, ds->surface->height); }static void jazz_led_invalidate_display (void *opaque)
hw/musicpal.c +4 -4
@@ -801,7 +801,7 @@ (musicpal_lcd_state *s, int x, int y, type col) \ { \int dx, dy; \ -type *pixel = &((type *) s->ds->data)[(y *128 *3 + x) *3 ]; \ +type *pixel = &((type *) s->ds->surface->data)[(y *128 *3 + x) *3 ]; \ \for (dy =0 ; dy <3 ; dy++, pixel +=127 *3 ) \for (dx =0 ; dx <3 ; dx++, pixel++) \
@@ -818,7 +818,7 @@musicpal_lcd_state *s = opaque;int x, y, col; -switch (s->ds->depth) { +switch (s->ds->surface->pf.bits_per_pixel) {case 0 :return ;#define LCD_REFRESH (depth, func) \
@@ -835,10 +835,10 @@break ; LCD_REFRESH(8, rgb_to_pixel8) LCD_REFRESH(16, rgb_to_pixel16) - LCD_REFRESH(32, (s->ds->bgr ? rgb_to_pixel32bgr : rgb_to_pixel32)) + LCD_REFRESH(32, rgb_to_pixel32)default :cpu_abort (cpu_single_env,"unsupported colour depth %i\n" , - s->ds->depth); + s->ds->surface->pf.bits_per_pixel); }dpy_update (s->ds,0 ,0 ,128 *3 ,64 *3 );
hw/nseries.c +2 -1
@@ -1361,7 +1361,8 @@/* FIXME: We shouldn't really be doing this here. The LCD controller will set the size once configured, so this just sets an initial size until the guest activates the display. */ -dpy_resize (ds,800 ,480 ); + ds->surface =qemu_resizeDisplaySurface (ds->surface,800 ,480 ,32 ,4 *800 ); +dpy_resize (ds); }static struct arm_boot_info n800_binfo = {
hw/omap_lcdc.c +14 -14
@@ -125,7 +125,7 @@uint8_t *s, *d;if (!omap_lcd || omap_lcd->plm ==1 || - !omap_lcd->enable || !omap_lcd->state->depth) + !omap_lcd->enable || !omap_lcd->state->surface->pf.bits_per_pixel)return ; frame_offset =0 ;
@@ -145,25 +145,25 @@/* Colour depth */ switch ((omap_lcd->palette[0 ] >>12 ) &7 ) {case 1 : - draw_line = draw_line_table2[omap_lcd->state->depth]; + draw_line = draw_line_table2[omap_lcd->state->surface->pf.bits_per_pixel]; bpp =2 ;break ;case 2 : - draw_line = draw_line_table4[omap_lcd->state->depth]; + draw_line = draw_line_table4[omap_lcd->state->surface->pf.bits_per_pixel]; bpp =4 ;break ;case 3 : - draw_line = draw_line_table8[omap_lcd->state->depth]; + draw_line = draw_line_table8[omap_lcd->state->surface->pf.bits_per_pixel]; bpp =8 ;break ; case 4 ... 7:if (!omap_lcd->tft) - draw_line = draw_line_table12[omap_lcd->state->depth]; + draw_line = draw_line_table12[omap_lcd->state->surface->pf.bits_per_pixel];else - draw_line = draw_line_table16[omap_lcd->state->depth]; + draw_line = draw_line_table16[omap_lcd->state->surface->pf.bits_per_pixel]; bpp =16 ;break ;
@@ -174,8 +174,8 @@/* Resolution */ width = omap_lcd->width; -if (width != omap_lcd->state->width || - omap_lcd->height != omap_lcd->state->height) { +if (width != omap_lcd->state->surface->width || + omap_lcd->height != omap_lcd->state->surface->height) {qemu_console_resize (omap_lcd->console, omap_lcd->width, omap_lcd->height); omap_lcd->invalidate =1 ;
@@ -202,7 +202,7 @@if (omap_lcd->dma->dual) omap_lcd->dma->current_frame ^=1 ; -if (!omap_lcd->state->depth) +if (!omap_lcd->state->surface->pf.bits_per_pixel)return ; line =0 ;
@@ -217,8 +217,8 @@ step = width * bpp >>3 ; scanline = frame_base + step * line; s = (uint8_t *) (phys_ram_base + scanline); - d = omap_lcd->state->data; - linesize = omap_lcd->state->linesize; + d = omap_lcd->state->surface->data; + linesize = omap_lcd->state->surface->linesize; dirty[0 ] = dirty[1 ] =cpu_physical_memory_get_dirty (scanline,VGA_DIRTY_FLAG );
@@ -293,10 +293,10 @@static void omap_screen_dump (void *opaque,const char *filename) {struct omap_lcd_panel_s *omap_lcd = opaque;omap_update_display (opaque); -if (omap_lcd && omap_lcd->state->data) -ppm_save (filename, omap_lcd->state->data, +if (omap_lcd && omap_lcd->state->surface->data) +ppm_save (filename, omap_lcd->state->surface->data, omap_lcd->width, omap_lcd->height, - omap_lcd->state->linesize); + omap_lcd->state->surface->linesize); }static void omap_invalidate_display (void *opaque) {
hw/palm.c +2 -1
@@ -278,7 +278,8 @@/* FIXME: We shouldn't really be doing this here. The LCD controller will set the size once configured, so this just sets an initial size until the guest activates the display. */ -dpy_resize (ds,320 ,320 ); + ds->surface =qemu_resizeDisplaySurface (ds->surface,320 ,320 ,32 ,4 *320 ); +dpy_resize (ds); }QEMUMachine palmte_machine = {
hw/pl110.c +3 -3
@@ -124,7 +124,7 @@if (!pl110_enabled (s))return ; -switch (s->ds->depth) { +switch (s->ds->surface->pf.bits_per_pixel) {case 0 :return ;case 8 :
@@ -190,7 +190,7 @@if (base >0x80000000 ) base -=0x80000000 ; src = phys_ram_base + base; - dest = s->ds->data; + dest = s->ds->surface->data; first =-1 ; addr = base;
@@ -249,7 +249,7 @@ b = (raw &0x1f ) <<3 ;/* The I bit is ignored. */ raw >>=6 ; -switch (s->ds->depth) { +switch (s->ds->surface->pf.bits_per_pixel) {case 8 : s->pallette[n] =rgb_to_pixel8 (r, g, b);break ;
hw/pxa2xx_lcd.c +4 -4
@@ -650,7 +650,7 @@ }break ; } -switch (s->ds->depth) { +switch (s->ds->surface->pf.bits_per_pixel) {case 8 : *dest =rgb_to_pixel8 (r, g, b) | alpha;break ;
@@ -693,7 +693,7 @@else if (s->bpp > pxa_lcdc_8bpp) src_width *=2 ; - dest = s->ds->data; + dest = s->ds->surface->data; dest_width = s->xres * s->dest_width; addr = (ram_addr_t) (fb - phys_ram_base);
@@ -750,7 +750,7 @@ src_width *=2 ; dest_width = s->yres * s->dest_width; - dest = s->ds->data + dest_width * (s->xres -1 ); + dest = s->ds->surface->data + dest_width * (s->xres -1 ); addr = (ram_addr_t) (fb - phys_ram_base); start = addr + s->yres * src_width;
@@ -1006,7 +1006,7 @@ pxa2xx_invalidate_display, pxa2xx_screen_dump, NULL, s); -switch (s->ds->depth) { +switch (s->ds->surface->pf.bits_per_pixel) {case 0 : s->dest_width =0 ;break ;
hw/ssd0303.c +2 -2
@@ -206,7 +206,7 @@if (!s->redraw)return ; -switch (s->ds->depth) { +switch (s->ds->surface->pf.bits_per_pixel) {case 0 :return ;case 15 :
@@ -238,7 +238,7 @@ colors[0 ] = colortab + dest_width; colors[1 ] = colortab; } - dest = s->ds->data; + dest = s->ds->surface->data;for (y =0 ; y <16 ; y++) { line = (y + s->start_line) &63 ; src = s->framebuffer +132 * (line >>3 ) +36 ;
hw/ssd0323.c +3 -3
@@ -187,7 +187,7 @@if (!s->redraw)return ; -switch (s->ds->depth) { +switch (s->ds->surface->pf.bits_per_pixel) {case 0 :return ;case 15 :
@@ -210,7 +210,7 @@for (i =0 ; i <16 ; i++) {int n; colors[i] = p; -switch (s->ds->depth) { +switch (s->ds->surface->pf.bits_per_pixel) {case 15 : n = i *2 + (i >>3 ); p[0 ] = n | (n <<5 );
@@ -233,7 +233,7 @@ p += dest_width; }/* TODO: Implement row/column remapping. */ - dest = s->ds->data; + dest = s->ds->surface->data;for (y =0 ; y <64 ; y++) { line = y; src = s->framebuffer +64 * line;
hw/tc6393xb.c +6 -6
@@ -430,7 +430,7 @@static void tc6393xb_draw_graphic (struct tc6393xb_s *s,int full_update) { -switch (s->ds->depth) { +switch (s->ds->surface->pf.bits_per_pixel) {case 8 :tc6393xb_draw_graphic8 (s);break ;
@@ -447,7 +447,7 @@tc6393xb_draw_graphic32 (s);break ;default : -printf ("tc6393xb: unknown depth %d\n" , s->ds->depth); +printf ("tc6393xb: unknown depth %d\n" , s->ds->surface->pf.bits_per_pixel);return ; }
@@ -462,11 +462,11 @@if (!full_update)return ; - w = s->scr_width * ((s->ds->depth +7 ) >>3 ); - d = s->ds->data; + w = s->scr_width * ((s->ds->surface->pf.bits_per_pixel +7 ) >>3 ); + d = s->ds->surface->data;for (i =0 ; i < s->scr_height; i++) {memset (d,0 , w); - d += s->ds->linesize; + d += s->ds->surface->linesize; }dpy_update (s->ds,0 ,0 , s->scr_width, s->scr_height);
@@ -485,7 +485,7 @@ s->blanked = s->blank; full_update =1 ; } -if (s->scr_width != s->ds->width || s->scr_height != s->ds->height) { +if (s->scr_width != s->ds->surface->width || s->scr_height != s->ds->surface->height) {qemu_console_resize (s->console, s->scr_width, s->scr_height); full_update =1 ; }
hw/tc6393xb_template.h +2 -2
@@ -46,12 +46,12 @@ data_buffer = (uint16_t *)(phys_ram_base + s->vram_addr); w_display = s->scr_width *BITS /8 ; - data_display = s->ds->data; + data_display = s->ds->surface->data;for (i =0 ; i < s->scr_height; i++) {#if (BITS ==16 )memcpy (data_display, data_buffer, s->scr_width *2 ); data_buffer += s->scr_width; - data_display += s->ds->linesize; + data_display += s->ds->surface->linesize;#else int j;for (j =0 ; j < s->scr_width; j++, data_display +=BITS /8 , data_buffer++) {
hw/tcx.c +13 -26
@@ -55,28 +55,19 @@ {int i;for (i = start; i < end; i++) { -switch (s->ds->depth) { +switch (s->ds->surface->pf.bits_per_pixel) {default :case 8 : s->palette[i] =rgb_to_pixel8 (s->r[i], s->g[i], s->b[i]);break ;case 15 : -if (s->ds->bgr) - s->palette[i] =rgb_to_pixel15bgr (s->r[i], s->g[i], s->b[i]); -else - s->palette[i] =rgb_to_pixel15 (s->r[i], s->g[i], s->b[i]); + s->palette[i] =rgb_to_pixel15 (s->r[i], s->g[i], s->b[i]);break ;case 16 : -if (s->ds->bgr) - s->palette[i] =rgb_to_pixel16bgr (s->r[i], s->g[i], s->b[i]); -else - s->palette[i] =rgb_to_pixel16 (s->r[i], s->g[i], s->b[i]); + s->palette[i] =rgb_to_pixel16 (s->r[i], s->g[i], s->b[i]);break ;case 32 : -if (s->ds->bgr) - s->palette[i] =rgb_to_pixel32bgr (s->r[i], s->g[i], s->b[i]); -else - s->palette[i] =rgb_to_pixel32 (s->r[i], s->g[i], s->b[i]); + s->palette[i] =rgb_to_pixel32 (s->r[i], s->g[i], s->b[i]);break ; } }
@@ -134,12 +125,11 @@const uint32_t *cplane, const uint32_t *s24) { - int x, bgr, r, g, b; + int x, r, g, b;uint8_t val, *p8;uint32_t *p = (uint32_t *)d;uint32_t dval; - bgr = s1->ds->bgr;for (x =0 ; x < width; x++, s++, s24++) {if ((be32_to_cpu (*cplane++) &0xff000000 ) ==0x03000000 ) {// 24-bit direct, BGR order
@@ -148,10 +138,7 @@ b = *p8++; g = *p8++; r = *p8++; -if (bgr) - dval =rgb_to_pixel32bgr (r, g, b); -else - dval =rgb_to_pixel32 (r, g, b); + dval =rgb_to_pixel32 (r, g, b); }else { val = *s; dval = s1->palette[val];
@@ -200,18 +187,18 @@uint8_t *d, *s;void (*f)(TCXState *s1,uint8_t *dst,const uint8_t *src,int width); -if (ts->ds->depth ==0 ) +if (ts->ds->surface->pf.bits_per_pixel ==0 )return ; page = ts->vram_offset; y_start =-1 ; page_min =0xffffffff ; page_max =0 ; - d = ts->ds->data; + d = ts->ds->surface->data; s = ts->vram; - dd = ts->ds->linesize; + dd = ts->ds->surface->linesize; ds =1024 ; -switch (ts->ds->depth) { +switch (ts->ds->surface->pf.bits_per_pixel) {case 32 : f = tcx_draw_line32;break ;
@@ -278,7 +265,7 @@uint8_t *d, *s;uint32_t *cptr, *s24; -if (ts->ds->depth !=32 ) +if (ts->ds->surface->pf.bits_per_pixel !=32 )return ; page = ts->vram_offset; page24 = ts->vram24_offset;
@@ -286,11 +273,11 @@ y_start =-1 ; page_min =0xffffffff ; page_max =0 ; - d = ts->ds->data; + d = ts->ds->surface->data; s = ts->vram; s24 = ts->vram24; cptr = ts->cplane; - dd = ts->ds->linesize; + dd = ts->ds->surface->linesize; ds =1024 ; for(y = 0; y < ts->height; y += 4, page += TARGET_PAGE_SIZE,
hw/vga.c +78 -53
274 lines not on this page · raw message
hw/vga_int.h +2 -0
@@ -149,9 +149,11 @@uint32_t line_compare; \uint32_t start_addr; \uint32_t plane_updated; \ +uint32_t last_line_offset; \uint8_t last_cw, last_ch; \uint32_t last_width, last_height;/* in chars or pixels */ \uint32_t last_scr_width, last_scr_height;/* in pixels */ \ +uint32_t last_depth;/* in bits */ \uint8_t cursor_start, cursor_end; \uint32_t cursor_offset; \ unsigned int (*rgb_to_pixel)(unsigned int r, \
hw/vmware_vga.c +12 -12
@@ -319,7 +319,7 @@ width = s->bypp * w; start = s->bypp * x + bypl * y; src = s->vram + start; - dst = s->ds->data + start; + dst = s->ds->surface->data + start;for (; line >0 ; line --, src += bypl, dst += bypl)memcpy (dst, src, width);
@@ -331,7 +331,7 @@static inline void vmsvga_update_screen (struct vmsvga_state_s *s) {#ifndef DIRECT_VRAM -memcpy (s->ds->data, s->vram, s->bypp * s->width * s->height); +memcpy (s->ds->surface->data, s->vram, s->bypp * s->width * s->height);#endif dpy_update (s->ds,0 ,0 , s->width, s->height);
@@ -373,7 +373,7 @@ int x0, int y0, int x1, int y1, int w, int h) { # ifdef DIRECT_VRAM - uint8_t *vram = s->ds->data; + uint8_t *vram = s->ds->surface->data;# else uint8_t *vram = s->vram;# endif
@@ -410,7 +410,7 @@ uint32_t c, int x, int y, int w, int h) { # ifdef DIRECT_VRAM - uint8_t *vram = s->ds->data; + uint8_t *vram = s->ds->surface->data;# else uint8_t *vram = s->vram;# endif
@@ -915,7 +915,7 @@ s->width =-1 ; s->height =-1 ; s->svgaid =SVGA_ID ; - s->depth = s->ds->depth ? s->ds->depth :24 ; + s->depth = s->ds->surface->pf.bits_per_pixel; s->bypp = (s->depth +7 ) >>3 ; s->cursor.on =0 ; s->redraw_fifo_first =0 ;
@@ -976,7 +976,7 @@ }if (s->depth ==32 ) { -ppm_save (filename, s->vram, s->width, s->height, s->ds->linesize); +ppm_save (filename, s->vram, s->width, s->height, s->ds->surface->linesize); } }
@@ -994,7 +994,7 @@struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque; addr -= s->vram_base;if (addr < s->fb_size) -return *(uint8_t *) (s->ds->data + addr); +return *(uint8_t *) (s->ds->surface->data + addr);else return *(uint8_t *) (s->vram + addr); }
@@ -1004,7 +1004,7 @@struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque; addr -= s->vram_base;if (addr < s->fb_size) -return *(uint16_t *) (s->ds->data + addr); +return *(uint16_t *) (s->ds->surface->data + addr);else return *(uint16_t *) (s->vram + addr); }
@@ -1014,7 +1014,7 @@struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque; addr -= s->vram_base;if (addr < s->fb_size) -return *(uint32_t *) (s->ds->data + addr); +return *(uint32_t *) (s->ds->surface->data + addr);else return *(uint32_t *) (s->vram + addr); }
@@ -1025,7 +1025,7 @@struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque; addr -= s->vram_base;if (addr < s->fb_size) - *(uint8_t *) (s->ds->data + addr) = value; + *(uint8_t *) (s->ds->surface->data + addr) = value;else *(uint8_t *) (s->vram + addr) = value; }
@@ -1036,7 +1036,7 @@struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque; addr -= s->vram_base;if (addr < s->fb_size) - *(uint16_t *) (s->ds->data + addr) = value; + *(uint16_t *) (s->ds->surface->data + addr) = value;else *(uint16_t *) (s->vram + addr) = value; }
@@ -1047,7 +1047,7 @@struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque; addr -= s->vram_base;if (addr < s->fb_size) - *(uint32_t *) (s->ds->data + addr) = value; + *(uint32_t *) (s->ds->surface->data + addr) = value;else *(uint32_t *) (s->vram + addr) = value; }
qemu-common.h +4 -0
@@ -96,6 +96,7 @@void *qemu_malloc (size_t size);void *qemu_realloc (void *ptr,size_t size); +void *qemu_reallocz (void *ptr,size_t size);void *qemu_mallocz (size_t size);void qemu_free (void *ptr);char *qemu_strdup (const char *str);
@@ -128,6 +129,9 @@typedef struct AudioState AudioState ;typedef struct BlockDriverState BlockDriverState ;typedef struct DisplayState DisplayState ; +typedef struct DisplayChangeListener DisplayChangeListener ; +typedef struct DisplaySurface DisplaySurface ; +typedef struct PixelFormat PixelFormat ;typedef struct TextConsole TextConsole ;typedef TextConsole QEMUConsole ;typedef struct CharDriverState CharDriverState ;
qemu-malloc.c +10 -0
@@ -43,6 +43,16 @@return realloc (ptr, size); } +void *qemu_reallocz (void *ptr,size_t size) +{ +void *res; + res =realloc (ptr, size); +if (!res) +return NULL ; +memset (res,0 , size); +return res; +} +void *qemu_mallocz (size_t size) {void *ptr;
sdl.c +55 -42
171 lines not on this page · raw message
vl.c +60 -37
172 lines not on this page · raw message
vnc.c +63 -95
347 lines not on this page · raw message
vnchextile.h +5 -5
@@ -13,7 +13,7 @@void *last_fg_, int *has_bg, int *has_fg) { - uint8_t *row = (vs->ds->data + y * vs->ds->linesize + x * vs->depth); + uint8_t *row = (vs->ds->surface->data + y * vs->ds->surface->linesize + x * vs->depth);pixel_t *irow = (pixel_t *)row;int j, i;pixel_t *last_bg = (pixel_t *)last_bg_;
@@ -57,7 +57,7 @@ }if (n_colors >2 )break ; - irow += vs->ds->linesize /sizeof (pixel_t); + irow += vs->ds->surface->linesize /sizeof (pixel_t); }if (n_colors >1 && fg_count > bg_count) {
@@ -105,7 +105,7 @@ n_data +=2 ; n_subtiles++; } - irow += vs->ds->linesize /sizeof (pixel_t); + irow += vs->ds->surface->linesize /sizeof (pixel_t); }break ;case 3 :
@@ -161,7 +161,7 @@ n_data +=2 ; n_subtiles++; } - irow += vs->ds->linesize /sizeof (pixel_t); + irow += vs->ds->surface->linesize /sizeof (pixel_t); }/* A SubrectsColoured subtile invalidates the foreground color */
@@ -198,7 +198,7 @@ }else {for (j =0 ; j < h; j++) { vs->write_pixels (vs, row, w * vs->depth); - row += vs->ds->linesize; + row += vs->ds->surface->linesize; } } }
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 11 lines · Paul Brook
Quoted 4 lines · Stefano Stabellini
Hi all,
this patch changes the DisplayState interface adding support for multiple frontends at the same time (sdl and vnc) and implements most of the benefit of theshared_bufpatch without the added complexity.Unless I'm misunderstanding something, isn't this all going to go horribly wrong when we want to have multiple displays? You shouldn't be using DisplayState at all, you should be attaching these things to QEMUConsole.
That was the main problem I had to solve, but I managed to make it work
correctly: everything is handled transparently by qemu_console_resize and console_select in console.c.
If the backend is smart enought to share the buffer it does so checking that it is the current active console first (look at hw/vga.c:vga_draw_graphic, vga.c is the only "smart" backend at the moment).
You can test it passing "-sdl -vnc :1" as arguments to qemu.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 4 lines · Paul Brook
No, I mean what happens when I have (for example) two emulated VGA devices, one displaying to SDL and the other to VNC? Or I want an intermediate later that composites multiple device outputs into a single host image.
If you want multiple device output you need multiple DisplayStates. You need a DisplayState for each device output you want at the same time. My patches do not make any harder to implement this scenario, actually being the interface simpler it should be much simpler to handle this case as well.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 12 lines · Paul Brook
Quoted 10 lines · Stefano Stabellini
Quoted 4 lines · Paul Brook
No, I mean what happens when I have (for example) two emulated VGA devices, one displaying to SDL and the other to VNC? Or I want an intermediate later that composites multiple device outputs into a single host image.
If you want multiple device output you need multiple DisplayStates. You need a DisplayState for each device output you want at the same time. My patches do not make any harder to implement this scenario, actually being the interface simpler it should be much simpler to handle this case as well.
Quoted 4 lines
Maybe. We already have a per-display structure (QEMUConsole). IIUC you're using DisplayState (which IMHO should be per host side display) to store per device information.
The assumption I made in my patches is the following:
DisplayState is the interface between multiple backend (for example vga and serial, each of them has its own QEMUConsole) and multiple host-side display (vnc.c and sdl.c).
If you want to see different things at the same time on multiple display you need multiple DisplayState.
Then you can have, for example, two vga, each of them connected to an sdl windows and a vnc server (2 windows and 2 servers total).
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 5 lines · Paul Brook
Quoted 4 lines
If the backend is smart enought to share the buffer it does so checking that it is the current active console first (look at hw/vga.c:vga_draw_graphic,
vga.cis the only "smart" backend at the moment).
Quoted 8 lines
This worries me. We shouldn't have "smart" and dumb devices, they should all just work. This suggests you've either got the abstraction wrong, or only implemented half of the required changes.
It feels like you're replacing one bit of host knowledge with another. IMHO We should be aiming for individual devices to know less about how the host displays the image.
All the backends work, but if a backend wants to reuse a preexisting buffer it needs to check that its QEMUConsole is the active console. This is not knowledge of the host, it is knowledge of the fact that my QEMUConsole could not be active at the moment.
I could easily add a qemu_resizeDisplaySurfaceFrom that takes a pointer to a buffer but I thought that it was uglier, maybe I am wrong.
Quoted 1 line
Ok. In that case we should be removing QEMUConsole and giving every
output
Quoted 4 lines
source[*] its own DisplayState.
[*] output source == Emulated device or virtual console.
Even though this model you are proposing is simpler, it has the disadvantage that implies a display buffer per backend while at the moment we are sharing it between multiple backends.
In any case, I can assure you that the change you want to make does *not* go against my patches, they are orthogonal, they neither help nor cause problems to each other, so I would suggest to examine them separately.
Hi Stefano,
Quoted 15 lines · Stefano Stabellini
Hi all,
this patch changes the DisplayState interface adding support for multiple frontends at the same time (sdl and vnc) and implements most of the benefit of theshared_bufpatch without the added complexity.Currently DisplayState is managed by sdl (or vnc) and sdl (or vnc) is also responsible for allocating the data and setting the depth.
Vga.c(or another backend) will do any necessary conversion.The idea is to change it so that is
vga.c(or another backend) that fully manages the DisplayState interface allocating data and setting the depth (either 16 or 32 bit, if the guest uses a different resolution or is in text mode,vga.c(or another backend) is in charge of doing the conversion seamlessly).
Quoted 6 lines
The other idea is that DisplayState supports *multiple* frontends like sdl and vnc; each of them can register some callbacks to be called when a display event occurs.
Signed-off-by Stefano Stabellini <[email protected]>
There are really two parts to this patch. One part is a completely mechanical conversion of things like ds->linesize to ds->surface->linesize. The second is the guys of the API change.
If you introduce accessors to access things like linesize from DisplayState, so something like:
int ds_get_linesize(DisplayState *ds) {
return ds->linesize;
}You can do the mechanical conversion in a single patch. That patch will then be a breeze to review. Then in your next patch, you can just convert these accessors to use the new ds->surface->linesize.
That should make this all considerably easier to thoroughly review. It's just too big right now to review properly.
Regards,
Anthony Liguori
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 7 lines · Paul Brook
Quoted 7 lines
There are really two parts to this patch. One part is a completely mechanical conversion of things like
ds->linesizetods->surface->linesize. The second is the guys of the API change.If you introduce accessors to access things like linesize from DisplayState, so something like:
Quoted 8 lines
Quoted 4 lines
int ds_get_linesize(DisplayState *ds) { return ds->linesize; }I think this sort of thing should be going via the console structures.
i.e. vga emulation deals entirely with a QEMUConsole. sdl/vnc deal entirely with a DisplayState, and qemu mediates in between.
I'm not sure. You can't really hide the fact that there are two VGA cards to the SDL/VNC backend. I think a model where each emulated VGA device had a DisplayState, and each DisplayState had an SDL/VNC backend connected to it could work.
That way, you could have two VNC servers for each of the two VGA devices. SDL is unworkable for multiple monitors AFAIK so it's kind of a moot point.
Where you thinking that we would try to have a QEMUConsole with each VGA card and then multiplex the QEMUConsoles on a single DisplayState? Couldn't we do the same by multiplexing two DisplayState's onto one DisplayState?
I don't think required interface for QEMUConsole would be much different than DisplayState so it's unclear to me if two structures are really needed.
Anyway, Stefano, please add accessors in some form to help with review of this patch. If we decide we need a QEMUConsole abstraction, it's easy enough to update the patch to modify some of the accessors.
Regards,
Anthony Liguori
Quoted 2 lines
Paul
Quoted 7 lines · Paul Brook
Quoted 7 lines
There are really two parts to this patch. One part is a completely mechanical conversion of things like
ds->linesizetods->surface->linesize. The second is the guys of the API change.If you introduce accessors to access things like linesize from DisplayState, so something like:
Quoted 8 lines
Quoted 4 lines
int ds_get_linesize(DisplayState *ds) { return ds->linesize; }I think this sort of thing should be going via the console structures.
i.e. vga emulation deals entirely with a QEMUConsole. sdl/vnc deal entirely with a DisplayState, and qemu mediates in between.
I'm not sure. You can't really hide the fact that there are two VGA cards to the SDL/VNC backend. I think a model where each emulated VGA device had a DisplayState, and each DisplayState had an SDL/VNC backend connected to it could work.
That way, you could have two VNC servers for each of the two VGA devices. SDL is unworkable for multiple monitors AFAIK so it's kind of a moot point.
Where you thinking that we would try to have a QEMUConsole with each VGA card and then multiplex the QEMUConsoles on a single DisplayState? Couldn't we do the same by multiplexing two DisplayState's onto one DisplayState?
I don't think required interface for QEMUConsole would be much different than DisplayState so it's unclear to me if two structures are really needed.
Anyway, Stefano, please add accessors in some form to help with review of this patch. If we decide we need a QEMUConsole abstraction, it's easy enough to update the patch to modify some of the accessors.
Regards,
Anthony Liguori
Quoted 2 lines
Paul
Quoted 7 lines · Paul Brook
Quoted 7 lines
There are really two parts to this patch. One part is a completely mechanical conversion of things like
ds->linesizetods->surface->linesize. The second is the guys of the API change.If you introduce accessors to access things like linesize from DisplayState, so something like:
Quoted 8 lines
Quoted 4 lines
int ds_get_linesize(DisplayState *ds) { return ds->linesize; }I think this sort of thing should be going via the console structures.
i.e. vga emulation deals entirely with a QEMUConsole. sdl/vnc deal entirely with a DisplayState, and qemu mediates in between.
BTW, I really like the idea of just using DisplayState because it implies that you could stack these things in multiple orders. For instance, you may want to have a DisplayState that took two DisplayStates, and produced a tiled image (think side-by-side VGA displays). You may want to take that DisplayState and combine it with a DisplayState for serial/monitor/parallel so that you can switch by the side-by-side VGA display and the other consoles.
Using the same structure here gives you lots of flexibility in how you stack these things.
Regards,
Anthony Liguori
Quoted 2 lines
Paul