diff --git a/frameworks/kits/js/common/auxiliary_picture_napi.cpp b/frameworks/kits/js/common/auxiliary_picture_napi.cpp index 216d5b13aad8e182c667aaa4efa4d0645e9bc803..f572e952b0981a7cfced67e5d3d04be3d86429cb 100644 --- a/frameworks/kits/js/common/auxiliary_picture_napi.cpp +++ b/frameworks/kits/js/common/auxiliary_picture_napi.cpp @@ -83,8 +83,6 @@ struct NapiValues { std::unique_ptr context; }; -napi_ref AuxiliaryPictureNapi::fragmentpropertyKeyRef_ = nullptr; - struct AuxiliaryPictureEnum { std::string name; int32_t numVal; @@ -110,13 +108,10 @@ AuxiliaryPictureNapi::~AuxiliaryPictureNapi() } static napi_value CreateEnumTypeObject(napi_env env, napi_valuetype type, - napi_ref* ref, std::vector AuxiliaryPictureEnumMap) + std::vector AuxiliaryPictureEnumMap) { napi_value result = nullptr; - napi_status status; - int32_t refCount = 1; - std::string propName; - status = napi_create_object(env, &result); + napi_status status = napi_create_object(env, &result); if (status == napi_ok) { for (auto imgEnum : AuxiliaryPictureEnumMap) { napi_value enumNapiValue = nullptr; @@ -136,13 +131,7 @@ static napi_value CreateEnumTypeObject(napi_env env, napi_valuetype type, break; } } - - if (status == napi_ok) { - status = napi_create_reference(env, result, refCount, ref); - if (status == napi_ok) { - return result; - } - } + return result; } IMAGE_LOGE("CreateEnumTypeObject is Failed!"); napi_get_undefined(env, &result); @@ -163,8 +152,7 @@ napi_value AuxiliaryPictureNapi::Init(napi_env env, napi_value exports) }; napi_property_descriptor static_prop[] = { DECLARE_NAPI_STATIC_FUNCTION("createAuxiliaryPicture", CreateAuxiliaryPicture), - DECLARE_NAPI_PROPERTY("FragmentMapPropertyKey", CreateEnumTypeObject(env, napi_string, - &fragmentpropertyKeyRef_, fragmentPropertyKeyMap)), + DECLARE_NAPI_PROPERTY("FragmentMapPropertyKey", CreateEnumTypeObject(env, napi_string, fragmentPropertyKeyMap)), }; napi_value constructor = nullptr; diff --git a/frameworks/kits/js/common/image_packer_napi.cpp b/frameworks/kits/js/common/image_packer_napi.cpp index 51096d2b589033789f3e1c8d18938550fd0119a3..63ef67e55302198c1eb70251b878f3f84a297ba3 100644 --- a/frameworks/kits/js/common/image_packer_napi.cpp +++ b/frameworks/kits/js/common/image_packer_napi.cpp @@ -52,7 +52,6 @@ namespace Media { static const std::string CLASS_NAME_IMAGEPACKER = "ImagePacker"; thread_local std::shared_ptr ImagePackerNapi::sImgPck_ = nullptr; thread_local napi_ref ImagePackerNapi::sConstructor_ = nullptr; -napi_ref ImagePackerNapi::packingDynamicRangeRef_ = nullptr; struct ImageEnum { std::string name; int32_t numVal; @@ -416,13 +415,10 @@ STATIC_COMPLETE_FUNC(Packing) } static napi_value CreateEnumTypeObject(napi_env env, - napi_valuetype type, napi_ref* ref, std::vector imageEnumMap) + napi_valuetype type, std::vector imageEnumMap) { napi_value result = nullptr; - napi_status status; - int32_t refCount = 1; - std::string propName; - status = napi_create_object(env, &result); + napi_status status = napi_create_object(env, &result); if (status == napi_ok) { for (auto imgEnum : imageEnumMap) { napi_value enumNapiValue = nullptr; @@ -443,12 +439,7 @@ static napi_value CreateEnumTypeObject(napi_env env, } } - if (status == napi_ok) { - status = napi_create_reference(env, result, refCount, ref); - if (status == napi_ok) { - return result; - } - } + return result; } IMAGE_LOGE("CreateEnumTypeObject is Failed!"); napi_get_undefined(env, &result); @@ -471,7 +462,7 @@ napi_value ImagePackerNapi::Init(napi_env env, napi_value exports) DECLARE_NAPI_STATIC_FUNCTION("createImagePacker", CreateImagePacker), DECLARE_NAPI_STATIC_FUNCTION("getImagePackerSupportedFormats", GetImagePackerSupportedFormats), DECLARE_NAPI_PROPERTY("PackingDynamicRange", - CreateEnumTypeObject(env, napi_number, &packingDynamicRangeRef_, sPackingDynamicRangeMap)), + CreateEnumTypeObject(env, napi_number, sPackingDynamicRangeMap)), }; napi_value constructor = nullptr; diff --git a/frameworks/kits/js/common/image_source_napi.cpp b/frameworks/kits/js/common/image_source_napi.cpp index 8f8ba30007e0731f6f6be825312f8eabcc424559..55c9e5d5daa9a16b3d9234e6c0b0b3b5dd8cc866 100644 --- a/frameworks/kits/js/common/image_source_napi.cpp +++ b/frameworks/kits/js/common/image_source_napi.cpp @@ -63,17 +63,6 @@ thread_local int ImageSourceNapi::fileDescriptor_ = -1; thread_local void* ImageSourceNapi::fileBuffer_ = nullptr; thread_local size_t ImageSourceNapi::fileBufferSize_ = 0; -napi_ref ImageSourceNapi::pixelMapFormatRef_ = nullptr; -napi_ref ImageSourceNapi::propertyKeyRef_ = nullptr; -napi_ref ImageSourceNapi::imageFormatRef_ = nullptr; -napi_ref ImageSourceNapi::alphaTypeRef_ = nullptr; -napi_ref ImageSourceNapi::scaleModeRef_ = nullptr; -napi_ref ImageSourceNapi::componentTypeRef_ = nullptr; -napi_ref ImageSourceNapi::decodingDynamicRangeRef_ = nullptr; -napi_ref ImageSourceNapi::decodingResolutionQualityRef_ = nullptr; -napi_ref ImageSourceNapi::decodingAllocatorTypeRef_ = nullptr; -napi_ref ImageSourceNapi::cropAndScaleStrategyRef_ = nullptr; - static std::mutex imageSourceCrossThreadMutex_; using JpegYuvDecodeError = OHOS::ImagePlugin::JpegYuvDecodeError; @@ -601,13 +590,10 @@ static void ImageSourceCallbackWithErrorObj(napi_env env, } static napi_value CreateEnumTypeObject(napi_env env, - napi_valuetype type, napi_ref* ref, std::vector imageEnumMap) + napi_valuetype type, std::vector imageEnumMap) { napi_value result = nullptr; - napi_status status; - int32_t refCount = 1; - std::string propName; - status = napi_create_object(env, &result); + napi_status status = napi_create_object(env, &result); if (status == napi_ok) { for (auto imgEnum : imageEnumMap) { napi_value enumNapiValue = nullptr; @@ -627,13 +613,7 @@ static napi_value CreateEnumTypeObject(napi_env env, break; } } - - if (status == napi_ok) { - status = napi_create_reference(env, result, refCount, ref); - if (status == napi_ok) { - return result; - } - } + return result; } IMAGE_LOGE("CreateEnumTypeObject is Failed!"); napi_get_undefined(env, &result); @@ -926,21 +906,21 @@ napi_value ImageSourceNapi::Init(napi_env env, napi_value exports) DECLARE_NAPI_STATIC_FUNCTION("CreateIncrementalSource", CreateIncrementalSource), DECLARE_NAPI_STATIC_FUNCTION("getImageSourceSupportedFormats", GetImageSourceSupportedFormats), DECLARE_NAPI_PROPERTY("PixelMapFormat", - CreateEnumTypeObject(env, napi_number, &pixelMapFormatRef_, sPixelMapFormatMap)), - DECLARE_NAPI_PROPERTY("PropertyKey", CreateEnumTypeObject(env, napi_string, &propertyKeyRef_, sPropertyKeyMap)), - DECLARE_NAPI_PROPERTY("ImageFormat", CreateEnumTypeObject(env, napi_number, &imageFormatRef_, sImageFormatMap)), - DECLARE_NAPI_PROPERTY("AlphaType", CreateEnumTypeObject(env, napi_number, &alphaTypeRef_, sAlphaTypeMap)), - DECLARE_NAPI_PROPERTY("ScaleMode", CreateEnumTypeObject(env, napi_number, &scaleModeRef_, sScaleModeMap)), + CreateEnumTypeObject(env, napi_number, sPixelMapFormatMap)), + DECLARE_NAPI_PROPERTY("PropertyKey", CreateEnumTypeObject(env, napi_string, sPropertyKeyMap)), + DECLARE_NAPI_PROPERTY("ImageFormat", CreateEnumTypeObject(env, napi_number, sImageFormatMap)), + DECLARE_NAPI_PROPERTY("AlphaType", CreateEnumTypeObject(env, napi_number, sAlphaTypeMap)), + DECLARE_NAPI_PROPERTY("ScaleMode", CreateEnumTypeObject(env, napi_number, sScaleModeMap)), DECLARE_NAPI_PROPERTY("ComponentType", - CreateEnumTypeObject(env, napi_number, &componentTypeRef_, sComponentTypeMap)), + CreateEnumTypeObject(env, napi_number, sComponentTypeMap)), DECLARE_NAPI_PROPERTY("DecodingDynamicRange", - CreateEnumTypeObject(env, napi_number, &decodingDynamicRangeRef_, sDecodingDynamicRangeMap)), + CreateEnumTypeObject(env, napi_number, sDecodingDynamicRangeMap)), DECLARE_NAPI_PROPERTY("ResolutionQuality", - CreateEnumTypeObject(env, napi_number, &decodingResolutionQualityRef_, sDecodingResolutionQualityMap)), + CreateEnumTypeObject(env, napi_number, sDecodingResolutionQualityMap)), DECLARE_NAPI_PROPERTY("AllocatorType", - CreateEnumTypeObject(env, napi_number, &decodingAllocatorTypeRef_, sAllocatorType)), + CreateEnumTypeObject(env, napi_number, sAllocatorType)), DECLARE_NAPI_PROPERTY("CropAndScaleStrategy", - CreateEnumTypeObject(env, napi_number, &cropAndScaleStrategyRef_, sCropAndScaleStrategyMap)), + CreateEnumTypeObject(env, napi_number, sCropAndScaleStrategyMap)), }; struct ImageConstructorInfo info = { diff --git a/frameworks/kits/js/common/picture_napi.cpp b/frameworks/kits/js/common/picture_napi.cpp index 13471f6c632d42c769a5149e1084f480685aa0f7..016b9f38d0a8f7e2aff98027e368070ded932300 100644 --- a/frameworks/kits/js/common/picture_napi.cpp +++ b/frameworks/kits/js/common/picture_napi.cpp @@ -70,10 +70,6 @@ struct PictureAsyncContext { using PictureAsyncContextPtr = std::unique_ptr; -napi_ref PictureNapi::auxiliaryPictureTypeRef_ = nullptr; -napi_ref PictureNapi::metadataTypeRef_ = nullptr; -napi_ref PictureNapi::gifPropertyKeyRef_ = nullptr; - struct PictureEnum { std::string name; int32_t numVal; @@ -110,12 +106,10 @@ struct NapiValues { }; static napi_value CreateEnumTypeObject(napi_env env, - napi_valuetype type, napi_ref* ref, std::vector pictureEnumMap) + napi_valuetype type, std::vector pictureEnumMap) { napi_value result = nullptr; - napi_status status; - std::string propName; - status = napi_create_object(env, &result); + napi_status status = napi_create_object(env, &result); if (status == napi_ok) { for (auto imgEnum : pictureEnumMap) { napi_value enumNapiValue = nullptr; @@ -136,14 +130,7 @@ static napi_value CreateEnumTypeObject(napi_env env, break; } } - - if (status == napi_ok) { - int32_t refCount = 1; - status = napi_create_reference(env, result, refCount, ref); - if (status == napi_ok) { - return result; - } - } + return result; } IMAGE_LOGE("CreateEnumTypeObject is Failed!"); napi_get_undefined(env, &result); @@ -264,12 +251,9 @@ napi_value PictureNapi::Init(napi_env env, napi_value exports) DECLARE_NAPI_STATIC_FUNCTION("createPicture", CreatePicture), DECLARE_NAPI_STATIC_FUNCTION("createPictureFromParcel", CreatePictureFromParcel), DECLARE_NAPI_STATIC_FUNCTION("createPictureByHdrAndSdrPixelMap", CreatePictureByHdrAndSdrPixelMap), - DECLARE_NAPI_PROPERTY("AuxiliaryPictureType", CreateEnumTypeObject(env, napi_number, - &auxiliaryPictureTypeRef_, auxiliaryPictureTypeMap)), - DECLARE_NAPI_PROPERTY("MetadataType", CreateEnumTypeObject(env, napi_number, - &metadataTypeRef_, metadataTypeMap)), - DECLARE_NAPI_PROPERTY("GifPropertyKey", CreateEnumTypeObject(env, napi_string, - &gifPropertyKeyRef_, gifPropertyKeyMap)), + DECLARE_NAPI_PROPERTY("AuxiliaryPictureType", CreateEnumTypeObject(env, napi_number, auxiliaryPictureTypeMap)), + DECLARE_NAPI_PROPERTY("MetadataType", CreateEnumTypeObject(env, napi_number, metadataTypeMap)), + DECLARE_NAPI_PROPERTY("GifPropertyKey", CreateEnumTypeObject(env, napi_string, gifPropertyKeyMap)), }; napi_value constructor = nullptr; diff --git a/interfaces/kits/js/common/include/auxiliary_picture_napi.h b/interfaces/kits/js/common/include/auxiliary_picture_napi.h index a45bb99223778e0a3eeea609400deefd64f870d6..a676973b5f4d3ec18ae22f7f20f65182051ff36b 100644 --- a/interfaces/kits/js/common/include/auxiliary_picture_napi.h +++ b/interfaces/kits/js/common/include/auxiliary_picture_napi.h @@ -60,7 +60,6 @@ private: napi_env env_ = nullptr; bool isRelease = false; uint32_t uniqueId_ = 0; - static napi_ref fragmentpropertyKeyRef_; }; } // namespace Media } // namespace OHOS diff --git a/interfaces/kits/js/common/include/image_packer_napi.h b/interfaces/kits/js/common/include/image_packer_napi.h index 67299b785bf5d56f66da87f460efa7d638ea05a6..8b20b65832ee77d70777d674f9a85947b7174c60 100644 --- a/interfaces/kits/js/common/include/image_packer_napi.h +++ b/interfaces/kits/js/common/include/image_packer_napi.h @@ -62,7 +62,6 @@ private: bool isRelease = false; static thread_local napi_ref sConstructor_; static thread_local std::shared_ptr sImgPck_; - static napi_ref packingDynamicRangeRef_; napi_env env_ = nullptr; std::shared_ptr nativeImgPck = nullptr; }; diff --git a/interfaces/kits/js/common/include/image_source_napi.h b/interfaces/kits/js/common/include/image_source_napi.h index e07d227558fe0a4d449d4c0a4c4605db8a0c431d..2fce4deec8363679091913abefbcbcf1b630ce09 100644 --- a/interfaces/kits/js/common/include/image_source_napi.h +++ b/interfaces/kits/js/common/include/image_source_napi.h @@ -92,16 +92,6 @@ private: static thread_local std::shared_ptr sImgSrc_; static thread_local std::shared_ptr sIncPixelMap_; std::shared_ptr navIncPixelMap_ = nullptr; - static napi_ref pixelMapFormatRef_; - static napi_ref propertyKeyRef_; - static napi_ref imageFormatRef_; - static napi_ref alphaTypeRef_; - static napi_ref scaleModeRef_; - static napi_ref componentTypeRef_; - static napi_ref decodingDynamicRangeRef_; - static napi_ref decodingResolutionQualityRef_; - static napi_ref decodingAllocatorTypeRef_; - static napi_ref cropAndScaleStrategyRef_; napi_env env_ = nullptr; bool isRelease = false; diff --git a/interfaces/kits/js/common/include/picture_napi.h b/interfaces/kits/js/common/include/picture_napi.h index 9d8fc2c248edf74dbc252c84d363a8dd72879ba1..d28ff08f1e030928861206aa1689655e5d77ad4e 100644 --- a/interfaces/kits/js/common/include/picture_napi.h +++ b/interfaces/kits/js/common/include/picture_napi.h @@ -61,9 +61,6 @@ private: std::shared_ptr nativePicture_; bool isRelease = false; uint32_t uniqueId_ = 0; - static napi_ref auxiliaryPictureTypeRef_; - static napi_ref metadataTypeRef_; - static napi_ref gifPropertyKeyRef_; }; } // namespace Media } // namespace OHOS