display: DisplaySwapper class was separated
authorGiWoong Kim <giwoong.kim@samsung.com>
Mon, 6 Jul 2015 08:36:20 +0000 (17:36 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Tue, 7 Jul 2015 13:12:00 +0000 (22:12 +0900)
And call a quit slot when swapper has been terminated

Change-Id: I3b863d2a761fad49191ea964099a9142105c938b
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
tizen/src/ui/Makefile.objs
tizen/src/ui/displayswapper.cpp [new file with mode: 0644]
tizen/src/ui/displayswapper.h [new file with mode: 0644]
tizen/src/ui/mainwindow.cpp
tizen/src/ui/mainwindow.h

index 88d4b26fd11f5e99bec3dd74c013061b422275f0..ef66fac600db4765590f83378e0fbbf28af38d10 100644 (file)
@@ -8,6 +8,7 @@ $(obj)/qrc_resource.cpp: $(TIZEN_UI)/resource/resource.qrc
 obj-$(CONFIG_QT) += displaybase.o
 obj-$(CONFIG_QT) += displayglwidget.o moc_displayglwidget.o
 obj-$(CONFIG_QT) += displayswwidget.o moc_displayswwidget.o
+obj-$(CONFIG_QT) += displayswapper.o moc_displayswapper.o
 obj-$(CONFIG_QT) += mainwindow.o moc_mainwindow.o
 obj-$(CONFIG_QT) += skinbezelitem.o
 obj-$(CONFIG_QT) += skinkeyitem.o moc_skinkeyitem.o
@@ -30,6 +31,9 @@ $(obj)/moc_displayglwidget.cpp: $(obj)/displayglwidget.h
 $(obj)/moc_displayswwidget.o: $(obj)/moc_displayswwidget.cpp
 $(obj)/moc_displayswwidget.cpp: $(obj)/displayswwidget.h
        moc $< -o $@
+$(obj)/moc_displayswapper.o: $(obj)/moc_displayswapper.cpp
+$(obj)/moc_displayswapper.cpp: $(obj)/displayswapper.h
+       moc $< -o $@
 $(obj)/moc_mainwindow.o: $(obj)/moc_mainwindow.cpp
 $(obj)/moc_mainwindow.cpp: $(obj)/mainwindow.h
        moc $< -o $@
diff --git a/tizen/src/ui/displayswapper.cpp b/tizen/src/ui/displayswapper.cpp
new file mode 100644 (file)
index 0000000..34f56a1
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Qt UI
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ * Stanislav Vorobiov
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#include "displayswapper.h"
+
+extern "C" {
+void qt5_graphic_hw_update(void);
+int qt5_graphic_hw_display(void);
+}
+
+DisplaySwapper::DisplaySwapper(QGLContext* context, QObject* parent) :
+    QObject(parent), context(context), terminating(false)
+{
+    /* do nothing */
+}
+
+void DisplaySwapper::display()
+{
+    if (context) {
+        while (!terminating) {
+            context->makeCurrent();
+            if (qt5_graphic_hw_display()) {
+                context->swapBuffers();
+            }
+            context->doneCurrent();
+        }
+    } else {
+        while (!terminating) {
+            qt5_graphic_hw_display();
+        }
+    }
+
+    qDebug("DisplaySwapper::display() terminated");
+
+    emit displayFinished();
+}
diff --git a/tizen/src/ui/displayswapper.h b/tizen/src/ui/displayswapper.h
new file mode 100644 (file)
index 0000000..aa5714b
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Qt UI
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ * Stanislav Vorobiov
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#ifndef DISPLAYSWAPPER_H
+#define DISPLAYSWAPPER_H
+
+#include <QWidget>
+#include <QGLContext>
+
+class DisplaySwapper : public QObject
+{
+    Q_OBJECT
+
+public:
+    DisplaySwapper(QGLContext* context, QObject* parent = 0);
+
+    inline void setTerminating() { terminating = true; }
+
+public slots:
+    void display();
+
+signals:
+    void displayFinished();
+
+private:
+    QGLContext *context;
+    bool terminating;
+};
+
+#endif // DISPLAYSWAPPER_H
index 57027673fedfb95a99f49e21c19ccd32ed07a26f..eb265aa57eae4cb2ed4a858c2d4b804100636dd3 100644 (file)
 
 extern "C" {
 void qt5_graphic_hw_update(void);
-int qt5_graphic_hw_display(void);
 }
 
 QOpenGLContext *qt5GLContext = NULL;
 QSurfaceFormat qt5GLFormat;
 
-DisplaySwapper::DisplaySwapper(QGLContext* context, QObject* parent) :
-    QObject(parent), context(context), terminating(false)
-{
-    /* do nothing */
-}
-
-void DisplaySwapper::display()
-{
-    /*
-     * TODO: Currently qt5 skin doesn't terminate properly,
-     * check this once proper termination is implemented.
-     */
-
-    if (context) {
-        while (!terminating) {
-            context->makeCurrent();
-            if (qt5_graphic_hw_display()) {
-                context->swapBuffers();
-            }
-            context->doneCurrent();
-        }
-    } else {
-        while (!terminating) {
-            qt5_graphic_hw_display();
-        }
-    }
-
-    qDebug("DisplaySwapper::display() terminated");
-}
-
 MainWindow::MainWindow(UIInformation *uiInfo, QWidget *parent) :
     QWidget(parent)
 {
@@ -175,7 +144,11 @@ DisplayBase *MainWindow::createDisplay(DisplayType *displayForm)
 
         swapper = new DisplaySwapper(context);
         swapper->moveToThread(swapperThread);
-        connect(swapperThread, &QThread::finished, swapper, &QObject::deleteLater);
+
+        connect(swapper, SIGNAL(displayFinished()),
+            swapperThread, SLOT(quit()), Qt::DirectConnection);
+        connect(swapperThread, SIGNAL(finished()), swapper, SLOT(deleteLater()));
+        connect(swapperThread, SIGNAL(finished()), swapperThread, SLOT(deleteLater()));
 
         swapperThread->start();
     } else { /* off-screen rendering */
index 888b4a1d3ce3c589c34fc4cecd61a7fa9b92979a..7a6541e75e6297cc79376471af77df5f92e750ad 100644 (file)
@@ -39,6 +39,7 @@
 #include "menu/contextmenu.h"
 #include "skinview.h"
 #include "displaybase.h"
+#include "displayswapper.h"
 #include "rotaryview.h"
 #include "uiinformation.h"
 #include "controller/dockingcontroller.h"
@@ -49,23 +50,6 @@ extern "C" {
 #include "skin/maruskin_operation.h"
 }
 
-class DisplaySwapper : public QObject
-{
-    Q_OBJECT
-
-public:
-    DisplaySwapper(QGLContext* context, QObject* parent = 0);
-
-    inline void setTerminating() { terminating = true; }
-
-public slots:
-    void display();
-
-private:
-    QGLContext *context;
-    bool terminating;
-};
-
 class MainWindow : public QWidget
 {
     Q_OBJECT