!15403 适配PC多屏vsync

Merge pull request !15403 from shegangbin/fix_hdi_screen_init
This commit is contained in:
openharmony_ci 2024-10-13 02:36:03 +00:00 committed by Gitee
commit 2a4c30f0d3
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 25 additions and 20 deletions

View File

@ -86,14 +86,7 @@ bool HdiScreen::Init()
return false;
}
ret = device_->SetScreenVsyncEnabled(screenId_, true);
if (ret != GRAPHIC_DISPLAY_SUCCESS) {
HLOGE("SetScreenVsyncEnabled failed, ret is %{public}d", ret);
return false;
}
HLOGI("Init hdiScreen succeed");
return true;
}

View File

@ -19,6 +19,7 @@
#include <cinttypes>
#include "platform/common/rs_log.h"
#include "platform/common/rs_system_properties.h"
#include "rs_trace.h"
#include "string_utils.h"
#include "hisysevent.h"
@ -131,6 +132,9 @@ void RSScreen::PhysicalScreenInit() noexcept
}
hdiScreen_->Init();
if (!RSSystemProperties::IsPcType() && !RSSystemProperties::IsTabletType()) {
hdiScreen_->SetScreenVsyncEnabled(true);
}
if (hdiScreen_->GetScreenSupportedModes(supportedModes_) < 0) {
RS_LOGE("RSScreen %{public}s: RSScreen(id %{public}" PRIu64 ") failed to GetScreenSupportedModes.",
__func__, id_);
@ -366,8 +370,9 @@ void RSScreen::SetPowerStatus(uint32_t powerStatus)
return;
}
if (powerStatus == GraphicDispPowerStatus::GRAPHIC_POWER_STATUS_ON ||
powerStatus == GraphicDispPowerStatus::GRAPHIC_POWER_STATUS_ON_ADVANCED) {
if ((powerStatus == GraphicDispPowerStatus::GRAPHIC_POWER_STATUS_ON ||
powerStatus == GraphicDispPowerStatus::GRAPHIC_POWER_STATUS_ON_ADVANCED) &&
!RSSystemProperties::IsPcType() && !RSSystemProperties::IsTabletType()) {
RS_LOGD("RSScreen %{public}s Enable hardware vsync", __func__);
if (hdiScreen_->SetScreenVsyncEnabled(true) != GRAPHIC_DISPLAY_SUCCESS) {
RS_LOGE("RSScreen %{public}s SetScreenVsyncEnabled failed", __func__);

View File

@ -616,14 +616,6 @@ void RSScreenManager::ProcessScreenConnectedLocked(std::shared_ptr<HdiOutput> &o
screens_[id] = std::make_unique<RSScreen>(id, isVirtual, output, nullptr);
auto vsyncSampler = CreateVSyncSampler();
auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType();
if (renderType != UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) {
RegSetScreenVsyncEnabledCallbackForMainThread(id);
} else {
RegSetScreenVsyncEnabledCallbackForHardwareThread(id);
}
if (screens_[id]->GetCapability().type == GraphicInterfaceType::GRAPHIC_DISP_INTF_MIPI) {
if (!mipiCheckInFirstHotPlugEvent_) {
defaultScreenId_ = id;
@ -633,6 +625,20 @@ void RSScreenManager::ProcessScreenConnectedLocked(std::shared_ptr<HdiOutput> &o
defaultScreenId_ = id;
}
ScreenId vsyncEnabledScreenId = id;
if (RSSystemProperties::IsPcType() || RSSystemProperties::IsTabletType()) {
vsyncEnabledScreenId = defaultScreenId_;
if (defaultScreenId_ == id) {
screens_[id]->SetScreenVsyncEnabled(true);
}
}
auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType();
if (renderType != UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) {
RegSetScreenVsyncEnabledCallbackForMainThread(vsyncEnabledScreenId);
} else {
RegSetScreenVsyncEnabledCallbackForHardwareThread(vsyncEnabledScreenId);
}
RS_LOGI("RSScreenManager %{public}s: A new screen(id %{public}" PRIu64 ") connected.", __func__, id);
connectedIds_.emplace_back(id);
#ifdef RS_SUBSCRIBE_SENSOR_ENABLE
@ -664,9 +670,10 @@ void RSScreenManager::ProcessScreenDisConnectedLocked(std::shared_ptr<HdiOutput>
}
ScreenId vsyncEnabledScreenId = INVALID_SCREEN_ID;
auto it = screens_.end();
if (screens_.size() != 0) {
vsyncEnabledScreenId = (--it)->first;
if (RSSystemProperties::IsPcType() || RSSystemProperties::IsTabletType()) {
vsyncEnabledScreenId = defaultScreenId_;
} else if (screens_.size() != 0) {
vsyncEnabledScreenId = screens_.rbegin()->first;
}
auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType();
if (renderType != UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) {