From a16b173e6be4385887be9f7acd0490844e863324 Mon Sep 17 00:00:00 2001 From: yzj688 Date: Wed, 26 Jun 2024 16:15:36 +0800 Subject: [PATCH] =?UTF-8?q?Drawing=20=E5=AE=89=E5=85=A8=E7=BC=96=E7=A0=81?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20Signed-off-by:=20yzj688=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../graphic/drawing/color_filter_napi/js_color_filter.cpp | 2 +- interfaces/kits/napi/graphic/drawing/font_napi/js_font.cpp | 4 ++++ .../napi/graphic/drawing/mask_filter_napi/js_mask_filter.cpp | 2 +- .../napi/graphic/drawing/path_effect_napi/js_path_effect.cpp | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/interfaces/kits/napi/graphic/drawing/color_filter_napi/js_color_filter.cpp b/interfaces/kits/napi/graphic/drawing/color_filter_napi/js_color_filter.cpp index 2f5fb5b4d2..42875ccbc1 100644 --- a/interfaces/kits/napi/graphic/drawing/color_filter_napi/js_color_filter.cpp +++ b/interfaces/kits/napi/graphic/drawing/color_filter_napi/js_color_filter.cpp @@ -119,7 +119,7 @@ napi_value JsColorFilter::CreateBlendModeColorFilter(napi_env env, napi_callback } int32_t jsMode = 0; - GET_INT32_CHECK_GE_ZERO_PARAM(ARGC_ONE, jsMode); + GET_ENUM_PARAM(ARGC_ONE, jsMode, 0, static_cast(BlendMode::LUMINOSITY)); auto color = Color::ColorQuadSetARGB(argb[ARGC_ZERO], argb[ARGC_ONE], argb[ARGC_TWO], argb[ARGC_THREE]); std::shared_ptr colorFilter = ColorFilter::CreateBlendModeColorFilter(color, BlendMode(jsMode)); diff --git a/interfaces/kits/napi/graphic/drawing/font_napi/js_font.cpp b/interfaces/kits/napi/graphic/drawing/font_napi/js_font.cpp index d5d3947495..9929c6fadb 100644 --- a/interfaces/kits/napi/graphic/drawing/font_napi/js_font.cpp +++ b/interfaces/kits/napi/graphic/drawing/font_napi/js_font.cpp @@ -84,6 +84,10 @@ napi_value JsFont::Constructor(napi_env env, napi_callback_info info) std::shared_ptr font = std::make_shared(); font->SetTypeface(JsTypeface::LoadZhCnTypeface()); JsFont *jsFont = new(std::nothrow) JsFont(font); + if (!jsFont) { + ROSEN_LOGE("Failed to create JsFont"); + return nullptr; + } status = napi_wrap(env, jsThis, jsFont, JsFont::Destructor, nullptr, nullptr); diff --git a/interfaces/kits/napi/graphic/drawing/mask_filter_napi/js_mask_filter.cpp b/interfaces/kits/napi/graphic/drawing/mask_filter_napi/js_mask_filter.cpp index 227a4ba45f..9968158057 100644 --- a/interfaces/kits/napi/graphic/drawing/mask_filter_napi/js_mask_filter.cpp +++ b/interfaces/kits/napi/graphic/drawing/mask_filter_napi/js_mask_filter.cpp @@ -103,7 +103,7 @@ napi_value JsMaskFilter::CreateBlurMaskFilter(napi_env env, napi_callback_info i CHECK_PARAM_NUMBER_WITHOUT_OPTIONAL_PARAMS(argv, ARGC_TWO); int32_t blurType = 0; - GET_INT32_CHECK_GE_ZERO_PARAM(ARGC_ZERO, blurType); + GET_ENUM_PARAM(ARGC_ZERO, blurType, 0, static_cast(BlurType::INNER)); double sigma = 0.0; GET_DOUBLE_PARAM(ARGC_ONE, sigma); diff --git a/interfaces/kits/napi/graphic/drawing/path_effect_napi/js_path_effect.cpp b/interfaces/kits/napi/graphic/drawing/path_effect_napi/js_path_effect.cpp index 4c2e7aa112..657ad8a9ba 100644 --- a/interfaces/kits/napi/graphic/drawing/path_effect_napi/js_path_effect.cpp +++ b/interfaces/kits/napi/graphic/drawing/path_effect_napi/js_path_effect.cpp @@ -105,10 +105,10 @@ napi_value JsPathEffect::CreateDashPathEffect(napi_env env, napi_callback_info i uint32_t arrayLength = 0; if ((napi_get_array_length(env, argv[ARGC_ZERO], &arrayLength) != napi_ok)) { - ROSEN_LOGE("JsPathEffect::CreateDashPathEffect count of intervals is not even : %{public}u", arrayLength); return NapiThrowError(env, DrawingErrorCode::ERROR_INVALID_PARAM, "Invalid array length params."); } if (arrayLength % NUMBER_TWO || arrayLength < NUMBER_TWO) { // arrayLength must be an even number greater than 0 + ROSEN_LOGE("JsPathEffect::CreateDashPathEffect count of intervals is not even : %{public}u", arrayLength); return NapiThrowError(env, DrawingErrorCode::ERROR_INVALID_PARAM, "parameter array length verification failed."); }