From c1f057eb7516cc50342a9a231a8003a2b6fb2bef Mon Sep 17 00:00:00 2001 From: Tombaugh Date: Thu, 12 Oct 2023 20:23:05 +0800 Subject: [PATCH] Signed-off-by: Tombaugh Change-Id: If74aa693762a8ce28af22938fc1cfcf755b70b94 --- frameworks/kits/js/common/image_source_napi.cpp | 8 ++++---- .../kits/js/common/include/image_napi_utils.h | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/frameworks/kits/js/common/image_source_napi.cpp b/frameworks/kits/js/common/image_source_napi.cpp index 2cc49edc2..1a7add32c 100644 --- a/frameworks/kits/js/common/image_source_napi.cpp +++ b/frameworks/kits/js/common/image_source_napi.cpp @@ -1039,8 +1039,8 @@ napi_value ImageSourceNapi::CreatePixelMap(napi_env env, napi_callback_info info } ImageNapiUtils::HicheckerReport(); - IMG_CREATE_CREATE_ASYNC_WORK(env, status, "CreatePixelMap", CreatePixelMapExecute, - CreatePixelMapComplete, asyncContext, asyncContext->work); + IMG_CREATE_CREATE_ASYNC_WORK_WITH_QOS(env, status, "CreatePixelMap", CreatePixelMapExecute, + CreatePixelMapComplete, asyncContext, asyncContext->work, napi_qos_user_initiated); IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, HiLog::Error(LABEL, "fail to create async work")); @@ -1737,8 +1737,8 @@ napi_value ImageSourceNapi::CreatePixelMapList(napi_env env, napi_callback_info ImageNapiUtils::HicheckerReport(); napi_status status; - IMG_CREATE_CREATE_ASYNC_WORK(env, status, "CreatePixelMapList", CreatePixelMapListExec, - CreatePixelMapListComplete, asyncContext, asyncContext->work); + IMG_CREATE_CREATE_ASYNC_WORK_WITH_QOS(env, status, "CreatePixelMapList", CreatePixelMapListExec, + CreatePixelMapListComplete, asyncContext, asyncContext->work, napi_qos_user_initiated); IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, HiLog::Error(LABEL, "fail to create async work")); FinishTrace(HITRACE_TAG_ZIMAGE); diff --git a/frameworks/kits/js/common/include/image_napi_utils.h b/frameworks/kits/js/common/include/image_napi_utils.h index 3ae2e1391..26a96f2a5 100644 --- a/frameworks/kits/js/common/include/image_napi_utils.h +++ b/frameworks/kits/js/common/include/image_napi_utils.h @@ -69,6 +69,21 @@ do \ } \ } while (0) +#define IMG_CREATE_CREATE_ASYNC_WORK_WITH_QOS(env, status, workName, exec, complete, aContext, work, qos) \ +do \ +{ \ + napi_value _resource = nullptr; \ + napi_create_string_utf8((env), (workName), NAPI_AUTO_LENGTH, &_resource); \ + (status) = napi_create_async_work(env, nullptr, _resource, (exec), \ + (complete), static_cast((aContext).get()), &(work)); \ + if ((status) == napi_ok) { \ + (status) = napi_queue_async_work_with_qos((env), (work), (qos)); \ + if ((status) == napi_ok) { \ + (aContext).release(); \ + } \ + } \ +} while (0) + #define IMG_ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) #define GET_BUFFER_BY_NAME(root, name, res, len) ImageNapiUtils::GetBufferByName(env, (root), (name), &(res), &(len)) -- Gitee