From: GiWoong Kim Date: Thu, 9 Apr 2015 05:49:42 +0000 (+0900) Subject: display: declare createDisplay function X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.2~508 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=00e257f364a2cd8c49ce9a5e8c76b252e31d41fa;p=sdk%2Femulator%2Fqemu.git display: declare createDisplay function Change-Id: I9e00758b4111ce5bafbfc77b9001f4b6c5f30627 Signed-off-by: GiWoong Kim --- diff --git a/tizen/src/display/qt5_supplement.cpp b/tizen/src/display/qt5_supplement.cpp index e524956fdd..e46e2462fc 100644 --- a/tizen/src/display/qt5_supplement.cpp +++ b/tizen/src/display/qt5_supplement.cpp @@ -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(); diff --git a/tizen/src/ui/mainwindow.cpp b/tizen/src/ui/mainwindow.cpp index 81a9c14519..997d7e1043 100644 --- a/tizen/src/ui/mainwindow.cpp +++ b/tizen/src/ui/mainwindow.cpp @@ -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) diff --git a/tizen/src/ui/mainwindow.h b/tizen/src/ui/mainwindow.h index da0ce214e6..b0ecbd0367 100644 --- a/tizen/src/ui/mainwindow.h +++ b/tizen/src/ui/mainwindow.h @@ -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;