From 84b2af00fb86a03df12ae7eb20acf01290d30077 Mon Sep 17 00:00:00 2001 From: "M. Liebmann" Date: Tue, 28 Feb 2017 15:02:09 +0100 Subject: [PATCH] osd resolution: Add src/gui/osd_helpers.cpp - Move switch osd resolution from COsdSetup::changeNotify() to COsdHelpers::changeOsdResolution() --- src/gui/Makefile.am | 1 + src/gui/osd_helpers.cpp | 183 ++++++++++++++++++++++++++++++++++++++++ src/gui/osd_helpers.h | 29 +++++++ src/gui/osd_setup.cpp | 8 ++ 4 files changed, 221 insertions(+) create mode 100644 src/gui/osd_helpers.cpp create mode 100644 src/gui/osd_helpers.h diff --git a/src/gui/Makefile.am b/src/gui/Makefile.am index 86a06903f..ce717471c 100644 --- a/src/gui/Makefile.am +++ b/src/gui/Makefile.am @@ -74,6 +74,7 @@ libneutrino_gui_a_SOURCES = \ network_setup.cpp \ nfs.cpp \ opkg_manager.cpp \ + osd_helpers.cpp \ osd_progressbar_setup.cpp \ osd_setup.cpp \ osdlang_setup.cpp \ diff --git a/src/gui/osd_helpers.cpp b/src/gui/osd_helpers.cpp new file mode 100644 index 000000000..c06563f5a --- /dev/null +++ b/src/gui/osd_helpers.cpp @@ -0,0 +1,183 @@ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include + +extern CInfoClock *InfoClock; +extern CTimeOSD *FileTimeOSD; +extern cVideo *videoDecoder; + +COsdHelpers::COsdHelpers() +{ + g_settings_osd_resolution_save = 0; +} + +COsdHelpers::~COsdHelpers() +{ +} + +COsdHelpers* COsdHelpers::getInstance() +{ + static COsdHelpers* osdh = NULL; + if(!osdh) + osdh = new COsdHelpers(); + + return osdh; +} + +#ifdef ENABLE_CHANGE_OSD_RESOLUTION +void COsdHelpers::changeOsdResolution(uint32_t mode, bool automode/*=false*/, bool forceOsdReset/*=false*/) +{ + size_t idx = 0; + bool resetOsd = false; + uint32_t modeNew; + + CFrameBuffer *frameBuffer = CFrameBuffer::getInstance(); + + if (automode) { + if (g_settings.video_Mode == VIDEO_STD_AUTO) + modeNew = OSDMODE_1080; + else + modeNew = g_settings_osd_resolution_save; + } + else { + modeNew = mode; + } + + int videoSystem = getVideoSystem(); + if (!isVideoSystem1080(videoSystem)) + modeNew = OSDMODE_720; + idx = frameBuffer->getIndexOsdResolution(modeNew); + resetOsd = (modeNew != getOsdResolution()) ? true : false; + + if (forceOsdReset) + resetOsd = true; + + if (frameBuffer->fullHdAvailable()) { + if (frameBuffer->osd_resolutions.empty()) + return; + + bool ivVisible = false; + if (g_InfoViewer && g_InfoViewer->is_visible) { + g_InfoViewer->killTitle(); + ivVisible = true; + } + + int switchFB = frameBuffer->setMode(frameBuffer->osd_resolutions[idx].xRes, + frameBuffer->osd_resolutions[idx].yRes, + frameBuffer->osd_resolutions[idx].bpp); + + if (switchFB == 0) { +//printf("\n>>>>>[%s:%d] New res: %dx%dx%d\n \n", __func__, __LINE__, resW, resH, bpp); + g_settings.osd_resolution = modeNew; + if (InfoClock) + InfoClock->enableInfoClock(false); + frameBuffer->Clear(); + if (resetOsd) { + CNeutrinoApp::getInstance()->setScreenSettings(); + CNeutrinoApp::getInstance()->SetupFonts(CNeutrinoFonts::FONTSETUP_NEUTRINO_FONT); + CVolumeHelper::getInstance()->refresh(); + if (InfoClock) + CInfoClock::getInstance()->ClearDisplay(); + if (FileTimeOSD) + FileTimeOSD->Init(); + if (CNeutrinoApp::getInstance()->channelList) + CNeutrinoApp::getInstance()->channelList->ResetModules(); + } + if (InfoClock) + InfoClock->enableInfoClock(true); + } + if (g_InfoViewer) { + g_InfoViewer->ResetModules(); + g_InfoViewer->start(); + } + if (ivVisible) { + CNeutrinoApp::getInstance()->StopSubtitles(); + g_InfoViewer->showTitle(CNeutrinoApp::getInstance()->channelList->getActiveChannel(), true, 0, true); + CNeutrinoApp::getInstance()->StartSubtitles(); + } + } +} + +void COsdHelpers::resetOsdResolution(int newSystem) +{ + int videoSystem = getVideoSystem(); + if ((isVideoSystem1080(videoSystem)) && (!isVideoSystem1080(newSystem))) { + CFrameBuffer::getInstance()->setMode(1280, 720, 32); + } +} +#else +void COsdHelpers::changeOsdResolution(uint32_t, bool, bool) +{ +} + +void COsdHelpers::resetOsdResolution(int) +{ +} +#endif + + +int COsdHelpers::isVideoSystem1080(int res) +{ + if ((res == VIDEO_STD_1080I60) || + (res == VIDEO_STD_1080I50) || + (res == VIDEO_STD_1080P30) || + (res == VIDEO_STD_1080P24) || + (res == VIDEO_STD_1080P25)) + return true; + +#ifdef BOXMODEL_CS_HD2 + if ((res == VIDEO_STD_1080P50) || + (res == VIDEO_STD_1080P60) || + (res == VIDEO_STD_1080P2397) || + (res == VIDEO_STD_1080P2997)) + return true; +#endif + +#if 0 + /* for testing only */ + if (res == VIDEO_STD_720P50) + return true; +#endif + + return false; +} + +#ifdef ENABLE_CHANGE_OSD_RESOLUTION +int COsdHelpers::getVideoSystem() +{ + return videoDecoder->GetVideoSystem(); +} +#else +int COsdHelpers::getVideoSystem() +{ + return g_settings.video_Mode; +} +#endif + +uint32_t COsdHelpers::getOsdResolution() +{ + CFrameBuffer *frameBuffer = CFrameBuffer::getInstance(); + if (frameBuffer->osd_resolutions.size() == 1) + return 0; + + uint32_t yRes = frameBuffer->getScreenHeight(true); + for (size_t i = 0; i < frameBuffer->osd_resolutions.size(); i++) { + if (frameBuffer->osd_resolutions[i].yRes == yRes) + return frameBuffer->osd_resolutions[i].mode; + } + return 0; +} diff --git a/src/gui/osd_helpers.h b/src/gui/osd_helpers.h new file mode 100644 index 000000000..d2c735e50 --- /dev/null +++ b/src/gui/osd_helpers.h @@ -0,0 +1,29 @@ + +#ifndef __osd_helpers__ +#define __osd_helpers__ + +enum { + OSDMODE_720 = 0, + OSDMODE_1080 = 1 +}; + +class COsdHelpers +{ + private: + + public: + COsdHelpers(); + ~COsdHelpers(); + static COsdHelpers* getInstance(); + + int g_settings_osd_resolution_save; + + void changeOsdResolution(uint32_t mode, bool automode=false, bool forceOsdReset=false); + void resetOsdResolution(int newSystem); + int isVideoSystem1080(int res); + int getVideoSystem(); + uint32_t getOsdResolution(); +}; + + +#endif //__osd_helpers__ diff --git a/src/gui/osd_setup.cpp b/src/gui/osd_setup.cpp index 4e5128c67..ad4b6b51e 100644 --- a/src/gui/osd_setup.cpp +++ b/src/gui/osd_setup.cpp @@ -39,6 +39,7 @@ #include #include "osd_setup.h" +#include "osd_helpers.h" #include "themes.h" #include "screensetup.h" #include "osdlang_setup.h" @@ -1389,6 +1390,12 @@ bool COsdSetup::changeNotify(const neutrino_locale_t OptionName, void * data) #ifdef ENABLE_CHANGE_OSD_RESOLUTION else if (ARE_LOCALES_EQUAL(OptionName, LOCALE_COLORMENU_OSD_RESOLUTION)) { + if (frameBuffer->osd_resolutions.empty()) + return true; + osd_menu->hide(); + uint32_t osd_mode = (uint32_t)*(int*)data; + COsdHelpers::getInstance()->changeOsdResolution(osd_mode, osd_mode); +#if 0 if (frameBuffer->fullHdAvailable()) { if (frameBuffer->osd_resolutions.empty()) return true; @@ -1418,6 +1425,7 @@ bool COsdSetup::changeNotify(const neutrino_locale_t OptionName, void * data) g_InfoViewer->ResetModules(); } } +#endif return true; } #endif