mirror of
https://github.com/openharmony/ace_ace_engine.git
synced 2026-07-20 15:14:04 -04:00
Px2Fp以及Fp2Px fontScale赋值时pipelineContext判空
Signed-off-by: xiexiyun <xiexiyun@huawei.com> Change-Id: Ib9c0be9cfd4a9559c832f2e37622d12623d33484
This commit is contained in:
@@ -673,7 +673,10 @@ panda::Local<panda::JSValueRef> Px2Fp(panda::EcmaVM* vm, panda::Local<panda::JSV
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
auto pipelineContext = container->GetPipelineContext();
|
||||
double fontScale = pipelineContext->GetFontScale();
|
||||
double fontScale = 1.0;
|
||||
if (pipelineContext) {
|
||||
fontScale = pipelineContext->GetFontScale();
|
||||
}
|
||||
double ratio = density * fontScale;
|
||||
double fpValue = pxValue / ratio;
|
||||
return panda::NumberRef::New(vm, fpValue);
|
||||
|
||||
@@ -627,7 +627,10 @@ JSValue Fp2Px(JSContext* ctx, JSValueConst new_target, int argc, JSValueConst* a
|
||||
return JS_ThrowSyntaxError(ctx, "container is null");
|
||||
}
|
||||
auto pipelineContext = container->GetPipelineContext();
|
||||
double fontScale = pipelineContext->GetFontScale();
|
||||
double fontScale = 1.0;
|
||||
if (pipelineContext) {
|
||||
fontScale = pipelineContext->GetFontScale();
|
||||
}
|
||||
double pxValue = fpValue * density * fontScale;
|
||||
|
||||
int32_t result = GreatOrEqual(pxValue, 0) ? (pxValue + 0.5) : (pxValue - 0.5);
|
||||
@@ -655,7 +658,10 @@ JSValue Px2Fp(JSContext* ctx, JSValueConst new_target, int argc, JSValueConst* a
|
||||
return JS_ThrowSyntaxError(ctx, "container is null");
|
||||
}
|
||||
auto pipelineContext = container->GetPipelineContext();
|
||||
double fontScale = pipelineContext->GetFontScale();
|
||||
double fontScale = 1.0;
|
||||
if (pipelineContext) {
|
||||
fontScale = pipelineContext->GetFontScale();
|
||||
}
|
||||
double ratio = density * fontScale;
|
||||
double fpValue = pxValue / ratio;
|
||||
|
||||
|
||||
@@ -434,7 +434,10 @@ void Fp2Px(const v8::FunctionCallbackInfo<v8::Value>& args)
|
||||
return;
|
||||
}
|
||||
auto pipelineContext = container->GetPipelineContext();
|
||||
double fontScale = pipelineContext->GetFontScale();
|
||||
double fontScale = 1.0;
|
||||
if (pipelineContext) {
|
||||
fontScale = pipelineContext->GetFontScale();
|
||||
}
|
||||
double pxValue = fpValue * density * fontScale;
|
||||
|
||||
int32_t result = GreatOrEqual(pxValue, 0) ? (pxValue + 0.5) : (pxValue - 0.5);
|
||||
@@ -468,7 +471,10 @@ void Px2Fp(const v8::FunctionCallbackInfo<v8::Value>& args)
|
||||
return;
|
||||
}
|
||||
auto pipelineContext = container->GetPipelineContext();
|
||||
double fontScale = pipelineContext->GetFontScale();
|
||||
double fontScale = 1.0;
|
||||
if (pipelineContext) {
|
||||
fontScale = pipelineContext->GetFontScale();
|
||||
}
|
||||
double ratio = density * fontScale;
|
||||
double fpValue = pxValue / ratio;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user