Description:修复冷启动,不跟随时fontSizeScale不一定为1
Sig: SIG_ApplicationFramework
Feature or Bugfix:Bugfix
Binary Source:No
TDD:(评估不涉及)
XTS:Pass
预测试:评估不涉及
Signed-off-by:guanzengkun <guanzengkun@huawei.com>
This commit is contained in:
guanzengkun 2024-07-30 09:15:25 +08:00
parent b7e12a58f4
commit 7e511473a9
3 changed files with 14 additions and 11 deletions

View File

@ -1217,12 +1217,16 @@ void UIContentImpl::UpdateFontScale(const std::shared_ptr<OHOS::AppExecFwk::Conf
auto followSystem = config->GetItem(OHOS::AAFwk::GlobalConfigurationKey::APP_FONT_SIZE_SCALE);
auto context = NG::PipelineContext::GetContextByContainerId(instanceId_);
CHECK_NULL_VOID(context);
auto isFollowSystem = followSystem == "followSystem";
if (!followSystem.empty()) {
context->SetFollowSystem(followSystem == "followSystem");
context->SetFollowSystem(isFollowSystem);
}
if (!maxAppFontScale.empty()) {
context->SetMaxAppFontScale(std::stof(maxAppFontScale));
}
if (!isFollowSystem) {
context->SetFontScale(1.0f);
}
}
void UIContentImpl::SetConfiguration(const std::shared_ptr<OHOS::AppExecFwk::Configuration>& config)

View File

@ -173,6 +173,14 @@ DimensionUnit Dimension::GetAdaptDimensionUnit(const Dimension& dimension)
double Dimension::ConvertToPxDistribute(std::optional<float> minOptional, std::optional<float> maxOptional) const
{
if (unit_ != DimensionUnit::FP) {
return ConvertToPx();
}
auto pipeline = PipelineBase::GetCurrentContextSafely();
CHECK_NULL_RETURN(pipeline, value_);
if (!pipeline->IsFollowSystem()) {
return value_ * pipeline->GetDipScale();
}
auto minFontScale = minOptional.value_or(0.0f);
auto maxFontScale = maxOptional.value_or(static_cast<float>(INT32_MAX));
if (!maxOptional.has_value()) {
@ -183,9 +191,6 @@ double Dimension::ConvertToPxDistribute(std::optional<float> minOptional, std::o
double Dimension::ConvertToPxByCustomFontScale(float minFontScale, float maxFontScale) const
{
if (unit_ != DimensionUnit::FP) {
return ConvertToPx();
}
auto pipeline = PipelineBase::GetCurrentContextSafely();
CHECK_NULL_RETURN(pipeline, value_);
float fontScale = std::clamp(pipeline->GetFontScale(), minFontScale, maxFontScale);
@ -194,14 +199,8 @@ double Dimension::ConvertToPxByCustomFontScale(float minFontScale, float maxFont
double Dimension::ConvertToPxByAppFontScale(float minFontScale) const
{
if (unit_ != DimensionUnit::FP) {
return ConvertToPx();
}
auto pipeline = PipelineBase::GetCurrentContextSafely();
CHECK_NULL_RETURN(pipeline, value_);
if (!pipeline->IsFollowSystem()) {
return value_ * pipeline->GetDipScale();
}
float maxFontScale = pipeline->GetMaxAppFontScale();
float fontScale = std::clamp(pipeline->GetFontScale(), minFontScale, maxFontScale);
return value_ * pipeline->GetDipScale() * fontScale;

View File

@ -1496,7 +1496,7 @@ private:
WindowSizeChangeReason type_ = WindowSizeChangeReason::UNDEFINED;
std::shared_ptr<Rosen::RSTransaction> rsTransaction_;
uint32_t frameCount_ = 0;
bool followSystem_ = true;
bool followSystem_ = false;
float maxAppFontScale_ = static_cast<float>(INT32_MAX);
float dragNodeGrayscale_ = 0.0f;