qt5: respect QemuConsole and DisplaySurface
authorSeokYeon Hwang <syeon.hwang@samsung.com>
Sun, 9 Aug 2015 06:58:58 +0000 (15:58 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Mon, 10 Aug 2015 07:45:06 +0000 (16:45 +0900)
Change-Id: I5ae832a2ab72ab3f49aa791ba557430d2a2ab7c6
Signed-off-by: SeokYeon Hwang <syeon.hwang@samsung.com>
tizen/src/display/qt5.c
tizen/src/emul_state.c
ui/console.c

index f00e0e4c027bf7ec9ab6db7ee7c76ef64b6689ca..e39875847d8183a6327f912393a9fdc65ad3c99f 100644 (file)
 #include "qt5_supplement.h"
 #include "hw/pci/maru_brightness.h"
 
+#include "util/new_debug_ch.h"
+
+DECLARE_DEBUG_CHANNEL(qt5_console);
+
 /* static Notifier mouse_mode_notifier; */
 static int qt5_num_outputs;
 
@@ -63,21 +67,32 @@ int qt5_graphic_hw_display(void)
 static void qt5_update(DisplayChangeListener *dcl,
                        int x, int y, int w, int h)
 {
-    DisplaySurface *surf = qemu_console_surface(dcl->con);
-    if (!surf) {
-        return;
-    }
+    struct qt5_state *con = container_of(dcl, struct qt5_state, dcl);
+
+    assert(con->surface);
 
-    composite_brightness_image(surf->image);
+    composite_brightness_image(con->surface->image);
 
-    qt5_update_internal(surface_data(surf),
-                        surface_width(surf),
-                        surface_height(surf));
+    qt5_update_internal(surface_data(con->surface),
+                        surface_width(con->surface),
+                        surface_height(con->surface));
 }
 
 static void qt5_switch(DisplayChangeListener *dcl,
                        DisplaySurface *new_surface)
 {
+    struct qt5_state *con = container_of(dcl, struct qt5_state, dcl);
+
+    if (con->surface &&
+            (surface_width(con->surface) != surface_width(new_surface) ||
+             surface_height(con->surface) != surface_height(new_surface))) {
+        // TODO: we should adjust display size.
+        // We should warn to user since we can not adjust display size now.
+        LOG_WARNING("display size is changed.\n");
+    }
+
+    con->surface = new_surface;
+
 }
 
 static void qt5_refresh(DisplayChangeListener *dcl)
@@ -168,7 +183,6 @@ void maru_qt5_display_init(MaruDisplayChangeListener *mdcl, int full_screen)
         register_displaychangelistener(&qt5_console[i].dcl);
         qt5_console[i].idx = i;
     }
-    //mdcl->fini = maru_qt5_display_quit;
 
     if (full_screen) {
         /* TODO */
index a31de28b48d76bd6aa033fbda8e5b047c15e3e1a..c064186692ea969365f38a8e5867f3fdcdc20b30 100644 (file)
@@ -652,8 +652,8 @@ const char *get_vm_data_path(void)
 }
 
 // display resolution
-static int initial_resolution_width = -1;
-static int initial_resolution_height = -1;
+int initial_resolution_width = -1;
+int initial_resolution_height = -1;
 
 #ifdef CONFIG_JAVA_UI
 static void set_resolution_legacy(void)
@@ -685,22 +685,36 @@ void set_initial_display_resolution(int width, int height)
 
 int get_display_resolution_width(void)
 {
-#ifdef CONFIG_JAVA_UI
+#ifndef CONFIG_JAVA_UI
+    return qemu_console_get_width(NULL, -1);
+#else
+    if (display_type == DT_MARU_QT_ONSCREEN ||
+            display_type == DT_MARU_QT_OFFSCREEN) {
+        return qemu_console_get_width(NULL, -1);
+    }
     if (initial_resolution_width == -1) {
         set_resolution_legacy();
     }
-#endif
+    // for JAVA_UI
     return initial_resolution_width;
+#endif
 }
 
 int get_display_resolution_height(void)
 {
-#ifdef CONFIG_JAVA_UI
-    if (initial_resolution_width == -1) {
+#ifndef CONFIG_JAVA_UI
+    return qemu_console_get_height(NULL, -1);
+#else
+    if (display_type == DT_MARU_QT_ONSCREEN ||
+            display_type == DT_MARU_QT_OFFSCREEN) {
+        return qemu_console_get_height(NULL, -1);
+    }
+    if (initial_resolution_height == -1) {
         set_resolution_legacy();
     }
-#endif
+    // for JAVA_UI
     return initial_resolution_height;
+#endif
 }
 
 #ifdef CONFIG_JAVA_UI
index 60d546e051bd722b17d391b4ef1db46716d71711..118da3e294fe60392a6b56e319d1cc670831688f 100644 (file)
 #include "trace.h"
 #include "exec/memory.h"
 
-#ifdef SDL_THREAD
+#ifdef CONFIG_MARU
+extern int initial_resolution_width;
+extern int initial_resolution_height;
+# ifdef SDL_THREAD
 extern QemuMutex sdl_mutex;
+# endif
 #endif
 
 #define DEFAULT_BACKSCROLL 512
@@ -1714,6 +1718,13 @@ QemuConsole *graphic_console_init(DeviceState *dev, uint32_t head,
         "Guest has not initialized the display (yet).";
     int width = 640;
     int height = 480;
+#ifdef CONFIG_MARU
+    if (initial_resolution_width > 0 &&
+            initial_resolution_height > 0) {
+        width = initial_resolution_width;
+        height = initial_resolution_height;
+    }
+#endif
     QemuConsole *s;
     DisplayState *ds;