From: Mateusz Majewski Date: Tue, 25 Mar 2025 10:06:02 +0000 (+0100) Subject: Store Maru display type as an enum and not as a bool X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e53aab2702a06f23e6f525be7204177998167d28;p=sdk%2Femulator%2Fqemu.git Store Maru display type as an enum and not as a bool This will be necessary to introduce a third value. Change-Id: I27d79cf6f647bfcd87418f7eaabc08a56aea35b8 --- diff --git a/hw/vigs/vigs_qt5.cpp b/hw/vigs/vigs_qt5.cpp index e33817a61e..ca8356a1f0 100644 --- a/hw/vigs/vigs_qt5.cpp +++ b/hw/vigs/vigs_qt5.cpp @@ -32,9 +32,10 @@ #include #include #include "config-host.h" +#include "qt5_supplement.h" #include "vigs_qt5.h" -extern bool qt5IsOnscreen; +extern maru_display_type display_type; extern QApplication *qt5App; extern QOpenGLContext *qt5GLContext; @@ -47,7 +48,7 @@ extern void qt5_update_texture(void *dpy_item); bool vigs_qt5_onscreen_enabled(void) { - if (qt5App != NULL && qt5IsOnscreen) { + if (qt5App != NULL && display_type == MARU_DISPLAY_TYPE_ONSCREEN) { return true; } return false; diff --git a/tizen/src/ui/mainwindow.cpp b/tizen/src/ui/mainwindow.cpp index d88f61bffe..ce3e35b365 100644 --- a/tizen/src/ui/mainwindow.cpp +++ b/tizen/src/ui/mainwindow.cpp @@ -48,7 +48,7 @@ void qt5_graphic_hw_update(void); void qemu_system_graceful_shutdown_request(unsigned int sec); } -MainWindow::MainWindow(UiInformation *uiInfo, bool useGL, QWidget *parent) : +MainWindow::MainWindow(UiInformation *uiInfo, maru_display_type display_type, QWidget *parent) : QWidget(parent) { /* initialize */ @@ -105,7 +105,7 @@ MainWindow::MainWindow(UiInformation *uiInfo, bool useGL, QWidget *parent) : /* display */ updateDisplayTransform(); - createDisplay(useGL); + createDisplay(display_type); /* set HW Key shortcut */ keyboardShortcut = new KeyboardShortcut(this); @@ -118,19 +118,23 @@ MainWindow::MainWindow(UiInformation *uiInfo, bool useGL, QWidget *parent) : SLOT(slotContextMenu(const QPoint&))); } -void MainWindow::createDisplay(bool useGL) +void MainWindow::createDisplay(maru_display_type display_type) { qDebug("create a display"); + DisplaySWWidget *widget; - if (useGL) { /* on-screen rendering */ + switch (display_type) { + case MARU_DISPLAY_TYPE_ONSCREEN: this->display = new DisplayGLWidget(this, uiInfo->getMainFormDpyType(), uiInfo->getResolution(), getUiState()->getScaleFactor()); - } else { /* off-screen rendering */ - DisplaySWWidget *widget = new DisplaySWWidget(this, + break; + case MARU_DISPLAY_TYPE_OFFSCREEN: + widget = new DisplaySWWidget(this, uiInfo->getMainFormDpyType(), uiInfo->getResolution(), getUiState()->getScaleFactor()); this->screenWidget = widget; this->display = widget; + break; } } diff --git a/tizen/src/ui/mainwindow.h b/tizen/src/ui/mainwindow.h index 84159c7cae..f66237a184 100644 --- a/tizen/src/ui/mainwindow.h +++ b/tizen/src/ui/mainwindow.h @@ -39,6 +39,7 @@ #include "menu/contextmenu.h" #include "mainview.h" #include "displaybase.h" +#include "qt5_supplement.h" #include "rotaryview.h" #include "uiinformation.h" #include "controller/dockingcontroller.h" @@ -54,7 +55,7 @@ public: bool isMovingMode; explicit MainWindow(UiInformation *uiInfo, - bool useGL, + maru_display_type display_type, QWidget *parent = 0); ~MainWindow(); @@ -103,7 +104,7 @@ protected: QLabel *screenWidget; private: - void createDisplay(bool useGL); + void createDisplay(maru_display_type display_type); RotaryView *createRotary(); UiInformation *uiInfo; diff --git a/tizen/src/ui/qt5.c b/tizen/src/ui/qt5.c index c6023fcef2..6007112785 100644 --- a/tizen/src/ui/qt5.c +++ b/tizen/src/ui/qt5.c @@ -129,10 +129,10 @@ static const DisplayChangeListenerOps dcl_ops = { .dpy_cursor_define = qt5_mouse_define, }; -void maru_early_qt5_display_init(bool isOnscreen) +void maru_early_qt5_display_init(enum maru_display_type display_type) { #ifdef CONFIG_DARWIN - ns_run_in_event_loop_with_int(&qt5_early_prepare, isOnscreen); + ns_run_in_event_loop_with_int(&qt5_early_prepare, display_type); /* set emulator icon */ const int path_len = strlen(get_bin_path()) + @@ -146,13 +146,16 @@ void maru_early_qt5_display_init(bool isOnscreen) set_application_icon(icon_path); g_free(icon_path); #else - qt5_early_prepare(isOnscreen); + qt5_early_prepare(display_type); #endif - if (isOnscreen) { + switch (display_type) { + case MARU_DISPLAY_TYPE_ONSCREEN: LOG_INFO("Display Type: QT5 Onscreen\n"); - } else { + break; + case MARU_DISPLAY_TYPE_OFFSCREEN: LOG_INFO("Display Type: QT5 Offscreen\n"); + break; } } diff --git a/tizen/src/ui/qt5.h b/tizen/src/ui/qt5.h index 226ea3759d..f9dfdbdecb 100644 --- a/tizen/src/ui/qt5.h +++ b/tizen/src/ui/qt5.h @@ -33,8 +33,9 @@ #include "qemu/osdep.h" #include "sysemu/sysemu.h" +#include "qt5_supplement.h" -void maru_early_qt5_display_init(bool isOnscreen); +void maru_early_qt5_display_init(enum maru_display_type); void maru_qt5_display_init(DisplayState *ds, int full_screen); void maru_qt5_display_fini(void); diff --git a/tizen/src/ui/qt5_supplement.cpp b/tizen/src/ui/qt5_supplement.cpp index d546ea8065..113ac3dd07 100644 --- a/tizen/src/ui/qt5_supplement.cpp +++ b/tizen/src/ui/qt5_supplement.cpp @@ -53,7 +53,7 @@ bool is_display_off(void); } //using namespace std; -bool qt5IsOnscreen; +maru_display_type display_type; QApplication *qt5App = NULL; QOpenGLContext *qt5GLContext; bool isForceLegacy; @@ -326,7 +326,7 @@ static void qt5_gui_init(void) /* GUI */ qDebug("start!"); - mainwindow = new MainWindow(uiInfo, qt5IsOnscreen); + mainwindow = new MainWindow(uiInfo, display_type); mainwindow->setCaptureRequestHandler(captureRequestListener, captureRequestHandler); /* position */ @@ -440,13 +440,13 @@ void qt5_set_force_legacy(bool isLegacy) isForceLegacy = isLegacy; } -void qt5_early_prepare(bool isOnscreen) +void qt5_early_prepare(enum maru_display_type _display_type) { - qt5IsOnscreen = isOnscreen; + display_type = _display_type; Q_INIT_RESOURCE(resource); - if (qt5IsOnscreen) { + if (display_type == MARU_DISPLAY_TYPE_ONSCREEN) { QCoreApplication::setAttribute(Qt::AA_UseDesktopOpenGL); QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts); @@ -481,7 +481,7 @@ void qt5_early_prepare(bool isOnscreen) eventFilter = new EventFilter(); qt5App->installNativeEventFilter(eventFilter); #endif - if (qt5IsOnscreen) { + if (display_type == MARU_DISPLAY_TYPE_ONSCREEN) { qt5GLContext = QOpenGLContext::globalShareContext(); qDebug("* Qt global share context: OpenGL %d.%d(Profile:%d)", qt5GLContext->format().majorVersion(), diff --git a/tizen/src/ui/qt5_supplement.h b/tizen/src/ui/qt5_supplement.h index dbdcd06be2..73b82e0360 100644 --- a/tizen/src/ui/qt5_supplement.h +++ b/tizen/src/ui/qt5_supplement.h @@ -34,10 +34,16 @@ #ifdef __cplusplus extern "C" { #endif + +enum maru_display_type { + MARU_DISPLAY_TYPE_ONSCREEN, + MARU_DISPLAY_TYPE_OFFSCREEN, +}; + void qt5_graphic_hw_invalidate(void); void qt5_graphic_hw_update(void); int qt5_graphic_hw_display(void); -void qt5_early_prepare(bool isOnscreen); +void qt5_early_prepare(enum maru_display_type); void qt5_prepare(void); void qt5_destroy(void); diff --git a/vl.c b/vl.c index 91c0f08c2c..3317a1424b 100644 --- a/vl.c +++ b/vl.c @@ -4489,9 +4489,9 @@ int main(int argc, char **argv, char **envp) #ifdef CONFIG_MARU # if defined(CONFIG_QT) if (display_type == DT_MARU_QT_ONSCREEN) { - maru_early_qt5_display_init(true); + maru_early_qt5_display_init(MARU_DISPLAY_TYPE_ONSCREEN); } else if (display_type == DT_MARU_QT_OFFSCREEN) { - maru_early_qt5_display_init(false); + maru_early_qt5_display_init(MARU_DISPLAY_TYPE_OFFSCREEN); } # endif #endif