From 10e7e30f134e3411546eacde90645e921f9f7c70 Mon Sep 17 00:00:00 2001 From: GiWoong Kim Date: Tue, 1 Sep 2015 20:50:01 +0900 Subject: 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 --- tizen/src/display/maru_sdl.c | 6 +-- tizen/src/display/maru_shm.c | 6 +-- tizen/src/ui/displaybase.cpp | 89 ++++++++++++++++++++------------------- tizen/src/ui/displaybase.h | 28 ++++++------ tizen/src/ui/menu/contextmenu.cpp | 22 +--------- tizen/src/ui/qt5_supplement.cpp | 39 ++++++++--------- 6 files changed, 86 insertions(+), 104 deletions(-) diff --git a/tizen/src/display/maru_sdl.c b/tizen/src/display/maru_sdl.c index 1caae288d5..bc985579b6 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 41f30e87d2..3efa780df4 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 db9e30b6fd..993fc0c7bc 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 8469475c22..6440105e9e 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 47743bdcef..76edb57674 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 7c1f1e40d5..7c1a2a3a71 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."; } } -- cgit v1.2.3