display: Added new features to the Qt5 UI
authorjinhyung.jo <jinhyung.jo@samsung.com>
Wed, 15 Apr 2015 07:48:46 +0000 (16:48 +0900)
committerjinhyung.jo <jinhyung.jo@samsung.com>
Wed, 15 Apr 2015 08:06:04 +0000 (17:06 +0900)
1. Additional parameters to select a rendering mode
 -display maru_qt,rendering=<onscreen/offscreen>
2. Implemented brightness & rotation, scaling features in the offscreen mode

Change-Id: I00169dde7f23ed16acb5426a073a144820d1cb67
Signed-off-by: Jinhyung Jo <jinhyung.jo@samsung.com>
hw/vigs/vigs_qt5.cpp
hw/vigs/vigs_server.c
include/sysemu/sysemu.h
tizen/src/display/maru_display.c
tizen/src/display/maru_display.h
tizen/src/display/qt5.c
tizen/src/display/qt5_supplement.cpp
tizen/src/display/qt5_supplement.h
vl.c

index 1166c8d..927d558 100644 (file)
@@ -34,6 +34,7 @@
 #include <qpa/qplatformnativeinterface.h>
 #include <stdio.h>
 
+extern bool qt5IsOnscreen;
 extern QApplication *qt5App;
 extern QOpenGLContext *qt5GLContext;
 extern QSurfaceFormat qt5GLFormat;
@@ -46,14 +47,10 @@ extern void qt5_process_captured(bool captured, void *pixels,
 
 bool vigs_qt5_onscreen_enabled(void)
 {
-#ifndef CONFIG_DARWIN
-    /* Qt5 bug, QGLWidget has some problem on MacOS.
-     * (scrambled screen when resizing, invalid region masking) */
-    if (qt5App != NULL) {
+    // TODO: on Darwin?
+    if (qt5App != NULL && qt5IsOnscreen) {
         return true;
     }
-#endif
-
     return  false;
 }
 
index 5e26629..13575b5 100644 (file)
@@ -458,6 +458,7 @@ static void vigs_server_capture_work(struct work_queue_item *wq_item)
 
     if (pixels) {
         captured = server->capture(server, root_sfc, pixels);
+        /* TODO: brightness composite to pixels */
     }
 
     server->capture_ops->process_captured(captured,
index 57b3107..7652c16 100644 (file)
@@ -103,7 +103,8 @@ typedef enum DisplayType
 #ifdef CONFIG_MARU
     DT_MARU_SDL,
     DT_MARU_SHM,
-    DT_MARU_QT,
+    DT_MARU_QT_ONSCREEN,
+    DT_MARU_QT_OFFSCREEN,
 #endif
     DT_NONE,
 } DisplayType;
index b3aa9c2..db2abfb 100644 (file)
@@ -64,8 +64,11 @@ void maru_display_early_init(DisplayType display_type)
 {
     switch (display_type) {
 #ifdef CONFIG_QT
-    case DT_MARU_QT:
-        maru_qt5_display_early_init();
+    case DT_MARU_QT_ONSCREEN:
+        maru_qt5_display_early_init(true);
+        break;
+    case DT_MARU_QT_OFFSCREEN:
+        maru_qt5_display_early_init(false);
         break;
 #endif
     default:
@@ -92,7 +95,8 @@ void maru_display_init(DisplayState *ds, DisplayType display_type,
         break;
 #endif
 #ifdef CONFIG_QT
-    case DT_MARU_QT:
+    case DT_MARU_QT_ONSCREEN:
+    case DT_MARU_QT_OFFSCREEN:
         maru_qt5_display_init(mdcl, full_screen);
         break;
 #endif
index c58a4af..caee72c 100644 (file)
@@ -74,7 +74,7 @@ void maru_sdl_pre_init(MaruDisplayChangeListener *mdcl);
 void maru_shm_pre_init(MaruDisplayChangeListener *mdcl);
 
 /* maru_qt */
-void maru_qt5_display_early_init(void);
+void maru_qt5_display_early_init(bool isOnscreen);
 
 void maru_qt5_display_init(MaruDisplayChangeListener *mdcl, int full_screen);
 
index 495a17d..6f33a22 100644 (file)
  *
  */
 
+#include <png.h>
 #include "ui/console.h"
 #include "emul_state.h"
 #include "maru_display.h"
 #include "qt5_supplement.h"
+#include "maru_display_processing.h"
 
 extern QemuMutex sdl_mutex;
 extern QemuCond sdl_cond;
@@ -65,6 +67,8 @@ static void qt5_update(DisplayChangeListener *dcl,
         return;
     }
 
+    composite_brightness_image(surf->image);
+
     qt5_update_internal(surface_data(surf),
                         surface_width(surf),
                         surface_height(surf));
@@ -105,7 +109,7 @@ void ns_run_in_event_loop(void (*func)());
 void set_application_icon(char *path);
 #endif
 
-void maru_qt5_display_early_init(void)
+void maru_qt5_display_early_init(bool isOnscreen)
 {
 #ifdef CONFIG_DARWIN
     ns_run_in_event_loop(&qt5_early_prepare);
@@ -124,7 +128,7 @@ void maru_qt5_display_early_init(void)
     set_application_icon(icon_path);
     g_free(icon_path);
 #else
-    qt5_early_prepare();
+    qt5_early_prepare(isOnscreen);
 #endif
 }
 
index e46e246..41af9f3 100644 (file)
@@ -45,6 +45,7 @@ void qMessageOutput(QtMsgType, const QMessageLogContext &, const QString &);
 void loadMainFormFromXML(QFile *, UIInformation *);
 void loadConFormFromXML(QFile *, UIInformation *);
 
+bool qt5IsOnscreen;
 QApplication *qt5App = NULL;
 
 static int argc = 0;
@@ -257,8 +258,9 @@ void qt5_destroy()
     delete uiInfo;
 }
 
-void qt5_early_prepare(void)
+void qt5_early_prepare(bool isOnscreen)
 {
+    qt5IsOnscreen = isOnscreen;
     Q_INIT_RESOURCE(resource);
     qInstallMessageHandler(qMessageOutput);
 
@@ -294,17 +296,17 @@ void qt5_prepare(void)
 
 void qt5_update_internal(void *data, int width, int height)
 {
+    QMatrix matrix = QMatrix();
     QPixmap pixmap = QPixmap();
     QLabel *screenWidget = mainwindow->getScreenWidget();
 
-    /*
-     * TODO: support rotation.
-     */
+    matrix.scale(mainwindow->getUIState()->getScaleFactor(),
+                 mainwindow->getUIState()->getScaleFactor());
+    matrix.rotate(mainwindow->uiInfo->getMainFormDisplayType()->getAngle());
 
     QImage image = QImage((uchar *)data, width, height, QImage::Format_RGB32);
-    pixmap.convertFromImage(image);
-    screenWidget->setPixmap(pixmap.scaled(screenWidget->size(),
-        Qt::KeepAspectRatio, Qt::SmoothTransformation));
+    pixmap.convertFromImage(image.transformed(matrix, Qt::SmoothTransformation));
+    screenWidget->setPixmap(pixmap);
 }
 
 void qt5_switch_internal(void)
index 74b96a8..d9a9189 100644 (file)
@@ -36,7 +36,7 @@ extern "C" {
 #endif
 void qt5_graphic_hw_invalidate(void);
 int qt5_graphic_hw_display(void);
-void qt5_early_prepare(void);
+void qt5_early_prepare(bool isOnscreen);
 void qt5_prepare(void);
 void qt5_destroy(void);
 
diff --git a/vl.c b/vl.c
index 22e4ee4..18269c7 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -2209,7 +2209,25 @@ static DisplayType select_display(const char *p)
 # endif
     } else if (strstart(p, "maru_qt", &opts)) {
 # ifdef CONFIG_QT
-        display = DT_MARU_QT;
+        if (*opts) {
+            const char *nextopt;
+            if (strstart(opts, ",rendering=", &nextopt)) {
+                opts = nextopt;
+                if (strstart(opts, "onscreen", &nextopt)) {
+                    display = DT_MARU_QT_ONSCREEN;
+                } else if (strstart(opts, "offscreen", &nextopt)) {
+                    display = DT_MARU_QT_OFFSCREEN;
+                } else {
+                    goto invalid_maru_qt_args;
+                }
+            } else {
+            invalid_maru_qt_args:
+                fprintf(stderr, "Invalid maru_qt option string: %s\n", p);
+                exit(1);
+            }
+        } else {
+            display = DT_MARU_QT_ONSCREEN;
+        }
 # else
         fprintf(stderr, "maru_qt is disabled\n");
 
@@ -4544,7 +4562,8 @@ int main(int argc, char **argv, char **envp)
         break;
 #endif
 #if defined(CONFIG_QT)
-    case DT_MARU_QT:
+    case DT_MARU_QT_ONSCREEN:
+    case DT_MARU_QT_OFFSCREEN:
         maru_display_init(ds, display_type, full_screen);
         break;
 #endif