已开启
fix common rate #22
wangdi创建于  6月18日
wangdi成员
6月18日 创建

fix common rate

likedislike
wangdi成员
6月18日 评论:
void ScreenSessionManager::RecoverSecondaryScreenResolution(
    sptr<ScreenSession> mainScreen, sptr<ScreenSession> secondaryScreen)
{
    if (!mainScreen || !secondaryScreen) {
        TLOGNFE(WmsLogTag::DMS, "Screen session is null");
        return;
    }

    std::string secSN = secondaryScreen->GetSerialNumber();
    if (secSN.empty()) {
        TLOGNFW(WmsLogTag::DMS, "Secondary screen serialNumber is empty");
        ApplyCommonRefreshRateAlgorithm(mainScreen, secondaryScreen);
        return;
    }

    auto resolutionMap = ScreenSettingHelper::GetResolutionMode();
    auto it = resolutionMap.find(secSN);
    if (it == resolutionMap.end()) {
        TLOGNFI(WmsLogTag::DMS, "No DB config for secondary screen, apply common rate algorithm");
        ApplyCommonRefreshRateAlgorithm(mainScreen, secondaryScreen);
        return;
    }

    uint32_t mainRate = mainScreen->GetRefreshRate();
    auto& secConfig = it->second;

    TLOGNFI(WmsLogTag::DMS, 
        "Recover secondary screen(%{public}" PRIu64 " %{public}" PRIu64 "): mainRate=%{public}u, secSN=%{public}s",
        secondaryScreen->GetScreenId(), secondaryScreen->GetRSScreenId(), mainRate, secSN.c_str());

    if (secConfig.refreshRate_ != mainRate) {
        TLOGNFI(WmsLogTag::DMS, 
            "Refresh rate mismatch (DB=%{public}u, Main=%{public}u), apply commonRateAlgorithm",
            secConfig.refreshRate_, mainRate);
        ApplyCommonRefreshRateAlgorithm(mainScreen, secondaryScreen);
        return;
    }

    bool has4K = Is4KScreen(mainScreen->GetScreenProperty().GetBounds().rect_.GetWidth(),
                            mainScreen->GetScreenProperty().GetBounds().rect_.GetHeight()) ||
                            Is4KScreen(secConfig.width_, secConfig.height_);
    if (has4K && mainRate > PC_REFRESH_RATE_60_HZ) {
        TLOGNFI(WmsLogTag::DMS, "Has 4K screen, unify refresh rate to 60Hz");
        ApplyCommonRefreshRateAlgorithm(mainScreen, secondaryScreen);
        return;
    }

    TLOGNFI(WmsLogTag::DMS, "No 4K screen, directly recover secondary screen from DB");
    RecoverScreenActiveMode(secondaryScreen->GetRSScreenId());
}
likedislike
wangdi成员
6月18日 评论:
bool ScreenSessionManager::Is4KScreen(const uint32_t& width, const uint32_t& height)
{
    if (width >= FOUR_K_WIDTH || height >= FOUR_K_WIDTH) {
        return true;
    }
    return false;
}
likedislike
wangdi成员
6月18日 评论:
void ScreenSessionManager::RecoverMirrorScreenPropertyForDesktop(ScreenId screenId)
{
    sptr<ScreenSession> screenSession = GetScreenSessionByRsId(screenId);
    if (!screenSession || screenSession->GetScreenProperty().GetScreenType() != ScreenType::REAL ||
        !CheckPhysicalScreenReady(screenSession)) {
        return;
    }
    ScreenCombination combination = screenSession->GetScreenCombination();
    if (combination != ScreenCombination::SCREEN_MIRROR) {
        return;
    }
    sptr<ScreenSession> mainSession = FindMainScreenSession();
    if (mainSession == nullptr) {
        TLOGNFW(WmsLogTag::DMS, "Main screen not found.");
        return;
    }
    screenSession->UpdateMirrorWidth(mainSession->GetScreenProperty().GetMirrorWidth());
    screenSession->UpdateMirrorHeight(mainSession->GetScreenProperty().GetMirrorHeight());
    TLOGI(WmsLogTag::DMS, "GetMirror %{public}u %{public}u.",
        screenSession->GetScreenProperty().GetMirrorWidth(), screenSession->GetScreenProperty().GetMirrorHeight());
    NotifyScreenModeChange();
    return;
}
likedislike
wangdi成员
6月18日 评论:
void ScreenSession::UpdateRotationAfterActiveModeChange(float rotation)
{
    Rotation targetRotation = ConvertIntToRotation(static_cast<int>(rotation));
    property_.UpdateDeviceRotation(targetRotation);
    property_.SetRotation(static_cast<float>(rotation));
    property_.SetPhysicalRotation(rotation);
    property_.SetScreenComponentRotation(rotation);
    TLOGI(WmsLogTag::DMS, "Rotation:%{public}f, orientation:%{public}u", rotation, targetRotation);
}
likedislike