提交 0da2ea1b 编写于 作者: M malc

fix endianness problem sharing the videoram buffer

[ The following text is in the "UTF-8" character set. ]

    [ Your display is set for the "koi8-r" character set.  ]

    [ Some characters may be displayed incorrectly. ]

This patch fixes vga rendering when the guest endianness differs from
the host endianness: in this case we can only share the buffer if the
bpp is 32 and we must change the pixelformat accordingly.
Signed-off-by: NStefano Stabellini <stefano.stabellini@eu.citrix.com>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6413 c046a42c-6fe2-441c-8c8c-71466251a162
上级 1a6f0dbc
...@@ -1449,7 +1449,7 @@ void qemu_console_copy(DisplayState *ds, int src_x, int src_y, ...@@ -1449,7 +1449,7 @@ void qemu_console_copy(DisplayState *ds, int src_x, int src_y,
} }
} }
static PixelFormat qemu_default_pixelformat(int bpp) PixelFormat qemu_different_endianness_pixelformat(int bpp)
{ {
PixelFormat pf; PixelFormat pf;
...@@ -1460,17 +1460,48 @@ static PixelFormat qemu_default_pixelformat(int bpp) ...@@ -1460,17 +1460,48 @@ static PixelFormat qemu_default_pixelformat(int bpp)
pf.depth = bpp == 32 ? 24 : bpp; pf.depth = bpp == 32 ? 24 : bpp;
switch (bpp) { switch (bpp) {
case 8: case 24:
pf.rmask = 0x000000E0; pf.rmask = 0x000000FF;
pf.gmask = 0x0000001C; pf.gmask = 0x0000FF00;
pf.bmask = 0x00000003; pf.bmask = 0x00FF0000;
pf.rmax = 7; pf.rmax = 255;
pf.gmax = 7; pf.gmax = 255;
pf.bmax = 3; pf.bmax = 255;
pf.rshift = 5; pf.rshift = 0;
pf.gshift = 2; pf.gshift = 8;
pf.bshift = 0; pf.bshift = 16;
break; break;
case 32:
pf.rmask = 0x0000FF00;
pf.gmask = 0x00FF0000;
pf.bmask = 0xFF000000;
pf.amask = 0x00000000;
pf.amax = 255;
pf.rmax = 255;
pf.gmax = 255;
pf.bmax = 255;
pf.ashift = 0;
pf.rshift = 8;
pf.gshift = 16;
pf.bshift = 24;
break;
default:
break;
}
return pf;
}
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 16: case 16:
pf.rmask = 0x0000F800; pf.rmask = 0x0000F800;
pf.gmask = 0x000007E0; pf.gmask = 0x000007E0;
...@@ -1483,13 +1514,24 @@ static PixelFormat qemu_default_pixelformat(int bpp) ...@@ -1483,13 +1514,24 @@ static PixelFormat qemu_default_pixelformat(int bpp)
pf.bshift = 0; pf.bshift = 0;
break; break;
case 24: case 24:
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;
case 32: case 32:
pf.rmask = 0x00FF0000; pf.rmask = 0x00FF0000;
pf.gmask = 0x0000FF00; pf.gmask = 0x0000FF00;
pf.bmask = 0x000000FF; pf.bmask = 0x000000FF;
pf.amax = 255;
pf.rmax = 255; pf.rmax = 255;
pf.gmax = 255; pf.gmax = 255;
pf.bmax = 255; pf.bmax = 255;
pf.ashift = 24;
pf.rshift = 16; pf.rshift = 16;
pf.gshift = 8; pf.gshift = 8;
pf.bshift = 0; pf.bshift = 0;
......
...@@ -134,6 +134,8 @@ DisplaySurface* qemu_resize_displaysurface(DisplaySurface *surface, ...@@ -134,6 +134,8 @@ DisplaySurface* qemu_resize_displaysurface(DisplaySurface *surface,
DisplaySurface* qemu_create_displaysurface_from(int width, int height, int bpp, DisplaySurface* qemu_create_displaysurface_from(int width, int height, int bpp,
int linesize, uint8_t *data); int linesize, uint8_t *data);
void qemu_free_displaysurface(DisplaySurface *surface); void qemu_free_displaysurface(DisplaySurface *surface);
PixelFormat qemu_different_endianness_pixelformat(int bpp);
PixelFormat qemu_default_pixelformat(int bpp);
static inline int is_buffer_shared(DisplaySurface *surface) static inline int is_buffer_shared(DisplaySurface *surface)
{ {
......
...@@ -1623,12 +1623,19 @@ static void vga_draw_graphic(VGAState *s, int full_update) ...@@ -1623,12 +1623,19 @@ static void vga_draw_graphic(VGAState *s, int full_update)
disp_width != s->last_width || disp_width != s->last_width ||
height != s->last_height || height != s->last_height ||
s->last_depth != depth) { s->last_depth != depth) {
#if defined(WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN)
if (depth == 16 || depth == 32) { if (depth == 16 || depth == 32) {
#else
if (depth == 32) {
#endif
if (is_graphic_console()) { if (is_graphic_console()) {
qemu_free_displaysurface(s->ds->surface); qemu_free_displaysurface(s->ds->surface);
s->ds->surface = qemu_create_displaysurface_from(disp_width, height, depth, s->ds->surface = qemu_create_displaysurface_from(disp_width, height, depth,
s->line_offset, s->line_offset,
s->vram_ptr + (s->start_addr * 4)); s->vram_ptr + (s->start_addr * 4));
#if defined(WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN)
s->ds->surface->pf = qemu_different_endianness_pixelformat(depth);
#endif
dpy_resize(s->ds); dpy_resize(s->ds);
} else { } else {
qemu_console_resize(s->ds, disp_width, height); qemu_console_resize(s->ds, disp_width, height);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册