From: GiWoong Kim Date: Tue, 1 Sep 2015 11:50:01 +0000 (+0900) Subject: display: modified "display off guide image" processing X-Git-Tag: TizenStudio_2.0_p2.3.2~39^2~166 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=10e7e30f134e3411546eacde90645e921f9f7c70;p=sdk%2Femulator%2Fqemu.git display: modified "display off guide image" processing use an absolute path on image loading. remove unnecessary image format conversions. modify some variable and function names. Change-Id: I679ffb5e8661b51bbdd78d48dc34b23692e160ce Signed-off-by: GiWoong Kim --- diff --git a/tizen/src/display/maru_sdl.c b/tizen/src/display/maru_sdl.c index 1caae28..bc98557 100644 --- a/tizen/src/display/maru_sdl.c +++ b/tizen/src/display/maru_sdl.c @@ -73,7 +73,7 @@ static unsigned int sdl_skip_count; static bool blank_guide_enable; static unsigned int blank_cnt; -#define MAX_BLANK_FRAME_CNT 10 +#define MAX_DPY_BLANK_FRAME_CNT 10 #define BLANK_GUIDE_IMAGE_PATH "../images/" #define BLANK_GUIDE_IMAGE_NAME "display_off_guide.png" @@ -219,7 +219,7 @@ static void qemu_ds_sdl_refresh(DisplayChangeListener *dcl) /* draw cover image */ if (sdl_skip_update && display_off) { - if (blank_cnt > MAX_BLANK_FRAME_CNT) { + if (blank_cnt > MAX_DPY_BLANK_FRAME_CNT) { #ifdef CONFIG_WIN32 if (sdl_invalidate && is_skin_enabled()) { draw_image(surface_screen, get_blank_guide_image()); @@ -227,7 +227,7 @@ static void qemu_ds_sdl_refresh(DisplayChangeListener *dcl) #endif return; - } else if (blank_cnt == MAX_BLANK_FRAME_CNT) { + } else if (blank_cnt == MAX_DPY_BLANK_FRAME_CNT) { if (blank_guide_enable == true && is_skin_enabled()) { INFO("draw a blank guide image\n"); diff --git a/tizen/src/display/maru_shm.c b/tizen/src/display/maru_shm.c index 41f30e8..3efa780 100644 --- a/tizen/src/display/maru_shm.c +++ b/tizen/src/display/maru_shm.c @@ -59,7 +59,7 @@ static int shm_skip_count; static bool blank_guide_enable; static int blank_cnt; -#define MAX_BLANK_FRAME_CNT 10 +#define MAX_DPY_BLANK_FRAME_CNT 10 extern QemuMutex mutex_draw_display; extern int draw_display_state; @@ -148,10 +148,10 @@ static void qemu_ds_shm_refresh(DisplayChangeListener *dcl) /* If the display is turned off, the screen does not update until the it is turned on */ if (shm_skip_update && display_off) { - if (blank_cnt > MAX_BLANK_FRAME_CNT) { + if (blank_cnt > MAX_DPY_BLANK_FRAME_CNT) { /* do nothing */ return; - } else if (blank_cnt == MAX_BLANK_FRAME_CNT) { + } else if (blank_cnt == MAX_DPY_BLANK_FRAME_CNT) { if (blank_guide_enable == true) { INFO("draw a blank guide image\n"); diff --git a/tizen/src/ui/displaybase.cpp b/tizen/src/ui/displaybase.cpp index db9e30b..993fc0c 100644 --- a/tizen/src/ui/displaybase.cpp +++ b/tizen/src/ui/displaybase.cpp @@ -47,16 +47,17 @@ int qt5_window_angle = 0; DisplayBase::DisplayBase(DisplayType *displayForm, QSize resolution, qreal scaleFactor, QWidget *w) : resolution(resolution), widget(w) { + this->win = (MainWindow *)widget->parentWidget(); this->rect = displayForm->getRect(); this->maskImage = displayForm->getMask(); this->rotateAngle = displayForm->getAngle(); this->scaleFactor = scaleFactor; this->isDragging = false; - this->gImgState = false; + + this->offGuide = NULL; + this->offGuideShown = false; this->tsHelper = new TouchScreenHelper(this); - this->gImg = new QImage(); - this->gPxmImg = new QPixmap(); isTouch = is_touchscreen_enabled(); if (!isTouch) { @@ -66,11 +67,10 @@ DisplayBase::DisplayBase(DisplayType *displayForm, QSize resolution, qreal scale mouseStatus = MOUSE_LEAVE; } - loadGuideImg(); - - MainWindow *win = (MainWindow *)widget->parentWidget(); win->getMainView()->getKbdHelper()->setMtTracker(tsHelper->getMtTracker()); + loadGuideImg(); + updateGeometry(); /* update sensor */ @@ -79,60 +79,56 @@ DisplayBase::DisplayBase(DisplayType *displayForm, QSize resolution, qreal scale void DisplayBase::loadGuideImg() { - QString guide_img_path(SDK_EMULATOR_IMAGES_PATH); - guide_img_path.append(DISPLAY_OFF_GUIDE_IMAGE_FILE); + QString offImage = QDir(QCoreApplication::applicationDirPath() + + QDir::separator() + SDK_EMULATOR_IMAGES_PATH + + DISPLAY_OFF_GUIDE_IMAGE_FILE).absolutePath(); - bool ret = gImg->load(guide_img_path); - if (ret == false) { - qDebug() << guide_img_path << ": No such file"; - isGimgReady = false; - } else { - isGimgReady = true; + if (offGuideImg.load(offImage) == false) { + qWarning() << "failed to load image from" << offImage; } } -void DisplayBase::startGuideImg() +bool DisplayBase::isOffGuideReady() { - MainWindow *win = (MainWindow *)widget->parentWidget(); - int rWidth = rect.width() * scaleFactor; - int rHeight = rect.height() * scaleFactor; - int x = rect.x() * scaleFactor; - int y = rect.y() * scaleFactor; + return !offGuideImg.isNull(); +} - gLabel = new QLabel(win); - gLabel->setAttribute(Qt::WA_DeleteOnClose); - gLabel->setStyleSheet("background-color: black"); +void DisplayBase::showOffGuideImg() +{ + offGuideShown = true; - *gPxmImg = QPixmap::fromImage(*gImg); - *gPxmImg = gPxmImg->scaled(rWidth, rHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation); + offGuide = new QLabel(win); + offGuide->setAttribute(Qt::WA_DeleteOnClose); + offGuide->setStyleSheet( + "background-color: black; border-style: none;"); + offGuide->setAlignment(Qt::AlignCenter); - gLabel->setPixmap(*gPxmImg); - gLabel->setGeometry(x, y, rWidth, rHeight); - gLabel->setAlignment(Qt::AlignCenter); - gLabel->show(); + offGuide->setGeometry(getGeometry()); + offGuide->setPixmap(offGuideImg.scaled( + getGeometry().width(), getGeometry().height(), + Qt::KeepAspectRatio, Qt::SmoothTransformation)); - gImgState = true; + offGuide->show(); } -void DisplayBase::stopGuideImg() +void DisplayBase::hideOffGuideImg() { - gLabel->close(); - gImgState = false; -} + if (offGuide != NULL) { + offGuide->close(); + offGuide = NULL; + } -bool DisplayBase::getIsGimgReady() -{ - return isGimgReady; + offGuideShown = false; } -bool DisplayBase::getGimgState() +bool DisplayBase::isOffGuideShown() { - return gImgState; + return offGuideShown; } void DisplayBase::switchForm(DisplayType *displayForm) { - qDebug() << "display switch angle :" << displayForm->getAngle(); + qDebug() << "display switch angle:" << displayForm->getAngle(); qt5_window_angle = rotateAngle = displayForm->getAngle(); @@ -150,7 +146,7 @@ void DisplayBase::switchForm(DisplayType *displayForm) void DisplayBase::scaleForm(qreal scaleFactor) { - qDebug() << "display scale factor :" << scaleFactor; + qDebug() << "display scale factor:" << scaleFactor; this->scaleFactor = scaleFactor; @@ -167,10 +163,13 @@ void DisplayBase::update() void DisplayBase::updateGeometry() { + if (isOffGuideShown() == true) { + hideOffGuideImg(); + } + qreal sx = rect.x() * scaleFactor; qreal sy = rect.y() * scaleFactor; - widget->setGeometry( qRound(sx), - qRound(sy), + widget->setGeometry(qRound(sx), qRound(sy), rect.width() * scaleFactor, rect.height() * scaleFactor); } @@ -192,7 +191,7 @@ void DisplayBase::handlePaint(QPaintEvent *event) void DisplayBase::handleResize(QResizeEvent *event) { - qDebug() << "resize display :" << event->size(); + qDebug() << "resize display:" << event->size(); qt5_window_width = widget->width(); qt5_window_height = widget->height(); @@ -408,6 +407,8 @@ DisplayBase::~DisplayBase() { qDebug("destroy display"); + hideOffGuideImg(); + if (tsHelper != NULL) { delete tsHelper; } diff --git a/tizen/src/ui/displaybase.h b/tizen/src/ui/displaybase.h index 8469475..6440105 100644 --- a/tizen/src/ui/displaybase.h +++ b/tizen/src/ui/displaybase.h @@ -40,6 +40,8 @@ #include "layout/displaytype.h" #include "input/touchscreenhelper.h" +class MainWindow; + enum { TOUCH_PRESS = 1, TOUCH_RELEASE = 2, @@ -65,11 +67,10 @@ enum { class DisplayBase { public: - void loadGuideImg(); - void startGuideImg(); - void stopGuideImg(); - bool getIsGimgReady(); - bool getGimgState(); + bool isOffGuideReady(); + void showOffGuideImg(); + void hideOffGuideImg(); + bool isOffGuideShown(); void switchForm(DisplayType *displayForm); void scaleForm(qreal scaleFactor); @@ -101,6 +102,8 @@ protected: bool isDragging; private: + void loadGuideImg(); + void sendMouseEvent(int eventType, int clientX, int clientY); QSize resolution; @@ -111,16 +114,15 @@ private: int mouseStatus; struct timeval lastMouseTime; - QLabel *gLabel; - QPixmap *gPxmImg; - QImage *gImg; - QWidget *widget; - TouchScreenHelper *tsHelper; - + MainWindow *win; + QWidget *widget; /* child */ QRect rect; QPixmap maskImage; - bool isGimgReady; - bool gImgState; + TouchScreenHelper *tsHelper; + + QLabel *offGuide; + QPixmap offGuideImg; + bool offGuideShown; }; #endif diff --git a/tizen/src/ui/menu/contextmenu.cpp b/tizen/src/ui/menu/contextmenu.cpp index 47743bd..76edb57 100644 --- a/tizen/src/ui/menu/contextmenu.cpp +++ b/tizen/src/ui/menu/contextmenu.cpp @@ -634,18 +634,9 @@ void ContextMenu::slotTopMostShortcut() void ContextMenu::slotSwitch(int index) { - qDebug("switch : %d", index); + qDebug("switch: %d", index); parent->switchForm(index); - - DisplayBase *db = parent->getDisplay(); - if (db) { - if (db->getGimgState() == true) { - db->stopGuideImg(); - } - } else { - qDebug() << "Display is not ready."; - } } void ContextMenu::slotSwitchShortcutPrev() @@ -702,18 +693,9 @@ void ContextMenu::slotSwitchShortcutNext() void ContextMenu::slotScale(int scale) { - qDebug("scale : %d", scale); + qDebug("scale: %d", scale); parent->scaleForm(scale); - - DisplayBase *db = parent->getDisplay(); - if (db) { - if (db->getGimgState() == true) { - db->stopGuideImg(); - } - } else { - qDebug() << "Display is not ready."; - } } void ContextMenu::slotScaleShortcutPrev() diff --git a/tizen/src/ui/qt5_supplement.cpp b/tizen/src/ui/qt5_supplement.cpp index 7c1f1e4..7c1a2a3 100644 --- a/tizen/src/ui/qt5_supplement.cpp +++ b/tizen/src/ui/qt5_supplement.cpp @@ -56,8 +56,8 @@ QApplication *qt5App = NULL; static int argc = 0; static char *argv[0]; -#define MAX_BLANK_FRAME_CNT 10 -static unsigned int blank_cnt; +#define MAX_DPY_BLANK_FRAME_CNT 10 +static unsigned int dpy_blank_cnt; static void *captureRequestListener; static void (*captureRequestHandler)(void *); @@ -365,28 +365,25 @@ void qt5_refresh_internal(void) { qt5App->processEvents(); - DisplayBase *db = mainwindow->getDisplay(); - if (db) { - if (db->getIsGimgReady()) { - if (is_display_off()) { - if (db->getGimgState() == false) { - if (blank_cnt > MAX_BLANK_FRAME_CNT) { - db->startGuideImg(); - blank_cnt = 0; - } else { - blank_cnt++; - } + DisplayBase *display = mainwindow->getDisplay(); + if (display && display->isOffGuideReady() == true) { + if (is_display_off() == true) { + /* show guide image for display off */ + if (display->isOffGuideShown() == false) { + if (dpy_blank_cnt > MAX_DPY_BLANK_FRAME_CNT) { + display->showOffGuideImg(); + dpy_blank_cnt = 0; + } else { + dpy_blank_cnt++; } - } else { - if (db->getGimgState() == true) { - db->stopGuideImg(); - } - - blank_cnt = 0; } + } else { + if (display->isOffGuideShown() == true) { + display->hideOffGuideImg(); + } + + dpy_blank_cnt = 0; } - } else { - qDebug() << "Display is not ready."; } }