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 1166c8d561a75700d72f2e275c2c0338a1103fa5..927d558320c7516aa100a1875433b7548fb24709 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 5e266295c4e1efadfc997f486e0833113c7a2121..13575b538c459904dba39aac8bc38712dcfb8338 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 57b31073ad81a26bc8b9da245c9de66862f59d55..7652c16fa562165a2bd1b506650cc855c5b19999 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 b3aa9c2c6cb4f9158af0149524f7bb73dc1b2e7a..db2abfb78ee3d325393b549e955e628f069fece9 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 c58a4aff5b33f5b5fd7bab00c9eb33c609e6c155..caee72c542d859b1977cd4df40a9a3ae7d15997e 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 495a17d5e9a0f8b99b3c3b2da1dea0d990514117..6f33a22a47e7857c7890b4a3ac1601ec1ca727af 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 e46e2462fce716759db9384c76879b85344bc8a2..41af9f39c734f7b3ed23067b71b4fcd3ef6948b2 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 74b96a8c418eaa14fa484194ce67b0f2a982a6dc..d9a91894447396b0dc5b8b03ea81dca3830b7655 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 22e4ee4eeb106e607af0d028a3ce8d0fcf2258e8..18269c722d2c949cbbf802958c40c67d8c325277 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