From bb757ac686625cacd052d32d79f363c71bbf8651 Mon Sep 17 00:00:00 2001 From: Jose Dapena Paz Date: Wed, 12 Dec 2018 13:20:31 +0100 Subject: [PATCH] fixup! [open][media] Provide additional contents scale :Release Notes: Use wayland provided display side for obtaining the UI resolution. :Detailed Notes: With previous approach, frequently the apps would not get the scale on time, or would be obtained after the display UI was adapted to the resolution override. This new approach just uses the existing webos::WebAppWindow API for retrieving the display width and height. :Testing Performed: Install viewster, and launch it (from test app and from app store), and switch between them and enyo2sampler playing videos. :QA Notes: Test-cases: GT-15269, GT-19638, GT-24241 :Issues Addressed: [PLAT-69164] [chromium 68] Viewster CP app (incorrect video size) [PLAT-70362] [chromium 68] Viewster CP app incorrect video size after all webapps are closed Change-Id: I4a1ef735e917641428bcceff276b8771f9ba4f10 Reviewed-on: http://gpro.lgsvl.com/225117 Reviewed-by: Jose Dapena Tested-by: Jose Dapena Reviewed-by: Lokesh Kumar Goel --- src/core/WebAppBase.cpp | 16 ---------------- src/core/WebAppBase.h | 2 -- src/core/WebAppManager.cpp | 20 -------------------- src/core/WebAppManager.h | 2 -- src/core/WebPageBase.cpp | 10 ---------- src/core/WebPageBase.h | 2 -- src/platform/WebAppWayland.cpp | 7 +++++++ src/platform/webengine/WebPageBlink.cpp | 8 +++++--- src/platform/webengine/WebPageBlink.h | 1 + src/webos/DeviceInfoImpl.cpp | 15 +++++---------- 10 files changed, 18 insertions(+), 65 deletions(-) diff --git a/src/core/WebAppBase.cpp b/src/core/WebAppBase.cpp index 2f873b18..c0c3ca76 100644 --- a/src/core/WebAppBase.cpp +++ b/src/core/WebAppBase.cpp @@ -191,16 +191,6 @@ void WebAppBase::cleanResources() d->m_appDesc.reset(); } -int WebAppBase::screenWidth() -{ - return WebAppManager::instance()->currentUiWidth(); -} - -int WebAppBase::screenHeight() -{ - return WebAppManager::instance()->currentUiHeight(); -} - int WebAppBase::currentUiWidth() { return WebAppManager::instance()->currentUiWidth(); @@ -370,12 +360,6 @@ void WebAppBase::setAppDescription(std::shared_ptr appDe // set appId here from appDesc d->m_appId = QString::fromStdString(appDesc->id()); - - if (appDesc->widthOverride() && appDesc->heightOverride()) { - float scaleX = static_cast(screenWidth()) / appDesc->widthOverride(); - float scaleY = static_cast(screenHeight()) / appDesc->heightOverride(); - m_scaleFactor = (scaleX < scaleY) ? scaleX : scaleY; - } } void WebAppBase::setAppProperties(QString properties) diff --git a/src/core/WebAppBase.h b/src/core/WebAppBase.h index 8f84e705..99b72bbc 100644 --- a/src/core/WebAppBase.h +++ b/src/core/WebAppBase.h @@ -110,8 +110,6 @@ class WebAppBase : public QObject, void setNeedReload(bool status) { m_needReload = status; } bool needReload() { return m_needReload; } - static int screenWidth(); - static int screenHeight(); static int currentUiWidth(); static int currentUiHeight(); diff --git a/src/core/WebAppManager.cpp b/src/core/WebAppManager.cpp index 88f7e770..8088c579 100644 --- a/src/core/WebAppManager.cpp +++ b/src/core/WebAppManager.cpp @@ -121,26 +121,6 @@ void WebAppManager::setUiSize(int width, int height) } } -int WebAppManager::screenWidth() -{ - QString width; - if (m_deviceInfo && m_deviceInfo->getDeviceInfo("ScreenWidth", width)) { - return width.toInt(); - } else { - return currentUiWidth(); - } -} - -int WebAppManager::screenHeight() -{ - QString height; - if (m_deviceInfo && m_deviceInfo->getDeviceInfo("ScreenHeight", height)) { - return height.toInt(); - } else { - return currentUiHeight(); - } -} - int WebAppManager::currentUiWidth() { int width = 0; diff --git a/src/core/WebAppManager.h b/src/core/WebAppManager.h index 06e23dac..c13f183a 100644 --- a/src/core/WebAppManager.h +++ b/src/core/WebAppManager.h @@ -102,8 +102,6 @@ class WebAppManager { void setContainerAppLaunched(bool launched); QString& getContainerAppId(); WebAppBase* getContainerApp(); - int screenWidth(); - int screenHeight(); int currentUiWidth(); int currentUiHeight(); void setUiSize(int width, int height); diff --git a/src/core/WebPageBase.cpp b/src/core/WebPageBase.cpp index fa983f8a..7931564d 100644 --- a/src/core/WebPageBase.cpp +++ b/src/core/WebPageBase.cpp @@ -302,16 +302,6 @@ bool WebPageBase::getDeviceInfo(QString name, QString &value) return WebAppManager::instance()->getDeviceInfo(name, value); } -int WebPageBase::screenWidth() -{ - return WebAppManager::instance()->screenWidth(); -} - -int WebPageBase::screenHeight() -{ - return WebAppManager::instance()->screenHeight(); -} - int WebPageBase::currentUiWidth() { return WebAppManager::instance()->currentUiWidth(); diff --git a/src/core/WebPageBase.h b/src/core/WebPageBase.h index 5442c297..5253e647 100644 --- a/src/core/WebPageBase.h +++ b/src/core/WebPageBase.h @@ -176,8 +176,6 @@ protected Q_SLOTS: void handleLoadFailed(int errorCode); bool getDeviceInfo(QString name, QString& value); bool getSystemLanguage(QString& value); - int screenWidth(); - int screenHeight(); int currentUiWidth(); int currentUiHeight(); WebProcessManager* getWebProcessManager(); diff --git a/src/platform/WebAppWayland.cpp b/src/platform/WebAppWayland.cpp index 9da79134..3a172a81 100644 --- a/src/platform/WebAppWayland.cpp +++ b/src/platform/WebAppWayland.cpp @@ -158,6 +158,13 @@ void WebAppWayland::attach(WebPageBase *page) setKeyMask(webos::WebOSKeyMask::KEY_MASK_EXIT, getAppDescription()->handleExitKey()); + if (getAppDescription()->widthOverride() && getAppDescription()->heightOverride()) { + float scaleX = static_cast(m_appWindow->DisplayWidth()) / getAppDescription()->widthOverride(); + float scaleY = static_cast(m_appWindow->DisplayHeight()) / getAppDescription()->heightOverride(); + m_scaleFactor = (scaleX < scaleY) ? scaleX : scaleY; + static_cast(page)->setAdditionalContentsScale(scaleX, scaleY); + } + doAttach(); static_cast(this->page())->setObserver(this); diff --git a/src/platform/webengine/WebPageBlink.cpp b/src/platform/webengine/WebPageBlink.cpp index f37dbc6c..50e5ea4c 100644 --- a/src/platform/webengine/WebPageBlink.cpp +++ b/src/platform/webengine/WebPageBlink.cpp @@ -768,9 +768,6 @@ void WebPageBlink::setViewportSize() { if (m_appDesc->widthOverride() && m_appDesc->heightOverride()) { d->pageView->SetViewportSize(m_appDesc->widthOverride(), m_appDesc->heightOverride()); - double scale_x = static_cast(screenWidth()) / static_cast(m_appDesc->widthOverride()); - double scale_y = static_cast(screenHeight()) / static_cast(m_appDesc->heightOverride()); - d->pageView->SetAdditionalContentsScale(scale_x, scale_y); } } @@ -994,6 +991,11 @@ void WebPageBlink::setFileAccessBlocked(bool blocked) webos::WebViewBase::SetFileAccessBlocked(blocked); } +void WebPageBlink::setAdditionalContentsScale(float scaleX, float scaleY) +{ + d->pageView->SetAdditionalContentsScale(scaleX, scaleY); +} + void WebPageBlink::updateHardwareResolution() { QString hardwareWidth, hardwareHeight; diff --git a/src/platform/webengine/WebPageBlink.h b/src/platform/webengine/WebPageBlink.h index 4c51ab1e..287861a5 100644 --- a/src/platform/webengine/WebPageBlink.h +++ b/src/platform/webengine/WebPageBlink.h @@ -130,6 +130,7 @@ class WebPageBlink : public WebPageBase, public WebPageBlinkDelegate { void updateBoardType(); void updateMediaCodecCapability(); double devicePixelRatio(); + void setAdditionalContentsScale(float scaleX, float scaleY); void setFontHinting(FontRenderParams hinting); void setSupportDolbyHDRContents(); void updateHardwareResolution(); diff --git a/src/webos/DeviceInfoImpl.cpp b/src/webos/DeviceInfoImpl.cpp index 8301537d..0643f9da 100644 --- a/src/webos/DeviceInfoImpl.cpp +++ b/src/webos/DeviceInfoImpl.cpp @@ -64,14 +64,6 @@ DeviceInfoImpl::DeviceInfoImpl() bool DeviceInfoImpl::getDeviceInfo(QString name, QString &value) { - if (name == "ScreenWidth") { - value = QString::number(m_screenWidth); - return true; - } else if (name == "ScreenHeight") { - value = QString::number(m_screenHeight); - return true; - } - return DeviceInfo::getDeviceInfo(name, value); } @@ -97,8 +89,7 @@ bool DeviceInfoImpl::getInfoFromLunaPrefs(const char* key, std::string& value) void DeviceInfoImpl::initDisplayInfo() { // Display information -------------------------------------------------------- - getDisplayWidth(m_screenWidth); - getDisplayHeight(m_screenHeight); + float m_screenDensity = 1.0f; int hardwareScreenWidth = 0; int hardwareScreenHeight = 0; @@ -112,6 +103,10 @@ void DeviceInfoImpl::initDisplayInfo() getDisplayWidth(hardwareScreenWidth); getDisplayHeight(hardwareScreenHeight); } + + m_screenWidth = (int) (hardwareScreenWidth / m_screenDensity); + m_screenHeight = (int) (hardwareScreenHeight / m_screenDensity); + } void DeviceInfoImpl::initPlatformInfo()