display: declare createDisplay function
authorGiWoong Kim <giwoong.kim@samsung.com>
Thu, 9 Apr 2015 05:49:42 +0000 (14:49 +0900)
committerGiWoong Kim <giwoong.kim@samsung.com>
Thu, 9 Apr 2015 05:49:42 +0000 (14:49 +0900)
Change-Id: I9e00758b4111ce5bafbfc77b9001f4b6c5f30627
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
tizen/src/display/qt5_supplement.cpp
tizen/src/ui/mainwindow.cpp
tizen/src/ui/mainwindow.h

index e524956fdd79479029945b675957dfbae0d9f457..e46e2462fce716759db9384c76879b85344bc8a2 100644 (file)
@@ -224,7 +224,7 @@ void qt5_gui_init(void)
 
     mainwindow->show();
 
-    mainwindow->startSwapper();
+    mainwindow->startDisplaySwapper();
 }
 
 void qt5_destroy()
@@ -248,7 +248,7 @@ void qt5_destroy()
     }
 
     /* clean up */
-    mainwindow->terminateSwapper();
+    mainwindow->terminateDisplaySwapper();
 
     mainwindow->closeController();
 
index 81a9c14519b2a4c6a1eb8063ff117426dadb69bc..997d7e1043cc150cafcae0260bf0fe757bc3933d 100644 (file)
@@ -75,13 +75,16 @@ MainWindow::MainWindow(UIInformation *uiInfo, QWidget *parent) :
 {
     /* initialize */
     this->uiInfo = uiInfo;
-    this->popupMenu = NULL;
     this->skinView = NULL;
+    this->popupMenu = NULL;
+
     this->display = NULL;
-    this->screenWidget = NULL;
+    this->swapper = NULL;
+    this->swapperThread = NULL;
 
-    captureRequestHandler = NULL;
-    captureRequestData = NULL;
+    this->screenWidget = NULL;
+    this->captureRequestHandler = NULL;
+    this->captureRequestData = NULL;
 
     /* windowing */
     setWindowTitle("Emulator");
@@ -103,9 +106,27 @@ MainWindow::MainWindow(UIInformation *uiInfo, QWidget *parent) :
     winLayout->addWidget(skinView);
 
     /* display */
-    QGLContext *context = NULL;
+    display = createDisplay();
+
+    /* set HW Key shortcut */
+    keyboardShortcut = new KeyboardShortcut(this);
+    keyboardShortcut->setKeyboardShortcutHwKey();
+
+    /* popup menu */
+    popupMenu = new ContextMenu(this);
+
+    setContextMenuPolicy(Qt::CustomContextMenu);
+    connect(this, SIGNAL(customContextMenuRequested(const QPoint&)),
+        SLOT(showContextMenu(const QPoint&)));
+}
+
+DisplayBase *MainWindow::createDisplay()
+{
+    DisplayBase *displayWidget = NULL;
+
     if (qt5GLContext) { /* on-screen rendering */
-        QGLContext *wrapperContext = QGLContext::fromOpenGLContext(qt5GLContext);
+        QGLContext *wrapperContext =
+            QGLContext::fromOpenGLContext(qt5GLContext);
 
         /*
          * Qt5 bug, wrapperContext->requestedFormat() doesn't return
@@ -119,60 +140,50 @@ MainWindow::MainWindow(UIInformation *uiInfo, QWidget *parent) :
          * Qt5 bug, format set here doesn't always have effect, must
          * set it after QGLWidget is created.
          */
-        context = new QGLContext(format);
+        QGLContext *context = new QGLContext(format);
 
-        display = new DisplayGLWidget(skinView, context,
+        displayWidget = new DisplayGLWidget(skinView, context,
             uiInfo->getMainFormDisplayType()->getRect(),
             uiInfo->getMainFormDisplayType()->getAngle(),
             getUIState()->getScaleFactor());
 
         context->setFormat(format);
-
         context->create(wrapperContext);
-    } else { /* off-screen rendering */
-        DisplaySWWidget *w = new DisplaySWWidget(skinView,
-            uiInfo->getMainFormDisplayType()->getRect(),
-            uiInfo->getMainFormDisplayType()->getAngle(),
-            getUIState()->getScaleFactor());
 
-        display = w;
-        screenWidget = w;
-    }
+        /* display swapper */
+        swapperThread = new QThread(this);
 
-    /* set HwKey shortcut */
-    keyboardShortcut = new KeyboardShortcut(this);
-    keyboardShortcut->setKeyboardShortcutHwKey();
+        if (context) {
+            context->doneCurrent();
+            context->moveToThread(swapperThread);
+        }
 
-    /* popup menu */
-    popupMenu = new ContextMenu(this);
+        swapper = new DisplaySwapper(context);
+        swapper->moveToThread(swapperThread);
+        connect(swapperThread, &QThread::finished, swapper, &QObject::deleteLater);
 
-    setContextMenuPolicy(Qt::CustomContextMenu);
-    connect(this, SIGNAL(customContextMenuRequested(const QPoint&)),
-        SLOT(showContextMenu(const QPoint&)));
-
-    /* swapper */
-    swapperThread = new QThread(this);
+        swapperThread->start();
+    } else { /* off-screen rendering */
+        DisplaySWWidget *widget = new DisplaySWWidget(skinView,
+            uiInfo->getMainFormDisplayType()->getRect(),
+            uiInfo->getMainFormDisplayType()->getAngle(),
+            getUIState()->getScaleFactor());
 
-    if (context) {
-        context->doneCurrent();
-        context->moveToThread(swapperThread);
+        screenWidget = widget;
+        displayWidget = widget;
     }
 
-    swapper = new DisplaySwapper(context);
-    swapper->moveToThread(swapperThread);
-    connect(swapperThread, &QThread::finished, swapper, &QObject::deleteLater);
-
-    swapperThread->start();
+    return displayWidget;
 }
 
-void MainWindow::startSwapper()
+void MainWindow::startDisplaySwapper()
 {
     if (swapper != NULL) {
         QMetaObject::invokeMethod(swapper, "display", Qt::QueuedConnection);
     }
 }
 
-void MainWindow::terminateSwapper()
+void MainWindow::terminateDisplaySwapper()
 {
     if (swapper != NULL) {
         swapper->setTerminating();
@@ -361,9 +372,11 @@ void MainWindow::switchForm(int index)
     resize(uiInfo->getUiSize());
     skinView->update();
 
-    display->rotate(
-        uiInfo->getMainFormDisplayType()->getRect(),
-        uiInfo->getMainFormDisplayType()->getAngle());
+    if (display != NULL) {
+        display->rotate(
+            uiInfo->getMainFormDisplayType()->getRect(),
+            uiInfo->getMainFormDisplayType()->getAngle());
+    }
 }
 
 void MainWindow::scaleForm(int scale)
@@ -379,7 +392,9 @@ void MainWindow::scaleForm(int scale)
     resize(uiInfo->getUiSize());
     skinView->update();
 
-    display->scale(getUIState()->getScaleFactor());
+    if (display != NULL) {
+        display->scale(getUIState()->getScaleFactor());
+    }
 }
 
 void MainWindow::capture(void)
index da0ce214e6f9619d4b4b58d13f64e9bb66ec1453..b0ecbd0367fd7149de462333ae2cdde23d7ffed9 100644 (file)
@@ -89,8 +89,8 @@ public:
     FloatingController *getFloatingCon();
     void openController(int index, int dockPos);
     void closeController();
-    void startSwapper();
-    void terminateSwapper();
+    void startDisplaySwapper();
+    void terminateDisplaySwapper();
 
     UIInformation *uiInfo;
 
@@ -106,6 +106,8 @@ protected:
     QLabel *screenWidget;
 
 private:
+    DisplayBase *createDisplay();
+
     /* windowing */
     QHBoxLayout *winLayout;
     QGraphicsScene *skinScene;