aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid 'Digit' Turner <digit@android.com>2011-01-20 02:46:33 +0100
committerDavid 'Digit' Turner <digit@android.com>2011-01-20 02:46:33 +0100
commit94702b0dc4a9729b234c6f0265a9e43c72ef79ad (patch)
treef0a51ef09af88cbb95899a90057bd5f53e4e5bb6
parenta9edc435e6592fcc001e21e150391a84bde114a6 (diff)
downloadexternal_qemu-94702b0dc4a9729b234c6f0265a9e43c72ef79ad.zip
external_qemu-94702b0dc4a9729b234c6f0265a9e43c72ef79ad.tar.gz
external_qemu-94702b0dc4a9729b234c6f0265a9e43c72ef79ad.tar.bz2
Fix ui/core display depth mismatch.
This patch fixes a problem where the core's framebuffer was incorrectly initialized to a pitch of width*4 by default (instead of width*2 when using a 16-bit framebuffer). The reason for this was complex, but essentially, when the machine initialization was moved before the display one in vl-android.c, this changed the way the DisplayState was initialized. Also get rid of the useless and confusing "display_state" global in vl-android.c (not the same than "display_state" in console.c) Change-Id: If8e2b8baf7ccaeedcb66da0174cc529521d67a60
-rw-r--r--console.c26
-rw-r--r--console.h4
-rw-r--r--vl-android.c30
3 files changed, 35 insertions, 25 deletions
diff --git a/console.c b/console.c
index 6cadb73..5c9a16b 100644
--- a/console.c
+++ b/console.c
@@ -1734,11 +1734,27 @@ PixelFormat qemu_default_pixelformat(int bpp)
#ifdef CONFIG_ANDROID
void
-android_display_init_from(int width, int height, int rotation, int bpp)
+android_display_reset(DisplayState* ds, int width, int height, int bitspp)
{
- DisplayState *ds = qemu_mallocz(sizeof(DisplayState));
- ds->allocator = &default_allocator;
- ds->surface = qemu_create_displaysurface(ds, width, height);
- register_displaystate(ds);
+ DisplaySurface* surface;
+ int bytespp = (bitspp+7)/8;
+ int pitch = (bytespp*width + 3) & ~3;
+
+ qemu_free_displaysurface(ds);
+
+ surface = (DisplaySurface*) qemu_mallocz(sizeof(DisplaySurface));
+
+ surface->width = width;
+ surface->height = height;
+ surface->linesize = pitch;
+ surface->pf = qemu_default_pixelformat(bitspp);
+ surface->data = (uint8_t*) qemu_malloc(surface->linesize * surface->height);
+#ifdef HOST_WORDS_BIGENDIAN
+ surface->flags = QEMU_ALLOCATED_FLAG | QEMU_BIG_ENDIAN_FLAG;
+#else
+ surface->flags = QEMU_ALLOCATED_FLAG;
+#endif
+
+ ds->surface = surface;
}
#endif
diff --git a/console.h b/console.h
index b8e1234..bfbc71c 100644
--- a/console.h
+++ b/console.h
@@ -200,7 +200,7 @@ DisplayAllocator *register_displayallocator(DisplayState *ds, DisplayAllocator *
static inline DisplaySurface* qemu_create_displaysurface(DisplayState *ds, int width, int height)
{
- return ds->allocator->create_displaysurface(width, height);
+ return ds->allocator->create_displaysurface(width, height);
}
static inline DisplaySurface* qemu_resize_displaysurface(DisplayState *ds, int width, int height)
@@ -381,7 +381,7 @@ char *vnc_display_local_addr(DisplayState *ds);
void curses_display_init(DisplayState *ds, int full_screen);
#ifdef CONFIG_ANDROID
-void android_display_init_from(int width, int height, int rotation, int bpp);
+void android_display_reset(DisplayState* ds, int width, int height, int bitspp);
#endif
#endif
diff --git a/vl-android.c b/vl-android.c
index 75b1bce..af17c33 100644
--- a/vl-android.c
+++ b/vl-android.c
@@ -243,7 +243,6 @@ DriveInfo drives_table[MAX_DRIVES+1];
int nb_drives;
#endif
enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
-static DisplayState *display_state;
DisplayType display_type = DT_DEFAULT;
const char* keyboard_layout = NULL;
int64_t ticks_per_sec;
@@ -5191,22 +5190,17 @@ int main(int argc, char **argv, char **envp)
}
/* just use the first displaystate for the moment */
- ds = display_state = get_displaystate();
-
- if (!display_state) {
- if (android_op_gui) {
- /* Initialize display from the command line parameters. */
- android_display_init_from(android_display_width,
- android_display_height, 0,
- android_display_bpp);
- } else {
- ds = get_displaystate(); /* this forces a dumb display init */
- }
- } else if (android_op_gui) {
- /* Resize display from the command line parameters. */
- display_state->surface = qemu_resize_displaysurface(display_state,
- android_display_width,
- android_display_height);
+ ds = get_displaystate();
+
+ if (android_op_gui) {
+ /* Initialize display from the command line parameters. */
+ android_display_reset(ds,
+ android_display_width,
+ android_display_height,
+ android_display_bpp);
+ } else {
+ /* By default, use 320x480x16 */
+ android_display_reset(ds, 320, 480, 16);
}
if (display_type == DT_DEFAULT) {
@@ -5270,7 +5264,7 @@ int main(int argc, char **argv, char **envp)
qemu_mod_timer(nographic_timer, qemu_get_clock(rt_clock));
}
- text_consoles_set_display(display_state);
+ text_consoles_set_display(ds);
qemu_chr_initial_reset();
if (monitor_device && monitor_hd)