From 0efc97da978b59925d16ca2e20f8c95a4c66a3ca Mon Sep 17 00:00:00 2001 From: linyunxuan Date: Thu, 28 Dec 2023 19:23:06 +0800 Subject: [PATCH 1/2] use qos_manager instead of scene sched for audio scenarios Signed-off-by: linyunxuan --- media/audio/audio_thread_impl.cc | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/media/audio/audio_thread_impl.cc b/media/audio/audio_thread_impl.cc index 414f3ddff4..75f3c05f71 100644 --- a/media/audio/audio_thread_impl.cc +++ b/media/audio/audio_thread_impl.cc @@ -40,13 +40,6 @@ AudioThreadImpl::AudioThreadImpl() #endif worker_task_runner_ = thread_.task_runner(); -#if BUILDFLAG(IS_OHOS) - OHOS::NWeb::ResSchedClientAdapter::ReportKeyThread( - OHOS::NWeb::ResSchedStatusAdapter::THREAD_CREATED, - base::GetCurrentRealPid(), thread_.GetThreadRealId(), - OHOS::NWeb::ResSchedRoleAdapter::IMPORTANT_AUDIO); -#endif - #if !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_ANDROID) // Since we run on the main thread on Mac, we don't need a hang monitor. // https://crbug.com/946968: The hang monitor possibly causes crashes on @@ -66,13 +59,6 @@ void AudioThreadImpl::Stop() { hang_monitor_.reset(); -#if BUILDFLAG(IS_OHOS) - OHOS::NWeb::ResSchedClientAdapter::ReportKeyThread( - OHOS::NWeb::ResSchedStatusAdapter::THREAD_DESTROYED, - base::GetCurrentRealPid(), thread_.GetThreadRealId(), - OHOS::NWeb::ResSchedRoleAdapter::IMPORTANT_AUDIO); -#endif - // Note that on MACOSX, we can still have tasks posted on the |task_runner_|, // since it is the main thread task runner and we do not stop the main thread. // But this is fine because none of those tasks will actually run. -- Gitee From 9d97beafd6677a53ab24305b276cd1e4e8ecf21f Mon Sep 17 00:00:00 2001 From: xuefu Date: Thu, 28 Dec 2023 15:43:40 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=AF=B9=E9=B8=BF=E8=92=99PC=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E5=83=8F=E7=B4=A0=E6=AF=94=E4=BD=9C=E5=9F=BA=E5=87=86?= =?UTF-8?q?=E7=B3=BB=E6=95=B0=E8=B0=83=E6=95=B4=EF=BC=8C=E4=BB=A5=E4=BD=BF?= =?UTF-8?q?=E7=BD=91=E9=A1=B5=E6=98=BE=E7=A4=BA=E6=95=88=E6=9E=9C=E4=B8=8E?= =?UTF-8?q?=E5=90=8C=E5=B0=BA=E5=AF=B8Mac=E8=AE=BE=E5=A4=87=E7=9B=B8?= =?UTF-8?q?=E8=BF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xuefu Change-Id: Ia56e1ba88292838fab2027ce0f0242dc20f2dfce Signed-off-by: xuefu --- ohos_nweb/src/cef_delegate/nweb_delegate.cc | 31 ++++++++++++++++++++- ohos_nweb/src/cef_delegate/nweb_delegate.h | 8 ++++++ ohos_nweb/src/nweb_delegate_interface.h | 4 +++ ohos_nweb/src/nweb_impl.cc | 21 ++++++++++---- 4 files changed, 57 insertions(+), 7 deletions(-) diff --git a/ohos_nweb/src/cef_delegate/nweb_delegate.cc b/ohos_nweb/src/cef_delegate/nweb_delegate.cc index c8f7448259..8f08729417 100644 --- a/ohos_nweb/src/cef_delegate/nweb_delegate.cc +++ b/ohos_nweb/src/cef_delegate/nweb_delegate.cc @@ -425,7 +425,15 @@ InitRichtextIdentifier(); // Created a richtext component SetVirtualPixelRatio(richtextDisplayRatio); } else { +#if BUILDFLAG(IS_OHOS) + if (GetBaseDisplayWidth() > 0) { + SetVirtualPixelRatio(display->GetWidth() / GetBaseDisplayWidth()); + } else { + SetVirtualPixelRatio(display->GetVirtualPixelRatio()); + } +#else SetVirtualPixelRatio(display->GetVirtualPixelRatio()); +#endif } } @@ -754,7 +762,15 @@ void NWebDelegate::NotifyScreenInfoChanged(RotationType rotation, // Created a richtext component display_ratio = richtextDisplayRatio; } else { +#if BUILDFLAG(IS_OHOS) + if (GetBaseDisplayWidth() > 0) { + display_ratio = display->GetWidth() / GetBaseDisplayWidth(); + } else { + display_ratio = display->GetVirtualPixelRatio(); + } +#else display_ratio = display->GetVirtualPixelRatio(); +#endif } if (display_ratio <= 0) { LOG(ERROR) << "Invalid display_ratio, display_ratio = " << display_ratio; @@ -786,6 +802,12 @@ void NWebDelegate::SetVirtualPixelRatio(float ratio) { ui::GestureConfiguration::GetInstance()->set_virtual_pixel_ratio(default_virtual_pixel_ratio_); } +#if BUILDFLAG(IS_OHOS) +float NWebDelegate::GetBaseDisplayWidth() { + return base_display_width_; +} +#endif + std::shared_ptr NWebDelegate::GetPreference() const { return preference_delegate_; } @@ -1255,6 +1277,13 @@ void NWebDelegate::InitializeCef(std::string url, settings.persist_session_cookies = !is_pc_device; #if BUILDFLAG(IS_OHOS) + if (deviceType == OHOS::NWeb::ProductDeviceType::DEVICE_TYPE_2IN1) { + // To achieve a similar web page display effect on HarmonyOS PC devices as + // on Mac devices of the same size, it is necessary to make the web page + // width around approximately 1512 when in full screen. + base_display_width_ = 1512; + } + if (base::CommandLine::ForCurrentProcess()) { base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( ::switches::kOhosDeviceType, FromProductDeviceType(deviceType)); @@ -2451,7 +2480,7 @@ void NWebDelegate::RegisterAccessibilityIdGenerator( std::function accessibilityIdGenerator) const { content::BrowserAccessibilityManagerOHOS::RegisterAccessibilityIdGenerator( accessibilityIdGenerator); -}; +} void NWebDelegate::SetAccessibilityState(cef_state_t accessibilityState) { if (GetBrowser() == nullptr || GetBrowser()->GetHost() == nullptr) { diff --git a/ohos_nweb/src/cef_delegate/nweb_delegate.h b/ohos_nweb/src/cef_delegate/nweb_delegate.h index 52db99b192..57ca880468 100644 --- a/ohos_nweb/src/cef_delegate/nweb_delegate.h +++ b/ohos_nweb/src/cef_delegate/nweb_delegate.h @@ -341,6 +341,10 @@ class NWebDelegate : public NWebDelegateInterface, public virtual CefRefCount { void SetVirtualPixelRatio(float ratio) override; #endif // defined(OHOS_SCREEN_ROTATION) +#if BUILDFLAG(IS_OHOS) + float GetBaseDisplayWidth() override; +#endif + #ifdef OHOS_POST_URL int PostUrl(const std::string& url, std::vector& postData) override; #endif // defined(OHOS_POST_URL) @@ -443,6 +447,10 @@ class NWebDelegate : public NWebDelegateInterface, public virtual CefRefCount { uint32_t nweb_id_; #endif +#if BUILDFLAG(IS_OHOS) + float base_display_width_ = -1.f; +#endif + bool is_enhance_surface_ = false; #if defined(OHOS_INPUT_EVENTS) bool is_onPause_ = false; diff --git a/ohos_nweb/src/nweb_delegate_interface.h b/ohos_nweb/src/nweb_delegate_interface.h index 692daa4113..429cf88ee9 100644 --- a/ohos_nweb/src/nweb_delegate_interface.h +++ b/ohos_nweb/src/nweb_delegate_interface.h @@ -334,6 +334,10 @@ class NWebDelegateInterface virtual void SetVirtualPixelRatio(float ratio) = 0; #endif // defined(OHOS_SCREEN_ROTATION) +#if BUILDFLAG(IS_OHOS) + virtual float GetBaseDisplayWidth() = 0; +#endif + #ifdef OHOS_EX_TOPCONTROLS virtual void UpdateBrowserControlsState(int constraints, int current, diff --git a/ohos_nweb/src/nweb_impl.cc b/ohos_nweb/src/nweb_impl.cc index 6b12069041..ba3add0c98 100644 --- a/ohos_nweb/src/nweb_impl.cc +++ b/ohos_nweb/src/nweb_impl.cc @@ -432,7 +432,16 @@ bool NWebImpl::SetVirtualDeviceRatio() { // Created a richtext component device_pixel_ratio_ = richtextDisplayRatio; } else { +#if BUILDFLAG(IS_OHOS) + if (nweb_delegate_ && nweb_delegate_->GetBaseDisplayWidth() > 0) { + device_pixel_ratio_ = + display->GetWidth() / nweb_delegate_->GetBaseDisplayWidth(); + } else { + device_pixel_ratio_ = display->GetVirtualPixelRatio(); + } +#else device_pixel_ratio_ = display->GetVirtualPixelRatio(); +#endif } if (device_pixel_ratio_ <= 0) { WVLOG_E("invalid ratio."); @@ -464,12 +473,6 @@ bool NWebImpl::InitWebEngine(const NWebCreateInfo& create_info) { } } - if (!SetVirtualDeviceRatio()) { - WVLOG_E("fail to set virtual device ratio"); - delete[] argv; - return false; - } - is_enhance_surface_ = create_info.init_args.is_enhance_surface; void* window = nullptr; if (is_enhance_surface_) { @@ -517,6 +520,12 @@ bool NWebImpl::InitWebEngine(const NWebCreateInfo& create_info) { return false; } + if (!SetVirtualDeviceRatio()) { + WVLOG_E("fail to set virtual device ratio"); + delete[] argv; + return false; + } + std::weak_ptr output_handler_weak(output_handler_); auto render_update_cb = [output_handler_weak](const char* buffer) -> void { if (!output_handler_weak.expired()) { -- Gitee