mirror of
https://gitee.com/openharmony/graphic_graphic_2d
synced 2024-11-23 23:20:32 +00:00
!15403 适配PC多屏vsync
Merge pull request !15403 from shegangbin/fix_hdi_screen_init
This commit is contained in:
commit
2a4c30f0d3
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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__);
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user