From: GiWoong Kim Date: Mon, 6 Jul 2015 08:36:20 +0000 (+0900) Subject: display: DisplaySwapper class was separated X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.2~317 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8d8222e91a16a934536981e4a6528d46fe691bb4;p=sdk%2Femulator%2Fqemu.git display: DisplaySwapper class was separated And call a quit slot when swapper has been terminated Change-Id: I3b863d2a761fad49191ea964099a9142105c938b Signed-off-by: GiWoong Kim --- diff --git a/tizen/src/ui/Makefile.objs b/tizen/src/ui/Makefile.objs index 88d4b26fd1..ef66fac600 100644 --- a/tizen/src/ui/Makefile.objs +++ b/tizen/src/ui/Makefile.objs @@ -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 index 0000000000..34f56a1e3b --- /dev/null +++ b/tizen/src/ui/displayswapper.cpp @@ -0,0 +1,63 @@ +/* + * Qt UI + * + * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * GiWoong Kim + * Sangho Park + * 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 index 0000000000..aa5714b0c2 --- /dev/null +++ b/tizen/src/ui/displayswapper.h @@ -0,0 +1,57 @@ +/* + * Qt UI + * + * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * GiWoong Kim + * Sangho Park + * 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 +#include + +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 diff --git a/tizen/src/ui/mainwindow.cpp b/tizen/src/ui/mainwindow.cpp index 57027673fe..eb265aa57e 100644 --- a/tizen/src/ui/mainwindow.cpp +++ b/tizen/src/ui/mainwindow.cpp @@ -37,42 +37,11 @@ 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 */ diff --git a/tizen/src/ui/mainwindow.h b/tizen/src/ui/mainwindow.h index 888b4a1d3c..7a6541e75e 100644 --- a/tizen/src/ui/mainwindow.h +++ b/tizen/src/ui/mainwindow.h @@ -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