summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiWoong Kim <giwoong.kim@samsung.com>2015-09-01 20:50:01 +0900
committerSeokYeon Hwang <syeon.hwang@samsung.com>2015-09-02 16:55:08 +0900
commit10e7e30f134e3411546eacde90645e921f9f7c70 (patch)
tree9ba77340916a54be009fe2b8e197660ba9bd0e12
parent98ef667ccfd04fa2d3147c7ff7b66e4519afa195 (diff)
downloadqemu-10e7e30f134e3411546eacde90645e921f9f7c70.tar.gz
qemu-10e7e30f134e3411546eacde90645e921f9f7c70.tar.bz2
qemu-10e7e30f134e3411546eacde90645e921f9f7c70.zip
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 <giwoong.kim@samsung.com>
-rw-r--r--tizen/src/display/maru_sdl.c6
-rw-r--r--tizen/src/display/maru_shm.c6
-rw-r--r--tizen/src/ui/displaybase.cpp89
-rw-r--r--tizen/src/ui/displaybase.h28
-rw-r--r--tizen/src/ui/menu/contextmenu.cpp22
-rw-r--r--tizen/src/ui/qt5_supplement.cpp39
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.";
}
}