From 5b8f6bdb87a2c28f013b4fc432fbb4aab9ade52e Mon Sep 17 00:00:00 2001 From: y00656910 Date: Thu, 25 Jan 2024 10:38:43 +0800 Subject: [PATCH] change HiLog::xx->HILOG_xx by IMAGE_LOGx Signed-off-by: y00656910 Change-Id: Ib937137822f0b43a3d18723c26943bac06ea7bfe --- .../innerkitsimpl/codec/src/image_packer.cpp | 69 +-- .../innerkitsimpl/codec/src/image_source.cpp | 294 +++++------ .../common/src/incremental_pixel_map.cpp | 22 +- .../common/src/memory_manager.cpp | 53 +- .../innerkitsimpl/common/src/native_image.cpp | 41 +- .../innerkitsimpl/common/src/pixel_astc.cpp | 69 +-- .../innerkitsimpl/common/src/pixel_map.cpp | 472 +++++++++--------- .../common/src/pixel_map_parcel.cpp | 59 +-- .../converter/include/basic_transformer.h | 15 +- .../converter/src/basic_transformer.cpp | 24 +- .../innerkitsimpl/converter/src/matrix.cpp | 13 +- .../converter/src/pixel_convert.cpp | 21 +- .../innerkitsimpl/converter/src/post_proc.cpp | 86 ++-- .../converter/src/scan_line_filter.cpp | 23 +- .../creator/src/image_creator.cpp | 59 +-- .../egl_image/src/pixel_map_from_surface.cpp | 29 +- .../egl_image/src/render_context.cpp | 32 +- .../innerkitsimpl/pixelconverter/BUILD.gn | 2 + .../include/pixel_map_jni_utils.h | 3 +- .../src/pixel_convert_adapter.cpp | 35 +- .../receiver/src/image_receiver.cpp | 442 ++++++++-------- .../stream/src/buffer_packer_stream.cpp | 21 +- .../stream/src/buffer_source_stream.cpp | 35 +- .../stream/src/file_packer_stream.cpp | 25 +- .../stream/src/file_source_stream.cpp | 81 +-- .../stream/src/incremental_source_stream.cpp | 35 +- .../stream/src/istream_source_stream.cpp | 47 +- .../stream/src/ostream_packer_stream.cpp | 12 +- .../test/unittest/egl_image_test.cpp | 2 - .../test/unittest/exif_maker_note_test.cpp | 3 - .../test/unittest/image_color_space_test.cpp | 30 +- .../test/unittest/image_creator_test.cpp | 1 - .../unittest/image_receiver_manager_test.cpp | 1 - .../test/unittest/image_receiver_test.cpp | 1 - .../image_source_bmp_test.cpp | 2 - .../image_source_gif_ex_test.cpp | 12 +- .../image_source_gif_test.cpp | 20 +- .../image_source_jpeg_test.cpp | 21 +- .../image_source_png_test.cpp | 21 +- .../image_source_raw_test.cpp | 2 - .../image_source_test/image_source_test.cpp | 303 ++++++++++- .../image_source_test/image_source_util.cpp | 32 +- .../image_source_wbmp_test.cpp | 2 - .../image_source_webp_test.cpp | 15 +- .../test/unittest/jpeg_utils_test.cpp | 1 - .../test/unittest/mock_directory_ex_test.cpp | 3 - .../unittest/plugin_texture_encode_test.cpp | 2 - .../png_test/nine_path_listener_test.cpp | 3 - .../test/unittest/post_proc_test.cpp | 1 - .../innerkitsimpl/utils/include/image_log.h | 16 +- .../innerkitsimpl/utils/src/image_utils.cpp | 79 +-- .../kits/js/common/image_creator_napi.cpp | 13 +- frameworks/kits/js/common/image_napi.cpp | 25 +- .../kits/js/common/image_packer_mdk_kits.cpp | 45 +- .../kits/js/common/image_packer_napi.cpp | 123 ++--- .../kits/js/common/image_receiver_napi.cpp | 16 +- .../kits/js/common/image_source_mdk_kits.cpp | 191 +++---- .../kits/js/common/image_source_napi.cpp | 381 +++++++------- .../kits/js/common/include/image_napi_utils.h | 16 +- .../js/common/native_module_ohos_image.cpp | 26 +- frameworks/kits/js/common/pixel_map_napi.cpp | 412 +++++++-------- interfaces/innerkits/BUILD.gn | 2 + interfaces/kits/js/common/BUILD.gn | 9 +- .../native/ndk_test_example/my_pixel_map.cpp | 59 +-- mock/native/src/HiLog.cpp | 5 + .../libs/image/formatagentplugin/BUILD.gn | 2 +- .../src/bmp_format_agent.cpp | 19 +- .../src/gif_format_agent.cpp | 19 +- .../src/heif_format_agent.cpp | 32 +- .../src/jpeg_format_agent.cpp | 19 +- .../formatagentplugin/src/plugin_export.cpp | 28 +- .../src/png_format_agent.cpp | 17 +- .../src/raw_format_agent.cpp | 15 +- .../src/svg_format_agent.cpp | 19 +- .../src/wbmp_format_agent.cpp | 29 +- .../src/webp_format_agent.cpp | 16 +- .../common/libs/image/libbmpplugin/BUILD.gn | 1 + .../image/libbmpplugin/src/bmp_decoder.cpp | 69 +-- .../image/libbmpplugin/src/bmp_stream.cpp | 25 +- .../image/libbmpplugin/src/plugin_export.cpp | 27 +- .../common/libs/image/libextplugin/BUILD.gn | 2 + .../image/libextplugin/include/ext_encoder.h | 2 - .../image/libextplugin/src/ext_decoder.cpp | 172 +++---- .../image/libextplugin/src/ext_encoder.cpp | 21 +- .../image/libextplugin/src/ext_stream.cpp | 19 +- .../image/libextplugin/src/ext_wstream.cpp | 17 +- .../image/libextplugin/src/plugin_export.cpp | 27 +- .../src/texture_encode/astc_codec.cpp | 57 +-- .../src/texture_encode/image_compressor.cpp | 124 ++--- .../image/libgifplugin/include/gif_decoder.h | 2 - .../image/libgifplugin/src/gif_decoder.cpp | 201 ++++---- .../image/libgifplugin/src/plugin_export.cpp | 22 +- .../libheifplugin/include/heif_decoder.h | 2 - .../image/libheifplugin/src/heif_decoder.cpp | 44 +- .../image/libheifplugin/src/plugin_export.cpp | 21 +- .../libjpegplugin/include/icc_profile_info.h | 2 - .../libjpegplugin/include/jpeg_decoder.h | 2 - .../image/libjpegplugin/src/exif_info.cpp | 204 ++++---- .../libjpegplugin/src/exif_maker_note.cpp | 142 +++--- .../libjpegplugin/src/icc_profile_info.cpp | 23 +- .../image/libjpegplugin/src/jpeg_decoder.cpp | 129 ++--- .../image/libjpegplugin/src/jpeg_encoder.cpp | 50 +- .../image/libjpegplugin/src/jpeg_utils.cpp | 48 +- .../image/libjpegplugin/src/plugin_export.cpp | 21 +- .../libpngplugin/src/nine_patch_listener.cpp | 21 +- .../image/libpngplugin/src/plugin_export.cpp | 21 +- .../image/libpngplugin/src/png_decoder.cpp | 242 +++++---- .../image/librawplugin/src/plugin_export.cpp | 21 +- .../image/librawplugin/src/raw_decoder.cpp | 134 ++--- .../image/librawplugin/src/raw_stream.cpp | 32 +- .../image/libsvgplugin/src/plugin_export.cpp | 21 +- .../image/libsvgplugin/src/svg_decoder.cpp | 169 ++++--- .../common/libs/image/libwebpplugin/BUILD.gn | 2 + .../image/libwebpplugin/src/plugin_export.cpp | 27 +- .../image/libwebpplugin/src/webp_decoder.cpp | 87 ++-- .../image/libwebpplugin/src/webp_encoder.cpp | 222 ++++---- .../manager/include/pluginbase/plugin_utils.h | 4 +- plugins/manager/src/common/attr_data.cpp | 95 ++-- plugins/manager/src/common/platform_adp.cpp | 17 +- plugins/manager/src/framework/capability.cpp | 85 ++-- plugins/manager/src/framework/impl_class.cpp | 95 ++-- .../manager/src/framework/impl_class_key.cpp | 18 +- .../manager/src/framework/impl_class_mgr.cpp | 73 +-- plugins/manager/src/framework/json_helper.cpp | 48 +- plugins/manager/src/framework/plugin.cpp | 89 ++-- .../manager/src/framework/plugin_export.cpp | 29 +- plugins/manager/src/framework/plugin_fw.cpp | 14 +- plugins/manager/src/framework/plugin_mgr.cpp | 48 +- plugins/manager/src/plugin_server.cpp | 39 +- .../src/pluginbase/plugin_class_base.cpp | 15 +- .../thirdpartyadp/gstreamer/gst_plugin_fw.cpp | 21 +- .../plugin_example1/cloud_label_detector.cpp | 20 +- .../plugin_example1/label_detector.cpp | 20 +- .../plugin_example1/plugin_export.cpp | 27 +- .../plugin_example2/cloud_label_detector2.cpp | 20 +- .../plugin_example2/label_detector2.cpp | 20 +- .../plugin_example2/plugin_export.cpp | 27 +- .../plugin_example3/cloud_label_detector3.cpp | 20 +- .../plugin_example3/label_detector3.cpp | 20 +- .../plugin_example3/plugin_export.cpp | 27 +- .../unittest/common/plugin_manager_test.cpp | 63 ++- 141 files changed, 4075 insertions(+), 3584 deletions(-) diff --git a/frameworks/innerkitsimpl/codec/src/image_packer.cpp b/frameworks/innerkitsimpl/codec/src/image_packer.cpp index d197596cf..ca5c133dc 100644 --- a/frameworks/innerkitsimpl/codec/src/image_packer.cpp +++ b/frameworks/innerkitsimpl/codec/src/image_packer.cpp @@ -17,11 +17,10 @@ #include "buffer_packer_stream.h" #include "file_packer_stream.h" -#include "hilog/log.h" #include "image/abs_image_encoder.h" +#include "image_log.h" #include "image_trace.h" #include "image_utils.h" -#include "log_tags.h" #include "media_errors.h" #include "ostream_packer_stream.h" #include "plugin_server.h" @@ -29,12 +28,16 @@ #include "include/jpeg_encoder.h" #endif +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "ImagePacker" + namespace OHOS { namespace Media { -using namespace OHOS::HiviewDFX; using namespace ImagePlugin; using namespace MultimediaPlugin; -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "ImagePacker" }; static constexpr uint8_t QUALITY_MAX = 100; const static std::string EXTENDED_ENCODER = "image/extended"; static constexpr size_t SIZE_ZERO = 0; @@ -48,7 +51,7 @@ uint32_t ImagePacker::GetSupportedFormats(std::set &formats) uint32_t ret = pluginServer_.PluginServerGetClassInfo(AbsImageEncoder::SERVICE_DEFAULT, classInfos); if (ret != SUCCESS) { - HiLog::Error(LABEL, "get class info from plugin server failed, ret:%{public}u.", ret); + IMAGE_LOGE("get class info from plugin server failed, ret:%{public}u.", ret); return ret; } for (auto &info : classInfos) { @@ -60,7 +63,7 @@ uint32_t ImagePacker::GetSupportedFormats(std::set &formats) AttrData &attr = iter->second; std::string format; if (attr.GetValue(format) != SUCCESS) { - HiLog::Error(LABEL, "attr data get format failed."); + IMAGE_LOGE("attr data get format failed."); continue; } formats.insert(format); @@ -71,11 +74,11 @@ uint32_t ImagePacker::GetSupportedFormats(std::set &formats) uint32_t ImagePacker::StartPackingImpl(const PackOption &option) { if (packerStream_ == nullptr || packerStream_.get() == nullptr) { - HiLog::Error(LABEL, "make buffer packer stream failed."); + IMAGE_LOGE("make buffer packer stream failed."); return ERR_IMAGE_DATA_ABNORMAL; } if (!GetEncoderPlugin(option)) { - HiLog::Error(LABEL, "StartPackingImpl get encoder plugin failed."); + IMAGE_LOGE("StartPackingImpl get encoder plugin failed."); return ERR_IMAGE_MISMATCHED_FORMAT; } PlEncodeOptions plOpts; @@ -89,18 +92,18 @@ uint32_t ImagePacker::StartPacking(uint8_t *outputData, uint32_t maxSize, const { ImageTrace imageTrace("ImagePacker::StartPacking by outputData"); if (!IsPackOptionValid(option)) { - HiLog::Error(LABEL, "array startPacking option invalid %{public}s, %{public}u.", option.format.c_str(), - option.quality); + IMAGE_LOGE("array startPacking option invalid %{public}s, %{public}u.", option.format.c_str(), + option.quality); return ERR_IMAGE_INVALID_PARAMETER; } if (outputData == nullptr) { - HiLog::Error(LABEL, "output buffer is null."); + IMAGE_LOGE("output buffer is null."); return ERR_IMAGE_INVALID_PARAMETER; } BufferPackerStream *stream = new (std::nothrow) BufferPackerStream(outputData, maxSize); if (stream == nullptr) { - HiLog::Error(LABEL, "make buffer packer stream failed."); + IMAGE_LOGE("make buffer packer stream failed."); return ERR_IMAGE_DATA_ABNORMAL; } FreeOldPackerStream(); @@ -112,13 +115,13 @@ uint32_t ImagePacker::StartPacking(const std::string &filePath, const PackOption { ImageTrace imageTrace("ImagePacker::StartPacking by filePath"); if (!IsPackOptionValid(option)) { - HiLog::Error(LABEL, "filepath startPacking option invalid %{public}s, %{public}u.", option.format.c_str(), - option.quality); + IMAGE_LOGE("filepath startPacking option invalid %{public}s, %{public}u.", option.format.c_str(), + option.quality); return ERR_IMAGE_INVALID_PARAMETER; } FilePackerStream *stream = new (std::nothrow) FilePackerStream(filePath); if (stream == nullptr) { - HiLog::Error(LABEL, "make file packer stream failed."); + IMAGE_LOGE("make file packer stream failed."); return ERR_IMAGE_DATA_ABNORMAL; } FreeOldPackerStream(); @@ -130,13 +133,12 @@ uint32_t ImagePacker::StartPacking(const int &fd, const PackOption &option) { ImageTrace imageTrace("ImagePacker::StartPacking by fd"); if (!IsPackOptionValid(option)) { - HiLog::Error(LABEL, "fd startPacking option invalid %{public}s, %{public}u.", option.format.c_str(), - option.quality); + IMAGE_LOGE("fd startPacking option invalid %{public}s, %{public}u.", option.format.c_str(), option.quality); return ERR_IMAGE_INVALID_PARAMETER; } FilePackerStream *stream = new (std::nothrow) FilePackerStream(fd); if (stream == nullptr) { - HiLog::Error(LABEL, "make file packer stream failed."); + IMAGE_LOGE("make file packer stream failed."); return ERR_IMAGE_DATA_ABNORMAL; } FreeOldPackerStream(); @@ -148,13 +150,13 @@ uint32_t ImagePacker::StartPacking(std::ostream &outputStream, const PackOption { ImageTrace imageTrace("ImagePacker::StartPacking by outputStream"); if (!IsPackOptionValid(option)) { - HiLog::Error(LABEL, "outputStream startPacking option invalid %{public}s, %{public}u.", option.format.c_str(), - option.quality); + IMAGE_LOGE("outputStream startPacking option invalid %{public}s, %{public}u.", option.format.c_str(), + option.quality); return ERR_IMAGE_INVALID_PARAMETER; } OstreamPackerStream *stream = new (std::nothrow) OstreamPackerStream(outputStream); if (stream == nullptr) { - HiLog::Error(LABEL, "make ostream packer stream failed."); + IMAGE_LOGE("make ostream packer stream failed."); return ERR_IMAGE_DATA_ABNORMAL; } FreeOldPackerStream(); @@ -170,8 +172,7 @@ uint32_t ImagePacker::StartPackingAdapter(PackerStream &outputStream, const Pack packerStream_ = std::unique_ptr(&outputStream); if (!IsPackOptionValid(option)) { - HiLog::Error(LABEL, "packer stream option invalid %{public}s, %{public}u.", option.format.c_str(), - option.quality); + IMAGE_LOGE("packer stream option invalid %{public}s, %{public}u.", option.format.c_str(), option.quality); return ERR_IMAGE_INVALID_PARAMETER; } return StartPackingImpl(option); @@ -196,11 +197,11 @@ uint32_t ImagePacker::AddImage(ImageSource &source) } pixelMap_ = source.CreatePixelMap(opts, ret); if (ret != SUCCESS) { - HiLog::Error(LABEL, "image source create pixel map failed."); + IMAGE_LOGE("image source create pixel map failed."); return ret; } if (pixelMap_ == nullptr || pixelMap_.get() == nullptr) { - HiLog::Error(LABEL, "create the pixel map unique_ptr fail."); + IMAGE_LOGE("create the pixel map unique_ptr fail."); return ERR_IMAGE_MALLOC_ABNORMAL; } return AddImage(*pixelMap_.get()); @@ -216,11 +217,11 @@ uint32_t ImagePacker::AddImage(ImageSource &source, uint32_t index) } pixelMap_ = source.CreatePixelMap(index, opts, ret); if (ret != SUCCESS) { - HiLog::Error(LABEL, "image source create pixel map failed."); + IMAGE_LOGE("image source create pixel map failed."); return ret; } if (pixelMap_ == nullptr || pixelMap_.get() == nullptr) { - HiLog::Error(LABEL, "create the pixel map unique_ptr fail."); + IMAGE_LOGE("create the pixel map unique_ptr fail."); return ERR_IMAGE_MALLOC_ABNORMAL; } return AddImage(*pixelMap_.get()); @@ -232,7 +233,7 @@ uint32_t ImagePacker::FinalizePacking() return DoEncodingFunc([](ImagePlugin::AbsImageEncoder* encoder) { auto res = encoder->FinalizeEncode(); if (res != SUCCESS) { - HiLog::Error(LABEL, "FinalizePacking failed %{public}d.", res); + IMAGE_LOGE("FinalizePacking failed %{public}d.", res); } return res; }, false); @@ -258,18 +259,18 @@ static ImagePlugin::AbsImageEncoder* GetEncoder(PluginServer &pluginServer, std: bool ImagePacker::GetEncoderPlugin(const PackOption &option) { encoders_.clear(); - HiLog::Debug(LABEL, "GetEncoderPlugin current encoder plugin size %{public}zu.", encoders_.size()); + IMAGE_LOGD("GetEncoderPlugin current encoder plugin size %{public}zu.", encoders_.size()); auto encoder = GetEncoder(pluginServer_, EXTENDED_ENCODER); if (encoder != nullptr) { encoders_.emplace_back(std::unique_ptr(encoder)); } else { - HiLog::Error(LABEL, "GetEncoderPlugin get ext_encoder plugin failed."); + IMAGE_LOGE("GetEncoderPlugin get ext_encoder plugin failed."); } encoder = GetEncoder(pluginServer_, option.format); if (encoder != nullptr) { encoders_.emplace_back(std::unique_ptr(encoder)); } else { - HiLog::Debug(LABEL, "GetEncoderPlugin get %{public}s plugin failed, use ext_encoder plugin", + IMAGE_LOGD("GetEncoderPlugin get %{public}s plugin failed, use ext_encoder plugin", option.format.c_str()); } return encoders_.size() != SIZE_ZERO; @@ -297,7 +298,7 @@ bool ImagePacker::IsPackOptionValid(const PackOption &option) uint32_t ImagePacker::DoEncodingFunc(std::function func, bool forAll) { if (encoders_.size() == SIZE_ZERO) { - HiLog::Error(LABEL, "DoEncodingFunc encoders is empty."); + IMAGE_LOGE("DoEncodingFunc encoders is empty."); return ERR_IMAGE_DECODE_ABNORMAL; } std::vector rets; @@ -305,7 +306,7 @@ uint32_t ImagePacker::DoEncodingFunc(std::function PIXEL_FORMAT_MAP = { { PixelFormat::UNKNOWN, PlPixelFormat::UNKNOWN }, { PixelFormat::ARGB_8888, PlPixelFormat::ARGB_8888 }, { PixelFormat::ALPHA_8, PlPixelFormat::ALPHA_8 }, { PixelFormat::RGB_565, PlPixelFormat::RGB_565 }, @@ -136,14 +140,14 @@ ImageSource::FormatAgentMap ImageSource::formatAgentMap_ = InitClass(); uint32_t ImageSource::GetSupportedFormats(set &formats) { - HiLog::Debug(LABEL, "[ImageSource]get supported image type."); + IMAGE_LOGD("[ImageSource]get supported image type."); formats.clear(); vector classInfos; uint32_t ret = pluginServer_.PluginServerGetClassInfo(AbsImageDecoder::SERVICE_DEFAULT, classInfos); if (ret != SUCCESS) { - HiLog::Error(LABEL, "[ImageSource]get class info from plugin server failed, ret:%{public}u.", ret); + IMAGE_LOGE("[ImageSource]get class info from plugin server failed, ret:%{public}u.", ret); return ret; } @@ -157,7 +161,7 @@ uint32_t ImageSource::GetSupportedFormats(set &formats) AttrData &attr = iter->second; const string *format = nullptr; if (attr.GetValue(format) != SUCCESS) { - HiLog::Error(LABEL, "[ImageSource]attr data get format failed."); + IMAGE_LOGE("[ImageSource]attr data get format failed."); continue; } @@ -175,7 +179,7 @@ unique_ptr ImageSource::DoImageSourceCreate( const SourceOptions &opts, uint32_t &errorCode, const string traceName) { ImageTrace imageTrace(traceName); - HiLog::Debug(LABEL, "[ImageSource]DoImageSourceCreate IN."); + IMAGE_LOGD("[ImageSource]DoImageSourceCreate IN."); errorCode = ERR_IMAGE_SOURCE_DATA; auto streamPtr = stream(); if (streamPtr == nullptr) { @@ -184,7 +188,7 @@ unique_ptr ImageSource::DoImageSourceCreate( auto sourcePtr = new (std::nothrow) ImageSource(std::move(streamPtr), opts); if (sourcePtr == nullptr) { - HiLog::Error(LABEL, "[ImageSource]failed to create ImageSource."); + IMAGE_LOGE("[ImageSource]failed to create ImageSource."); return nullptr; } auto imageSource = unique_ptr(sourcePtr); @@ -200,11 +204,11 @@ unique_ptr ImageSource::DoImageSourceCreate( unique_ptr ImageSource::CreateImageSource(unique_ptr is, const SourceOptions &opts, uint32_t &errorCode) { - HiLog::Debug(LABEL, "[ImageSource]create Imagesource with stream."); + IMAGE_LOGD("[ImageSource]create Imagesource with stream."); return DoImageSourceCreate([&is]() { auto stream = IstreamSourceStream::CreateSourceStream(move(is)); if (stream == nullptr) { - HiLog::Error(LABEL, "[ImageSource]failed to create istream source stream."); + IMAGE_LOGE("[ImageSource]failed to create istream source stream."); } return stream; }, opts, errorCode, "CreateImageSource by istream"); @@ -213,10 +217,10 @@ unique_ptr ImageSource::CreateImageSource(unique_ptr is, unique_ptr ImageSource::CreateImageSource(const uint8_t *data, uint32_t size, const SourceOptions &opts, uint32_t &errorCode) { - HiLog::Debug(LABEL, "[ImageSource]create Imagesource with buffer."); + IMAGE_LOGD("[ImageSource]create Imagesource with buffer."); if (data == nullptr || size == 0) { - HiLog::Error(LABEL, "[ImageSource]parameter error."); + IMAGE_LOGE("[ImageSource]parameter error."); errorCode = ERR_MEDIA_INVALID_PARAM; return nullptr; } @@ -226,7 +230,7 @@ unique_ptr ImageSource::CreateImageSource(const uint8_t *data, uint streamPtr = BufferSourceStream::CreateSourceStream(data, size); } if (streamPtr == nullptr) { - HiLog::Error(LABEL, "[ImageSource]failed to create buffer source stream."); + IMAGE_LOGE("[ImageSource]failed to create buffer source stream."); } return streamPtr; }, opts, errorCode, "CreateImageSource by data"); @@ -235,9 +239,9 @@ unique_ptr ImageSource::CreateImageSource(const uint8_t *data, uint unique_ptr ImageSource::CreateImageSource(const std::string &pathName, const SourceOptions &opts, uint32_t &errorCode) { - HiLog::Debug(LABEL, "[ImageSource]create Imagesource with pathName."); + IMAGE_LOGD("[ImageSource]create Imagesource with pathName."); if (pathName.size() == SIZE_ZERO) { - HiLog::Error(LABEL, "[ImageSource]parameter error."); + IMAGE_LOGE("[ImageSource]parameter error."); return nullptr; } return DoImageSourceCreate([&pathName]() { @@ -246,7 +250,7 @@ unique_ptr ImageSource::CreateImageSource(const std::string &pathNa streamPtr = FileSourceStream::CreateSourceStream(pathName); } if (streamPtr == nullptr) { - HiLog::Error(LABEL, "[ImageSource]failed to create file path source stream. pathName=%{public}s", + IMAGE_LOGE("[ImageSource]failed to create file path source stream. pathName=%{public}s", pathName.c_str()); } return streamPtr; @@ -256,11 +260,11 @@ unique_ptr ImageSource::CreateImageSource(const std::string &pathNa unique_ptr ImageSource::CreateImageSource(const int fd, const SourceOptions &opts, uint32_t &errorCode) { - HiLog::Debug(LABEL, "[ImageSource]create Imagesource with fd."); + IMAGE_LOGD("[ImageSource]create Imagesource with fd."); return DoImageSourceCreate([&fd]() { auto streamPtr = FileSourceStream::CreateSourceStream(fd); if (streamPtr == nullptr) { - HiLog::Error(LABEL, "[ImageSource]failed to create file fd source stream."); + IMAGE_LOGE("[ImageSource]failed to create file fd source stream."); } return streamPtr; }, opts, errorCode, "CreateImageSource by fd"); @@ -269,11 +273,11 @@ unique_ptr ImageSource::CreateImageSource(const int fd, const Sourc unique_ptr ImageSource::CreateImageSource(const int fd, int32_t offset, int32_t length, const SourceOptions &opts, uint32_t &errorCode) { - HiLog::Debug(LABEL, "[ImageSource]create Imagesource with fd offset and length."); + IMAGE_LOGD("[ImageSource]create Imagesource with fd offset and length."); return DoImageSourceCreate([&fd, offset, length]() { auto streamPtr = FileSourceStream::CreateSourceStream(fd, offset, length); if (streamPtr == nullptr) { - HiLog::Error(LABEL, "[ImageSource]failed to create file fd source stream."); + IMAGE_LOGE("[ImageSource]failed to create file fd source stream."); } return streamPtr; }, opts, errorCode, "CreateImageSource by fd offset and length"); @@ -282,11 +286,11 @@ unique_ptr ImageSource::CreateImageSource(const int fd, int32_t off unique_ptr ImageSource::CreateIncrementalImageSource(const IncrementalSourceOptions &opts, uint32_t &errorCode) { - HiLog::Debug(LABEL, "[ImageSource]create incremental ImageSource."); + IMAGE_LOGD("[ImageSource]create incremental ImageSource."); auto sourcePtr = DoImageSourceCreate([&opts]() { auto streamPtr = IncrementalSourceStream::CreateSourceStream(opts.incrementalMode); if (streamPtr == nullptr) { - HiLog::Error(LABEL, "[ImageSource]failed to create incremental source stream."); + IMAGE_LOGE("[ImageSource]failed to create incremental source stream."); } return streamPtr; }, opts.sourceOptions, errorCode, "CreateImageSource by fd"); @@ -310,7 +314,7 @@ void ImageSource::Reset() unique_ptr ImageSource::CreatePixelMapEx(uint32_t index, const DecodeOptions &opts, uint32_t &errorCode) { - HiLog::Info(LABEL, "[ImageSource]CreatePixelMapEx imageId_ is %{public}lu, desiredPixelFormat: %{public}d," + IMAGE_LOGI("[ImageSource]CreatePixelMapEx imageId_ is %{public}lu, desiredPixelFormat: %{public}d," "desiredSize: (%{public}d, %{public}d)", static_cast(imageId_), opts.desiredPixelFormat, opts.desiredSize.width, opts.desiredSize.height); @@ -456,7 +460,7 @@ bool IsWidthAligned(const int32_t &width) bool IsSupportDma(const DecodeOptions &opts, const ImageInfo &info, bool hasDesiredSizeOptions) { #if defined(_WIN32) || defined(_APPLE) || defined(A_PLATFORM) || defined(IOS_PLATFORM) - HiLog::Error(LABEL, "Unsupport dma mem alloc"); + IMAGE_LOGE("Unsupport dma mem alloc"); return false; #else // used for test surfacebuffer @@ -481,7 +485,7 @@ DecodeContext InitDecodeContext(const DecodeOptions &opts, const ImageInfo &info context.allocatorType = opts.allocatorType; } else { if (preference == MemoryUsagePreference::DEFAULT && IsSupportDma(opts, info, hasDesiredSizeOptions)) { - HiLog::Debug(LABEL, "[ImageSource] allocatorType is DMA_ALLOC"); + IMAGE_LOGD("[ImageSource] allocatorType is DMA_ALLOC"); context.allocatorType = AllocatorType::DMA_ALLOC; } else { context.allocatorType = AllocatorType::SHARE_MEM_ALLOC; @@ -505,7 +509,7 @@ unique_ptr ImageSource::CreatePixelMapExtended(uint32_t index, ImageInfo info; errorCode = GetImageInfo(FIRST_FRAME, info); if (errorCode != SUCCESS || !IsSizeVailed(info.size)) { - HiLog::Error(LABEL, "[ImageSource]get image info failed, ret:%{public}u.", errorCode); + IMAGE_LOGE("[ImageSource]get image info failed, ret:%{public}u.", errorCode); errorCode = ERR_IMAGE_DATA_ABNORMAL; return nullptr; } @@ -516,7 +520,7 @@ unique_ptr ImageSource::CreatePixelMapExtended(uint32_t index, ImagePlugin::PlImageInfo plInfo; errorCode = SetDecodeOptions(mainDecoder_, index, opts_, plInfo); if (errorCode != SUCCESS) { - HiLog::Error(LABEL, "[ImageSource]set decode options error (index:%{public}u), ret:%{public}u.", index, + IMAGE_LOGE("[ImageSource]set decode options error (index:%{public}u), ret:%{public}u.", index, errorCode); return nullptr; } @@ -531,7 +535,7 @@ unique_ptr ImageSource::CreatePixelMapExtended(uint32_t index, ninePatchInfo_.patchSize = context.ninePatchContext.patchSize; guard.unlock(); if (errorCode != SUCCESS) { - HiLog::Error(LABEL, "[ImageSource]decode source fail, ret:%{public}u.", errorCode); + IMAGE_LOGE("[ImageSource]decode source fail, ret:%{public}u.", errorCode); FreeContextBuffer(context.freeFunc, context.allocatorType, context.pixelsBuffer); return nullptr; } @@ -544,7 +548,7 @@ unique_ptr ImageSource::CreatePixelMapExtended(uint32_t index, if (!context.ifPartialOutput) { NotifyDecodeEvent(decodeListeners_, DecodeEvent::EVENT_COMPLETE_DECODE, nullptr); } - HiLog::Info(LABEL, "ImageSource::CreatePixelMapExtended success, desiredSize: (%{public}d, %{public}d)," + IMAGE_LOGI("ImageSource::CreatePixelMapExtended success, desiredSize: (%{public}d, %{public}d)," "imageSize: (%{public}d, %{public}d), cost %{public}lu us", opts.desiredSize.width, opts.desiredSize.height, info.size.width, info.size.height, static_cast(GetNowTimeMicroSeconds() - decodeStartTime)); return pixelMap; @@ -594,7 +598,7 @@ unique_ptr ImageSource::CreatePixelMapByInfos(ImagePlugin::PlImageInfo pixelMap->SetPixelsAddr(addrInfos.addr, addrInfos.context, addrInfos.size, addrInfos.type, addrInfos.func); errorCode = UpdatePixelMapInfo(opts_, plInfo, *(pixelMap.get()), opts_.fitDensity, true); if (errorCode != SUCCESS) { - HiLog::Error(LABEL, "[ImageSource]update pixelmap info error ret:%{public}u.", errorCode); + IMAGE_LOGE("[ImageSource]update pixelmap info error ret:%{public}u.", errorCode); return nullptr; } auto saveEditable = pixelMap->IsEditable(); @@ -612,7 +616,7 @@ unique_ptr ImageSource::CreatePixelMapByInfos(ImagePlugin::PlImageInfo GetValidCropRect(opts_.CropRect, plInfo, crop); errorCode = pixelMap->crop(crop); if (errorCode != SUCCESS) { - HiLog::Error(LABEL, "[ImageSource]CropRect pixelmap fail, ret:%{public}u.", errorCode); + IMAGE_LOGE("[ImageSource]CropRect pixelmap fail, ret:%{public}u.", errorCode); return nullptr; } if (!hasDesiredSizeOptions) { @@ -651,7 +655,7 @@ unique_ptr ImageSource::CreatePixelMap(uint32_t index, const DecodeOpt } auto iter = GetValidImageStatus(index, errorCode); if (iter == imageStatusMap_.end()) { - HiLog::Error(LABEL, "[ImageSource]get valid image status fail on create pixel map, ret:%{public}u.", errorCode); + IMAGE_LOGE("[ImageSource]get valid image status fail on create pixel map, ret:%{public}u.", errorCode); return nullptr; } if (ImageSystemProperties::GetSkiaEnabled()) { @@ -663,13 +667,13 @@ unique_ptr ImageSource::CreatePixelMap(uint32_t index, const DecodeOpt // the mainDecoder_ may be borrowed by Incremental decoding, so needs to be checked. if (InitMainDecoder() != SUCCESS) { - HiLog::Error(LABEL, "[ImageSource]image decode plugin is null."); + IMAGE_LOGE("[ImageSource]image decode plugin is null."); errorCode = ERR_IMAGE_PLUGIN_CREATE_FAILED; return nullptr; } unique_ptr pixelMap = make_unique(); if (pixelMap == nullptr || pixelMap.get() == nullptr) { - HiLog::Error(LABEL, "[ImageSource]create the pixel map unique_ptr fail."); + IMAGE_LOGE("[ImageSource]create the pixel map unique_ptr fail."); errorCode = ERR_IMAGE_MALLOC_ABNORMAL; return nullptr; } @@ -677,7 +681,7 @@ unique_ptr ImageSource::CreatePixelMap(uint32_t index, const DecodeOpt ImagePlugin::PlImageInfo plInfo; errorCode = SetDecodeOptions(mainDecoder_, index, opts_, plInfo); if (errorCode != SUCCESS) { - HiLog::Error(LABEL, "[ImageSource]set decode options error (index:%{public}u), ret:%{public}u.", index, + IMAGE_LOGE("[ImageSource]set decode options error (index:%{public}u), ret:%{public}u.", index, errorCode); return nullptr; } @@ -695,7 +699,7 @@ unique_ptr ImageSource::CreatePixelMap(uint32_t index, const DecodeOpt PostProc::ValidCropValue(opts_.CropRect, size); errorCode = UpdatePixelMapInfo(opts_, plInfo, *(pixelMap.get())); if (errorCode != SUCCESS) { - HiLog::Error(LABEL, "[ImageSource]update pixelmap info error ret:%{public}u.", errorCode); + IMAGE_LOGE("[ImageSource]update pixelmap info error ret:%{public}u.", errorCode); return nullptr; } @@ -705,7 +709,7 @@ unique_ptr ImageSource::CreatePixelMap(uint32_t index, const DecodeOpt if (!useSkia) { bool hasNinePatch = mainDecoder_->HasProperty(NINE_PATCH); finalOutputStep = GetFinalOutputStep(opts_, *(pixelMap.get()), hasNinePatch); - HiLog::Debug(LABEL, "[ImageSource]finalOutputStep:%{public}d. opts.allocatorType %{public}d", + IMAGE_LOGD("[ImageSource]finalOutputStep:%{public}d. opts.allocatorType %{public}d", finalOutputStep, opts_.allocatorType); if (finalOutputStep == FinalOutputStep::NO_CHANGE) { @@ -729,7 +733,7 @@ unique_ptr ImageSource::CreatePixelMap(uint32_t index, const DecodeOpt } guard.unlock(); if (errorCode != SUCCESS) { - HiLog::Error(LABEL, "[ImageSource]decode source fail, ret:%{public}u.", errorCode); + IMAGE_LOGE("[ImageSource]decode source fail, ret:%{public}u.", errorCode); if (context.pixelsBuffer.buffer != nullptr) { if (context.freeFunc != nullptr) { context.freeFunc(context.pixelsBuffer.buffer, context.pixelsBuffer.context, @@ -776,7 +780,7 @@ unique_ptr ImageSource::CreateIncrementalPixelMap(uint32_t { IncrementalPixelMap *incPixelMapPtr = new (std::nothrow) IncrementalPixelMap(index, opts, this); if (incPixelMapPtr == nullptr) { - HiLog::Error(LABEL, "[ImageSource]create the incremental pixel map unique_ptr fail."); + IMAGE_LOGE("[ImageSource]create the incremental pixel map unique_ptr fail."); errorCode = ERR_IMAGE_MALLOC_ABNORMAL; return nullptr; } @@ -794,23 +798,23 @@ uint32_t ImageSource::PromoteDecoding(uint32_t index, const DecodeOptions &opts, opts_ = opts; auto imageStatusIter = GetValidImageStatus(index, ret); if (imageStatusIter == imageStatusMap_.end()) { - HiLog::Error(LABEL, "[ImageSource]get valid image status fail on promote decoding, ret:%{public}u.", ret); + IMAGE_LOGE("[ImageSource]get valid image status fail on promote decoding, ret:%{public}u.", ret); return ret; } auto incrementalRecordIter = incDecodingMap_.find(&pixelMap); if (incrementalRecordIter == incDecodingMap_.end()) { ret = AddIncrementalContext(pixelMap, incrementalRecordIter); if (ret != SUCCESS) { - HiLog::Error(LABEL, "[ImageSource]failed to add context on incremental decoding, ret:%{public}u.", ret); + IMAGE_LOGE("[ImageSource]failed to add context on incremental decoding, ret:%{public}u.", ret); return ret; } } if (incrementalRecordIter->second.IncrementalState == ImageDecodingState::BASE_INFO_PARSED) { - HiLog::Debug(LABEL, "[ImageSource]promote decode : set decode options."); + IMAGE_LOGD("[ImageSource]promote decode : set decode options."); ImagePlugin::PlImageInfo plInfo; ret = SetDecodeOptions(incrementalRecordIter->second.decoder, index, opts_, plInfo); if (ret != SUCCESS) { - HiLog::Error(LABEL, "[ImageSource]set decode options error (image index:%{public}u), ret:%{public}u.", + IMAGE_LOGE("[ImageSource]set decode options error (image index:%{public}u), ret:%{public}u.", index, ret); return ret; } @@ -831,7 +835,7 @@ uint32_t ImageSource::PromoteDecoding(uint32_t index, const DecodeOptions &opts, PostProc::ValidCropValue(opts_.CropRect, size); ret = UpdatePixelMapInfo(opts_, plInfo, pixelMap); if (ret != SUCCESS) { - HiLog::Error(LABEL, "[ImageSource]update pixelmap info error (image index:%{public}u), ret:%{public}u.", + IMAGE_LOGE("[ImageSource]update pixelmap info error (image index:%{public}u), ret:%{public}u.", index, ret); return ret; } @@ -863,7 +867,7 @@ uint32_t ImageSource::PromoteDecoding(uint32_t index, const DecodeOptions &opts, state = incrementalRecordIter->second.IncrementalState; decodeProgress = incrementalRecordIter->second.decodingProgress; if (incrementalRecordIter->second.IncrementalState == ImageDecodingState::IMAGE_ERROR) { - HiLog::Error(LABEL, "[ImageSource]invalid imageState %{public}d on incremental decoding.", + IMAGE_LOGE("[ImageSource]invalid imageState %{public}d on incremental decoding.", incrementalRecordIter->second.IncrementalState); return ERR_IMAGE_DECODE_ABNORMAL; } @@ -889,7 +893,7 @@ void ImageSource::DetachIncrementalDecoding(PixelMap &pixelMap) uint32_t ImageSource::UpdateData(const uint8_t *data, uint32_t size, bool isCompleted) { if (sourceStreamPtr_ == nullptr) { - HiLog::Error(LABEL, "[ImageSource]image source update data, source stream is null."); + IMAGE_LOGE("[ImageSource]image source update data, source stream is null."); return ERR_IMAGE_INVALID_PARAMETER; } std::lock_guard guard(decodingMutex_); @@ -912,12 +916,12 @@ uint32_t ImageSource::GetImageInfo(uint32_t index, ImageInfo &imageInfo) auto iter = GetValidImageStatus(index, ret); if (iter == imageStatusMap_.end()) { guard.unlock(); - HiLog::Error(LABEL, "[ImageSource]get valid image status fail on get image info, ret:%{public}u.", ret); + IMAGE_LOGE("[ImageSource]get valid image status fail on get image info, ret:%{public}u.", ret); return ret; } ImageInfo &info = (iter->second).imageInfo; if (info.size.width == 0 || info.size.height == 0) { - HiLog::Error(LABEL, "[ImageSource]get the image size fail on get image info, width:%{public}d," + IMAGE_LOGE("[ImageSource]get the image size fail on get image info, width:%{public}d," "height:%{public}d.", info.size.width, info.size.height); return ERR_IMAGE_DECODE_FAILED; } @@ -933,12 +937,12 @@ uint32_t ImageSource::ModifyImageProperty(uint32_t index, const std::string &key uint32_t ret; auto iter = GetValidImageStatus(0, ret); if (iter == imageStatusMap_.end()) { - HiLog::Error(LABEL, "[ImageSource]get valid image status fail on modify image property, ret:%{public}u.", ret); + IMAGE_LOGE("[ImageSource]get valid image status fail on modify image property, ret:%{public}u.", ret); return ret; } ret = mainDecoder_->ModifyImageProperty(index, key, value, path); if (ret != SUCCESS) { - HiLog::Error(LABEL, "[ImageSource] ModifyImageProperty fail, ret:%{public}u", ret); + IMAGE_LOGE("[ImageSource] ModifyImageProperty fail, ret:%{public}u", ret); return ret; } return SUCCESS; @@ -951,12 +955,12 @@ uint32_t ImageSource::ModifyImageProperty(uint32_t index, const std::string &key uint32_t ret; auto iter = GetValidImageStatus(0, ret); if (iter == imageStatusMap_.end()) { - HiLog::Error(LABEL, "[ImageSource]get valid image status fail on modify image property, ret:%{public}u.", ret); + IMAGE_LOGE("[ImageSource]get valid image status fail on modify image property, ret:%{public}u.", ret); return ret; } ret = mainDecoder_->ModifyImageProperty(index, key, value, fd); if (ret != SUCCESS) { - HiLog::Error(LABEL, "[ImageSource] ModifyImageProperty fail, ret:%{public}u", ret); + IMAGE_LOGE("[ImageSource] ModifyImageProperty fail, ret:%{public}u", ret); return ret; } return SUCCESS; @@ -969,12 +973,12 @@ uint32_t ImageSource::ModifyImageProperty(uint32_t index, const std::string &key uint32_t ret; auto iter = GetValidImageStatus(0, ret); if (iter == imageStatusMap_.end()) { - HiLog::Error(LABEL, "[ImageSource]get valid image status fail on modify image property, ret:%{public}u.", ret); + IMAGE_LOGE("[ImageSource]get valid image status fail on modify image property, ret:%{public}u.", ret); return ret; } ret = mainDecoder_->ModifyImageProperty(index, key, value, data, size); if (ret != SUCCESS) { - HiLog::Error(LABEL, "[ImageSource] ModifyImageProperty fail, ret:%{public}u", ret); + IMAGE_LOGE("[ImageSource] ModifyImageProperty fail, ret:%{public}u", ret); return ret; } return SUCCESS; @@ -986,13 +990,13 @@ uint32_t ImageSource::GetImagePropertyInt(uint32_t index, const std::string &key uint32_t ret; auto iter = GetValidImageStatus(0, ret); if (iter == imageStatusMap_.end()) { - HiLog::Error(LABEL, "[ImageSource]get valid image status fail on get image property, ret:%{public}u.", ret); + IMAGE_LOGE("[ImageSource]get valid image status fail on get image property, ret:%{public}u.", ret); return ret; } ret = mainDecoder_->GetImagePropertyInt(index, key, value); if (ret != SUCCESS) { - HiLog::Debug(LABEL, "[ImageSource] GetImagePropertyInt fail, ret:%{public}u", ret); + IMAGE_LOGD("[ImageSource] GetImagePropertyInt fail, ret:%{public}u", ret); return ret; } return SUCCESS; @@ -1004,12 +1008,12 @@ uint32_t ImageSource::GetImagePropertyString(uint32_t index, const std::string & uint32_t ret; auto iter = GetValidImageStatus(0, ret); if (iter == imageStatusMap_.end()) { - HiLog::Error(LABEL, "[ImageSource]get valid image status fail on get image property, ret:%{public}u.", ret); + IMAGE_LOGE("[ImageSource]get valid image status fail on get image property, ret:%{public}u.", ret); return ret; } ret = mainDecoder_->GetImagePropertyString(index, key, value); if (ret != SUCCESS) { - HiLog::Debug(LABEL, "[ImageSource] GetImagePropertyString fail, ret:%{public}u", ret); + IMAGE_LOGD("[ImageSource] GetImagePropertyString fail, ret:%{public}u", ret); return ret; } return SUCCESS; @@ -1048,7 +1052,7 @@ void ImageSource::UnRegisterListener(PeerListener *listener) void ImageSource::AddDecodeListener(DecodeListener *listener) { if (listener == nullptr) { - HiLog::Error(LABEL, "AddDecodeListener listener null"); + IMAGE_LOGE("AddDecodeListener listener null"); return; } std::lock_guard guard(listenerMutex_); @@ -1058,7 +1062,7 @@ void ImageSource::AddDecodeListener(DecodeListener *listener) void ImageSource::RemoveDecodeListener(DecodeListener *listener) { if (listener == nullptr) { - HiLog::Error(LABEL, "RemoveDecodeListener listener null"); + IMAGE_LOGE("RemoveDecodeListener listener null"); return; } std::lock_guard guard(listenerMutex_); @@ -1070,7 +1074,7 @@ void ImageSource::RemoveDecodeListener(DecodeListener *listener) ImageSource::~ImageSource() { - HiLog::Debug(LABEL, "ImageSource destructor enter"); + IMAGE_LOGD("ImageSource destructor enter"); std::lock_guard guard(listenerMutex_); for (const auto &listener : listeners_) { listener->OnPeerDestory(); @@ -1110,7 +1114,7 @@ ImageSource::FormatAgentMap ImageSource::InitClass() AttrData &attr = iter->second; string format; if (SUCCESS != attr.GetValue(format)) { - HiLog::Error(LABEL, "[ImageSource]attr data get format:[%{public}s] failed.", format.c_str()); + IMAGE_LOGE("[ImageSource]attr data get format:[%{public}s] failed.", format.c_str()); continue; } formats.insert(move(format)); @@ -1139,7 +1143,7 @@ uint32_t ImageSource::CheckEncodedFormat(AbsImageFormatAgent &agent) return res; } if (!agent.CheckFormat(outData.inputStreamBuffer, size)) { - HiLog::Error(LABEL, "[ImageSource]check mismatched format :%{public}s.", agent.GetFormatType().c_str()); + IMAGE_LOGE("[ImageSource]check mismatched format :%{public}s.", agent.GetFormatType().c_str()); return ERR_IMAGE_MISMATCHED_FORMAT; } return SUCCESS; @@ -1148,15 +1152,15 @@ uint32_t ImageSource::CheckEncodedFormat(AbsImageFormatAgent &agent) uint32_t ImageSource::GetData(ImagePlugin::DataStreamBuffer &outData, size_t size) { if (sourceStreamPtr_ == nullptr) { - HiLog::Error(LABEL, "[ImageSource]check image format, source stream is null."); + IMAGE_LOGE("[ImageSource]check image format, source stream is null."); return ERR_IMAGE_INVALID_PARAMETER; } if (!sourceStreamPtr_->Peek(size, outData)) { - HiLog::Error(LABEL, "[ImageSource]stream peek the data fail, desiredSize:%{public}zu", size); + IMAGE_LOGE("[ImageSource]stream peek the data fail, desiredSize:%{public}zu", size); return ERR_IMAGE_SOURCE_DATA; } if (outData.inputStreamBuffer == nullptr || outData.dataSize < size) { - HiLog::Error(LABEL, "[ImageSource]the outData is incomplete."); + IMAGE_LOGE("[ImageSource]the outData is incomplete."); return ERR_IMAGE_SOURCE_DATA_INCOMPLETE; } return SUCCESS; @@ -1167,14 +1171,14 @@ uint32_t ImageSource::CheckFormatHint(const string &formatHint, FormatAgentMap:: uint32_t ret = ERROR; formatIter = formatAgentMap_.find(formatHint); if (formatIter == formatAgentMap_.end()) { - HiLog::Error(LABEL, "[ImageSource]check input format fail."); + IMAGE_LOGE("[ImageSource]check input format fail."); return ret; } AbsImageFormatAgent *agent = formatIter->second; ret = CheckEncodedFormat(*agent); if (ret != SUCCESS) { if (ret == ERR_IMAGE_SOURCE_DATA_INCOMPLETE) { - HiLog::Error(LABEL, "[ImageSource]image source incomplete."); + IMAGE_LOGE("[ImageSource]image source incomplete."); } return ret; } @@ -1188,12 +1192,12 @@ AbsImageDecoder *DoCreateDecoder(std::string codecFormat, for (const auto &capability : capabilities) { std::string x = "undefined"; capability.second.GetValue(x); - HiLog::Debug(LABEL, "[ImageSource] capabilities [%{public}s],[%{public}s]", + IMAGE_LOGD("[ImageSource] capabilities [%{public}s],[%{public}s]", capability.first.c_str(), x.c_str()); } auto decoder = pluginServer.CreateObject(AbsImageDecoder::SERVICE_DEFAULT, capabilities); if (decoder == nullptr) { - HiLog::Error(LABEL, "[ImageSource]failed to create decoder object."); + IMAGE_LOGE("[ImageSource]failed to create decoder object."); errorCode = ERR_IMAGE_PLUGIN_CREATE_FAILED; return nullptr; } @@ -1210,7 +1214,7 @@ uint32_t ImageSource::GetFormatExtended(string &format) } if (sourceStreamPtr_ == nullptr) { - HiLog::Error(LABEL, "[ImageSource]sourceStreamPtr_ is null"); + IMAGE_LOGE("[ImageSource]sourceStreamPtr_ is null"); return ERR_MEDIA_NULL_POINTER; } @@ -1219,13 +1223,13 @@ uint32_t ImageSource::GetFormatExtended(string &format) auto codec = DoCreateDecoder(InnerFormat::IMAGE_EXTENDED_CODEC, pluginServer_, *sourceStreamPtr_, errorCode); if (errorCode != SUCCESS || codec == nullptr) { - HiLog::Error(LABEL, "[ImageSource]No extended decoder."); + IMAGE_LOGE("[ImageSource]No extended decoder."); return errorCode; } const static string EXT_ENCODED_FORMAT_KEY = "EncodedFormat"; auto decoderPtr = unique_ptr(codec); if (decoderPtr == nullptr) { - HiLog::Error(LABEL, "[ImageSource]decoderPtr null"); + IMAGE_LOGE("[ImageSource]decoderPtr null"); return ERR_MEDIA_NULL_POINTER; } ProgDecodeContext context; @@ -1235,12 +1239,12 @@ uint32_t ImageSource::GetFormatExtended(string &format) } errorCode = decoderPtr->GetImagePropertyString(FIRST_FRAME, EXT_ENCODED_FORMAT_KEY, format); if (errorCode != SUCCESS) { - HiLog::Error(LABEL, "[ImageSource]Extended get format failed %{public}d.", errorCode); + IMAGE_LOGE("[ImageSource]Extended get format failed %{public}d.", errorCode); return ERR_IMAGE_DECODE_HEAD_ABNORMAL; } if (!ImageSystemProperties::GetSkiaEnabled()) { - HiLog::Debug(LABEL, "[ImageSource]Extended close SK decode"); + IMAGE_LOGD("[ImageSource]Extended close SK decode"); if (format != "image/gif") { sourceStreamPtr_->Seek(imageType); return ERR_MEDIA_DATA_UNSUPPORT; @@ -1258,10 +1262,10 @@ uint32_t ImageSource::GetEncodedFormat(const string &formatHint, string &format) ret = CheckFormatHint(formatHint, hintIter); if (ret == SUCCESS) { format = hintIter->first; - HiLog::Debug(LABEL, "[ImageSource]check input image format success, format:%{public}s.", format.c_str()); + IMAGE_LOGD("[ImageSource]check input image format success, format:%{public}s.", format.c_str()); return SUCCESS; } else { - HiLog::Error(LABEL, "[ImageSource]checkFormatHint error, type: %{public}d", ret); + IMAGE_LOGE("[ImageSource]checkFormatHint error, type: %{public}d", ret); return ret; } } @@ -1280,18 +1284,18 @@ uint32_t ImageSource::GetEncodedFormat(const string &formatHint, string &format) if (ret == ERR_IMAGE_MISMATCHED_FORMAT) { continue; } else if (ret == SUCCESS) { - HiLog::Info(LABEL, "[ImageSource]GetEncodedFormat success format :%{public}s.", iter->first.c_str()); + IMAGE_LOGI("[ImageSource]GetEncodedFormat success format :%{public}s.", iter->first.c_str()); format = iter->first; return SUCCESS; } else { - HiLog::Error(LABEL, "[ImageSource]checkEncodedFormat error, type: %{public}d", ret); + IMAGE_LOGE("[ImageSource]checkEncodedFormat error, type: %{public}d", ret); return ret; } } // default return raw image, ERR_IMAGE_MISMATCHED_FORMAT case format = InnerFormat::RAW_FORMAT; - HiLog::Info(LABEL, "[ImageSource]image default to raw format."); + IMAGE_LOGI("[ImageSource]image default to raw format."); return SUCCESS; } @@ -1301,7 +1305,7 @@ uint32_t ImageSource::OnSourceRecognized(bool isAcquiredImageNum) if (ret != SUCCESS) { sourceInfo_.state = SourceInfoState::UNSUPPORTED_FORMAT; decodeState_ = SourceDecodingState::UNSUPPORTED_FORMAT; - HiLog::Error(LABEL, "[ImageSource]image decode error, ret:[%{public}u].", ret); + IMAGE_LOGE("[ImageSource]image decode error, ret:[%{public}u].", ret); return ret; } @@ -1311,7 +1315,7 @@ uint32_t ImageSource::OnSourceRecognized(bool isAcquiredImageNum) if (ret == SUCCESS) { // update new format sourceInfo_.encodedFormat = value; - HiLog::Info(LABEL, "[ImageSource] update new format, value:%{public}s", value.c_str()); + IMAGE_LOGI("[ImageSource] update new format, value:%{public}s", value.c_str()); } if (isAcquiredImageNum) { @@ -1319,12 +1323,12 @@ uint32_t ImageSource::OnSourceRecognized(bool isAcquiredImageNum) if (ret != SUCCESS) { if (ret == ERR_IMAGE_SOURCE_DATA_INCOMPLETE) { sourceInfo_.state = SourceInfoState::SOURCE_INCOMPLETE; - HiLog::Error(LABEL, "[ImageSource]image source data incomplete."); + IMAGE_LOGE("[ImageSource]image source data incomplete."); return ERR_IMAGE_SOURCE_DATA_INCOMPLETE; } sourceInfo_.state = SourceInfoState::FILE_INFO_ERROR; decodeState_ = SourceDecodingState::FILE_INFO_ERROR; - HiLog::Error(LABEL, "[ImageSource]image source error."); + IMAGE_LOGE("[ImageSource]image source error."); return ret; } } @@ -1342,18 +1346,18 @@ uint32_t ImageSource::OnSourceUnresolved() auto ret = GetEncodedFormat(sourceInfo_.encodedFormat, formatResult); if (ret != SUCCESS) { if (ret == ERR_IMAGE_SOURCE_DATA_INCOMPLETE) { - HiLog::Error(LABEL, "[ImageSource]image source incomplete."); + IMAGE_LOGE("[ImageSource]image source incomplete."); sourceInfo_.state = SourceInfoState::SOURCE_INCOMPLETE; return ERR_IMAGE_SOURCE_DATA_INCOMPLETE; } else if (ret == ERR_IMAGE_UNKNOWN_FORMAT) { - HiLog::Error(LABEL, "[ImageSource]image unknown format."); + IMAGE_LOGE("[ImageSource]image unknown format."); sourceInfo_.state = SourceInfoState::UNKNOWN_FORMAT; decodeState_ = SourceDecodingState::UNKNOWN_FORMAT; return ERR_IMAGE_UNKNOWN_FORMAT; } sourceInfo_.state = SourceInfoState::SOURCE_ERROR; decodeState_ = SourceDecodingState::SOURCE_ERROR; - HiLog::Error(LABEL, "[ImageSource]image source error."); + IMAGE_LOGE("[ImageSource]image source error."); return ret; } } @@ -1403,7 +1407,7 @@ uint32_t ImageSource::DecodeSourceInfo(bool isAcquiredImageNum) if (decodeState_ == SourceDecodingState::UNRESOLVED) { ret = OnSourceUnresolved(); if (ret != SUCCESS) { - HiLog::Error(LABEL, "[ImageSource]unresolved source: check format failed, ret:[%{public}d].", ret); + IMAGE_LOGE("[ImageSource]unresolved source: check format failed, ret:[%{public}d].", ret); return ret; } } @@ -1414,13 +1418,13 @@ uint32_t ImageSource::DecodeSourceInfo(bool isAcquiredImageNum) } else { ret = OnSourceRecognized(isAcquiredImageNum); if (ret != SUCCESS) { - HiLog::Error(LABEL, "[ImageSource]recognized source: get source info failed, ret:[%{public}d].", ret); + IMAGE_LOGE("[ImageSource]recognized source: get source info failed, ret:[%{public}d].", ret); return ret; } } return SUCCESS; } - HiLog::Error(LABEL, "[ImageSource]invalid source state %{public}d on decode source info.", decodeState_); + IMAGE_LOGE("[ImageSource]invalid source state %{public}d on decode source info.", decodeState_); ret = GetSourceDecodingState(decodeState_); return ret; } @@ -1429,7 +1433,7 @@ uint32_t ImageSource::DecodeImageInfo(uint32_t index, ImageStatusMap::iterator & { uint32_t ret = DecodeSourceInfo(false); if (ret != SUCCESS) { - HiLog::Error(LABEL, "[ImageSource]decode the image fail, ret:%{public}d.", ret); + IMAGE_LOGE("[ImageSource]decode the image fail, ret:%{public}d.", ret); return ret; } if (sourceInfo_.encodedFormat == InnerFormat::ASTC_FORMAT) { @@ -1442,12 +1446,12 @@ uint32_t ImageSource::DecodeImageInfo(uint32_t index, ImageStatusMap::iterator & iter = result.first; return SUCCESS; } else { - HiLog::Error(LABEL, "[ImageSource] decode astc image info failed."); + IMAGE_LOGE("[ImageSource] decode astc image info failed."); return ERR_IMAGE_DECODE_FAILED; } } if (mainDecoder_ == nullptr) { - HiLog::Error(LABEL, "[ImageSource]get image size, image decode plugin is null."); + IMAGE_LOGE("[ImageSource]get image size, image decode plugin is null."); return ERR_IMAGE_PLUGIN_CREATE_FAILED; } ImagePlugin::PlSize size; @@ -1461,14 +1465,14 @@ uint32_t ImageSource::DecodeImageInfo(uint32_t index, ImageStatusMap::iterator & iter = result.first; return SUCCESS; } else if (ret == ERR_IMAGE_SOURCE_DATA_INCOMPLETE) { - HiLog::Error(LABEL, "[ImageSource]source data incomplete."); + IMAGE_LOGE("[ImageSource]source data incomplete."); return ERR_IMAGE_SOURCE_DATA_INCOMPLETE; } else { ImageDecodingStatus status; status.imageState = ImageDecodingState::BASE_INFO_ERROR; auto errorResult = imageStatusMap_.insert(ImageStatusMap::value_type(index, status)); iter = errorResult.first; - HiLog::Error(LABEL, "[ImageSource]decode the image info fail."); + IMAGE_LOGE("[ImageSource]decode the image info fail."); return ERR_IMAGE_DECODE_FAILED; } } @@ -1517,14 +1521,14 @@ uint32_t ImageSource::SetDecodeOptions(std::unique_ptr &decoder plOptions.desiredPixelFormat = plDesiredFormat; uint32_t ret = decoder->SetDecodeOptions(index, plOptions, plInfo); if (ret != SUCCESS) { - HiLog::Error(LABEL, "[ImageSource]decoder plugin set decode options fail (image index:%{public}u)," + IMAGE_LOGE("[ImageSource]decoder plugin set decode options fail (image index:%{public}u)," "ret:%{public}u.", index, ret); return ret; } auto iter = imageStatusMap_.find(index); if (iter != imageStatusMap_.end()) { ImageInfo &info = (iter->second).imageInfo; - HiLog::Debug(LABEL, "[ImageSource]SetDecodeOptions plInfo.pixelFormat %{public}d", plInfo.pixelFormat); + IMAGE_LOGD("[ImageSource]SetDecodeOptions plInfo.pixelFormat %{public}d", plInfo.pixelFormat); PlPixelFormat format = plInfo.pixelFormat; auto find_item = std::find_if(PIXEL_FORMAT_MAP.begin(), PIXEL_FORMAT_MAP.end(), @@ -1534,7 +1538,7 @@ uint32_t ImageSource::SetDecodeOptions(std::unique_ptr &decoder if (find_item != PIXEL_FORMAT_MAP.end()) { info.pixelFormat = (*find_item).first; } - HiLog::Debug(LABEL, "[ImageSource]SetDecodeOptions info.pixelFormat %{public}d", info.pixelFormat); + IMAGE_LOGD("[ImageSource]SetDecodeOptions info.pixelFormat %{public}d", info.pixelFormat); } return SUCCESS; } @@ -1619,11 +1623,11 @@ ImageSource::ImageStatusMap::iterator ImageSource::GetValidImageStatus(uint32_t if (iter == imageStatusMap_.end()) { errorCode = DecodeImageInfo(index, iter); if (errorCode != SUCCESS) { - HiLog::Error(LABEL, "[ImageSource]image info decode fail, ret:%{public}u.", errorCode); + IMAGE_LOGE("[ImageSource]image info decode fail, ret:%{public}u.", errorCode); return imageStatusMap_.end(); } } else if (iter->second.imageState < ImageDecodingState::BASE_INFO_PARSED) { - HiLog::Error(LABEL, "[ImageSource]invalid imageState %{public}d on get image status.", iter->second.imageState); + IMAGE_LOGE("[ImageSource]invalid imageState %{public}d on get image status.", iter->second.imageState); errorCode = ERR_IMAGE_DECODE_FAILED; return imageStatusMap_.end(); } @@ -1642,7 +1646,7 @@ uint32_t ImageSource::AddIncrementalContext(PixelMap &pixelMap, IncrementalRecor context.decoder = std::unique_ptr(CreateDecoder(ret)); } if (context.decoder == nullptr) { - HiLog::Error(LABEL, "[ImageSource]failed to create decoder on add incremental context, ret:%{public}u.", ret); + IMAGE_LOGE("[ImageSource]failed to create decoder on add incremental context, ret:%{public}u.", ret); return ret; } // mainDecoder has parsed base info in DecodeImageInfo(); @@ -1655,7 +1659,7 @@ uint32_t ImageSource::AddIncrementalContext(PixelMap &pixelMap, IncrementalRecor uint32_t ImageSource::DoIncrementalDecoding(uint32_t index, const DecodeOptions &opts, PixelMap &pixelMap, IncrementalDecodingContext &recordContext) { - HiLog::Debug(LABEL, "[ImageSource]do incremental decoding: begin."); + IMAGE_LOGD("[ImageSource]do incremental decoding: begin."); uint8_t *pixelAddr = static_cast(pixelMap.GetWritablePixels()); ProgDecodeContext context; context.decodeContext.pixelsBuffer.buffer = pixelAddr; @@ -1665,16 +1669,16 @@ uint32_t ImageSource::DoIncrementalDecoding(uint32_t index, const DecodeOptions context.decodeContext.pixelsBuffer.bufferSize, context.decodeContext.allocatorType, context.decodeContext.freeFunc); } - HiLog::Debug(LABEL, "[ImageSource]do incremental decoding progress:%{public}u.", context.totalProcessProgress); + IMAGE_LOGD("[ImageSource]do incremental decoding progress:%{public}u.", context.totalProcessProgress); recordContext.decodingProgress = context.totalProcessProgress; if (ret != SUCCESS && ret != ERR_IMAGE_SOURCE_DATA_INCOMPLETE) { recordContext.IncrementalState = ImageDecodingState::IMAGE_ERROR; - HiLog::Error(LABEL, "[ImageSource]do incremental decoding source fail, ret:%{public}u.", ret); + IMAGE_LOGE("[ImageSource]do incremental decoding source fail, ret:%{public}u.", ret); return ret; } if (ret == SUCCESS) { recordContext.IncrementalState = ImageDecodingState::IMAGE_DECODED; - HiLog::Info(LABEL, "[ImageSource]do incremental decoding success."); + IMAGE_LOGI("[ImageSource]do incremental decoding success."); } return ret; } @@ -1700,12 +1704,12 @@ uint32_t ImageSource::GetFilterArea(const int &privacyType, std::vectorGetFilterArea(privacyType, ranges); if (ret != SUCCESS) { - HiLog::Error(LABEL, "[ImageSource] GetFilterArea fail, ret:%{public}u", ret); + IMAGE_LOGE("[ImageSource] GetFilterArea fail, ret:%{public}u", ret); return ret; } return SUCCESS; @@ -1789,10 +1793,10 @@ bool ImageSource::ImageConverChange(const Rect &cropRect, ImageInfo &dstImageInf } CropValue value = PostProc::GetCropValue(cropRect, srcImageInfo.size); if (value == CropValue::NOCROP && !hasPixelConvert) { - HiLog::Debug(LABEL, "[ImageSource]no need crop and pixel convert."); + IMAGE_LOGD("[ImageSource]no need crop and pixel convert."); return false; } else if (value == CropValue::INVALID) { - HiLog::Error(LABEL, "[ImageSource]invalid corp region, top:%{public}d, left:%{public}d, " + IMAGE_LOGE("[ImageSource]invalid corp region, top:%{public}d, left:%{public}d, " "width:%{public}d, height:%{public}d", cropRect.top, cropRect.left, cropRect.width, cropRect.height); return false; } @@ -1802,45 +1806,45 @@ unique_ptr ImageSource::DecodeBase64(const uint8_t *data, uint32_t { if (size < IMAGE_URL_PREFIX.size() || ::memcmp(data, IMAGE_URL_PREFIX.c_str(), IMAGE_URL_PREFIX.size()) != INT_ZERO) { - HiLog::Debug(LABEL, "[ImageSource]Base64 image header mismatch."); + IMAGE_LOGD("[ImageSource]Base64 image header mismatch."); return nullptr; } const char* data1 = reinterpret_cast(data); auto sub = ::strstr(data1, BASE64_URL_PREFIX.c_str()); if (sub == nullptr) { - HiLog::Info(LABEL, "[ImageSource]Base64 mismatch."); + IMAGE_LOGI("[ImageSource]Base64 mismatch."); return nullptr; } sub = sub + BASE64_URL_PREFIX.size(); uint32_t subSize = size - (sub - data1); - HiLog::Debug(LABEL, "[ImageSource]Base64 image input: %{public}p, data: %{public}p, size %{public}u.", + IMAGE_LOGD("[ImageSource]Base64 image input: %{public}p, data: %{public}p, size %{public}u.", data, sub, subSize); #ifdef NEW_SKIA size_t outputLen = 0; SkBase64::Error error = SkBase64::Decode(sub, subSize, nullptr, &outputLen); if (error != SkBase64::Error::kNoError) { - HiLog::Error(LABEL, "[ImageSource]Base64 decode get out size failed."); + IMAGE_LOGE("[ImageSource]Base64 decode get out size failed."); return nullptr; } sk_sp resData = SkData::MakeUninitialized(outputLen); error = SkBase64::Decode(sub, subSize, resData->writable_data(), &outputLen); if (error != SkBase64::Error::kNoError) { - HiLog::Error(LABEL, "[ImageSource]Base64 decode get data failed."); + IMAGE_LOGE("[ImageSource]Base64 decode get data failed."); return nullptr; } - HiLog::Debug(LABEL, "[ImageSource][NewSkia]Create BufferSource from decoded base64 string."); + IMAGE_LOGD("[ImageSource][NewSkia]Create BufferSource from decoded base64 string."); auto imageData = static_cast(resData->data()); return BufferSourceStream::CreateSourceStream(imageData, resData->size()); #else SkBase64 base64Decoder; if (base64Decoder.decode(sub, subSize) != SkBase64::kNoError) { - HiLog::Error(LABEL, "[ImageSource]base64 image decode failed!"); + IMAGE_LOGE("[ImageSource]base64 image decode failed!"); return nullptr; } auto base64Data = base64Decoder.getData(); const uint8_t* imageData = reinterpret_cast(base64Data); - HiLog::Debug(LABEL, "[ImageSource]Create BufferSource from decoded base64 string."); + IMAGE_LOGD("[ImageSource]Create BufferSource from decoded base64 string."); auto result = BufferSourceStream::CreateSourceStream(imageData, base64Decoder.getDataSize()); if (base64Data != nullptr) { delete[] base64Data; @@ -1879,10 +1883,10 @@ static inline uint8_t FloatToUint8(float f) bool ImageSource::ConvertYUV420ToRGBA(uint8_t *data, uint32_t size, bool isSupportOdd, bool isAddUV, uint32_t &errorCode) { - HiLog::Debug(LABEL, "[ImageSource]ConvertYUV420ToRGBA IN srcPixelFormat:%{public}d, srcSize:(%{public}d," + IMAGE_LOGD("[ImageSource]ConvertYUV420ToRGBA IN srcPixelFormat:%{public}d, srcSize:(%{public}d," "%{public}d)", sourceOptions_.pixelFormat, sourceOptions_.size.width, sourceOptions_.size.height); if ((!isSupportOdd) && (sourceOptions_.size.width & 1) == 1) { - HiLog::Error(LABEL, "[ImageSource]ConvertYUV420ToRGBA odd width, %{public}d", sourceOptions_.size.width); + IMAGE_LOGE("[ImageSource]ConvertYUV420ToRGBA odd width, %{public}d", sourceOptions_.size.width); errorCode = ERR_IMAGE_DATA_UNSUPPORT; return false; } @@ -1894,7 +1898,7 @@ bool ImageSource::ConvertYUV420ToRGBA(uint8_t *data, uint32_t size, const size_t yuvSize = sourceStreamPtr_->GetStreamSize(); const size_t ubase = width * height + ((sourceOptions_.pixelFormat == PixelFormat::NV12) ? 0 : 1); const size_t vbase = width * height + ((sourceOptions_.pixelFormat == PixelFormat::NV12) ? 1 : 0); - HiLog::Debug(LABEL, "[ImageSource]ConvertYUV420ToRGBA uvbase:(%{public}zu, %{public}zu)," + IMAGE_LOGD("[ImageSource]ConvertYUV420ToRGBA uvbase:(%{public}zu, %{public}zu)," "width:(%{public}zu, %{public}zu)", ubase, vbase, width, uvwidth); for (size_t h = 0; h < height; h++) { @@ -1922,19 +1926,19 @@ bool ImageSource::ConvertYUV420ToRGBA(uint8_t *data, uint32_t size, } } } - HiLog::Debug(LABEL, "[ImageSource]ConvertYUV420ToRGBA OUT"); + IMAGE_LOGD("[ImageSource]ConvertYUV420ToRGBA OUT"); return true; } unique_ptr ImageSource::CreatePixelMapForYUV(uint32_t &errorCode) { - HiLog::Debug(LABEL, "[ImageSource]CreatePixelMapForYUV IN srcPixelFormat:%{public}d, srcSize:(%{public}d," + IMAGE_LOGD("[ImageSource]CreatePixelMapForYUV IN srcPixelFormat:%{public}d, srcSize:(%{public}d," "%{public}d)", sourceOptions_.pixelFormat, sourceOptions_.size.width, sourceOptions_.size.height); DumpInputData("yuv"); unique_ptr pixelMap = make_unique(); if (pixelMap == nullptr) { - HiLog::Error(LABEL, "[ImageSource]create the pixel map unique_ptr fail."); + IMAGE_LOGE("[ImageSource]create the pixel map unique_ptr fail."); errorCode = ERR_IMAGE_MALLOC_ABNORMAL; return nullptr; } @@ -1947,14 +1951,14 @@ unique_ptr ImageSource::CreatePixelMapForYUV(uint32_t &errorCode) info.alphaType = AlphaType::IMAGE_ALPHA_TYPE_OPAQUE; errorCode = pixelMap->SetImageInfo(info); if (errorCode != SUCCESS) { - HiLog::Error(LABEL, "[ImageSource]update pixelmap info error ret:%{public}u.", errorCode); + IMAGE_LOGE("[ImageSource]update pixelmap info error ret:%{public}u.", errorCode); return nullptr; } size_t bufferSize = static_cast(pixelMap->GetWidth() * pixelMap->GetHeight() * pixelMap->GetPixelBytes()); auto buffer = malloc(bufferSize); if (buffer == nullptr) { - HiLog::Error(LABEL, "allocate memory size %{public}zu fail", bufferSize); + IMAGE_LOGE("allocate memory size %{public}zu fail", bufferSize); errorCode = ERR_IMAGE_MALLOC_ABNORMAL; return nullptr; } @@ -1963,19 +1967,19 @@ unique_ptr ImageSource::CreatePixelMapForYUV(uint32_t &errorCode) pixelMap->SetPixelsAddr(buffer, nullptr, bufferSize, AllocatorType::HEAP_ALLOC, nullptr); if (!ConvertYUV420ToRGBA(static_cast(buffer), bufferSize, false, false, errorCode)) { - HiLog::Error(LABEL, "convert yuv420 to rgba issue, errorCode=%{public}u", errorCode); + IMAGE_LOGE("convert yuv420 to rgba issue, errorCode=%{public}u", errorCode); errorCode = ERROR; return nullptr; } - HiLog::Debug(LABEL, "[ImageSource]CreatePixelMapForYUV OUT"); + IMAGE_LOGD("[ImageSource]CreatePixelMapForYUV OUT"); return pixelMap; } bool ImageSource::IsASTC(const uint8_t *fileData, size_t fileSize) { if (fileData == nullptr || fileSize < ASTC_HEADER_SIZE) { - HiLog::Error(LABEL, "[ImageSource]IsASTC fileData incorrect."); + IMAGE_LOGE("[ImageSource]IsASTC fileData incorrect."); return false; } unsigned int magicVal = static_cast(fileData[0]) + (static_cast(fileData[1]) << 8) + @@ -1987,7 +1991,7 @@ bool ImageSource::GetImageInfoForASTC(ImageInfo& imageInfo) { ASTCInfo astcInfo; if (!GetASTCInfo(sourceStreamPtr_->GetDataPtr(), sourceStreamPtr_->GetStreamSize(), astcInfo)) { - HiLog::Error(LABEL, "[ImageSource] get astc image info failed."); + IMAGE_LOGE("[ImageSource] get astc image info failed."); return false; } imageInfo.size = astcInfo.size; @@ -2005,7 +2009,7 @@ bool ImageSource::GetImageInfoForASTC(ImageInfo& imageInfo) break; } default: - HiLog::Error(LABEL, "[ImageSource]GetImageInfoForASTC pixelFormat is unknown."); + IMAGE_LOGE("[ImageSource]GetImageInfoForASTC pixelFormat is unknown."); imageInfo.pixelFormat = PixelFormat::UNKNOWN; } return true; @@ -2024,13 +2028,13 @@ unique_ptr ImageSource::CreatePixelMapForASTC(uint32_t &errorCode) ImageInfo info; if (!GetImageInfoForASTC(info)) { - HiLog::Error(LABEL, "[ImageSource] get astc image info failed."); + IMAGE_LOGE("[ImageSource] get astc image info failed."); return nullptr; } errorCode = pixelAstc->SetImageInfo(info); pixelAstc->SetAstcRealSize(info.size); if (errorCode != SUCCESS) { - HiLog::Error(LABEL, "[ImageSource]update pixelmap info error ret:%{public}u.", errorCode); + IMAGE_LOGE("[ImageSource]update pixelmap info error ret:%{public}u.", errorCode); return nullptr; } pixelAstc->SetEditable(false); @@ -2043,18 +2047,18 @@ unique_ptr ImageSource::CreatePixelMapForASTC(uint32_t &errorCode) } else if (sourceStreamPtr_->GetStreamType() == ImagePlugin::BUFFER_SOURCE_TYPE) { int fd = AshmemCreate("CreatePixelMapForASTC Data", fileSize); if (fd < 0) { - HiLog::Error(LABEL, "[ImageSource]CreatePixelMapForASTC AshmemCreate fd < 0."); + IMAGE_LOGE("[ImageSource]CreatePixelMapForASTC AshmemCreate fd < 0."); return nullptr; } int result = AshmemSetProt(fd, PROT_READ | PROT_WRITE); if (result < 0) { - HiLog::Error(LABEL, "[ImageSource]CreatePixelMapForASTC AshmemSetPort error."); + IMAGE_LOGE("[ImageSource]CreatePixelMapForASTC AshmemSetPort error."); ::close(fd); return nullptr; } void* ptr = ::mmap(nullptr, fileSize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if (ptr == MAP_FAILED || ptr == nullptr) { - HiLog::Error(LABEL, "[ImageSource]CreatePixelMapForASTC data is nullptr."); + IMAGE_LOGE("[ImageSource]CreatePixelMapForASTC data is nullptr."); ::close(fd); return nullptr; } @@ -2072,7 +2076,7 @@ unique_ptr ImageSource::CreatePixelMapForASTC(uint32_t &errorCode) bool ImageSource::GetASTCInfo(const uint8_t *fileData, size_t fileSize, ASTCInfo& astcInfo) { if (fileData == nullptr || fileSize < ASTC_HEADER_SIZE) { - HiLog::Error(LABEL, "[ImageSource]GetASTCInfo fileData incorrect."); + IMAGE_LOGE("[ImageSource]GetASTCInfo fileData incorrect."); return false; } astcInfo.size.width = static_cast(fileData[ASTC_HEADER_DIM_X]) + @@ -2092,7 +2096,7 @@ unique_ptr>> ImageSource::CreatePixelMapList(const D DumpInputData(); auto frameCount = GetFrameCount(errorCode); if (errorCode != SUCCESS) { - HiLog::Error(LABEL, "[ImageSource]CreatePixelMapList get frame count error."); + IMAGE_LOGE("[ImageSource]CreatePixelMapList get frame count error."); return nullptr; } @@ -2100,7 +2104,7 @@ unique_ptr>> ImageSource::CreatePixelMapList(const D for (uint32_t index = 0; index < frameCount; index++) { auto pixelMap = CreatePixelMap(index, opts, errorCode); if (errorCode != SUCCESS) { - HiLog::Error(LABEL, "[ImageSource]CreatePixelMapList create PixelMap error. index=%{public}u", index); + IMAGE_LOGE("[ImageSource]CreatePixelMapList create PixelMap error. index=%{public}u", index); return nullptr; } pixelMaps->push_back(std::move(pixelMap)); @@ -2115,7 +2119,7 @@ unique_ptr> ImageSource::GetDelayTime(uint32_t &errorCode) { auto frameCount = GetFrameCount(errorCode); if (errorCode != SUCCESS) { - HiLog::Error(LABEL, "[ImageSource]GetDelayTime get frame sum error."); + IMAGE_LOGE("[ImageSource]GetDelayTime get frame sum error."); return nullptr; } @@ -2125,17 +2129,17 @@ unique_ptr> ImageSource::GetDelayTime(uint32_t &errorCode) string delayTimeStr; errorCode = mainDecoder_->GetImagePropertyString(index, GIF_IMAGE_DELAY_TIME, delayTimeStr); if (errorCode != SUCCESS) { - HiLog::Error(LABEL, "[ImageSource]GetDelayTime get delay time issue. index=%{public}u", index); + IMAGE_LOGE("[ImageSource]GetDelayTime get delay time issue. index=%{public}u", index); return nullptr; } if (!IsNumericStr(delayTimeStr)) { - HiLog::Error(LABEL, "[ImageSource]GetDelayTime not a numeric string. delayTimeStr=%{public}s", + IMAGE_LOGE("[ImageSource]GetDelayTime not a numeric string. delayTimeStr=%{public}s", delayTimeStr.c_str()); return nullptr; } int delayTime = 0; if (!StrToInt(delayTimeStr, delayTime)) { - HiLog::Error(LABEL, "[ImageSource]GetDelayTime to int fail. delayTimeStr=%{public}s", delayTimeStr.c_str()); + IMAGE_LOGE("[ImageSource]GetDelayTime to int fail. delayTimeStr=%{public}s", delayTimeStr.c_str()); return nullptr; } delayTimes->push_back(delayTime); @@ -2150,12 +2154,12 @@ uint32_t ImageSource::GetFrameCount(uint32_t &errorCode) { uint32_t frameCount = GetSourceInfo(errorCode).topLevelImageNum; if (errorCode != SUCCESS) { - HiLog::Error(LABEL, "[ImageSource]GetFrameCount get source info error."); + IMAGE_LOGE("[ImageSource]GetFrameCount get source info error."); return 0; } if (InitMainDecoder() != SUCCESS) { - HiLog::Error(LABEL, "[ImageSource]GetFrameCount image decode plugin is null."); + IMAGE_LOGE("[ImageSource]GetFrameCount image decode plugin is null."); errorCode = ERR_IMAGE_PLUGIN_CREATE_FAILED; return 0; } @@ -2170,7 +2174,7 @@ void ImageSource::DumpInputData(const std::string& fileSuffix) } if (sourceStreamPtr_ == nullptr) { - HiLog::Info(LABEL, "ImageSource::DumpInputData failed, streamPtr is null"); + IMAGE_LOGI("ImageSource::DumpInputData failed, streamPtr is null"); return; } diff --git a/frameworks/innerkitsimpl/common/src/incremental_pixel_map.cpp b/frameworks/innerkitsimpl/common/src/incremental_pixel_map.cpp index 58d3d4e55..3c6f06365 100644 --- a/frameworks/innerkitsimpl/common/src/incremental_pixel_map.cpp +++ b/frameworks/innerkitsimpl/common/src/incremental_pixel_map.cpp @@ -14,16 +14,18 @@ */ #include "incremental_pixel_map.h" -#include "hilog/log.h" +#include "image_log.h" #include "image_source.h" -#include "log_tags.h" #include "media_errors.h" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "IncrementalPixelMap" + namespace OHOS { namespace Media { -using namespace OHOS::HiviewDFX; - -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "IncrementalPixelMap" }; static IncrementalDecodingState ConvertImageStateToIncrementalState(ImageDecodingState imageState) { @@ -50,7 +52,7 @@ static IncrementalDecodingState ConvertImageStateToIncrementalState(ImageDecodin return IncrementalDecodingState::IMAGE_DECODED; } default: { - HiLog::Error(LABEL, "unexpected imageState %{public}d.", imageState); + IMAGE_LOGE("unexpected imageState %{public}d.", imageState); return IncrementalDecodingState::UNRESOLVED; } } @@ -77,11 +79,11 @@ uint32_t IncrementalPixelMap::PromoteDecoding(uint8_t &decodeProgress) if (imageSource_ == nullptr) { if (decodingStatus_.state == IncrementalDecodingState::BASE_INFO_ERROR || decodingStatus_.state == IncrementalDecodingState::IMAGE_ERROR) { - HiLog::Error(LABEL, "promote decode failed for state %{public}d, errorDetail %{public}u.", - decodingStatus_.state, decodingStatus_.errorDetail); + IMAGE_LOGE("promote decode failed for state %{public}d, errorDetail %{public}u.", decodingStatus_.state, + decodingStatus_.errorDetail); return decodingStatus_.errorDetail; } - HiLog::Error(LABEL, "promote decode failed or terminated, image source is null."); + IMAGE_LOGE("promote decode failed or terminated, image source is null."); return ERR_IMAGE_SOURCE_DATA; } ImageDecodingState imageState = ImageDecodingState::UNRESOLVED; @@ -94,7 +96,7 @@ uint32_t IncrementalPixelMap::PromoteDecoding(uint8_t &decodeProgress) if (ret != SUCCESS && ret != ERR_IMAGE_SOURCE_DATA_INCOMPLETE) { DetachSource(); decodingStatus_.errorDetail = ret; - HiLog::Error(LABEL, "promote decode failed, ret=%{public}u.", ret); + IMAGE_LOGE("promote decode failed, ret=%{public}u.", ret); } if (ret == SUCCESS) { DetachSource(); diff --git a/frameworks/innerkitsimpl/common/src/memory_manager.cpp b/frameworks/innerkitsimpl/common/src/memory_manager.cpp index b9a04faec..7b6e03e2b 100644 --- a/frameworks/innerkitsimpl/common/src/memory_manager.cpp +++ b/frameworks/innerkitsimpl/common/src/memory_manager.cpp @@ -17,9 +17,8 @@ #include #include -#include "hilog/log.h" +#include "image_log.h" #include "image_utils.h" -#include "log_tags.h" #include "media_errors.h" #include "securec.h" @@ -30,10 +29,14 @@ #define SUPPORT_SHARED_MEMORY #endif +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "MemoryManager" + namespace OHOS { namespace Media { -using namespace OHOS::HiviewDFX; -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "MemoryManager" }; static const size_t SIZE_ZERO = 0; static const int LINUX_SUCCESS = 0; // Define pixel map malloc max size 600MB @@ -41,18 +44,18 @@ constexpr int32_t PIXEL_MAP_MAX_RAM_SIZE = 600 * 1024 * 1024; uint32_t HeapMemory::Create() { - HiLog::Debug(LABEL, "HeapMemory::Create IN"); + IMAGE_LOGD("HeapMemory::Create IN"); if (data.data != nullptr) { - HiLog::Debug(LABEL, "HeapMemory::Create has created"); + IMAGE_LOGD("HeapMemory::Create has created"); return SUCCESS; } if (data.size == 0 || data.size > PIXEL_MAP_MAX_RAM_SIZE) { - HiLog::Error(LABEL, "HeapMemory::Create Invalid value of bufferSize"); + IMAGE_LOGE("HeapMemory::Create Invalid value of bufferSize"); return ERR_IMAGE_DATA_ABNORMAL; } data.data = static_cast(malloc(data.size)); if (data.data == nullptr) { - HiLog::Error(LABEL, "HeapMemory::Create malloc buffer failed"); + IMAGE_LOGE("HeapMemory::Create malloc buffer failed"); return ERR_IMAGE_MALLOC_ABNORMAL; } #if defined(IOS_PLATFORM) || defined(A_PLATFORM) @@ -64,9 +67,9 @@ uint32_t HeapMemory::Create() uint32_t HeapMemory::Release() { #if !defined(IOS_PLATFORM) &&!defined(A_PLATFORM) - HiLog::Debug(LABEL, "HeapMemory::Release IN"); + IMAGE_LOGD("HeapMemory::Release IN"); if (data.data == nullptr) { - HiLog::Info(LABEL, "HeapMemory::Release nullptr data"); + IMAGE_LOGI("HeapMemory::Release nullptr data"); return ERR_IMAGE_DATA_ABNORMAL; } free(data.data); @@ -90,27 +93,27 @@ static inline void ReleaseSharedMemory(int* fdPtr, uint8_t* ptr = nullptr, size_ uint32_t SharedMemory::Create() { #ifdef SUPPORT_SHARED_MEMORY - HiLog::Debug(LABEL, "SharedMemory::Create IN tag %{public}s, data size %{public}zu", + IMAGE_LOGD("SharedMemory::Create IN tag %{public}s, data size %{public}zu", (data.tag == nullptr)?"nullptr":data.tag, data.size); if (data.tag == nullptr || data.size == SIZE_ZERO) { - HiLog::Error(LABEL, "SharedMemory::Create tag is nullptr or data size %{public}zu", data.size); + IMAGE_LOGE("SharedMemory::Create tag is nullptr or data size %{public}zu", data.size); return ERR_IMAGE_DATA_ABNORMAL; } auto fdPtr = std::make_unique(); *fdPtr = AshmemCreate(data.tag, data.size); if (*fdPtr < 0) { - HiLog::Error(LABEL, "SharedMemory::Create AshmemCreate fd:[%{public}d].", *fdPtr); + IMAGE_LOGE("SharedMemory::Create AshmemCreate fd:[%{public}d].", *fdPtr); return ERR_IMAGE_DATA_ABNORMAL; } if (AshmemSetProt(*fdPtr, PROT_READ | PROT_WRITE) < LINUX_SUCCESS) { - HiLog::Error(LABEL, "SharedMemory::Create AshmemSetProt errno %{public}d.", errno); + IMAGE_LOGE("SharedMemory::Create AshmemSetProt errno %{public}d.", errno); ReleaseSharedMemory(fdPtr.get()); return ERR_IMAGE_DATA_ABNORMAL; } data.data = ::mmap(nullptr, data.size, PROT_READ | PROT_WRITE, MAP_SHARED, *fdPtr, 0); if (data.data == MAP_FAILED) { - HiLog::Error(LABEL, "SharedMemory::Create mmap failed, errno:%{public}d", errno); + IMAGE_LOGE("SharedMemory::Create mmap failed, errno:%{public}d", errno); ReleaseSharedMemory(fdPtr.get(), static_cast(data.data), data.size); return ERR_IMAGE_DATA_ABNORMAL; } @@ -118,7 +121,7 @@ uint32_t SharedMemory::Create() extend.data = fdPtr.release(); return SUCCESS; #else - HiLog::Error(LABEL, "SharedMemory::Create unsupported"); + IMAGE_LOGE("SharedMemory::Create unsupported"); return ERR_IMAGE_DATA_UNSUPPORT; #endif } @@ -126,7 +129,7 @@ uint32_t SharedMemory::Create() uint32_t SharedMemory::Release() { #ifdef SUPPORT_SHARED_MEMORY - HiLog::Debug(LABEL, "SharedMemory::Release IN"); + IMAGE_LOGD("SharedMemory::Release IN"); ReleaseSharedMemory(static_cast(extend.data), static_cast(data.data), data.size); data.data = nullptr; data.size = SIZE_ZERO; @@ -137,7 +140,7 @@ uint32_t SharedMemory::Release() } return SUCCESS; #else - HiLog::Error(LABEL, "SharedMemory::Release unsupported"); + IMAGE_LOGE("SharedMemory::Release unsupported"); return ERR_IMAGE_DATA_UNSUPPORT; #endif } @@ -145,7 +148,7 @@ uint32_t SharedMemory::Release() uint32_t DmaMemory::Create() { #if defined(_WIN32) || defined(_APPLE) || defined(A_PLATFORM) || defined(IOS_PLATFORM) - HiLog::Error(LABEL, "Unsupport dma mem alloc"); + IMAGE_LOGE("Unsupport dma mem alloc"); return ERR_IMAGE_DATA_UNSUPPORT; #else sptr sb = SurfaceBuffer::Create(); @@ -161,13 +164,13 @@ uint32_t DmaMemory::Create() }; GSError ret = sb->Alloc(requestConfig); if (ret != GSERROR_OK) { - HiLog::Error(LABEL, "SurfaceBuffer Alloc failed, %{public}s", GSErrorStr(ret).c_str()); + IMAGE_LOGE("SurfaceBuffer Alloc failed, %{public}s", GSErrorStr(ret).c_str()); return ERR_DMA_NOT_EXIST; } void* nativeBuffer = sb.GetRefPtr(); int32_t err = ImageUtils::SurfaceBuffer_Reference(nativeBuffer); if (err != OHOS::GSERROR_OK) { - HiLog::Error(LABEL, "NativeBufferReference failed"); + IMAGE_LOGE("NativeBufferReference failed"); return ERR_DMA_DATA_ABNORMAL; } data.data = static_cast(sb->GetVirAddr()); @@ -180,7 +183,7 @@ uint32_t DmaMemory::Create() uint32_t DmaMemory::Release() { #if defined(_WIN32) || defined(_APPLE) || defined(A_PLATFORM) || defined(IOS_PLATFORM) - HiLog::Error(LABEL, "Unsupport dma mem release"); + IMAGE_LOGE("Unsupport dma mem release"); return ERR_IMAGE_DATA_UNSUPPORT; #else data.data = nullptr; @@ -188,7 +191,7 @@ uint32_t DmaMemory::Release() if (extend.data != nullptr) { int32_t err = ImageUtils::SurfaceBuffer_Unreference(static_cast(extend.data)); if (err != OHOS::GSERROR_OK) { - HiLog::Error(LABEL, "NativeBufferReference failed"); + IMAGE_LOGE("NativeBufferReference failed"); return ERR_DMA_DATA_ABNORMAL; } extend.data = nullptr; @@ -215,7 +218,7 @@ std::unique_ptr MemoryManager::CreateMemory(AllocatorType type, Memor res = std::make_unique(); break; case AllocatorType::CUSTOM_ALLOC: - HiLog::Error(LABEL, "MemoryManager::CreateMemory unsupported CUSTOM_ALLOC now"); + IMAGE_LOGE("MemoryManager::CreateMemory unsupported CUSTOM_ALLOC now"); return nullptr; case AllocatorType::DEFAULT: case AllocatorType::HEAP_ALLOC: @@ -224,7 +227,7 @@ std::unique_ptr MemoryManager::CreateMemory(AllocatorType type, Memor break; } if (res == nullptr) { - HiLog::Error(LABEL, "MemoryManager::CreateMemory unsupported %{public}d", type); + IMAGE_LOGE("MemoryManager::CreateMemory unsupported %{public}d", type); return nullptr; } res->data.data = data.data; diff --git a/frameworks/innerkitsimpl/common/src/native_image.cpp b/frameworks/innerkitsimpl/common/src/native_image.cpp index 0695da650..12a0718be 100644 --- a/frameworks/innerkitsimpl/common/src/native_image.cpp +++ b/frameworks/innerkitsimpl/common/src/native_image.cpp @@ -14,15 +14,17 @@ */ #include +#include "image_log.h" #include "media_errors.h" -#include "hilog/log.h" -#include "log_tags.h" #include "native_image.h" -using OHOS::HiviewDFX::HiLog; +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "NativeImage" namespace { - constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "NativeImage"}; constexpr int32_t NUMI_0 = 0; constexpr uint32_t NUM_0 = 0; constexpr uint32_t NUM_1 = 1; @@ -95,14 +97,14 @@ int32_t NativeImage::SplitYUV422SPComponent() { auto rawBuffer = GetSurfaceBufferAddr(); if (rawBuffer == nullptr) { - HiLog::Error(LABEL, "SurfaceBuffer viraddr is nullptr"); + IMAGE_LOGE("SurfaceBuffer viraddr is nullptr"); return ERR_MEDIA_NULL_POINTER; } uint64_t surfaceSize = NUM_0; auto res = GetDataSize(surfaceSize); if (res != SUCCESS || surfaceSize == NUM_0) { - HiLog::Error(LABEL, "S size is 0"); + IMAGE_LOGE("S size is 0"); return ERR_MEDIA_DATA_UNSUPPORT; } @@ -110,7 +112,7 @@ int32_t NativeImage::SplitYUV422SPComponent() int32_t height = NUM_0; res = GetSize(width, height); if (res != SUCCESS || width <= NUMI_0 || height <= NUMI_0) { - HiLog::Error(LABEL, "Invaild width %{public}" PRId32 " height %{public}" PRId32, width, height); + IMAGE_LOGE("Invaild width %{public}" PRId32 " height %{public}" PRId32, width, height); return ERR_MEDIA_DATA_UNSUPPORT; } @@ -119,7 +121,7 @@ int32_t NativeImage::SplitYUV422SPComponent() yuv.ySize = static_cast(width * height); yuv.uvSize = static_cast(height * uvStride); if (surfaceSize < (yuv.ySize + yuv.uvSize * NUM_2)) { - HiLog::Error(LABEL, "S size %{public}" PRIu64 " < y plane %{public}" PRIu64 + IMAGE_LOGE("S size %{public}" PRIu64 " < y plane %{public}" PRIu64 " + uv plane %{public}" PRIu64, surfaceSize, yuv.ySize, yuv.uvSize * NUM_2); return ERR_MEDIA_DATA_UNSUPPORT; } @@ -128,7 +130,7 @@ int32_t NativeImage::SplitYUV422SPComponent() NativeComponent* u = CreateComponent(int32_t(ComponentType::YUV_U), yuv.uvSize, uvStride, NUM_2, nullptr); NativeComponent* v = CreateComponent(int32_t(ComponentType::YUV_V), yuv.uvSize, uvStride, NUM_2, nullptr); if ((y == nullptr) || (u == nullptr) || (v == nullptr)) { - HiLog::Error(LABEL, "Create Component failed"); + IMAGE_LOGE("Create Component failed"); return ERR_MEDIA_DATA_UNSUPPORT; } yuv.y = y->raw; @@ -166,7 +168,7 @@ int32_t NativeImage::CombineYUVComponents() return res; } if (!IsYUV422SPFormat(format)) { - HiLog::Info(LABEL, "No need to combine components for NO YUV format now"); + IMAGE_LOGI("No need to combine components for NO YUV format now"); return SUCCESS; } @@ -174,7 +176,7 @@ int32_t NativeImage::CombineYUVComponents() auto u = GetComponent(int32_t(ComponentType::YUV_U)); auto v = GetComponent(int32_t(ComponentType::YUV_V)); if ((y == nullptr) || (u == nullptr) || (v == nullptr)) { - HiLog::Error(LABEL, "No component need to combine"); + IMAGE_LOGE("No component need to combine"); return ERR_MEDIA_DATA_UNSUPPORT; } YUVData data; @@ -194,7 +196,7 @@ int32_t NativeImage::CombineYUVComponents() static std::unique_ptr BuildComponent(size_t size, int32_t row, int32_t pixel, uint8_t* vir) { if (size == NUM_0 && vir == nullptr) { - HiLog::Error(LABEL, "Could't create 0 size component data"); + IMAGE_LOGE("Could't create 0 size component data"); return nullptr; } std::unique_ptr component = std::make_unique(); @@ -223,7 +225,7 @@ NativeComponent* NativeImage::CreateComponent(int32_t type, size_t size, int32_t { NativeComponent* res = GetCachedComponent(type); if (res != nullptr) { - HiLog::Info(LABEL, "Component %{public}d already exist. No need create", type); + IMAGE_LOGI("Component %{public}d already exist. No need create", type); return res; } @@ -262,22 +264,21 @@ int32_t NativeImage::GetDataSize(uint64_t &size) size = static_cast(buffer_->GetSize()); auto extraData = buffer_->GetExtraData(); if (extraData == nullptr) { - HiLog::Info(LABEL, "Nullptr s extra data. return buffer size %{public}" PRIu64, size); + IMAGE_LOGI("Nullptr s extra data. return buffer size %{public}" PRIu64, size); return SUCCESS; } int32_t extraDataSize = NUMI_0; auto res = extraData->ExtraGet(DATA_SIZE_TAG, extraDataSize); if (res != NUM_0) { - HiLog::Info(LABEL, "S ExtraGet dataSize error %{public}d", res); + IMAGE_LOGI("S ExtraGet dataSize error %{public}d", res); } else if (extraDataSize <= NUMI_0) { - HiLog::Info(LABEL, "S ExtraGet dataSize Ok, but size <= 0"); + IMAGE_LOGI("S ExtraGet dataSize Ok, but size <= 0"); } else if (static_cast(extraDataSize) > size) { - HiLog::Info(LABEL, - "S ExtraGet dataSize Ok,but dataSize %{public}d is bigger than bufferSize %{public}" PRIu64, + IMAGE_LOGI("S ExtraGet dataSize Ok,but dataSize %{public}d is bigger than bufferSize %{public}" PRIu64, extraDataSize, size); } else { - HiLog::Info(LABEL, "S ExtraGet dataSize %{public}d", extraDataSize); + IMAGE_LOGI("S ExtraGet dataSize %{public}d", extraDataSize); size = extraDataSize; } return SUCCESS; @@ -327,7 +328,7 @@ void NativeImage::release() if (buffer_ == nullptr) { return; } - HiLog::Info(LABEL, "NativeImage release"); + IMAGE_LOGI("NativeImage release"); if (components_.size() > 0) { components_.clear(); } diff --git a/frameworks/innerkitsimpl/common/src/pixel_astc.cpp b/frameworks/innerkitsimpl/common/src/pixel_astc.cpp index 0997c5c05..5072c195e 100644 --- a/frameworks/innerkitsimpl/common/src/pixel_astc.cpp +++ b/frameworks/innerkitsimpl/common/src/pixel_astc.cpp @@ -15,6 +15,7 @@ #include "pixel_astc.h" +#include "image_log.h" #include "image_utils.h" #include "image_trace.h" #include "image_type_converter.h" @@ -22,52 +23,54 @@ #include "include/core/SkBitmap.h" #include "include/core/SkCanvas.h" #include "include/core/SkImage.h" -#include "hilog/log.h" #include "hitrace_meter.h" -#include "log_tags.h" #include "media_errors.h" #include "pubdef.h" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "PixelAstc" + namespace OHOS { namespace Media { -using namespace OHOS::HiviewDFX; using namespace std; -constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "PixelAstc" }; PixelAstc::~PixelAstc() { - HiLog::Info(LABEL, "PixelAstc destory"); + IMAGE_LOGI("PixelAstc destory"); FreePixelMap(); } const uint8_t *PixelAstc::GetPixel8(int32_t x, int32_t y) { - HiLog::Error(LABEL, "GetPixel8 is not support on pixelastc"); + IMAGE_LOGE("GetPixel8 is not support on pixelastc"); return nullptr; } const uint16_t *PixelAstc::GetPixel16(int32_t x, int32_t y) { - HiLog::Error(LABEL, "GetPixel16 is not support on pixelastc"); + IMAGE_LOGE("GetPixel16 is not support on pixelastc"); return nullptr; } const uint32_t *PixelAstc::GetPixel32(int32_t x, int32_t y) { - HiLog::Error(LABEL, "GetPixel32 is not support on pixelastc"); + IMAGE_LOGE("GetPixel32 is not support on pixelastc"); return nullptr; } bool PixelAstc::GetARGB32Color(int32_t x, int32_t y, uint32_t &color) { - HiLog::Error(LABEL, "GetARGB32Color is not support on pixelastc"); + IMAGE_LOGE("GetARGB32Color is not support on pixelastc"); return false; } void PixelAstc::scale(float xAxis, float yAxis) { if (xAxis == 0 || yAxis == 0) { - HiLog::Error(LABEL, "scale param incorrect on pixelastc"); + IMAGE_LOGE("scale param incorrect on pixelastc"); return; } else { TransformData transformData; @@ -85,7 +88,7 @@ void PixelAstc::scale(float xAxis, float yAxis) bool PixelAstc::resize(float xAxis, float yAxis) { - HiLog::Error(LABEL, "resize is not support on pixelastc"); + IMAGE_LOGE("resize is not support on pixelastc"); return false; } @@ -133,7 +136,7 @@ uint32_t PixelAstc::crop(const Rect &rect) imageInfo.size.height = rect.height; SetImageInfo(imageInfo, true); } else { - HiLog::Error(LABEL, "crop failed"); + IMAGE_LOGE("crop failed"); return ERR_IMAGE_CROP; } return SUCCESS; @@ -141,127 +144,127 @@ uint32_t PixelAstc::crop(const Rect &rect) uint32_t PixelAstc::SetAlpha(const float percent) { - HiLog::Error(LABEL, "SetAlpha is not support on pixelastc"); + IMAGE_LOGE("SetAlpha is not support on pixelastc"); return ERR_IMAGE_DATA_UNSUPPORT; } uint8_t PixelAstc::GetARGB32ColorA(uint32_t color) { - HiLog::Error(LABEL, "GetARGB32ColorA is not support on pixelastc"); + IMAGE_LOGE("GetARGB32ColorA is not support on pixelastc"); return 0; } uint8_t PixelAstc::GetARGB32ColorR(uint32_t color) { - HiLog::Error(LABEL, "GetARGB32ColorR is not support on pixelastc"); + IMAGE_LOGE("GetARGB32ColorR is not support on pixelastc"); return 0; } uint8_t PixelAstc::GetARGB32ColorG(uint32_t color) { - HiLog::Error(LABEL, "GetARGB32ColorG is not support on pixelastc"); + IMAGE_LOGE("GetARGB32ColorG is not support on pixelastc"); return 0; } uint8_t PixelAstc::GetARGB32ColorB(uint32_t color) { - HiLog::Error(LABEL, "GetARGB32ColorB is not support on pixelastc"); + IMAGE_LOGE("GetARGB32ColorB is not support on pixelastc"); return 0; } bool PixelAstc::IsSameImage(const PixelMap &other) { - HiLog::Error(LABEL, "IsSameImage is not support on pixelastc"); + IMAGE_LOGE("IsSameImage is not support on pixelastc"); return false; } uint32_t PixelAstc::ReadPixels(const uint64_t &bufferSize, const uint32_t &offset, const uint32_t &stride, const Rect ®ion, uint8_t *dst) { - HiLog::Error(LABEL, "ReadPixels is not support on pixelastc"); + IMAGE_LOGE("ReadPixels is not support on pixelastc"); return ERR_IMAGE_INVALID_PARAMETER; } uint32_t PixelAstc::ReadPixels(const uint64_t &bufferSize, uint8_t *dst) { - HiLog::Error(LABEL, "ReadPixels is not support on pixelastc"); + IMAGE_LOGE("ReadPixels is not support on pixelastc"); return ERR_IMAGE_INVALID_PARAMETER; } uint32_t PixelAstc::ReadPixel(const Position &pos, uint32_t &dst) { - HiLog::Error(LABEL, "ReadPixel is not support on pixelastc"); + IMAGE_LOGE("ReadPixel is not support on pixelastc"); return ERR_IMAGE_INVALID_PARAMETER; } uint32_t PixelAstc::ResetConfig(const Size &size, const PixelFormat &format) { - HiLog::Error(LABEL, "ResetConfig is not support on pixelastc"); + IMAGE_LOGE("ResetConfig is not support on pixelastc"); return ERR_IMAGE_INVALID_PARAMETER; } bool PixelAstc::SetAlphaType(const AlphaType &alphaType) { - HiLog::Error(LABEL, "SetAlphaType is not support on pixelastc"); + IMAGE_LOGE("SetAlphaType is not support on pixelastc"); return false; } uint32_t PixelAstc::WritePixel(const Position &pos, const uint32_t &color) { - HiLog::Error(LABEL, "WritePixel is not support on pixelastc"); + IMAGE_LOGE("WritePixel is not support on pixelastc"); return ERR_IMAGE_INVALID_PARAMETER; } uint32_t PixelAstc::WritePixels(const uint8_t *source, const uint64_t &bufferSize, const uint32_t &offset, const uint32_t &stride, const Rect ®ion) { - HiLog::Error(LABEL, "WritePixels is not support on pixelastc"); + IMAGE_LOGE("WritePixels is not support on pixelastc"); return ERR_IMAGE_INVALID_PARAMETER; } uint32_t PixelAstc::WritePixels(const uint8_t *source, const uint64_t &bufferSize) { - HiLog::Error(LABEL, "WritePixels is not support on pixelastc"); + IMAGE_LOGE("WritePixels is not support on pixelastc"); return ERR_IMAGE_INVALID_PARAMETER; } bool PixelAstc::WritePixels(const uint32_t &color) { - HiLog::Error(LABEL, "WritePixels is not support on pixelastc"); + IMAGE_LOGE("WritePixels is not support on pixelastc"); return false; } void PixelAstc::SetTransformered(bool isTransformered) { - HiLog::Error(LABEL, "SetTransformered is not support on pixelastc"); + IMAGE_LOGE("SetTransformered is not support on pixelastc"); } bool PixelAstc::IsTransformered() { - HiLog::Error(LABEL, "IsTransformered is not support on pixelastc"); + IMAGE_LOGE("IsTransformered is not support on pixelastc"); return false; } void PixelAstc::SetRowStride(uint32_t stride) { - HiLog::Error(LABEL, "SetRowStride is not support on pixelastc"); + IMAGE_LOGE("SetRowStride is not support on pixelastc"); } int32_t PixelAstc::GetRowStride() { - HiLog::Error(LABEL, "GetRowStride is not support on pixelastc"); + IMAGE_LOGE("GetRowStride is not support on pixelastc"); return 0; } bool PixelAstc::IsSourceAsResponse() { - HiLog::Error(LABEL, "IsSourceAsResponse is not support on pixelastc"); + IMAGE_LOGE("IsSourceAsResponse is not support on pixelastc"); return false; } void* PixelAstc::GetWritablePixels() const { - HiLog::Error(LABEL, "GetWritablePixels is not support on pixelastc"); + IMAGE_LOGE("GetWritablePixels is not support on pixelastc"); return nullptr; } } // namespace Media diff --git a/frameworks/innerkitsimpl/common/src/pixel_map.cpp b/frameworks/innerkitsimpl/common/src/pixel_map.cpp index 87b6d4d2f..b0cfaacb5 100644 --- a/frameworks/innerkitsimpl/common/src/pixel_map.cpp +++ b/frameworks/innerkitsimpl/common/src/pixel_map.cpp @@ -17,6 +17,7 @@ #include #include +#include "image_log.h" #include "image_system_properties.h" #include "image_trace.h" #include "image_type_converter.h" @@ -25,9 +26,7 @@ #include "include/core/SkBitmap.h" #include "include/core/SkCanvas.h" #include "include/core/SkImage.h" -#include "hilog/log.h" #include "hitrace_meter.h" -#include "log_tags.h" #include "media_errors.h" #include "pixel_convert_adapter.h" #include "pixel_map_utils.h" @@ -54,11 +53,15 @@ #include "surface_buffer.h" #endif +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "PixelMap" + namespace OHOS { namespace Media { -using namespace OHOS::HiviewDFX; using namespace std; -constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "PixelMap" }; constexpr int32_t MAX_DIMENSION = INT32_MAX >> 2; constexpr uint8_t FOUR_BYTE_SHIFT = 2; constexpr int8_t INVALID_ALPHA_INDEX = -1; @@ -84,7 +87,7 @@ std::atomic PixelMap::currentId = 0; PixelMap::~PixelMap() { - HiLog::Debug(LABEL, "PixelMap::~PixelMap_id:%{public}d", GetUniqueId()); + IMAGE_LOGD("PixelMap::~PixelMap_id:%{public}d", GetUniqueId()); FreePixelMap(); } @@ -136,7 +139,7 @@ void PixelMap::FreePixelMap() __attribute__((no_sanitize("cfi"))) break; } default: { - HiLog::Error(LABEL, "unknown allocator type:[%{public}d].", allocatorType_); + IMAGE_LOGE("unknown allocator type:[%{public}d].", allocatorType_); return; } } @@ -170,11 +173,11 @@ void PixelMap::SetTransformered(bool isTransformered) void PixelMap::SetPixelsAddr(void *addr, void *context, uint32_t size, AllocatorType type, CustomFreePixelMap func) { if (data_ != nullptr) { - HiLog::Debug(LABEL, "SetPixelsAddr release the existed data first"); + IMAGE_LOGD("SetPixelsAddr release the existed data first"); FreePixelMap(); } if (type == AllocatorType::SHARE_MEM_ALLOC && context == nullptr) { - HiLog::Error(LABEL, "SetPixelsAddr error type %{public}d ", type); + IMAGE_LOGE("SetPixelsAddr error type %{public}d ", type); } data_ = static_cast(addr); context_ = context; @@ -189,13 +192,13 @@ void PixelMap::SetPixelsAddr(void *addr, void *context, uint32_t size, Allocator bool CheckPixelmap(std::unique_ptr &pixelMap, ImageInfo &imageInfo) { if (pixelMap->SetImageInfo(imageInfo) != SUCCESS) { - HiLog::Error(LABEL, "set image info fail"); + IMAGE_LOGE("set image info fail"); return false; } uint32_t bufferSize = pixelMap->GetByteCount(); if (bufferSize == 0 || (pixelMap->GetAllocatorType() == AllocatorType::HEAP_ALLOC && bufferSize > PIXEL_MAP_MAX_RAM_SIZE)) { - HiLog::Error(LABEL, "AllocSharedMemory parameter is zero"); + IMAGE_LOGE("AllocSharedMemory parameter is zero"); return false; } return true; @@ -203,14 +206,14 @@ bool CheckPixelmap(std::unique_ptr &pixelMap, ImageInfo &imageInfo) unique_ptr PixelMap::Create(const uint32_t *colors, uint32_t colorLength, const InitializationOptions &opts) { - HiLog::Debug(LABEL, "PixelMap::Create1 enter"); + IMAGE_LOGD("PixelMap::Create1 enter"); return Create(colors, colorLength, 0, opts.size.width, opts); } unique_ptr PixelMap::Create(const uint32_t *colors, uint32_t colorLength, int32_t offset, int32_t stride, const InitializationOptions &opts) { - HiLog::Debug(LABEL, "PixelMap::Create2 enter"); + IMAGE_LOGD("PixelMap::Create2 enter"); return Create(colors, colorLength, 0, opts.size.width, opts, false); } @@ -270,7 +273,7 @@ unique_ptr PixelMap::Create(const uint32_t *colors, uint32_t colorLeng uint32_t bufferSize = dstPixelMap->GetByteCount(); void *dstPixels = AllocSharedMemory(bufferSize, fd, dstPixelMap->GetUniqueId()); if (dstPixels == nullptr) { - HiLog::Error(LABEL, "allocate memory size %{public}u fail", bufferSize); + IMAGE_LOGE("allocate memory size %{public}u fail", bufferSize); errorCode = IMAGE_RESULT_ERR_SHAMEM_NOT_EXIST; return nullptr; } @@ -278,7 +281,7 @@ unique_ptr PixelMap::Create(const uint32_t *colors, uint32_t colorLeng if (!PixelConvertAdapter::WritePixelsConvert(reinterpret_cast(colors + offset), static_cast(stride) << FOUR_BYTE_SHIFT, srcImageInfo, dstPixels, dstPosition, dstPixelMap->GetRowBytes(), dstImageInfo)) { - HiLog::Error(LABEL, "pixel convert in adapter failed."); + IMAGE_LOGE("pixel convert in adapter failed."); ReleaseBuffer(AllocatorType::SHARE_MEM_ALLOC, fd, bufferSize, &dstPixels); dstPixels = nullptr; errorCode = IMAGE_RESULT_THIRDPART_SKIA_ERROR; @@ -317,18 +320,18 @@ void *PixelMap::AllocSharedMemory(const uint64_t bufferSize, int &fd, uint32_t u std::string name = "PixelMap RawData, uniqueId: " + std::to_string(getpid()) + '_' + std::to_string(uniqueId); fd = AshmemCreate(name.c_str(), bufferSize); if (fd < 0) { - HiLog::Error(LABEL, "AllocSharedMemory fd error"); + IMAGE_LOGE("AllocSharedMemory fd error"); return nullptr; } int result = AshmemSetProt(fd, PROT_READ | PROT_WRITE); if (result < 0) { - HiLog::Error(LABEL, "AshmemSetProt error"); + IMAGE_LOGE("AshmemSetProt error"); ::close(fd); return nullptr; } void* ptr = ::mmap(nullptr, bufferSize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if (ptr == MAP_FAILED) { - HiLog::Error(LABEL, "mmap error, errno: %{public}s, fd %{public}d, bufferSize %{public}lld", + IMAGE_LOGE("mmap error, errno: %{public}s, fd %{public}d, bufferSize %{public}lld", strerror(errno), fd, (long long)bufferSize); ::close(fd); return nullptr; @@ -343,27 +346,27 @@ bool PixelMap::CheckParams(const uint32_t *colors, uint32_t colorLength, int32_t const InitializationOptions &opts) { if (colors == nullptr || colorLength <= 0) { - HiLog::Error(LABEL, "colors invalid"); + IMAGE_LOGE("colors invalid"); return false; } int32_t dstWidth = opts.size.width; int32_t dstHeight = opts.size.height; if (dstWidth <= 0 || dstHeight <= 0) { - HiLog::Error(LABEL, "initial options size invalid"); + IMAGE_LOGE("initial options size invalid"); return false; } if (stride < dstWidth) { - HiLog::Error(LABEL, "stride: %{public}d must >= width: %{public}d", stride, dstWidth); + IMAGE_LOGE("stride: %{public}d must >= width: %{public}d", stride, dstWidth); return false; } if (stride > MAX_DIMENSION) { - HiLog::Error(LABEL, "stride %{public}d is out of range", stride); + IMAGE_LOGE("stride %{public}d is out of range", stride); return false; } int64_t lastLine = static_cast(dstHeight - 1) * stride + offset; if (offset < 0 || static_cast(offset) + dstWidth > colorLength || lastLine + dstWidth > colorLength) { - HiLog::Error(LABEL, "colors length: %{public}u, offset: %{public}d, stride: %{public}d is invalid", - colorLength, offset, stride); + IMAGE_LOGE("colors length: %{public}u, offset: %{public}d, stride: %{public}d is invalid", + colorLength, offset, stride); return false; } return true; @@ -371,10 +374,10 @@ bool PixelMap::CheckParams(const uint32_t *colors, uint32_t colorLength, int32_t unique_ptr PixelMap::Create(const InitializationOptions &opts) { - HiLog::Debug(LABEL, "PixelMap::Create3 enter"); + IMAGE_LOGD("PixelMap::Create3 enter"); unique_ptr dstPixelMap = make_unique(); if (dstPixelMap == nullptr) { - HiLog::Error(LABEL, "create pixelMap pointer fail"); + IMAGE_LOGE("create pixelMap pointer fail"); return nullptr; } PixelFormat dstPixelFormat = (opts.pixelFormat == PixelFormat::UNKNOWN ? PixelFormat::RGBA_8888 : opts.pixelFormat); @@ -383,18 +386,18 @@ unique_ptr PixelMap::Create(const InitializationOptions &opts) dstAlphaType = ImageUtils::GetValidAlphaTypeByFormat(dstAlphaType, dstPixelFormat); ImageInfo dstImageInfo = MakeImageInfo(opts.size.width, opts.size.height, dstPixelFormat, dstAlphaType); if (dstPixelMap->SetImageInfo(dstImageInfo) != SUCCESS) { - HiLog::Error(LABEL, "set image info fail"); + IMAGE_LOGE("set image info fail"); return nullptr; } uint32_t bufferSize = dstPixelMap->GetByteCount(); if (bufferSize == 0) { - HiLog::Error(LABEL, "calloc parameter bufferSize:[%{public}d] error.", bufferSize); + IMAGE_LOGE("calloc parameter bufferSize:[%{public}d] error.", bufferSize); return nullptr; } int fd = 0; void *dstPixels = AllocSharedMemory(bufferSize, fd, dstPixelMap->GetUniqueId()); if (dstPixels == nullptr) { - HiLog::Error(LABEL, "allocate memory size %{public}u fail", bufferSize); + IMAGE_LOGE("allocate memory size %{public}u fail", bufferSize); return nullptr; } // update alpha opaque @@ -435,7 +438,7 @@ void PixelMap::UpdatePixelsAlpha(const AlphaType &alphaType, const PixelFormat & unique_ptr PixelMap::Create(PixelMap &source, const InitializationOptions &opts) { - HiLog::Debug(LABEL, "PixelMap::Create4 enter"); + IMAGE_LOGD("PixelMap::Create4 enter"); Rect rect; return Create(source, rect, opts); } @@ -451,7 +454,7 @@ static int32_t BuildPixelMap(unique_ptr &dstPixelMap, CropValue &cropT { dstPixelMap = make_unique(); if (dstPixelMap == nullptr) { - HiLog::Error(LABEL, "create pixelmap pointer fail"); + IMAGE_LOGE("create pixelmap pointer fail"); return IMAGE_RESULT_PLUGIN_REGISTER_FAILED; } @@ -470,14 +473,14 @@ static int32_t BuildPixelMap(unique_ptr &dstPixelMap, CropValue &cropT unique_ptr PixelMap::Create(PixelMap &source, const Rect &srcRect, const InitializationOptions &opts, int32_t &errorCode) { - HiLog::Debug(LABEL, "PixelMap::Create5 enter"); + IMAGE_LOGD("PixelMap::Create5 enter"); ImageInfo srcImageInfo; source.GetImageInfo(srcImageInfo); PostProc postProc; Rect sRect = srcRect; CropValue cropType = PostProc::ValidCropValue(sRect, srcImageInfo.size); if (cropType == CropValue::INVALID) { - HiLog::Error(LABEL, "src crop range is invalid"); + IMAGE_LOGE("src crop range is invalid"); errorCode = IMAGE_RESULT_DECODE_FAILED; return nullptr; } @@ -521,7 +524,7 @@ bool PixelMap::SourceCropAndConvert(PixelMap &source, const ImageInfo &srcImageI uint32_t bufferSize = dstPixelMap.GetByteCount(); if (bufferSize == 0 || (source.GetAllocatorType() == AllocatorType::HEAP_ALLOC && bufferSize > PIXEL_MAP_MAX_RAM_SIZE)) { - HiLog::Error(LABEL, "SourceCropAndConvert parameter bufferSize:[%{public}d] error.", bufferSize); + IMAGE_LOGE("SourceCropAndConvert parameter bufferSize:[%{public}d] error.", bufferSize); return false; } int fd = 0; @@ -532,17 +535,17 @@ bool PixelMap::SourceCropAndConvert(PixelMap &source, const ImageInfo &srcImageI dstPixels = malloc(bufferSize); } if (dstPixels == nullptr) { - HiLog::Error(LABEL, "source crop allocate memory fail allocatetype: %{public}d ", source.GetAllocatorType()); + IMAGE_LOGE("source crop allocate memory fail allocatetype: %{public}d ", source.GetAllocatorType()); return false; } if (memset_s(dstPixels, bufferSize, 0, bufferSize) != EOK) { - HiLog::Error(LABEL, "dstPixels memset_s failed."); + IMAGE_LOGE("dstPixels memset_s failed."); } Position srcPosition { srcRect.left, srcRect.top }; if (!PixelConvertAdapter::ReadPixelsConvert(source.GetPixels(), srcPosition, source.GetRowStride(), srcImageInfo, dstPixels, dstPixelMap.GetRowStride(), dstImageInfo)) { - HiLog::Error(LABEL, "pixel convert in adapter failed."); + IMAGE_LOGE("pixel convert in adapter failed."); ReleaseBuffer(fd > 0 ? AllocatorType::SHARE_MEM_ALLOC : AllocatorType::HEAP_ALLOC, fd, bufferSize, &dstPixels); return false; } @@ -570,13 +573,13 @@ bool PixelMap::ScalePixelMap(const Size &targetSize, const Size &dstSize, const PostProc postProc; if (scaleMode == ScaleMode::FIT_TARGET_SIZE) { if (!postProc.ScalePixelMap(targetSize, dstPixelMap)) { - HiLog::Error(LABEL, "scale FIT_TARGET_SIZE fail"); + IMAGE_LOGE("scale FIT_TARGET_SIZE fail"); return false; } } if (scaleMode == ScaleMode::CENTER_CROP) { if (!postProc.CenterScale(targetSize, dstPixelMap)) { - HiLog::Error(LABEL, "scale CENTER_CROP fail"); + IMAGE_LOGE("scale CENTER_CROP fail"); return false; } } @@ -609,7 +612,7 @@ bool PixelMap::CopyPixMapToDst(PixelMap &source, void* &dstPixels, int &fd, uint errno_t ret = memcpy_s(dstPixels, source.GetRowBytes(), source.GetPixels() + i * source.GetRowStride(), source.GetRowBytes()); if (ret != 0) { - HiLog::Error(LABEL, "copy source memory size %{public}u fail", bufferSize); + IMAGE_LOGE("copy source memory size %{public}u fail", bufferSize); ReleaseBuffer(AllocatorType::DMA_ALLOC, fd, bufferSize, &dstPixels); return false; } @@ -618,7 +621,7 @@ bool PixelMap::CopyPixMapToDst(PixelMap &source, void* &dstPixels, int &fd, uint } } else { if (memcpy_s(dstPixels, bufferSize, source.GetPixels(), bufferSize) != 0) { - HiLog::Error(LABEL, "copy source memory size %{public}u fail", bufferSize); + IMAGE_LOGE("copy source memory size %{public}u fail", bufferSize); ReleaseBuffer(fd > 0 ? AllocatorType::SHARE_MEM_ALLOC : AllocatorType::HEAP_ALLOC, fd, bufferSize, &dstPixels); return false; @@ -636,13 +639,13 @@ bool PixelMap::CopyPixelMap(PixelMap &source, PixelMap &dstPixelMap, int32_t &er { uint32_t bufferSize = source.GetByteCount(); if (source.GetPixels() == nullptr) { - HiLog::Error(LABEL, "source pixelMap data invalid"); + IMAGE_LOGE("source pixelMap data invalid"); error = IMAGE_RESULT_GET_DATA_ABNORMAL; return false; } if (bufferSize == 0 || (source.GetAllocatorType() == AllocatorType::HEAP_ALLOC && bufferSize > PIXEL_MAP_MAX_RAM_SIZE)) { - HiLog::Error(LABEL, "AllocSharedMemory parameter bufferSize:[%{public}d] error.", bufferSize); + IMAGE_LOGE("AllocSharedMemory parameter bufferSize:[%{public}d] error.", bufferSize); error = IMAGE_RESULT_DATA_ABNORMAL; return false; } @@ -654,7 +657,7 @@ bool PixelMap::CopyPixelMap(PixelMap &source, PixelMap &dstPixelMap, int32_t &er dstPixels = malloc(bufferSize); } if (dstPixels == nullptr) { - HiLog::Error(LABEL, "source crop allocate memory fail allocatetype: %{public}d ", source.GetAllocatorType()); + IMAGE_LOGE("source crop allocate memory fail allocatetype: %{public}d ", source.GetAllocatorType()); error = IMAGE_RESULT_MALLOC_ABNORMAL; return false; } @@ -732,7 +735,7 @@ bool PixelMap::GetPixelFormatDetail(const PixelFormat format) pixelBytes_ = ASTC_4x4_BYTES; break; default: { - HiLog::Error(LABEL, "pixel format:[%{public}d] not supported.", format); + IMAGE_LOGE("pixel format:[%{public}d] not supported.", format); return false; } } @@ -759,7 +762,7 @@ uint32_t PixelMap::SetRowDataSizeForImageInfo(ImageInfo info) if (info.pixelFormat == PixelFormat::ALPHA_8) { rowDataSize_ = pixelBytes_ * ((info.size.width + FILL_NUMBER) / ALIGN_NUMBER * ALIGN_NUMBER); SetRowStride(rowDataSize_); - HiLog::Info(LABEL, "ALPHA_8 rowDataSize_ %{public}d.", rowDataSize_); + IMAGE_LOGI("ALPHA_8 rowDataSize_ %{public}d.", rowDataSize_); } else if (info.pixelFormat == PixelFormat::ASTC_4x4) { rowDataSize_ = pixelBytes_ * (((info.size.width + NUM_3) >> NUM_2) << NUM_2); } else if (info.pixelFormat == PixelFormat::ASTC_6x6) { @@ -770,7 +773,7 @@ uint32_t PixelMap::SetRowDataSizeForImageInfo(ImageInfo info) #if !defined(IOS_PLATFORM) && !defined(A_PLATFORM) if (allocatorType_ == AllocatorType::DMA_ALLOC) { if (context_ == nullptr) { - HiLog::Error(LABEL, "set imageInfo failed, context_ is null"); + IMAGE_LOGE("set imageInfo failed, context_ is null"); return ERR_IMAGE_DATA_ABNORMAL; } SurfaceBuffer* sbBuffer = reinterpret_cast(context_); @@ -789,7 +792,7 @@ uint32_t PixelMap::SetRowDataSizeForImageInfo(ImageInfo info) uint32_t PixelMap::SetImageInfo(ImageInfo &info, bool isReused) { if (info.size.width <= 0 || info.size.height <= 0) { - HiLog::Error(LABEL, "pixel map image info invalid."); + IMAGE_LOGE("pixel map image info invalid."); return ERR_IMAGE_DATA_ABNORMAL; } if (!GetPixelFormatDetail(info.pixelFormat)) { @@ -798,26 +801,26 @@ uint32_t PixelMap::SetImageInfo(ImageInfo &info, bool isReused) if (pixelBytes_ <= 0) { ResetPixelMap(); - HiLog::Error(LABEL, "pixel map bytes is invalid."); + IMAGE_LOGE("pixel map bytes is invalid."); return ERR_IMAGE_DATA_ABNORMAL; } if (allocatorType_ == AllocatorType::HEAP_ALLOC && ((static_cast(pixelBytes_) * info.size.width * info.size.height) > PIXEL_MAP_MAX_RAM_SIZE)) { ResetPixelMap(); - HiLog::Error(LABEL, "image size is out of range."); + IMAGE_LOGE("image size is out of range."); return ERR_IMAGE_TOO_LARGE; } if (SetRowDataSizeForImageInfo(info) != SUCCESS) { - HiLog::Error(LABEL, "pixel map set rowDataSize error."); + IMAGE_LOGE("pixel map set rowDataSize error."); return ERR_IMAGE_DATA_ABNORMAL; } if (rowDataSize_ != 0 && allocatorType_ == AllocatorType::HEAP_ALLOC && info.size.height > (PIXEL_MAP_MAX_RAM_SIZE / rowDataSize_)) { ResetPixelMap(); - HiLog::Error(LABEL, "pixel map byte count out of range."); + IMAGE_LOGE("pixel map byte count out of range."); return ERR_IMAGE_TOO_LARGE; } if (!isReused) { @@ -830,8 +833,8 @@ uint32_t PixelMap::SetImageInfo(ImageInfo &info, bool isReused) const uint8_t *PixelMap::GetPixel8(int32_t x, int32_t y) { if (!CheckValidParam(x, y) || (pixelBytes_ != ALPHA_8_BYTES)) { - HiLog::Error(LABEL, "get addr8 pixel position:(%{public}d, %{public}d) pixel bytes:%{public}d invalid.", x, y, - pixelBytes_); + IMAGE_LOGE("get addr8 pixel position:(%{public}d, %{public}d) pixel bytes:%{public}d invalid.", x, y, + pixelBytes_); return nullptr; } #if !defined(IOS_PLATFORM) && !defined(A_PLATFORM) @@ -844,8 +847,8 @@ const uint8_t *PixelMap::GetPixel8(int32_t x, int32_t y) const uint16_t *PixelMap::GetPixel16(int32_t x, int32_t y) { if (!CheckValidParam(x, y) || (pixelBytes_ != RGB_565_BYTES)) { - HiLog::Error(LABEL, "get addr16 pixel position:(%{public}d, %{public}d) pixel bytes:%{public}d invalid.", x, y, - pixelBytes_); + IMAGE_LOGE("get addr16 pixel position:(%{public}d, %{public}d) pixel bytes:%{public}d invalid.", x, y, + pixelBytes_); return nullptr; } // convert uint8_t* to uint16_t* @@ -859,8 +862,8 @@ const uint16_t *PixelMap::GetPixel16(int32_t x, int32_t y) const uint32_t *PixelMap::GetPixel32(int32_t x, int32_t y) { if (!CheckValidParam(x, y) || (pixelBytes_ != ARGB_8888_BYTES)) { - HiLog::Error(LABEL, "get addr32 pixel position:(%{public}d, %{public}d) pixel bytes:%{public}d invalid.", x, y, - pixelBytes_); + IMAGE_LOGE("get addr32 pixel position:(%{public}d, %{public}d) pixel bytes:%{public}d invalid.", x, y, + pixelBytes_); return nullptr; } // convert uint8_t* to uint32_t* @@ -874,7 +877,7 @@ const uint32_t *PixelMap::GetPixel32(int32_t x, int32_t y) const uint8_t *PixelMap::GetPixel(int32_t x, int32_t y) { if (!CheckValidParam(x, y)) { - HiLog::Error(LABEL, "input pixel position:(%{public}d, %{public}d) invalid.", x, y); + IMAGE_LOGE("input pixel position:(%{public}d, %{public}d) invalid.", x, y); return nullptr; } #if !defined(IOS_PLATFORM) && !defined(A_PLATFORM) @@ -887,12 +890,12 @@ const uint8_t *PixelMap::GetPixel(int32_t x, int32_t y) bool PixelMap::GetARGB32Color(int32_t x, int32_t y, uint32_t &color) { if (colorProc_ == nullptr) { - HiLog::Error(LABEL, "pixel format not supported."); + IMAGE_LOGE("pixel format not supported."); return false; } const uint8_t *src = GetPixel(x, y); if (src == nullptr) { - HiLog::Error(LABEL, "get pixel color error."); + IMAGE_LOGE("get pixel color error."); return false; } // use founction point for frequently called interface @@ -902,7 +905,7 @@ bool PixelMap::GetARGB32Color(int32_t x, int32_t y, uint32_t &color) bool PixelMap::ALPHA8ToARGB(const uint8_t *in, uint32_t inCount, uint32_t *out, uint32_t outCount) { if (inCount != outCount) { - HiLog::Error(LABEL, "input count:%{public}u is not match to output count:%{public}u.", inCount, outCount); + IMAGE_LOGE("input count:%{public}u is not match to output count:%{public}u.", inCount, outCount); return false; } const uint8_t *src = in; @@ -915,7 +918,7 @@ bool PixelMap::ALPHA8ToARGB(const uint8_t *in, uint32_t inCount, uint32_t *out, bool PixelMap::RGB565ToARGB(const uint8_t *in, uint32_t inCount, uint32_t *out, uint32_t outCount) { if (((inCount / RGB_565_BYTES) != outCount) && ((inCount % RGB_565_BYTES) != 0)) { - HiLog::Error(LABEL, "input count:%{public}u is not match to output count:%{public}u.", inCount, outCount); + IMAGE_LOGE("input count:%{public}u is not match to output count:%{public}u.", inCount, outCount); return false; } const uint16_t *src = reinterpret_cast(in); @@ -929,7 +932,7 @@ bool PixelMap::RGB565ToARGB(const uint8_t *in, uint32_t inCount, uint32_t *out, bool PixelMap::ARGB8888ToARGB(const uint8_t *in, uint32_t inCount, uint32_t *out, uint32_t outCount) { if (((inCount / ARGB_8888_BYTES) != outCount) && ((inCount % ARGB_8888_BYTES) != 0)) { - HiLog::Error(LABEL, "input count:%{public}u is not match to output count:%{public}u.", inCount, outCount); + IMAGE_LOGE("input count:%{public}u is not match to output count:%{public}u.", inCount, outCount); return false; } const uint32_t *src = reinterpret_cast(in); @@ -944,7 +947,7 @@ bool PixelMap::ARGB8888ToARGB(const uint8_t *in, uint32_t inCount, uint32_t *out bool PixelMap::RGBA8888ToARGB(const uint8_t *in, uint32_t inCount, uint32_t *out, uint32_t outCount) { if (((inCount / ARGB_8888_BYTES) != outCount) && ((inCount % ARGB_8888_BYTES) != 0)) { - HiLog::Error(LABEL, "input count:%{public}u is not match to output count:%{public}u.", inCount, outCount); + IMAGE_LOGE("input count:%{public}u is not match to output count:%{public}u.", inCount, outCount); return false; } const uint32_t *src = reinterpret_cast(in); @@ -959,7 +962,7 @@ bool PixelMap::RGBA8888ToARGB(const uint8_t *in, uint32_t inCount, uint32_t *out bool PixelMap::BGRA8888ToARGB(const uint8_t *in, uint32_t inCount, uint32_t *out, uint32_t outCount) { if (((inCount / ARGB_8888_BYTES) != outCount) && ((inCount % ARGB_8888_BYTES) != 0)) { - HiLog::Error(LABEL, "input count:%{public}u is not match to output count:%{public}u.", inCount, outCount); + IMAGE_LOGE("input count:%{public}u is not match to output count:%{public}u.", inCount, outCount); return false; } const uint32_t *src = reinterpret_cast(in); @@ -974,7 +977,7 @@ bool PixelMap::BGRA8888ToARGB(const uint8_t *in, uint32_t inCount, uint32_t *out bool PixelMap::RGB888ToARGB(const uint8_t *in, uint32_t inCount, uint32_t *out, uint32_t outCount) { if (((inCount / RGB_888_BYTES) != outCount) && ((inCount % RGB_888_BYTES) != 0)) { - HiLog::Error(LABEL, "input count:%{public}u is not match to output count:%{public}u.", inCount, outCount); + IMAGE_LOGE("input count:%{public}u is not match to output count:%{public}u.", inCount, outCount); return false; } const uint8_t *src = in; @@ -999,7 +1002,7 @@ int32_t PixelMap::GetRowBytes() int32_t PixelMap::GetByteCount() { - HiLog::Debug(LABEL, "GetByteCount"); + IMAGE_LOGD("GetByteCount"); return rowDataSize_ * imageInfo_.size.height; } @@ -1076,18 +1079,18 @@ uint8_t PixelMap::GetARGB32ColorB(uint32_t color) bool PixelMap::IsSameImage(const PixelMap &other) { if (data_ == nullptr || other.data_ == nullptr) { - HiLog::Error(LABEL, "IsSameImage data_ is nullptr."); + IMAGE_LOGE("IsSameImage data_ is nullptr."); return false; } if (imageInfo_.size.width != other.imageInfo_.size.width || imageInfo_.size.height != other.imageInfo_.size.height || imageInfo_.pixelFormat != other.imageInfo_.pixelFormat || imageInfo_.alphaType != other.imageInfo_.alphaType) { - HiLog::Info(LABEL, "IsSameImage imageInfo is not same"); + IMAGE_LOGI("IsSameImage imageInfo is not same"); return false; } uint64_t size = static_cast(rowDataSize_) * imageInfo_.size.height; if (memcmp(data_, other.data_, size) != 0) { - HiLog::Info(LABEL, "IsSameImage memcmp is not same"); + IMAGE_LOGI("IsSameImage memcmp is not same"); return false; } return true; @@ -1097,16 +1100,16 @@ uint32_t PixelMap::ReadPixels(const uint64_t &bufferSize, uint8_t *dst) { ImageTrace imageTrace("ReadPixels by bufferSize"); if (dst == nullptr) { - HiLog::Error(LABEL, "read pixels by buffer input dst address is null."); + IMAGE_LOGE("read pixels by buffer input dst address is null."); return ERR_IMAGE_READ_PIXELMAP_FAILED; } if (data_ == nullptr) { - HiLog::Error(LABEL, "read pixels by buffer current PixelMap data is null."); + IMAGE_LOGE("read pixels by buffer current PixelMap data is null."); return ERR_IMAGE_READ_PIXELMAP_FAILED; } if (bufferSize < static_cast(pixelsSize_)) { - HiLog::Error(LABEL, "read pixels by buffer input dst buffer(%{public}llu) < current pixelmap size(%{public}u).", - static_cast(bufferSize), pixelsSize_); + IMAGE_LOGE("read pixels by buffer input dst buffer(%{public}llu) < current pixelmap size(%{public}u).", + static_cast(bufferSize), pixelsSize_); return ERR_IMAGE_INVALID_PARAMETER; } @@ -1114,7 +1117,7 @@ uint32_t PixelMap::ReadPixels(const uint64_t &bufferSize, uint8_t *dst) for (int i = 0; i < imageInfo_.size.height; ++i) { errno_t ret = memcpy_s(dst, rowDataSize_, data_ + i * rowStride_, rowDataSize_); if (ret != 0) { - HiLog::Error(LABEL, "read pixels by buffer memcpy the pixelmap data to dst fail, error:%{public}d", ret); + IMAGE_LOGE("read pixels by buffer memcpy the pixelmap data to dst fail, error:%{public}d", ret); return ERR_IMAGE_READ_PIXELMAP_FAILED; } dst += rowDataSize_; // Move the destination buffer pointer to the next row @@ -1126,55 +1129,52 @@ bool PixelMap::CheckPixelsInput(const uint8_t *dst, const uint64_t &bufferSize, const uint32_t &stride, const Rect ®ion) { if (dst == nullptr) { - HiLog::Error(LABEL, "CheckPixelsInput input dst address is null."); + IMAGE_LOGE("CheckPixelsInput input dst address is null."); return false; } if (bufferSize == 0) { - HiLog::Error(LABEL, "CheckPixelsInput input buffer size is 0."); + IMAGE_LOGE("CheckPixelsInput input buffer size is 0."); return false; } if (region.left < 0 || region.top < 0 || stride > numeric_limits::max() || static_cast(offset) > bufferSize) { - HiLog::Error( - LABEL, + IMAGE_LOGE( "CheckPixelsInput left(%{public}d) or top(%{public}d) or stride(%{public}u) or offset(%{public}u) < 0.", region.left, region.top, stride, offset); return false; } if (region.width <= 0 || region.height <= 0 || region.width > MAX_DIMENSION || region.height > MAX_DIMENSION) { - HiLog::Error(LABEL, "CheckPixelsInput width(%{public}d) or height(%{public}d) is < 0.", region.width, - region.height); + IMAGE_LOGE("CheckPixelsInput width(%{public}d) or height(%{public}d) is < 0.", region.width, region.height); return false; } if (region.left > GetWidth() - region.width) { - HiLog::Error(LABEL, "CheckPixelsInput left(%{public}d) + width(%{public}d) is > pixelmap width(%{public}d).", - region.left, region.width, GetWidth()); + IMAGE_LOGE("CheckPixelsInput left(%{public}d) + width(%{public}d) is > pixelmap width(%{public}d).", + region.left, region.width, GetWidth()); return false; } if (region.top > GetHeight() - region.height) { - HiLog::Error(LABEL, "CheckPixelsInput top(%{public}d) + height(%{public}d) is > pixelmap height(%{public}d).", - region.top, region.height, GetHeight()); + IMAGE_LOGE("CheckPixelsInput top(%{public}d) + height(%{public}d) is > pixelmap height(%{public}d).", + region.top, region.height, GetHeight()); return false; } uint32_t regionStride = static_cast(region.width) * 4; // bytes count, need multiply by 4 if (stride < regionStride) { - HiLog::Error(LABEL, "CheckPixelsInput stride(%{public}d) < width*4 (%{public}d).", stride, regionStride); + IMAGE_LOGE("CheckPixelsInput stride(%{public}d) < width*4 (%{public}d).", stride, regionStride); return false; } if (bufferSize < regionStride) { - HiLog::Error(LABEL, "CheckPixelsInput input buffer size is < width * 4."); + IMAGE_LOGE("CheckPixelsInput input buffer size is < width * 4."); return false; } uint64_t lastLinePos = offset + static_cast(region.height - 1) * stride; // "1" is except the last line. if (static_cast(offset) > (bufferSize - regionStride) || lastLinePos > (bufferSize - regionStride)) { - HiLog::Error(LABEL, - "CheckPixelsInput fail, height(%{public}d), width(%{public}d), lastLine(%{public}llu), " - "offset(%{public}u), bufferSize:%{public}llu.", - region.height, region.width, static_cast(lastLinePos), offset, - static_cast(bufferSize)); + IMAGE_LOGE( + "CheckPixelsInput fail, height(%{public}d), width(%{public}d), lastLine(%{public}llu), " + "offset(%{public}u), bufferSize:%{public}llu.", region.height, region.width, + static_cast(lastLinePos), offset, static_cast(bufferSize)); return false; } return true; @@ -1184,11 +1184,11 @@ uint32_t PixelMap::ReadPixels(const uint64_t &bufferSize, const uint32_t &offset const Rect ®ion, uint8_t *dst) { if (!CheckPixelsInput(dst, bufferSize, offset, stride, region)) { - HiLog::Error(LABEL, "read pixels by rect input parameter fail."); + IMAGE_LOGE("read pixels by rect input parameter fail."); return ERR_IMAGE_INVALID_PARAMETER; } if (data_ == nullptr) { - HiLog::Error(LABEL, "read pixels by rect this pixel data is null."); + IMAGE_LOGE("read pixels by rect this pixel data is null."); return ERR_IMAGE_READ_PIXELMAP_FAILED; } ImageInfo dstImageInfo = @@ -1196,7 +1196,7 @@ uint32_t PixelMap::ReadPixels(const uint64_t &bufferSize, const uint32_t &offset Position srcPosition { region.left, region.top }; if (!PixelConvertAdapter::ReadPixelsConvert(data_, srcPosition, rowStride_, imageInfo_, dst + offset, stride, dstImageInfo)) { - HiLog::Error(LABEL, "read pixels by rect call ReadPixelsConvert fail."); + IMAGE_LOGE("read pixels by rect call ReadPixelsConvert fail."); return ERR_IMAGE_READ_PIXELMAP_FAILED; } return SUCCESS; @@ -1205,11 +1205,11 @@ uint32_t PixelMap::ReadPixels(const uint64_t &bufferSize, const uint32_t &offset uint32_t PixelMap::ReadPixel(const Position &pos, uint32_t &dst) { if (pos.x < 0 || pos.y < 0 || pos.x >= GetWidth() || pos.y >= GetHeight()) { - HiLog::Error(LABEL, "read pixel by pos input invalid exception. [x(%{public}d), y(%{public}d)]", pos.x, pos.y); + IMAGE_LOGE("read pixel by pos input invalid exception. [x(%{public}d), y(%{public}d)]", pos.x, pos.y); return ERR_IMAGE_INVALID_PARAMETER; } if (data_ == nullptr) { - HiLog::Error(LABEL, "read pixel by pos source data is null."); + IMAGE_LOGE("read pixel by pos source data is null."); return ERR_IMAGE_READ_PIXELMAP_FAILED; } ImageInfo dstImageInfo = @@ -1218,7 +1218,7 @@ uint32_t PixelMap::ReadPixel(const Position &pos, uint32_t &dst) Position srcPosition { pos.x, pos.y }; if (!PixelConvertAdapter::ReadPixelsConvert(data_, srcPosition, rowStride_, imageInfo_, &dst, dstRowBytes, dstImageInfo)) { - HiLog::Error(LABEL, "read pixel by pos call ReadPixelsConvert fail."); + IMAGE_LOGE("read pixel by pos call ReadPixelsConvert fail."); return ERR_IMAGE_READ_PIXELMAP_FAILED; } return SUCCESS; @@ -1227,30 +1227,30 @@ uint32_t PixelMap::ReadPixel(const Position &pos, uint32_t &dst) uint32_t PixelMap::ResetConfig(const Size &size, const PixelFormat &format) { if (size.width <= 0 || size.height <= 0) { - HiLog::Error(LABEL, "ResetConfig reset input width(%{public}d) or height(%{public}d) is < 0.", size.width, - size.height); + IMAGE_LOGE("ResetConfig reset input width(%{public}d) or height(%{public}d) is < 0.", size.width, + size.height); return ERR_IMAGE_INVALID_PARAMETER; } uint32_t bytesPerPixel = ImageUtils::GetPixelBytes(format); if (bytesPerPixel == 0) { - HiLog::Error(LABEL, "ResetConfig get bytes by per pixel fail."); + IMAGE_LOGE("ResetConfig get bytes by per pixel fail."); return ERR_IMAGE_INVALID_PARAMETER; } uint64_t dstSize = static_cast(size.width) * size.height * bytesPerPixel; if (dstSize > static_cast(pixelsSize_)) { - HiLog::Error(LABEL, "ResetConfig reset dstSize(%{public}llu) > current(%{public}u).", - static_cast(dstSize), pixelsSize_); + IMAGE_LOGE("ResetConfig reset dstSize(%{public}llu) > current(%{public}u).", + static_cast(dstSize), pixelsSize_); return ERR_IMAGE_INVALID_PARAMETER; } AlphaType dstAlphaType = ImageUtils::GetValidAlphaTypeByFormat(GetAlphaType(), format); if (dstAlphaType == AlphaType::IMAGE_ALPHA_TYPE_UNKNOWN) { - HiLog::Error(LABEL, "ResetConfig Failed to get validate alpha type."); + IMAGE_LOGE("ResetConfig Failed to get validate alpha type."); return ERR_IMAGE_INVALID_PARAMETER; } ImageInfo dstInfo = MakeImageInfo(size.width, size.height, format, dstAlphaType); uint32_t ret = SetImageInfo(dstInfo, true); if (ret != SUCCESS) { - HiLog::Error(LABEL, "ResetConfig call SetImageInfo Failed. ret:%{public}u", ret); + IMAGE_LOGE("ResetConfig call SetImageInfo Failed. ret:%{public}u", ret); return ERR_IMAGE_CONFIG_FAILED; } return SUCCESS; @@ -1260,14 +1260,14 @@ bool PixelMap::SetAlphaType(const AlphaType &alphaType) { AlphaType type = ImageUtils::GetValidAlphaTypeByFormat(alphaType, imageInfo_.pixelFormat); if (type == AlphaType::IMAGE_ALPHA_TYPE_UNKNOWN) { - HiLog::Error(LABEL, "SetAlphaType Failed to get validate alpha type."); + IMAGE_LOGE("SetAlphaType Failed to get validate alpha type."); return false; } ImageInfo dstInfo = imageInfo_; dstInfo.alphaType = type; uint32_t ret = SetImageInfo(dstInfo, true); if (ret != SUCCESS) { - HiLog::Error(LABEL, "SetAlphaType call SetImageInfo Failed. ret:%{public}u", ret); + IMAGE_LOGE("SetAlphaType call SetImageInfo Failed. ret:%{public}u", ret); return false; } return true; @@ -1276,22 +1276,21 @@ bool PixelMap::SetAlphaType(const AlphaType &alphaType) uint32_t PixelMap::WritePixel(const Position &pos, const uint32_t &color) { if (pos.x < 0 || pos.y < 0 || pos.x >= GetWidth() || pos.y >= GetHeight()) { - HiLog::Error(LABEL, - "write pixel by pos but input position is invalid. [x(%{public}d), y(%{public}d)]"\ - "Width() %{public}d, Height() %{public}d, ", - pos.x, pos.y, GetWidth(), GetHeight()); + IMAGE_LOGE( + "write pixel by pos but input position is invalid. [x(%{public}d), y(%{public}d)]"\ + "Width() %{public}d, Height() %{public}d, ", pos.x, pos.y, GetWidth(), GetHeight()); return ERR_IMAGE_INVALID_PARAMETER; } if (!IsEditable()) { - HiLog::Error(LABEL, "write pixel by pos pixelmap is not editable."); + IMAGE_LOGE("write pixel by pos pixelmap is not editable."); return ERR_IMAGE_PIXELMAP_NOT_ALLOW_MODIFY; } if (!ImageUtils::IsValidImageInfo(imageInfo_)) { - HiLog::Error(LABEL, "write pixel by pos current pixelmap image info is invalid."); + IMAGE_LOGE("write pixel by pos current pixelmap image info is invalid."); return ERR_IMAGE_WRITE_PIXELMAP_FAILED; } if (data_ == nullptr) { - HiLog::Error(LABEL, "write pixel by pos but current pixelmap data is nullptr."); + IMAGE_LOGE("write pixel by pos but current pixelmap data is nullptr."); return ERR_IMAGE_WRITE_PIXELMAP_FAILED; } ImageInfo srcImageInfo = @@ -1300,7 +1299,7 @@ uint32_t PixelMap::WritePixel(const Position &pos, const uint32_t &color) Position dstPosition { pos.x, pos.y }; // source is per pixel. if (!PixelConvertAdapter::WritePixelsConvert(&color, srcRowBytes, srcImageInfo, data_, dstPosition, rowStride_, imageInfo_)) { - HiLog::Error(LABEL, "write pixel by pos call WritePixelsConvert fail."); + IMAGE_LOGE("write pixel by pos call WritePixelsConvert fail."); return ERR_IMAGE_WRITE_PIXELMAP_FAILED; } return SUCCESS; @@ -1310,24 +1309,24 @@ uint32_t PixelMap::WritePixels(const uint8_t *source, const uint64_t &bufferSize const uint32_t &stride, const Rect ®ion) { if (!CheckPixelsInput(source, bufferSize, offset, stride, region)) { - HiLog::Error(LABEL, "write pixel by rect input parameter fail."); + IMAGE_LOGE("write pixel by rect input parameter fail."); return ERR_IMAGE_INVALID_PARAMETER; } if (!IsEditable()) { - HiLog::Error(LABEL, "write pixel by rect pixelmap data is not editable."); + IMAGE_LOGE("write pixel by rect pixelmap data is not editable."); return ERR_IMAGE_PIXELMAP_NOT_ALLOW_MODIFY; } if (!ImageUtils::IsValidImageInfo(imageInfo_)) { - HiLog::Error(LABEL, "write pixel by rect current pixelmap image info is invalid."); + IMAGE_LOGE("write pixel by rect current pixelmap image info is invalid."); return ERR_IMAGE_WRITE_PIXELMAP_FAILED; } if (data_ == nullptr) { - HiLog::Error(LABEL, "write pixel by rect current pixel map data is null."); + IMAGE_LOGE("write pixel by rect current pixel map data is null."); return ERR_IMAGE_WRITE_PIXELMAP_FAILED; } uint32_t bytesPerPixel = ImageUtils::GetPixelBytes(imageInfo_.pixelFormat); if (bytesPerPixel == 0) { - HiLog::Error(LABEL, "write pixel by rect get bytes by per pixel fail."); + IMAGE_LOGE("write pixel by rect get bytes by per pixel fail."); return ERR_IMAGE_WRITE_PIXELMAP_FAILED; } Position dstPosition { region.left, region.top }; @@ -1335,7 +1334,7 @@ uint32_t PixelMap::WritePixels(const uint8_t *source, const uint64_t &bufferSize MakeImageInfo(region.width, region.height, PixelFormat::BGRA_8888, AlphaType::IMAGE_ALPHA_TYPE_UNPREMUL); if (!PixelConvertAdapter::WritePixelsConvert(source + offset, stride, srcInfo, data_, dstPosition, rowStride_, imageInfo_)) { - HiLog::Error(LABEL, "write pixel by rect call WritePixelsConvert fail."); + IMAGE_LOGE("write pixel by rect call WritePixelsConvert fail."); return ERR_IMAGE_WRITE_PIXELMAP_FAILED; } return SUCCESS; @@ -1345,20 +1344,20 @@ uint32_t PixelMap::WritePixels(const uint8_t *source, const uint64_t &bufferSize { ImageTrace imageTrace("WritePixels"); if (source == nullptr || bufferSize < static_cast(pixelsSize_)) { - HiLog::Error(LABEL, "write pixels by buffer source is nullptr or size(%{public}llu) < pixelSize(%{public}u).", - static_cast(bufferSize), pixelsSize_); + IMAGE_LOGE("write pixels by buffer source is nullptr or size(%{public}llu) < pixelSize(%{public}u).", + static_cast(bufferSize), pixelsSize_); return ERR_IMAGE_INVALID_PARAMETER; } if (!IsEditable()) { - HiLog::Error(LABEL, "write pixels by buffer pixelmap data is not editable."); + IMAGE_LOGE("write pixels by buffer pixelmap data is not editable."); return ERR_IMAGE_PIXELMAP_NOT_ALLOW_MODIFY; } if (!ImageUtils::IsValidImageInfo(imageInfo_)) { - HiLog::Error(LABEL, "write pixels by buffer current pixelmap image info is invalid."); + IMAGE_LOGE("write pixels by buffer current pixelmap image info is invalid."); return ERR_IMAGE_WRITE_PIXELMAP_FAILED; } if (data_ == nullptr) { - HiLog::Error(LABEL, "write pixels by buffer current pixelmap data is nullptr."); + IMAGE_LOGE("write pixels by buffer current pixelmap data is nullptr."); return ERR_IMAGE_WRITE_PIXELMAP_FAILED; } @@ -1366,7 +1365,7 @@ uint32_t PixelMap::WritePixels(const uint8_t *source, const uint64_t &bufferSize const uint8_t* sourceRow = source + i * rowDataSize_; errno_t ret = memcpy_s(data_ + i * rowStride_, rowDataSize_, sourceRow, rowDataSize_); if (ret != 0) { - HiLog::Error(LABEL, "write pixels by buffer memcpy the pixelmap data to dst fail, error:%{public}d", ret); + IMAGE_LOGE("write pixels by buffer memcpy the pixelmap data to dst fail, error:%{public}d", ret); return ERR_IMAGE_WRITE_PIXELMAP_FAILED; } } @@ -1376,21 +1375,21 @@ uint32_t PixelMap::WritePixels(const uint8_t *source, const uint64_t &bufferSize bool PixelMap::WritePixels(const uint32_t &color) { if (!IsEditable()) { - HiLog::Error(LABEL, "erase pixels by color pixelmap data is not editable."); + IMAGE_LOGE("erase pixels by color pixelmap data is not editable."); return false; } if (!ImageUtils::IsValidImageInfo(imageInfo_)) { - HiLog::Error(LABEL, "erase pixels by color current pixelmap image info is invalid."); + IMAGE_LOGE("erase pixels by color current pixelmap image info is invalid."); return false; } if (data_ == nullptr) { - HiLog::Error(LABEL, "erase pixels by color current pixel map data is null."); + IMAGE_LOGE("erase pixels by color current pixel map data is null."); return false; } ImageInfo srcInfo = MakeImageInfo(imageInfo_.size.width, imageInfo_.size.height, imageInfo_.pixelFormat, imageInfo_.alphaType); if (!PixelConvertAdapter::EraseBitmap(data_, rowStride_, srcInfo, color)) { - HiLog::Error(LABEL, "erase pixels by color call EraseBitmap fail."); + IMAGE_LOGE("erase pixels by color call EraseBitmap fail."); return false; } return true; @@ -1398,13 +1397,13 @@ bool PixelMap::WritePixels(const uint32_t &color) bool PixelMap::IsStrideAlignment() { - HiLog::Error(LABEL, "IsStrideAlignment error "); + IMAGE_LOGE("IsStrideAlignment error "); if (allocatorType_ == AllocatorType::DMA_ALLOC) { - HiLog::Error(LABEL, "SetPixelsAddr error allocatorType_ %{public}d ", allocatorType_); + IMAGE_LOGE("SetPixelsAddr error allocatorType_ %{public}d ", allocatorType_); return true; } return false; - HiLog::Error(LABEL, "IsStrideAlignment error "); + IMAGE_LOGE("IsStrideAlignment error "); } AllocatorType PixelMap::GetAllocatorType() @@ -1459,13 +1458,13 @@ bool PixelMap::WriteAshmemDataToParcel(Parcel &parcel, size_t size) const uint32_t id = GetUniqueId(); std::string name = "Parcel ImageData, uniqueId: " + std::to_string(getpid()) + '_' + std::to_string(id); int fd = AshmemCreate(name.c_str(), size); - HiLog::Info(LABEL, "AshmemCreate:[%{public}d].", fd); + IMAGE_LOGI("AshmemCreate:[%{public}d].", fd); if (fd < 0) { return false; } int result = AshmemSetProt(fd, PROT_READ | PROT_WRITE); - HiLog::Info(LABEL, "AshmemSetProt:[%{public}d].", result); + IMAGE_LOGI("AshmemSetProt:[%{public}d].", result); if (result < 0) { ::close(fd); return false; @@ -1473,30 +1472,30 @@ bool PixelMap::WriteAshmemDataToParcel(Parcel &parcel, size_t size) const void *ptr = ::mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if (ptr == MAP_FAILED) { ::close(fd); - HiLog::Error(LABEL, "WriteAshmemData map failed, errno:%{public}d", errno); + IMAGE_LOGE("WriteAshmemData map failed, errno:%{public}d", errno); return false; } - HiLog::Info(LABEL, "mmap success"); + IMAGE_LOGI("mmap success"); if (memcpy_s(ptr, size, data, size) != EOK) { ::munmap(ptr, size); ::close(fd); - HiLog::Error(LABEL, "WriteAshmemData memcpy_s error"); + IMAGE_LOGE("WriteAshmemData memcpy_s error"); return false; } if (!WriteFileDescriptor(parcel, fd)) { ::munmap(ptr, size); ::close(fd); - HiLog::Error(LABEL, "WriteAshmemData WriteFileDescriptor error"); + IMAGE_LOGE("WriteAshmemData WriteFileDescriptor error"); return false; } - HiLog::Debug(LABEL, "WriteAshmemData WriteFileDescriptor success"); + IMAGE_LOGD("WriteAshmemData WriteFileDescriptor success"); ::munmap(ptr, size); ::close(fd); return true; #endif - HiLog::Error(LABEL, "WriteAshmemData not support crossplatform"); + IMAGE_LOGE("WriteAshmemData not support crossplatform"); return false; } @@ -1504,12 +1503,12 @@ bool PixelMap::WriteImageData(Parcel &parcel, size_t size) const { const uint8_t *data = data_; if (data == nullptr || size > MAX_IMAGEDATA_SIZE) { - HiLog::Error(LABEL, "WriteImageData failed, data is null or size bigger than 128M."); + IMAGE_LOGE("WriteImageData failed, data is null or size bigger than 128M."); return false; } if (!parcel.WriteInt32(size)) { - HiLog::Error(LABEL, "WriteImageData size failed."); + IMAGE_LOGE("WriteImageData size failed."); return false; } if (size <= MIN_IMAGEDATA_SIZE) { @@ -1522,25 +1521,25 @@ uint8_t *PixelMap::ReadHeapDataFromParcel(Parcel &parcel, int32_t bufferSize) { uint8_t *base = nullptr; if (bufferSize <= 0) { - HiLog::Error(LABEL, "malloc parameter bufferSize:[%{public}d] error.", bufferSize); + IMAGE_LOGE("malloc parameter bufferSize:[%{public}d] error.", bufferSize); return nullptr; } const uint8_t *ptr = parcel.ReadUnpadBuffer(bufferSize); if (ptr == nullptr) { - HiLog::Error(LABEL, "read buffer from parcel failed, read buffer addr is null"); + IMAGE_LOGE("read buffer from parcel failed, read buffer addr is null"); return nullptr; } base = static_cast(malloc(bufferSize)); if (base == nullptr) { - HiLog::Error(LABEL, "alloc output pixel memory size:[%{public}d] error.", bufferSize); + IMAGE_LOGE("alloc output pixel memory size:[%{public}d] error.", bufferSize); return nullptr; } if (memcpy_s(base, bufferSize, ptr, bufferSize) != 0) { free(base); base = nullptr; - HiLog::Error(LABEL, "memcpy pixel data size:[%{public}d] error.", bufferSize); + IMAGE_LOGE("memcpy pixel data size:[%{public}d] error.", bufferSize); return nullptr; } return base; @@ -1551,32 +1550,32 @@ uint8_t *PixelMap::ReadAshmemDataFromParcel(Parcel &parcel, int32_t bufferSize) uint8_t *base = nullptr; int fd = ReadFileDescriptor(parcel); if (fd < 0) { - HiLog::Error(LABEL, "read fd :[%{public}d] error", fd); + IMAGE_LOGE("read fd :[%{public}d] error", fd); return nullptr; } if (bufferSize <= 0 || bufferSize > PIXEL_MAP_MAX_RAM_SIZE) { - HiLog::Error(LABEL, "malloc parameter bufferSize:[%{public}d] error.", bufferSize); + IMAGE_LOGE("malloc parameter bufferSize:[%{public}d] error.", bufferSize); return nullptr; } void *ptr = ::mmap(nullptr, bufferSize, PROT_READ, MAP_SHARED, fd, 0); if (ptr == MAP_FAILED) { // do not close fd here. fd will be closed in FileDescriptor, ::close(fd) - HiLog::Error(LABEL, "ReadImageData map failed, errno:%{public}d", errno); + IMAGE_LOGE("ReadImageData map failed, errno:%{public}d", errno); return nullptr; } base = static_cast(malloc(bufferSize)); if (base == nullptr) { ::munmap(ptr, bufferSize); - HiLog::Error(LABEL, "alloc output pixel memory size:[%{public}d] error.", bufferSize); + IMAGE_LOGE("alloc output pixel memory size:[%{public}d] error.", bufferSize); return nullptr; } if (memcpy_s(base, bufferSize, ptr, bufferSize) != 0) { ::munmap(ptr, bufferSize); free(base); base = nullptr; - HiLog::Error(LABEL, "memcpy pixel data size:[%{public}d] error.", bufferSize); + IMAGE_LOGE("memcpy pixel data size:[%{public}d] error.", bufferSize); return nullptr; } @@ -1634,27 +1633,27 @@ int PixelMap::ReadFileDescriptor(Parcel &parcel) bool PixelMap::WriteImageInfo(Parcel &parcel) const { if (!parcel.WriteInt32(imageInfo_.size.width)) { - HiLog::Error(LABEL, "write image info width:[%{public}d] to parcel failed.", imageInfo_.size.width); + IMAGE_LOGE("write image info width:[%{public}d] to parcel failed.", imageInfo_.size.width); return false; } if (!parcel.WriteInt32(imageInfo_.size.height)) { - HiLog::Error(LABEL, "write image info height:[%{public}d] to parcel failed.", imageInfo_.size.height); + IMAGE_LOGE("write image info height:[%{public}d] to parcel failed.", imageInfo_.size.height); return false; } if (!parcel.WriteInt32(static_cast(imageInfo_.pixelFormat))) { - HiLog::Error(LABEL, "write image info pixel format:[%{public}d] to parcel failed.", imageInfo_.pixelFormat); + IMAGE_LOGE("write image info pixel format:[%{public}d] to parcel failed.", imageInfo_.pixelFormat); return false; } if (!parcel.WriteInt32(static_cast(imageInfo_.colorSpace))) { - HiLog::Error(LABEL, "write image info color space:[%{public}d] to parcel failed.", imageInfo_.colorSpace); + IMAGE_LOGE("write image info color space:[%{public}d] to parcel failed.", imageInfo_.colorSpace); return false; } if (!parcel.WriteInt32(static_cast(imageInfo_.alphaType))) { - HiLog::Error(LABEL, "write image info alpha type:[%{public}d] to parcel failed.", imageInfo_.alphaType); + IMAGE_LOGE("write image info alpha type:[%{public}d] to parcel failed.", imageInfo_.alphaType); return false; } if (!parcel.WriteInt32(imageInfo_.baseDensity)) { - HiLog::Error(LABEL, "write image info base density:[%{public}d] to parcel failed.", imageInfo_.baseDensity); + IMAGE_LOGE("write image info base density:[%{public}d] to parcel failed.", imageInfo_.baseDensity); return false; } return true; @@ -1663,29 +1662,28 @@ bool PixelMap::WriteImageInfo(Parcel &parcel) const bool PixelMap::WriteInfoToParcel(Parcel &parcel) const { if (!WriteImageInfo(parcel)) { - HiLog::Error(LABEL, "write image info to parcel failed."); + IMAGE_LOGE("write image info to parcel failed."); return false; } if (!parcel.WriteBool(editable_)) { - HiLog::Error(LABEL, "write pixel map editable to parcel failed."); + IMAGE_LOGE("write pixel map editable to parcel failed."); return false; } if (!parcel.WriteBool(isAstc_)) { - HiLog::Error(LABEL, "write pixel map isAstc_ to parcel failed."); + IMAGE_LOGE("write pixel map isAstc_ to parcel failed."); return false; } if (!parcel.WriteInt32(static_cast(allocatorType_))) { - HiLog::Error(LABEL, "write pixel map allocator type:[%{public}d] to parcel failed.", - allocatorType_); + IMAGE_LOGE("write pixel map allocator type:[%{public}d] to parcel failed.", allocatorType_); return false; } if (!parcel.WriteInt32(static_cast(grColorSpace_ ? grColorSpace_->GetColorSpaceName() : ERR_MEDIA_INVALID_VALUE))) { - HiLog::Error(LABEL, "write pixel map grColorSpace to parcel failed."); + IMAGE_LOGE("write pixel map grColorSpace to parcel failed."); return false; } return true; @@ -1695,47 +1693,47 @@ bool PixelMap::WriteTransformDataToParcel(Parcel &parcel) const { if (isAstc_) { if (!parcel.WriteFloat(static_cast(transformData_.scaleX))) { - HiLog::Error(LABEL, "write scaleX:[%{public}f] to parcel failed.", transformData_.scaleX); + IMAGE_LOGE("write scaleX:[%{public}f] to parcel failed.", transformData_.scaleX); return false; } if (!parcel.WriteFloat(static_cast(transformData_.scaleY))) { - HiLog::Error(LABEL, "write scaleY:[%{public}f] to parcel failed.", transformData_.scaleY); + IMAGE_LOGE("write scaleY:[%{public}f] to parcel failed.", transformData_.scaleY); return false; } if (!parcel.WriteFloat(static_cast(transformData_.rotateD))) { - HiLog::Error(LABEL, "write rotateD:[%{public}f] to parcel failed.", transformData_.rotateD); + IMAGE_LOGE("write rotateD:[%{public}f] to parcel failed.", transformData_.rotateD); return false; } if (!parcel.WriteFloat(static_cast(transformData_.cropLeft))) { - HiLog::Error(LABEL, "write cropLeft:[%{public}f] to parcel failed.", transformData_.cropLeft); + IMAGE_LOGE("write cropLeft:[%{public}f] to parcel failed.", transformData_.cropLeft); return false; } if (!parcel.WriteFloat(static_cast(transformData_.cropTop))) { - HiLog::Error(LABEL, "write cropTop:[%{public}f] to parcel failed.", transformData_.cropTop); + IMAGE_LOGE("write cropTop:[%{public}f] to parcel failed.", transformData_.cropTop); return false; } if (!parcel.WriteFloat(static_cast(transformData_.cropWidth))) { - HiLog::Error(LABEL, "write cropWidth:[%{public}f] to parcel failed.", transformData_.cropWidth); + IMAGE_LOGE("write cropWidth:[%{public}f] to parcel failed.", transformData_.cropWidth); return false; } if (!parcel.WriteFloat(static_cast(transformData_.cropHeight))) { - HiLog::Error(LABEL, "write cropHeight:[%{public}f] to parcel failed.", transformData_.cropHeight); + IMAGE_LOGE("write cropHeight:[%{public}f] to parcel failed.", transformData_.cropHeight); return false; } if (!parcel.WriteFloat(static_cast(transformData_.translateX))) { - HiLog::Error(LABEL, "write translateX:[%{public}f] to parcel failed.", transformData_.translateX); + IMAGE_LOGE("write translateX:[%{public}f] to parcel failed.", transformData_.translateX); return false; } if (!parcel.WriteFloat(static_cast(transformData_.translateY))) { - HiLog::Error(LABEL, "write translateY:[%{public}f] to parcel failed.", transformData_.translateY); + IMAGE_LOGE("write translateY:[%{public}f] to parcel failed.", transformData_.translateY); return false; } if (!parcel.WriteBool(static_cast(transformData_.flipX))) { - HiLog::Error(LABEL, "write astc transformData_.flipX to parcel failed."); + IMAGE_LOGE("write astc transformData_.flipX to parcel failed."); return false; } if (!parcel.WriteBool(static_cast(transformData_.flipY))) { - HiLog::Error(LABEL, "write astc transformData_.flipY to parcel failed."); + IMAGE_LOGE("write astc transformData_.flipY to parcel failed."); return false; } } @@ -1746,11 +1744,11 @@ bool PixelMap::WriteAstcRealSizeToParcel(Parcel &parcel) const { if (isAstc_) { if (!parcel.WriteInt32(static_cast(astcrealSize_.width))) { - HiLog::Error(LABEL, "write astcrealSize_.width:[%{public}d] to parcel failed.", astcrealSize_.width); + IMAGE_LOGE("write astcrealSize_.width:[%{public}d] to parcel failed.", astcrealSize_.width); return false; } if (!parcel.WriteInt32(static_cast(astcrealSize_.height))) { - HiLog::Error(LABEL, "write astcrealSize_.height:[%{public}d] to parcel failed.", astcrealSize_.height); + IMAGE_LOGE("write astcrealSize_.height:[%{public}d] to parcel failed.", astcrealSize_.height); return false; } } @@ -1767,15 +1765,15 @@ bool PixelMap::Marshalling(Parcel &parcel) const if (static_cast(bufferSize) <= MIN_IMAGEDATA_SIZE && static_cast(bufferSize + PIXEL_MAP_INFO_MAX_LENGTH) > parcel.GetDataCapacity() && !parcel.SetDataCapacity(bufferSize + PIXEL_MAP_INFO_MAX_LENGTH)) { - HiLog::Error(LABEL, "set parcel max capacity:[%{public}d] failed.", bufferSize + PIXEL_MAP_INFO_MAX_LENGTH); + IMAGE_LOGE("set parcel max capacity:[%{public}d] failed.", bufferSize + PIXEL_MAP_INFO_MAX_LENGTH); return false; } if (!WriteInfoToParcel(parcel)) { - HiLog::Error(LABEL, "write info to parcel failed."); + IMAGE_LOGE("write info to parcel failed."); return false; } if (!parcel.WriteInt32(static_cast(rowDataSize_))) { - HiLog::Error(LABEL, "write image info rowStride_:[%{public}d] to parcel failed.", rowDataSize_); + IMAGE_LOGE("write image info rowStride_:[%{public}d] to parcel failed.", rowDataSize_); return false; } #if !defined(_WIN32) && !defined(_APPLE) &&!defined(IOS_PLATFORM) &&!defined(A_PLATFORM) @@ -1786,12 +1784,12 @@ bool PixelMap::Marshalling(Parcel &parcel) const int *fd = static_cast(context_); if (fd == nullptr || *fd < 0) { - HiLog::Error(LABEL, "write pixel map failed, fd is [%{public}d] or fd < 0.", fd == nullptr ? 1 : 0); + IMAGE_LOGE("write pixel map failed, fd is [%{public}d] or fd < 0.", fd == nullptr ? 1 : 0); return false; } if (!WriteFileDescriptor(parcel, *fd)) { - HiLog::Error(LABEL, "write pixel map fd:[%{public}d] to parcel failed.", *fd); + IMAGE_LOGE("write pixel map fd:[%{public}d] to parcel failed.", *fd); return false; } } else if (allocatorType_ == AllocatorType::DMA_ALLOC) { @@ -1802,23 +1800,23 @@ bool PixelMap::Marshalling(Parcel &parcel) const sbBuffer->WriteToMessageParcel(static_cast(parcel)); } else { if (!WriteImageData(parcel, bufferSize)) { - HiLog::Error(LABEL, "write pixel map buffer to parcel failed."); + IMAGE_LOGE("write pixel map buffer to parcel failed."); return false; } } #else if (!WriteImageData(parcel, bufferSize)) { - HiLog::Error(LABEL, "write pixel map buffer to parcel failed."); + IMAGE_LOGE("write pixel map buffer to parcel failed."); return false; } #endif if (!WriteTransformDataToParcel(parcel)) { - HiLog::Error(LABEL, "write transformData to parcel failed."); + IMAGE_LOGE("write transformData to parcel failed."); return false; } if (!WriteAstcRealSizeToParcel(parcel)) { - HiLog::Error(LABEL, "write astcrealSize to parcel failed."); + IMAGE_LOGE("write astcrealSize to parcel failed."); return false; } return true; @@ -1827,15 +1825,15 @@ bool PixelMap::Marshalling(Parcel &parcel) const bool PixelMap::ReadImageInfo(Parcel &parcel, ImageInfo &imgInfo) { imgInfo.size.width = parcel.ReadInt32(); - HiLog::Debug(LABEL, "read pixel map width:[%{public}d] to parcel.", imgInfo.size.width); + IMAGE_LOGD("read pixel map width:[%{public}d] to parcel.", imgInfo.size.width); imgInfo.size.height = parcel.ReadInt32(); - HiLog::Debug(LABEL, "read pixel map height:[%{public}d] to parcel.", imgInfo.size.height); + IMAGE_LOGD("read pixel map height:[%{public}d] to parcel.", imgInfo.size.height); imgInfo.pixelFormat = static_cast(parcel.ReadInt32()); - HiLog::Debug(LABEL, "read pixel map pixelFormat:[%{public}d] to parcel.", imgInfo.pixelFormat); + IMAGE_LOGD("read pixel map pixelFormat:[%{public}d] to parcel.", imgInfo.pixelFormat); imgInfo.colorSpace = static_cast(parcel.ReadInt32()); - HiLog::Debug(LABEL, "read pixel map colorSpace:[%{public}d] to parcel.", imgInfo.colorSpace); + IMAGE_LOGD("read pixel map colorSpace:[%{public}d] to parcel.", imgInfo.colorSpace); imgInfo.alphaType = static_cast(parcel.ReadInt32()); - HiLog::Debug(LABEL, "read pixel map alphaType:[%{public}d] to parcel.", imgInfo.alphaType); + IMAGE_LOGD("read pixel map alphaType:[%{public}d] to parcel.", imgInfo.alphaType); imgInfo.baseDensity = parcel.ReadInt32(); return true; } @@ -1876,7 +1874,7 @@ PixelMap *PixelMap::Unmarshalling(Parcel &parcel) PIXEL_MAP_ERR error; PixelMap* dstPixelMap = PixelMap::Unmarshalling(parcel, error); if (dstPixelMap == nullptr || error.errorCode != SUCCESS) { - HiLog::Error(LABEL, "unmarshalling failed errorCode:%{public}d, errorInfo:%{public}s", + IMAGE_LOGE("unmarshalling failed errorCode:%{public}d, errorInfo:%{public}s", error.errorCode, error.errorInfo.c_str()); } return dstPixelMap; @@ -1892,7 +1890,7 @@ PixelMap *PixelMap::Unmarshalling(Parcel &parcel, PIXEL_MAP_ERR &error) ImageInfo imgInfo; if (!pixelMap->ReadImageInfo(parcel, imgInfo)) { - HiLog::Error(LABEL, "read imageInfo fail"); + IMAGE_LOGE("read imageInfo fail"); delete pixelMap; PixelMap::ConstructPixelMapError(error, ERR_IMAGE_READ_PIXELMAP_FAILED, "read pixelmap failed"); return nullptr; @@ -1916,12 +1914,12 @@ PixelMap *PixelMap::Unmarshalling(Parcel &parcel, PIXEL_MAP_ERR &error) int32_t bytesPerPixel = ImageUtils::GetPixelBytes(imgInfo.pixelFormat); if (bytesPerPixel == 0) { delete pixelMap; - HiLog::Error(LABEL, "unmarshalling get bytes by per pixel fail."); + IMAGE_LOGE("unmarshalling get bytes by per pixel fail."); return nullptr; } if ((!isAstc) && bufferSize != rowDataSize * imgInfo.size.height) { delete pixelMap; - HiLog::Error(LABEL, "unmarshalling bufferSize parcelling error"); + IMAGE_LOGE("unmarshalling bufferSize parcelling error"); PixelMap::ConstructPixelMapError(error, ERR_IMAGE_BUFFER_SIZE_PARCEL_ERROR, "unmarshalling bufferSize parcelling error"); return nullptr; @@ -1932,7 +1930,7 @@ PixelMap *PixelMap::Unmarshalling(Parcel &parcel, PIXEL_MAP_ERR &error) if (allocType == AllocatorType::SHARE_MEM_ALLOC) { int fd = ReadFileDescriptor(parcel); if (fd < 0) { - HiLog::Error(LABEL, "fd < 0"); + IMAGE_LOGE("fd < 0"); delete pixelMap; PixelMap::ConstructPixelMapError(error, ERR_IMAGE_GET_FD_BAD, "fd acquisition failed"); return nullptr; @@ -1943,7 +1941,7 @@ PixelMap *PixelMap::Unmarshalling(Parcel &parcel, PIXEL_MAP_ERR &error) if (ptr == MAP_FAILED) { ::close(fd); delete pixelMap; - HiLog::Error(LABEL, "shared memory map in memalloc failed, errno:%{public}d", errno); + IMAGE_LOGE("shared memory map in memalloc failed, errno:%{public}d", errno); PixelMap::ConstructPixelMapError(error, ERR_IMAGE_GET_FD_BAD, "shared memory map in memalloc failed"); return nullptr; } @@ -1968,7 +1966,7 @@ PixelMap *PixelMap::Unmarshalling(Parcel &parcel, PIXEL_MAP_ERR &error) } else { base = ReadImageData(parcel, bufferSize); if (base == nullptr) { - HiLog::Error(LABEL, "get pixel memory size:[%{public}d] error.", bufferSize); + IMAGE_LOGE("get pixel memory size:[%{public}d] error.", bufferSize); delete pixelMap; PixelMap::ConstructPixelMapError(error, ERR_IMAGE_GET_DATA_ABNORMAL, "ReadImageData failed"); return nullptr; @@ -1977,7 +1975,7 @@ PixelMap *PixelMap::Unmarshalling(Parcel &parcel, PIXEL_MAP_ERR &error) #else base = ReadImageData(parcel, bufferSize); if (base == nullptr) { - HiLog::Error(LABEL, "get pixel memory size:[%{public}d] error.", bufferSize); + IMAGE_LOGE("get pixel memory size:[%{public}d] error.", bufferSize); delete pixelMap; return nullptr; } @@ -1993,17 +1991,17 @@ PixelMap *PixelMap::Unmarshalling(Parcel &parcel, PIXEL_MAP_ERR &error) delete static_cast(context); } delete pixelMap; - HiLog::Error(LABEL, "create pixel map from parcel failed, set image info error."); + IMAGE_LOGE("create pixel map from parcel failed, set image info error."); return nullptr; } pixelMap->SetPixelsAddr(base, context, bufferSize, allocType, nullptr); if (!pixelMap->ReadTransformData(parcel, pixelMap)) { - HiLog::Error(LABEL, "read transformData fail"); + IMAGE_LOGE("read transformData fail"); delete pixelMap; return nullptr; } if (!pixelMap->ReadAstcRealSize(parcel, pixelMap)) { - HiLog::Error(LABEL, "read astcrealSize fail"); + IMAGE_LOGE("read astcrealSize fail"); delete pixelMap; return nullptr; } @@ -2018,7 +2016,7 @@ void PixelMap::WriteUint8(std::vector &buff, uint8_t value) const uint8_t PixelMap::ReadUint8(std::vector &buff, int32_t &cursor) { if (static_cast(cursor + 1) > buff.size()) { - HiLog::Error(LABEL, "ReadUint8 out of range"); + IMAGE_LOGE("ReadUint8 out of range"); return TLV_END; } return buff[cursor++]; @@ -2050,7 +2048,7 @@ int32_t PixelMap::ReadVarint(std::vector &buff, int32_t &cursor) int32_t item = 0; do { if (static_cast(cursor + 1) > buff.size()) { - HiLog::Error(LABEL, "ReadVarint out of range"); + IMAGE_LOGE("ReadVarint out of range"); return static_cast(TLV_END); } item = int32_t(buff[cursor++]); @@ -2080,16 +2078,16 @@ void PixelMap::WriteData(std::vector &buff, const uint8_t *data, uint8_t *PixelMap::ReadData(std::vector &buff, int32_t size, int32_t &cursor) { if (size <= 0) { - HiLog::Error(LABEL, "pixel map tlv read data fail: invalid size[%{public}d]", size); + IMAGE_LOGE("pixel map tlv read data fail: invalid size[%{public}d]", size); return nullptr; } if (static_cast(cursor + size) > buff.size()) { - HiLog::Error(LABEL, "ReadData out of range"); + IMAGE_LOGE("ReadData out of range"); return nullptr; } uint8_t *data = static_cast(malloc(size)); if (data == nullptr) { - HiLog::Error(LABEL, "pixel map tlv read data fail: malloc memory size[%{public}d]", size); + IMAGE_LOGE("pixel map tlv read data fail: malloc memory size[%{public}d]", size); return nullptr; } for (int32_t offset = 0; offset < size; offset++) { @@ -2128,7 +2126,7 @@ bool PixelMap::EncodeTlv(std::vector &buff) const if (data == nullptr || size_t(dataSize) > MAX_IMAGEDATA_SIZE || dataSize <= 0) { WriteVarint(buff, 0); // L is zero and no value WriteUint8(buff, TLV_END); // end tag - HiLog::Error(LABEL, "pixel map tlv encode fail: no data"); + IMAGE_LOGE("pixel map tlv encode fail: no data"); return false; } WriteVarint(buff, dataSize); @@ -2143,7 +2141,7 @@ void PixelMap::ReadTlvAttr(std::vector &buff, ImageInfo &info, int32_t for (uint8_t tag = ReadUint8(buff, cursor); tag != TLV_END; tag = ReadUint8(buff, cursor)) { int32_t len = ReadVarint(buff, cursor); if (len <= 0 || static_cast(cursor + len) > buff.size()) { - HiLog::Error(LABEL, "ReadTlvAttr out of range"); + IMAGE_LOGE("ReadTlvAttr out of range"); return; } switch (tag) { @@ -2167,7 +2165,7 @@ void PixelMap::ReadTlvAttr(std::vector &buff, ImageInfo &info, int32_t break; case TLV_IMAGE_ALLOCATORTYPE: type = ReadVarint(buff, cursor); - HiLog::Info(LABEL, "pixel alloctype: %{public}d", type); + IMAGE_LOGI("pixel alloctype: %{public}d", type); break; case TLV_IMAGE_DATA: size = len; @@ -2175,7 +2173,7 @@ void PixelMap::ReadTlvAttr(std::vector &buff, ImageInfo &info, int32_t break; default: cursor += len; // skip unknown tag - HiLog::Warn(LABEL, "pixel map tlv decode warn: unknown tag[%{public}d]", tag); + IMAGE_LOGW("pixel map tlv decode warn: unknown tag[%{public}d]", tag); break; } } @@ -2185,7 +2183,7 @@ PixelMap *PixelMap::DecodeTlv(std::vector &buff) { PixelMap *pixelMap = new PixelMap(); if (pixelMap == nullptr) { - HiLog::Error(LABEL, "pixel map tlv decode fail: new PixelMap error"); + IMAGE_LOGE("pixel map tlv decode fail: new PixelMap error"); return nullptr; } ImageInfo imageInfo; @@ -2195,19 +2193,19 @@ PixelMap *PixelMap::DecodeTlv(std::vector &buff) ReadTlvAttr(buff, imageInfo, allocType, dataSize, &data); if (data == nullptr) { delete pixelMap; - HiLog::Error(LABEL, "pixel map tlv decode fail: no data"); + IMAGE_LOGE("pixel map tlv decode fail: no data"); return nullptr; } uint32_t ret = pixelMap->SetImageInfo(imageInfo); if (ret != SUCCESS) { free(data); delete pixelMap; - HiLog::Error(LABEL, "pixel map tlv decode fail: set image info error[%{public}d]", ret); + IMAGE_LOGE("pixel map tlv decode fail: set image info error[%{public}d]", ret); return nullptr; } if (dataSize != pixelMap->GetByteCount()) { delete pixelMap; - HiLog::Error(LABEL, "pixel map tlv decode fail: dataSize not match"); + IMAGE_LOGE("pixel map tlv decode fail: dataSize not match"); return nullptr; } pixelMap->SetPixelsAddr(data, nullptr, dataSize, static_cast(allocType), nullptr); @@ -2367,14 +2365,14 @@ uint32_t PixelMap::SetAlpha(const float percent) auto alphaType = GetAlphaType(); if (alphaType == AlphaType::IMAGE_ALPHA_TYPE_UNKNOWN || alphaType == AlphaType::IMAGE_ALPHA_TYPE_OPAQUE) { - HiLog::Error(LABEL, + IMAGE_LOGE( "Could not set alpha on %{public}s", GetNamedAlphaType(alphaType).c_str()); return ERR_IMAGE_DATA_UNSUPPORT; } if (percent <= 0 || percent > 1) { - HiLog::Error(LABEL, + IMAGE_LOGE( "Set alpha input should (0 < input <= 1). Current input %{public}f", percent); return ERR_IMAGE_INVALID_PARAMETER; @@ -2385,14 +2383,14 @@ uint32_t PixelMap::SetAlpha(const float percent) uint32_t pixelsSize = GetByteCount(); int8_t alphaIndex = GetAlphaIndex(pixelFormat); if (alphaIndex == INVALID_ALPHA_INDEX) { - HiLog::Error(LABEL, "Could not set alpha on %{public}s", + IMAGE_LOGE("Could not set alpha on %{public}s", GetNamedPixelFormat(pixelFormat).c_str()); return ERR_IMAGE_DATA_UNSUPPORT; } if ((pixelFormat == PixelFormat::ALPHA_8 && pixelBytes_ != ALPHA_BYTES) || (pixelFormat == PixelFormat::RGBA_F16 && pixelBytes_ != RGBA_F16_BYTES)) { - HiLog::Error(LABEL, "Pixel format %{public}s mismatch pixelByte %{public}d", + IMAGE_LOGE("Pixel format %{public}s mismatch pixelByte %{public}d", GetNamedPixelFormat(pixelFormat).c_str(), pixelBytes_); return ERR_IMAGE_INVALID_PARAMETER; } @@ -2424,8 +2422,8 @@ static SkImageInfo ToSkImageInfo(ImageInfo &info, sk_sp colorSpace { SkColorType colorType = ImageTypeConverter::ToSkColorType(info.pixelFormat); SkAlphaType alphaType = ImageTypeConverter::ToSkAlphaType(info.alphaType); - HiLog::Debug(LABEL, "ToSkImageInfo w %{public}d, h %{public}d", info.size.width, info.size.height); - HiLog::Debug(LABEL, + IMAGE_LOGD("ToSkImageInfo w %{public}d, h %{public}d", info.size.width, info.size.height); + IMAGE_LOGD( "ToSkImageInfo pf %{public}s, at %{public}s, skpf %{public}s, skat %{public}s", ImageTypeConverter::ToName(info.pixelFormat).c_str(), ImageTypeConverter::ToName(info.alphaType).c_str(), @@ -2472,7 +2470,7 @@ static void GenSrcTransInfo(SkTransInfo &srcInfo, ImageInfo &imageInfo, PixelMap uint64_t rowStride = srcInfo.info.minRowBytes(); if (pixelmap->GetAllocatorType() == AllocatorType::DMA_ALLOC) { if (pixelmap->GetFd() == nullptr) { - HiLog::Error(LABEL, "GenSrcTransInfo get surfacebuffer failed"); + IMAGE_LOGE("GenSrcTransInfo get surfacebuffer failed"); } SurfaceBuffer* sbBuffer = reinterpret_cast(pixelmap->GetFd()); rowStride = sbBuffer->GetStride(); @@ -2508,7 +2506,7 @@ static bool GendstTransInfo(SkTransInfo &srcInfo, SkTransInfo &dstInfo, SkMatrix #endif std::unique_ptr dstMemory = MemoryManager::CreateMemory(memoryInfo.allocType, memoryData); if (dstMemory == nullptr) { - HiLog::Error(LABEL, "CreateMemory falied"); + IMAGE_LOGE("CreateMemory falied"); return false; } memoryInfo.memory = std::move(dstMemory); @@ -2516,7 +2514,7 @@ static bool GendstTransInfo(SkTransInfo &srcInfo, SkTransInfo &dstInfo, SkMatrix uint64_t rowStride = dstInfo.info.minRowBytes(); if (memoryInfo.allocType == AllocatorType::DMA_ALLOC) { if (memoryInfo.memory->extend.data == nullptr) { - HiLog::Error(LABEL, "GendstTransInfo get surfacebuffer failed"); + IMAGE_LOGE("GendstTransInfo get surfacebuffer failed"); } SurfaceBuffer* sbBuffer = reinterpret_cast(memoryInfo.memory->extend.data); rowStride = sbBuffer->GetStride(); @@ -2571,7 +2569,7 @@ bool PixelMap::DoTranslation(TransInfos &infos, const AntiAliasingOption &option SkTransInfo dst; if (!GendstTransInfo(src, dst, infos.matrix, dstMemory)) { - HiLog::Error(LABEL, "GendstTransInfo dstMemory falied"); + IMAGE_LOGE("GendstTransInfo dstMemory falied"); this->errorCode = IMAGE_RESULT_DECODE_FAILED; return false; } @@ -2609,7 +2607,7 @@ void PixelMap::scale(float xAxis, float yAxis) TransInfos infos; infos.matrix.setScale(xAxis, yAxis); if (!DoTranslation(infos)) { - HiLog::Error(LABEL, "scale falied"); + IMAGE_LOGE("scale falied"); } } @@ -2619,7 +2617,7 @@ void PixelMap::scale(float xAxis, float yAxis, const AntiAliasingOption &option) TransInfos infos; infos.matrix.setScale(xAxis, yAxis); if (!DoTranslation(infos, option)) { - HiLog::Error(LABEL, "scale falied"); + IMAGE_LOGE("scale falied"); } } @@ -2629,7 +2627,7 @@ bool PixelMap::resize(float xAxis, float yAxis) TransInfos infos; infos.matrix.setScale(xAxis, yAxis); if (!DoTranslation(infos)) { - HiLog::Error(LABEL, "resize falied"); + IMAGE_LOGE("resize falied"); return false; } return true; @@ -2641,7 +2639,7 @@ void PixelMap::translate(float xAxis, float yAxis) TransInfos infos; infos.matrix.setTranslate(xAxis, yAxis); if (!DoTranslation(infos)) { - HiLog::Error(LABEL, "translate falied"); + IMAGE_LOGE("translate falied"); } } @@ -2651,7 +2649,7 @@ void PixelMap::rotate(float degrees) TransInfos infos; infos.matrix.setRotate(degrees); if (!DoTranslation(infos)) { - HiLog::Error(LABEL, "rotate falied"); + IMAGE_LOGE("rotate falied"); } } @@ -2684,7 +2682,7 @@ uint32_t PixelMap::crop(const Rect &rect) } if (!src.r.contains(dst.r)) { - HiLog::Error(LABEL, "Invalid crop rect"); + IMAGE_LOGE("Invalid crop rect"); return ERR_IMAGE_CROP; } dst.info = src.info.makeWH(dstIRect.width(), dstIRect.height()); @@ -2692,20 +2690,20 @@ uint32_t PixelMap::crop(const Rect &rect) MemoryData memoryData = {nullptr, dst.info.computeMinByteSize(), "Trans ImageData", desiredSize}; auto m = MemoryManager::CreateMemory(allocatorType_, memoryData); if (m == nullptr) { - HiLog::Error(LABEL, "crop CreateMemory failed"); + IMAGE_LOGE("crop CreateMemory failed"); return ERR_IMAGE_CROP; } uint64_t rowStride = dst.info.minRowBytes(); #if !defined(IOS_PLATFORM) && !defined(A_PLATFORM) if (allocatorType_ == AllocatorType::DMA_ALLOC) { if (m->extend.data == nullptr) { - HiLog::Error(LABEL, "GendstTransInfo get surfacebuffer failed"); + IMAGE_LOGE("GendstTransInfo get surfacebuffer failed"); } rowStride = reinterpret_cast(m->extend.data)->GetStride(); } #endif if (!src.bitmap.readPixels(dst.info, m->data.data, rowStride, dstIRect.fLeft, dstIRect.fTop)) { - HiLog::Error(LABEL, "ReadPixels failed"); + IMAGE_LOGE("ReadPixels failed"); return ERR_IMAGE_CROP; } ToImageInfo(imageInfo, dst.info); @@ -2774,13 +2772,13 @@ uint32_t PixelMap::ApplyColorSpace(const OHOS::ColorManager::ColorSpace &grColor "Trans ImageData", {dst.info.width(), dst.info.height()}}; auto m = MemoryManager::CreateMemory(allocatorType_, memoryData); if (m == nullptr) { - HiLog::Error(LABEL, "applyColorSpace CreateMemory failed"); + IMAGE_LOGE("applyColorSpace CreateMemory failed"); return ERR_IMAGE_COLOR_CONVERT; } // Transfor pixels by readPixels if (!src.bitmap.readPixels(dst.info, m->data.data, rowStride, 0, 0)) { m->Release(); - HiLog::Error(LABEL, "ReadPixels failed"); + IMAGE_LOGE("ReadPixels failed"); return ERR_IMAGE_COLOR_CONVERT; } // Restore target infomation into pixelmap diff --git a/frameworks/innerkitsimpl/common/src/pixel_map_parcel.cpp b/frameworks/innerkitsimpl/common/src/pixel_map_parcel.cpp index d4217f876..6d8a10432 100644 --- a/frameworks/innerkitsimpl/common/src/pixel_map_parcel.cpp +++ b/frameworks/innerkitsimpl/common/src/pixel_map_parcel.cpp @@ -15,8 +15,7 @@ #include "pixel_map_parcel.h" #include -#include "hilog/log.h" -#include "log_tags.h" +#include "image_log.h" #include "media_errors.h" #ifndef _WIN32 #include "securec.h" @@ -29,11 +28,15 @@ #include "ashmem.h" #endif +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "PixelMapParcel" + namespace OHOS { namespace Media { -using namespace OHOS::HiviewDFX; using namespace std; -constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "PixelMapParcel" }; constexpr int32_t PIXEL_MAP_INFO_MAX_LENGTH = 128; @@ -63,18 +66,18 @@ uint8_t *PixelMapParcel::ReadAshmemDataFromParcel(OHOS::MessageParcel& data, int uint8_t *base = nullptr; int fd = data.ReadFileDescriptor(); if (fd < 0) { - HiLog::Error(LABEL, "read fileDescriptor failed, fd < 0"); + IMAGE_LOGE("read fileDescriptor failed, fd < 0"); return nullptr; } void* ptr = ::mmap(nullptr, bufferSize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if (ptr == MAP_FAILED) { ::close(fd); - HiLog::Error(LABEL, "mmap shared memory failed"); + IMAGE_LOGE("mmap shared memory failed"); return nullptr; } context = new int32_t(); if (context == nullptr) { - HiLog::Error(LABEL, "alloc context failed."); + IMAGE_LOGE("alloc context failed."); ::munmap(ptr, bufferSize); ::close(fd); return nullptr; @@ -89,22 +92,22 @@ uint8_t *PixelMapParcel::ReadHeapDataFromParcel(OHOS::MessageParcel& data, int32 const uint8_t *addr = data.ReadBuffer(bufferSize); uint8_t *base = nullptr; if (addr == nullptr) { - HiLog::Error(LABEL, "read buffer from parcel failed, read buffer addr is null"); + IMAGE_LOGE("read buffer from parcel failed, read buffer addr is null"); return nullptr; } if (bufferSize <= 0 || bufferSize > PIXEL_MAP_MAX_RAM_SIZE) { - HiLog::Error(LABEL, "read bufferSize failed, invalid bufferSize."); + IMAGE_LOGE("read bufferSize failed, invalid bufferSize."); return nullptr; } base = static_cast(malloc(bufferSize)); if (base == nullptr) { - HiLog::Error(LABEL, "alloc new pixel memory size:[%{public}d] failed.", bufferSize); + IMAGE_LOGE("alloc new pixel memory size:[%{public}d] failed.", bufferSize); return nullptr; } if (memcpy_s(base, bufferSize, addr, bufferSize) != 0) { free(base); base = nullptr; - HiLog::Error(LABEL, "memcpy pixel data size:[%{public}d] error.", bufferSize); + IMAGE_LOGE("memcpy pixel data size:[%{public}d] error.", bufferSize); return nullptr; } return base; @@ -114,7 +117,7 @@ std::unique_ptr PixelMapParcel::CreateFromParcel(OHOS::MessageParcel& { unique_ptr pixelMap = make_unique(); if (pixelMap == nullptr) { - HiLog::Error(LABEL, "create pixelmap pointer fail"); + IMAGE_LOGE("create pixelmap pointer fail"); return nullptr; } @@ -140,7 +143,7 @@ std::unique_ptr PixelMapParcel::CreateFromParcel(OHOS::MessageParcel& uint32_t ret = pixelMap->SetImageInfo(imgInfo); if (ret != SUCCESS) { ReleaseMemory(allocType, base, reinterpret_cast(context), bufferSize); - HiLog::Error(LABEL, "create pixel map from parcel failed, set image info error."); + IMAGE_LOGE("create pixel map from parcel failed, set image info error."); return nullptr; } pixelMap->SetPixelsAddr(base, reinterpret_cast(context), bufferSize, allocType, nullptr); @@ -152,40 +155,40 @@ bool PixelMapParcel::WriteImageInfo(PixelMap* pixelMap, OHOS::MessageParcel& dat int32_t bufferSize = pixelMap->GetByteCount(); if (static_cast(bufferSize + PIXEL_MAP_INFO_MAX_LENGTH) > data.GetDataCapacity() && !data.SetDataCapacity(bufferSize + PIXEL_MAP_INFO_MAX_LENGTH)) { - HiLog::Error(LABEL, "set parcel max capacity:[%{public}d] failed.", bufferSize + PIXEL_MAP_INFO_MAX_LENGTH); + IMAGE_LOGE("set parcel max capacity:[%{public}d] failed.", bufferSize + PIXEL_MAP_INFO_MAX_LENGTH); return false; } if (!data.WriteInt32(pixelMap->GetWidth())) { - HiLog::Error(LABEL, "write pixel map width:[%{public}d] to parcel failed.", pixelMap->GetWidth()); + IMAGE_LOGE("write pixel map width:[%{public}d] to parcel failed.", pixelMap->GetWidth()); return false; } if (!data.WriteInt32(pixelMap->GetHeight())) { - HiLog::Error(LABEL, "write pixel map height:[%{public}d] to parcel failed.", pixelMap->GetHeight()); + IMAGE_LOGE("write pixel map height:[%{public}d] to parcel failed.", pixelMap->GetHeight()); return false; } if (!data.WriteInt32(static_cast(pixelMap->GetPixelFormat()))) { - HiLog::Error(LABEL, "write pixel map pixel format:[%{public}d] to parcel failed.", pixelMap->GetPixelFormat()); + IMAGE_LOGE("write pixel map pixel format:[%{public}d] to parcel failed.", pixelMap->GetPixelFormat()); return false; } if (!data.WriteInt32(static_cast(pixelMap->GetColorSpace()))) { - HiLog::Error(LABEL, "write pixel map color space:[%{public}d] to parcel failed.", pixelMap->GetColorSpace()); + IMAGE_LOGE("write pixel map color space:[%{public}d] to parcel failed.", pixelMap->GetColorSpace()); return false; } if (!data.WriteInt32(static_cast(pixelMap->GetAlphaType()))) { - HiLog::Error(LABEL, "write pixel map alpha type:[%{public}d] to parcel failed.", pixelMap->GetAlphaType()); + IMAGE_LOGE("write pixel map alpha type:[%{public}d] to parcel failed.", pixelMap->GetAlphaType()); return false; } if (!data.WriteInt32(pixelMap->GetBaseDensity())) { - HiLog::Error(LABEL, "write pixel map base density:[%{public}d] to parcel failed.", pixelMap->GetBaseDensity()); + IMAGE_LOGE("write pixel map base density:[%{public}d] to parcel failed.", pixelMap->GetBaseDensity()); return false; } if (!data.WriteInt32(bufferSize)) { - HiLog::Error(LABEL, "write pixel map buffer size:[%{public}d] to parcel failed.", bufferSize); + IMAGE_LOGE("write pixel map buffer size:[%{public}d] to parcel failed.", bufferSize); return false; } if (!data.WriteInt32(static_cast(pixelMap->GetAllocatorType()))) { - HiLog::Error(LABEL, "write pixel map allocator type:[%{public}d] to parcel failed.", - pixelMap->GetAllocatorType()); + IMAGE_LOGE("write pixel map allocator type:[%{public}d] to parcel failed.", + pixelMap->GetAllocatorType()); return false; } return true; @@ -198,29 +201,29 @@ bool PixelMapParcel::WriteToParcel(PixelMap* pixelMap, OHOS::MessageParcel& data } int32_t bufferSize = pixelMap->GetByteCount(); if (!WriteImageInfo(pixelMap, data)) { - HiLog::Error(LABEL, "write pixel map info failed."); + IMAGE_LOGE("write pixel map info failed."); return false; } if (pixelMap->GetAllocatorType() == AllocatorType::SHARE_MEM_ALLOC) { #if !defined(_WIN32) && !defined(_APPLE) int *fd = static_cast(pixelMap->GetFd()); if (*fd < 0) { - HiLog::Error(LABEL, "write pixel map failed, fd < 0."); + IMAGE_LOGE("write pixel map failed, fd < 0."); return false; } if (!data.WriteFileDescriptor(*fd)) { - HiLog::Error(LABEL, "write pixel map fd:[%{public}d] to parcel failed.", *fd); + IMAGE_LOGE("write pixel map fd:[%{public}d] to parcel failed.", *fd); return false; } #endif } else { const uint8_t *addr = pixelMap->GetPixels(); if (addr == nullptr) { - HiLog::Error(LABEL, "write to parcel failed, pixel memory is null."); + IMAGE_LOGE("write to parcel failed, pixel memory is null."); return false; } if (!data.WriteBuffer(addr, bufferSize)) { - HiLog::Error(LABEL, "write pixel map buffer to parcel failed."); + IMAGE_LOGE("write pixel map buffer to parcel failed."); return false; } } diff --git a/frameworks/innerkitsimpl/converter/include/basic_transformer.h b/frameworks/innerkitsimpl/converter/include/basic_transformer.h index b114e6fd0..393e25f84 100644 --- a/frameworks/innerkitsimpl/converter/include/basic_transformer.h +++ b/frameworks/innerkitsimpl/converter/include/basic_transformer.h @@ -19,11 +19,16 @@ #include #include -#include "hilog/log.h" +#include "image_log.h" #include "image_type.h" -#include "log_tags.h" #include "matrix.h" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "BasicTransformer" + static constexpr uint32_t IMAGE_SUCCESS = 0; // success static constexpr uint32_t IMAGE_BASE_ERROR = 1000; // base error static constexpr uint32_t ERR_IMAGE_GENERAL_ERROR = IMAGE_BASE_ERROR + 1; // general error @@ -44,10 +49,6 @@ namespace Media { struct BilinearPixelProcArgs; using BilinearPixelProcArgs = struct BilinearPixelProcArgs; -using namespace OHOS::HiviewDFX; -static constexpr OHOS::HiviewDFX::HiLogLabel BASIC_TRANSFORMER_LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, - "BasicTransformer" }; - static inline bool CheckOutOfRange(const Point &pt, const Size &size) { if ((pt.x >= 0) && (pt.x < size.width) && (pt.y >= 0) && (pt.y < size.height)) { @@ -115,7 +116,7 @@ struct PixmapInfo { void PrintPixmapInfo(const std::string &strFlag) const { - HiLog::Debug(BASIC_TRANSFORMER_LABEL, "[PixmapInfo][%{public}s][width, height:%{public}d, %{public}d]" + IMAGE_LOGD("[PixmapInfo][%{public}s][width, height:%{public}d, %{public}d]" "[bufferSize:%{public}u][pixelFormat:%{public}d].", strFlag.c_str(), imageInfo.size.width, imageInfo.size.height, bufferSize, static_cast(imageInfo.pixelFormat)); } diff --git a/frameworks/innerkitsimpl/converter/src/basic_transformer.cpp b/frameworks/innerkitsimpl/converter/src/basic_transformer.cpp index d7622e60c..45d750fa5 100644 --- a/frameworks/innerkitsimpl/converter/src/basic_transformer.cpp +++ b/frameworks/innerkitsimpl/converter/src/basic_transformer.cpp @@ -31,6 +31,12 @@ #include #endif +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "BasicTransformer" + namespace { constexpr uint32_t RGB24_R_MASK = 0x00ff0000; constexpr uint32_t RGB24_G_MASK = 0x0000ff00; @@ -111,7 +117,7 @@ bool BasicTransformer::CheckAllocateBuffer(PixmapInfo &outPixmap, AllocateMem al int &fd, uint64_t &bufferSize, Size &dstSize) { if (bufferSize == 0 || bufferSize > PIXEL_MAP_MAX_RAM_SIZE) { - HiLog::Error(BASIC_TRANSFORMER_LABEL, "[BasicTransformer]Invalid value of bufferSize"); + IMAGE_LOGE("[BasicTransformer]Invalid value of bufferSize"); return false; } if (allocate == nullptr) { @@ -123,7 +129,7 @@ bool BasicTransformer::CheckAllocateBuffer(PixmapInfo &outPixmap, AllocateMem al outPixmap.context = tmp.release(); } if (outPixmap.data == nullptr) { - HiLog::Error(BASIC_TRANSFORMER_LABEL, "[BasicTransformer]apply heap memory failed"); + IMAGE_LOGE("[BasicTransformer]apply heap memory failed"); return false; } return true; @@ -152,12 +158,12 @@ void BasicTransformer::ReleaseBuffer(AllocatorType allocatorType, int fd, int da uint32_t BasicTransformer::TransformPixmap(const PixmapInfo &inPixmap, PixmapInfo &outPixmap, AllocateMem allocate) { if (inPixmap.data == nullptr) { - HiLog::Error(BASIC_TRANSFORMER_LABEL, "[BasicTransformer]input data is null."); + IMAGE_LOGE("[BasicTransformer]input data is null."); return ERR_IMAGE_GENERAL_ERROR; } int32_t pixelBytes = ImageUtils::GetPixelBytes(inPixmap.imageInfo.pixelFormat); if (pixelBytes == 0) { - HiLog::Error(BASIC_TRANSFORMER_LABEL, "[BasicTransformer]input pixel is invalid."); + IMAGE_LOGE("[BasicTransformer]input pixel is invalid."); return ERR_IMAGE_INVALID_PIXEL; } @@ -165,13 +171,13 @@ uint32_t BasicTransformer::TransformPixmap(const PixmapInfo &inPixmap, PixmapInf GetDstDimension(inPixmap.imageInfo.size, dstSize); outPixmap.imageInfo.size = dstSize; if (dstSize.width <= 0 || dstSize.height <= 0) { - HiLog::Error(BASIC_TRANSFORMER_LABEL, "[BasicTransformer]buffer size is invalid."); + IMAGE_LOGE("[BasicTransformer]buffer size is invalid."); return ERR_IMAGE_ALLOC_MEMORY_FAILED; } uint64_t bufferSize = static_cast(dstSize.width) * dstSize.height * pixelBytes; if (bufferSize > PIXEL_MAP_MAX_RAM_SIZE) { - HiLog::Error(BASIC_TRANSFORMER_LABEL, "[BasicTransformer] buffer size:%{public}llu out of range.", + IMAGE_LOGE("[BasicTransformer] buffer size:%{public}llu out of range.", static_cast(bufferSize)); return ERR_IMAGE_ALLOC_MEMORY_FAILED; } @@ -186,14 +192,14 @@ uint32_t BasicTransformer::TransformPixmap(const PixmapInfo &inPixmap, PixmapInf outPixmap.imageInfo.baseDensity = inPixmap.imageInfo.baseDensity; if (memset_s(outPixmap.data, bufferSize * sizeof(uint8_t), COLOR_DEFAULT, bufferSize * sizeof(uint8_t)) != EOK) { - HiLog::Error(BASIC_TRANSFORMER_LABEL, "[BasicTransformer]apply heap memory failed."); + IMAGE_LOGE("[BasicTransformer]apply heap memory failed."); ReleaseBuffer((allocate == nullptr) ? AllocatorType::HEAP_ALLOC : AllocatorType::SHARE_MEM_ALLOC, fd, bufferSize, outPixmap.data); return ERR_IMAGE_GENERAL_ERROR; } if (!DrawPixelmap(inPixmap, pixelBytes, dstSize, outPixmap.data)) { - HiLog::Error(BASIC_TRANSFORMER_LABEL, "[BasicTransformer] the matrix can not invert."); + IMAGE_LOGE("[BasicTransformer] the matrix can not invert."); ReleaseBuffer((allocate == nullptr) ? AllocatorType::HEAP_ALLOC : AllocatorType::SHARE_MEM_ALLOC, fd, bufferSize, outPixmap.data); return ERR_IMAGE_MATRIX_NOT_INVERT; @@ -336,7 +342,7 @@ void BasicTransformer::BilinearPixelProc(const AroundPos aroundPos, struct Bilin break; } default: - HiLog::Error(BASIC_TRANSFORMER_LABEL, "[BasicTransformer] pixel format not supported, format:%{public}d", + IMAGE_LOGE("[BasicTransformer] pixel format not supported, format:%{public}d", args.format); } } diff --git a/frameworks/innerkitsimpl/converter/src/matrix.cpp b/frameworks/innerkitsimpl/converter/src/matrix.cpp index ce70fa89d..feca04b0f 100644 --- a/frameworks/innerkitsimpl/converter/src/matrix.cpp +++ b/frameworks/innerkitsimpl/converter/src/matrix.cpp @@ -15,13 +15,16 @@ #include "matrix.h" -#include "hilog/log.h" -#include "log_tags.h" +#include "image_log.h" + +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "Matrix" namespace OHOS { namespace Media { -using namespace OHOS::HiviewDFX; -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "Matrix" }; Matrix &Matrix::Reset() { @@ -236,7 +239,7 @@ const Matrix::CalcXYProc Matrix::gCalcXYProcs[] = { Matrix::IdentityXY, Matrix:: // Matrix print function, including 9 elements void Matrix::Print() { - HiLog::Debug(LABEL, "[Matrix][%{public}8.4f %{public}8.4f %{public}8.4f]" + IMAGE_LOGD("[Matrix][%{public}8.4f %{public}8.4f %{public}8.4f]" "[%{public}8.4f %{public}8.4f %{public}8.4f][%{public}8.4f %{public}8.4f %{public}8.4f].", fMat_[0], fMat_[1], fMat_[2], fMat_[3], fMat_[4], fMat_[5], fMat_[6], fMat_[7], fMat_[8]); } diff --git a/frameworks/innerkitsimpl/converter/src/pixel_convert.cpp b/frameworks/innerkitsimpl/converter/src/pixel_convert.cpp index 75c22dacc..a1f6acf4e 100644 --- a/frameworks/innerkitsimpl/converter/src/pixel_convert.cpp +++ b/frameworks/innerkitsimpl/converter/src/pixel_convert.cpp @@ -18,14 +18,17 @@ #include #include -#include "hilog/log.h" -#include "log_tags.h" +#include "image_log.h" + +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "PixelConvert" namespace OHOS { namespace Media { using namespace std; -using namespace OHOS::HiviewDFX; -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "PixelConvert" }; #if __BYTE_ORDER == __LITTLE_ENDIAN constexpr bool IS_LITTLE_ENDIAN = true; #else @@ -1061,14 +1064,14 @@ PixelConvert::PixelConvert(ProcFuncType funcPtr, ProcFuncExtension extension, bo std::unique_ptr PixelConvert::Create(const ImageInfo &srcInfo, const ImageInfo &dstInfo) { if (srcInfo.pixelFormat == PixelFormat::UNKNOWN || dstInfo.pixelFormat == PixelFormat::UNKNOWN) { - HiLog::Error(LABEL, "source or destination pixel format unknown"); + IMAGE_LOGE("source or destination pixel format unknown"); return nullptr; } uint32_t srcFormat = static_cast(srcInfo.pixelFormat); uint32_t dstFormat = static_cast(dstInfo.pixelFormat); ProcFuncType funcPtr = GetProcFuncType(srcFormat, dstFormat); if (funcPtr == nullptr) { - HiLog::Error(LABEL, "not found convert function. pixelFormat %{public}u -> %{public}u", srcFormat, dstFormat); + IMAGE_LOGE("not found convert function. pixelFormat %{public}u -> %{public}u", srcFormat, dstFormat); return nullptr; } ProcFuncExtension extension; @@ -1083,7 +1086,7 @@ std::unique_ptr PixelConvert::Create(const ImageInfo &srcInfo, con AlphaConvertType PixelConvert::GetAlphaConvertType(const AlphaType &srcType, const AlphaType &dstType) { if (srcType == AlphaType::IMAGE_ALPHA_TYPE_UNKNOWN || dstType == AlphaType::IMAGE_ALPHA_TYPE_UNKNOWN) { - HiLog::Debug(LABEL, "source or destination alpha type unknown"); + IMAGE_LOGD("source or destination alpha type unknown"); return AlphaConvertType::NO_CONVERT; } if ((srcType == AlphaType::IMAGE_ALPHA_TYPE_PREMUL) && (dstType == AlphaType::IMAGE_ALPHA_TYPE_UNPREMUL)) { @@ -1104,11 +1107,11 @@ AlphaConvertType PixelConvert::GetAlphaConvertType(const AlphaType &srcType, con void PixelConvert::Convert(void *destinationPixels, const uint8_t *sourcePixels, uint32_t sourcePixelsNum) { if ((destinationPixels == nullptr) || (sourcePixels == nullptr)) { - HiLog::Error(LABEL, "destinationPixel or sourcePixel is null"); + IMAGE_LOGE("destinationPixel or sourcePixel is null"); return; } if (!isNeedConvert_) { - HiLog::Debug(LABEL, "no need convert"); + IMAGE_LOGD("no need convert"); return; } procFunc_(destinationPixels, sourcePixels, sourcePixelsNum, procFuncExtension_); diff --git a/frameworks/innerkitsimpl/converter/src/post_proc.cpp b/frameworks/innerkitsimpl/converter/src/post_proc.cpp index 48b0ecd5d..6351ca408 100644 --- a/frameworks/innerkitsimpl/converter/src/post_proc.cpp +++ b/frameworks/innerkitsimpl/converter/src/post_proc.cpp @@ -18,10 +18,9 @@ #include #include "basic_transformer.h" -#include "hilog/log.h" +#include "image_log.h" #include "image_trace.h" #include "image_utils.h" -#include "log_tags.h" #include "media_errors.h" #include "memory_manager.h" #include "pixel_convert_adapter.h" @@ -44,11 +43,16 @@ extern "C" { #ifdef __cplusplus }; #endif + +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "PostProc" + namespace OHOS { namespace Media { using namespace std; -using namespace OHOS::HiviewDFX; -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "PostProc" }; constexpr uint32_t NEED_NEXT = 1; constexpr float EPSILON = 1e-6; constexpr uint8_t HALF = 2; @@ -72,21 +76,21 @@ uint32_t PostProc::DecodePostProc(const DecodeOptions &opts, PixelMap &pixelMap, GetDstImageInfo(opts, pixelMap, srcImageInfo, dstImageInfo); uint32_t errorCode = ConvertProc(opts.CropRect, dstImageInfo, pixelMap, srcImageInfo); if (errorCode != SUCCESS) { - HiLog::Error(LABEL, "[PostProc]crop pixel map failed, errcode:%{public}u", errorCode); + IMAGE_LOGE("[PostProc]crop pixel map failed, errcode:%{public}u", errorCode); return errorCode; } decodeOpts_.allocatorType = opts.allocatorType; bool isNeedRotate = !ImageUtils::FloatCompareZero(opts.rotateDegrees); if (isNeedRotate) { if (!RotatePixelMap(opts.rotateDegrees, pixelMap)) { - HiLog::Error(LABEL, "[PostProc]rotate:transform pixel map failed"); + IMAGE_LOGE("[PostProc]rotate:transform pixel map failed"); return ERR_IMAGE_TRANSFORM; } } decodeOpts_.allocatorType = opts.allocatorType; if (opts.desiredSize.height > 0 && opts.desiredSize.width > 0) { if (!ScalePixelMap(opts.desiredSize, pixelMap)) { - HiLog::Error(LABEL, "[PostProc]scale:transform pixel map failed"); + IMAGE_LOGE("[PostProc]scale:transform pixel map failed"); return ERR_IMAGE_TRANSFORM; } } else { @@ -99,7 +103,7 @@ uint32_t PostProc::DecodePostProc(const DecodeOptions &opts, PixelMap &pixelMap, size.height = targetHeight; size.width = targetWidth; if (!ScalePixelMap(size, pixelMap)) { - HiLog::Error(LABEL, "[PostProc]density scale:transform pixel map failed"); + IMAGE_LOGE("[PostProc]density scale:transform pixel map failed"); return ERR_IMAGE_TRANSFORM; } info.baseDensity = opts.fitDensity; @@ -139,7 +143,7 @@ bool PostProc::CenterScale(const Size &size, PixelMap &pixelMap) int32_t targetWidth = size.width; int32_t targetHeight = size.height; if (targetWidth <= 0 || targetHeight <= 0 || srcWidth <= 0 || srcHeight <= 0) { - HiLog::Error(LABEL, "[PostProc]params invalid, targetWidth:%{public}d, targetHeight:%{public}d, " + IMAGE_LOGE("[PostProc]params invalid, targetWidth:%{public}d, targetHeight:%{public}d, " "srcWidth:%{public}d, srcHeight:%{public}d", targetWidth, targetHeight, srcWidth, srcHeight); return false; } @@ -164,7 +168,7 @@ bool PostProc::CenterScale(const Size &size, PixelMap &pixelMap) return true; } if (!ScalePixelMap(scale, scale, pixelMap)) { - HiLog::Error(LABEL, "[PostProc]center scale pixelmap %{public}f fail", scale); + IMAGE_LOGE("[PostProc]center scale pixelmap %{public}f fail", scale); return false; } srcWidth = pixelMap.GetWidth(); @@ -173,7 +177,7 @@ bool PostProc::CenterScale(const Size &size, PixelMap &pixelMap) return true; } if (srcWidth < targetWidth || srcHeight < targetHeight) { - HiLog::Error(LABEL, "[PostProc]src size [%{public}d, %{public}d] must less than dst size [%{public}d," + IMAGE_LOGE("[PostProc]src size [%{public}d, %{public}d] must less than dst size [%{public}d," "%{public}d]", srcWidth, srcHeight, targetWidth, targetHeight); return false; } @@ -207,7 +211,7 @@ bool PostProc::CopyPixels(PixelMap& pixelMap, uint8_t* dstPixels, const Size& ds srcStartPixel = srcPixels + scanLine * srcRowStride; errno_t errRet = memcpy_s(dstStartPixel, targetRowBytes, srcStartPixel, copyRowBytes); if (errRet != EOK) { - HiLog::Error(LABEL, "[PostProc]memcpy scanline %{public}d fail, errorCode = %{public}d", scanLine, errRet); + IMAGE_LOGE("[PostProc]memcpy scanline %{public}d fail, errorCode = %{public}d", scanLine, errRet); return false; } } @@ -223,7 +227,7 @@ bool PostProc::CenterDisplay(PixelMap &pixelMap, int32_t srcWidth, int32_t srcHe dstImageInfo.size.width = targetWidth; dstImageInfo.size.height = targetHeight; if (pixelMap.SetImageInfo(dstImageInfo, true) != SUCCESS) { - HiLog::Error(LABEL, "update ImageInfo failed"); + IMAGE_LOGE("update ImageInfo failed"); return false; } int32_t bufferSize = pixelMap.GetByteCount(); @@ -238,18 +242,18 @@ bool PostProc::CenterDisplay(PixelMap &pixelMap, int32_t srcWidth, int32_t srcHe } else if (pixelMap.GetAllocatorType() == AllocatorType::DMA_ALLOC) { dstPixels = AllocDmaMemory(dstImageInfo.size, bufferSize, &nativeBuffer, targetRowStride); if (dstPixels == nullptr) { - HiLog::Error(LABEL, "[PostProc]CenterDisplay AllocDmaMemory failed"); + IMAGE_LOGE("[PostProc]CenterDisplay AllocDmaMemory failed"); return false; } } else { dstPixels = AllocSharedMemory(dstImageInfo.size, bufferSize, fd, pixelMap.GetUniqueId()); if (dstPixels == nullptr) { - HiLog::Error(LABEL, "[PostProc]CenterDisplay AllocSharedMemory failed"); + IMAGE_LOGE("[PostProc]CenterDisplay AllocSharedMemory failed"); return false; } } if (!CopyPixels(pixelMap, dstPixels, dstImageInfo.size, srcWidth, srcHeight, srcRowStride, targetRowStride)) { - HiLog::Error(LABEL, "[PostProc]CopyPixels failed"); + IMAGE_LOGE("[PostProc]CopyPixels failed"); ReleaseBuffer(pixelMap.GetAllocatorType(), fd, bufferSize, &dstPixels, nativeBuffer); return false; } @@ -283,7 +287,7 @@ bool PostProc::ProcessScanlineFilter(ScanlineFilter &scanlineFilter, const Rect uint32_t ret = scanlineFilter.FilterLine(resultData + ((scanLine - cropRect.top) * rowBytes), rowBytes, srcData + (scanLine * pixelMap.GetRowBytes())); if (ret != SUCCESS) { - HiLog::Error(LABEL, "[PostProc]scan line failed, ret:%{public}u", ret); + IMAGE_LOGE("[PostProc]scan line failed, ret:%{public}u", ret); return false; } scanLine++; @@ -300,7 +304,7 @@ uint32_t PostProc::CheckScanlineFilter(const Rect &cropRect, ImageInfo &dstImage if (decodeOpts_.allocatorType == AllocatorType::SHARE_MEM_ALLOC) { resultData = AllocSharedMemory(dstImageInfo.size, bufferSize, fd, pixelMap.GetUniqueId()); if (resultData == nullptr) { - HiLog::Error(LABEL, "[PostProc]AllocSharedMemory failed"); + IMAGE_LOGE("[PostProc]AllocSharedMemory failed"); return ERR_IMAGE_CROP; } } else { @@ -309,14 +313,14 @@ uint32_t PostProc::CheckScanlineFilter(const Rect &cropRect, ImageInfo &dstImage } } if (ImageUtils::CheckMulOverflow(dstImageInfo.size.width, pixelBytes)) { - HiLog::Error(LABEL, "[PostProc]size.width:%{public}d, is too large", + IMAGE_LOGE("[PostProc]size.width:%{public}d, is too large", dstImageInfo.size.width); ReleaseBuffer(decodeOpts_.allocatorType, fd, bufferSize, &resultData); return ERR_IMAGE_CROP; } uint32_t rowBytes = pixelBytes * dstImageInfo.size.width; if (!ProcessScanlineFilter(scanlineFilter, cropRect, pixelMap, resultData, rowBytes)) { - HiLog::Error(LABEL, "[PostProc]ProcessScanlineFilter failed"); + IMAGE_LOGE("[PostProc]ProcessScanlineFilter failed"); ReleaseBuffer(decodeOpts_.allocatorType, fd, bufferSize, &resultData); return ERR_IMAGE_CROP; } @@ -348,7 +352,7 @@ uint32_t PostProc::ConvertProc(const Rect &cropRect, ImageInfo &dstImageInfo, Pi // we suppose a quick method to scanline in mostly seen cases: NO CROP && hasPixelConvert if (GetCropValue(cropRect, srcImageInfo.size) == CropValue::NOCROP && dstImageInfo.pixelFormat == PixelFormat::ARGB_8888 && hasPixelConvert) { - HiLog::Info(LABEL, "[PostProc]no need crop, only pixel convert."); + IMAGE_LOGI("[PostProc]no need crop, only pixel convert."); return PixelConvertProc(dstImageInfo, pixelMap, srcImageInfo); } @@ -361,7 +365,7 @@ uint32_t PostProc::ConvertProc(const Rect &cropRect, ImageInfo &dstImageInfo, Pi return ERR_IMAGE_CROP; } if (ImageUtils::CheckMulOverflow(dstImageInfo.size.width, dstImageInfo.size.height, pixelBytes)) { - HiLog::Error(LABEL, "[PostProc]size.width:%{public}d, size.height:%{public}d is too large", + IMAGE_LOGE("[PostProc]size.width:%{public}d, size.height:%{public}d is too large", dstImageInfo.size.width, dstImageInfo.size.height); return ERR_IMAGE_CROP; } @@ -412,17 +416,17 @@ uint32_t PostProc::AllocBuffer(ImageInfo imageInfo, uint8_t **resultData, uint64 return ERR_IMAGE_CROP; } if (ImageUtils::CheckMulOverflow(imageInfo.size.width, imageInfo.size.height, pixelBytes)) { - HiLog::Error(LABEL, "[PostProc]size.width:%{public}d, size.height:%{public}d is too large", + IMAGE_LOGE("[PostProc]size.width:%{public}d, size.height:%{public}d is too large", imageInfo.size.width, imageInfo.size.height); return ERR_IMAGE_CROP; } bufferSize = static_cast(imageInfo.size.width) * imageInfo.size.height * pixelBytes; - HiLog::Debug(LABEL, "[PostProc]size.width:%{public}d, size.height:%{public}d, bufferSize:%{public}lld", + IMAGE_LOGD("[PostProc]size.width:%{public}d, size.height:%{public}d, bufferSize:%{public}lld", imageInfo.size.width, imageInfo.size.height, static_cast(bufferSize)); if (decodeOpts_.allocatorType == AllocatorType::SHARE_MEM_ALLOC) { *resultData = AllocSharedMemory(imageInfo.size, bufferSize, fd, id); if (*resultData == nullptr) { - HiLog::Error(LABEL, "[PostProc]AllocSharedMemory failed"); + IMAGE_LOGE("[PostProc]AllocSharedMemory failed"); return ERR_IMAGE_CROP; } } else { @@ -436,19 +440,19 @@ uint32_t PostProc::AllocBuffer(ImageInfo imageInfo, uint8_t **resultData, uint64 bool PostProc::AllocHeapBuffer(uint64_t bufferSize, uint8_t **buffer) { if (bufferSize == 0 || bufferSize > MALLOC_MAX_LENTH) { - HiLog::Error(LABEL, "[PostProc]Invalid value of bufferSize"); + IMAGE_LOGE("[PostProc]Invalid value of bufferSize"); return false; } *buffer = static_cast(malloc(bufferSize)); if (*buffer == nullptr) { - HiLog::Error(LABEL, "[PostProc]alloc covert color buffersize[%{public}llu] failed.", + IMAGE_LOGE("[PostProc]alloc covert color buffersize[%{public}llu] failed.", static_cast(bufferSize)); return false; } #ifdef _WIN32 errno_t backRet = memset_s(*buffer, 0, bufferSize); if (backRet != EOK) { - HiLog::Error(LABEL, "[PostProc]memset convertData fail, errorCode = %{public}d", backRet); + IMAGE_LOGE("[PostProc]memset convertData fail, errorCode = %{public}d", backRet); ReleaseBuffer(AllocatorType::HEAP_ALLOC, 0, 0, buffer); return false; } @@ -456,7 +460,7 @@ bool PostProc::AllocHeapBuffer(uint64_t bufferSize, uint8_t **buffer) #else errno_t errRet = memset_s(*buffer, bufferSize, 0, bufferSize); if (errRet != EOK) { - HiLog::Error(LABEL, "[PostProc]memset convertData fail, errorCode = %{public}d", errRet); + IMAGE_LOGE("[PostProc]memset convertData fail, errorCode = %{public}d", errRet); ReleaseBuffer(AllocatorType::HEAP_ALLOC, 0, 0, buffer); return false; } @@ -472,19 +476,19 @@ uint8_t *PostProc::AllocSharedMemory(const Size &size, const uint64_t bufferSize std::string name = "Parcel RawData, uniqueId: " + std::to_string(getpid()) + '_' + std::to_string(uniqueId); fd = AshmemCreate(name.c_str(), bufferSize); if (fd < 0) { - HiLog::Error(LABEL, "[PostProc]AllocSharedMemory fd error, bufferSize %{public}lld", + IMAGE_LOGE("[PostProc]AllocSharedMemory fd error, bufferSize %{public}lld", static_cast(bufferSize)); return nullptr; } int result = AshmemSetProt(fd, PROT_READ | PROT_WRITE); if (result < 0) { - HiLog::Error(LABEL, "[PostProc]AshmemSetProt error"); + IMAGE_LOGE("[PostProc]AshmemSetProt error"); ::close(fd); return nullptr; } void* ptr = ::mmap(nullptr, bufferSize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if (ptr == MAP_FAILED) { - HiLog::Error(LABEL, "[PostProc]mmap error, errno: %{public}s, fd %{public}d, bufferSize %{public}lld", + IMAGE_LOGE("[PostProc]mmap error, errno: %{public}s, fd %{public}d, bufferSize %{public}lld", strerror(errno), fd, (long long)bufferSize); ::close(fd); return nullptr; @@ -526,7 +530,7 @@ void PostProc::ReleaseBuffer(AllocatorType allocatorType, int fd, if (nativeBuffer != nullptr) { int32_t err = ImageUtils::SurfaceBuffer_Unreference(static_cast(nativeBuffer)); if (err != OHOS::GSERROR_OK) { - HiLog::Error(LABEL, "PostProc NativeBufferReference failed"); + IMAGE_LOGE("PostProc NativeBufferReference failed"); } } return; @@ -546,10 +550,10 @@ uint32_t PostProc::NeedScanlineFilter(const Rect &cropRect, const Size &srcSize, { CropValue value = GetCropValue(cropRect, srcSize); if (value == CropValue::NOCROP && !hasPixelConvert) { - HiLog::Info(LABEL, "[PostProc]no need crop and pixel convert."); + IMAGE_LOGI("[PostProc]no need crop and pixel convert."); return SUCCESS; } else if (value == CropValue::INVALID) { - HiLog::Error(LABEL, "[PostProc]invalid corp region, top:%{public}d, left:%{public}d, " + IMAGE_LOGE("[PostProc]invalid corp region, top:%{public}d, left:%{public}d, " "width:%{public}d, height:%{public}d", cropRect.top, cropRect.left, cropRect.width, cropRect.height); return ERR_IMAGE_CROP; } @@ -584,7 +588,7 @@ bool PostProc::ScalePixelMap(const Size &size, PixelMap &pixelMap) int32_t srcWidth = pixelMap.GetWidth(); int32_t srcHeight = pixelMap.GetHeight(); if (srcWidth <= 0 || srcHeight <= 0) { - HiLog::Error(LABEL, "[PostProc]src width:%{public}d, height:%{public}d is invalid.", srcWidth, srcHeight); + IMAGE_LOGE("[PostProc]src width:%{public}d, height:%{public}d is invalid.", srcWidth, srcHeight); return false; } float scaleX = static_cast(size.width) / static_cast(srcWidth); @@ -613,7 +617,7 @@ bool PostProc::TranslatePixelMap(float tX, float tY, PixelMap &pixelMap) bool PostProc::Transform(BasicTransformer &trans, const PixmapInfo &input, PixelMap &pixelMap) { if (pixelMap.IsTransformered()) { - HiLog::Error(LABEL, "[PostProc]Transform pixelmap is transforming"); + IMAGE_LOGE("[PostProc]Transform pixelmap is transforming"); return false; } pixelMap.SetTransformered(true); @@ -747,19 +751,19 @@ bool PostProc::ScalePixelMapEx(const Size &desiredSize, PixelMap &pixelMap, cons int32_t srcWidth = pixelMap.GetWidth(); int32_t srcHeight = pixelMap.GetHeight(); if (srcWidth <= 0 || srcHeight <= 0 || !pixelMap.GetWritablePixels()) { - HiLog::Error(LABEL, "pixelMap param is invalid, src width:%{public}d, height:%{public}d", srcWidth, srcHeight); + IMAGE_LOGE("pixelMap param is invalid, src width:%{public}d, height:%{public}d", srcWidth, srcHeight); return false; } AVPixelFormat pixelFormat; if (!GetScaleFormat(imgInfo.pixelFormat, pixelFormat)) { - HiLog::Error(LABEL, "pixelMap format is invalid, format: %{public}d", imgInfo.pixelFormat); + IMAGE_LOGE("pixelMap format is invalid, format: %{public}d", imgInfo.pixelFormat); return false; } uint32_t dstBufferSize = desiredSize.height * desiredSize.width * ImageUtils::GetPixelBytes(imgInfo.pixelFormat); MemoryData memoryData = {nullptr, dstBufferSize, "ScalePixelMapEx ImageData", desiredSize}; auto mem = MemoryManager::CreateMemory(pixelMap.GetAllocatorType(), memoryData); if (mem == nullptr) { - HiLog::Error(LABEL, "ScalePixelMapEx CreateMemory failed"); + IMAGE_LOGE("ScalePixelMapEx CreateMemory failed"); return false; } @@ -778,7 +782,7 @@ bool PostProc::ScalePixelMapEx(const Size &desiredSize, PixelMap &pixelMap, cons if (!res) { sws_freeContext(swsContext); mem->Release(); - HiLog::Error(LABEL, "sws_scale failed"); + IMAGE_LOGE("sws_scale failed"); return false; } pixelMap.SetPixelsAddr(mem->data.data, mem->extend.data, dstBufferSize, mem->GetType(), nullptr); diff --git a/frameworks/innerkitsimpl/converter/src/scan_line_filter.cpp b/frameworks/innerkitsimpl/converter/src/scan_line_filter.cpp index 00ae5cb8e..626bb48b7 100644 --- a/frameworks/innerkitsimpl/converter/src/scan_line_filter.cpp +++ b/frameworks/innerkitsimpl/converter/src/scan_line_filter.cpp @@ -15,9 +15,8 @@ #include "scan_line_filter.h" -#include "hilog/log.h" +#include "image_log.h" #include "image_utils.h" -#include "log_tags.h" #include "media_errors.h" #ifndef _WIN32 #include "securec.h" @@ -25,10 +24,14 @@ #include "memory.h" #endif +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "ScanLineFilter" + namespace OHOS { namespace Media { -using namespace OHOS::HiviewDFX; -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "ScanLineFilter" }; ScanlineFilter::ScanlineFilter(const PixelFormat &srcPixelFormat) : srcBpp_(ImageUtils::GetPixelBytes(srcPixelFormat)) {} @@ -66,23 +69,23 @@ void ScanlineFilter::SetPixelConvert(const ImageInfo &srcImageInfo, const ImageI uint32_t ScanlineFilter::FilterLine(void *destRowPixels, uint32_t destRowBytes, const void *srcRowPixels) { if (destRowPixels == nullptr || srcRowPixels == nullptr) { - HiLog::Error(LABEL, "[ScanlineFilter]the src or dest pixel point is null."); + IMAGE_LOGE("[ScanlineFilter]the src or dest pixel point is null."); return ERR_IMAGE_CROP; } auto startPixel = static_cast(srcRowPixels) + srcRegion_.left * srcBpp_; if (startPixel == nullptr) { - HiLog::Error(LABEL, "[ScanlineFilter]the shift src pixel point is null."); + IMAGE_LOGE("[ScanlineFilter]the shift src pixel point is null."); return ERR_IMAGE_CROP; } if (!needPixelConvert_) { errno_t ret = memcpy_s(destRowPixels, destRowBytes, startPixel, srcRegion_.width * srcBpp_); if (ret != 0) { - HiLog::Error(LABEL, "[ScanlineFilter]memcpy failed,ret=%{public}d.", ret); + IMAGE_LOGE("[ScanlineFilter]memcpy failed,ret=%{public}d.", ret); return ERR_IMAGE_CROP; } } else { if (!ConvertPixels(destRowPixels, startPixel, srcRegion_.width)) { - HiLog::Error(LABEL, "[ScanlineFilter]convert color failed."); + IMAGE_LOGE("[ScanlineFilter]convert color failed."); return ERR_IMAGE_COLOR_CONVERT; } } @@ -92,12 +95,12 @@ uint32_t ScanlineFilter::FilterLine(void *destRowPixels, uint32_t destRowBytes, bool ScanlineFilter::ConvertPixels(void *destRowPixels, const uint8_t *startPixel, uint32_t reqPixelNum) { if (destRowPixels == nullptr || startPixel == nullptr) { - HiLog::Error(LABEL, "[ScanlineFilter]convert color failed, the destRowPixels or startPixel is null."); + IMAGE_LOGE("[ScanlineFilter]convert color failed, the destRowPixels or startPixel is null."); return false; } if (pixelConverter_ == nullptr) { - HiLog::Error(LABEL, "[ScanlineFilter]pixel converter is null"); + IMAGE_LOGE("[ScanlineFilter]pixel converter is null"); return false; } diff --git a/frameworks/innerkitsimpl/creator/src/image_creator.cpp b/frameworks/innerkitsimpl/creator/src/image_creator.cpp index 308cd8e23..5270de9b6 100644 --- a/frameworks/innerkitsimpl/creator/src/image_creator.cpp +++ b/frameworks/innerkitsimpl/creator/src/image_creator.cpp @@ -15,19 +15,22 @@ #include "image_creator.h" -#include "hilog/log.h" #include "image_creator_buffer_processor.h" #include "image_creator_manager.h" +#include "image_log.h" #include "image_packer.h" #include "image_source.h" #include "image_utils.h" -#include "log_tags.h" + +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "imageCreator" namespace OHOS { namespace Media { -constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "imageCreator"}; std::map ImageCreator::bufferCreatorMap_; -using namespace OHOS::HiviewDFX; ImageCreator::~ImageCreator() { if (iraContext_ != nullptr) { @@ -42,7 +45,7 @@ ImageCreator::~ImageCreator() GSError ImageCreator::OnBufferRelease(sptr &buffer) { - HiLog::Info(LABEL, "OnBufferRelease"); + IMAGE_LOGI("OnBufferRelease"); if (buffer == nullptr) { return GSERROR_NO_ENTRY; } @@ -52,7 +55,7 @@ GSError ImageCreator::OnBufferRelease(sptr &buffer) } auto icr = iter->second; if (icr->surfaceBufferReleaseListener_ == nullptr) { - HiLog::Info(LABEL, "empty icr"); + IMAGE_LOGI("empty icr"); return GSERROR_NO_ENTRY; } icr->surfaceBufferReleaseListener_->OnSurfaceBufferRelease(); @@ -68,7 +71,7 @@ std::shared_ptr ImageCreatorContext ::CreateImageCreatorCon void ImageCreatorSurfaceListener ::OnBufferAvailable() { - HiLog::Debug(LABEL, "CreatorBufferAvailable"); + IMAGE_LOGD("CreatorBufferAvailable"); if (ic_->surfaceBufferAvaliableListener_ != nullptr) { ic_->surfaceBufferAvaliableListener_->OnSurfaceBufferAvaliable(); } @@ -81,7 +84,7 @@ std::shared_ptr ImageCreator::CreateImageCreator(int32_t width, iva->iraContext_ = ImageCreatorContext::CreateImageCreatorContext(); iva->creatorConsumerSurface_ = IConsumerSurface::Create(); if (iva->creatorConsumerSurface_ == nullptr) { - HiLog::Debug(LABEL, "SurfaceAsConsumer == nullptr"); + IMAGE_LOGD("SurfaceAsConsumer == nullptr"); return iva; } iva->creatorConsumerSurface_->SetDefaultWidthAndHeight(width, height); @@ -94,7 +97,7 @@ std::shared_ptr ImageCreator::CreateImageCreator(int32_t width, iva->creatorProducerSurface_ = Surface::CreateSurfaceAsProducer(p); iva->creatorProducerSurface_->SetQueueSize(capicity); if (iva->creatorProducerSurface_ == nullptr) { - HiLog::Debug(LABEL, "SurfaceAsProducer == nullptr"); + IMAGE_LOGD("SurfaceAsProducer == nullptr"); return iva; } iva->iraContext_->SetCreatorBufferConsumer(iva->creatorConsumerSurface_); @@ -113,7 +116,7 @@ std::shared_ptr ImageCreator::CreateImageCreator(int32_t width, int64_t CreatorPackImage(uint8_t *tempBuffer, uint32_t bufferSize, std::unique_ptr pixelMap) { - HiLog::Debug(LABEL, "PackImage"); + IMAGE_LOGD("PackImage"); ImagePacker imagePacker; PackOption option; option.format = ImageReceiver::OPTION_FORMAT; @@ -123,16 +126,16 @@ int64_t CreatorPackImage(uint8_t *tempBuffer, uint32_t bufferSize, std::unique_p uint32_t ret = imagePacker.GetSupportedFormats(formats); if (ret != SUCCESS) { - HiLog::Error(LABEL, "image packer get supported format failed, ret=%{public}u.", ret); + IMAGE_LOGE("image packer get supported format failed, ret=%{public}u.", ret); return 0; } else { - HiLog::Debug(LABEL, "SUCCESS"); + IMAGE_LOGD("SUCCESS"); } imagePacker.StartPacking(tempBuffer, bufferSize, option); imagePacker.AddImage(*pixelMap); int64_t packedSize = 0; imagePacker.FinalizePacking(packedSize); - HiLog::Info(LABEL, "packedSize=%{public}lld.", static_cast(packedSize)); + IMAGE_LOGI("packedSize=%{public}lld.", static_cast(packedSize)); return packedSize; } static const int BIT4 = 4; @@ -148,13 +151,13 @@ static void dumpBuffer(const uint8_t* tempBuffer, int64_t size) ss.push_back(xx[tempBuffer[i]&BIT4_MASK]); if (i % PRINT_WIDTH == PRINT_WIDTH_MOD) { ss.push_back('\0'); - HiLog::Info(LABEL, "buffer[%{public}d] = [%{public}s]", i, ss.data()); + IMAGE_LOGI("buffer[%{public}d] = [%{public}s]", i, ss.data()); ss.clear(); ss.resize(0); } } ss.push_back('\0'); - HiLog::Info(LABEL, "buffer[LAST] = [%{public}s]", ss.data()); + IMAGE_LOGI("buffer[LAST] = [%{public}s]", ss.data()); ss.clear(); ss.resize(0); } @@ -167,10 +170,10 @@ int32_t ImageCreator::SaveSTP(uint32_t *buffer, if (pixelMap.get() != nullptr) { ImageInfo imageInfo; pixelMap->GetImageInfo(imageInfo); - HiLog::Debug(LABEL, "create pixel map imageInfo.size.width=%{public}u.", + IMAGE_LOGD("create pixel map imageInfo.size.width=%{public}u.", imageInfo.size.width); } else { - HiLog::Error(LABEL, "pixelMap.get() == nullptr"); + IMAGE_LOGE("pixelMap.get() == nullptr"); return ERR_MEDIA_INVALID_VALUE; } ImagePacker imagePacker; @@ -199,18 +202,18 @@ static void ReleaseBuffer(AllocatorType allocatorType, uint8_t **buffer) static bool AllocHeapBuffer(uint64_t bufferSize, uint8_t **buffer) { if (bufferSize == 0 || bufferSize > MALLOC_MAX_LENTH) { - HiLog::Error(LABEL, "[PostProc]Invalid value of bufferSize"); + IMAGE_LOGE("[PostProc]Invalid value of bufferSize"); return false; } *buffer = static_cast(malloc(bufferSize)); if (*buffer == nullptr) { - HiLog::Error(LABEL, "[PostProc]alloc covert color buffersize[%{public}llu] failed.", + IMAGE_LOGE("[PostProc]alloc covert color buffersize[%{public}llu] failed.", static_cast(bufferSize)); return false; } errno_t errRet = memset_s(*buffer, bufferSize, 0, bufferSize); if (errRet != EOK) { - HiLog::Error(LABEL, "[PostProc]memset convertData fail, errorCode = %{public}d", errRet); + IMAGE_LOGE("[PostProc]memset convertData fail, errorCode = %{public}d", errRet); ReleaseBuffer(AllocatorType::HEAP_ALLOC, buffer); return false; } @@ -226,14 +229,14 @@ int32_t ImageCreator::SaveSenderBufferAsImage(OHOS::sptr bu uint8_t *addr2 = nullptr; int32_t size = buffer->GetSize(); if (!AllocHeapBuffer(size, &addr2)) { - HiLog::Error(LABEL, "AllocHeapBuffer failed"); + IMAGE_LOGE("AllocHeapBuffer failed"); return ERR_MEDIA_INVALID_VALUE; } errorcode = SaveSTP(addr, addr2, static_cast(size), initializationOpts); (iraContext_->GetCreatorBufferConsumer())->ReleaseBuffer(buffer, -1); - HiLog::Info(LABEL, "start release"); + IMAGE_LOGI("start release"); } else { - HiLog::Debug(LABEL, "SaveBufferAsImage buffer == nullptr"); + IMAGE_LOGD("SaveBufferAsImage buffer == nullptr"); } return errorcode; } @@ -254,7 +257,7 @@ OHOS::sptr ImageCreator::DequeueImage() if (surfaceError == SURFACE_ERROR_OK) { iraContext_->currentCreatorBuffer_ = buffer; } else { - HiLog::Debug(LABEL, "error : request buffer is null"); + IMAGE_LOGD("error : request buffer is null"); } if (buffer != nullptr && buffer->GetVirAddr() != nullptr) { bufferCreatorMap_.insert( @@ -265,16 +268,16 @@ OHOS::sptr ImageCreator::DequeueImage() void ImageCreator::QueueImage(OHOS::sptr &buffer) { - HiLog::Info(LABEL, "start Queue Image"); + IMAGE_LOGI("start Queue Image"); int32_t flushFence = -1; BufferFlushConfig config; config.damage.w = iraContext_->GetWidth(); config.damage.h = iraContext_->GetHeight(); sptr creatorSurface = iraContext_->GetCreatorBufferProducer(); SurfaceError surfaceError = creatorSurface->FlushBuffer(buffer, flushFence, config); - HiLog::Info(LABEL, "finish Queue Image"); + IMAGE_LOGI("finish Queue Image"); if (surfaceError != SURFACE_ERROR_OK) { - HiLog::Debug(LABEL, "Queue fail"); + IMAGE_LOGD("Queue fail"); } } sptr ImageCreator::GetCreatorSurface() @@ -286,7 +289,7 @@ sptr ImageCreator::getSurfaceById(std::string id) { ImageCreatorManager& imageCreatorManager = ImageCreatorManager::getInstance(); sptr surface = imageCreatorManager.GetSurfaceByKeyId(id); - HiLog::Debug(LABEL, "getSurfaceByCreatorId"); + IMAGE_LOGD("getSurfaceByCreatorId"); return surface; } void ImageCreator::ReleaseCreator() diff --git a/frameworks/innerkitsimpl/egl_image/src/pixel_map_from_surface.cpp b/frameworks/innerkitsimpl/egl_image/src/pixel_map_from_surface.cpp index cef85e416..534e8fe95 100644 --- a/frameworks/innerkitsimpl/egl_image/src/pixel_map_from_surface.cpp +++ b/frameworks/innerkitsimpl/egl_image/src/pixel_map_from_surface.cpp @@ -15,14 +15,17 @@ #include "pixel_map_from_surface.h" +#include "image_log.h" #include "sync_fence.h" -#include "hilog/log.h" -#include "log_tags.h" + +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "PixelMap" namespace OHOS { namespace Media { -constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "PixelMap" }; -using namespace OHOS::HiviewDFX; PixelMapFromSurface::PixelMapFromSurface() {} @@ -70,7 +73,7 @@ bool PixelMapFromSurface::GetNativeWindowBufferFromSurface(const sptr & int ret = surface->GetLastFlushedBuffer(surfaceBuffer_, fence, matrix); if (ret != OHOS::GSERROR_OK || surfaceBuffer_ == nullptr) { Clear(); - HiLog::Error(LABEL, + IMAGE_LOGE( "CreatePixelMapFromSurface: GetLastFlushedBuffer from nativeWindow failed, err: %{public}d", ret); return false; @@ -81,7 +84,7 @@ bool PixelMapFromSurface::GetNativeWindowBufferFromSurface(const sptr & if (srcRect.width > bufferWidth || srcRect.height > bufferHeight || srcRect.left >= bufferWidth || srcRect.top >= bufferHeight || srcRect.left + srcRect.width > bufferWidth || srcRect.top + srcRect.height > bufferHeight) { - HiLog::Error(LABEL, + IMAGE_LOGE( "CreatePixelMapFromSurface: invalid argument: srcRect[%{public}d, %{public}d, %{public}d, %{public}d]," "bufferSize:[%{public}d, %{public}d]", srcRect.left, srcRect.top, srcRect.width, srcRect.height, @@ -108,7 +111,7 @@ bool PixelMapFromSurface::CreateEGLImage() nativeWindowBuffer_, attrs); if (eglImage_ == EGL_NO_IMAGE_KHR) { Clear(); - HiLog::Error(LABEL, "%{public}s create egl image fail %{public}d", __func__, eglGetError()); + IMAGE_LOGE("%{public}s create egl image fail %{public}d", __func__, eglGetError()); return false; } glGenTextures(1, &texId_); @@ -121,7 +124,7 @@ bool PixelMapFromSurface::CreateEGLImage() eglGetProcAddress("glEGLImageTargetTexture2DOES")); if (glEGLImageTargetTexture2DOESFunc == nullptr) { Clear(); - HiLog::Error(LABEL, "%{public}s glEGLImageTargetTexture2DOES func not found: %{public}d", + IMAGE_LOGE("%{public}s glEGLImageTargetTexture2DOES func not found: %{public}d", __func__, eglGetError()); return false; } @@ -149,7 +152,7 @@ bool PixelMapFromSurface::DrawImage(const Rect &srcRect) kTopLeft_GrSurfaceOrigin, colorType, kPremul_SkAlphaType, nullptr); if (image == nullptr) { Clear(); - HiLog::Error(LABEL, "%{public}s create SkImage failed.", __func__); + IMAGE_LOGE("%{public}s create SkImage failed.", __func__); return false; } @@ -158,7 +161,7 @@ bool PixelMapFromSurface::DrawImage(const Rect &srcRect) imageInfo, 0, kTopLeft_GrSurfaceOrigin, nullptr); if (targetSurface_ == nullptr) { Clear(); - HiLog::Error(LABEL, "%{public}s SkSurface::MakeRenderTarget failed.", __func__); + IMAGE_LOGE("%{public}s SkSurface::MakeRenderTarget failed.", __func__); return false; } @@ -177,7 +180,7 @@ bool PixelMapFromSurface::DrawImage(const Rect &srcRect) std::unique_ptr PixelMapFromSurface::Create(uint64_t surfaceId, const Rect &srcRect) { if (srcRect.left < 0 || srcRect.top < 0 || srcRect.width <= 0 || srcRect.height <= 0) { - HiLog::Error(LABEL, + IMAGE_LOGE( "CreatePixelMapFromSurface: invalid argument: srcRect[%{public}d, %{public}d, %{public}d, %{public}d]", srcRect.left, srcRect.top, srcRect.width, srcRect.height); return nullptr; @@ -186,7 +189,7 @@ std::unique_ptr PixelMapFromSurface::Create(uint64_t surfaceId, const Clear(); sptr surface = SurfaceUtils::GetInstance()->GetSurface(surfaceId); if (surface == nullptr) { - HiLog::Error(LABEL, + IMAGE_LOGE( "CreatePixelMapFromSurface: can't find surface for surfaceId: %{public}" PRIu64 ".", surfaceId); return nullptr; } @@ -199,7 +202,7 @@ std::unique_ptr PixelMapFromSurface::Create(uint64_t surfaceId, const renderContext_ = std::make_unique(); if (!renderContext_->Init()) { Clear(); - HiLog::Error(LABEL, "CreatePixelMapFromSurface: init renderContext failed."); + IMAGE_LOGE("CreatePixelMapFromSurface: init renderContext failed."); return nullptr; } diff --git a/frameworks/innerkitsimpl/egl_image/src/render_context.cpp b/frameworks/innerkitsimpl/egl_image/src/render_context.cpp index be8940556..6794e9e9c 100644 --- a/frameworks/innerkitsimpl/egl_image/src/render_context.cpp +++ b/frameworks/innerkitsimpl/egl_image/src/render_context.cpp @@ -15,13 +15,16 @@ #include "render_context.h" -#include "hilog/log.h" -#include "log_tags.h" +#include "image_log.h" + +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "PixelMap" namespace OHOS { namespace Media { -constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "PixelMap" }; -using namespace OHOS::HiviewDFX; RenderContext::RenderContext() {} @@ -48,19 +51,19 @@ bool RenderContext::InitEGLContext() { eglDisplay_ = eglGetPlatformDisplay(EGL_PLATFORM_OHOS_KHR, EGL_DEFAULT_DISPLAY, nullptr); if (eglDisplay_ == EGL_NO_DISPLAY) { - HiLog::Error(LABEL, "RenderContext::Init: eglGetDisplay error: "); + IMAGE_LOGE("RenderContext::Init: eglGetDisplay error: "); return false; } EGLint major = 0; EGLint minor = 0; if (eglInitialize(eglDisplay_, &major, &minor) == EGL_FALSE) { - HiLog::Error(LABEL, "Failed to initialize EGLDisplay"); + IMAGE_LOGE("Failed to initialize EGLDisplay"); return false; } if (eglBindAPI(EGL_OPENGL_ES_API) == EGL_FALSE) { - HiLog::Error(LABEL, "Failed to bind OpenGL ES API"); + IMAGE_LOGE("Failed to bind OpenGL ES API"); return false; } @@ -71,14 +74,14 @@ bool RenderContext::InitEGLContext() ret = eglChooseConfig(eglDisplay_, configAttribs, &config_, 1, &count); if (!(ret && static_cast(count) >= 1)) { - HiLog::Error(LABEL, "Failed to eglChooseConfig"); + IMAGE_LOGE("Failed to eglChooseConfig"); return false; } static const EGLint contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; eglContext_ = eglCreateContext(eglDisplay_, config_, EGL_NO_CONTEXT, contextAttribs); if (eglContext_ == EGL_NO_CONTEXT) { - HiLog::Error(LABEL, "Failed to create egl context %{public}x", eglGetError()); + IMAGE_LOGE("Failed to create egl context %{public}x", eglGetError()); return false; } @@ -96,8 +99,7 @@ bool RenderContext::CreatePbufferSurface() EGLint attribs[] = {EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE}; pbufferSurface_ = eglCreatePbufferSurface(eglDisplay_, config_, attribs); if (pbufferSurface_ == EGL_NO_SURFACE) { - HiLog::Error( - LABEL, + IMAGE_LOGE( "RenderContext::CreatePbufferSurface failed, error is %{public}x", eglGetError()); return false; @@ -116,8 +118,7 @@ void RenderContext::MakeCurrent(EGLSurface surface) const if (eglMakeCurrent(eglDisplay_, currSurface, currSurface, eglContext_) != EGL_TRUE) { EGLint surfaceId = -1; eglQuerySurface(eglDisplay_, surface, EGL_CONFIG_ID, &surfaceId); - HiLog::Error( - LABEL, + IMAGE_LOGE( "RenderContext::MakeCurrent failed for eglSurface %{public}d, error is %{public}x", surfaceId, eglGetError()); @@ -128,7 +129,7 @@ bool RenderContext::InitGrContext() { sk_sp glInterface(GrGLCreateNativeInterface()); if (glInterface == nullptr) { - HiLog::Error(LABEL, "SetUpGrContext failed to make native interface"); + IMAGE_LOGE("SetUpGrContext failed to make native interface"); return false; } @@ -151,8 +152,7 @@ void RenderContext::Clear() noexcept if (pbufferSurface_ != EGL_NO_SURFACE) { EGLBoolean ret = eglDestroySurface(eglDisplay_, pbufferSurface_); if (ret != EGL_TRUE) { - HiLog::Error(LABEL, "RenderContext::Clear() failed to destroy pbuffer surface, error is %{public}x.", - eglGetError()); + IMAGE_LOGE("RenderContext::Clear() failed to destroy pbuffer surface, error is %{public}x.", eglGetError()); } pbufferSurface_ = EGL_NO_SURFACE; } diff --git a/frameworks/innerkitsimpl/pixelconverter/BUILD.gn b/frameworks/innerkitsimpl/pixelconverter/BUILD.gn index 9d0015b94..f4c153312 100644 --- a/frameworks/innerkitsimpl/pixelconverter/BUILD.gn +++ b/frameworks/innerkitsimpl/pixelconverter/BUILD.gn @@ -23,6 +23,7 @@ config("pixelconvertadapter_public_config") { "//base/hiviewdfx/hilog/interfaces/native/innerkits/include", "//foundation/communication/ipc/utils/include", "//foundation/multimedia/media_utils_lite/interfaces/kits", + "${image_subsystem}/frameworks/innerkitsimpl/utils/include", "$skia_root/skia/include/core", "$skia_root/skia/include/encode", "$skia_root/skia", @@ -172,6 +173,7 @@ if (use_clang_ios) { external_deps = [ "c_utils:utils", "graphic_2d:color_manager", + "hilog:libhilog", ] } diff --git a/frameworks/innerkitsimpl/pixelconverter/include/pixel_map_jni_utils.h b/frameworks/innerkitsimpl/pixelconverter/include/pixel_map_jni_utils.h index a5a4f920b..6a743f527 100644 --- a/frameworks/innerkitsimpl/pixelconverter/include/pixel_map_jni_utils.h +++ b/frameworks/innerkitsimpl/pixelconverter/include/pixel_map_jni_utils.h @@ -16,9 +16,8 @@ #ifndef FRAMEWORKS_INNERKITSIMPL_PIXELCONVERTER_INCLUDE_PIXEL_MAP_JNI_UTILS_H #define FRAMEWORKS_INNERKITSIMPL_PIXELCONVERTER_INCLUDE_PIXEL_MAP_JNI_UTILS_H -#include "hilog/log.h" +#include "image_log.h" #include "jkit_utils.h" -#include "log_tags.h" namespace OHOS { namespace Media { diff --git a/frameworks/innerkitsimpl/pixelconverter/src/pixel_convert_adapter.cpp b/frameworks/innerkitsimpl/pixelconverter/src/pixel_convert_adapter.cpp index 23165335a..4a945ecf9 100644 --- a/frameworks/innerkitsimpl/pixelconverter/src/pixel_convert_adapter.cpp +++ b/frameworks/innerkitsimpl/pixelconverter/src/pixel_convert_adapter.cpp @@ -17,7 +17,7 @@ #include -#include "hilog/log.h" +#include "image_log.h" #include "include/core/SkBitmap.h" #include "include/core/SkCanvas.h" #include "include/core/SkColor.h" @@ -25,17 +25,20 @@ #include "include/core/SkImageInfo.h" #include "include/core/SkPaint.h" #include "include/core/SkPixmap.h" -#include "log_tags.h" #ifdef _WIN32 #include #endif +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "PixelConvertAdapter" + namespace OHOS { namespace Media { -using namespace OHOS::HiviewDFX; using namespace std; -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "PixelConvertAdapter" }; static const uint8_t NUM_0 = 0; static const uint8_t NUM_1 = 1; static const uint8_t NUM_2 = 2; @@ -62,7 +65,7 @@ static SkColorType PixelFormatConvert(const PixelFormat &pixelFormat) static void ARGBToRGBA(uint8_t* srcPixels, uint8_t* dstPixels, uint32_t byteCount) { if (byteCount % NUM_4 != NUM_0) { - HiLog::Error(LABEL, "Pixel count must multiple of 4."); + IMAGE_LOGE("Pixel count must multiple of 4."); return; } uint8_t *src = srcPixels; @@ -81,7 +84,7 @@ static void ARGBToRGBA(uint8_t* srcPixels, uint8_t* dstPixels, uint32_t byteCoun static void RGBAToARGB(uint8_t* srcPixels, uint8_t* dstPixels, uint32_t byteCount) { if (byteCount % NUM_4 != NUM_0) { - HiLog::Error(LABEL, "Pixel count must multiple of 4."); + IMAGE_LOGE("Pixel count must multiple of 4."); return; } uint8_t *src = srcPixels; @@ -100,7 +103,7 @@ static void RGBAToARGB(uint8_t* srcPixels, uint8_t* dstPixels, uint32_t byteCoun static void RGBxToRGB(const uint8_t* srcPixels, uint8_t* dstPixels, uint32_t byteCount) { if (byteCount % NUM_4 != NUM_0) { - HiLog::Error(LABEL, "Pixel count must multiple of 4."); + IMAGE_LOGE("Pixel count must multiple of 4."); return; } const uint8_t *src = srcPixels; @@ -118,7 +121,7 @@ static void RGBxToRGB(const uint8_t* srcPixels, uint8_t* dstPixels, uint32_t byt static void RGBToRGBx(const uint8_t* srcPixels, uint8_t* dstPixels, uint32_t byteCount) { if (byteCount % NUM_3 != NUM_0) { - HiLog::Error(LABEL, "Pixel count must multiple of 3."); + IMAGE_LOGE("Pixel count must multiple of 3."); return; } const uint8_t *src = srcPixels; @@ -150,7 +153,7 @@ bool PixelConvertAdapter::WritePixelsConvert(const void *srcPixels, uint32_t src { // basic valid check, other parameters valid check in writePixels method if (srcPixels == nullptr || dstPixels == nullptr) { - HiLog::Error(LABEL, "src or dst pixels invalid."); + IMAGE_LOGE("src or dst pixels invalid."); return false; } @@ -182,11 +185,11 @@ bool PixelConvertAdapter::WritePixelsConvert(const void *srcPixels, uint32_t src SkBitmap dstBitmap; if (!dstBitmap.installPixels(dstImageInfo, dstPixels, dstRowBytes)) { - HiLog::Error(LABEL, "WritePixelsConvert dst bitmap install pixels failed."); + IMAGE_LOGE("WritePixelsConvert dst bitmap install pixels failed."); return false; } if (!dstBitmap.writePixels(srcPixmap, dstPos.x, dstPos.y)) { - HiLog::Error(LABEL, "WritePixelsConvert dst bitmap write pixels by source failed."); + IMAGE_LOGE("WritePixelsConvert dst bitmap write pixels by source failed."); return false; } @@ -206,7 +209,7 @@ bool PixelConvertAdapter::ReadPixelsConvert(const void *srcPixels, const Positio { // basic valid check, other parameters valid check in readPixels method if (srcPixels == nullptr || dstPixels == nullptr) { - HiLog::Error(LABEL, "src or dst pixels invalid."); + IMAGE_LOGE("src or dst pixels invalid."); return false; } SkAlphaType srcAlphaType = static_cast(srcInfo.alphaType); @@ -218,11 +221,11 @@ bool PixelConvertAdapter::ReadPixelsConvert(const void *srcPixels, const Positio SkBitmap srcBitmap; if (!srcBitmap.installPixels(srcImageInfo, const_cast(srcPixels), srcRowBytes)) { - HiLog::Error(LABEL, "ReadPixelsConvert src bitmap install pixels failed."); + IMAGE_LOGE("ReadPixelsConvert src bitmap install pixels failed."); return false; } if (!srcBitmap.readPixels(dstImageInfo, dstPixels, dstRowBytes, srcPos.x, srcPos.y)) { - HiLog::Error(LABEL, "ReadPixelsConvert read dst pixels from source failed."); + IMAGE_LOGE("ReadPixelsConvert read dst pixels from source failed."); return false; } return true; @@ -232,7 +235,7 @@ bool PixelConvertAdapter::EraseBitmap(const void *srcPixels, uint32_t srcRowByte uint32_t color) { if (srcPixels == nullptr) { - HiLog::Error(LABEL, "srcPixels is null."); + IMAGE_LOGE("srcPixels is null."); return false; } SkAlphaType srcAlphaType = static_cast(srcInfo.alphaType); @@ -240,7 +243,7 @@ bool PixelConvertAdapter::EraseBitmap(const void *srcPixels, uint32_t srcRowByte SkImageInfo srcImageInfo = SkImageInfo::Make(srcInfo.size.width, srcInfo.size.height, srcColorType, srcAlphaType); SkBitmap srcBitmap; if (!srcBitmap.installPixels(srcImageInfo, const_cast(srcPixels), srcRowBytes)) { - HiLog::Error(LABEL, "ReadPixelsConvert src bitmap install pixels failed."); + IMAGE_LOGE("ReadPixelsConvert src bitmap install pixels failed."); return false; } const SkColor4f skColor = SkColor4f::FromColor(color); diff --git a/frameworks/innerkitsimpl/receiver/src/image_receiver.cpp b/frameworks/innerkitsimpl/receiver/src/image_receiver.cpp index fdaf7a5d3..6163caea0 100644 --- a/frameworks/innerkitsimpl/receiver/src/image_receiver.cpp +++ b/frameworks/innerkitsimpl/receiver/src/image_receiver.cpp @@ -15,245 +15,252 @@ #include "image_receiver.h" -#include "hilog/log.h" +#include "image_log.h" #include "image_packer.h" #include "image_source.h" #include "image_utils.h" #include "image_receiver_buffer_processor.h" #include "image_receiver_manager.h" -#include "log_tags.h" + +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "imageReceiver" namespace OHOS { - namespace Media { - ImageReceiver::~ImageReceiver() - { - std::lock_guard guard(imageReceiverMutex_); - if (receiverConsumerSurface_ != nullptr) { - receiverConsumerSurface_->UnregisterConsumerListener(); - } - receiverConsumerSurface_ = nullptr; - receiverProducerSurface_ = nullptr; - iraContext_ = nullptr; - surfaceBufferAvaliableListener_ = nullptr; - bufferProcessor_ = nullptr; +namespace Media { + +ImageReceiver::~ImageReceiver() +{ + std::lock_guard guard(imageReceiverMutex_); + if (receiverConsumerSurface_ != nullptr) { + receiverConsumerSurface_->UnregisterConsumerListener(); + } + receiverConsumerSurface_ = nullptr; + receiverProducerSurface_ = nullptr; + iraContext_ = nullptr; + surfaceBufferAvaliableListener_ = nullptr; + bufferProcessor_ = nullptr; +} + +enum class Mode { + MODE_PREVIEW = 0, + MODE_PHOTO +}; + +int64_t PackImage(int &fd, std::unique_ptr pixelMap) +{ + IMAGE_LOGD("PackImage"); + ImagePacker imagePacker; + PackOption option; + option.format = ImageReceiver::OPTION_FORMAT; + option.quality = ImageReceiver::OPTION_QUALITY; + option.numberHint = ImageReceiver::OPTION_NUMBERHINT; + std::set formats; + if (pixelMap == nullptr) { + IMAGE_LOGE("pixelMap is nullptr"); + return 0; + } + uint32_t ret = imagePacker.GetSupportedFormats(formats); + if (ret != SUCCESS) { + IMAGE_LOGE("image packer get supported format failed, ret=%{public}u.", ret); + return 0; + } else { + IMAGE_LOGD("SUCCESS"); + } + imagePacker.StartPacking(fd, option); + imagePacker.AddImage(*pixelMap); + int64_t packedSize = 0; + imagePacker.FinalizePacking(packedSize); + IMAGE_LOGD("packedSize=%{public}lld.", static_cast(packedSize)); + IMAGE_LOGD("packedSize=%{public}lld.", static_cast(packedSize)); + return packedSize; +} + +std::unique_ptr ImageReceiver::getSurfacePixelMap(InitializationOptions initializationOpts) +{ + uint32_t *addr = reinterpret_cast(iraContext_->currentBuffer_->GetVirAddr()); + int32_t size = iraContext_->currentBuffer_->GetSize(); + return PixelMap::Create(addr, (uint32_t)size, initializationOpts); +} + +static int32_t SaveSTP(uint32_t *buffer, + uint32_t bufferSize, + int &fd, + InitializationOptions initializationOpts) +{ + int64_t errorCode = -1; + std::unique_ptr pixelMap = PixelMap::Create(buffer, bufferSize, initializationOpts); + if (pixelMap.get() != nullptr) { + ImageInfo imageInfo; + pixelMap->GetImageInfo(imageInfo); + IMAGE_LOGD("create pixel map imageInfo.size.width=%{public}u.", imageInfo.size.width); + } else { + IMAGE_LOGE("pixelMap.get() == nullptr"); + return ERR_MEDIA_INVALID_VALUE; + } + ImagePacker imagePacker; + errorCode = PackImage(fd, std::move(pixelMap)); + if (errorCode > 0) { + errorCode = SUCCESS; + } else { + errorCode = ERR_MEDIA_INVALID_VALUE; + } + return errorCode; +} + +int32_t ImageReceiver::SaveBufferAsImage(int &fd, + OHOS::sptr buffer, + InitializationOptions initializationOpts) +{ + int32_t errorcode = 0; + if (buffer != nullptr) { + uint32_t *addr = reinterpret_cast(buffer->GetVirAddr()); + int32_t size = buffer->GetSize(); + errorcode = SaveSTP(addr, static_cast(size), fd, initializationOpts); + if ((iraContext_->GetReceiverBufferConsumer()) != nullptr) { + (iraContext_->GetReceiverBufferConsumer())->ReleaseBuffer(buffer, -1); + } else { + IMAGE_LOGD("iraContext_->GetReceiverBufferConsumer() == nullptr"); } - constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "imageReceiver"}; - using namespace OHOS::HiviewDFX; + } else { + IMAGE_LOGD("SaveBufferAsImage buffer == nullptr"); + } + return errorcode; +} - enum class Mode { - MODE_PREVIEW = 0, - MODE_PHOTO - }; +int32_t ImageReceiver::SaveBufferAsImage(int &fd, + InitializationOptions initializationOpts) +{ + if (iraContext_->currentBuffer_ != nullptr) { + return SaveBufferAsImage(fd, iraContext_->currentBuffer_, initializationOpts); + } + IMAGE_LOGD("iraContext_->GetCurrentBuffer() == nullptr"); + return 0; +} - int64_t PackImage(int &fd, std::unique_ptr pixelMap) - { - HiLog::Debug(LABEL, "PackImage"); - ImagePacker imagePacker; - PackOption option; - option.format = ImageReceiver::OPTION_FORMAT; - option.quality = ImageReceiver::OPTION_QUALITY; - option.numberHint = ImageReceiver::OPTION_NUMBERHINT; - std::set formats; - if (pixelMap == nullptr) { - HiLog::Error(LABEL, "pixelMap is nullptr"); - return 0; - } - uint32_t ret = imagePacker.GetSupportedFormats(formats); - if (ret != SUCCESS) { - HiLog::Error(LABEL, "image packer get supported format failed, ret=%{public}u.", ret); - return 0; +void ImageReceiver::ReleaseBuffer(OHOS::sptr &buffer) __attribute__((no_sanitize("cfi"))) +{ + std::lock_guard guard(imageReceiverMutex_); + if (buffer != nullptr) { + if (iraContext_ != nullptr) { + auto listenerConsumerSurface = iraContext_->GetReceiverBufferConsumer(); + if (listenerConsumerSurface != nullptr) { + listenerConsumerSurface->ReleaseBuffer(buffer, -1); } else { - HiLog::Debug(LABEL, "SUCCESS"); + IMAGE_LOGD("listenerConsumerSurface == nullptr"); } - imagePacker.StartPacking(fd, option); - imagePacker.AddImage(*pixelMap); - int64_t packedSize = 0; - imagePacker.FinalizePacking(packedSize); - HiLog::Debug(LABEL, "packedSize=%{public}lld.", static_cast(packedSize)); - HiLog::Debug(LABEL, "packedSize=%{public}lld.", static_cast(packedSize)); - return packedSize; + } else { + IMAGE_LOGD("iraContext_ == nullptr"); } + buffer = nullptr; + } +} - std::unique_ptr ImageReceiver::getSurfacePixelMap(InitializationOptions initializationOpts) - { - uint32_t *addr = reinterpret_cast(iraContext_->currentBuffer_->GetVirAddr()); - int32_t size = iraContext_->currentBuffer_->GetSize(); - return PixelMap::Create(addr, (uint32_t)size, initializationOpts); - } +void ImageReceiverSurfaceListener ::OnBufferAvailable() +{ + IMAGE_LOGD("OnBufferAvailable"); + auto ir = ir_.lock(); + if (ir && ir->surfaceBufferAvaliableListener_ != nullptr) { + ir->surfaceBufferAvaliableListener_->OnSurfaceBufferAvaliable(); + } +} - static int32_t SaveSTP(uint32_t *buffer, - uint32_t bufferSize, - int &fd, - InitializationOptions initializationOpts) - { - int64_t errorCode = -1; - std::unique_ptr pixelMap = PixelMap::Create(buffer, bufferSize, initializationOpts); - if (pixelMap.get() != nullptr) { - ImageInfo imageInfo; - pixelMap->GetImageInfo(imageInfo); - HiLog::Debug(LABEL, "create pixel map imageInfo.size.width=%{public}u.", imageInfo.size.width); - } else { - HiLog::Error(LABEL, "pixelMap.get() == nullptr"); - return ERR_MEDIA_INVALID_VALUE; - } - ImagePacker imagePacker; - errorCode = PackImage(fd, std::move(pixelMap)); - if (errorCode > 0) { - errorCode = SUCCESS; - } else { - errorCode = ERR_MEDIA_INVALID_VALUE; - } - return errorCode; - } +std::shared_ptr ImageReceiverContext ::CreateImageReceiverContext() +{ + std::shared_ptr irc = std::make_shared(); + return irc; +} - int32_t ImageReceiver::SaveBufferAsImage(int &fd, - OHOS::sptr buffer, - InitializationOptions initializationOpts) - { - int32_t errorcode = 0; - if (buffer != nullptr) { - uint32_t *addr = reinterpret_cast(buffer->GetVirAddr()); - int32_t size = buffer->GetSize(); - errorcode = SaveSTP(addr, static_cast(size), fd, initializationOpts); - if ((iraContext_->GetReceiverBufferConsumer()) != nullptr) { - (iraContext_->GetReceiverBufferConsumer())->ReleaseBuffer(buffer, -1); - } else { - HiLog::Debug(LABEL, "iraContext_->GetReceiverBufferConsumer() == nullptr"); - } - } else { - HiLog::Debug(LABEL, "SaveBufferAsImage buffer == nullptr"); - } - return errorcode; - } +sptr ImageReceiver::getSurfaceById(std::string id) +{ + ImageReceiverManager& imageReceiverManager = ImageReceiverManager::getInstance(); + sptr surface = imageReceiverManager.getSurfaceByKeyId(id); + IMAGE_LOGD("getSurfaceById"); + return surface; +} - int32_t ImageReceiver::SaveBufferAsImage(int &fd, - InitializationOptions initializationOpts) - { - if (iraContext_->currentBuffer_ != nullptr) { - return SaveBufferAsImage(fd, iraContext_->currentBuffer_, initializationOpts); - } - HiLog::Debug(LABEL, "iraContext_->GetCurrentBuffer() == nullptr"); - return 0; - } +std::shared_ptr ImageReceiver::CreateImageReceiver(int32_t width, + int32_t height, + int32_t format, + int32_t capicity) +{ + std::shared_ptr iva = std::make_shared(); + iva->iraContext_ = ImageReceiverContext::CreateImageReceiverContext(); + iva->receiverConsumerSurface_ = IConsumerSurface::Create(); + if (iva->receiverConsumerSurface_ == nullptr) { + IMAGE_LOGD("SurfaceAsConsumer == nullptr"); + return iva; + } - void ImageReceiver::ReleaseBuffer(OHOS::sptr &buffer) __attribute__((no_sanitize("cfi"))) - { - std::lock_guard guard(imageReceiverMutex_); - if (buffer != nullptr) { - if (iraContext_ != nullptr) { - auto listenerConsumerSurface = iraContext_->GetReceiverBufferConsumer(); - if (listenerConsumerSurface != nullptr) { - listenerConsumerSurface->ReleaseBuffer(buffer, -1); - } else { - HiLog::Debug(LABEL, "listenerConsumerSurface == nullptr"); - } - } else { - HiLog::Debug(LABEL, "iraContext_ == nullptr"); - } - buffer = nullptr; - } - } - void ImageReceiverSurfaceListener ::OnBufferAvailable() - { - HiLog::Debug(LABEL, "OnBufferAvailable"); - auto ir = ir_.lock(); - if (ir && ir->surfaceBufferAvaliableListener_ != nullptr) { - ir->surfaceBufferAvaliableListener_->OnSurfaceBufferAvaliable(); - } - } + iva->receiverConsumerSurface_->SetDefaultWidthAndHeight(width, height); + iva->receiverConsumerSurface_->SetQueueSize(capicity); + auto p = iva->receiverConsumerSurface_->GetProducer(); + iva->receiverProducerSurface_ = Surface::CreateSurfaceAsProducer(p); + if (iva->receiverProducerSurface_ == nullptr) { + IMAGE_LOGD("SurfaceAsProducer == nullptr"); + return iva; + } - std::shared_ptr ImageReceiverContext ::CreateImageReceiverContext() - { - std::shared_ptr irc = std::make_shared(); - return irc; - } - sptr ImageReceiver::getSurfaceById(std::string id) - { - ImageReceiverManager& imageReceiverManager = ImageReceiverManager::getInstance(); - sptr surface = imageReceiverManager.getSurfaceByKeyId(id); - HiLog::Debug(LABEL, "getSurfaceById"); - return surface; - } - std::shared_ptr ImageReceiver::CreateImageReceiver(int32_t width, - int32_t height, - int32_t format, - int32_t capicity) - { - std::shared_ptr iva = std::make_shared(); - iva->iraContext_ = ImageReceiverContext::CreateImageReceiverContext(); - iva->receiverConsumerSurface_ = IConsumerSurface::Create(); - if (iva->receiverConsumerSurface_ == nullptr) { - HiLog::Debug(LABEL, "SurfaceAsConsumer == nullptr"); - return iva; - } + iva->iraContext_->SetReceiverBufferConsumer(iva->receiverConsumerSurface_); + iva->iraContext_->SetReceiverBufferProducer(iva->receiverProducerSurface_); + iva->iraContext_->SetWidth(width); + iva->iraContext_->SetHeight(height); + iva->iraContext_->SetFormat(format); + iva->iraContext_->SetCapicity(capicity); + ImageReceiverManager& imageReceiverManager = ImageReceiverManager::getInstance(); + std::string receiverKey = imageReceiverManager.SaveImageReceiver(iva); + iva->iraContext_->SetReceiverKey(receiverKey); + sptr listener = new ImageReceiverSurfaceListener(); + listener->ir_ = iva; + iva->receiverConsumerSurface_-> + RegisterConsumerListener((sptr &)listener); + return iva; +} - iva->receiverConsumerSurface_->SetDefaultWidthAndHeight(width, height); - iva->receiverConsumerSurface_->SetQueueSize(capicity); - auto p = iva->receiverConsumerSurface_->GetProducer(); - iva->receiverProducerSurface_ = Surface::CreateSurfaceAsProducer(p); - if (iva->receiverProducerSurface_ == nullptr) { - HiLog::Debug(LABEL, "SurfaceAsProducer == nullptr"); - return iva; - } +OHOS::sptr ImageReceiver::ReadNextImage() +{ + int32_t flushFence = 0; + int64_t timestamp = 0; + OHOS::Rect damage = {}; + OHOS::sptr buffer; + sptr listenerConsumerSurface = iraContext_->GetReceiverBufferConsumer(); + SurfaceError surfaceError = listenerConsumerSurface->AcquireBuffer(buffer, flushFence, timestamp, damage); + if (surfaceError == SURFACE_ERROR_OK) { + iraContext_->currentBuffer_ = buffer; + } else { + IMAGE_LOGD("buffer is null"); + } + return iraContext_->GetCurrentBuffer(); +} - iva->iraContext_->SetReceiverBufferConsumer(iva->receiverConsumerSurface_); - iva->iraContext_->SetReceiverBufferProducer(iva->receiverProducerSurface_); - iva->iraContext_->SetWidth(width); - iva->iraContext_->SetHeight(height); - iva->iraContext_->SetFormat(format); - iva->iraContext_->SetCapicity(capicity); - ImageReceiverManager& imageReceiverManager = ImageReceiverManager::getInstance(); - std::string receiverKey = imageReceiverManager.SaveImageReceiver(iva); - iva->iraContext_->SetReceiverKey(receiverKey); - sptr listener = new ImageReceiverSurfaceListener(); - listener->ir_ = iva; - iva->receiverConsumerSurface_-> - RegisterConsumerListener((sptr &)listener); - return iva; - } +OHOS::sptr ImageReceiver::ReadLastImage() +{ + int32_t flushFence = 0; + int64_t timestamp = 0; + OHOS::Rect damage = {}; + OHOS::sptr buffer; + OHOS::sptr bufferBefore; + sptr listenerConsumerSurface = iraContext_->GetReceiverBufferConsumer(); + SurfaceError surfaceError = listenerConsumerSurface->AcquireBuffer(buffer, flushFence, timestamp, damage); + while (surfaceError == SURFACE_ERROR_OK) { + bufferBefore = buffer; + surfaceError = listenerConsumerSurface->AcquireBuffer(buffer, flushFence, timestamp, damage); + } + iraContext_->currentBuffer_ = bufferBefore; + return iraContext_->GetCurrentBuffer(); +} - OHOS::sptr ImageReceiver::ReadNextImage() - { - int32_t flushFence = 0; - int64_t timestamp = 0; - OHOS::Rect damage = {}; - OHOS::sptr buffer; - sptr listenerConsumerSurface = iraContext_->GetReceiverBufferConsumer(); - SurfaceError surfaceError = listenerConsumerSurface->AcquireBuffer(buffer, flushFence, timestamp, damage); - if (surfaceError == SURFACE_ERROR_OK) { - iraContext_->currentBuffer_ = buffer; - } else { - HiLog::Debug(LABEL, "buffer is null"); - } - return iraContext_->GetCurrentBuffer(); - } +sptr ImageReceiver::GetReceiverSurface() +{ + return iraContext_->GetReceiverBufferProducer(); +} - OHOS::sptr ImageReceiver::ReadLastImage() - { - int32_t flushFence = 0; - int64_t timestamp = 0; - OHOS::Rect damage = {}; - OHOS::sptr buffer; - OHOS::sptr bufferBefore; - sptr listenerConsumerSurface = iraContext_->GetReceiverBufferConsumer(); - SurfaceError surfaceError = listenerConsumerSurface->AcquireBuffer(buffer, flushFence, timestamp, damage); - while (surfaceError == SURFACE_ERROR_OK) { - bufferBefore = buffer; - surfaceError = listenerConsumerSurface->AcquireBuffer(buffer, flushFence, timestamp, damage); - } - iraContext_->currentBuffer_ = bufferBefore; - return iraContext_->GetCurrentBuffer(); - } - - sptr ImageReceiver::GetReceiverSurface() - { - return iraContext_->GetReceiverBufferProducer(); - } - - void ImageReceiver::ReleaseReceiver() - { - ImageReceiver::~ImageReceiver(); - } +void ImageReceiver::ReleaseReceiver() +{ + ImageReceiver::~ImageReceiver(); +} std::shared_ptr ImageReceiver::GetBufferProcessor() { @@ -275,6 +282,7 @@ std::shared_ptr ImageReceiver::NextNativeImage() } return std::make_shared(surfaceBuffer, GetBufferProcessor()); } + std::shared_ptr ImageReceiver::LastNativeImage() { if (GetBufferProcessor() == nullptr) { @@ -287,5 +295,5 @@ std::shared_ptr ImageReceiver::LastNativeImage() } return std::make_shared(surfaceBuffer, GetBufferProcessor()); } - } // namespace Media +} // namespace Media } // namespace OHOS diff --git a/frameworks/innerkitsimpl/stream/src/buffer_packer_stream.cpp b/frameworks/innerkitsimpl/stream/src/buffer_packer_stream.cpp index 2a8143d3d..9aa387e99 100644 --- a/frameworks/innerkitsimpl/stream/src/buffer_packer_stream.cpp +++ b/frameworks/innerkitsimpl/stream/src/buffer_packer_stream.cpp @@ -15,14 +15,17 @@ #include "buffer_packer_stream.h" -#include "hilog/log.h" -#include "log_tags.h" +#include "image_log.h" #include "securec.h" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "BufferPackerStream" + namespace OHOS { namespace Media { -using namespace OHOS::HiviewDFX; -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "BufferPackerStream"}; BufferPackerStream::BufferPackerStream(uint8_t *outputData, uint32_t maxSize) : outputData_(outputData), maxSize_(maxSize) @@ -31,21 +34,21 @@ BufferPackerStream::BufferPackerStream(uint8_t *outputData, uint32_t maxSize) bool BufferPackerStream::Write(const uint8_t *buffer, uint32_t size) { if ((buffer == nullptr) || (size == 0)) { - HiLog::Error(LABEL, "input parameter invalid."); + IMAGE_LOGE("input parameter invalid."); return false; } if (outputData_ == nullptr) { - HiLog::Error(LABEL, "output stream is null."); + IMAGE_LOGE("output stream is null."); return false; } uint32_t leftSize = maxSize_ - offset_; if (size > leftSize) { - HiLog::Error(LABEL, "write data:[%{public}lld] out of max size:[%{public}u].", - static_cast(size + offset_), maxSize_); + IMAGE_LOGE("write data:[%{public}lld] out of max size:[%{public}u].", + static_cast(size + offset_), maxSize_); return false; } if (memcpy_s(outputData_ + offset_, leftSize, buffer, size) != EOK) { - HiLog::Error(LABEL, "memory copy failed."); + IMAGE_LOGE("memory copy failed."); return false; } offset_ += size; diff --git a/frameworks/innerkitsimpl/stream/src/buffer_source_stream.cpp b/frameworks/innerkitsimpl/stream/src/buffer_source_stream.cpp index 0e3c74bd1..b0cafeaf6 100644 --- a/frameworks/innerkitsimpl/stream/src/buffer_source_stream.cpp +++ b/frameworks/innerkitsimpl/stream/src/buffer_source_stream.cpp @@ -16,19 +16,22 @@ #include "buffer_source_stream.h" #include -#include "hilog/log.h" -#include "log_tags.h" #ifndef _WIN32 #include "securec.h" #else #include "memory.h" #endif #include "buffer_packer_stream.h" +#include "image_log.h" + +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "BufferSourceStream" namespace OHOS { namespace Media { -using namespace OHOS::HiviewDFX; -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "BufferSourceStream"}; using namespace std; using namespace ImagePlugin; @@ -47,19 +50,19 @@ BufferSourceStream::~BufferSourceStream() std::unique_ptr BufferSourceStream::CreateSourceStream(const uint8_t *data, uint32_t size) { if ((data == nullptr) || (size == 0)) { - HiLog::Error(LABEL, "[BufferSourceStream]input the parameter exception."); + IMAGE_LOGE("[BufferSourceStream]input the parameter exception."); return nullptr; } uint8_t *dataCopy = static_cast(malloc(size)); if (dataCopy == nullptr) { - HiLog::Error(LABEL, "[BufferSourceStream]malloc the input data buffer fail."); + IMAGE_LOGE("[BufferSourceStream]malloc the input data buffer fail."); return nullptr; } errno_t ret = memcpy_s(dataCopy, size, data, size); if (ret != EOK) { free(dataCopy); dataCopy = nullptr; - HiLog::Error(LABEL, "[BufferSourceStream]copy the input data fail, ret:%{public}d.", ret); + IMAGE_LOGE("[BufferSourceStream]copy the input data fail, ret:%{public}d.", ret); return nullptr; } return (unique_ptr(new BufferSourceStream(dataCopy, size, 0))); @@ -68,7 +71,7 @@ std::unique_ptr BufferSourceStream::CreateSourceStream(const bool BufferSourceStream::Read(uint32_t desiredSize, DataStreamBuffer &outData) { if (!Peek(desiredSize, outData)) { - HiLog::Error(LABEL, "[BufferSourceStream]read fail."); + IMAGE_LOGE("[BufferSourceStream]read fail."); return false; } dataOffset_ += outData.dataSize; @@ -78,11 +81,11 @@ bool BufferSourceStream::Read(uint32_t desiredSize, DataStreamBuffer &outData) bool BufferSourceStream::Peek(uint32_t desiredSize, DataStreamBuffer &outData) { if (desiredSize == 0) { - HiLog::Error(LABEL, "[BufferSourceStream]input the parameter exception."); + IMAGE_LOGE("[BufferSourceStream]input the parameter exception."); return false; } if (dataSize_ == dataOffset_) { - HiLog::Error(LABEL, "[BufferSourceStream]buffer read finish, offset:%{public}zu ,dataSize%{public}zu.", + IMAGE_LOGE("[BufferSourceStream]buffer read finish, offset:%{public}zu ,dataSize%{public}zu.", dataOffset_, dataSize_); return false; } @@ -92,7 +95,7 @@ bool BufferSourceStream::Peek(uint32_t desiredSize, DataStreamBuffer &outData) } outData.dataSize = desiredSize; outData.inputStreamBuffer = inputBuffer_ + dataOffset_; - HiLog::Debug(LABEL, "[BufferSourceStream]Peek end. desiredSize:%{public}d, offset:%{public}zu," + IMAGE_LOGD("[BufferSourceStream]Peek end. desiredSize:%{public}d, offset:%{public}zu," "dataSize%{public}zu.", desiredSize, dataOffset_, dataSize_); return true; } @@ -100,7 +103,7 @@ bool BufferSourceStream::Peek(uint32_t desiredSize, DataStreamBuffer &outData) bool BufferSourceStream::Read(uint32_t desiredSize, uint8_t *outBuffer, uint32_t bufferSize, uint32_t &readSize) { if (!Peek(desiredSize, outBuffer, bufferSize, readSize)) { - HiLog::Error(LABEL, "[BufferSourceStream]read fail."); + IMAGE_LOGE("[BufferSourceStream]read fail."); return false; } dataOffset_ += readSize; @@ -110,12 +113,12 @@ bool BufferSourceStream::Read(uint32_t desiredSize, uint8_t *outBuffer, uint32_t bool BufferSourceStream::Peek(uint32_t desiredSize, uint8_t *outBuffer, uint32_t bufferSize, uint32_t &readSize) { if (desiredSize == 0 || outBuffer == nullptr || desiredSize > bufferSize) { - HiLog::Error(LABEL, "[BufferSourceStream]input the parameter exception, desiredSize:%{public}u," + IMAGE_LOGE("[BufferSourceStream]input the parameter exception, desiredSize:%{public}u," "bufferSize:%{public}u.", desiredSize, bufferSize); return false; } if (dataSize_ == dataOffset_) { - HiLog::Error(LABEL, "[BufferSourceStream]buffer read finish, offset:%{public}zu ,dataSize%{public}zu.", + IMAGE_LOGE("[BufferSourceStream]buffer read finish, offset:%{public}zu ,dataSize%{public}zu.", dataOffset_, dataSize_); return false; } @@ -124,7 +127,7 @@ bool BufferSourceStream::Peek(uint32_t desiredSize, uint8_t *outBuffer, uint32_t } errno_t ret = memcpy_s(outBuffer, bufferSize, inputBuffer_ + dataOffset_, desiredSize); if (ret != EOK) { - HiLog::Error(LABEL, "[BufferSourceStream]copy data fail, ret:%{public}d, bufferSize:%{public}u," + IMAGE_LOGE("[BufferSourceStream]copy data fail, ret:%{public}d, bufferSize:%{public}u," "offset:%{public}zu, desiredSize:%{public}u.", ret, bufferSize, dataOffset_, desiredSize); return false; } @@ -140,7 +143,7 @@ uint32_t BufferSourceStream::Tell() bool BufferSourceStream::Seek(uint32_t position) { if (position > dataSize_) { - HiLog::Error(LABEL, "[BufferSourceStream]Seek the position greater than the Data Size,position:%{public}u.", + IMAGE_LOGE("[BufferSourceStream]Seek the position greater than the Data Size,position:%{public}u.", position); return false; } diff --git a/frameworks/innerkitsimpl/stream/src/file_packer_stream.cpp b/frameworks/innerkitsimpl/stream/src/file_packer_stream.cpp index 3dfd7b968..bcde1dc7e 100644 --- a/frameworks/innerkitsimpl/stream/src/file_packer_stream.cpp +++ b/frameworks/innerkitsimpl/stream/src/file_packer_stream.cpp @@ -18,14 +18,17 @@ #include #include "directory_ex.h" -#include "hilog/log.h" +#include "image_log.h" #include "image_utils.h" -#include "log_tags.h" + +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "FilePackerStream" namespace OHOS { namespace Media { -using namespace OHOS::HiviewDFX; -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "FilePackerStream" }; FilePackerStream::FilePackerStream(const std::string &filePath) { @@ -42,20 +45,20 @@ FilePackerStream::FilePackerStream(const std::string &filePath) std::string realPath; if (!ImageUtils::PathToRealPath(dirPath, realPath)) { file_ = nullptr; - HiLog::Error(LABEL, "convert to real path failed."); + IMAGE_LOGE("convert to real path failed."); return; } if (!ForceCreateDirectory(realPath)) { file_ = nullptr; - HiLog::Error(LABEL, "create directory failed."); + IMAGE_LOGE("create directory failed."); return; } std::string fullPath = realPath + "/" + fileName; file_ = fopen(fullPath.c_str(), "wb"); if (file_ == nullptr) { - HiLog::Error(LABEL, "fopen file failed, error:%{public}d", errno); + IMAGE_LOGE("fopen file failed, error:%{public}d", errno); return; } } @@ -63,7 +66,7 @@ FilePackerStream::FilePackerStream(const int fd) { file_ = fdopen(fd, "wb"); if (file_ == nullptr) { - HiLog::Error(LABEL, "fopen file failed, error:%{public}d", errno); + IMAGE_LOGE("fopen file failed, error:%{public}d", errno); return; } } @@ -78,15 +81,15 @@ FilePackerStream::~FilePackerStream() bool FilePackerStream::Write(const uint8_t *buffer, uint32_t size) { if ((buffer == nullptr) || (size == 0)) { - HiLog::Error(LABEL, "input parameter invalid."); + IMAGE_LOGE("input parameter invalid."); return false; } if (file_ == nullptr) { - HiLog::Error(LABEL, "output file is null."); + IMAGE_LOGE("output file is null."); return false; } if (fwrite(buffer, sizeof(uint8_t), size, file_) != size) { - HiLog::Error(LABEL, "write %{public}u bytes failed.", size); + IMAGE_LOGE("write %{public}u bytes failed.", size); fclose(file_); file_ = nullptr; return false; diff --git a/frameworks/innerkitsimpl/stream/src/file_source_stream.cpp b/frameworks/innerkitsimpl/stream/src/file_source_stream.cpp index 85f76a246..fe986153e 100644 --- a/frameworks/innerkitsimpl/stream/src/file_source_stream.cpp +++ b/frameworks/innerkitsimpl/stream/src/file_source_stream.cpp @@ -19,9 +19,8 @@ #include "directory_ex.h" #include "file_packer_stream.h" -#include "hilog/log.h" +#include "image_log.h" #include "image_utils.h" -#include "log_tags.h" #include "media_errors.h" #if !defined(_WIN32) && !defined(_APPLE) &&!defined(IOS_PLATFORM) &&!defined(A_PLATFORM) @@ -29,12 +28,16 @@ #define SUPPORT_MMAP #endif +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "FileSourceStream" + namespace OHOS { namespace Media { -using namespace OHOS::HiviewDFX; using namespace std; using namespace ImagePlugin; -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "FileSourceStream" }; FileSourceStream::FileSourceStream(std::FILE *file, size_t size, size_t offset, size_t original) : filePtr_(file), fileSize_(size), fileOffset_(offset), fileOriginalOffset_(original) @@ -42,7 +45,7 @@ FileSourceStream::FileSourceStream(std::FILE *file, size_t size, size_t offset, FileSourceStream::~FileSourceStream() { - HiLog::Debug(LABEL, "[FileSourceStream]destructor enter."); + IMAGE_LOGD("[FileSourceStream]destructor enter."); fclose(filePtr_); ResetReadBuffer(); } @@ -51,22 +54,22 @@ unique_ptr FileSourceStream::CreateSourceStream(const string & { string realPath; if (!PathToRealPath(pathName, realPath)) { - HiLog::Error(LABEL, "[FileSourceStream]input the file path exception, pathName=%{public}s", pathName.c_str()); + IMAGE_LOGE("[FileSourceStream]input the file path exception, pathName=%{public}s", pathName.c_str()); return nullptr; } size_t size = 0; if (!ImageUtils::GetFileSize(realPath, size)) { - HiLog::Error(LABEL, "[FileSourceStream]get the file size fail."); + IMAGE_LOGE("[FileSourceStream]get the file size fail."); return nullptr; } FILE *filePtr = fopen(realPath.c_str(), "rb"); if (filePtr == nullptr) { - HiLog::Error(LABEL, "[FileSourceStream]open file fail."); + IMAGE_LOGE("[FileSourceStream]open file fail."); return nullptr; } int64_t offset = ftell(filePtr); if (offset < 0) { - HiLog::Error(LABEL, "[FileSourceStream]get the position fail."); + IMAGE_LOGE("[FileSourceStream]get the position fail."); fclose(filePtr); return nullptr; } @@ -79,28 +82,28 @@ unique_ptr FileSourceStream::CreateSourceStream(const int fd) int dupFd = dup(fd); if (dupFd < 0) { - HiLog::Error(LABEL, "[FileSourceStream]Fail to dup fd."); + IMAGE_LOGE("[FileSourceStream]Fail to dup fd."); return nullptr; } if (!ImageUtils::GetFileSize(dupFd, size)) { - HiLog::Error(LABEL, "[FileSourceStream]get the file size fail."); + IMAGE_LOGE("[FileSourceStream]get the file size fail."); return nullptr; } FILE *filePtr = fdopen(dupFd, "rb"); if (filePtr == nullptr) { - HiLog::Error(LABEL, "[FileSourceStream]open file fail."); + IMAGE_LOGE("[FileSourceStream]open file fail."); return nullptr; } int ret = fseek(filePtr, 0, SEEK_SET); if (ret != 0) { - HiLog::Error(LABEL, "[FileSourceStream]Go to 0 position fail, ret:%{public}d.", ret); + IMAGE_LOGE("[FileSourceStream]Go to 0 position fail, ret:%{public}d.", ret); } int64_t offset = ftell(filePtr); if (offset < 0) { - HiLog::Error(LABEL, "[FileSourceStream]get the position fail."); + IMAGE_LOGE("[FileSourceStream]get the position fail."); fclose(filePtr); return nullptr; } @@ -112,19 +115,19 @@ unique_ptr FileSourceStream::CreateSourceStream( { int dupFd = dup(fd); if (dupFd < 0) { - HiLog::Error(LABEL, "[FileSourceStream]Fail to dup fd."); + IMAGE_LOGE("[FileSourceStream]Fail to dup fd."); return nullptr; } FILE *filePtr = fdopen(dupFd, "rb"); if (filePtr == nullptr) { - HiLog::Error(LABEL, "[FileSourceStream]open file fail."); + IMAGE_LOGE("[FileSourceStream]open file fail."); return nullptr; } int ret = fseek(filePtr, offset, SEEK_SET); if (ret != 0) { - HiLog::Error(LABEL, "[FileSourceStream]Go to %{public}d position fail, ret:%{public}d.", offset, ret); + IMAGE_LOGE("[FileSourceStream]Go to %{public}d position fail, ret:%{public}d.", offset, ret); return nullptr; } return make_unique(filePtr, length, offset, offset); @@ -133,11 +136,11 @@ unique_ptr FileSourceStream::CreateSourceStream( bool FileSourceStream::Read(uint32_t desiredSize, DataStreamBuffer &outData) { if (desiredSize == 0 || filePtr_ == nullptr) { - HiLog::Error(LABEL, "[FileSourceStream]read stream input parameter exception."); + IMAGE_LOGE("[FileSourceStream]read stream input parameter exception."); return false; } if (!GetData(desiredSize, outData)) { - HiLog::Info(LABEL, "[FileSourceStream]read dataStreamBuffer fail."); + IMAGE_LOGI("[FileSourceStream]read dataStreamBuffer fail."); return false; } fileOffset_ += outData.dataSize; @@ -147,16 +150,16 @@ bool FileSourceStream::Read(uint32_t desiredSize, DataStreamBuffer &outData) bool FileSourceStream::Peek(uint32_t desiredSize, DataStreamBuffer &outData) { if (desiredSize == 0 || filePtr_ == nullptr) { - HiLog::Error(LABEL, "[FileSourceStream]peek stream input parameter exception."); + IMAGE_LOGE("[FileSourceStream]peek stream input parameter exception."); return false; } if (!GetData(desiredSize, outData)) { - HiLog::Info(LABEL, "[FileSourceStream]peek dataStreamBuffer fail, desiredSize:%{public}zu", desiredSize); + IMAGE_LOGI("[FileSourceStream]peek dataStreamBuffer fail, desiredSize:%{public}zu", desiredSize); return false; } int ret = fseek(filePtr_, fileOffset_, SEEK_SET); if (ret != 0) { - HiLog::Error(LABEL, "[FileSourceStream]go to original position fail, ret:%{public}d.", ret); + IMAGE_LOGE("[FileSourceStream]go to original position fail, ret:%{public}d.", ret); return false; } return true; @@ -165,12 +168,12 @@ bool FileSourceStream::Peek(uint32_t desiredSize, DataStreamBuffer &outData) bool FileSourceStream::Read(uint32_t desiredSize, uint8_t *outBuffer, uint32_t bufferSize, uint32_t &readSize) { if (desiredSize == 0 || outBuffer == nullptr || desiredSize > bufferSize || desiredSize > fileSize_) { - HiLog::Error(LABEL, "[FileSourceStream]input parameter exception, desiredSize:%{public}u," + IMAGE_LOGE("[FileSourceStream]input parameter exception, desiredSize:%{public}u," "bufferSize:%{public}u,fileSize_:%{public}zu.", desiredSize, bufferSize, fileSize_); return false; } if (!GetData(desiredSize, outBuffer, bufferSize, readSize)) { - HiLog::Info(LABEL, "[FileSourceStream]read outBuffer fail."); + IMAGE_LOGI("[FileSourceStream]read outBuffer fail."); return false; } fileOffset_ += readSize; @@ -180,17 +183,17 @@ bool FileSourceStream::Read(uint32_t desiredSize, uint8_t *outBuffer, uint32_t b bool FileSourceStream::Peek(uint32_t desiredSize, uint8_t *outBuffer, uint32_t bufferSize, uint32_t &readSize) { if (desiredSize == 0 || outBuffer == nullptr || desiredSize > bufferSize || desiredSize > fileSize_) { - HiLog::Error(LABEL, "[FileSourceStream]input parameter exception, desiredSize:%{public}u," + IMAGE_LOGE("[FileSourceStream]input parameter exception, desiredSize:%{public}u," "bufferSize:%{public}u, fileSize_:%{public}zu.", desiredSize, bufferSize, fileSize_); return false; } if (!GetData(desiredSize, outBuffer, bufferSize, readSize)) { - HiLog::Info(LABEL, "[FileSourceStream]peek outBuffer fail."); + IMAGE_LOGI("[FileSourceStream]peek outBuffer fail."); return false; } int ret = fseek(filePtr_, fileOffset_, SEEK_SET); if (ret != 0) { - HiLog::Error(LABEL, "[FileSourceStream]go to original position fail, ret:%{public}d.", ret); + IMAGE_LOGE("[FileSourceStream]go to original position fail, ret:%{public}d.", ret); return false; } return true; @@ -199,7 +202,7 @@ bool FileSourceStream::Peek(uint32_t desiredSize, uint8_t *outBuffer, uint32_t b bool FileSourceStream::Seek(uint32_t position) { if (position > fileSize_) { - HiLog::Error(LABEL, "[FileSourceStream]Seek the position greater than the file size, position:%{public}u.", + IMAGE_LOGE("[FileSourceStream]Seek the position greater than the file size, position:%{public}u.", position); return false; } @@ -207,7 +210,7 @@ bool FileSourceStream::Seek(uint32_t position) fileOffset_ = ((targetPosition < fileSize_) ? targetPosition : fileSize_); int ret = fseek(filePtr_, fileOffset_, SEEK_SET); if (ret != 0) { - HiLog::Error(LABEL, "[FileSourceStream]go to offset position fail, ret:%{public}d.", ret); + IMAGE_LOGE("[FileSourceStream]go to offset position fail, ret:%{public}d.", ret); return false; } return true; @@ -221,7 +224,7 @@ uint32_t FileSourceStream::Tell() bool FileSourceStream::GetData(uint32_t desiredSize, uint8_t *outBuffer, uint32_t bufferSize, uint32_t &readSize) { if (fileSize_ == fileOffset_) { - HiLog::Error(LABEL, "[FileSourceStream]read finish, offset:%{public}zu ,dataSize%{public}zu.", + IMAGE_LOGE("[FileSourceStream]read finish, offset:%{public}zu ,dataSize%{public}zu.", fileOffset_, fileSize_); return false; } @@ -230,7 +233,7 @@ bool FileSourceStream::GetData(uint32_t desiredSize, uint8_t *outBuffer, uint32_ } size_t bytesRead = fread(outBuffer, sizeof(outBuffer[0]), desiredSize, filePtr_); if (bytesRead < desiredSize) { - HiLog::Info(LABEL, "[FileSourceStream]read outBuffer fail, bytesRead:%{public}zu", bytesRead); + IMAGE_LOGI("[FileSourceStream]read outBuffer fail, bytesRead:%{public}zu", bytesRead); return false; } readSize = desiredSize; @@ -240,20 +243,20 @@ bool FileSourceStream::GetData(uint32_t desiredSize, uint8_t *outBuffer, uint32_ bool FileSourceStream::GetData(uint32_t desiredSize, DataStreamBuffer &outData) { if (fileSize_ == fileOffset_) { - HiLog::Error(LABEL, "[FileSourceStream]read finish, offset:%{public}zu ,dataSize%{public}zu.", + IMAGE_LOGE("[FileSourceStream]read finish, offset:%{public}zu ,dataSize%{public}zu.", fileOffset_, fileSize_); return false; } if (desiredSize == 0 || desiredSize > MALLOC_MAX_LENTH) { - HiLog::Error(LABEL, "[FileSourceStream]Invalid value, desiredSize out of size."); + IMAGE_LOGE("[FileSourceStream]Invalid value, desiredSize out of size."); return false; } ResetReadBuffer(); readBuffer_ = static_cast(malloc(desiredSize)); if (readBuffer_ == nullptr) { - HiLog::Error(LABEL, "[FileSourceStream]malloc the desiredSize fail."); + IMAGE_LOGE("[FileSourceStream]malloc the desiredSize fail."); return false; } outData.bufferSize = desiredSize; @@ -262,7 +265,7 @@ bool FileSourceStream::GetData(uint32_t desiredSize, DataStreamBuffer &outData) } size_t bytesRead = fread(readBuffer_, sizeof(uint8_t), desiredSize, filePtr_); if (bytesRead < desiredSize) { - HiLog::Info(LABEL, "[FileSourceStream]read dataStreamBuffer fail, bytesRead:%{public}zu", bytesRead); + IMAGE_LOGI("[FileSourceStream]read dataStreamBuffer fail, bytesRead:%{public}zu", bytesRead); free(readBuffer_); readBuffer_ = nullptr; return false; @@ -281,12 +284,12 @@ static bool DupFd(FILE *f, int &res) { res = fileno(f); if (res < 0) { - HiLog::Error(LABEL, "[FileSourceStream]Fail to fileno fd."); + IMAGE_LOGE("[FileSourceStream]Fail to fileno fd."); return false; } res = dup(res); if (res < 0) { - HiLog::Error(LABEL, "[FileSourceStream]Fail to dup fd."); + IMAGE_LOGE("[FileSourceStream]Fail to dup fd."); return false; } return true; @@ -303,7 +306,7 @@ uint8_t *FileSourceStream::GetDataPtr() } auto mmptr = ::mmap(nullptr, fileSize_, PROT_READ, MAP_SHARED, mmapFd_, 0); if (mmptr == MAP_FAILED) { - HiLog::Error(LABEL, "[FileSourceStream] mmap failed, errno:%{public}d", errno); + IMAGE_LOGE("[FileSourceStream] mmap failed, errno:%{public}d", errno); return nullptr; } fileData_ = static_cast(mmptr); @@ -335,7 +338,7 @@ OutputDataStream* FileSourceStream::ToOutputDataStream() { int dupFd = -1; if (DupFd(filePtr_, dupFd)) { - HiLog::Error(LABEL, "[FileSourceStream] ToOutputDataStream fd failed"); + IMAGE_LOGE("[FileSourceStream] ToOutputDataStream fd failed"); return nullptr; } return new (std::nothrow) FilePackerStream(dupFd); diff --git a/frameworks/innerkitsimpl/stream/src/incremental_source_stream.cpp b/frameworks/innerkitsimpl/stream/src/incremental_source_stream.cpp index b120812df..0fc7ea9ae 100644 --- a/frameworks/innerkitsimpl/stream/src/incremental_source_stream.cpp +++ b/frameworks/innerkitsimpl/stream/src/incremental_source_stream.cpp @@ -17,20 +17,23 @@ #include #include -#include "hilog/log.h" -#include "log_tags.h" +#include "image_log.h" #ifndef _WIN32 #include "securec.h" #else #include "memory.h" #endif +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "IncrementalSourceStream" + namespace OHOS { namespace Media { -using namespace OHOS::HiviewDFX; using namespace std; using namespace ImagePlugin; -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "IncrementalSourceStream" }; IncrementalSourceStream::IncrementalSourceStream(IncrementalMode mode) : incrementalMode_(mode), isFinalize_(false), dataSize_(0), dataOffset_(0) @@ -38,14 +41,14 @@ IncrementalSourceStream::IncrementalSourceStream(IncrementalMode mode) unique_ptr IncrementalSourceStream::CreateSourceStream(IncrementalMode mode) { - HiLog::Debug(LABEL, "[IncrementalSourceStream]mode:%{public}d.", mode); + IMAGE_LOGD("[IncrementalSourceStream]mode:%{public}d.", mode); return (unique_ptr(new IncrementalSourceStream(mode))); } bool IncrementalSourceStream::Read(uint32_t desiredSize, DataStreamBuffer &outData) { if (!Peek(desiredSize, outData)) { - HiLog::Error(LABEL, "[IncrementalSourceStream]read fail."); + IMAGE_LOGE("[IncrementalSourceStream]read fail."); return false; } dataOffset_ += outData.dataSize; @@ -55,11 +58,11 @@ bool IncrementalSourceStream::Read(uint32_t desiredSize, DataStreamBuffer &outDa bool IncrementalSourceStream::Peek(uint32_t desiredSize, DataStreamBuffer &outData) { if (desiredSize == 0) { - HiLog::Error(LABEL, "[IncrementalSourceStream]input the parameter exception."); + IMAGE_LOGE("[IncrementalSourceStream]input the parameter exception."); return false; } if (sourceData_.empty() || dataSize_ == 0 || dataOffset_ >= dataSize_) { - HiLog::Error(LABEL, "[IncrementalSourceStream]source data exception. dataSize_:%{public}zu," + IMAGE_LOGE("[IncrementalSourceStream]source data exception. dataSize_:%{public}zu," "dataOffset_:%{public}zu.", dataSize_, dataOffset_); return false; } @@ -69,7 +72,7 @@ bool IncrementalSourceStream::Peek(uint32_t desiredSize, DataStreamBuffer &outDa } outData.dataSize = desiredSize; outData.inputStreamBuffer = sourceData_.data() + dataOffset_; - HiLog::Debug(LABEL, "[IncrementalSourceStream]Peek end. desiredSize:%{public}u, offset:%{public}zu," + IMAGE_LOGD("[IncrementalSourceStream]Peek end. desiredSize:%{public}u, offset:%{public}zu," "dataSize_:%{public}zu,dataOffset_:%{public}zu.", desiredSize, dataOffset_, dataSize_, dataOffset_); return true; } @@ -77,7 +80,7 @@ bool IncrementalSourceStream::Peek(uint32_t desiredSize, DataStreamBuffer &outDa bool IncrementalSourceStream::Read(uint32_t desiredSize, uint8_t *outBuffer, uint32_t bufferSize, uint32_t &readSize) { if (!Peek(desiredSize, outBuffer, bufferSize, readSize)) { - HiLog::Error(LABEL, "[IncrementalSourceStream]read fail."); + IMAGE_LOGE("[IncrementalSourceStream]read fail."); return false; } dataOffset_ += readSize; @@ -87,12 +90,12 @@ bool IncrementalSourceStream::Read(uint32_t desiredSize, uint8_t *outBuffer, uin bool IncrementalSourceStream::Peek(uint32_t desiredSize, uint8_t *outBuffer, uint32_t bufferSize, uint32_t &readSize) { if (desiredSize == 0 || outBuffer == nullptr || desiredSize > bufferSize) { - HiLog::Error(LABEL, "[IncrementalSourceStream]input parameter exception, desiredSize:%{public}u," + IMAGE_LOGE("[IncrementalSourceStream]input parameter exception, desiredSize:%{public}u," "bufferSize:%{public}u.", desiredSize, bufferSize); return false; } if (sourceData_.empty() || dataSize_ == 0 || dataOffset_ >= dataSize_) { - HiLog::Error(LABEL, "[IncrementalSourceStream]source data exception. dataSize_:%{public}zu," + IMAGE_LOGE("[IncrementalSourceStream]source data exception. dataSize_:%{public}zu," "dataOffset_:%{public}zu.", dataSize_, dataOffset_); return false; } @@ -101,7 +104,7 @@ bool IncrementalSourceStream::Peek(uint32_t desiredSize, uint8_t *outBuffer, uin } errno_t ret = memcpy_s(outBuffer, bufferSize, sourceData_.data() + dataOffset_, desiredSize); if (ret != 0) { - HiLog::Error(LABEL, "[IncrementalSourceStream]copy data fail, ret:%{public}d, bufferSize:%{public}u," + IMAGE_LOGE("[IncrementalSourceStream]copy data fail, ret:%{public}d, bufferSize:%{public}u," "offset:%{public}zu, desiredSize:%{public}u, dataSize:%{public}zu.", ret, bufferSize, dataOffset_, desiredSize, dataSize_); return false; @@ -118,7 +121,7 @@ uint32_t IncrementalSourceStream::Tell() bool IncrementalSourceStream::Seek(uint32_t position) { if (position >= dataSize_) { - HiLog::Error(LABEL, "[IncrementalSourceStream]Seek the position greater than the Data Size."); + IMAGE_LOGE("[IncrementalSourceStream]Seek the position greater than the Data Size."); return false; } dataOffset_ = position; @@ -128,11 +131,11 @@ bool IncrementalSourceStream::Seek(uint32_t position) uint32_t IncrementalSourceStream::UpdateData(const uint8_t *data, uint32_t size, bool isCompleted) { if (data == nullptr) { - HiLog::Error(LABEL, "[IncrementalSourceStream]input the parameter exception."); + IMAGE_LOGE("[IncrementalSourceStream]input the parameter exception."); return ERR_IMAGE_DATA_ABNORMAL; } if (size == 0) { - HiLog::Debug(LABEL, "[IncrementalSourceStream]no need to update data."); + IMAGE_LOGD("[IncrementalSourceStream]no need to update data."); return SUCCESS; } if (incrementalMode_ == IncrementalMode::INCREMENTAL_DATA) { diff --git a/frameworks/innerkitsimpl/stream/src/istream_source_stream.cpp b/frameworks/innerkitsimpl/stream/src/istream_source_stream.cpp index 3e9e4e0e9..bdeef387b 100644 --- a/frameworks/innerkitsimpl/stream/src/istream_source_stream.cpp +++ b/frameworks/innerkitsimpl/stream/src/istream_source_stream.cpp @@ -15,16 +15,19 @@ #include "istream_source_stream.h" -#include "hilog/log.h" +#include "image_log.h" #include "image_utils.h" -#include "log_tags.h" + +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "IstreamSourceStream" namespace OHOS { namespace Media { -using namespace OHOS::HiviewDFX; using namespace std; using namespace ImagePlugin; -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "IstreamSourceStream" }; IstreamSourceStream::IstreamSourceStream(unique_ptr inputStream, size_t size, size_t original, size_t offset) : inputStream_(move(inputStream)), streamSize_(size), streamOriginalOffset_(original), streamOffset_(offset) @@ -39,16 +42,16 @@ std::unique_ptr IstreamSourceStream::CreateSourceStream(uni { if ((inputStream == nullptr) || (inputStream->rdbuf() == nullptr) || inputStream.get() == nullptr) { - HiLog::Error(LABEL, "[IstreamSourceStream]input parameter exception."); + IMAGE_LOGE("[IstreamSourceStream]input parameter exception."); return nullptr; } size_t streamSize = 0; if (!ImageUtils::GetInputStreamSize(*(inputStream.get()), streamSize)) { - HiLog::Error(LABEL, "[IstreamSourceStream]Get the input stream exception."); + IMAGE_LOGE("[IstreamSourceStream]Get the input stream exception."); return nullptr; } if (streamSize == 0) { - HiLog::Error(LABEL, "[IstreamSourceStream]input stream size exception."); + IMAGE_LOGE("[IstreamSourceStream]input stream size exception."); return nullptr; } size_t original = inputStream->tellg(); @@ -59,11 +62,11 @@ std::unique_ptr IstreamSourceStream::CreateSourceStream(uni bool IstreamSourceStream::Read(uint32_t desiredSize, DataStreamBuffer &outData) { if (desiredSize == 0) { - HiLog::Error(LABEL, "[IstreamSourceStream]read stream input parameter exception."); + IMAGE_LOGE("[IstreamSourceStream]read stream input parameter exception."); return false; } if (!GetData(desiredSize, outData)) { - HiLog::Error(LABEL, "[IstreamSourceStream]read fail."); + IMAGE_LOGE("[IstreamSourceStream]read fail."); return false; } streamOffset_ += outData.dataSize; @@ -73,11 +76,11 @@ bool IstreamSourceStream::Read(uint32_t desiredSize, DataStreamBuffer &outData) bool IstreamSourceStream::Peek(uint32_t desiredSize, DataStreamBuffer &outData) { if (desiredSize == 0) { - HiLog::Error(LABEL, "[IstreamSourceStream]peek stream input parameter exception."); + IMAGE_LOGE("[IstreamSourceStream]peek stream input parameter exception."); return false; } if (!GetData(desiredSize, outData)) { - HiLog::Error(LABEL, "[IstreamSourceStream]peek fail."); + IMAGE_LOGE("[IstreamSourceStream]peek fail."); return false; } inputStream_->seekg(streamOffset_); @@ -87,12 +90,12 @@ bool IstreamSourceStream::Peek(uint32_t desiredSize, DataStreamBuffer &outData) bool IstreamSourceStream::Read(uint32_t desiredSize, uint8_t *outBuffer, uint32_t bufferSize, uint32_t &readSize) { if (desiredSize == 0 || outBuffer == nullptr || desiredSize > bufferSize) { - HiLog::Error(LABEL, "[IstreamSourceStream]input the parameter exception, desiredSize:%{public}u," + IMAGE_LOGE("[IstreamSourceStream]input the parameter exception, desiredSize:%{public}u," "bufferSize:%{public}u.", desiredSize, bufferSize); return false; } if (!GetData(desiredSize, outBuffer, bufferSize, readSize)) { - HiLog::Error(LABEL, "[IstreamSourceStream]read fail."); + IMAGE_LOGE("[IstreamSourceStream]read fail."); return false; } streamOffset_ += readSize; @@ -102,12 +105,12 @@ bool IstreamSourceStream::Read(uint32_t desiredSize, uint8_t *outBuffer, uint32_ bool IstreamSourceStream::Peek(uint32_t desiredSize, uint8_t *outBuffer, uint32_t bufferSize, uint32_t &readSize) { if (desiredSize == 0 || outBuffer == nullptr || desiredSize > bufferSize) { - HiLog::Error(LABEL, "[IstreamSourceStream]input the parameter exception, desiredSize:%{public}u," + IMAGE_LOGE("[IstreamSourceStream]input the parameter exception, desiredSize:%{public}u," "bufferSize:%{public}u.", desiredSize, bufferSize); return false; } if (!GetData(desiredSize, outBuffer, bufferSize, readSize)) { - HiLog::Error(LABEL, "[IstreamSourceStream]peek fail."); + IMAGE_LOGE("[IstreamSourceStream]peek fail."); return false; } inputStream_->seekg(streamOffset_); @@ -117,7 +120,7 @@ bool IstreamSourceStream::Peek(uint32_t desiredSize, uint8_t *outBuffer, uint32_ bool IstreamSourceStream::Seek(uint32_t position) { if (position > streamSize_) { - HiLog::Error(LABEL, "[IstreamSourceStream]Seek the position error, position:%{public}u," + IMAGE_LOGE("[IstreamSourceStream]Seek the position error, position:%{public}u," "streamSize_:%{public}zu.", position, streamSize_); return false; } @@ -135,7 +138,7 @@ uint32_t IstreamSourceStream::Tell() bool IstreamSourceStream::GetData(uint32_t desiredSize, uint8_t *outBuffer, uint32_t bufferSize, uint32_t &readSize) { if (streamSize_ == 0 || streamOffset_ >= streamSize_) { - HiLog::Error(LABEL, "[IstreamSourceStream]get source data fail. streamSize:%{public}zu," + IMAGE_LOGE("[IstreamSourceStream]get source data fail. streamSize:%{public}zu," "streamOffset:%{public}zu.", streamSize_, streamOffset_); return false; } @@ -143,7 +146,7 @@ bool IstreamSourceStream::GetData(uint32_t desiredSize, uint8_t *outBuffer, uint desiredSize = (streamSize_ - streamOffset_); } if (!inputStream_->read(reinterpret_cast(outBuffer), desiredSize)) { - HiLog::Error(LABEL, "[IstreamSourceStream]read the inputstream fail."); + IMAGE_LOGE("[IstreamSourceStream]read the inputstream fail."); return false; } readSize = desiredSize; @@ -153,19 +156,19 @@ bool IstreamSourceStream::GetData(uint32_t desiredSize, uint8_t *outBuffer, uint bool IstreamSourceStream::GetData(uint32_t desiredSize, DataStreamBuffer &outData) { if (streamSize_ == 0 || streamOffset_ >= streamSize_) { - HiLog::Error(LABEL, "[IstreamSourceStream]get source data fail. streamSize:%{public}zu," + IMAGE_LOGE("[IstreamSourceStream]get source data fail. streamSize:%{public}zu," "streamOffset:%{public}zu.", streamSize_, streamOffset_); return false; } if (desiredSize == 0 || desiredSize > MALLOC_MAX_LENTH) { - HiLog::Error(LABEL, "IstreamSourceStream]Invalid value, desiredSize out of size."); + IMAGE_LOGE("IstreamSourceStream]Invalid value, desiredSize out of size."); return false; } ResetReadBuffer(); databuffer_ = static_cast(malloc(desiredSize)); if (databuffer_ == nullptr) { - HiLog::Error(LABEL, "[IstreamSourceStream]malloc the output data buffer fail."); + IMAGE_LOGE("[IstreamSourceStream]malloc the output data buffer fail."); return false; } outData.bufferSize = desiredSize; @@ -174,7 +177,7 @@ bool IstreamSourceStream::GetData(uint32_t desiredSize, DataStreamBuffer &outDat } inputStream_->seekg(streamOffset_); if (!inputStream_->read(reinterpret_cast(databuffer_), desiredSize)) { - HiLog::Error(LABEL, "[IstreamSourceStream]read the inputstream fail."); + IMAGE_LOGE("[IstreamSourceStream]read the inputstream fail."); free(databuffer_); databuffer_ = nullptr; return false; diff --git a/frameworks/innerkitsimpl/stream/src/ostream_packer_stream.cpp b/frameworks/innerkitsimpl/stream/src/ostream_packer_stream.cpp index 74c15cfe6..a85efdbe9 100644 --- a/frameworks/innerkitsimpl/stream/src/ostream_packer_stream.cpp +++ b/frameworks/innerkitsimpl/stream/src/ostream_packer_stream.cpp @@ -15,20 +15,24 @@ #include "ostream_packer_stream.h" -#include "hilog/log.h" +#include "image_log.h" #include "log_tags.h" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "OstreamPackerStream" + namespace OHOS { namespace Media { -using namespace OHOS::HiviewDFX; -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "OstreamPackerStream"}; OstreamPackerStream::OstreamPackerStream(std::ostream &outputStream) : outputStream_(&outputStream) {} bool OstreamPackerStream::Write(const uint8_t *buffer, uint32_t size) { if ((buffer == nullptr) || (size == 0)) { - HiLog::Error(LABEL, "input parameter invalid."); + IMAGE_LOGE("input parameter invalid."); return false; } outputStream_->write(reinterpret_cast(buffer), size); diff --git a/frameworks/innerkitsimpl/test/unittest/egl_image_test.cpp b/frameworks/innerkitsimpl/test/unittest/egl_image_test.cpp index 99652379f..422dd6c52 100644 --- a/frameworks/innerkitsimpl/test/unittest/egl_image_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/egl_image_test.cpp @@ -16,12 +16,10 @@ #include #include -#include "hilog/log.h" #include "native_window.h" #include "pixel_map_from_surface.h" using namespace testing::ext; -using namespace OHOS::HiviewDFX; namespace OHOS { namespace Media { diff --git a/frameworks/innerkitsimpl/test/unittest/exif_maker_note_test.cpp b/frameworks/innerkitsimpl/test/unittest/exif_maker_note_test.cpp index 1d8be9ad4..7c1f45706 100644 --- a/frameworks/innerkitsimpl/test/unittest/exif_maker_note_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/exif_maker_note_test.cpp @@ -19,8 +19,6 @@ #include "exif_maker_note.h" #include "securec.h" #include "string_ex.h" -#include "hilog/log.h" -#include "log_tags.h" #include "media_errors.h" #include "exif_info.h" #include "jpeg_decoder.h" @@ -28,7 +26,6 @@ using namespace testing::ext; using namespace OHOS::Media; -using namespace OHOS::HiviewDFX; namespace OHOS { namespace ImagePlugin { constexpr unsigned char HW_MNOTE_HEADER[] = { 'H', 'U', 'A', 'W', 'E', 'I', '\0', '\0' }; diff --git a/frameworks/innerkitsimpl/test/unittest/image_color_space_test.cpp b/frameworks/innerkitsimpl/test/unittest/image_color_space_test.cpp index 04dabb576..0ab9597be 100644 --- a/frameworks/innerkitsimpl/test/unittest/image_color_space_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/image_color_space_test.cpp @@ -20,19 +20,23 @@ #include "color_space.h" #endif #include "directory_ex.h" -#include "hilog/log.h" +#include "image_log.h" #include "image_packer.h" #include "image_source.h" #include "image_type.h" #include "image_utils.h" -#include "log_tags.h" #include "media_errors.h" #include "pixel_map.h" #include "image_source_util.h" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "ImageColorSpaceTest" + using namespace testing::ext; using namespace OHOS::Media; -using namespace OHOS::HiviewDFX; using namespace OHOS::ImageSourceUtil; namespace OHOS { @@ -42,10 +46,6 @@ static const std::string IMAGE_OUTPUT_JPEG_INCLUDE_ICC_PATH = "/data/test/test_j static const std::string IMAGE_INPUT_JPEG_NOT_INCLUDE_ICC_PATH = "/data/local/tmp/image/test.jpg"; static const std::string IMAGE_OUTPUT_JPEG_NOT_INCLUDE_ICC_PATH = "/data/test/test_jpeg_no_include_icc_profile.jpg"; -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL_TEST = { - LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "ImageColorSpaceTest" -}; - class ImageColorSpaceTest : public testing::Test { public: ImageColorSpaceTest() {}; @@ -68,7 +68,7 @@ HWTEST_F(ImageColorSpaceTest, JpegColorSpaceDecode001, TestSize.Level3) opts.formatHint = "image/jpeg"; std::unique_ptr imageSource = ImageSource::CreateImageSource(IMAGE_INPUT_JPEG_INCLUDE_ICC_PATH, opts, errorCode); - HiLog::Debug(LABEL_TEST, "create image source error code=%{public}u.", errorCode); + IMAGE_LOGD("create image source error code=%{public}u.", errorCode); ASSERT_EQ(errorCode, SUCCESS); ASSERT_NE(imageSource.get(), nullptr); @@ -79,7 +79,7 @@ HWTEST_F(ImageColorSpaceTest, JpegColorSpaceDecode001, TestSize.Level3) */ DecodeOptions decodeOpts; std::unique_ptr pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); - HiLog::Debug(LABEL_TEST, "create pixel map error code=%{public}u.", errorCode); + IMAGE_LOGD("create pixel map error code=%{public}u.", errorCode); ASSERT_EQ(errorCode, SUCCESS); ASSERT_NE(pixelMap.get(), nullptr); #ifdef IMAGE_COLORSPACE_FLAG @@ -107,7 +107,7 @@ HWTEST_F(ImageColorSpaceTest, JpegColorSpaceEncode001, TestSize.Level3) opts.formatHint = "image/jpeg"; std::unique_ptr imageSource = ImageSource::CreateImageSource(IMAGE_INPUT_JPEG_INCLUDE_ICC_PATH, opts, errorCode); - HiLog::Debug(LABEL_TEST, "create image source error code==%{public}u.", errorCode); + IMAGE_LOGD("create image source error code==%{public}u.", errorCode); ASSERT_EQ(errorCode, SUCCESS); ASSERT_NE(imageSource.get(), nullptr); @@ -118,7 +118,7 @@ HWTEST_F(ImageColorSpaceTest, JpegColorSpaceEncode001, TestSize.Level3) */ DecodeOptions decodeOpts; std::unique_ptr pixelMapOne = imageSource->CreatePixelMap(decodeOpts, errorCode); - HiLog::Debug(LABEL_TEST, "create pixel map error code=%{public}u.", errorCode); + IMAGE_LOGD("create pixel map error code=%{public}u.", errorCode); ASSERT_EQ(errorCode, SUCCESS); ASSERT_NE(pixelMapOne.get(), nullptr); #ifdef IMAGE_COLORSPACE_FLAG @@ -176,7 +176,7 @@ HWTEST_F(ImageColorSpaceTest, JpegColorSpaceDecode002, TestSize.Level3) opts.formatHint = "image/jpeg"; std::unique_ptr imageSource = ImageSource::CreateImageSource(IMAGE_INPUT_JPEG_NOT_INCLUDE_ICC_PATH, opts, errorCode); - HiLog::Debug(LABEL_TEST, "create image source error code=%{public}u.", errorCode); + IMAGE_LOGD("create image source error code=%{public}u.", errorCode); ASSERT_EQ(errorCode, SUCCESS); ASSERT_NE(imageSource.get(), nullptr); @@ -187,7 +187,7 @@ HWTEST_F(ImageColorSpaceTest, JpegColorSpaceDecode002, TestSize.Level3) */ DecodeOptions decodeOpts; std::unique_ptr pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); - HiLog::Debug(LABEL_TEST, "create pixel map error code=%{public}u.", errorCode); + IMAGE_LOGD("create pixel map error code=%{public}u.", errorCode); ASSERT_EQ(errorCode, SUCCESS); ASSERT_NE(pixelMap.get(), nullptr); #ifdef IMAGE_COLORSPACE_FLAG @@ -212,7 +212,7 @@ HWTEST_F(ImageColorSpaceTest, JpegColorSpaceEncode002, TestSize.Level3) opts.formatHint = "image/jpeg"; std::unique_ptr imageSource = ImageSource::CreateImageSource(IMAGE_INPUT_JPEG_NOT_INCLUDE_ICC_PATH, opts, errorCode); - HiLog::Debug(LABEL_TEST, "create image source error code==%{public}u.", errorCode); + IMAGE_LOGD("create image source error code==%{public}u.", errorCode); ASSERT_EQ(errorCode, SUCCESS); ASSERT_NE(imageSource.get(), nullptr); @@ -223,7 +223,7 @@ HWTEST_F(ImageColorSpaceTest, JpegColorSpaceEncode002, TestSize.Level3) */ DecodeOptions decodeOpts; std::unique_ptr pixelMapOne = imageSource->CreatePixelMap(decodeOpts, errorCode); - HiLog::Debug(LABEL_TEST, "create pixel map error code=%{public}u.", errorCode); + IMAGE_LOGD("create pixel map error code=%{public}u.", errorCode); ASSERT_EQ(errorCode, SUCCESS); ASSERT_NE(pixelMapOne.get(), nullptr); #ifdef IMAGE_COLORSPACE_FLAG diff --git a/frameworks/innerkitsimpl/test/unittest/image_creator_test.cpp b/frameworks/innerkitsimpl/test/unittest/image_creator_test.cpp index 19284cc5c..fc1157ecf 100644 --- a/frameworks/innerkitsimpl/test/unittest/image_creator_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/image_creator_test.cpp @@ -15,7 +15,6 @@ #include #include -#include "hilog/log.h" #include "image_creator.h" #include "image_packer.h" #include "image_source.h" diff --git a/frameworks/innerkitsimpl/test/unittest/image_receiver_manager_test.cpp b/frameworks/innerkitsimpl/test/unittest/image_receiver_manager_test.cpp index 76cc7b1b5..def5667cf 100644 --- a/frameworks/innerkitsimpl/test/unittest/image_receiver_manager_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/image_receiver_manager_test.cpp @@ -20,7 +20,6 @@ #include "image_packer.h" #include "image_source.h" #include "image_utils.h" -#include "hilog/log.h" #include "image_receiver_manager.h" using namespace testing::ext; diff --git a/frameworks/innerkitsimpl/test/unittest/image_receiver_test.cpp b/frameworks/innerkitsimpl/test/unittest/image_receiver_test.cpp index 8a4db155f..98894a638 100644 --- a/frameworks/innerkitsimpl/test/unittest/image_receiver_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/image_receiver_test.cpp @@ -21,7 +21,6 @@ #include "image_source.h" #include "image_type.h" #include "image_utils.h" -#include "hilog/log.h" #include "image_receiver_manager.h" using namespace testing::ext; diff --git a/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_bmp_test.cpp b/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_bmp_test.cpp index 52d0a2b55..c9fdfa2dc 100644 --- a/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_bmp_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_bmp_test.cpp @@ -16,7 +16,6 @@ #include #include #include "directory_ex.h" -#include "hilog/log.h" #include "image_packer.h" #include "image_source.h" #include "image_source_util.h" @@ -27,7 +26,6 @@ using namespace testing::ext; using namespace OHOS::Media; -using namespace OHOS::HiviewDFX; using namespace OHOS::ImageSourceUtil; namespace OHOS { namespace Multimedia { diff --git a/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_gif_ex_test.cpp b/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_gif_ex_test.cpp index dc1ecebd4..7ab8c01a3 100644 --- a/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_gif_ex_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_gif_ex_test.cpp @@ -19,14 +19,18 @@ #include "media_errors.h" #include "image_source.h" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "ImageSourceGifExTest" + using namespace testing::ext; using namespace OHOS::Media; -using namespace OHOS::HiviewDFX; using namespace OHOS::ImageSourceUtil; namespace OHOS { namespace Media { namespace { -static constexpr HiLogLabel LABEL_TEST = { LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "ImageSourceGifExTest" }; static const std::string INPUT_PATH = "/data/local/tmp/image/"; static const std::string OUTPUT_PATH = "/data/local/tmp/image/output_"; static const std::string OUTPUT_EXT = ".jpg"; @@ -168,7 +172,7 @@ HWTEST_F(ImageSourceGifExTest, GetDelayTime001, TestSize.Level3) ASSERT_EQ(delayTimes->size(), TEST_FILE_SINGLE_FRAME_GIF_FRAME_COUNT); for (auto delayTime : *delayTimes) { - HiLog::Debug(LABEL_TEST, "delay time is %{public}u.", delayTime); + IMAGE_LOGD("delay time is %{public}u.", delayTime); } GTEST_LOG_(INFO) << "ImageSourceGifExTest: GetDelayTime001 end"; @@ -196,7 +200,7 @@ HWTEST_F(ImageSourceGifExTest, GetDelayTime002, TestSize.Level3) ASSERT_EQ(delayTimes->size(), TEST_FILE_MULTI_FRAME_GIF_FRAME_COUNT); for (auto delayTime : *delayTimes) { - HiLog::Debug(LABEL_TEST, "delay time is %{public}u.", delayTime); + IMAGE_LOGD("delay time is %{public}u.", delayTime); } GTEST_LOG_(INFO) << "ImageSourceGifExTest: GetDelayTime002 end"; diff --git a/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_gif_test.cpp b/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_gif_test.cpp index 32e5e2140..238f9b8a7 100644 --- a/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_gif_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_gif_test.cpp @@ -16,28 +16,28 @@ #include #include #include "directory_ex.h" -#include "hilog/log.h" +#include "image_log.h" #include "image_packer.h" #include "image_source.h" #include "image_source_util.h" #include "image_type.h" #include "image_utils.h" #include "incremental_pixel_map.h" -#include "log_tags.h" #include "media_errors.h" #include "pixel_map.h" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "ImageSourceGifTest" + using namespace testing::ext; using namespace OHOS::Media; -using namespace OHOS::HiviewDFX; using namespace OHOS::ImageSourceUtil; namespace OHOS { namespace Multimedia { -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL_TEST = { - LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "ImageSourceGifTest" -}; - class ImageSourceGifTest : public testing::Test { public: ImageSourceGifTest() {} @@ -120,7 +120,7 @@ HWTEST_F(ImageSourceGifTest, GifImageDecode004, TestSize.Level3) DecodeOptions decodeOpts; decodeOpts.desiredPixelFormat = PixelFormat::BGRA_8888; std::unique_ptr pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); - HiLog::Debug(LABEL_TEST, "create bitmap code=%{public}d.", errorCode); + IMAGE_LOGD("create bitmap code=%{public}d.", errorCode); ASSERT_EQ(errorCode, SUCCESS); ASSERT_NE(pixelMap.get(), nullptr); /** @@ -135,7 +135,7 @@ HWTEST_F(ImageSourceGifTest, GifImageDecode004, TestSize.Level3) uint8_t red = pixelMap->GetARGB32ColorR(color); uint8_t green = pixelMap->GetARGB32ColorG(color); uint8_t blue = pixelMap->GetARGB32ColorB(color); - HiLog::Debug(LABEL_TEST, "point:[%u, %u] ARGB:[%u, %u, %u, %u]", posX, posY, alpha, red, green, blue); + IMAGE_LOGD("point:[%u, %u] ARGB:[%u, %u, %u, %u]", posX, posY, alpha, red, green, blue); EXPECT_EQ(255, alpha); EXPECT_EQ(244, red); EXPECT_EQ(63, green); @@ -183,7 +183,7 @@ HWTEST_F(ImageSourceGifTest, GifImageDecode005, TestSize.Level3) uint8_t green = pixelMap->GetARGB32ColorG(color); uint8_t blue = pixelMap->GetARGB32ColorB(color); uint8_t alpha = pixelMap->GetARGB32ColorA(color); - HiLog::Debug(LABEL_TEST, "point:[%u, %u] RGBA:[%u, %u, %u, %u]", posX, posY, red, green, blue, alpha); + IMAGE_LOGD("point:[%u, %u] RGBA:[%u, %u, %u, %u]", posX, posY, red, green, blue, alpha); EXPECT_EQ(255, alpha); EXPECT_EQ(244, red); EXPECT_EQ(63, green); diff --git a/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_jpeg_test.cpp b/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_jpeg_test.cpp index 56d8d8d26..ef8873a6b 100644 --- a/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_jpeg_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_jpeg_test.cpp @@ -17,13 +17,12 @@ #include #include #include "directory_ex.h" -#include "hilog/log.h" +#include "image_log.h" #include "image_packer.h" #include "image_source.h" #include "image_type.h" #include "image_utils.h" #include "incremental_pixel_map.h" -#include "log_tags.h" #include "media_errors.h" #include "pixel_map.h" #include "image_receiver.h" @@ -32,16 +31,18 @@ #include "graphic_common.h" #include "image_receiver_manager.h" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "ImageSourceJpegTest" + using namespace testing::ext; using namespace OHOS::Media; -using namespace OHOS::HiviewDFX; using namespace OHOS::ImageSourceUtil; namespace OHOS { namespace Multimedia { -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL_TEST = { - LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "ImageSourceJpegTest" -}; static constexpr uint32_t DEFAULT_DELAY_UTIME = 10000; // 10 ms. static const std::string IMAGE_INPUT_JPEG_PATH = "/data/local/tmp/image/test.jpg"; static const std::string IMAGE_INPUT_HW_JPEG_PATH = "/data/local/tmp/image/test_hw.jpg"; @@ -257,7 +258,7 @@ HWTEST_F(ImageSourceJpegTest, TC036, TestSize.Level3) decodeOpts.desiredSize.height = 400; decodeOpts.rotateDegrees = 90; std::unique_ptr pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); - HiLog::Debug(LABEL_TEST, "create pixel map error code=%{public}u.", errorCode); + IMAGE_LOGD("create pixel map error code=%{public}u.", errorCode); ASSERT_EQ(errorCode, SUCCESS); ASSERT_NE(pixelMap.get(), nullptr); EXPECT_EQ(200, pixelMap->GetWidth()); @@ -987,7 +988,7 @@ HWTEST_F(ImageSourceJpegTest, JpegImageDecode011, TestSize.Level3) */ DecodeOptions decodeOpts; std::unique_ptr pixelMap = imageSource->CreatePixelMap(decodeOpts, status); - HiLog::Debug(LABEL_TEST, "create pixel map ret=%{public}u.", status); + IMAGE_LOGD("create pixel map ret=%{public}u.", status); ASSERT_EQ(status, SUCCESS); ASSERT_NE(pixelMap.get(), nullptr); @@ -1042,7 +1043,7 @@ HWTEST_F(ImageSourceJpegTest, JpgImageCrop001, TestSize.Level3) decodeOpts.desiredSize.height = 400; decodeOpts.rotateDegrees = 90; std::unique_ptr pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); - HiLog::Debug(LABEL_TEST, "create pixel map error code=%{public}u.", errorCode); + IMAGE_LOGD("create pixel map error code=%{public}u.", errorCode); ASSERT_EQ(errorCode, SUCCESS); ASSERT_NE(pixelMap.get(), nullptr); EXPECT_EQ(200, pixelMap->GetWidth()); @@ -1073,7 +1074,7 @@ HWTEST_F(ImageSourceJpegTest, JpegImageHwDecode001, TestSize.Level3) */ DecodeOptions decodeOpts; std::unique_ptr pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); - HiLog::Debug(LABEL_TEST, "create pixel map ret=%{public}u.", errorCode); + IMAGE_LOGD("create pixel map ret=%{public}u.", errorCode); ASSERT_EQ(errorCode, SUCCESS); ASSERT_NE(pixelMap.get(), nullptr); /** diff --git a/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_png_test.cpp b/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_png_test.cpp index 644a795b3..4ed1bb6f0 100644 --- a/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_png_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_png_test.cpp @@ -16,26 +16,27 @@ #include #include #include "directory_ex.h" -#include "hilog/log.h" +#include "image_log.h" #include "image_packer.h" #include "image_source.h" #include "image_source_util.h" #include "image_type.h" #include "image_utils.h" #include "incremental_pixel_map.h" -#include "log_tags.h" #include "media_errors.h" #include "pixel_map.h" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "ImageSourcePngTest" + using namespace testing::ext; using namespace OHOS::Media; -using namespace OHOS::HiviewDFX; using namespace OHOS::ImageSourceUtil; namespace OHOS { namespace Multimedia { -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL_TEST = { - LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "ImageSourcePngTest" -}; static constexpr uint32_t DEFAULT_DELAY_UTIME = 10000; // 10 ms. class ImageSourcePngTest : public testing::Test { @@ -68,7 +69,7 @@ HWTEST_F(ImageSourcePngTest, PngImageDecode001, TestSize.Level3) */ DecodeOptions decodeOpts; std::unique_ptr pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); - HiLog::Debug(LABEL_TEST, "create pixel map error code=%{public}u.", errorCode); + IMAGE_LOGD("create pixel map error code=%{public}u.", errorCode); ASSERT_EQ(errorCode, SUCCESS); ASSERT_NE(pixelMap.get(), nullptr); /** @@ -204,7 +205,7 @@ HWTEST_F(ImageSourcePngTest, PngImageDecode006, TestSize.Level3) */ DecodeOptions decodeOpts; std::unique_ptr pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); - HiLog::Debug(LABEL_TEST, "create pixel map error code=%{public}u.", errorCode); + IMAGE_LOGD("create pixel map error code=%{public}u.", errorCode); ASSERT_EQ(errorCode, SUCCESS); ASSERT_NE(pixelMap.get(), nullptr); /** @@ -258,7 +259,7 @@ HWTEST_F(ImageSourcePngTest, PngImageDecode007, TestSize.Level3) uint32_t ret = imageSource->UpdateData(buffer + updateSize, updateOnceSize, isCompleted); ASSERT_EQ(ret, SUCCESS); uint8_t decodeProgress = 0; - HiLog::Debug(LABEL_TEST, "updateOnceSize:%{public}u,updateSize:%{public}u,bufferSize:%{public}zu", + IMAGE_LOGD("updateOnceSize:%{public}u,updateSize:%{public}u,bufferSize:%{public}zu", updateOnceSize, updateSize, bufferSize); incPixelMap->PromoteDecoding(decodeProgress); updateSize += updateOnceSize; @@ -490,7 +491,7 @@ HWTEST_F(ImageSourcePngTest, PngImageCrop001, TestSize.Level3) decodeOpts.CropRect.left = 3; decodeOpts.CropRect.height = 40; std::unique_ptr pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); - HiLog::Debug(LABEL_TEST, "create pixel map error code=%{public}u.", errorCode); + IMAGE_LOGD("create pixel map error code=%{public}u.", errorCode); ASSERT_EQ(errorCode, SUCCESS); ASSERT_NE(pixelMap.get(), nullptr); EXPECT_EQ(200, pixelMap->GetWidth()); diff --git a/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_raw_test.cpp b/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_raw_test.cpp index c1701ea28..f6c1f075d 100644 --- a/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_raw_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_raw_test.cpp @@ -15,7 +15,6 @@ #include #include -#include "hilog/log.h" #include "directory_ex.h" #include "image_source_util.h" #include "image_packer.h" @@ -27,7 +26,6 @@ using namespace testing::ext; using namespace OHOS::Media; -using namespace OHOS::HiviewDFX; namespace OHOS { namespace Multimedia { diff --git a/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_test.cpp b/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_test.cpp index 76f053f20..ffc26ef1d 100644 --- a/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_test.cpp @@ -38,7 +38,6 @@ using namespace testing::ext; using namespace OHOS::Media; -using namespace OHOS::HiviewDFX; namespace OHOS { namespace Media { static const std::string IMAGE_INPUT_JPEG_PATH = "/data/local/tmp/image/test.jpg"; @@ -1510,5 +1509,307 @@ HWTEST_F(ImageSourceTest, CreatePixelMapForYUVTest001, TestSize.Level3) ASSERT_EQ(ret, nullptr); GTEST_LOG_(INFO) << "ImageSourceTest: CreatePixelMapForYUVTest001 end"; } + +/** + * @tc.name: End2EndTest001 + * @tc.desc: test CreateImageSource and CreatePixelMap of jpg resource + * @tc.type: FUNC + */ +HWTEST_F(ImageSourceTest, End2EndTest001, TestSize.Level3) +{ + GTEST_LOG_(INFO) << "ImageSourceTest: End2EndTest001 start"; + uint32_t errorCode = 0; + SourceOptions opts; + std::unique_ptr imageSource = + ImageSource::CreateImageSource("/data/local/tmp/image/test.jpg", opts, errorCode); + ASSERT_EQ(errorCode, SUCCESS); + ASSERT_NE(imageSource.get(), nullptr); + + int32_t jpegWidth = 472; + int32_t jpegHeight = 226; + + DecodeOptions decodeOpts; + std::unique_ptr pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); + ASSERT_EQ(errorCode, SUCCESS); + ASSERT_NE(pixelMap.get(), nullptr); + ASSERT_EQ(jpegWidth, pixelMap->GetWidth()); + ASSERT_EQ(jpegHeight, pixelMap->GetHeight()); + + int32_t desiredWidth = 400; + int32_t desiredHeight = 200; + + decodeOpts.desiredSize.width = desiredWidth; + decodeOpts.desiredSize.height = desiredHeight; + pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); + ASSERT_EQ(errorCode, SUCCESS); + ASSERT_NE(pixelMap.get(), nullptr); + ASSERT_EQ(desiredWidth, pixelMap->GetWidth()); + ASSERT_EQ(desiredHeight, pixelMap->GetHeight()); + + GTEST_LOG_(INFO) << "ImageSourceTest: End2EndTest001 end"; +} + +/** + * @tc.name: End2EndTest002 + * @tc.desc: test CreateImageSource and CreatePixelMap of png resource + * @tc.type: FUNC + */ +HWTEST_F(ImageSourceTest, End2EndTest002, TestSize.Level3) +{ + GTEST_LOG_(INFO) << "ImageSourceTest: End2EndTest002 start"; + uint32_t errorCode = 0; + SourceOptions opts; + std::unique_ptr imageSource = + ImageSource::CreateImageSource("/data/local/tmp/image/test.png", opts, errorCode); + ASSERT_EQ(errorCode, SUCCESS); + ASSERT_NE(imageSource.get(), nullptr); + + int32_t pngWidth = 472; + int32_t pngHeight = 75; + + DecodeOptions decodeOpts; + std::unique_ptr pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); + ASSERT_EQ(errorCode, SUCCESS); + ASSERT_NE(pixelMap.get(), nullptr); + ASSERT_EQ(pngWidth, pixelMap->GetWidth()); + ASSERT_EQ(pngHeight, pixelMap->GetHeight()); + + int32_t desiredWidth = 400; + int32_t desiredHeight = 200; + + decodeOpts.desiredSize.width = desiredWidth; + decodeOpts.desiredSize.height = desiredHeight; + pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); + ASSERT_EQ(errorCode, SUCCESS); + ASSERT_NE(pixelMap.get(), nullptr); + ASSERT_EQ(desiredWidth, pixelMap->GetWidth()); + ASSERT_EQ(desiredHeight, pixelMap->GetHeight()); + + GTEST_LOG_(INFO) << "ImageSourceTest: End2EndTest002 end"; +} + +/** + * @tc.name: End2EndTest003 + * @tc.desc: test CreateImageSource and CreatePixelMap of bmp resource + * @tc.type: FUNC + */ +HWTEST_F(ImageSourceTest, End2EndTest003, TestSize.Level3) +{ + GTEST_LOG_(INFO) << "ImageSourceTest: End2EndTest003 start"; + uint32_t errorCode = 0; + SourceOptions opts; + std::unique_ptr imageSource = + ImageSource::CreateImageSource("/data/local/tmp/image/test.bmp", opts, errorCode); + ASSERT_EQ(errorCode, SUCCESS); + ASSERT_NE(imageSource.get(), nullptr); + + int32_t bmpWidth = 472; + int32_t bmpHeight = 75; + + DecodeOptions decodeOpts; + std::unique_ptr pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); + ASSERT_EQ(errorCode, SUCCESS); + ASSERT_NE(pixelMap.get(), nullptr); + ASSERT_EQ(bmpWidth, pixelMap->GetWidth()); + ASSERT_EQ(bmpHeight, pixelMap->GetHeight()); + + int32_t desiredWidth = 400; + int32_t desiredHeight = 200; + + decodeOpts.desiredSize.width = desiredWidth; + decodeOpts.desiredSize.height = desiredHeight; + pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); + ASSERT_EQ(errorCode, SUCCESS); + ASSERT_NE(pixelMap.get(), nullptr); + ASSERT_EQ(desiredWidth, pixelMap->GetWidth()); + ASSERT_EQ(desiredHeight, pixelMap->GetHeight()); + + GTEST_LOG_(INFO) << "ImageSourceTest: End2EndTest003 end"; +} + +/** + * @tc.name: End2EndTest004 + * @tc.desc: test CreateImageSource and CreatePixelMap of ico resource + * @tc.type: FUNC + */ +HWTEST_F(ImageSourceTest, End2EndTest004, TestSize.Level3) +{ + GTEST_LOG_(INFO) << "ImageSourceTest: End2EndTest004 start"; + uint32_t errorCode = 0; + SourceOptions opts; + std::unique_ptr imageSource = + ImageSource::CreateImageSource("/data/local/tmp/image/test.ico", opts, errorCode); + ASSERT_EQ(errorCode, SUCCESS); + ASSERT_NE(imageSource.get(), nullptr); + + int32_t icoWidth = 48; + int32_t icoHeight = 48; + + DecodeOptions decodeOpts; + std::unique_ptr pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); + ASSERT_EQ(errorCode, SUCCESS); + ASSERT_NE(pixelMap.get(), nullptr); + ASSERT_EQ(icoWidth, pixelMap->GetWidth()); + ASSERT_EQ(icoHeight, pixelMap->GetHeight()); + + int32_t desiredWidth = 56; + int32_t desiredHeight = 56; + + decodeOpts.desiredSize.width = desiredWidth; + decodeOpts.desiredSize.height = desiredHeight; + pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); + ASSERT_EQ(errorCode, SUCCESS); + ASSERT_NE(pixelMap.get(), nullptr); + ASSERT_EQ(desiredWidth, pixelMap->GetWidth()); + ASSERT_EQ(desiredHeight, pixelMap->GetHeight()); + + GTEST_LOG_(INFO) << "ImageSourceTest: End2EndTest004 end"; +} + +/** + * @tc.name: End2EndTest005 + * @tc.desc: test CreateImageSource and CreatePixelMap of svg resource + * @tc.type: FUNC + */ +HWTEST_F(ImageSourceTest, End2EndTest005, TestSize.Level3) +{ + GTEST_LOG_(INFO) << "ImageSourceTest: End2EndTest005 start"; + uint32_t errorCode = 0; + SourceOptions opts; + std::unique_ptr imageSource = + ImageSource::CreateImageSource("/data/local/tmp/image/test.svg", opts, errorCode); + ASSERT_EQ(errorCode, SUCCESS); + ASSERT_NE(imageSource.get(), nullptr); + + int32_t desiredWidth = 56; + int32_t desiredHeight = 56; + DecodeOptions decodeOpts; + decodeOpts.desiredSize.width = desiredWidth; + decodeOpts.desiredSize.height = desiredHeight; + std::unique_ptr pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); + ASSERT_EQ(errorCode, SUCCESS); + ASSERT_NE(pixelMap.get(), nullptr); + ASSERT_EQ(desiredWidth, pixelMap->GetWidth()); + ASSERT_EQ(desiredHeight, pixelMap->GetHeight()); + + GTEST_LOG_(INFO) << "ImageSourceTest: End2EndTest005 end"; +} + +/** + * @tc.name: End2EndTest006 + * @tc.desc: test CreateImageSource and CreatePixelMap of gif resource + * @tc.type: FUNC + */ +HWTEST_F(ImageSourceTest, End2EndTest006, TestSize.Level3) +{ + GTEST_LOG_(INFO) << "ImageSourceTest: End2EndTest006 start"; + uint32_t errorCode = 0; + SourceOptions opts; + std::unique_ptr imageSource = + ImageSource::CreateImageSource("/data/local/tmp/image/test.gif", opts, errorCode); + ASSERT_EQ(errorCode, SUCCESS); + ASSERT_NE(imageSource.get(), nullptr); + + int32_t gifWidth = 198; + int32_t gifHeight = 202; + + DecodeOptions decodeOpts; + std::unique_ptr pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); + ASSERT_EQ(errorCode, SUCCESS); + ASSERT_NE(pixelMap.get(), nullptr); + ASSERT_EQ(gifWidth, pixelMap->GetWidth()); + ASSERT_EQ(gifHeight, pixelMap->GetHeight()); + + int32_t desiredWidth = 150; + int32_t desiredHeight = 150; + + decodeOpts.desiredSize.width = desiredWidth; + decodeOpts.desiredSize.height = desiredHeight; + pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); + ASSERT_EQ(errorCode, SUCCESS); + ASSERT_NE(pixelMap.get(), nullptr); + ASSERT_EQ(desiredWidth, pixelMap->GetWidth()); + ASSERT_EQ(desiredHeight, pixelMap->GetHeight()); + + GTEST_LOG_(INFO) << "ImageSourceTest: End2EndTest006 end"; +} + +/** + * @tc.name: End2EndTest007 + * @tc.desc: test CreateImageSource and CreatePixelMap of webp resource + * @tc.type: FUNC + */ +HWTEST_F(ImageSourceTest, End2EndTest007, TestSize.Level3) +{ + GTEST_LOG_(INFO) << "ImageSourceTest: End2EndTest007 start"; + uint32_t errorCode = 0; + SourceOptions opts; + std::unique_ptr imageSource = + ImageSource::CreateImageSource("/data/local/tmp/image/test.webp", opts, errorCode); + ASSERT_EQ(errorCode, SUCCESS); + ASSERT_NE(imageSource.get(), nullptr); + + int32_t webpWidth = 286; + int32_t webpHeight = 221; + + DecodeOptions decodeOpts; + std::unique_ptr pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); + ASSERT_EQ(errorCode, SUCCESS); + ASSERT_NE(pixelMap.get(), nullptr); + ASSERT_EQ(webpWidth, pixelMap->GetWidth()); + ASSERT_EQ(webpHeight, pixelMap->GetHeight()); + + int32_t desiredWidth = 150; + int32_t desiredHeight = 150; + + decodeOpts.desiredSize.width = desiredWidth; + decodeOpts.desiredSize.height = desiredHeight; + pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); + ASSERT_EQ(errorCode, SUCCESS); + ASSERT_NE(pixelMap.get(), nullptr); + ASSERT_EQ(desiredWidth, pixelMap->GetWidth()); + ASSERT_EQ(desiredHeight, pixelMap->GetHeight()); + + GTEST_LOG_(INFO) << "ImageSourceTest: End2EndTest007 end"; +} + +/** + * @tc.name: End2EndTest008 + * @tc.desc: test CreateImageSource and CreatePixelMap of dng resource + * @tc.type: FUNC + */ +HWTEST_F(ImageSourceTest, End2EndTest008, TestSize.Level3) +{ + GTEST_LOG_(INFO) << "ImageSourceTest: End2EndTest008 start"; + uint32_t errorCode = 0; + SourceOptions opts; + std::unique_ptr imageSource = + ImageSource::CreateImageSource("/data/local/tmp/image/test.dng", opts, errorCode); + ASSERT_EQ(errorCode, SUCCESS); + ASSERT_NE(imageSource.get(), nullptr); + + int32_t webpWidth = 160; + int32_t webpHeight = 120; + + DecodeOptions decodeOpts; + std::unique_ptr pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); + ASSERT_EQ(errorCode, SUCCESS); + ASSERT_NE(pixelMap.get(), nullptr); + ASSERT_EQ(webpWidth, pixelMap->GetWidth()); + ASSERT_EQ(webpHeight, pixelMap->GetHeight()); + + int32_t desiredWidth = 100; + int32_t desiredHeight = 100; + + decodeOpts.desiredSize.width = desiredWidth; + decodeOpts.desiredSize.height = desiredHeight; + pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); + ASSERT_EQ(errorCode, SUCCESS); + ASSERT_NE(pixelMap.get(), nullptr); + ASSERT_EQ(desiredWidth, pixelMap->GetWidth()); + ASSERT_EQ(desiredHeight, pixelMap->GetHeight()); + + GTEST_LOG_(INFO) << "ImageSourceTest: End2EndTest008 end"; +} } // namespace Multimedia } // namespace OHOS \ No newline at end of file diff --git a/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_util.cpp b/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_util.cpp index a79610317..4eeee355d 100644 --- a/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_util.cpp +++ b/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_util.cpp @@ -16,20 +16,23 @@ #include #include #include "directory_ex.h" -#include "hilog/log.h" +#include "image_log.h" #include "image_packer.h" #include "image_type.h" #include "image_utils.h" -#include "log_tags.h" #include "media_errors.h" #include "pixel_map.h" #include "image_source_util.h" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "ImageSourceUtil" + using namespace OHOS::Media; -using namespace OHOS::HiviewDFX; using namespace OHOS::ImageSourceUtil; -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL_TEST = { LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "ImageSourceUtil" }; namespace OHOS { namespace ImageSourceUtil { constexpr uint32_t NUM_1 = 1; @@ -45,12 +48,12 @@ int64_t PackImage(const std::string &filePath, std::unique_ptr pixelMa option.numberHint = NUM_1; std::set formats; if (pixelMap == nullptr) { - HiLog::Error(LABEL_TEST, "pixelMap is nullptr"); + IMAGE_LOGE("pixelMap is nullptr"); return 0; } uint32_t ret = imagePacker.GetSupportedFormats(formats); if (ret != SUCCESS) { - HiLog::Error(LABEL_TEST, "image packer get supported format failed, ret=%{public}u.", ret); + IMAGE_LOGE("image packer get supported format failed, ret=%{public}u.", ret); return 0; } imagePacker.StartPacking(filePath, option); @@ -69,18 +72,18 @@ int64_t PackImage(std::unique_ptr imageSource) option.numberHint = 1; std::set formats; if (imageSource == nullptr) { - HiLog::Error(LABEL_TEST, "imageSource is nullptr"); + IMAGE_LOGE("imageSource is nullptr"); return 0; } uint32_t ret = imagePacker.GetSupportedFormats(formats); if (ret != SUCCESS) { - HiLog::Error(LABEL_TEST, "image packer get supported format failed, ret=%{public}u.", ret); + IMAGE_LOGE("image packer get supported format failed, ret=%{public}u.", ret); return 0; } int64_t bufferSize = BUFFER_SIZE; uint8_t *resultBuffer = reinterpret_cast(malloc(bufferSize)); if (resultBuffer == nullptr) { - HiLog::Error(LABEL_TEST, "image packer malloc buffer failed."); + IMAGE_LOGE("image packer malloc buffer failed."); return 0; } imagePacker.StartPacking(resultBuffer, bufferSize, option); @@ -94,32 +97,31 @@ bool ReadFileToBuffer(const std::string &filePath, uint8_t *buffer, size_t buffe { std::string realPath; if (!OHOS::PathToRealPath(filePath, realPath)) { - HiLog::Error(LABEL_TEST, "file path to real path failed, file path=%{public}s.", filePath.c_str()); + IMAGE_LOGE("file path to real path failed, file path=%{public}s.", filePath.c_str()); return false; } if (buffer == nullptr) { - HiLog::Error(LABEL_TEST, "buffer is nullptr"); + IMAGE_LOGE("buffer is nullptr"); return false; } FILE *fp = fopen(realPath.c_str(), "rb"); if (fp == nullptr) { - HiLog::Error(LABEL_TEST, "open file failed, real path=%{public}s.", realPath.c_str()); + IMAGE_LOGE("open file failed, real path=%{public}s.", realPath.c_str()); return false; } fseek(fp, 0, SEEK_END); size_t fileSize = ftell(fp); fseek(fp, 0, SEEK_SET); if (bufferSize < fileSize) { - HiLog::Error(LABEL_TEST, "buffer size:(%{public}zu) is smaller than file size:(%{public}zu).", bufferSize, - fileSize); + IMAGE_LOGE("buffer size:(%{public}zu) is smaller than file size:(%{public}zu).", bufferSize, fileSize); fclose(fp); return false; } size_t retSize = fread(buffer, 1, fileSize, fp); if (retSize != fileSize) { - HiLog::Error(LABEL_TEST, "read file result size = %{public}zu, size = %{public}zu.", retSize, fileSize); + IMAGE_LOGE("read file result size = %{public}zu, size = %{public}zu.", retSize, fileSize); fclose(fp); return false; } diff --git a/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_wbmp_test.cpp b/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_wbmp_test.cpp index cac3a33ac..fab801570 100644 --- a/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_wbmp_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_wbmp_test.cpp @@ -16,7 +16,6 @@ #include #include #include "directory_ex.h" -#include "hilog/log.h" #include "image_packer.h" #include "image_source.h" #include "image_source_util.h" @@ -27,7 +26,6 @@ using namespace testing::ext; using namespace OHOS::Media; -using namespace OHOS::HiviewDFX; namespace OHOS { namespace Multimedia { diff --git a/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_webp_test.cpp b/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_webp_test.cpp index a66aaae0d..f431e3e15 100644 --- a/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_webp_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_webp_test.cpp @@ -16,27 +16,28 @@ #include #include #include "directory_ex.h" -#include "hilog/log.h" +#include "image_log.h" #include "image_packer.h" #include "image_source.h" #include "image_source_util.h" #include "image_type.h" #include "image_utils.h" #include "incremental_pixel_map.h" -#include "log_tags.h" #include "media_errors.h" #include "pixel_map.h" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "ImageSourceWebpTest" + using namespace testing::ext; using namespace OHOS::Media; -using namespace OHOS::HiviewDFX; using namespace OHOS::ImageSourceUtil; namespace OHOS { namespace Multimedia { -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL_TEST = { - LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "ImageSourceWebpTest" -}; static constexpr uint32_t DEFAULT_DELAY_UTIME = 10000; // 10 ms. static const std::string IMAGE_INPUT_WEBP_PATH = "/data/local/tmp/image/test_large.webp"; static const std::string IMAGE_INPUT_HW_JPEG_PATH = "/data/local/tmp/image/test_hw.jpg"; @@ -530,7 +531,7 @@ HWTEST_F(ImageSourceWebpTest, WebpImageCrop001, TestSize.Level3) decodeOpts.desiredSize.height = 300; decodeOpts.rotateDegrees = 90; std::unique_ptr pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); - HiLog::Debug(LABEL_TEST, "create pixel map error code=%{public}u.", errorCode); + IMAGE_LOGD("create pixel map error code=%{public}u.", errorCode); ASSERT_EQ(errorCode, SUCCESS); ASSERT_NE(pixelMap.get(), nullptr); EXPECT_EQ(200, pixelMap->GetWidth()); diff --git a/frameworks/innerkitsimpl/test/unittest/jpeg_utils_test.cpp b/frameworks/innerkitsimpl/test/unittest/jpeg_utils_test.cpp index 02c97740f..47493bb01 100644 --- a/frameworks/innerkitsimpl/test/unittest/jpeg_utils_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/jpeg_utils_test.cpp @@ -19,7 +19,6 @@ #include "jpeg_decoder.h" using namespace testing::ext; -using namespace OHOS::HiviewDFX; namespace OHOS { namespace ImagePlugin { class JpegUtilsTest : public testing::Test { diff --git a/frameworks/innerkitsimpl/test/unittest/mock_directory_ex_test.cpp b/frameworks/innerkitsimpl/test/unittest/mock_directory_ex_test.cpp index f7a010077..0d218a5a8 100644 --- a/frameworks/innerkitsimpl/test/unittest/mock_directory_ex_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/mock_directory_ex_test.cpp @@ -18,13 +18,10 @@ #include #include #include -#include "hilog/log.h" -#include "log_tags.h" #include "unistd.h" #include "directory_ex.h" using namespace testing::ext; -using namespace OHOS::HiviewDFX; namespace OHOS { namespace Multimedia { class MockDirectoryExTest : public testing::Test { diff --git a/frameworks/innerkitsimpl/test/unittest/plugin_texture_encode_test.cpp b/frameworks/innerkitsimpl/test/unittest/plugin_texture_encode_test.cpp index db27e5525..9df2acf83 100644 --- a/frameworks/innerkitsimpl/test/unittest/plugin_texture_encode_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/plugin_texture_encode_test.cpp @@ -18,12 +18,10 @@ #include "astc_codec.h" #include "buffer_packer_stream.h" -#include "hilog/log.h" #include "image_compressor.h" #include "image_source_util.h" #include "image_system_properties.h" #include "image_utils.h" -#include "log_tags.h" #include "media_errors.h" using namespace testing::ext; diff --git a/frameworks/innerkitsimpl/test/unittest/png_test/nine_path_listener_test.cpp b/frameworks/innerkitsimpl/test/unittest/png_test/nine_path_listener_test.cpp index b66ce87c5..91e09beb6 100644 --- a/frameworks/innerkitsimpl/test/unittest/png_test/nine_path_listener_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/png_test/nine_path_listener_test.cpp @@ -16,14 +16,11 @@ #include #include #include -#include -#include "hilog/log.h" #include "securec.h" #include "memory.h" #include "nine_patch_listener.h" using namespace testing::ext; -using namespace OHOS::HiviewDFX; namespace OHOS { namespace Multimedia { class NinePathListenerTest : public testing::Test { diff --git a/frameworks/innerkitsimpl/test/unittest/post_proc_test.cpp b/frameworks/innerkitsimpl/test/unittest/post_proc_test.cpp index bb73e689a..f259db3a9 100644 --- a/frameworks/innerkitsimpl/test/unittest/post_proc_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/post_proc_test.cpp @@ -19,7 +19,6 @@ #include "image_source.h" #include "image_type.h" #include "image_utils.h" -#include "hilog/log.h" #include "media_errors.h" #include "pixel_map.h" #include "image_source_util.h" diff --git a/frameworks/innerkitsimpl/utils/include/image_log.h b/frameworks/innerkitsimpl/utils/include/image_log.h index d4f9790f8..118963c46 100644 --- a/frameworks/innerkitsimpl/utils/include/image_log.h +++ b/frameworks/innerkitsimpl/utils/include/image_log.h @@ -19,12 +19,16 @@ #include "hilog/log.h" #include "log_tags.h" -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "ImageCode" }; +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE -#define IMAGE_LOGF(...) (void)OHOS::HiviewDFX::HiLog::Fatal(LABEL, __VA_ARGS__) -#define IMAGE_LOGE(...) (void)OHOS::HiviewDFX::HiLog::Error(LABEL, __VA_ARGS__) -#define IMAGE_LOGW(...) (void)OHOS::HiviewDFX::HiLog::Warn(LABEL, __VA_ARGS__) -#define IMAGE_LOGI(...) (void)OHOS::HiviewDFX::HiLog::Info(LABEL, __VA_ARGS__) -#define IMAGE_LOGD(...) (void)OHOS::HiviewDFX::HiLog::Debug(LABEL, __VA_ARGS__) +#undef LOG_TAG +#define LOG_TAG "ImageCode" + +#define IMAGE_LOGF(...) HILOG_FATAL(LOG_CORE, __VA_ARGS__) +#define IMAGE_LOGE(...) HILOG_ERROR(LOG_CORE, __VA_ARGS__) +#define IMAGE_LOGW(...) HILOG_WARN(LOG_CORE, __VA_ARGS__) +#define IMAGE_LOGI(...) HILOG_INFO(LOG_CORE, __VA_ARGS__) +#define IMAGE_LOGD(...) HILOG_DEBUG(LOG_CORE, __VA_ARGS__) #endif // FRAMEWORKS_INNERKITSIMPL_UTILS_INCLUDE_IMAGE_LOG_H diff --git a/frameworks/innerkitsimpl/utils/src/image_utils.cpp b/frameworks/innerkitsimpl/utils/src/image_utils.cpp index 5e43d2d75..151a38ee2 100644 --- a/frameworks/innerkitsimpl/utils/src/image_utils.cpp +++ b/frameworks/innerkitsimpl/utils/src/image_utils.cpp @@ -26,8 +26,7 @@ #include #include "__config" -#include "hilog/log.h" -#include "log_tags.h" +#include "image_log.h" #include "ios" #include "istream" #include "media_errors.h" @@ -47,13 +46,17 @@ #include "refbase.h" #endif +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "imageUtils" + namespace OHOS { namespace Media { -using namespace OHOS::HiviewDFX; using namespace std; using namespace MultimediaPlugin; -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "imageUtils" }; constexpr int32_t ALPHA8_BYTES = 1; constexpr int32_t RGB565_BYTES = 2; constexpr int32_t RGB888_BYTES = 3; @@ -74,13 +77,13 @@ static const string FILE_DIR_IN_THE_SANDBOX = "/data/storage/el2/base/files/"; bool ImageUtils::GetFileSize(const string &pathName, size_t &size) { if (pathName.empty()) { - HiLog::Error(LABEL, "[ImageUtil]input parameter exception."); + IMAGE_LOGE("[ImageUtil]input parameter exception."); return false; } struct stat statbuf; int ret = stat(pathName.c_str(), &statbuf); if (ret != 0) { - HiLog::Error(LABEL, "[ImageUtil]get the file size failed, ret:%{public}d, errno:%{public}d.", ret, errno); + IMAGE_LOGE("[ImageUtil]get the file size failed, ret:%{public}d, errno:%{public}d.", ret, errno); return false; } size = statbuf.st_size; @@ -97,7 +100,7 @@ bool ImageUtils::GetFileSize(const int fd, size_t &size) int ret = fstat(fd, &statbuf); if (ret != 0) { - HiLog::Error(LABEL, "[ImageUtil]get the file size failed, ret:%{public}d, errno:%{public}d.", ret, errno); + IMAGE_LOGE("[ImageUtil]get the file size failed, ret:%{public}d, errno:%{public}d.", ret, errno); return false; } size = statbuf.st_size; @@ -107,7 +110,7 @@ bool ImageUtils::GetFileSize(const int fd, size_t &size) bool ImageUtils::GetInputStreamSize(istream &inputStream, size_t &size) { if (inputStream.rdbuf() == nullptr) { - HiLog::Error(LABEL, "[ImageUtil]input parameter exception."); + IMAGE_LOGE("[ImageUtil]input parameter exception."); return false; } size_t original = inputStream.tellg(); @@ -149,7 +152,7 @@ int32_t ImageUtils::GetPixelBytes(const PixelFormat &pixelFormat) pixelBytes = ASTC_4X4_BYTES; break; default: - HiLog::Error(LABEL, "[ImageUtil]get pixel bytes failed, pixelFormat:%{public}d.", + IMAGE_LOGE("[ImageUtil]get pixel bytes failed, pixelFormat:%{public}d.", static_cast(pixelFormat)); break; } @@ -170,10 +173,10 @@ uint32_t ImageUtils::RegisterPluginServer() PluginServer &pluginServer = DelayedRefSingleton::GetInstance(); uint32_t result = pluginServer.Register(std::move(pluginPaths)); if (result != SUCCESS) { - HiLog::Error(LABEL, "[ImageUtil]failed to register plugin server, ERRNO: %{public}u.", result); + IMAGE_LOGE("[ImageUtil]failed to register plugin server, ERRNO: %{public}u.", result); } else { g_pluginRegistered = true; - HiLog::Info(LABEL, "[ImageUtil]success to register plugin server"); + IMAGE_LOGI("[ImageUtil]success to register plugin server"); } return result; } @@ -183,7 +186,7 @@ PluginServer& ImageUtils::GetPluginServer() if (!g_pluginRegistered) { uint32_t result = RegisterPluginServer(); if (result != SUCCESS) { - HiLog::Info(LABEL, "[ImageUtil]failed to register plugin server, ERRNO: %{public}u.", result); + IMAGE_LOGI("[ImageUtil]failed to register plugin server, ERRNO: %{public}u.", result); } } return DelayedRefSingleton::GetInstance(); @@ -192,12 +195,12 @@ PluginServer& ImageUtils::GetPluginServer() bool ImageUtils::PathToRealPath(const string &path, string &realPath) { if (path.empty()) { - HiLog::Error(LABEL, "path is empty!"); + IMAGE_LOGE("path is empty!"); return false; } if ((path.length() >= PATH_MAX)) { - HiLog::Error(LABEL, "path len is error, the len is: [%{public}lu]", static_cast(path.length())); + IMAGE_LOGE("path len is error, the len is: [%{public}lu]", static_cast(path.length())); return false; } @@ -205,11 +208,11 @@ bool ImageUtils::PathToRealPath(const string &path, string &realPath) #ifdef _WIN32 if (_fullpath(tmpPath, path.c_str(), path.length()) == nullptr) { - HiLog::Warn(LABEL, "path to _fullpath error"); + IMAGE_LOGW("path to _fullpath error"); } #else if (realpath(path.c_str(), tmpPath) == nullptr) { - HiLog::Error(LABEL, "path to realpath is nullptr"); + IMAGE_LOGE("path to realpath is nullptr"); return false; } #endif @@ -249,7 +252,7 @@ AlphaType ImageUtils::GetValidAlphaTypeByFormat(const AlphaType &dstType, const case PixelFormat::NV12: case PixelFormat::CMYK: default: { - HiLog::Error(LABEL, "GetValidAlphaTypeByFormat unsupport the format(%{public}d).", format); + IMAGE_LOGE("GetValidAlphaTypeByFormat unsupport the format(%{public}d).", format); return AlphaType::IMAGE_ALPHA_TYPE_UNKNOWN; } } @@ -260,11 +263,11 @@ bool ImageUtils::IsValidImageInfo(const ImageInfo &info) { if (info.size.width <= 0 || info.size.height <= 0 || info.size.width > MAX_DIMENSION || info.size.height > MAX_DIMENSION) { - HiLog::Error(LABEL, "width(%{public}d) or height(%{public}d) is invalid.", info.size.width, info.size.height); + IMAGE_LOGE("width(%{public}d) or height(%{public}d) is invalid.", info.size.width, info.size.height); return false; } if (info.pixelFormat == PixelFormat::UNKNOWN || info.alphaType == AlphaType::IMAGE_ALPHA_TYPE_UNKNOWN) { - HiLog::Error(LABEL, "check pixelformat and alphatype is invalid."); + IMAGE_LOGE("check pixelformat and alphatype is invalid."); return false; } return true; @@ -273,12 +276,12 @@ bool ImageUtils::IsValidImageInfo(const ImageInfo &info) bool ImageUtils::CheckMulOverflow(int32_t width, int32_t bytesPerPixel) { if (width == 0 || bytesPerPixel == 0) { - HiLog::Error(LABEL, "param is 0"); + IMAGE_LOGE("param is 0"); return true; } int64_t rowSize = static_cast(width) * bytesPerPixel; if ((rowSize / width) != bytesPerPixel) { - HiLog::Error(LABEL, "width * bytesPerPixel overflow!"); + IMAGE_LOGE("width * bytesPerPixel overflow!"); return true; } return false; @@ -287,17 +290,17 @@ bool ImageUtils::CheckMulOverflow(int32_t width, int32_t bytesPerPixel) bool ImageUtils::CheckMulOverflow(int32_t width, int32_t height, int32_t bytesPerPixel) { if (width == 0 || height == 0 || bytesPerPixel == 0) { - HiLog::Error(LABEL, "param is 0"); + IMAGE_LOGE("param is 0"); return true; } int64_t rectSize = static_cast(width) * height; if ((rectSize / width) != height) { - HiLog::Error(LABEL, "width * height overflow!"); + IMAGE_LOGE("width * height overflow!"); return true; } int64_t bufferSize = rectSize * bytesPerPixel; if ((bufferSize / bytesPerPixel) != rectSize) { - HiLog::Error(LABEL, "bytesPerPixel overflow!"); + IMAGE_LOGE("bytesPerPixel overflow!"); return true; } return false; @@ -306,7 +309,7 @@ bool ImageUtils::CheckMulOverflow(int32_t width, int32_t height, int32_t bytesPe static void ReversePixels(uint8_t* srcPixels, uint8_t* dstPixels, uint32_t byteCount) { if (byteCount % NUM_4 != NUM_0) { - HiLog::Error(LABEL, "Pixel count must multiple of 4."); + IMAGE_LOGE("Pixel count must multiple of 4."); return; } uint8_t *src = srcPixels; @@ -336,7 +339,7 @@ void ImageUtils::ARGBToBGRA(uint8_t* srcPixels, uint8_t* dstPixels, uint32_t byt int32_t ImageUtils::SurfaceBuffer_Reference(void* buffer) { if (buffer == nullptr) { - HiLog::Error(LABEL, "parameter error, please check input parameter"); + IMAGE_LOGE("parameter error, please check input parameter"); return ERR_SURFACEBUFFER_REFERENCE_FAILED; } OHOS::RefBase *ref = reinterpret_cast(buffer); @@ -347,7 +350,7 @@ int32_t ImageUtils::SurfaceBuffer_Reference(void* buffer) int32_t ImageUtils::SurfaceBuffer_Unreference(void* buffer) { if (buffer == nullptr) { - HiLog::Error(LABEL, "parameter error, please check input parameter"); + IMAGE_LOGE("parameter error, please check input parameter"); return ERR_SURFACEBUFFER_UNREFERENCE_FAILED; } OHOS::RefBase *ref = reinterpret_cast(buffer); @@ -361,19 +364,19 @@ void ImageUtils::DumpPixelMapIfDumpEnabled(std::unique_ptr& pixelMap, return; } if (pixelMap == nullptr) { - HiLog::Info(LABEL, "ImageUtils::DumpPixelMapIfDumpEnabled pixelMap is null"); + IMAGE_LOGI("ImageUtils::DumpPixelMapIfDumpEnabled pixelMap is null"); return; } - HiLog::Info(LABEL, "ImageUtils::DumpPixelMapIfDumpEnabled start"); + IMAGE_LOGI("ImageUtils::DumpPixelMapIfDumpEnabled start"); std::string fileName = FILE_DIR_IN_THE_SANDBOX + GetLocalTime() + "_imageId" + std::to_string(imageId) + GetPixelMapName(pixelMap.get()) + ".dat"; int32_t totalSize = pixelMap->GetRowStride() * pixelMap->GetHeight(); if (SUCCESS != SaveDataToFile(fileName, reinterpret_cast(pixelMap->GetPixels()), totalSize)) { - HiLog::Info(LABEL, "ImageUtils::DumpPixelMapIfDumpEnabled failed"); + IMAGE_LOGI("ImageUtils::DumpPixelMapIfDumpEnabled failed"); return; } - HiLog::Info(LABEL, "ImageUtils::DumpPixelMapIfDumpEnabled success, path = %{public}s", fileName.c_str()); + IMAGE_LOGI("ImageUtils::DumpPixelMapIfDumpEnabled success, path = %{public}s", fileName.c_str()); } void ImageUtils::DumpPixelMapBeforeEncode(PixelMap& pixelMap) @@ -381,15 +384,15 @@ void ImageUtils::DumpPixelMapBeforeEncode(PixelMap& pixelMap) if (!ImageSystemProperties::GetDumpImageEnabled()) { return; } - HiLog::Info(LABEL, "ImageUtils::DumpPixelMapBeforeEncode start"); + IMAGE_LOGI("ImageUtils::DumpPixelMapBeforeEncode start"); std::string fileName = FILE_DIR_IN_THE_SANDBOX + GetLocalTime() + "_beforeEncode" + GetPixelMapName(&pixelMap) + ".dat"; int32_t totalSize = pixelMap.GetRowStride() * pixelMap.GetHeight(); if (SUCCESS != SaveDataToFile(fileName, reinterpret_cast(pixelMap.GetPixels()), totalSize)) { - HiLog::Info(LABEL, "ImageUtils::DumpPixelMapBeforeEncode failed"); + IMAGE_LOGI("ImageUtils::DumpPixelMapBeforeEncode failed"); return; } - HiLog::Info(LABEL, "ImageUtils::DumpPixelMapBeforeEncode success, path = %{public}s", fileName.c_str()); + IMAGE_LOGI("ImageUtils::DumpPixelMapBeforeEncode success, path = %{public}s", fileName.c_str()); } void ImageUtils::DumpDataIfDumpEnabled(const char* data, const size_t& totalSize, @@ -401,17 +404,17 @@ void ImageUtils::DumpDataIfDumpEnabled(const char* data, const size_t& totalSize std::string fileName = FILE_DIR_IN_THE_SANDBOX + GetLocalTime() + "_imageId" + std::to_string(imageId) + "_data_total" + std::to_string(totalSize) + "." + fileSuffix; if (SUCCESS != SaveDataToFile(fileName, data, totalSize)) { - HiLog::Info(LABEL, "ImageUtils::DumpDataIfDumpEnabled failed"); + IMAGE_LOGI("ImageUtils::DumpDataIfDumpEnabled failed"); return; } - HiLog::Info(LABEL, "ImageUtils::DumpDataIfDumpEnabled success, path = %{public}s", fileName.c_str()); + IMAGE_LOGI("ImageUtils::DumpDataIfDumpEnabled success, path = %{public}s", fileName.c_str()); } uint32_t ImageUtils::SaveDataToFile(const std::string& fileName, const char* data, const size_t& totalSize) { std::ofstream outFile(fileName, std::ofstream::out); if (!outFile.is_open()) { - HiLog::Info(LABEL, "ImageUtils::SaveDataToFile write error, path=%{public}s", fileName.c_str()); + IMAGE_LOGI("ImageUtils::SaveDataToFile write error, path=%{public}s", fileName.c_str()); return IMAGE_RESULT_SAVE_DATA_TO_FILE_FAILED; } outFile.write(data, totalSize); @@ -435,7 +438,7 @@ std::string ImageUtils::GetLocalTime() std::string ImageUtils::GetPixelMapName(PixelMap* pixelMap) { if (!pixelMap) { - HiLog::Error(LABEL, "ImageUtils::GetPixelMapName error, pixelMap is null"); + IMAGE_LOGE("ImageUtils::GetPixelMapName error, pixelMap is null"); return ""; } std::string pixelMapStr = "_pixelMap_w" + std::to_string(pixelMap->GetWidth()) + diff --git a/frameworks/kits/js/common/image_creator_napi.cpp b/frameworks/kits/js/common/image_creator_napi.cpp index e87aa951d..8d0b8d5c3 100644 --- a/frameworks/kits/js/common/image_creator_napi.cpp +++ b/frameworks/kits/js/common/image_creator_napi.cpp @@ -16,14 +16,12 @@ #include "image_creator_napi.h" #include #include "media_errors.h" -#include "hilog/log.h" +#include "image_log.h" #include "image_napi_utils.h" #include "image_creator_context.h" #include "image_napi.h" #include "image_creator_manager.h" -#include "log_tags.h" -using OHOS::HiviewDFX::HiLog; using std::string; using std::shared_ptr; using std::unique_ptr; @@ -31,8 +29,13 @@ using std::vector; using std::make_shared; using std::make_unique; +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "ImageCreatorNapi" + namespace { - constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "ImageCreatorNapi"}; constexpr int32_t TEST_WIDTH = 8192; constexpr int32_t TEST_HEIGHT = 8; constexpr int32_t TEST_FORMAT = 4; @@ -161,7 +164,7 @@ napi_value ImageCreatorNapi::Init(napi_env env, napi_value exports) IMAGE_ERR("define properties fail") ); - HiLog::Debug(LABEL, "Init success"); + IMAGE_DEBUG("Init success"); IMAGE_FUNCTION_OUT(); return exports; diff --git a/frameworks/kits/js/common/image_napi.cpp b/frameworks/kits/js/common/image_napi.cpp index 57a90712b..9056cf8bc 100644 --- a/frameworks/kits/js/common/image_napi.cpp +++ b/frameworks/kits/js/common/image_napi.cpp @@ -16,14 +16,18 @@ #include "image_napi.h" #include "napi/native_node_api.h" -#include "hilog/log.h" +#include "image_log.h" #include "media_errors.h" #include "image_format.h" #include "image_napi_utils.h" -#include "log_tags.h" + +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "ImageNapi" namespace { - constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "ImageNapi"}; constexpr int NUM0 = 0; constexpr int NUM1 = 1; constexpr int NUM2 = 2; @@ -32,7 +36,6 @@ namespace { namespace OHOS { namespace Media { -using OHOS::HiviewDFX::HiLog; struct ImageAsyncContext { napi_env env = nullptr; napi_async_work work = nullptr; @@ -560,7 +563,7 @@ static bool BuildJsComponentObject(napi_env env, int32_t type, uint8_t* buffer, static void TestGetComponentCallBack(napi_env env, napi_status status, ImageAsyncContext* context) { if (context == nullptr) { - HiLog::Error(LABEL, "Invalid input context"); + IMAGE_ERR("Invalid input context"); return; } napi_value result; @@ -590,13 +593,13 @@ static void JsGetComponentCallBack(napi_env env, napi_status status, ImageAsyncC } if (context == nullptr) { - HiLog::Error(LABEL, "Invalid input context"); + IMAGE_ERR("Invalid input context"); return; } context->status = ERROR; NativeComponent* component = context->component; if (component == nullptr) { - HiLog::Error(LABEL, "Invalid component"); + IMAGE_ERR("Invalid component"); CommonCallbackRoutine(env, context, result); return; } @@ -609,7 +612,7 @@ static void JsGetComponentCallBack(napi_env env, napi_status status, ImageAsyncC } if (buffer == nullptr || component->size == NUM0) { - HiLog::Error(LABEL, "Invalid buffer"); + IMAGE_ERR("Invalid buffer"); CommonCallbackRoutine(env, context, result); return; } @@ -617,7 +620,7 @@ static void JsGetComponentCallBack(napi_env env, napi_status status, ImageAsyncC if (BuildJsComponentObject(env, context->componentType, buffer, component, &result)) { context->status = SUCCESS; } else { - HiLog::Error(LABEL, "napi_create_arraybuffer failed!"); + IMAGE_ERR("napi_create_arraybuffer failed!"); } IMAGE_FUNCTION_OUT(); @@ -626,13 +629,13 @@ static void JsGetComponentCallBack(napi_env env, napi_status status, ImageAsyncC static void JsGetComponentExec(napi_env env, ImageAsyncContext* context) { if (context == nullptr || context->napi == nullptr) { - HiLog::Error(LABEL, "Invalid input context"); + IMAGE_ERR("Invalid input context"); return; } auto native = context->napi->GetNative(); if (native == nullptr) { - HiLog::Error(LABEL, "Empty native"); + IMAGE_ERR("Empty native"); return; } context->component = native->GetComponent(context->componentType); diff --git a/frameworks/kits/js/common/image_packer_mdk_kits.cpp b/frameworks/kits/js/common/image_packer_mdk_kits.cpp index db9c85254..ecfa0c798 100644 --- a/frameworks/kits/js/common/image_packer_mdk_kits.cpp +++ b/frameworks/kits/js/common/image_packer_mdk_kits.cpp @@ -16,18 +16,21 @@ #include "image_packer_mdk_kits.h" #include -#include "hilog/log.h" -#include "log_tags.h" +#include "image_log.h" + +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "ImagePackerMdk" namespace { - constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "ImagePackerMdk"}; constexpr size_t SIZE_ZERO = 0; constexpr int INVALID_FD = -1; } namespace OHOS { namespace Media { -using OHOS::HiviewDFX::HiLog; using ImagePackerNativeFunc = int32_t (*)(struct ImagePackerArgs* args); enum class PackingSourceType : int32_t { @@ -44,7 +47,7 @@ static bool IsInstanceOf(napi_env env, napi_value value, napi_value global, cons { napi_value constructor = nullptr; if (napi_get_named_property(env, global, type, &constructor) != napi_ok) { - HiLog::Error(LABEL, "Get constructor property failed!"); + IMAGE_LOGE("Get constructor property failed!"); return false; } @@ -59,34 +62,34 @@ static PackingSourceType ParserPackingArgumentType(napi_env env, napi_value sour { napi_value global = nullptr; if (napi_get_global(env, &global) != napi_ok) { - HiLog::Error(LABEL, "Get global property failed!"); + IMAGE_LOGE("Get global property failed!"); return PackingSourceType::TYPE_INVALID; } if (IsInstanceOf(env, source, global, "ImageSource")) { - HiLog::Debug(LABEL, "This is ImageSource!"); + IMAGE_LOGD("This is ImageSource!"); return PackingSourceType::TYPE_IMAGE_SOURCE; } else if (IsInstanceOf(env, source, global, "PixelMap")) { - HiLog::Debug(LABEL, "This is PixelMap!"); + IMAGE_LOGD("This is PixelMap!"); return PackingSourceType::TYPE_PIXEL_MAP; } - HiLog::Error(LABEL, "Invalid type!"); + IMAGE_LOGE("Invalid type!"); return PackingSourceType::TYPE_INVALID; } static int32_t ImagePackerNapiCreate(struct ImagePackerArgs* args) { if (args == nullptr || args->inEnv == nullptr || args->outVal == nullptr) { - HiLog::Error(LABEL, "ImagePackerNapiCreate bad parameter"); + IMAGE_LOGE("ImagePackerNapiCreate bad parameter"); return IMAGE_RESULT_BAD_PARAMETER; } *(args->outVal) = ImagePackerNapi::CreateImagePacker(args->inEnv, nullptr); if (*(args->outVal) == nullptr) { - HiLog::Error(LABEL, "ImageSourceNapiCreate native create failed"); + IMAGE_LOGE("ImageSourceNapiCreate native create failed"); return IMAGE_RESULT_BAD_PARAMETER; } - HiLog::Debug(LABEL, "ImagePackerNapiCreate success"); + IMAGE_LOGD("ImagePackerNapiCreate success"); return IMAGE_RESULT_SUCCESS; } @@ -114,7 +117,7 @@ static int32_t DoStartPacking(std::shared_ptr &packer, struct Image } else if (args->inNum0 > INVALID_FD) { return packer->StartPacking(args->inNum0, option); } - HiLog::Error(LABEL, "DoNativePacking StartPacking failed"); + IMAGE_LOGE("DoNativePacking StartPacking failed"); return IMAGE_RESULT_BAD_PARAMETER; } @@ -130,7 +133,7 @@ static int32_t DoAddImage(std::shared_ptr &packer, if (image != nullptr) { return packer->AddImage(*image); } else { - HiLog::Error(LABEL, "DoNativePacking get image source native failed"); + IMAGE_LOGE("DoNativePacking get image source native failed"); return IMAGE_RESULT_BAD_PARAMETER; } } else if (type == PackingSourceType::TYPE_PIXEL_MAP) { @@ -138,11 +141,11 @@ static int32_t DoAddImage(std::shared_ptr &packer, if (pixel != nullptr) { return packer->AddImage(*pixel); } else { - HiLog::Error(LABEL, "DoNativePacking get pixelmap native failed"); + IMAGE_LOGE("DoNativePacking get pixelmap native failed"); return IMAGE_RESULT_BAD_PARAMETER; } } - HiLog::Error(LABEL, "DoNativePacking unsupport packing source type %{public}d", type); + IMAGE_LOGE("DoNativePacking unsupport packing source type %{public}d", type); return IMAGE_RESULT_BAD_PARAMETER; } @@ -158,17 +161,17 @@ static int32_t DoNativePacking(struct ImagePackerArgs* args) } auto nativeImagePacker = ImagePackerNapi::GetNative(args->inNapi); if (nativeImagePacker == nullptr) { - HiLog::Error(LABEL, "DoNativePacking get native failed"); + IMAGE_LOGE("DoNativePacking get native failed"); return IMAGE_RESULT_BAD_PARAMETER; } int32_t res = DoStartPacking(nativeImagePacker, args); if (res != IMAGE_RESULT_SUCCESS) { - HiLog::Error(LABEL, "DoNativePacking StartPacking failed"); + IMAGE_LOGE("DoNativePacking StartPacking failed"); return res; } res = DoAddImage(nativeImagePacker, type, args); if (res != IMAGE_RESULT_SUCCESS) { - HiLog::Error(LABEL, "DoNativePacking AddImage failed"); + IMAGE_LOGE("DoNativePacking AddImage failed"); return res; } int64_t packedSize = SIZE_ZERO; @@ -184,7 +187,7 @@ static int32_t ImagePackerNapiPackToData(struct ImagePackerArgs* args) args->inNapi == nullptr || args->inVal == nullptr || args->inOpts == nullptr || args->outData == nullptr || args->dataSize == nullptr || *(args->dataSize) == SIZE_ZERO) { - HiLog::Error(LABEL, "ImagePackerNapiPackToData bad parameter"); + IMAGE_LOGE("ImagePackerNapiPackToData bad parameter"); return IMAGE_RESULT_BAD_PARAMETER; } return DoNativePacking(args); @@ -195,7 +198,7 @@ static int32_t ImagePackerNapiPackToFile(struct ImagePackerArgs* args) if (args == nullptr || args->inEnv == nullptr || args->inNapi == nullptr || args->inVal == nullptr || args->inOpts == nullptr || args->inNum0 <= INVALID_FD) { - HiLog::Error(LABEL, "ImagePackerNapiPackToFile bad parameter"); + IMAGE_LOGE("ImagePackerNapiPackToFile bad parameter"); return IMAGE_RESULT_BAD_PARAMETER; } return DoNativePacking(args); diff --git a/frameworks/kits/js/common/image_packer_napi.cpp b/frameworks/kits/js/common/image_packer_napi.cpp index aa3ca905e..d1a84bfe5 100644 --- a/frameworks/kits/js/common/image_packer_napi.cpp +++ b/frameworks/kits/js/common/image_packer_napi.cpp @@ -14,20 +14,23 @@ */ #include "image_packer_napi.h" -#include "hilog/log.h" -#include "media_errors.h" + +#include "image_log.h" #include "image_napi_utils.h" #include "image_packer.h" #include "image_source.h" #include "image_source_napi.h" -#include "pixel_map_napi.h" #include "image_trace.h" -#include "hitrace_meter.h" -#include "log_tags.h" +#include "media_errors.h" +#include "pixel_map_napi.h" + +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "ImagePackerNapi" -using OHOS::HiviewDFX::HiLog; namespace { - constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "ImagePackerNapi"}; constexpr uint32_t NUM_0 = 0; constexpr uint32_t NUM_1 = 1; constexpr uint32_t NUM_2 = 2; @@ -113,7 +116,7 @@ static void ImagePackerErrorToNapiError(napi_env env, ImagePackerAsyncContext *c auto msg = (ctx->error.msg.empty()) ? "Internal error" : ctx->error.msg; if (!ctx->error.hasErrorCode) { if (napi_create_string_utf8(env, msg.c_str(), NAPI_AUTO_LENGTH, &out) != napi_ok) { - HiLog::Error(LABEL, "Create error msg only error"); + IMAGE_LOGE("Create error msg only error"); } return; } @@ -122,17 +125,17 @@ static void ImagePackerErrorToNapiError(napi_env env, ImagePackerAsyncContext *c napi_value message; napi_value code; if (napi_create_object(env, &out) != napi_ok) { - HiLog::Error(LABEL, "Create error object error"); + IMAGE_LOGE("Create error object error"); return; } if (napi_create_int32(env, errorCode, &code) != napi_ok || napi_set_named_property(env, out, "code", code) != napi_ok) { - HiLog::Error(LABEL, "Create error code error"); + IMAGE_LOGE("Create error code error"); return; } if (napi_create_string_utf8(env, msg.c_str(), NAPI_AUTO_LENGTH, &message) != napi_ok || napi_set_named_property(env, out, "message", message) != napi_ok) { - HiLog::Error(LABEL, "Create error msg error"); + IMAGE_LOGE("Create error msg error"); return; } } @@ -175,7 +178,7 @@ static void BuildMsgOnError(ImagePackerAsyncContext* ctx, bool assertion, const if (ctx == nullptr || assertion) { return; } - HiLog::Error(LABEL, "%{public}s", msg.c_str()); + IMAGE_LOGE("%{public}s", msg.c_str()); ctx->error.hasErrorCode = false; ctx->error.msg = msg; } @@ -186,7 +189,7 @@ static void BuildMsgOnError(ImagePackerAsyncContext* ctx, bool assertion, if (ctx == nullptr || assertion) { return; } - HiLog::Error(LABEL, "%{public}s", msg.c_str()); + IMAGE_LOGE("%{public}s", msg.c_str()); ctx->error.hasErrorCode = true; ctx->error.errorCode = errorCode; ctx->error.msg = msg; @@ -196,7 +199,7 @@ STATIC_EXEC_FUNC(Packing) { int64_t packedSize = 0; auto context = static_cast(data); - HiLog::Info(LABEL, "ImagePacker BufferSize %{public}" PRId64, context->resultBufferSize); + IMAGE_LOGI("ImagePacker BufferSize %{public}" PRId64, context->resultBufferSize); context->resultBuffer = std::make_unique( (context->resultBufferSize <= 0)?DEFAULT_BUFFER_SIZE:context->resultBufferSize); if (context->resultBuffer == nullptr) { @@ -206,14 +209,14 @@ STATIC_EXEC_FUNC(Packing) context->rImagePacker->StartPacking(context->resultBuffer.get(), context->resultBufferSize, context->packOption); if (context->packType == TYPE_IMAGE_SOURCE) { - HiLog::Info(LABEL, "ImagePacker set image source"); + IMAGE_LOGI("ImagePacker set image source"); if (context->rImageSource == nullptr) { BuildMsgOnError(context, context->rImageSource == nullptr, "ImageSource is nullptr"); return; } context->rImagePacker->AddImage(*(context->rImageSource)); } else { - HiLog::Info(LABEL, "ImagePacker set pixelmap"); + IMAGE_LOGI("ImagePacker set pixelmap"); if (context->rPixelMap == nullptr) { BuildMsgOnError(context, context->rImageSource == nullptr, "Pixelmap is nullptr"); return; @@ -221,13 +224,13 @@ STATIC_EXEC_FUNC(Packing) context->rImagePacker->AddImage(*(context->rPixelMap)); } context->rImagePacker->FinalizePacking(packedSize); - HiLog::Debug(LABEL, "packedSize=%{public}" PRId64, packedSize); + IMAGE_LOGD("packedSize=%{public}" PRId64, packedSize); if (packedSize > 0 && (packedSize < context->resultBufferSize)) { context->packedSize = packedSize; context->status = SUCCESS; } else { context->status = ERROR; - HiLog::Error(LABEL, "Packing failed, packedSize outside size."); + IMAGE_LOGE("Packing failed, packedSize outside size."); } } @@ -249,7 +252,7 @@ STATIC_COMPLETE_FUNC(Packing) if (!ImageNapiUtils::CreateArrayBuffer(env, context->resultBuffer.get(), context->packedSize, &result)) { context->status = ERROR; - HiLog::Error(LABEL, "napi_create_arraybuffer failed!"); + IMAGE_LOGE("napi_create_arraybuffer failed!"); napi_get_undefined(env, &result); } else { context->status = SUCCESS; @@ -277,27 +280,27 @@ napi_value ImagePackerNapi::Init(napi_env env, napi_value exports) IMG_NAPI_CHECK_RET_D(IMG_IS_OK( napi_define_class(env, CLASS_NAME_IMAGEPACKER.c_str(), NAPI_AUTO_LENGTH, Constructor, nullptr, IMG_ARRAY_SIZE(props), props, &constructor)), nullptr, - HiLog::Error(LABEL, "define class fail") + IMAGE_LOGE("define class fail") ); IMG_NAPI_CHECK_RET_D(IMG_IS_OK( napi_create_reference(env, constructor, 1, &sConstructor_)), nullptr, - HiLog::Error(LABEL, "create reference fail") + IMAGE_LOGE("create reference fail") ); IMG_NAPI_CHECK_RET_D(IMG_IS_OK( napi_set_named_property(env, exports, CLASS_NAME_IMAGEPACKER.c_str(), constructor)), nullptr, - HiLog::Error(LABEL, "set named property fail") + IMAGE_LOGE("set named property fail") ); IMG_NAPI_CHECK_RET_D(IMG_IS_OK( napi_define_properties(env, exports, IMG_ARRAY_SIZE(static_prop), static_prop)), nullptr, - HiLog::Error(LABEL, "define properties fail") + IMAGE_LOGE("define properties fail") ); - HiLog::Debug(LABEL, "Init success"); + IMAGE_LOGD("Init success"); return exports; } @@ -321,7 +324,7 @@ napi_value ImagePackerNapi::Constructor(napi_env env, napi_callback_info info) pImgPackerNapi.release(); return thisVar; } else { - HiLog::Error(LABEL, "Failure wrapping js to native napi"); + IMAGE_LOGE("Failure wrapping js to native napi"); } } } @@ -344,7 +347,7 @@ napi_value ImagePackerNapi::CreateImagePacker(napi_env env, napi_callback_info i if (status == napi_ok) { return result; } else { - HiLog::Error(LABEL, "New instance could not be obtained"); + IMAGE_LOGE("New instance could not be obtained"); } } return result; @@ -359,11 +362,11 @@ static int64_t parseBufferSize(napi_env env, napi_value root) napi_value tempValue = nullptr; int64_t tmpNumber = DEFAULT_BUFFER_SIZE; if (napi_get_named_property(env, root, "bufferSize", &tempValue) != napi_ok) { - HiLog::Info(LABEL, "No bufferSize, Using default"); + IMAGE_LOGI("No bufferSize, Using default"); return tmpNumber; } napi_get_value_int64(env, tempValue, &tmpNumber); - HiLog::Info(LABEL, "BufferSize is %{public}" PRId64, tmpNumber); + IMAGE_LOGI("BufferSize is %{public}" PRId64, tmpNumber); if (tmpNumber < 0) { return DEFAULT_BUFFER_SIZE; } @@ -374,11 +377,11 @@ static bool parsePackOptionOfQuality(napi_env env, napi_value root, PackOption* { uint32_t tmpNumber = 0; if (!GET_UINT32_BY_NAME(root, "quality", tmpNumber)) { - HiLog::Error(LABEL, "No quality in pack option"); + IMAGE_LOGE("No quality in pack option"); return false; } if (tmpNumber > SIZE) { - HiLog::Error(LABEL, "Invalid quality"); + IMAGE_LOGE("Invalid quality"); opts->quality = BYTE_FULL; } else { opts->quality = static_cast(tmpNumber & 0xff); @@ -391,7 +394,7 @@ static bool parsePackOptions(napi_env env, napi_value root, PackOption* opts) napi_value tmpValue = nullptr; if (!GET_NODE_BY_NAME(root, "format", tmpValue)) { - HiLog::Error(LABEL, "No format in pack option"); + IMAGE_LOGE("No format in pack option"); return false; } @@ -399,39 +402,39 @@ static bool parsePackOptions(napi_env env, napi_value root, PackOption* opts) napi_is_array(env, tmpValue, &isFormatArray); auto formatType = ImageNapiUtils::getType(env, tmpValue); - HiLog::Debug(LABEL, "parsePackOptions format type %{public}d, is array %{public}d", + IMAGE_LOGD("parsePackOptions format type %{public}d, is array %{public}d", formatType, isFormatArray); char buffer[SIZE] = {0}; size_t res = 0; if (napi_string == formatType) { if (napi_get_value_string_utf8(env, tmpValue, buffer, SIZE, &res) != napi_ok) { - HiLog::Error(LABEL, "Parse pack option format failed"); + IMAGE_LOGE("Parse pack option format failed"); return false; } opts->format = std::string(buffer); } else if (isFormatArray) { uint32_t len = 0; if (napi_get_array_length(env, tmpValue, &len) != napi_ok) { - HiLog::Error(LABEL, "Parse pack napi_get_array_length failed"); + IMAGE_LOGE("Parse pack napi_get_array_length failed"); return false; } - HiLog::Debug(LABEL, "Parse pack array_length=%{public}u", len); + IMAGE_LOGD("Parse pack array_length=%{public}u", len); for (size_t i = 0; i < len; i++) { napi_value item; napi_get_element(env, tmpValue, i, &item); if (napi_get_value_string_utf8(env, item, buffer, SIZE, &res) != napi_ok) { - HiLog::Error(LABEL, "Parse format in item failed %{public}zu", i); + IMAGE_LOGE("Parse format in item failed %{public}zu", i); continue; } opts->format = std::string(buffer); - HiLog::Debug(LABEL, "format is %{public}s.", opts->format.c_str()); + IMAGE_LOGD("format is %{public}s.", opts->format.c_str()); } } else { - HiLog::Error(LABEL, "Invalid pack option format type"); + IMAGE_LOGE("Invalid pack option format type"); return false; } - HiLog::Debug(LABEL, "parsePackOptions format:[%{public}s]", opts->format.c_str()); + IMAGE_LOGD("parsePackOptions format:[%{public}s]", opts->format.c_str()); return parsePackOptionOfQuality(env, root, opts); } @@ -446,43 +449,43 @@ static int32_t ParserPackingArgumentType(napi_env env, napi_value argv) ret = napi_get_named_property(env, global, "ImageSource", &constructor); if (ret != napi_ok) { - HiLog::Error(LABEL, "Get ImageSourceNapi property failed!"); + IMAGE_LOGE("Get ImageSourceNapi property failed!"); } ret = napi_instanceof(env, argv, constructor, &isInstance); if (ret == napi_ok && isInstance) { - HiLog::Debug(LABEL, "This is ImageSourceNapi type!"); + IMAGE_LOGD("This is ImageSourceNapi type!"); return TYPE_IMAGE_SOURCE; } ret = napi_get_named_property(env, global, "PixelMap", &constructor); if (ret != napi_ok) { - HiLog::Error(LABEL, "Get PixelMapNapi property failed!"); + IMAGE_LOGE("Get PixelMapNapi property failed!"); } ret = napi_instanceof(env, argv, constructor, &isInstance); if (ret == napi_ok && isInstance) { - HiLog::Debug(LABEL, "This is PixelMapNapi type!"); + IMAGE_LOGD("This is PixelMapNapi type!"); return TYPE_PIXEL_MAP; } - HiLog::Error(LABEL, "Invalid type!"); + IMAGE_LOGE("Invalid type!"); return TYPE_IMAGE_SOURCE; } static std::shared_ptr GetImageSourceFromNapi(napi_env env, napi_value value) { if (env == nullptr || value == nullptr) { - HiLog::Error(LABEL, "GetImageSourceFromNapi input is null"); + IMAGE_LOGE("GetImageSourceFromNapi input is null"); } std::unique_ptr imageSourceNapi = std::make_unique(); napi_status status = napi_unwrap(env, value, reinterpret_cast(&imageSourceNapi)); if (!IMG_IS_OK(status)) { - HiLog::Error(LABEL, "GetImageSourceFromNapi napi unwrap failed"); + IMAGE_LOGE("GetImageSourceFromNapi napi unwrap failed"); return nullptr; } if (imageSourceNapi == nullptr) { - HiLog::Error(LABEL, "GetImageSourceFromNapi imageSourceNapi is nullptr"); + IMAGE_LOGE("GetImageSourceFromNapi imageSourceNapi is nullptr"); return nullptr; } return imageSourceNapi.release()->nativeImgSrc; @@ -548,7 +551,7 @@ napi_value ImagePackerNapi::Packing(napi_env env, napi_callback_info info) } IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), - nullptr, HiLog::Error(LABEL, "fail to create async work")); + nullptr, IMAGE_LOGE("fail to create async work")); return result; } @@ -563,18 +566,18 @@ napi_value ImagePackerNapi::GetSupportedFormats(napi_env env, napi_callback_info IMG_JS_ARGS(env, info, status, argCount, nullptr, thisVar); - IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), result, HiLog::Error(LABEL, "fail to napi_get_cb_info")); + IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), result, IMAGE_LOGE("fail to napi_get_cb_info")); std::unique_ptr context = std::make_unique(); status = napi_unwrap(env, thisVar, reinterpret_cast(&context->constructor_)); IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, context->constructor_), - nullptr, HiLog::Error(LABEL, "fail to unwrap context")); + nullptr, IMAGE_LOGE("fail to unwrap context")); std::set formats; uint32_t ret = context->constructor_->nativeImgPck->GetSupportedFormats(formats); IMG_NAPI_CHECK_RET_D((ret == SUCCESS), - nullptr, HiLog::Error(LABEL, "fail to get supported formats")); + nullptr, IMAGE_LOGE("fail to get supported formats")); napi_create_array(env, &result); size_t i = 0; @@ -613,15 +616,15 @@ napi_value ImagePackerNapi::Release(napi_env env, napi_callback_info info) size_t argCount = 1; IMG_JS_ARGS(env, info, status, argCount, argValue, thisVar); - HiLog::Debug(LABEL, "Release argCount is [%{public}zu]", argCount); - IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), result, HiLog::Error(LABEL, "fail to napi_get_cb_info")); + IMAGE_LOGD("Release argCount is [%{public}zu]", argCount); + IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), result, IMAGE_LOGE("fail to napi_get_cb_info")); std::unique_ptr context = std::make_unique(); status = napi_remove_wrap(env, thisVar, reinterpret_cast(&context->constructor_)); IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, context->constructor_), result, - HiLog::Error(LABEL, "fail to unwrap context")); - HiLog::Debug(LABEL, "Release argCount is [%{public}zu]", argCount); + IMAGE_LOGE("fail to unwrap context")); + IMAGE_LOGD("Release argCount is [%{public}zu]", argCount); if (argCount == 1 && ImageNapiUtils::getType(env, argValue[NUM_0]) == napi_function) { napi_create_reference(env, argValue[NUM_0], refCount, &context->callbackRef); } @@ -684,7 +687,7 @@ STATIC_EXEC_FUNC(PackToFile) return; } if (context->packType == TYPE_IMAGE_SOURCE) { - HiLog::Info(LABEL, "ImagePacker set image source"); + IMAGE_LOGI("ImagePacker set image source"); if (context->rImageSource == nullptr) { BuildMsgOnError(context, context->rImageSource == nullptr, "ImageSource is nullptr", ERR_IMAGE_INVALID_PARAMETER); @@ -692,7 +695,7 @@ STATIC_EXEC_FUNC(PackToFile) } context->rImagePacker->AddImage(*(context->rImageSource)); } else { - HiLog::Info(LABEL, "ImagePacker set pixelmap"); + IMAGE_LOGI("ImagePacker set pixelmap"); if (context->rPixelMap == nullptr) { BuildMsgOnError(context, context->rImageSource == nullptr, "Pixelmap is nullptr", ERR_IMAGE_INVALID_PARAMETER); @@ -701,14 +704,14 @@ STATIC_EXEC_FUNC(PackToFile) context->rImagePacker->AddImage(*(context->rPixelMap)); } auto packRes = context->rImagePacker->FinalizePacking(packedSize); - HiLog::Debug(LABEL, "packRes=%{public}d packedSize=%{public}" PRId64, packRes, packedSize); + IMAGE_LOGD("packRes=%{public}d packedSize=%{public}" PRId64, packRes, packedSize); if (packRes == SUCCESS && packedSize > 0) { context->packedSize = packedSize; context->status = SUCCESS; } else { context->status = ERROR; BuildMsgOnError(context, packRes == SUCCESS, "PackedSize outside size", packRes); - HiLog::Error(LABEL, "Packing failed, packedSize outside size."); + IMAGE_LOGE("Packing failed, packedSize outside size."); } } @@ -755,7 +758,7 @@ napi_value ImagePackerNapi::PackToFile(napi_env env, napi_callback_info info) } IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), - nullptr, HiLog::Error(LABEL, "fail to create async work")); + nullptr, IMAGE_LOGE("fail to create async work")); return result; } void ImagePackerNapi::release() diff --git a/frameworks/kits/js/common/image_receiver_napi.cpp b/frameworks/kits/js/common/image_receiver_napi.cpp index 14c86cbd6..14cda056e 100644 --- a/frameworks/kits/js/common/image_receiver_napi.cpp +++ b/frameworks/kits/js/common/image_receiver_napi.cpp @@ -16,14 +16,18 @@ #include "image_receiver_napi.h" #include #include "media_errors.h" -#include "hilog/log.h" +#include "image_log.h" #include "image_napi_utils.h" -#include "image_receiver_context.h" #include "image_napi.h" +#include "image_receiver_context.h" #include "image_receiver_manager.h" -#include "log_tags.h" -using OHOS::HiviewDFX::HiLog; +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "ImageReceiverNapi" + using std::string; using std::shared_ptr; using std::unique_ptr; @@ -31,10 +35,6 @@ using std::vector; using std::make_shared; using std::make_unique; -namespace { - constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "ImageReceiverNapi"}; -} - namespace OHOS { namespace Media { static const std::string CLASS_NAME = "ImageReceiver"; diff --git a/frameworks/kits/js/common/image_source_mdk_kits.cpp b/frameworks/kits/js/common/image_source_mdk_kits.cpp index e9ab82cc0..2ab630036 100644 --- a/frameworks/kits/js/common/image_source_mdk_kits.cpp +++ b/frameworks/kits/js/common/image_source_mdk_kits.cpp @@ -15,13 +15,17 @@ #include "image_source_mdk_kits.h" #include -#include "hilog/log.h" -#include "log_tags.h" +#include "image_log.h" #include "media_errors.h" #include "securec.h" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "ImageSourceMdk" + namespace { - constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "ImageSourceMdk"}; constexpr size_t SIZE_ZERO = 0; constexpr int32_t INVALID_FD = -1; constexpr uint32_t DEFAULT_INDEX = 0; @@ -31,7 +35,6 @@ namespace { namespace OHOS { namespace Media { -using OHOS::HiviewDFX::HiLog; using ImageSourceNapiFunc = int32_t (*)(struct ImageSourceArgs* args); #ifdef __cplusplus extern "C" { @@ -97,7 +100,7 @@ static ImageSourceNapi* UnwrapNativeObject(napi_env env, napi_value value) napi_valuetype valueType; napi_typeof(env, value, &valueType); if (valueType != napi_object) { - HiLog::Error(LABEL, "UnwrapNativeObject value not a object"); + IMAGE_LOGE("UnwrapNativeObject value not a object"); return nullptr; } std::unique_ptr napi = nullptr; @@ -105,7 +108,7 @@ static ImageSourceNapi* UnwrapNativeObject(napi_env env, napi_value value) if ((status == napi_ok) && napi != nullptr) { return napi.release(); } - HiLog::Error(LABEL, "UnwrapNativeObject unwrap error"); + IMAGE_LOGE("UnwrapNativeObject unwrap error"); return nullptr; } @@ -113,7 +116,7 @@ static int32_t ImageSourceNativeCreate(struct OhosImageSource* source, struct OhosImageSourceOps* ops, std::shared_ptr &result, ImageResource &resource) { if (source == nullptr) { - HiLog::Error(LABEL, "ImageSourceNativeCreate source nullptr"); + IMAGE_LOGE("ImageSourceNativeCreate source nullptr"); return IMAGE_RESULT_BAD_PARAMETER; } uint32_t errorCode = ERR_MEDIA_INVALID_VALUE; @@ -123,20 +126,20 @@ static int32_t ImageSourceNativeCreate(struct OhosImageSource* source, } std::unique_ptr nativeImageSource = nullptr; if (source->uri != nullptr && source->uriSize != SIZE_ZERO) { - HiLog::Debug(LABEL, "ImageSourceNativeCreate by path"); + IMAGE_LOGD("ImageSourceNativeCreate by path"); std::string url(source->uri, source->uriSize); - HiLog::Debug(LABEL, "ImageSourceNativeCreate by path %{public}s", url.c_str()); + IMAGE_LOGD("ImageSourceNativeCreate by path %{public}s", url.c_str()); auto path = UrlToPath(url); nativeImageSource = ImageSource::CreateImageSource(path, opts, errorCode); resource.type = ImageResourceType::IMAGE_RESOURCE_PATH; resource.path = path; } else if (source->fd != INVALID_FD) { - HiLog::Debug(LABEL, "ImageSourceNativeCreate by fd"); + IMAGE_LOGD("ImageSourceNativeCreate by fd"); nativeImageSource = ImageSource::CreateImageSource(source->fd, opts, errorCode); resource.type = ImageResourceType::IMAGE_RESOURCE_FD; resource.fd = source->fd; } else if (source->buffer != nullptr && source->bufferSize != SIZE_ZERO) { - HiLog::Debug(LABEL, "ImageSourceNativeCreate by buffer"); + IMAGE_LOGD("ImageSourceNativeCreate by buffer"); nativeImageSource = ImageSource::CreateImageSource(source->buffer, source->bufferSize, opts, errorCode); resource.type = ImageResourceType::IMAGE_RESOURCE_BUFFER; @@ -145,10 +148,10 @@ static int32_t ImageSourceNativeCreate(struct OhosImageSource* source, } if (nativeImageSource != nullptr) { result = std::move(nativeImageSource); - HiLog::Debug(LABEL, "ImageSourceNativeCreate success"); + IMAGE_LOGD("ImageSourceNativeCreate success"); return IMAGE_RESULT_SUCCESS; } - HiLog::Error(LABEL, "ImageSourceNativeCreate no match source"); + IMAGE_LOGE("ImageSourceNativeCreate no match source"); return IMAGE_RESULT_BAD_PARAMETER; } @@ -157,12 +160,12 @@ static int32_t ImageSourceCreateNapi(napi_env env, napi_value* res, std::shared_ptr incrementalPixelMap, ImageResource* resource) { if (ImageSourceNapi::CreateImageSourceNapi(env, res) != SUCCESS) { - HiLog::Error(LABEL, "ImageSourceCreateNapi napi create failed"); + IMAGE_LOGE("ImageSourceCreateNapi napi create failed"); return IMAGE_RESULT_BAD_PARAMETER; } auto napi = UnwrapNativeObject(env, *(res)); if (napi == nullptr) { - HiLog::Error(LABEL, "ImageSourceCreateNapi napi unwrap check failed"); + IMAGE_LOGE("ImageSourceCreateNapi napi unwrap check failed"); return IMAGE_RESULT_BAD_PARAMETER; } @@ -175,7 +178,7 @@ static int32_t ImageSourceCreateNapi(napi_env env, napi_value* res, if (resource != nullptr) { napi->SetImageResource(*resource); } - HiLog::Debug(LABEL, "ImageSourceCreateNapi success"); + IMAGE_LOGD("ImageSourceCreateNapi success"); return IMAGE_RESULT_SUCCESS; } @@ -188,15 +191,15 @@ static int32_t ImageSourceNapiCreate(struct ImageSourceArgs* args) ImageResource resource; ImageSourceNativeCreate(args->source, args->sourceOps, imageSource, resource); if (imageSource == nullptr) { - HiLog::Error(LABEL, "ImageSourceNapiCreate native create failed"); + IMAGE_LOGE("ImageSourceNapiCreate native create failed"); return IMAGE_RESULT_BAD_PARAMETER; } if (ImageSourceCreateNapi(args->inEnv, args->outVal, imageSource, nullptr, &resource) != SUCCESS) { - HiLog::Error(LABEL, "ImageSourceNapiCreate napi create failed"); + IMAGE_LOGE("ImageSourceNapiCreate napi create failed"); args->outVal = nullptr; return IMAGE_RESULT_BAD_PARAMETER; } - HiLog::Debug(LABEL, "ImageSourceNapiCreate success"); + IMAGE_LOGD("ImageSourceNapiCreate success"); return IMAGE_RESULT_SUCCESS; } @@ -209,12 +212,12 @@ static int32_t ImageSourceNapiCreateFromUri(struct ImageSourceArgs* args) if (args->sourceOps != nullptr) { ParseImageSourceOps(opts, args->sourceOps); } - HiLog::Debug(LABEL, "ImageSourceNapiCreateFromUri by path %{public}s", args->uri.c_str()); + IMAGE_LOGD("ImageSourceNapiCreateFromUri by path %{public}s", args->uri.c_str()); auto path = UrlToPath(args->uri); uint32_t errorCode = ERR_MEDIA_INVALID_VALUE; std::unique_ptr nativeImageSource = ImageSource::CreateImageSource(path, opts, errorCode); if (nativeImageSource == nullptr) { - HiLog::Debug(LABEL, "ImageSourceNapiCreateFromUri create failed:%{public}d", errorCode); + IMAGE_LOGD("ImageSourceNapiCreateFromUri create failed:%{public}d", errorCode); return IMAGE_RESULT_BAD_PARAMETER; } ImageResource resource; @@ -222,15 +225,15 @@ static int32_t ImageSourceNapiCreateFromUri(struct ImageSourceArgs* args) resource.path = path; std::shared_ptr imageSource = std::move(nativeImageSource); if (imageSource == nullptr) { - HiLog::Error(LABEL, "ImageSourceNapiCreateFromUri native create failed"); + IMAGE_LOGE("ImageSourceNapiCreateFromUri native create failed"); return IMAGE_RESULT_BAD_PARAMETER; } if (ImageSourceCreateNapi(args->inEnv, args->outVal, imageSource, nullptr, &resource) != SUCCESS) { - HiLog::Error(LABEL, "ImageSourceNapiCreateFromUri napi create failed"); + IMAGE_LOGE("ImageSourceNapiCreateFromUri napi create failed"); args->outVal = nullptr; return IMAGE_RESULT_BAD_PARAMETER; } - HiLog::Debug(LABEL, "ImageSourceNapiCreateFromUri success"); + IMAGE_LOGD("ImageSourceNapiCreateFromUri success"); return IMAGE_RESULT_SUCCESS; } @@ -243,11 +246,11 @@ static int32_t ImageSourceNapiCreateFromFd(struct ImageSourceArgs* args) if (args->sourceOps != nullptr) { ParseImageSourceOps(opts, args->sourceOps); } - HiLog::Debug(LABEL, "ImageSourceNapiCreateFromFd"); + IMAGE_LOGD("ImageSourceNapiCreateFromFd"); uint32_t errorCode = ERR_MEDIA_INVALID_VALUE; std::unique_ptr nativeImageSource = ImageSource::CreateImageSource(args->fd, opts, errorCode); if (nativeImageSource == nullptr) { - HiLog::Debug(LABEL, "ImageSourceNapiCreateFromFd create failed:%{public}d", errorCode); + IMAGE_LOGD("ImageSourceNapiCreateFromFd create failed:%{public}d", errorCode); return IMAGE_RESULT_BAD_PARAMETER; } ImageResource resource; @@ -255,15 +258,15 @@ static int32_t ImageSourceNapiCreateFromFd(struct ImageSourceArgs* args) resource.fd = args->fd; std::shared_ptr imageSource = std::move(nativeImageSource); if (imageSource == nullptr) { - HiLog::Error(LABEL, "ImageSourceNapiCreateFromFd native create failed"); + IMAGE_LOGE("ImageSourceNapiCreateFromFd native create failed"); return IMAGE_RESULT_BAD_PARAMETER; } if (ImageSourceCreateNapi(args->inEnv, args->outVal, imageSource, nullptr, &resource) != SUCCESS) { - HiLog::Error(LABEL, "ImageSourceNapiCreateFromFd napi create failed"); + IMAGE_LOGE("ImageSourceNapiCreateFromFd napi create failed"); args->outVal = nullptr; return IMAGE_RESULT_BAD_PARAMETER; } - HiLog::Debug(LABEL, "ImageSourceNapiCreateFromFd success"); + IMAGE_LOGD("ImageSourceNapiCreateFromFd success"); return IMAGE_RESULT_SUCCESS; } @@ -277,12 +280,12 @@ static int32_t ImageSourceNapiCreateFromData(struct ImageSourceArgs* args) if (args->sourceOps != nullptr) { ParseImageSourceOps(opts, args->sourceOps); } - HiLog::Debug(LABEL, "ImageSourceNapiCreateFromData"); + IMAGE_LOGD("ImageSourceNapiCreateFromData"); uint32_t errorCode = ERR_MEDIA_INVALID_VALUE; std::unique_ptr nativeImageSource = ImageSource::CreateImageSource( args->dataArray.data, args->dataArray.dataSize, opts, errorCode); if (nativeImageSource == nullptr) { - HiLog::Debug(LABEL, "ImageSourceNapiCreateFromData create failed:%{public}d", errorCode); + IMAGE_LOGD("ImageSourceNapiCreateFromData create failed:%{public}d", errorCode); return IMAGE_RESULT_BAD_PARAMETER; } ImageResource resource; @@ -291,15 +294,15 @@ static int32_t ImageSourceNapiCreateFromData(struct ImageSourceArgs* args) resource.bufferSize = args->dataArray.dataSize; std::shared_ptr imageSource = std::move(nativeImageSource); if (imageSource == nullptr) { - HiLog::Error(LABEL, "ImageSourceNapiCreateFromData native create failed"); + IMAGE_LOGE("ImageSourceNapiCreateFromData native create failed"); return IMAGE_RESULT_BAD_PARAMETER; } if (ImageSourceCreateNapi(args->inEnv, args->outVal, imageSource, nullptr, &resource) != SUCCESS) { - HiLog::Error(LABEL, "ImageSourceNapiCreateFromData napi create failed"); + IMAGE_LOGE("ImageSourceNapiCreateFromData napi create failed"); args->outVal = nullptr; return IMAGE_RESULT_BAD_PARAMETER; } - HiLog::Debug(LABEL, "ImageSourceNapiCreateFromData success"); + IMAGE_LOGD("ImageSourceNapiCreateFromData success"); return IMAGE_RESULT_SUCCESS; } @@ -319,13 +322,13 @@ static int32_t ImageSourceNapiCreateFromRawFile(struct ImageSourceArgs* args) ParseImageSourceOps(opts, args->sourceOps); } RawFileDescriptor rawFile = args->rawFile; - HiLog::Debug(LABEL, "ImageSourceNapiCreateFromRawFile"); + IMAGE_LOGD("ImageSourceNapiCreateFromRawFile"); uint32_t errorCode = ERR_MEDIA_INVALID_VALUE; int32_t rawFileLength = rawFile.start + rawFile.length; std::unique_ptr nativeImageSource = ImageSource::CreateImageSource( rawFile.fd, rawFile.start, rawFileLength, opts, errorCode); if (nativeImageSource == nullptr) { - HiLog::Debug(LABEL, "ImageSourceNapiCreateFromRawFile create failed:%{public}d", errorCode); + IMAGE_LOGD("ImageSourceNapiCreateFromRawFile create failed:%{public}d", errorCode); return IMAGE_RESULT_BAD_PARAMETER; } ImageResource resource; @@ -335,38 +338,38 @@ static int32_t ImageSourceNapiCreateFromRawFile(struct ImageSourceArgs* args) resource.fileLength = rawFileLength; std::shared_ptr imageSource = std::move(nativeImageSource); if (imageSource == nullptr) { - HiLog::Error(LABEL, "ImageSourceNapiCreateFromRawFile native create failed"); + IMAGE_LOGE("ImageSourceNapiCreateFromRawFile native create failed"); return IMAGE_RESULT_BAD_PARAMETER; } if (ImageSourceCreateNapi(args->inEnv, args->outVal, imageSource, nullptr, &resource) != SUCCESS) { - HiLog::Error(LABEL, "ImageSourceNapiCreateFromRawFile napi create failed"); + IMAGE_LOGE("ImageSourceNapiCreateFromRawFile napi create failed"); args->outVal = nullptr; return IMAGE_RESULT_BAD_PARAMETER; } - HiLog::Debug(LABEL, "ImageSourceNapiCreateFromRawFile success"); + IMAGE_LOGD("ImageSourceNapiCreateFromRawFile success"); return IMAGE_RESULT_SUCCESS; } static int32_t ImageSourceNapiCreateIncremental(struct ImageSourceArgs* args) { if (args == nullptr || args->inEnv == nullptr) { - HiLog::Error(LABEL, "ImageSourceNapiCreateIncremental args or env is nullptr"); + IMAGE_LOGE("ImageSourceNapiCreateIncremental args or env is nullptr"); return IMAGE_RESULT_BAD_PARAMETER; } IncrementalSourceOptions incOpts; if (args->sourceOps != nullptr) { - HiLog::Debug(LABEL, "ImageSourceNapiCreate ParseImageSourceOps"); + IMAGE_LOGD("ImageSourceNapiCreate ParseImageSourceOps"); ParseImageSourceOps(incOpts.sourceOptions, args->sourceOps); } incOpts.incrementalMode = IncrementalMode::INCREMENTAL_DATA; uint32_t errorCode = ERR_MEDIA_INVALID_VALUE; std::unique_ptr imageSource = ImageSource::CreateIncrementalImageSource(incOpts, errorCode); if (imageSource == nullptr) { - HiLog::Error(LABEL, "ImageSourceNapiCreateIncremental native imagesource failed"); + IMAGE_LOGE("ImageSourceNapiCreateIncremental native imagesource failed"); return IMAGE_RESULT_BAD_PARAMETER; } if (args->dataArray.data != nullptr && args->dataArray.dataSize > SIZE_ZERO) { - HiLog::Debug(LABEL, "ImageSourceNapiCreateIncremental update dataArray"); + IMAGE_LOGD("ImageSourceNapiCreateIncremental update dataArray"); imageSource->UpdateData(args->dataArray.data, args->dataArray.dataSize, false); } DecodeOptions decodeOpts; @@ -378,41 +381,41 @@ static int32_t ImageSourceNapiCreateIncremental(struct ImageSourceArgs* args) std::unique_ptr incPixelMap = imageSource->CreateIncrementalPixelMap( index, decodeOpts, errorCode); if (incPixelMap == nullptr) { - HiLog::Error(LABEL, "ImageSourceNapiCreateIncremental native incremental pixelmap failed"); + IMAGE_LOGE("ImageSourceNapiCreateIncremental native incremental pixelmap failed"); return IMAGE_RESULT_BAD_PARAMETER; } if (ImageSourceCreateNapi(args->inEnv, args->outVal, std::move(imageSource), std::move(incPixelMap), nullptr) != SUCCESS) { - HiLog::Error(LABEL, "ImageSourceNapiCreateIncremental napi create failed"); + IMAGE_LOGE("ImageSourceNapiCreateIncremental napi create failed"); args->outVal = nullptr; return IMAGE_RESULT_BAD_PARAMETER; } - HiLog::Debug(LABEL, "ImageSourceNapiCreateIncremental success"); + IMAGE_LOGD("ImageSourceNapiCreateIncremental success"); return IMAGE_RESULT_SUCCESS; } static int32_t ImageSourceNapiGetSupportedFormats(struct ImageSourceArgs* args) { if (args == nullptr) { - HiLog::Error(LABEL, "ImageSourceNapiGetSupportedFormats args is nullptr"); + IMAGE_LOGE("ImageSourceNapiGetSupportedFormats args is nullptr"); return IMAGE_RESULT_BAD_PARAMETER; } auto formats = args->outFormats; if (formats == nullptr) { - HiLog::Error(LABEL, "ImageSourceNapiGetSupportedFormats args or napi is nullptr"); + IMAGE_LOGE("ImageSourceNapiGetSupportedFormats args or napi is nullptr"); return IMAGE_RESULT_BAD_PARAMETER; } std::set formatSet; uint32_t errorCode = ImageSource::GetSupportedFormats(formatSet); if (errorCode != SUCCESS) { - HiLog::Error(LABEL, "ImageSourceNapiGetSupportedFormats native failed"); + IMAGE_LOGE("ImageSourceNapiGetSupportedFormats native failed"); return IMAGE_RESULT_BAD_PARAMETER; } size_t formatCount = formatSet.size(); if (formats->supportedFormatList == nullptr) { formats->size = formatCount; - HiLog::Debug(LABEL, "ImageSourceNapiGetSupportedFormats get count only Success"); + IMAGE_LOGD("ImageSourceNapiGetSupportedFormats get count only Success"); return IMAGE_RESULT_SUCCESS; } else { formatCount = formats->size; @@ -425,7 +428,7 @@ static int32_t ImageSourceNapiGetSupportedFormats(struct ImageSourceArgs* args) break; } if (formatList[i] == nullptr || formatList[i]->format == nullptr) { - HiLog::Debug(LABEL, "ImageSourceNapiGetSupportedFormats nullptr format out buffer"); + IMAGE_LOGD("ImageSourceNapiGetSupportedFormats nullptr format out buffer"); return IMAGE_RESULT_BAD_PARAMETER; } memcpy_s(formatList[i]->format, formatList[i]->size, formatStr.c_str(), formatStr.size()); @@ -434,19 +437,19 @@ static int32_t ImageSourceNapiGetSupportedFormats(struct ImageSourceArgs* args) } i++; } - HiLog::Debug(LABEL, "ImageSourceNapiGetSupportedFormats Success"); + IMAGE_LOGD("ImageSourceNapiGetSupportedFormats Success"); return IMAGE_RESULT_SUCCESS; } static int32_t ImageSourceNapiUnwrap(struct ImageSourceArgs* args) { if (args == nullptr || args->inEnv == nullptr || args->inVal == nullptr) { - HiLog::Error(LABEL, "ImageSourceNapiUnwrap args or env is nullptr"); + IMAGE_LOGE("ImageSourceNapiUnwrap args or env is nullptr"); return IMAGE_RESULT_BAD_PARAMETER; } args->napi = UnwrapNativeObject(args->inEnv, args->inVal); if (args->napi == nullptr) { - HiLog::Error(LABEL, "ImageSourceNapiUnwrap UnwrapNativeObject failed"); + IMAGE_LOGE("ImageSourceNapiUnwrap UnwrapNativeObject failed"); return IMAGE_RESULT_BAD_PARAMETER; } return IMAGE_RESULT_SUCCESS; @@ -456,7 +459,7 @@ static int32_t ImageSourceNapiCreatePixelmap(struct ImageSourceArgs* args) { auto native = GetNativeImageSource(args); if (native == nullptr || args->inEnv == nullptr) { - HiLog::Error(LABEL, "ImageSourceNapiCreatePixelmap args or napi is nullptr"); + IMAGE_LOGE("ImageSourceNapiCreatePixelmap args or napi is nullptr"); return IMAGE_RESULT_BAD_PARAMETER; } std::shared_ptr nativePixelMap = args->napi->GetIncrementalPixelMap(); @@ -468,22 +471,22 @@ static int32_t ImageSourceNapiCreatePixelmap(struct ImageSourceArgs* args) ParseDecodingOps(decOps, args->decodingOps); index = args->decodingOps->index; } - HiLog::Debug(LABEL, "ImageSourceNapiCreatePixelmap CreatePixelMapEx"); + IMAGE_LOGD("ImageSourceNapiCreatePixelmap CreatePixelMapEx"); auto tmpPixelmap = native->CreatePixelMapEx(index, decOps, errorCode); if (tmpPixelmap != nullptr) { nativePixelMap = std::move(tmpPixelmap); } } if (nativePixelMap == nullptr) { - HiLog::Error(LABEL, "ImageSourceNapiCreatePixelmap native failed"); + IMAGE_LOGE("ImageSourceNapiCreatePixelmap native failed"); return IMAGE_RESULT_BAD_PARAMETER; } *(args->outVal) = PixelMapNapi::CreatePixelMap(args->inEnv, nativePixelMap); if (*(args->outVal) == nullptr) { - HiLog::Error(LABEL, "ImageSourceNapiCreatePixelmap create pixelmap failed"); + IMAGE_LOGE("ImageSourceNapiCreatePixelmap create pixelmap failed"); return IMAGE_RESULT_BAD_PARAMETER; } - HiLog::Debug(LABEL, "ImageSourceNapiCreatePixelmap Success"); + IMAGE_LOGD("ImageSourceNapiCreatePixelmap Success"); return IMAGE_RESULT_SUCCESS; } @@ -491,7 +494,7 @@ static int32_t ImageSourceNapiCreatePixelmapList(struct ImageSourceArgs* args) { auto native = GetNativeImageSource(args); if (native == nullptr || args->inEnv == nullptr) { - HiLog::Error(LABEL, "ImageSourceNapiCreatePixelmapList args or napi is nullptr"); + IMAGE_LOGE("ImageSourceNapiCreatePixelmapList args or napi is nullptr"); return IMAGE_RESULT_BAD_PARAMETER; } DecodeOptions decOps; @@ -501,7 +504,7 @@ static int32_t ImageSourceNapiCreatePixelmapList(struct ImageSourceArgs* args) } auto pixelMapList = native->CreatePixelMapList(decOps, errorCode); if (pixelMapList == nullptr) { - HiLog::Error(LABEL, "ImageSourceNapiCreatePixelmapList CreatePixelMapList failed"); + IMAGE_LOGE("ImageSourceNapiCreatePixelmapList CreatePixelMapList failed"); return IMAGE_RESULT_BAD_PARAMETER; } napi_create_array(args->inEnv, args->outVal); @@ -511,7 +514,7 @@ static int32_t ImageSourceNapiCreatePixelmapList(struct ImageSourceArgs* args) napi_set_element(args->inEnv, *(args->outVal), i, napiPixelMap); i++; } - HiLog::Debug(LABEL, "ImageSourceNapiCreatePixelmapList Success"); + IMAGE_LOGD("ImageSourceNapiCreatePixelmapList Success"); return IMAGE_RESULT_SUCCESS; } @@ -519,19 +522,19 @@ static int32_t ImageSourceNapiGetDelayTime(struct ImageSourceArgs* args) __attri { auto native = GetNativeImageSource(args); if (native == nullptr || args->outDelayTimes == nullptr) { - HiLog::Error(LABEL, "ImageSourceNapiGetDelayTime native image or out is nullptr"); + IMAGE_LOGE("ImageSourceNapiGetDelayTime native image or out is nullptr"); return IMAGE_RESULT_BAD_PARAMETER; } auto outDelayTimes = args->outDelayTimes; uint32_t errorCode = ERR_MEDIA_INVALID_VALUE; auto delayTimes = native->GetDelayTime(errorCode); if (delayTimes == nullptr) { - HiLog::Error(LABEL, "ImageSourceNapiGetDelayTime native failed"); + IMAGE_LOGE("ImageSourceNapiGetDelayTime native failed"); return IMAGE_RESULT_BAD_PARAMETER; } size_t actCount = (*delayTimes).size(); if (outDelayTimes->delayTimeList == nullptr) { - HiLog::Error(LABEL, "ImageSourceNapiGetDelayTime get times count only"); + IMAGE_LOGE("ImageSourceNapiGetDelayTime get times count only"); outDelayTimes->size = actCount; return IMAGE_RESULT_SUCCESS; } @@ -541,7 +544,7 @@ static int32_t ImageSourceNapiGetDelayTime(struct ImageSourceArgs* args) __attri for (size_t i = SIZE_ZERO; i < actCount; i++) { outDelayTimes->delayTimeList[i] = (*delayTimes)[i]; } - HiLog::Debug(LABEL, "ImageSourceNapiGetDelayTime Success"); + IMAGE_LOGD("ImageSourceNapiGetDelayTime Success"); return IMAGE_RESULT_SUCCESS; } @@ -549,16 +552,16 @@ static int32_t ImageSourceNapiGetFrameCount(struct ImageSourceArgs* args) { auto native = GetNativeImageSource(args); if (native == nullptr || args->outUint32 == nullptr) { - HiLog::Error(LABEL, "ImageSourceNapiGetFrameCount native image or out is nullptr"); + IMAGE_LOGE("ImageSourceNapiGetFrameCount native image or out is nullptr"); return IMAGE_RESULT_BAD_PARAMETER; } uint32_t errorCode = ERR_MEDIA_INVALID_VALUE; *(args->outUint32) = native->GetFrameCount(errorCode); if (errorCode != SUCCESS) { - HiLog::Error(LABEL, "ImageSourceNapiGetFrameCount native failed"); + IMAGE_LOGE("ImageSourceNapiGetFrameCount native failed"); return IMAGE_RESULT_BAD_PARAMETER; } - HiLog::Debug(LABEL, "ImageSourceNapiGetFrameCount Success"); + IMAGE_LOGD("ImageSourceNapiGetFrameCount Success"); return IMAGE_RESULT_SUCCESS; } @@ -566,22 +569,22 @@ static int32_t ImageSourceNapiGetImageInfo(struct ImageSourceArgs* args) { auto native = GetNativeImageSource(args); if (native == nullptr) { - HiLog::Error(LABEL, "ImageSourceNapiGetImageInfo native image is nullptr"); + IMAGE_LOGE("ImageSourceNapiGetImageInfo native image is nullptr"); return IMAGE_RESULT_BAD_PARAMETER; } auto imageSourceInfo = args->outInfo; if (imageSourceInfo == nullptr) { - HiLog::Error(LABEL, "ImageSourceNapiGetImageInfo image info is nullptr"); + IMAGE_LOGE("ImageSourceNapiGetImageInfo image info is nullptr"); return IMAGE_RESULT_BAD_PARAMETER; } ImageInfo imageInfo; uint32_t errorCode = native->GetImageInfo(args->inInt32, imageInfo); if (errorCode != SUCCESS) { - HiLog::Error(LABEL, "ImageSourceNapiGetImageInfo native failed"); + IMAGE_LOGE("ImageSourceNapiGetImageInfo native failed"); return IMAGE_RESULT_BAD_PARAMETER; } ParseImageSourceInfo(imageSourceInfo, imageInfo); - HiLog::Debug(LABEL, "ImageSourceNapiGetImageInfo Success"); + IMAGE_LOGD("ImageSourceNapiGetImageInfo Success"); return IMAGE_RESULT_SUCCESS; } @@ -590,28 +593,28 @@ static int32_t ImageSourceNapiGetImageProperty( { auto native = GetNativeImageSource(args); if (native == nullptr) { - HiLog::Error(LABEL, "ImageSourceNapiGetImageProperty native image is nullptr"); + IMAGE_LOGE("ImageSourceNapiGetImageProperty native image is nullptr"); return IMAGE_RESULT_BAD_PARAMETER; } auto propertyKey = args->inPropertyKey; auto propertyVal = args->propertyVal; if (propertyKey == nullptr || propertyKey->value == nullptr || propertyKey->size == SIZE_ZERO) { - HiLog::Error(LABEL, "ImageSourceNapiGetImageProperty key is empty"); + IMAGE_LOGE("ImageSourceNapiGetImageProperty key is empty"); return IMAGE_RESULT_BAD_PARAMETER; } if (propertyVal == nullptr) { - HiLog::Error(LABEL, "ImageSourceNapiGetImageProperty out val is nullptr"); + IMAGE_LOGE("ImageSourceNapiGetImageProperty out val is nullptr"); return IMAGE_RESULT_BAD_PARAMETER; } std::string key(propertyKey->value, propertyKey->size); std::string val; uint32_t errorCode = native->GetImagePropertyString(DEFAULT_INDEX, key, val); if (errorCode != SUCCESS || val.empty()) { - HiLog::Error(LABEL, "ImageSourceNapiGetImageProperty native failed"); + IMAGE_LOGE("ImageSourceNapiGetImageProperty native failed"); return IMAGE_RESULT_BAD_PARAMETER; } if (propertyVal->value == nullptr) { - HiLog::Debug(LABEL, "ImageSourceNapiGetImageProperty return size only"); + IMAGE_LOGD("ImageSourceNapiGetImageProperty return size only"); propertyVal->size = val.size(); return IMAGE_RESULT_SUCCESS; } @@ -619,7 +622,7 @@ static int32_t ImageSourceNapiGetImageProperty( if (propertyVal->size > val.size()) { propertyVal->size = val.size(); } - HiLog::Debug(LABEL, "ImageSourceNapiGetImageProperty Success"); + IMAGE_LOGD("ImageSourceNapiGetImageProperty Success"); return IMAGE_RESULT_SUCCESS; } @@ -629,28 +632,28 @@ static uint32_t NativePropertyModify(ImageSource* native, ImageResource &imageRe auto type = imageResource.type; uint32_t errorCode = ERR_MEDIA_INVALID_VALUE; if (type == ImageResourceType::IMAGE_RESOURCE_INVAILD) { - HiLog::Error(LABEL, "NativePropertyModify resource is invaild"); + IMAGE_LOGE("NativePropertyModify resource is invaild"); return IMAGE_RESULT_BAD_PARAMETER; } else if (type == ImageResourceType::IMAGE_RESOURCE_FD && imageResource.fd != INVALID_FD) { - HiLog::Debug(LABEL, "NativePropertyModify fd resource"); + IMAGE_LOGD("NativePropertyModify fd resource"); errorCode = native->ModifyImageProperty(DEFAULT_INDEX, key, val, imageResource.fd); } else if (type == ImageResourceType::IMAGE_RESOURCE_PATH && !imageResource.path.empty()) { - HiLog::Debug(LABEL, "NativePropertyModify path resource"); + IMAGE_LOGD("NativePropertyModify path resource"); errorCode = native->ModifyImageProperty(DEFAULT_INDEX, key, val, imageResource.path); } else if (type == ImageResourceType::IMAGE_RESOURCE_BUFFER && imageResource.buffer != nullptr && imageResource.bufferSize > SIZE_ZERO) { - HiLog::Debug(LABEL, "NativePropertyModify buffer resource"); + IMAGE_LOGD("NativePropertyModify buffer resource"); errorCode = native->ModifyImageProperty(DEFAULT_INDEX, key, val, imageResource.buffer, imageResource.bufferSize); } else { - HiLog::Error(LABEL, "NativePropertyModify %{public}d resource error", type); + IMAGE_LOGE("NativePropertyModify %{public}d resource error", type); return IMAGE_RESULT_BAD_PARAMETER; } if (errorCode == SUCCESS) { - HiLog::Debug(LABEL, "NativePropertyModify Success"); + IMAGE_LOGD("NativePropertyModify Success"); return IMAGE_RESULT_SUCCESS; } - HiLog::Error(LABEL, "NativePropertyModify native failed"); + IMAGE_LOGE("NativePropertyModify native failed"); return IMAGE_RESULT_BAD_PARAMETER; } @@ -658,17 +661,17 @@ static int32_t ImageSourceNapiModifyImageProperty(struct ImageSourceArgs* args) { auto native = GetNativeImageSource(args); if (native == nullptr) { - HiLog::Error(LABEL, "ImageSourceNapiModifyImageProperty native image is nullptr"); + IMAGE_LOGE("ImageSourceNapiModifyImageProperty native image is nullptr"); return IMAGE_RESULT_BAD_PARAMETER; } auto propertyKey = args->inPropertyKey; auto propertyVal = args->propertyVal; if (propertyKey == nullptr || propertyKey->value == nullptr || propertyKey->size == SIZE_ZERO) { - HiLog::Error(LABEL, "ImageSourceNapiModifyImageProperty key is empty"); + IMAGE_LOGE("ImageSourceNapiModifyImageProperty key is empty"); return IMAGE_RESULT_BAD_PARAMETER; } if (propertyVal == nullptr || propertyVal->value == nullptr || propertyVal->size == SIZE_ZERO) { - HiLog::Error(LABEL, "ImageSourceNapiModifyImageProperty val is nullptr"); + IMAGE_LOGE("ImageSourceNapiModifyImageProperty val is nullptr"); return IMAGE_RESULT_BAD_PARAMETER; } std::string key(propertyKey->value, propertyKey->size); @@ -682,7 +685,7 @@ static int32_t ProcessIncrementalPixelMap(struct ImageSourceArgs* args, bool com { auto incPixelMap = args->napi->GetIncrementalPixelMap(); if (incPixelMap == nullptr) { - HiLog::Error(LABEL, "ProcessIncrementalPixelMap incremental pixelmap is nullptr"); + IMAGE_LOGE("ProcessIncrementalPixelMap incremental pixelmap is nullptr"); return IMAGE_RESULT_BAD_PARAMETER; } uint8_t tmpProgress = 0; @@ -691,7 +694,7 @@ static int32_t ProcessIncrementalPixelMap(struct ImageSourceArgs* args, bool com incPixelMap->DetachFromDecoding(); } if (errCode != SUCCESS || (errCode == ERR_IMAGE_SOURCE_DATA_INCOMPLETE && !completed)) { - HiLog::Error(LABEL, "ProcessIncrementalPixelMap promote decoding failed"); + IMAGE_LOGE("ProcessIncrementalPixelMap promote decoding failed"); return IMAGE_RESULT_BAD_PARAMETER; } return IMAGE_RESULT_SUCCESS; @@ -709,20 +712,20 @@ static int32_t ImageSourceNapiUpdateData(struct ImageSourceArgs* args) { auto native = GetNativeImageSource(args); if (native == nullptr) { - HiLog::Error(LABEL, "ImageSourceNapiUpdateData native image is nullptr"); + IMAGE_LOGE("ImageSourceNapiUpdateData native image is nullptr"); return IMAGE_RESULT_BAD_PARAMETER; } auto data = args->inUpdateData; if (data == nullptr || data->buffer == nullptr || data->bufferSize == SIZE_ZERO || data->offset >= data->bufferSize) { - HiLog::Error(LABEL, "ImageSourceNapiUpdateData update data is empty"); + IMAGE_LOGE("ImageSourceNapiUpdateData update data is empty"); return IMAGE_RESULT_BAD_PARAMETER; } uint32_t actSize = MathMin((data->bufferSize - data->offset), data->updateLength); bool completed = data->isCompleted == INT8_TRUE; uint32_t errCode = native->UpdateData((data->buffer + data->offset), actSize, completed); if (errCode != SUCCESS) { - HiLog::Error(LABEL, "ImageSourceNapiUpdateData update native failed"); + IMAGE_LOGE("ImageSourceNapiUpdateData update native failed"); return IMAGE_RESULT_BAD_PARAMETER; } return ProcessIncrementalPixelMap(args, completed); diff --git a/frameworks/kits/js/common/image_source_napi.cpp b/frameworks/kits/js/common/image_source_napi.cpp index 7627d0f77..0e16e391c 100644 --- a/frameworks/kits/js/common/image_source_napi.cpp +++ b/frameworks/kits/js/common/image_source_napi.cpp @@ -15,9 +15,8 @@ #include "image_source_napi.h" #include -#include "hilog/log.h" +#include "image_log.h" #include "image_napi_utils.h" -#include "log_tags.h" #include "media_errors.h" #include "string_ex.h" #include "image_trace.h" @@ -26,9 +25,13 @@ #include "color_space_object_convertor.h" #endif -using OHOS::HiviewDFX::HiLog; +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "ImageSourceNapi" + namespace { - constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "ImageSourceNapi"}; constexpr int INVALID_FD = -1; constexpr uint32_t NUM_0 = 0; constexpr uint32_t NUM_1 = 1; @@ -201,13 +204,13 @@ static std::string GetStringArgument(napi_env env, napi_value value) if (status == napi_ok && bufLength > NUM_0 && bufLength < PATH_MAX) { char *buffer = reinterpret_cast(malloc((bufLength + NUM_1) * sizeof(char))); if (buffer == nullptr) { - HiLog::Error(LABEL, "No memory"); + IMAGE_LOGE("No memory"); return strValue; } status = napi_get_value_string_utf8(env, value, buffer, bufLength + NUM_1, &bufLength); if (status == napi_ok) { - HiLog::Debug(LABEL, "Get Success"); + IMAGE_LOGD("Get Success"); strValue.assign(buffer, 0, bufLength + NUM_1); } if (buffer != nullptr) { @@ -228,7 +231,7 @@ static void ImageSourceCallbackRoutine(napi_env env, ImageSourceAsyncContext* &c napi_get_undefined(env, &result[NUM_1]); if (context == nullptr) { - HiLog::Error(LABEL, "context is nullptr"); + IMAGE_LOGE("context is nullptr"); return; } @@ -237,7 +240,7 @@ static void ImageSourceCallbackRoutine(napi_env env, ImageSourceAsyncContext* &c } else if (context->errMsg.size() > 0) { napi_create_string_utf8(env, context->errMsg.c_str(), NAPI_AUTO_LENGTH, &result[NUM_0]); } else { - HiLog::Debug(LABEL, "error status, no message"); + IMAGE_LOGD("error status, no message"); napi_create_string_utf8(env, "error status, no message", NAPI_AUTO_LENGTH, &result[NUM_0]); } @@ -248,7 +251,7 @@ static void ImageSourceCallbackRoutine(napi_env env, ImageSourceAsyncContext* &c napi_reject_deferred(env, context->deferred, result[NUM_0]); } } else { - HiLog::Debug(LABEL, "call callback function"); + IMAGE_LOGD("call callback function"); napi_get_reference_value(env, context->callbackRef, &callback); napi_call_function(env, nullptr, callback, NUM_2, result, &retVal); napi_delete_reference(env, context->callbackRef); @@ -266,7 +269,7 @@ static void ImageSourceCallbackWithErrorObj(napi_env env, napi_value result[NUM_2] = {0}; if (context == nullptr) { - HiLog::Error(LABEL, "context is nullptr"); + IMAGE_LOGE("context is nullptr"); return; } @@ -275,7 +278,7 @@ static void ImageSourceCallbackWithErrorObj(napi_env env, result[NUM_1] = val; } else { std::string errMsg = (context->errMsg.size() > 0) ? context->errMsg : "error status, no message"; - HiLog::Debug(LABEL, "Operation failed code:%{public}d, msg:%{public}s", + IMAGE_LOGD("Operation failed code:%{public}d, msg:%{public}s", context->status, errMsg.c_str()); ImageNapiUtils::CreateErrorObj(env, result[NUM_0], context->status, errMsg); napi_get_undefined(env, &result[NUM_1]); @@ -290,7 +293,7 @@ static void ImageSourceCallbackWithErrorObj(napi_env env, } else { napi_value retVal; napi_value callback = nullptr; - HiLog::Debug(LABEL, "call callback function"); + IMAGE_LOGD("call callback function"); napi_get_reference_value(env, context->callbackRef, &callback); napi_call_function(env, nullptr, callback, NUM_2, result, &retVal); napi_delete_reference(env, context->callbackRef); @@ -319,13 +322,13 @@ static napi_value CreateEnumTypeObject(napi_env env, } else if (type == napi_number) { status = napi_create_int32(env, imgEnum.numVal, &enumNapiValue); } else { - HiLog::Error(LABEL, "Unsupported type %{public}d!", type); + IMAGE_LOGE("Unsupported type %{public}d!", type); } if (status == napi_ok && enumNapiValue != nullptr) { status = napi_set_named_property(env, result, imgEnum.name.c_str(), enumNapiValue); } if (status != napi_ok) { - HiLog::Error(LABEL, "Failed to add named prop!"); + IMAGE_LOGE("Failed to add named prop!"); break; } } @@ -337,7 +340,7 @@ static napi_value CreateEnumTypeObject(napi_env env, } } } - HiLog::Error(LABEL, "CreateEnumTypeObject is Failed!"); + IMAGE_LOGE("CreateEnumTypeObject is Failed!"); napi_get_undefined(env, &result); return result; } @@ -366,38 +369,38 @@ static napi_value DoInit(napi_env env, napi_value exports, struct ImageConstruct napi_status status = napi_define_class(env, info.className.c_str(), NAPI_AUTO_LENGTH, info.constructor, nullptr, info.propertyCount, info.property, &constructor); if (status != napi_ok) { - HiLog::Error(LABEL, "define class fail"); + IMAGE_LOGE("define class fail"); return nullptr; } status = napi_create_reference(env, constructor, NUM_1, info.classRef); if (status != napi_ok) { - HiLog::Error(LABEL, "create reference fail"); + IMAGE_LOGE("create reference fail"); return nullptr; } napi_value global = nullptr; status = napi_get_global(env, &global); if (status != napi_ok) { - HiLog::Error(LABEL, "Init:get global fail"); + IMAGE_LOGE("Init:get global fail"); return nullptr; } status = napi_set_named_property(env, global, info.className.c_str(), constructor); if (status != napi_ok) { - HiLog::Error(LABEL, "Init:set global named property fail"); + IMAGE_LOGE("Init:set global named property fail"); return nullptr; } status = napi_set_named_property(env, exports, info.className.c_str(), constructor); if (status != napi_ok) { - HiLog::Error(LABEL, "set named property fail"); + IMAGE_LOGE("set named property fail"); return nullptr; } status = napi_define_properties(env, exports, info.staticPropertyCount, info.staticProperty); if (status != napi_ok) { - HiLog::Error(LABEL, "define properties fail"); + IMAGE_LOGE("define properties fail"); return nullptr; } return exports; @@ -449,7 +452,7 @@ napi_value ImageSourceNapi::Init(napi_env env, napi_value exports) return nullptr; } - HiLog::Debug(LABEL, "Init success"); + IMAGE_LOGD("Init success"); return exports; } @@ -467,7 +470,7 @@ napi_value ImageSourceNapi::Constructor(napi_env env, napi_callback_info info) pImgSrcNapi->env_ = env; pImgSrcNapi->nativeImgSrc = sImgSrc_; if (pImgSrcNapi->nativeImgSrc == nullptr) { - HiLog::Error(LABEL, "Failed to set nativeImageSource with null. Maybe a reentrancy error"); + IMAGE_LOGE("Failed to set nativeImageSource with null. Maybe a reentrancy error"); } pImgSrcNapi->navIncPixelMap_ = sIncPixelMap_; sIncPixelMap_ = nullptr; @@ -478,7 +481,7 @@ napi_value ImageSourceNapi::Constructor(napi_env env, napi_callback_info info) pImgSrcNapi.release(); return thisVar; } else { - HiLog::Error(LABEL, "Failure wrapping js to native napi"); + IMAGE_LOGE("Failure wrapping js to native napi"); } } } @@ -489,7 +492,7 @@ napi_value ImageSourceNapi::Constructor(napi_env env, napi_callback_info info) void ImageSourceNapi::Destructor(napi_env env, void *nativeObject, void *finalize) { reinterpret_cast(nativeObject)->nativeImgSrc = nullptr; - HiLog::Debug(LABEL, "ImageSourceNapi::Destructor"); + IMAGE_LOGD("ImageSourceNapi::Destructor"); } napi_value ImageSourceNapi::GetSupportedFormats(napi_env env, napi_callback_info info) @@ -500,22 +503,22 @@ napi_value ImageSourceNapi::GetSupportedFormats(napi_env env, napi_callback_info napi_status status; napi_value thisVar = nullptr; size_t argCount = 0; - HiLog::Debug(LABEL, "GetSupportedFormats IN"); + IMAGE_LOGD("GetSupportedFormats IN"); IMG_JS_ARGS(env, info, status, argCount, nullptr, thisVar); - IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), result, HiLog::Error(LABEL, "fail to napi_get_cb_info")); + IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), result, IMAGE_LOGE("fail to napi_get_cb_info")); std::unique_ptr asyncContext = std::make_unique(); status = napi_unwrap(env, thisVar, reinterpret_cast(&asyncContext->constructor_)); IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, asyncContext->constructor_), - nullptr, HiLog::Error(LABEL, "fail to unwrap context")); + nullptr, IMAGE_LOGE("fail to unwrap context")); std::set formats; uint32_t ret = asyncContext->constructor_->nativeImgSrc->GetSupportedFormats(formats); IMG_NAPI_CHECK_RET_D((ret == SUCCESS), - nullptr, HiLog::Error(LABEL, "fail to get supported formats")); + nullptr, IMAGE_LOGE("fail to get supported formats")); napi_create_array(env, &result); size_t i = 0; @@ -562,7 +565,7 @@ STATIC_COMPLETE_FUNC(GetImageInfo) if (!IMG_IS_OK(status)) { context->status = ERROR; - HiLog::Error(LABEL, "napi_create_int32 failed!"); + IMAGE_LOGE("napi_create_int32 failed!"); napi_get_undefined(env, &result); } else { context->status = SUCCESS; @@ -577,7 +580,7 @@ STATIC_COMPLETE_FUNC(GetImageInfo) static bool ParseSize(napi_env env, napi_value root, Size* size) { if (size == nullptr) { - HiLog::Error(LABEL, "size is nullptr"); + IMAGE_LOGE("size is nullptr"); return false; } if (!GET_INT32_BY_NAME(root, "height", size->height)) { @@ -596,7 +599,7 @@ static bool ParseRegion(napi_env env, napi_value root, Rect* region) napi_value tmpValue = nullptr; if (region == nullptr) { - HiLog::Error(LABEL, "region is nullptr"); + IMAGE_LOGE("region is nullptr"); return false; } @@ -646,41 +649,41 @@ static bool ParseDecodeOptions2(napi_env env, napi_value root, DecodeOptions* op { uint32_t tmpNumber = 0; if (!GET_UINT32_BY_NAME(root, "desiredPixelFormat", tmpNumber)) { - HiLog::Debug(LABEL, "no desiredPixelFormat"); + IMAGE_LOGD("no desiredPixelFormat"); } else { if (IsSupportPixelFormat(tmpNumber)) { opts->desiredPixelFormat = ParsePixlForamt(tmpNumber); } else { - HiLog::Debug(LABEL, "Invalid desiredPixelFormat %{public}d", tmpNumber); + IMAGE_LOGD("Invalid desiredPixelFormat %{public}d", tmpNumber); error = "DecodeOptions mismatch"; return false; } } if (!GET_INT32_BY_NAME(root, "fitDensity", opts->fitDensity)) { - HiLog::Debug(LABEL, "no fitDensity"); + IMAGE_LOGD("no fitDensity"); } if (GET_UINT32_BY_NAME(root, "fillColor", opts->SVGOpts.fillColor.color)) { opts->SVGOpts.fillColor.isValidColor = true; - HiLog::Debug(LABEL, "fillColor %{public}x", opts->SVGOpts.fillColor.color); + IMAGE_LOGD("fillColor %{public}x", opts->SVGOpts.fillColor.color); } else { - HiLog::Debug(LABEL, "no fillColor"); + IMAGE_LOGD("no fillColor"); } if (GET_UINT32_BY_NAME(root, "SVGResize", opts->SVGOpts.SVGResize.resizePercentage)) { opts->SVGOpts.SVGResize.isValidPercentage = true; - HiLog::Debug(LABEL, "SVGResize percentage %{public}x", opts->SVGOpts.SVGResize.resizePercentage); + IMAGE_LOGD("SVGResize percentage %{public}x", opts->SVGOpts.SVGResize.resizePercentage); } else { - HiLog::Debug(LABEL, "no SVGResize percentage"); + IMAGE_LOGD("no SVGResize percentage"); } napi_value nDesiredColorSpace = nullptr; if (napi_get_named_property(env, root, "desiredColorSpace", &nDesiredColorSpace) == napi_ok) { opts->desiredColorSpaceInfo = OHOS::ColorManager::GetColorSpaceByJSObject(env, nDesiredColorSpace); - HiLog::Debug(LABEL, "desiredColorSpace parse finished"); + IMAGE_LOGD("desiredColorSpace parse finished"); } if (opts->desiredColorSpaceInfo == nullptr) { - HiLog::Debug(LABEL, "no desiredColorSpace"); + IMAGE_LOGD("no desiredColorSpace"); } return true; } @@ -691,48 +694,48 @@ static bool ParseDecodeOptions(napi_env env, napi_value root, DecodeOptions* opt napi_value tmpValue = nullptr; if (!ImageNapiUtils::GetUint32ByName(env, root, "index", pIndex)) { - HiLog::Debug(LABEL, "no index"); + IMAGE_LOGD("no index"); } if (opts == nullptr) { - HiLog::Error(LABEL, "opts is nullptr"); + IMAGE_LOGE("opts is nullptr"); return false; } if (!GET_UINT32_BY_NAME(root, "sampleSize", opts->sampleSize)) { - HiLog::Debug(LABEL, "no sampleSize"); + IMAGE_LOGD("no sampleSize"); } if (!GET_UINT32_BY_NAME(root, "rotate", opts->rotateNewDegrees)) { - HiLog::Debug(LABEL, "no rotate"); + IMAGE_LOGD("no rotate"); } else { if (opts->rotateNewDegrees >= 0 && opts->rotateNewDegrees <= 360) { // 360 is the maximum rotation angle. opts->rotateDegrees = static_cast(opts->rotateNewDegrees); } else { - HiLog::Debug(LABEL, "Invalid rotate %{public}d", opts->rotateNewDegrees); + IMAGE_LOGD("Invalid rotate %{public}d", opts->rotateNewDegrees); error = "DecodeOptions mismatch"; return false; } } if (!GET_BOOL_BY_NAME(root, "editable", opts->editable)) { - HiLog::Debug(LABEL, "no editable"); + IMAGE_LOGD("no editable"); } if (!GET_NODE_BY_NAME(root, "desiredSize", tmpValue)) { - HiLog::Debug(LABEL, "no desiredSize"); + IMAGE_LOGD("no desiredSize"); } else { if (!ParseSize(env, tmpValue, &(opts->desiredSize))) { - HiLog::Debug(LABEL, "ParseSize error"); + IMAGE_LOGD("ParseSize error"); } } if (!GET_NODE_BY_NAME(root, "desiredRegion", tmpValue)) { - HiLog::Debug(LABEL, "no desiredRegion"); + IMAGE_LOGD("no desiredRegion"); } else { if (!ParseRegion(env, tmpValue, &(opts->CropRect))) { - HiLog::Debug(LABEL, "ParseRegion error"); + IMAGE_LOGD("ParseRegion error"); } } return ParseDecodeOptions2(env, root, opts, error); @@ -750,25 +753,25 @@ static std::string FileUrlToRawPath(const std::string &path) static void parseSourceOptions(napi_env env, napi_value root, SourceOptions* opts) { if (!ImageNapiUtils::GetInt32ByName(env, root, "sourceDensity", &(opts->baseDensity))) { - HiLog::Debug(LABEL, "no sourceDensity"); + IMAGE_LOGD("no sourceDensity"); } int32_t pixelFormat = 0; if (!ImageNapiUtils::GetInt32ByName(env, root, "sourcePixelFormat", &pixelFormat)) { - HiLog::Debug(LABEL, "no sourcePixelFormat"); + IMAGE_LOGD("no sourcePixelFormat"); } else { opts->pixelFormat = static_cast(pixelFormat); - HiLog::Info(LABEL, "sourcePixelFormat:%{public}d", static_cast(opts->pixelFormat)); + IMAGE_LOGI("sourcePixelFormat:%{public}d", static_cast(opts->pixelFormat)); } napi_value tmpValue = nullptr; if (!GET_NODE_BY_NAME(root, "sourceSize", tmpValue)) { - HiLog::Debug(LABEL, "no sourceSize"); + IMAGE_LOGD("no sourceSize"); } else { if (!ParseSize(env, tmpValue, &(opts->size))) { - HiLog::Debug(LABEL, "ParseSize error"); + IMAGE_LOGD("ParseSize error"); } - HiLog::Info(LABEL, "sourceSize:(%{public}d, %{public}d)", opts->size.width, opts->size.height); + IMAGE_LOGI("sourceSize:(%{public}d, %{public}d)", opts->size.width, opts->size.height); } } static void PrepareNapiEnv(napi_env env) @@ -795,11 +798,11 @@ static bool parseRawFileItem(napi_env env, napi_value argValue, std::string item { napi_value nItem; if (napi_get_named_property(env, argValue, item.c_str(), &nItem) != napi_ok) { - HiLog::Error(LABEL, "Failed to parse RawFileDescriptor item %{public}s", item.c_str()); + IMAGE_LOGE("Failed to parse RawFileDescriptor item %{public}s", item.c_str()); return false; } if (napi_get_value_int32(env, nItem, value) != napi_ok) { - HiLog::Error(LABEL, "Failed to get RawFileDescriptor item %{public}s value", item.c_str()); + IMAGE_LOGE("Failed to get RawFileDescriptor item %{public}s value", item.c_str()); return false; } return true; @@ -808,13 +811,13 @@ static bool parseRawFileItem(napi_env env, napi_value argValue, std::string item static bool isRawFileDescriptor(napi_env env, napi_value argValue, ImageSourceAsyncContext* context) { if (env == nullptr || argValue == nullptr || context == nullptr) { - HiLog::Error(LABEL, "isRawFileDescriptor invalid input"); + IMAGE_LOGE("isRawFileDescriptor invalid input"); return false; } if (!hasNamedProperty(env, argValue, "fd") || !hasNamedProperty(env, argValue, "offset") || !hasNamedProperty(env, argValue, "length")) { - HiLog::Error(LABEL, "RawFileDescriptor mismatch"); + IMAGE_LOGE("RawFileDescriptor mismatch"); return false; } if (parseRawFileItem(env, argValue, "fd", &(context->rawFileInfo.fd)) && @@ -823,7 +826,7 @@ static bool isRawFileDescriptor(napi_env env, napi_value argValue, ImageSourceAs return true; } - HiLog::Error(LABEL, "Failed to parse RawFileDescriptor item"); + IMAGE_LOGE("Failed to parse RawFileDescriptor item"); return false; } @@ -837,19 +840,19 @@ static std::unique_ptr CreateNativeImageSource(napi_env env, napi_v auto inputType = ImageNapiUtils::getType(env, argValue); if (napi_string == inputType) { // File Path if (!ImageNapiUtils::GetUtf8String(env, argValue, context->pathName)) { - HiLog::Error(LABEL, "fail to get pathName"); + IMAGE_LOGE("fail to get pathName"); return imageSource; } context->pathName = FileUrlToRawPath(context->pathName); context->pathNameLength = context->pathName.size(); - HiLog::Debug(LABEL, "pathName is [%{public}s]", context->pathName.c_str()); + IMAGE_LOGD("pathName is [%{public}s]", context->pathName.c_str()); imageSource = ImageSource::CreateImageSource(context->pathName, opts, errorCode); } else if (napi_number == inputType) { // Fd napi_get_value_int32(env, argValue, &context->fdIndex); - HiLog::Debug(LABEL, "CreateImageSource fdIndex is [%{public}d]", context->fdIndex); + IMAGE_LOGD("CreateImageSource fdIndex is [%{public}d]", context->fdIndex); imageSource = ImageSource::CreateImageSource(context->fdIndex, opts, errorCode); } else if (isRawFileDescriptor(env, argValue, context)) { - HiLog::Debug(LABEL, + IMAGE_LOGE( "CreateImageSource RawFileDescriptor fd: %{public}d, offset: %{public}d, length: %{public}d", context->rawFileInfo.fd, context->rawFileInfo.offset, context->rawFileInfo.length); int32_t fileSize = context->rawFileInfo.offset + context->rawFileInfo.length; @@ -862,7 +865,7 @@ static std::unique_ptr CreateNativeImageSource(napi_env env, napi_v status = napi_get_arraybuffer_info(env, argValue, &(context->sourceBuffer), &(context->sourceBufferSize)); if (status != napi_ok) { napi_delete_reference(env, arrayRef); - HiLog::Error(LABEL, "fail to get arraybufferinfo"); + IMAGE_LOGE("fail to get arraybufferinfo"); return nullptr; } imageSource = ImageSource::CreateImageSource(static_cast(context->sourceBuffer), @@ -883,7 +886,7 @@ napi_value ImageSourceNapi::CreateImageSource(napi_env env, napi_callback_info i napi_value argValue[NUM_2] = {0}; size_t argCount = 2; IMG_JS_ARGS(env, info, status, argCount, argValue, thisVar); - IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, HiLog::Error(LABEL, "fail to napi_get_cb_info")); + IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, IMAGE_LOGE("fail to napi_get_cb_info")); NAPI_ASSERT(env, argCount > 0, "No arg!"); std::unique_ptr asyncContext = std::make_unique(); @@ -894,7 +897,7 @@ napi_value ImageSourceNapi::CreateImageSource(napi_env env, napi_callback_info i std::unique_ptr imageSource = CreateNativeImageSource(env, argValue[NUM_0], opts, asyncContext.get()); if (imageSource == nullptr) { - HiLog::Error(LABEL, "CreateImageSourceExec error"); + IMAGE_LOGE("CreateImageSourceExec error"); napi_get_undefined(env, &result); return result; } @@ -910,7 +913,7 @@ napi_value ImageSourceNapi::CreateImageSource(napi_env env, napi_callback_info i status = napi_new_instance(env, constructor, NUM_0, nullptr, &result); } if (!IMG_IS_OK(status)) { - HiLog::Error(LABEL, "New instance could not be obtained"); + IMAGE_LOGE("New instance could not be obtained"); napi_get_undefined(env, &result); } return result; @@ -921,7 +924,7 @@ napi_value ImageSourceNapi::CreateImageSourceComplete(napi_env env, napi_status napi_value constructor = nullptr; napi_value result = nullptr; - HiLog::Debug(LABEL, "CreateImageSourceComplete IN"); + IMAGE_LOGD("CreateImageSourceComplete IN"); auto context = static_cast(data); if (context == nullptr) { return result; @@ -934,7 +937,7 @@ napi_value ImageSourceNapi::CreateImageSourceComplete(napi_env env, napi_status if (!IMG_IS_OK(status)) { context->status = ERROR; - HiLog::Error(LABEL, "New instance could not be obtained"); + IMAGE_LOGE("New instance could not be obtained"); napi_get_undefined(env, &result); } return result; @@ -957,13 +960,13 @@ napi_value ImageSourceNapi::CreateIncrementalSource(napi_env env, napi_callback_ napi_get_undefined(env, &result); napi_status status; - HiLog::Debug(LABEL, "CreateIncrementalSource IN"); + IMAGE_LOGD("CreateIncrementalSource IN"); napi_value thisVar = nullptr; napi_value argValue[NUM_2] = {0}; size_t argCount = NUM_2; IMG_JS_ARGS(env, info, status, argCount, argValue, thisVar); - IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, HiLog::Error(LABEL, "fail to napi_get_cb_info")); + IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, IMAGE_LOGE("fail to napi_get_cb_info")); uint32_t errorCode = 0; IncrementalSourceOptions incOpts; @@ -975,9 +978,9 @@ napi_value ImageSourceNapi::CreateIncrementalSource(napi_env env, napi_callback_ std::unique_ptr imageSource = ImageSource::CreateIncrementalImageSource(incOpts, errorCode); DecodeOptions decodeOpts; std::unique_ptr incPixelMap = imageSource->CreateIncrementalPixelMap(0, decodeOpts, errorCode); - HiLog::Debug(LABEL, "CreateIncrementalImageSource end"); + IMAGE_LOGD("CreateIncrementalImageSource end"); if (errorCode != SUCCESS) { - HiLog::Error(LABEL, "CreateIncrementalImageSource error"); + IMAGE_LOGE("CreateIncrementalImageSource error"); napi_get_undefined(env, &result); return result; } @@ -989,7 +992,7 @@ napi_value ImageSourceNapi::CreateIncrementalSource(napi_env env, napi_callback_ status = napi_new_instance(env, constructor, NUM_0, nullptr, &result); } if (!IMG_IS_OK(status)) { - HiLog::Error(LABEL, "New instance could not be obtained"); + IMAGE_LOGE("New instance could not be obtained"); napi_get_undefined(env, &result); } return result; @@ -1006,32 +1009,32 @@ napi_value ImageSourceNapi::GetImageInfo(napi_env env, napi_callback_info info) napi_value thisVar = nullptr; napi_value argValue[NUM_2] = {0}; size_t argCount = 2; - HiLog::Debug(LABEL, "GetImageInfo IN"); + IMAGE_LOGD("GetImageInfo IN"); IMG_JS_ARGS(env, info, status, argCount, argValue, thisVar); - HiLog::Debug(LABEL, "GetImageInfo argCount is [%{public}zu]", argCount); + IMAGE_LOGD("GetImageInfo argCount is [%{public}zu]", argCount); - IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, HiLog::Error(LABEL, "fail to napi_get_cb_info")); + IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, IMAGE_LOGE("fail to napi_get_cb_info")); std::unique_ptr asyncContext = std::make_unique(); status = napi_unwrap(env, thisVar, reinterpret_cast(&asyncContext->constructor_)); IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, asyncContext->constructor_), - nullptr, HiLog::Error(LABEL, "fail to unwrap context")); + nullptr, IMAGE_LOGE("fail to unwrap context")); asyncContext->rImageSource = asyncContext->constructor_->nativeImgSrc; IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, asyncContext->rImageSource), - nullptr, HiLog::Error(LABEL, "empty native pixelmap")); - HiLog::Debug(LABEL, "GetImageInfo argCount is [%{public}zu]", argCount); + nullptr, IMAGE_LOGE("empty native pixelmap")); + IMAGE_LOGD("GetImageInfo argCount is [%{public}zu]", argCount); if (argCount == NUM_1 && ImageNapiUtils::getType(env, argValue[NUM_0]) == napi_function) { - HiLog::Debug(LABEL, "GetImageInfo arg0 getType is [%{public}u]", ImageNapiUtils::getType(env, argValue[NUM_0])); + IMAGE_LOGD("GetImageInfo arg0 getType is [%{public}u]", ImageNapiUtils::getType(env, argValue[NUM_0])); napi_create_reference(env, argValue[NUM_0], refCount, &asyncContext->callbackRef); } else if (argCount == NUM_1 && ImageNapiUtils::getType(env, argValue[NUM_0]) == napi_number) { napi_get_value_uint32(env, argValue[NUM_0], &asyncContext->index); } else if (argCount == NUM_2 && ImageNapiUtils::getType(env, argValue[NUM_0]) == napi_number && ImageNapiUtils::getType(env, argValue[NUM_1]) == napi_function) { - HiLog::Debug(LABEL, "GetImageInfo arg0 getType is [%{public}u]", ImageNapiUtils::getType(env, argValue[NUM_0])); - HiLog::Debug(LABEL, "GetImageInfo arg1 getType is [%{public}u]", ImageNapiUtils::getType(env, argValue[NUM_1])); + IMAGE_LOGD("GetImageInfo arg0 getType is [%{public}u]", ImageNapiUtils::getType(env, argValue[NUM_0])); + IMAGE_LOGD("GetImageInfo arg1 getType is [%{public}u]", ImageNapiUtils::getType(env, argValue[NUM_1])); napi_get_value_uint32(env, argValue[NUM_0], &asyncContext->index); napi_create_reference(env, argValue[NUM_1], refCount, &asyncContext->callbackRef); } @@ -1050,43 +1053,43 @@ napi_value ImageSourceNapi::GetImageInfo(napi_env env, napi_callback_info info) }, GetImageInfoComplete, asyncContext, asyncContext->work); IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), - nullptr, HiLog::Error(LABEL, "fail to create async work")); + nullptr, IMAGE_LOGE("fail to create async work")); return result; } static void CreatePixelMapExecute(napi_env env, void *data) { - HiLog::Debug(LABEL, "CreatePixelMapExecute IN"); + IMAGE_LOGD("CreatePixelMapExecute IN"); if (data == nullptr) { - HiLog::Error(LABEL, "data is nullptr"); + IMAGE_LOGE("data is nullptr"); return; } uint32_t errorCode = 0; auto context = static_cast(data); if (context == nullptr) { - HiLog::Error(LABEL, "empty context"); + IMAGE_LOGE("empty context"); return; } if (context->errMsg.size() > 0) { - HiLog::Error(LABEL, "mismatch args"); + IMAGE_LOGE("mismatch args"); context->status = ERROR; return; } if (context->rImageSource == nullptr) { - HiLog::Error(LABEL, "empty context rImageSource"); + IMAGE_LOGE("empty context rImageSource"); return; } if (context->constructor_ != nullptr) { auto incPixelMap = context->constructor_->GetIncrementalPixelMap(); if (incPixelMap != nullptr) { - HiLog::Info(LABEL, "Get Incremental PixelMap!!!"); + IMAGE_LOGI("Get Incremental PixelMap!!!"); context->rPixelMap = incPixelMap; } } else { - HiLog::Info(LABEL, "Create PixelMap!!!"); + IMAGE_LOGI("Create PixelMap!!!"); } if (context->rPixelMap == nullptr) { int index = (context->index >= NUM_0) ? context->index : NUM_0; @@ -1098,14 +1101,14 @@ static void CreatePixelMapExecute(napi_env env, void *data) } else { context->status = ERROR; context->errMsg = "Create PixelMap error"; - HiLog::Error(LABEL, "Create PixelMap error"); + IMAGE_LOGE("Create PixelMap error"); } - HiLog::Debug(LABEL, "CreatePixelMapExecute OUT"); + IMAGE_LOGD("CreatePixelMapExecute OUT"); } static void CreatePixelMapComplete(napi_env env, napi_status status, void *data) { - HiLog::Debug(LABEL, "CreatePixelMapComplete IN"); + IMAGE_LOGD("CreatePixelMapComplete IN"); napi_value result = nullptr; auto context = static_cast(data); @@ -1114,7 +1117,7 @@ static void CreatePixelMapComplete(napi_env env, napi_status status, void *data) } else { napi_get_undefined(env, &result); } - HiLog::Debug(LABEL, "CreatePixelMapComplete OUT"); + IMAGE_LOGD("CreatePixelMapComplete OUT"); ImageSourceCallbackRoutine(env, context, result); } @@ -1129,34 +1132,34 @@ napi_value ImageSourceNapi::CreatePixelMap(napi_env env, napi_callback_info info napi_value argValue[NUM_2] = {0}; size_t argCount = NUM_2; IMG_JS_ARGS(env, info, status, argCount, argValue, thisVar); - IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, thisVar), nullptr, HiLog::Error(LABEL, "fail to get thisVar")); - IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, HiLog::Error(LABEL, "fail to napi_get_cb_info")); + IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, thisVar), nullptr, IMAGE_LOGE("fail to get thisVar")); + IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, IMAGE_LOGE("fail to napi_get_cb_info")); std::unique_ptr asyncContext = std::make_unique(); status = napi_unwrap(env, thisVar, reinterpret_cast(&asyncContext->constructor_)); IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, asyncContext->constructor_), - nullptr, HiLog::Error(LABEL, "fail to unwrap context")); + nullptr, IMAGE_LOGE("fail to unwrap context")); IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, asyncContext->constructor_->nativeImgSrc), - nullptr, HiLog::Error(LABEL, "fail to unwrap nativeImgSrc")); + nullptr, IMAGE_LOGE("fail to unwrap nativeImgSrc")); asyncContext->rImageSource = asyncContext->constructor_->nativeImgSrc; IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, asyncContext->rImageSource), - nullptr, HiLog::Error(LABEL, "empty native rImageSource")); + nullptr, IMAGE_LOGE("empty native rImageSource")); if (argCount == NUM_0) { - HiLog::Debug(LABEL, "CreatePixelMap with no arg"); + IMAGE_LOGD("CreatePixelMap with no arg"); } else if (argCount == NUM_1 || argCount == NUM_2) { if (ImageNapiUtils::getType(env, argValue[NUM_0]) == napi_object) { if (!ParseDecodeOptions(env, argValue[NUM_0], &(asyncContext->decodeOpts), &(asyncContext->index), asyncContext->errMsg)) { - HiLog::Error(LABEL, "DecodeOptions mismatch"); + IMAGE_LOGE("DecodeOptions mismatch"); } } if (ImageNapiUtils::getType(env, argValue[argCount - 1]) == napi_function) { napi_create_reference(env, argValue[argCount - 1], refCount, &asyncContext->callbackRef); } } else { - HiLog::Error(LABEL, "argCount mismatch"); + IMAGE_LOGE("argCount mismatch"); return result; } if (asyncContext->callbackRef == nullptr) { @@ -1170,7 +1173,7 @@ napi_value ImageSourceNapi::CreatePixelMap(napi_env env, napi_callback_info info 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")); + nullptr, IMAGE_LOGE("fail to create async work")); return result; } @@ -1178,11 +1181,11 @@ static bool ParsePropertyOptions(napi_env env, napi_value root, ImageSourceAsync { napi_value tmpValue = nullptr; if (!GET_UINT32_BY_NAME(root, "index", context->index)) { - HiLog::Debug(LABEL, "no index"); + IMAGE_LOGD("no index"); return false; } if (!GET_NODE_BY_NAME(root, "defaultValue", tmpValue)) { - HiLog::Debug(LABEL, "no defaultValue"); + IMAGE_LOGD("no defaultValue"); } else { if (tmpValue != nullptr) { context->defaultValueStr = GetStringArgument(env, tmpValue); @@ -1194,7 +1197,7 @@ static bool ParsePropertyOptions(napi_env env, napi_value root, ImageSourceAsync static void ModifyImagePropertyComplete(napi_env env, napi_status status, ImageSourceAsyncContext *context) { if (context == nullptr) { - HiLog::Error(LABEL, "context is nullptr"); + IMAGE_LOGE("context is nullptr"); return; } @@ -1225,7 +1228,7 @@ static void ModifyImagePropertyComplete(napi_env env, napi_status status, ImageS napi_reject_deferred(env, context->deferred, result[NUM_0]); } } else { - HiLog::Debug(LABEL, "call callback function"); + IMAGE_LOGD("call callback function"); napi_get_reference_value(env, context->callbackRef, &callback); napi_call_function(env, nullptr, callback, NUM_2, result, &retVal); napi_delete_reference(env, context->callbackRef); @@ -1240,7 +1243,7 @@ static void ModifyImagePropertyComplete(napi_env env, napi_status status, ImageS static void GetImagePropertyComplete(napi_env env, napi_status status, ImageSourceAsyncContext *context) { if (context == nullptr) { - HiLog::Error(LABEL, "context is nullptr"); + IMAGE_LOGE("context is nullptr"); return; } @@ -1274,7 +1277,7 @@ static void GetImagePropertyComplete(napi_env env, napi_status status, ImageSour napi_reject_deferred(env, context->deferred, result[NUM_0]); } } else { - HiLog::Debug(LABEL, "call callback function"); + IMAGE_LOGD("call callback function"); napi_get_reference_value(env, context->callbackRef, &callback); napi_call_function(env, nullptr, callback, NUM_2, result, &retVal); napi_delete_reference(env, context->callbackRef); @@ -1293,35 +1296,35 @@ static std::unique_ptr UnwrapContext(napi_env env, napi napi_value argValue[NUM_3] = {0}; size_t argCount = NUM_3; IMG_JS_ARGS(env, info, status, argCount, argValue, thisVar); - HiLog::Debug(LABEL, "GetImageProperty argCount is [%{public}zu]", argCount); + IMAGE_LOGD("GetImageProperty argCount is [%{public}zu]", argCount); - IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, HiLog::Error(LABEL, "fail to napi_get_cb_info")); + IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, IMAGE_LOGE("fail to napi_get_cb_info")); std::unique_ptr context = std::make_unique(); status = napi_unwrap(env, thisVar, reinterpret_cast(&context->constructor_)); IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, context->constructor_), - nullptr, HiLog::Error(LABEL, "fail to unwrap context")); + nullptr, IMAGE_LOGE("fail to unwrap context")); context->rImageSource = context->constructor_->nativeImgSrc; IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, context->rImageSource), - nullptr, HiLog::Error(LABEL, "empty native rImageSource")); + nullptr, IMAGE_LOGE("empty native rImageSource")); if (argCount < NUM_1 || argCount > NUM_3) { - HiLog::Error(LABEL, "argCount mismatch"); + IMAGE_LOGE("argCount mismatch"); return nullptr; } if (ImageNapiUtils::getType(env, argValue[NUM_0]) == napi_string) { context->keyStr = GetStringArgument(env, argValue[NUM_0]); } else { - HiLog::Error(LABEL, "arg 0 type mismatch"); + IMAGE_LOGE("arg 0 type mismatch"); return nullptr; } if (argCount == NUM_2 || argCount == NUM_3) { if (ImageNapiUtils::getType(env, argValue[NUM_1]) == napi_object) { IMG_NAPI_CHECK_RET_D(ParsePropertyOptions(env, argValue[NUM_1], context.get()), - nullptr, HiLog::Error(LABEL, "PropertyOptions mismatch")); + nullptr, IMAGE_LOGE("PropertyOptions mismatch")); } if (ImageNapiUtils::getType(env, argValue[argCount - 1]) == napi_function) { napi_create_reference(env, argValue[argCount - 1], refCount, &context->callbackRef); @@ -1413,40 +1416,40 @@ static std::unique_ptr UnwrapContextForModify(napi_env napi_value argValue[NUM_4] = {0}; size_t argCount = NUM_4; IMG_JS_ARGS(env, info, status, argCount, argValue, thisVar); - HiLog::Debug(LABEL, "UnwrapContextForModify argCount is [%{public}zu]", argCount); + IMAGE_LOGD("UnwrapContextForModify argCount is [%{public}zu]", argCount); - IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, HiLog::Error(LABEL, "fail to napi_get_cb_info")); + IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, IMAGE_LOGE("fail to napi_get_cb_info")); std::unique_ptr context = std::make_unique(); status = napi_unwrap(env, thisVar, reinterpret_cast(&context->constructor_)); IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, context->constructor_), - nullptr, HiLog::Error(LABEL, "fail to unwrap context")); + nullptr, IMAGE_LOGE("fail to unwrap context")); context->rImageSource = context->constructor_->nativeImgSrc; IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, context->rImageSource), - nullptr, HiLog::Error(LABEL, "empty native rImageSource")); + nullptr, IMAGE_LOGE("empty native rImageSource")); if (argCount < NUM_1 || argCount > NUM_4) { - HiLog::Error(LABEL, "argCount mismatch"); + IMAGE_LOGE("argCount mismatch"); return nullptr; } if (ImageNapiUtils::getType(env, argValue[NUM_0]) == napi_string) { context->keyStr = GetStringArgument(env, argValue[NUM_0]); } else { - HiLog::Error(LABEL, "arg 0 type mismatch"); + IMAGE_LOGE("arg 0 type mismatch"); return nullptr; } if (ImageNapiUtils::getType(env, argValue[NUM_1]) == napi_string) { context->valueStr = GetStringArgument(env, argValue[NUM_1]); } else { - HiLog::Error(LABEL, "arg 1 type mismatch"); + IMAGE_LOGE("arg 1 type mismatch"); return nullptr; } if (argCount == NUM_3 || argCount == NUM_4) { if (ImageNapiUtils::getType(env, argValue[NUM_2]) == napi_object) { IMG_NAPI_CHECK_RET_D(ParsePropertyOptions(env, argValue[NUM_2], context.get()), - nullptr, HiLog::Error(LABEL, "PropertyOptions mismatch")); + nullptr, IMAGE_LOGE("PropertyOptions mismatch")); } if (ImageNapiUtils::getType(env, argValue[argCount - 1]) == napi_function) { napi_create_reference(env, argValue[argCount - 1], refCount, &context->callbackRef); @@ -1481,7 +1484,7 @@ napi_value ImageSourceNapi::ModifyImageProperty(napi_env env, napi_callback_info auto context = static_cast(data); if (!CheckExifDataValue(context->keyStr, context->valueStr, context->errMsg)) { - HiLog::Error(LABEL, "There is invalid exif data parameter"); + IMAGE_LOGE("There is invalid exif data parameter"); context->status = ERR_MEDIA_VALUE_INVALID; return; } @@ -1496,7 +1499,7 @@ napi_value ImageSourceNapi::ModifyImageProperty(napi_env env, napi_callback_info context->keyStr, context->valueStr, static_cast(context->sourceBuffer), context->sourceBufferSize); } else { - HiLog::Error(LABEL, "There is no image source!"); + IMAGE_LOGE("There is no image source!"); } }, reinterpret_cast(ModifyImagePropertyComplete), @@ -1504,7 +1507,7 @@ napi_value ImageSourceNapi::ModifyImageProperty(napi_env env, napi_callback_info asyncContext->work); IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), - nullptr, HiLog::Error(LABEL, "fail to create async work")); + nullptr, IMAGE_LOGE("fail to create async work")); return result; } @@ -1538,7 +1541,7 @@ napi_value ImageSourceNapi::GetImageProperty(napi_env env, napi_callback_info in asyncContext->work); IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), - nullptr, HiLog::Error(LABEL, "fail to create async work")); + nullptr, IMAGE_LOGE("fail to create async work")); return result; } @@ -1562,7 +1565,7 @@ static void UpdateDataExecute(napi_env env, void *data) uint8_t decodeProgress = 0; uint32_t err = incPixelMap->PromoteDecoding(decodeProgress); if (!(err == SUCCESS || (err == ERR_IMAGE_SOURCE_DATA_INCOMPLETE && !context->isCompleted))) { - HiLog::Error(LABEL, "UpdateData PromoteDecoding error"); + IMAGE_LOGE("UpdateData PromoteDecoding error"); context->isSuccess = false; } if (context->isCompleted) { @@ -1587,7 +1590,7 @@ static bool isNapiTypedArray(napi_env env, napi_value val) { bool res = false; napi_is_typedarray(env, val, &res); - HiLog::Debug(LABEL, "isNapiTypedArray %{public}d", res); + IMAGE_LOGD("isNapiTypedArray %{public}d", res); return res; } @@ -1602,23 +1605,23 @@ napi_value ImageSourceNapi::UpdateData(napi_env env, napi_callback_info info) napi_value argValue[NUM_5] = {0}; size_t argCount = 5; IMG_JS_ARGS(env, info, status, argCount, argValue, thisVar); - HiLog::Debug(LABEL, "UpdateData argCount is [%{public}zu]", argCount); + IMAGE_LOGD("UpdateData argCount is [%{public}zu]", argCount); - IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, HiLog::Error(LABEL, "fail to napi_get_cb_info")); + IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, IMAGE_LOGE("fail to napi_get_cb_info")); std::unique_ptr asyncContext = std::make_unique(); status = napi_unwrap(env, thisVar, reinterpret_cast(&asyncContext->constructor_)); IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, asyncContext->constructor_), - nullptr, HiLog::Error(LABEL, "fail to unwrap context")); + nullptr, IMAGE_LOGE("fail to unwrap context")); asyncContext->rImageSource = asyncContext->constructor_->nativeImgSrc; IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, asyncContext->rImageSource), - nullptr, HiLog::Error(LABEL, "empty native rImageSource")); - HiLog::Debug(LABEL, "UpdateData argCount %{public}zu", argCount); + nullptr, IMAGE_LOGE("empty native rImageSource")); + IMAGE_LOGD("UpdateData argCount %{public}zu", argCount); if (argCount > NUM_0 && isNapiTypedArray(env, argValue[NUM_0])) { - HiLog::Info(LABEL, "UpdateData napi_get_arraybuffer_info "); + IMAGE_LOGI("UpdateData napi_get_arraybuffer_info "); napi_typedarray_type type; napi_value arraybuffer; size_t offset; @@ -1634,17 +1637,17 @@ napi_value ImageSourceNapi::UpdateData(napi_env env, napi_callback_info info) if (argCount >= NUM_3 && ImageNapiUtils::getType(env, argValue[NUM_2]) == napi_number) { asyncContext->updataBufferOffset = 0; status = napi_get_value_uint32(env, argValue[NUM_2], &(asyncContext->updataBufferOffset)); - HiLog::Debug(LABEL, "asyncContext->updataBufferOffset is [%{public}u]", asyncContext->updataBufferOffset); + IMAGE_LOGD("asyncContext->updataBufferOffset is [%{public}u]", asyncContext->updataBufferOffset); } if (argCount >= NUM_4 && ImageNapiUtils::getType(env, argValue[NUM_3]) == napi_number) { asyncContext->updataLength = 0; status = napi_get_value_uint32(env, argValue[NUM_3], &(asyncContext->updataLength)); - HiLog::Debug(LABEL, "asyncContext->updataLength is [%{public}u]", asyncContext->updataLength); + IMAGE_LOGD("asyncContext->updataLength is [%{public}u]", asyncContext->updataLength); } if (!IMG_IS_OK(status)) { - HiLog::Error(LABEL, "fail to UpdateData"); + IMAGE_LOGE("fail to UpdateData"); napi_get_undefined(env, &result); return result; } @@ -1667,7 +1670,7 @@ napi_value ImageSourceNapi::UpdateData(napi_env env, napi_callback_info info) UpdateDataExecute, UpdateDataComplete, asyncContext, asyncContext->work); IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), - nullptr, HiLog::Error(LABEL, "fail to create async work")); + nullptr, IMAGE_LOGE("fail to create async work")); return result; } @@ -1684,7 +1687,7 @@ static void ReleaseComplete(napi_env env, napi_status status, void *data) napi_value ImageSourceNapi::Release(napi_env env, napi_callback_info info) { - HiLog::Debug(LABEL, "Release enter"); + IMAGE_LOGD("Release enter"); napi_value result = nullptr; napi_get_undefined(env, &result); @@ -1695,16 +1698,16 @@ napi_value ImageSourceNapi::Release(napi_env env, napi_callback_info info) size_t argCount = 1; IMG_JS_ARGS(env, info, status, argCount, argValue, thisVar); - HiLog::Debug(LABEL, "Release argCount is [%{public}zu]", argCount); - IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), result, HiLog::Error(LABEL, "fail to napi_get_cb_info")); + IMAGE_LOGD("Release argCount is [%{public}zu]", argCount); + IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), result, IMAGE_LOGE("fail to napi_get_cb_info")); std::unique_ptr asyncContext = std::make_unique(); status = napi_remove_wrap(env, thisVar, reinterpret_cast(&asyncContext->constructor_)); IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, asyncContext->constructor_), result, - HiLog::Error(LABEL, "fail to unwrap context")); + IMAGE_LOGE("fail to unwrap context")); - HiLog::Debug(LABEL, "Release argCount is [%{public}zu]", argCount); + IMAGE_LOGD("Release argCount is [%{public}zu]", argCount); if (argCount == 1 && ImageNapiUtils::getType(env, argValue[NUM_0]) == napi_function) { napi_create_reference(env, argValue[NUM_0], refCount, &asyncContext->callbackRef); } @@ -1715,7 +1718,7 @@ napi_value ImageSourceNapi::Release(napi_env env, napi_callback_info info) IMG_CREATE_CREATE_ASYNC_WORK(env, status, "Release", [](napi_env env, void *data) {}, ReleaseComplete, asyncContext, asyncContext->work); - HiLog::Debug(LABEL, "Release exit"); + IMAGE_LOGD("Release exit"); return result; } @@ -1738,37 +1741,37 @@ static std::unique_ptr UnwrapContextForList(napi_env en size_t argCount = NUM_3; IMG_JS_ARGS(env, info, status, argCount, argValue, thisVar); - HiLog::Debug(LABEL, "UnwrapContextForList argCount is [%{public}zu]", argCount); + IMAGE_LOGD("UnwrapContextForList argCount is [%{public}zu]", argCount); - IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, HiLog::Error(LABEL, "fail to napi_get_cb_info")); + IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, IMAGE_LOGE("fail to napi_get_cb_info")); std::unique_ptr context = std::make_unique(); status = napi_unwrap(env, thisVar, reinterpret_cast(&context->constructor_)); IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, context->constructor_), - nullptr, HiLog::Error(LABEL, "fail to unwrap context")); + nullptr, IMAGE_LOGE("fail to unwrap context")); context->rImageSource = context->constructor_->nativeImgSrc; IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, context->rImageSource), - nullptr, HiLog::Error(LABEL, "empty native rImageSource")); + nullptr, IMAGE_LOGE("empty native rImageSource")); if (argCount > NUM_2) { - HiLog::Error(LABEL, "argCount mismatch"); + IMAGE_LOGE("argCount mismatch"); return nullptr; } if (argCount > NUM_0) { if (ImageNapiUtils::getType(env, argValue[NUM_0]) == napi_object) { - HiLog::Debug(LABEL, "UnwrapContextForList object"); + IMAGE_LOGD("UnwrapContextForList object"); if (!ParseDecodeOptions(env, argValue[NUM_0], &(context->decodeOpts), &(context->index), context->errMsg)) { - HiLog::Error(LABEL, "DecodeOptions mismatch"); + IMAGE_LOGE("DecodeOptions mismatch"); } } if (ImageNapiUtils::getType(env, argValue[argCount - 1]) == napi_function) { - HiLog::Debug(LABEL, "UnwrapContextForList function"); + IMAGE_LOGD("UnwrapContextForList function"); napi_create_reference(env, argValue[argCount - 1], refCount, &context->callbackRef); } } @@ -1779,19 +1782,19 @@ static std::unique_ptr UnwrapContextForList(napi_env en static ImageSourceAsyncContext* CheckAsyncContext(ImageSourceAsyncContext* context, bool check) { if (context == nullptr) { - HiLog::Error(LABEL, "context is nullptr"); + IMAGE_LOGE("context is nullptr"); return nullptr; } if (check) { if (context->errMsg.size() > 0) { - HiLog::Error(LABEL, "mismatch args"); + IMAGE_LOGE("mismatch args"); context->status = ERROR; return nullptr; } if (context->rImageSource == nullptr) { - HiLog::Error(LABEL, "empty context rImageSource"); + IMAGE_LOGE("empty context rImageSource"); context->status = ERROR; return nullptr; } @@ -1803,13 +1806,13 @@ static ImageSourceAsyncContext* CheckAsyncContext(ImageSourceAsyncContext* conte STATIC_EXEC_FUNC(CreatePixelMapList) { if (data == nullptr) { - HiLog::Error(LABEL, "data is nullptr"); + IMAGE_LOGE("data is nullptr"); return; } auto context = CheckAsyncContext(static_cast(data), true); if (context == nullptr) { - HiLog::Error(LABEL, "check async context fail"); + IMAGE_LOGE("check async context fail"); return; } @@ -1822,7 +1825,7 @@ STATIC_EXEC_FUNC(CreatePixelMapList) if ((errorCode == SUCCESS) && IMG_NOT_NULL(context->pixelMaps)) { context->status = SUCCESS; } else { - HiLog::Error(LABEL, "Create PixelMap List error, error=%{public}u", errorCode); + IMAGE_LOGE("Create PixelMap List error, error=%{public}u", errorCode); context->errMsg = "Create PixelMap List error"; context->status = (errorCode != SUCCESS) ? errorCode : ERROR; } @@ -1831,19 +1834,19 @@ STATIC_EXEC_FUNC(CreatePixelMapList) STATIC_COMPLETE_FUNC(CreatePixelMapList) { if (data == nullptr) { - HiLog::Error(LABEL, "data is nullptr"); + IMAGE_LOGE("data is nullptr"); return; } auto context = CheckAsyncContext(static_cast(data), false); if (context == nullptr) { - HiLog::Error(LABEL, "check async context fail"); + IMAGE_LOGE("check async context fail"); return; } napi_value result = nullptr; if ((context->status == SUCCESS) && IMG_NOT_NULL(context->pixelMaps)) { - HiLog::Debug(LABEL, "CreatePixelMapListComplete array"); + IMAGE_LOGD("CreatePixelMapListComplete array"); napi_create_array(env, &result); size_t i = 0; for (auto &pixelMap : *context->pixelMaps.get()) { @@ -1852,11 +1855,11 @@ STATIC_COMPLETE_FUNC(CreatePixelMapList) i++; } } else { - HiLog::Debug(LABEL, "CreatePixelMapListComplete undefined"); + IMAGE_LOGD("CreatePixelMapListComplete undefined"); napi_get_undefined(env, &result); } - HiLog::Debug(LABEL, "CreatePixelMapListComplete set to nullptr"); + IMAGE_LOGD("CreatePixelMapListComplete set to nullptr"); context->pixelMaps = nullptr; ImageSourceCallbackWithErrorObj(env, context, result); @@ -1885,7 +1888,7 @@ napi_value ImageSourceNapi::CreatePixelMapList(napi_env env, napi_callback_info napi_status status; 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")); + IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, IMAGE_LOGE("fail to create async work")); return result; } @@ -1893,13 +1896,13 @@ napi_value ImageSourceNapi::CreatePixelMapList(napi_env env, napi_callback_info STATIC_EXEC_FUNC(GetDelayTime) { if (data == nullptr) { - HiLog::Error(LABEL, "data is nullptr"); + IMAGE_LOGE("data is nullptr"); return; } auto context = CheckAsyncContext(static_cast(data), true); if (context == nullptr) { - HiLog::Error(LABEL, "check async context fail"); + IMAGE_LOGE("check async context fail"); return; } @@ -1908,7 +1911,7 @@ STATIC_EXEC_FUNC(GetDelayTime) if ((errorCode == SUCCESS) && IMG_NOT_NULL(context->delayTimes)) { context->status = SUCCESS; } else { - HiLog::Error(LABEL, "Get DelayTime error, error=%{public}u", errorCode); + IMAGE_LOGE("Get DelayTime error, error=%{public}u", errorCode); context->errMsg = "Get DelayTime error"; context->status = (errorCode != SUCCESS) ? errorCode : ERROR; } @@ -1917,19 +1920,19 @@ STATIC_EXEC_FUNC(GetDelayTime) STATIC_COMPLETE_FUNC(GetDelayTime) { if (data == nullptr) { - HiLog::Error(LABEL, "data is nullptr"); + IMAGE_LOGE("data is nullptr"); return; } auto context = CheckAsyncContext(static_cast(data), false); if (context == nullptr) { - HiLog::Error(LABEL, "check async context fail"); + IMAGE_LOGE("check async context fail"); return; } napi_value result = nullptr; if (context->status == SUCCESS && IMG_NOT_NULL(context->delayTimes)) { - HiLog::Debug(LABEL, "GetDelayTimeComplete array"); + IMAGE_LOGD("GetDelayTimeComplete array"); napi_create_array(env, &result); size_t i = 0; for (auto delayTime : *context->delayTimes) { @@ -1939,11 +1942,11 @@ STATIC_COMPLETE_FUNC(GetDelayTime) i++; } } else { - HiLog::Debug(LABEL, "GetDelayTimeComplete undefined"); + IMAGE_LOGD("GetDelayTimeComplete undefined"); napi_get_undefined(env, &result); } - HiLog::Debug(LABEL, "GetDelayTimeComplete set to nullptr"); + IMAGE_LOGD("GetDelayTimeComplete set to nullptr"); context->delayTimes = nullptr; ImageSourceCallbackWithErrorObj(env, context, result); } @@ -1969,7 +1972,7 @@ napi_value ImageSourceNapi::GetDelayTime(napi_env env, napi_callback_info info) napi_status status; IMG_CREATE_CREATE_ASYNC_WORK(env, status, "GetDelayTime", GetDelayTimeExec, GetDelayTimeComplete, asyncContext, asyncContext->work); - IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, HiLog::Error(LABEL, "fail to create async work")); + IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, IMAGE_LOGE("fail to create async work")); return result; } @@ -1977,23 +1980,23 @@ napi_value ImageSourceNapi::GetDelayTime(napi_env env, napi_callback_info info) STATIC_EXEC_FUNC(GetFrameCount) { if (data == nullptr) { - HiLog::Error(LABEL, "data is nullptr"); + IMAGE_LOGE("data is nullptr"); return; } auto context = CheckAsyncContext(static_cast(data), true); if (context == nullptr) { - HiLog::Error(LABEL, "check async context fail"); + IMAGE_LOGE("check async context fail"); return; } uint32_t errorCode = 0; context->frameCount = context->rImageSource->GetFrameCount(errorCode); - HiLog::Debug(LABEL, "GetFrameCountExec count=%{public}u, error=%{public}u", context->frameCount, errorCode); + IMAGE_LOGD("GetFrameCountExec count=%{public}u, error=%{public}u", context->frameCount, errorCode); if (errorCode == SUCCESS) { context->status = SUCCESS; } else { - HiLog::Error(LABEL, "Get FrameCount error, error=%{public}u", errorCode); + IMAGE_LOGE("Get FrameCount error, error=%{public}u", errorCode); context->errMsg = "Get FrameCount error"; context->status = errorCode; } @@ -2002,22 +2005,22 @@ STATIC_EXEC_FUNC(GetFrameCount) STATIC_COMPLETE_FUNC(GetFrameCount) { if (data == nullptr) { - HiLog::Error(LABEL, "data is nullptr"); + IMAGE_LOGE("data is nullptr"); return; } auto context = CheckAsyncContext(static_cast(data), false); if (context == nullptr) { - HiLog::Error(LABEL, "check async context fail"); + IMAGE_LOGE("check async context fail"); return; } napi_value result = nullptr; if (context->status == SUCCESS) { - HiLog::Debug(LABEL, "GetFrameCountComplete uint"); + IMAGE_LOGD("GetFrameCountComplete uint"); napi_create_uint32(env, context->frameCount, &result); } else { - HiLog::Debug(LABEL, "GetFrameCountComplete undefined"); + IMAGE_LOGD("GetFrameCountComplete undefined"); napi_get_undefined(env, &result); } @@ -2046,7 +2049,7 @@ napi_value ImageSourceNapi::GetFrameCount(napi_env env, napi_callback_info info) napi_status status; IMG_CREATE_CREATE_ASYNC_WORK(env, status, "GetFrameCount", GetFrameCountExec, GetFrameCountComplete, asyncContext, asyncContext->work); - IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, HiLog::Error(LABEL, "fail to create async work")); + IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, IMAGE_LOGE("fail to create async work")); return result; } @@ -2063,7 +2066,7 @@ int32_t ImageSourceNapi::CreateImageSourceNapi(napi_env env, napi_value* result) } if (status != napi_ok || result == nullptr) { - HiLog::Error(LABEL, "CreateImageSourceNapi new instance failed"); + IMAGE_LOGE("CreateImageSourceNapi new instance failed"); napi_get_undefined(env, result); return ERR_IMAGE_DATA_ABNORMAL; } diff --git a/frameworks/kits/js/common/include/image_napi_utils.h b/frameworks/kits/js/common/include/image_napi_utils.h index c11016986..4757a8198 100644 --- a/frameworks/kits/js/common/include/image_napi_utils.h +++ b/frameworks/kits/js/common/include/image_napi_utils.h @@ -110,17 +110,17 @@ do \ #define DECORATOR_HILOG(op, fmt, args...) \ do { \ - op(LABEL, fmt, ##args); \ + op(LOG_CORE, fmt, ##args); \ } while (0) -#define IMAGE_ERR(fmt, ...) DECORATOR_HILOG(HiLog::Error, fmt, ##__VA_ARGS__) +#define IMAGE_ERR(fmt, ...) DECORATOR_HILOG(HILOG_ERROR, fmt, ##__VA_ARGS__) #ifdef IMAGE_DEBUG_FLAG -#define IMAGE_INFO(fmt, ...) DECORATOR_HILOG(HiLog::Info, fmt, ##__VA_ARGS__) -#define IMAGE_DEBUG(fmt, ...) DECORATOR_HILOG(HiLog::Debug, fmt, ##__VA_ARGS__) -#define IMAGE_FUNCTION_IN(fmt, ...) DECORATOR_HILOG(HiLog::Debug, fmt "%{public}s IN", __FUNCTION__, ##__VA_ARGS__) -#define IMAGE_FUNCTION_OUT(fmt, ...) DECORATOR_HILOG(HiLog::Debug, fmt "%{public}s OUT", __FUNCTION__, ##__VA_ARGS__) -#define IMAGE_LINE_IN(fmt, ...) DECORATOR_HILOG(HiLog::Debug, fmt "%{public}d IN", __LINE__, ##__VA_ARGS__) -#define IMAGE_LINE_OUT(fmt, ...) DECORATOR_HILOG(HiLog::Debug, fmt "%{public}d OUT", __LINE__, ##__VA_ARGS__) +#define IMAGE_INFO(fmt, ...) DECORATOR_HILOG(HILOG_INFO, fmt, ##__VA_ARGS__) +#define IMAGE_DEBUG(fmt, ...) DECORATOR_HILOG(HILOG_DEBUG, fmt, ##__VA_ARGS__) +#define IMAGE_FUNCTION_IN(fmt, ...) DECORATOR_HILOG(HILOG_DEBUG, fmt "%{public}s IN", ##__VA_ARGS__, __FUNCTION__) +#define IMAGE_FUNCTION_OUT(fmt, ...) DECORATOR_HILOG(HILOG_DEBUG, fmt "%{public}s OUT", ##__VA_ARGS__, __FUNCTION__) +#define IMAGE_LINE_IN(fmt, ...) DECORATOR_HILOG(HILOG_DEBUG, fmt "%{public}d IN", ##__VA_ARGS__, __LINE__) +#define IMAGE_LINE_OUT(fmt, ...) DECORATOR_HILOG(HILOG_DEBUG, fmt "%{public}d OUT", ##__VA_ARGS__, __LINE__) #else #define IMAGE_INFO(fmt, ...) #define IMAGE_DEBUG(fmt, ...) diff --git a/frameworks/kits/js/common/native_module_ohos_image.cpp b/frameworks/kits/js/common/native_module_ohos_image.cpp index 6c1a7d8b3..f965d8e7c 100644 --- a/frameworks/kits/js/common/native_module_ohos_image.cpp +++ b/frameworks/kits/js/common/native_module_ohos_image.cpp @@ -14,13 +14,15 @@ */ #include "native_module_ohos_image.h" -#include "hilog/log.h" -#include "log_tags.h" -using OHOS::HiviewDFX::HiLog; -namespace { - constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "NAPITEST"}; -} +#include "image_log.h" + +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "NAPITEST" + namespace OHOS { namespace Media{ /* @@ -28,18 +30,18 @@ namespace Media{ */ static napi_value Export(napi_env env, napi_value exports) { - HiLog::Info(LABEL, "ImagePackerNapi CALL"); + IMAGE_LOGD("ImagePackerNapi CALL"); ImagePackerNapi::Init(env, exports); - HiLog::Info(LABEL, "PixelMapNapi CALL"); + IMAGE_LOGD("PixelMapNapi CALL"); PixelMapNapi::Init(env, exports); - HiLog::Info(LABEL, "ImageSourceNapi CALL"); + IMAGE_LOGD("ImageSourceNapi CALL"); ImageSourceNapi::Init(env, exports); #if !defined(IOS_PLATFORM) && !defined(A_PLATFORM) - HiLog::Info(LABEL, "ImageReceiverNapi CALL"); + IMAGE_LOGD("ImageReceiverNapi CALL"); ImageReceiverNapi::Init(env, exports); - HiLog::Info(LABEL, "ImageCreatorNapi CALL"); + IMAGE_LOGD("ImageCreatorNapi CALL"); ImageCreatorNapi::Init(env, exports); - HiLog::Info(LABEL, "ImageNapi CALL"); + IMAGE_LOGD("ImageNapi CALL"); ImageNapi::Init(env, exports); #endif return exports; diff --git a/frameworks/kits/js/common/pixel_map_napi.cpp b/frameworks/kits/js/common/pixel_map_napi.cpp index 9b26b526e..9d6f6e6cf 100644 --- a/frameworks/kits/js/common/pixel_map_napi.cpp +++ b/frameworks/kits/js/common/pixel_map_napi.cpp @@ -15,8 +15,7 @@ #include "pixel_map_napi.h" #include "media_errors.h" -#include "hilog/log.h" -#include "log_tags.h" +#include "image_log.h" #include "image_napi_utils.h" #include "image_pixel_map_napi.h" #include "image_trace.h" @@ -30,10 +29,13 @@ #include "pixel_map.h" #include "pixel_map_from_surface.h" -using OHOS::HiviewDFX::HiLog; +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "PixelMapNapi" + namespace { - constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, - LOG_TAG_DOMAIN_ID_PIXEL_MAP_NAPI, "PixelMapNapi"}; constexpr uint32_t NUM_0 = 0; constexpr uint32_t NUM_1 = 1; constexpr uint32_t NUM_2 = 2; @@ -158,19 +160,19 @@ static bool parseInitializationOptions(napi_env env, napi_value root, Initializa } if (!GET_UINT32_BY_NAME(root, "alphaType", tmpNumber)) { - HiLog::Info(LABEL, "no alphaType in initialization options"); + IMAGE_LOGI("no alphaType in initialization options"); } opts->alphaType = ParseAlphaType(tmpNumber); tmpNumber = 0; if (!GET_UINT32_BY_NAME(root, "pixelFormat", tmpNumber)) { - HiLog::Info(LABEL, "no pixelFormat in initialization options"); + IMAGE_LOGI("no pixelFormat in initialization options"); } opts->pixelFormat = ParsePixlForamt(tmpNumber); tmpNumber = 0; if (!GET_UINT32_BY_NAME(root, "scaleMode", tmpNumber)) { - HiLog::Info(LABEL, "no scaleMode in initialization options"); + IMAGE_LOGI("no scaleMode in initialization options"); } opts->scaleMode = ParseScaleMode(tmpNumber); @@ -330,22 +332,22 @@ static napi_value DoInitAfter(napi_env env, napi_value global = nullptr; IMG_NAPI_CHECK_RET_D(IMG_IS_OK( napi_get_global(env, &global)), - nullptr, HiLog::Error(LABEL, "Init:get global fail") + nullptr, IMAGE_LOGE("Init:get global fail") ); IMG_NAPI_CHECK_RET_D(IMG_IS_OK( napi_set_named_property(env, global, CLASS_NAME.c_str(), constructor)), - nullptr, HiLog::Error(LABEL, "Init:set global named property fail") + nullptr, IMAGE_LOGE("Init:set global named property fail") ); IMG_NAPI_CHECK_RET_D(IMG_IS_OK( napi_set_named_property(env, exports, CLASS_NAME.c_str(), constructor)), - nullptr, HiLog::Error(LABEL, "set named property fail") + nullptr, IMAGE_LOGE("set named property fail") ); IMG_NAPI_CHECK_RET_D(IMG_IS_OK( napi_define_properties(env, exports, property_count, properties)), - nullptr, HiLog::Error(LABEL, "define properties fail") + nullptr, IMAGE_LOGE("define properties fail") ); return exports; } @@ -394,18 +396,18 @@ napi_value PixelMapNapi::Init(napi_env env, napi_value exports) napi_define_class(env, CLASS_NAME.c_str(), NAPI_AUTO_LENGTH, Constructor, nullptr, IMG_ARRAY_SIZE(props), props, &constructor)), - nullptr, HiLog::Error(LABEL, "define class fail") + nullptr, IMAGE_LOGE("define class fail") ); IMG_NAPI_CHECK_RET_D(IMG_IS_OK( napi_create_reference(env, constructor, 1, &sConstructor_)), - nullptr, HiLog::Error(LABEL, "create reference fail") + nullptr, IMAGE_LOGE("create reference fail") ); auto result = DoInitAfter(env, exports, constructor, IMG_ARRAY_SIZE(static_prop), static_prop); - HiLog::Debug(LABEL, "Init success"); + IMAGE_LOGD("Init success"); return result; } @@ -415,18 +417,18 @@ std::shared_ptr PixelMapNapi::GetPixelMap(napi_env env, napi_value pix napi_status status = napi_unwrap(env, pixelmap, reinterpret_cast(&pixelMapNapi)); if (!IMG_IS_OK(status)) { - HiLog::Error(LABEL, "GetPixelMap napi unwrap failed"); + IMAGE_LOGE("GetPixelMap napi unwrap failed"); return nullptr; } if (pixelMapNapi == nullptr) { - HiLog::Error(LABEL, "GetPixelMap pixmapNapi is nullptr"); + IMAGE_LOGE("GetPixelMap pixmapNapi is nullptr"); return nullptr; } auto pixelmapNapiPtr = pixelMapNapi.release(); if (pixelmapNapiPtr == nullptr) { - HiLog::Error(LABEL, "GetPixelMap pixelmapNapi is nullptr"); + IMAGE_LOGE("GetPixelMap pixelmapNapi is nullptr"); return nullptr; } return pixelmapNapiPtr->nativePixelMap_; @@ -460,7 +462,7 @@ extern "C" __attribute__((visibility("default"))) void* OHOS_MEDIA_GetPixelMap(n PixelMapNapi *pixmapNapi = nullptr; napi_unwrap(env, value, reinterpret_cast(&pixmapNapi)); if (pixmapNapi == nullptr) { - HiLog::Error(LABEL, "pixmapNapi unwrapped is nullptr"); + IMAGE_LOGE("pixmapNapi unwrapped is nullptr"); return nullptr; } return reinterpret_cast(pixmapNapi->GetPixelMap()); @@ -469,23 +471,23 @@ extern "C" __attribute__((visibility("default"))) void* OHOS_MEDIA_GetPixelMap(n extern "C" __attribute__((visibility("default"))) int32_t OHOS_MEDIA_GetImageInfo(napi_env env, napi_value value, OhosPixelMapInfo *info) { - HiLog::Debug(LABEL, "GetImageInfo IN"); + IMAGE_LOGD("GetImageInfo IN"); if (info == nullptr) { - HiLog::Error(LABEL, "info is nullptr"); + IMAGE_LOGE("info is nullptr"); return OHOS_IMAGE_RESULT_BAD_PARAMETER; } PixelMapNapi *pixmapNapi = nullptr; napi_unwrap(env, value, reinterpret_cast(&pixmapNapi)); if (pixmapNapi == nullptr) { - HiLog::Error(LABEL, "pixmapNapi unwrapped is nullptr"); + IMAGE_LOGE("pixmapNapi unwrapped is nullptr"); return OHOS_IMAGE_RESULT_BAD_PARAMETER; } std::shared_ptr pixelMap = pixmapNapi->GetPixelNapiInner(); if ((pixelMap == nullptr)) { - HiLog::Error(LABEL, "pixelMap is nullptr"); + IMAGE_LOGE("pixelMap is nullptr"); return OHOS_IMAGE_RESULT_BAD_PARAMETER; } @@ -496,7 +498,7 @@ extern "C" __attribute__((visibility("default"))) int32_t OHOS_MEDIA_GetImageInf info->rowSize = pixelMap->GetRowStride(); info->pixelFormat = static_cast(imageInfo.pixelFormat); - HiLog::Debug(LABEL, "GetImageInfo, w=%{public}u, h=%{public}u, r=%{public}u, f=%{public}d", + IMAGE_LOGD("GetImageInfo, w=%{public}u, h=%{public}u, r=%{public}u, f=%{public}d", info->width, info->height, info->rowSize, info->pixelFormat); return OHOS_IMAGE_RESULT_SUCCESS; @@ -505,30 +507,30 @@ extern "C" __attribute__((visibility("default"))) int32_t OHOS_MEDIA_GetImageInf extern "C" __attribute__((visibility("default"))) int32_t OHOS_MEDIA_AccessPixels(napi_env env, napi_value value, uint8_t** addrPtr) { - HiLog::Info(LABEL, "AccessPixels IN"); + IMAGE_LOGI("AccessPixels IN"); PixelMapNapi *pixmapNapi = nullptr; napi_unwrap(env, value, reinterpret_cast(&pixmapNapi)); if (pixmapNapi == nullptr) { - HiLog::Error(LABEL, "pixmapNapi unwrapped is nullptr"); + IMAGE_LOGE("pixmapNapi unwrapped is nullptr"); return OHOS_IMAGE_RESULT_BAD_PARAMETER; } std::shared_ptr pixelMap = pixmapNapi->GetPixelNapiInner(); if (pixelMap == nullptr) { - HiLog::Error(LABEL, "pixelMap is nullptr"); + IMAGE_LOGE("pixelMap is nullptr"); return OHOS_IMAGE_RESULT_BAD_PARAMETER; } const uint8_t *constPixels = pixelMap->GetPixels(); if (constPixels == nullptr) { - HiLog::Error(LABEL, "const pixels is nullptr"); + IMAGE_LOGE("const pixels is nullptr"); return OHOS_IMAGE_RESULT_BAD_PARAMETER; } uint8_t *pixels = const_cast(constPixels); if (pixels == nullptr) { - HiLog::Error(LABEL, "pixels is nullptr"); + IMAGE_LOGE("pixels is nullptr"); return OHOS_IMAGE_RESULT_BAD_PARAMETER; } @@ -538,18 +540,18 @@ extern "C" __attribute__((visibility("default"))) int32_t OHOS_MEDIA_AccessPixel *addrPtr = pixels; } - HiLog::Debug(LABEL, "AccessPixels OUT"); + IMAGE_LOGD("AccessPixels OUT"); return OHOS_IMAGE_RESULT_SUCCESS; } extern "C" __attribute__((visibility("default"))) int32_t OHOS_MEDIA_UnAccessPixels(napi_env env, napi_value value) { - HiLog::Debug(LABEL, "UnAccessPixels IN"); + IMAGE_LOGD("UnAccessPixels IN"); PixelMapNapi *pixmapNapi = nullptr; napi_unwrap(env, value, reinterpret_cast(&pixmapNapi)); if (pixmapNapi == nullptr) { - HiLog::Error(LABEL, "pixmapNapi unwrapped is nullptr"); + IMAGE_LOGE("pixmapNapi unwrapped is nullptr"); return OHOS_IMAGE_RESULT_BAD_PARAMETER; } @@ -560,9 +562,9 @@ extern "C" __attribute__((visibility("default"))) int32_t OHOS_MEDIA_UnAccessPix inline void *DetachPixelMapFunc(napi_env env, void *value, void *) { - HiLog::Debug(LABEL, "DetachPixelMapFunc in"); + IMAGE_LOGD("DetachPixelMapFunc in"); if (value == nullptr) { - HiLog::Error(LABEL, "DetachPixelMapFunc value is nullptr"); + IMAGE_LOGE("DetachPixelMapFunc value is nullptr"); return value; } auto pixelNapi = reinterpret_cast(value); @@ -578,7 +580,7 @@ static napi_status NewPixelNapiInstance(napi_env &env, napi_value &constructor, napi_status status; if (pixelMap == nullptr) { status = napi_invalid_arg; - HiLog::Error(LABEL, "NewPixelNapiInstance pixelMap is nullptr"); + IMAGE_LOGE("NewPixelNapiInstance pixelMap is nullptr"); return status; } size_t argc = NEW_INSTANCE_ARGC; @@ -592,14 +594,14 @@ static napi_status NewPixelNapiInstance(napi_env &env, napi_value &constructor, napi_value AttachPixelMapFunc(napi_env env, void *value, void *) { if (value == nullptr) { - HiLog::Error(LABEL, "attach value is nullptr"); + IMAGE_LOGE("attach value is nullptr"); return nullptr; } std::lock_guard lock(pixelMapCrossThreadMutex_); napi_value result = nullptr; if (value == nullptr) { - HiLog::Error(LABEL, "attach value lock losed"); + IMAGE_LOGE("attach value lock losed"); napi_get_undefined(env, &result); return result; } @@ -607,7 +609,7 @@ napi_value AttachPixelMapFunc(napi_env env, void *value, void *) std::shared_ptr attachPixelMap = std::move(data->pixelMap); delete data; if (attachPixelMap == nullptr) { - HiLog::Error(LABEL, "AttachPixelMapFunc attachPixelMap is nullptr"); + IMAGE_LOGE("AttachPixelMapFunc attachPixelMap is nullptr"); napi_get_undefined(env, &result); return result; } @@ -615,7 +617,7 @@ napi_value AttachPixelMapFunc(napi_env env, void *value, void *) napi_status status; if (PixelMapNapi::GetConstructor() == nullptr) { - HiLog::Info(LABEL, "PixelMapNapi::GetConstructor() is nullptr"); + IMAGE_LOGI("PixelMapNapi::GetConstructor() is nullptr"); napi_value exports = nullptr; napi_create_object(env, &exports); PixelMapNapi::Init(env, exports); @@ -624,7 +626,7 @@ napi_value AttachPixelMapFunc(napi_env env, void *value, void *) napi_get_global(env, &globalValue); status = napi_get_named_property(env, globalValue, CLASS_NAME.c_str(), &constructor); if (!IMG_IS_OK(status)) { - HiLog::Info(LABEL, "napi_get_named_property failed requireNapi in"); + IMAGE_LOGI("napi_get_named_property failed requireNapi in"); napi_value func; napi_get_named_property(env, globalValue, "requireNapi", &func); @@ -634,12 +636,12 @@ napi_value AttachPixelMapFunc(napi_env env, void *value, void *) napi_value returnValue; napi_call_function(env, globalValue, func, 1, funcArgv, &returnValue); status = napi_get_named_property(env, globalValue, CLASS_NAME.c_str(), &constructor); - IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, HiLog::Error(LABEL, "napi_get_named_property error")); + IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, IMAGE_LOGE("napi_get_named_property error")); } status = NewPixelNapiInstance(env, constructor, attachPixelMap, result); if (!IMG_IS_OK(status)) { - HiLog::Error(LABEL, "AttachPixelMapFunc napi_get_referencce_value failed"); + IMAGE_LOGE("AttachPixelMapFunc napi_get_referencce_value failed"); } return result; } @@ -654,7 +656,7 @@ napi_value PixelMapNapi::Constructor(napi_env env, napi_callback_info info) napi_get_undefined(env, &thisVar); size_t argc = NEW_INSTANCE_ARGC; napi_value argv[NEW_INSTANCE_ARGC] = { 0 }; - HiLog::Debug(LABEL, "Constructor IN"); + IMAGE_LOGD("Constructor IN"); status = napi_get_cb_info(env, info, &argc, argv, &thisVar, nullptr); IMG_NAPI_CHECK_RET(IMG_IS_READY(status, thisVar), undefineVar); uint32_t pixelMapId = 0; @@ -666,10 +668,10 @@ napi_value PixelMapNapi::Constructor(napi_env env, napi_callback_info info) pPixelMapNapi->env_ = env; if (PixelMapContainer::GetInstance().Find(pixelMapId)) { pPixelMapNapi->nativePixelMap_ = PixelMapContainer::GetInstance()[pixelMapId]; - HiLog::Debug(LABEL, "Constructor in napi_id:%{public}d, id:%{public}d", + IMAGE_LOGD("Constructor in napi_id:%{public}d, id:%{public}d", pPixelMapNapi->GetUniqueId(), pPixelMapNapi->nativePixelMap_->GetUniqueId()); } else { - HiLog::Error(LABEL, "Constructor nativePixelMap is nullptr"); + IMAGE_LOGE("Constructor nativePixelMap is nullptr"); } napi_coerce_to_native_binding_object( @@ -677,7 +679,7 @@ napi_value PixelMapNapi::Constructor(napi_env env, napi_callback_info info) status = napi_wrap(env, thisVar, reinterpret_cast(pPixelMapNapi.get()), PixelMapNapi::Destructor, nullptr, nullptr); - IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), undefineVar, HiLog::Error(LABEL, "Failure wrapping js to native napi")); + IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), undefineVar, IMAGE_LOGE("Failure wrapping js to native napi")); pPixelMapNapi.release(); PixelMapContainer::GetInstance().Erase(pixelMapId); @@ -688,7 +690,7 @@ void PixelMapNapi::Destructor(napi_env env, void *nativeObject, void *finalize) { if (nativeObject != nullptr) { std::lock_guard lock(pixelMapCrossThreadMutex_); - HiLog::Debug(LABEL, "Destructor pixelmapNapi"); + IMAGE_LOGD("Destructor pixelmapNapi"); delete reinterpret_cast(nativeObject); nativeObject = nullptr; } @@ -696,7 +698,7 @@ void PixelMapNapi::Destructor(napi_env env, void *nativeObject, void *finalize) static void BuildContextError(napi_env env, napi_ref &error, const std::string errMsg, const int32_t errCode) { - HiLog::Error(LABEL, "%{public}s", errMsg.c_str()); + IMAGE_LOGE("%{public}s", errMsg.c_str()); napi_value tmpError; ImageNapiUtils::CreateErrorObj(env, tmpError, errCode, errMsg); napi_create_reference(env, tmpError, NUM_1, &(error)); @@ -722,7 +724,7 @@ void PixelMapNapi::CreatePixelMapComplete(napi_env env, napi_status status, void napi_value constructor = nullptr; napi_value result = nullptr; - HiLog::Debug(LABEL, "CreatePixelMapComplete IN"); + IMAGE_LOGD("CreatePixelMapComplete IN"); auto context = static_cast(data); status = napi_get_reference_value(env, sConstructor_, &constructor); @@ -733,7 +735,7 @@ void PixelMapNapi::CreatePixelMapComplete(napi_env env, napi_status status, void if (!IMG_IS_OK(status)) { context->status = ERROR; - HiLog::Error(LABEL, "New instance could not be obtained"); + IMAGE_LOGE("New instance could not be obtained"); napi_get_undefined(env, &result); } @@ -757,22 +759,22 @@ napi_value PixelMapNapi::CreatePixelMap(napi_env env, napi_callback_info info) napi_value thisVar = nullptr; napi_value argValue[NUM_4] = {0}; size_t argCount = NUM_4; - HiLog::Debug(LABEL, "CreatePixelMap IN"); + IMAGE_LOGD("CreatePixelMap IN"); IMG_JS_ARGS(env, info, status, argCount, argValue, thisVar); // we are static method! // thisVar is nullptr here - IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, HiLog::Error(LABEL, "fail to napi_get_cb_info")); + IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, IMAGE_LOGE("fail to napi_get_cb_info")); std::unique_ptr asyncContext = std::make_unique(); status = napi_get_arraybuffer_info(env, argValue[NUM_0], &(asyncContext->colorsBuffer), &(asyncContext->colorsBufferSize)); - IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, HiLog::Error(LABEL, "colors mismatch")); + IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, IMAGE_LOGE("colors mismatch")); IMG_NAPI_CHECK_RET_D(parseInitializationOptions(env, argValue[1], &(asyncContext->opts)), - nullptr, HiLog::Error(LABEL, "InitializationOptions mismatch")); + nullptr, IMAGE_LOGE("InitializationOptions mismatch")); if (argCount == NUM_3 && ImageNapiUtils::getType(env, argValue[argCount - 1]) == napi_function) { napi_create_reference(env, argValue[argCount - 1], refCount, &asyncContext->callbackRef); @@ -788,14 +790,14 @@ napi_value PixelMapNapi::CreatePixelMap(napi_env env, napi_callback_info info) CreatePixelMapExec, CreatePixelMapComplete, asyncContext, asyncContext->work); IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), - nullptr, HiLog::Error(LABEL, "fail to create async work")); + nullptr, IMAGE_LOGE("fail to create async work")); return result; } STATIC_EXEC_FUNC(CreatePixelMapFromSurface) { auto context = static_cast(data); - HiLog::Debug(LABEL, "CreatePixelMapFromSurface id:%{public}s,area:%{public}d,%{public}d,%{public}d,%{public}d", + IMAGE_LOGD("CreatePixelMapFromSurface id:%{public}s,area:%{public}d,%{public}d,%{public}d,%{public}d", context->surfaceId.c_str(), context->area.region.left, context->area.region.top, context->area.region.height, context->area.region.width); @@ -814,7 +816,7 @@ void PixelMapNapi::CreatePixelMapFromSurfaceComplete(napi_env env, napi_status s napi_value constructor = nullptr; napi_value result = nullptr; - HiLog::Debug(LABEL, "CreatePixelMapFromSurface IN"); + IMAGE_LOGD("CreatePixelMapFromSurface IN"); auto context = static_cast(data); status = napi_get_reference_value(env, sConstructor_, &constructor); if (IMG_IS_OK(status)) { @@ -823,7 +825,7 @@ void PixelMapNapi::CreatePixelMapFromSurfaceComplete(napi_env env, napi_status s if (!IMG_IS_OK(status)) { context->status = ERR_IMAGE_PIXELMAP_CREATE_FAILED; - HiLog::Error(LABEL, "New instance could not be obtained"); + IMAGE_LOGE("New instance could not be obtained"); napi_get_undefined(env, &result); } @@ -843,13 +845,13 @@ static std::string GetStringArgument(napi_env env, napi_value value) if (status == napi_ok && bufLength > NUM_0 && bufLength < PATH_MAX) { char *buffer = reinterpret_cast(malloc((bufLength + NUM_1) * sizeof(char))); if (buffer == nullptr) { - HiLog::Error(LABEL, "No memory"); + IMAGE_LOGE("No memory"); return strValue; } status = napi_get_value_string_utf8(env, value, buffer, bufLength + NUM_1, &bufLength); if (status == napi_ok) { - HiLog::Debug(LABEL, "Get Success"); + IMAGE_LOGD("Get Success"); strValue.assign(buffer, 0, bufLength + NUM_1); } if (buffer != nullptr) { @@ -880,13 +882,13 @@ napi_value PixelMapNapi::CreatePixelMapFromSurface(napi_env env, napi_callback_i napi_value thisVar = nullptr; napi_value argValue[NUM_4] = {0}; size_t argCount = NUM_4; - HiLog::Debug(LABEL, "CreatePixelMapFromSurface IN"); + IMAGE_LOGD("CreatePixelMapFromSurface IN"); IMG_JS_ARGS(env, info, status, argCount, argValue, thisVar); - IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, HiLog::Error(LABEL, "fail to napi_get_cb_info")); + IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, IMAGE_LOGE("fail to napi_get_cb_info")); std::unique_ptr asyncContext = std::make_unique(); asyncContext->surfaceId = GetStringArgument(env, argValue[NUM_0]); bool ret = parseRegion(env, argValue[NUM_1], &(asyncContext->area.region)); - HiLog::Debug(LABEL, "CreatePixelMapFromSurface get data: %{public}d", ret); + IMAGE_LOGD("CreatePixelMapFromSurface get data: %{public}d", ret); if (argCount == NUM_3 && ImageNapiUtils::getType(env, argValue[argCount - 1]) == napi_function) { napi_create_reference(env, argValue[argCount - 1], refCount, &asyncContext->callbackRef); } @@ -903,7 +905,7 @@ napi_value PixelMapNapi::CreatePixelMapFromSurface(napi_env env, napi_callback_i IMG_CREATE_CREATE_ASYNC_WORK(env, status, "CreatePixelMapFromSurface", CreatePixelMapFromSurfaceExec, CreatePixelMapFromSurfaceComplete, asyncContext, asyncContext->work); IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), - nullptr, HiLog::Error(LABEL, "fail to create async work")); + nullptr, IMAGE_LOGE("fail to create async work")); return result; } @@ -919,7 +921,7 @@ napi_value PixelMapNapi::CreatePixelMap(napi_env env, std::shared_ptr napi_value result = nullptr; napi_status status; - HiLog::Debug(LABEL, "CreatePixelMap IN"); + IMAGE_LOGD("CreatePixelMap IN"); status = napi_get_reference_value(env, sConstructor_, &constructor); if (IMG_IS_OK(status)) { @@ -927,7 +929,7 @@ napi_value PixelMapNapi::CreatePixelMap(napi_env env, std::shared_ptr } if (!IMG_IS_OK(status)) { - HiLog::Error(LABEL, "CreatePixelMap | New instance could not be obtained"); + IMAGE_LOGE("CreatePixelMap | New instance could not be obtained"); napi_get_undefined(env, &result); } @@ -958,7 +960,7 @@ void PixelMapNapi::UnmarshallingComplete(napi_env env, napi_status status, void napi_value constructor = nullptr; napi_value result = nullptr; - HiLog::Debug(LABEL, "UnmarshallingComplete IN"); + IMAGE_LOGD("UnmarshallingComplete IN"); auto context = static_cast(data); status = napi_get_reference_value(env, sConstructor_, &constructor); @@ -968,7 +970,7 @@ void PixelMapNapi::UnmarshallingComplete(napi_env env, napi_status status, void if (!IMG_IS_OK(status)) { context->status = ERROR; - HiLog::Error(LABEL, "New instance could not be obtained"); + IMAGE_LOGE("New instance could not be obtained"); napi_get_undefined(env, &result); } @@ -992,7 +994,7 @@ napi_value PixelMapNapi::Unmarshalling(napi_env env, napi_callback_info info) napi_value thisVar = nullptr; napi_value argValue[NUM_4] = {0}; size_t argCount = NUM_4; - HiLog::Debug(LABEL, "Unmarshalling IN"); + IMAGE_LOGD("Unmarshalling IN"); IMG_JS_ARGS(env, info, status, argCount, argValue, thisVar); @@ -1060,7 +1062,7 @@ napi_value PixelMapNapi::CreatePixelMapFromParcel(napi_env env, napi_callback_in napi_value thisVar = nullptr; napi_value argValue[NUM_1] = {0}; size_t argCount = NUM_1; - HiLog::Debug(LABEL, "CreatePixelMapFromParcel IN"); + IMAGE_LOGD("CreatePixelMapFromParcel IN"); IMG_JS_ARGS(env, info, status, argCount, argValue, thisVar); if (!IMG_IS_OK(status) || argCount != NUM_1) { return PixelMapNapi::ThrowExceptionError(env, @@ -1086,7 +1088,7 @@ napi_value PixelMapNapi::CreatePixelMapFromParcel(napi_env env, napi_callback_in status = NewPixelNapiInstance(env, constructor, pixelPtr, result); } if (!IMG_IS_OK(status)) { - HiLog::Error(LABEL, "New instance could not be obtained"); + IMAGE_LOGE("New instance could not be obtained"); return PixelMapNapi::ThrowExceptionError(env, CREATE_PIXEL_MAP_FROM_PARCEL, ERR_IMAGE_NAPI_ERROR, "New instance could not be obtained"); } @@ -1102,16 +1104,16 @@ napi_value PixelMapNapi::GetIsEditable(napi_env env, napi_callback_info info) napi_status status; napi_value thisVar = nullptr; size_t argCount = 0; - HiLog::Debug(LABEL, "GetIsEditable IN"); + IMAGE_LOGD("GetIsEditable IN"); IMG_JS_ARGS(env, info, status, argCount, nullptr, thisVar); - IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), result, HiLog::Error(LABEL, "fail to napi_get_cb_info")); + IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), result, IMAGE_LOGE("fail to napi_get_cb_info")); std::unique_ptr pixelMapNapi = nullptr; status = napi_unwrap(env, thisVar, reinterpret_cast(&pixelMapNapi)); - IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, pixelMapNapi), result, HiLog::Error(LABEL, "fail to unwrap context")); + IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, pixelMapNapi), result, IMAGE_LOGE("fail to unwrap context")); if (pixelMapNapi->nativePixelMap_ == nullptr) { return result; @@ -1132,17 +1134,17 @@ napi_value PixelMapNapi::GetIsStrideAlignment(napi_env env, napi_callback_info i napi_status status; napi_value thisVar = nullptr; size_t argCount = 0; - HiLog::Debug(LABEL, "GetIsStrideAlignment IN"); + IMAGE_LOGD("GetIsStrideAlignment IN"); IMG_JS_ARGS(env, info, status, argCount, nullptr, thisVar); - IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), result, HiLog::Error(LABEL, "fail to napi_get_cb_info")); + IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), result, IMAGE_LOGE("fail to napi_get_cb_info")); std::unique_ptr pixelMapNapi = nullptr; status = napi_unwrap(env, thisVar, reinterpret_cast(&pixelMapNapi)); IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, pixelMapNapi), - result, HiLog::Error(LABEL, "fail to unwrap context")); + result, IMAGE_LOGE("fail to unwrap context")); if (pixelMapNapi->nativePixelMap_ == nullptr) { return result; @@ -1165,25 +1167,25 @@ napi_value PixelMapNapi::ReadPixelsToBuffer(napi_env env, napi_callback_info inf napi_value argValue[NUM_2] = {0}; size_t argCount = NUM_2; - HiLog::Debug(LABEL, "ReadPixelsToBuffer IN"); + IMAGE_LOGD("ReadPixelsToBuffer IN"); IMG_JS_ARGS(env, info, status, argCount, argValue, thisVar); - IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, HiLog::Error(LABEL, "fail to napi_get_cb_info")); + IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, IMAGE_LOGE("fail to napi_get_cb_info")); std::unique_ptr asyncContext = std::make_unique(); status = napi_unwrap(env, thisVar, reinterpret_cast(&asyncContext->nConstructor)); IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, asyncContext->nConstructor), - nullptr, HiLog::Error(LABEL, "fail to unwrap context")); + nullptr, IMAGE_LOGE("fail to unwrap context")); asyncContext->rPixelMap = asyncContext->nConstructor->nativePixelMap_; IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, asyncContext->rPixelMap), - nullptr, HiLog::Error(LABEL, "empty native pixelmap")); + nullptr, IMAGE_LOGE("empty native pixelmap")); status = napi_get_arraybuffer_info(env, argValue[NUM_0], &(asyncContext->colorsBuffer), &(asyncContext->colorsBufferSize)); - IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, HiLog::Error(LABEL, "colors mismatch")); + IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, IMAGE_LOGE("colors mismatch")); if (argCount == NUM_2 && ImageNapiUtils::getType(env, argValue[argCount - 1]) == napi_function) { napi_create_reference(env, argValue[argCount - 1], refCount, &asyncContext->callbackRef); @@ -1210,7 +1212,7 @@ napi_value PixelMapNapi::ReadPixelsToBuffer(napi_env env, napi_callback_info inf , EmptyResultComplete, asyncContext, asyncContext->work); IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), - nullptr, HiLog::Error(LABEL, "fail to create async work")); + nullptr, IMAGE_LOGE("fail to create async work")); return result; } @@ -1225,24 +1227,24 @@ napi_value PixelMapNapi::ReadPixels(napi_env env, napi_callback_info info) napi_value argValue[NUM_2] = {0}; size_t argCount = NUM_2; - HiLog::Debug(LABEL, "ReadPixels IN"); + IMAGE_LOGD("ReadPixels IN"); IMG_JS_ARGS(env, info, status, argCount, argValue, thisVar); - IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, HiLog::Error(LABEL, "fail to napi_get_cb_info")); + IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, IMAGE_LOGE("fail to napi_get_cb_info")); std::unique_ptr asyncContext = std::make_unique(); status = napi_unwrap(env, thisVar, reinterpret_cast(&asyncContext->nConstructor)); IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, asyncContext->nConstructor), - nullptr, HiLog::Error(LABEL, "fail to unwrap context")); + nullptr, IMAGE_LOGE("fail to unwrap context")); asyncContext->rPixelMap = asyncContext->nConstructor->nativePixelMap_; IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, asyncContext->rPixelMap), - nullptr, HiLog::Error(LABEL, "empty native pixelmap")); + nullptr, IMAGE_LOGE("empty native pixelmap")); IMG_NAPI_CHECK_RET_D(parsePositionArea(env, argValue[NUM_0], &(asyncContext->area)), - nullptr, HiLog::Error(LABEL, "fail to parse position area")); + nullptr, IMAGE_LOGE("fail to parse position area")); if (argCount == NUM_2 && ImageNapiUtils::getType(env, argValue[argCount - 1]) == napi_function) { napi_create_reference(env, argValue[argCount - 1], refCount, &asyncContext->callbackRef); @@ -1269,7 +1271,7 @@ napi_value PixelMapNapi::ReadPixels(napi_env env, napi_callback_info info) }, EmptyResultComplete, asyncContext, asyncContext->work); IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), - nullptr, HiLog::Error(LABEL, "fail to create async work")); + nullptr, IMAGE_LOGE("fail to create async work")); return result; } @@ -1284,23 +1286,23 @@ napi_value PixelMapNapi::WritePixels(napi_env env, napi_callback_info info) napi_value argValue[NUM_2] = {0}; size_t argCount = NUM_2; - HiLog::Debug(LABEL, "WritePixels IN"); + IMAGE_LOGD("WritePixels IN"); IMG_JS_ARGS(env, info, status, argCount, argValue, thisVar); - IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, HiLog::Error(LABEL, "fail to napi_get_cb_info")); + IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, IMAGE_LOGE("fail to napi_get_cb_info")); std::unique_ptr asyncContext = std::make_unique(); status = napi_unwrap(env, thisVar, reinterpret_cast(&asyncContext->nConstructor)); IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, asyncContext->nConstructor), - nullptr, HiLog::Error(LABEL, "fail to unwrap context")); + nullptr, IMAGE_LOGE("fail to unwrap context")); asyncContext->rPixelMap = asyncContext->nConstructor->nativePixelMap_; IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, asyncContext->rPixelMap), - nullptr, HiLog::Error(LABEL, "empty native pixelmap")); + nullptr, IMAGE_LOGE("empty native pixelmap")); IMG_NAPI_CHECK_RET_D(parsePositionArea(env, argValue[NUM_0], &(asyncContext->area)), - nullptr, HiLog::Error(LABEL, "fail to parse position area")); + nullptr, IMAGE_LOGE("fail to parse position area")); if (argCount == NUM_2 && ImageNapiUtils::getType(env, argValue[argCount - 1]) == napi_function) { napi_create_reference(env, argValue[argCount - 1], refCount, &asyncContext->callbackRef); @@ -1326,7 +1328,7 @@ napi_value PixelMapNapi::WritePixels(napi_env env, napi_callback_info info) }, EmptyResultComplete, asyncContext, asyncContext->work); IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), - nullptr, HiLog::Error(LABEL, "fail to create async work")); + nullptr, IMAGE_LOGE("fail to create async work")); return result; } @@ -1342,25 +1344,25 @@ napi_value PixelMapNapi::WriteBufferToPixels(napi_env env, napi_callback_info in napi_value argValue[NUM_2] = {0}; size_t argCount = NUM_2; - HiLog::Debug(LABEL, "WriteBufferToPixels IN"); + IMAGE_LOGD("WriteBufferToPixels IN"); IMG_JS_ARGS(env, info, status, argCount, argValue, thisVar); - IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, HiLog::Error(LABEL, "fail to napi_get_cb_info")); + IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, IMAGE_LOGE("fail to napi_get_cb_info")); std::unique_ptr asyncContext = std::make_unique(); status = napi_unwrap(env, thisVar, reinterpret_cast(&asyncContext->nConstructor)); IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, asyncContext->nConstructor), - nullptr, HiLog::Error(LABEL, "fail to unwrap context")); + nullptr, IMAGE_LOGE("fail to unwrap context")); asyncContext->rPixelMap = asyncContext->nConstructor->nativePixelMap_; IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, asyncContext->rPixelMap), - nullptr, HiLog::Error(LABEL, "empty native pixelmap")); + nullptr, IMAGE_LOGE("empty native pixelmap")); status = napi_get_arraybuffer_info(env, argValue[NUM_0], &(asyncContext->colorsBuffer), &(asyncContext->colorsBufferSize)); IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), - nullptr, HiLog::Error(LABEL, "fail to get buffer info")); + nullptr, IMAGE_LOGE("fail to get buffer info")); if (argCount == NUM_2 && ImageNapiUtils::getType(env, argValue[argCount - 1]) == napi_function) { napi_create_reference(env, argValue[argCount - 1], refCount, &asyncContext->callbackRef); @@ -1385,13 +1387,13 @@ napi_value PixelMapNapi::WriteBufferToPixels(napi_env env, napi_callback_info in }, EmptyResultComplete, asyncContext, asyncContext->work); IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), - nullptr, HiLog::Error(LABEL, "fail to create async work")); + nullptr, IMAGE_LOGE("fail to create async work")); return result; } STATIC_COMPLETE_FUNC(GetImageInfo) { - HiLog::Debug(LABEL, "[PixelMap]GetImageInfoComplete IN"); + IMAGE_LOGD("[PixelMap]GetImageInfoComplete IN"); napi_value result = nullptr; napi_create_object(env, &result); auto context = static_cast(data); @@ -1421,12 +1423,12 @@ STATIC_COMPLETE_FUNC(GetImageInfo) napi_set_named_property(env, result, "stride", strideValue); if (!IMG_IS_OK(status)) { context->status = ERROR; - HiLog::Error(LABEL, "napi_create_int32 failed!"); + IMAGE_LOGE("napi_create_int32 failed!"); napi_get_undefined(env, &result); } else { context->status = SUCCESS; } - HiLog::Debug(LABEL, "[PixelMap]GetImageInfoComplete OUT"); + IMAGE_LOGD("[PixelMap]GetImageInfoComplete OUT"); CommonCallbackRoutine(env, context, result); } napi_value PixelMapNapi::GetImageInfo(napi_env env, napi_callback_info info) @@ -1438,16 +1440,16 @@ napi_value PixelMapNapi::GetImageInfo(napi_env env, napi_callback_info info) napi_value thisVar = nullptr; napi_value argValue[NUM_1] = {0}; size_t argCount = 1; - HiLog::Debug(LABEL, "GetImageInfo IN"); + IMAGE_LOGD("GetImageInfo IN"); IMG_JS_ARGS(env, info, status, argCount, argValue, thisVar); - IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, HiLog::Error(LABEL, "fail to napi_get_cb_info")); + IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, IMAGE_LOGE("fail to napi_get_cb_info")); std::unique_ptr asyncContext = std::make_unique(); status = napi_unwrap(env, thisVar, reinterpret_cast(&asyncContext->nConstructor)); IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, asyncContext->nConstructor), - nullptr, HiLog::Error(LABEL, "fail to unwrap context")); + nullptr, IMAGE_LOGE("fail to unwrap context")); asyncContext->rPixelMap = asyncContext->nConstructor->nativePixelMap_; IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, asyncContext->rPixelMap), - nullptr, HiLog::Error(LABEL, "empty native pixelmap")); + nullptr, IMAGE_LOGE("empty native pixelmap")); if (argCount == NUM_1 && ImageNapiUtils::getType(env, argValue[argCount - 1]) == napi_function) { napi_create_reference(env, argValue[argCount - 1], refCount, &asyncContext->callbackRef); } @@ -1469,7 +1471,7 @@ napi_value PixelMapNapi::GetImageInfo(napi_env env, napi_callback_info info) context->status = SUCCESS; }, GetImageInfoComplete, asyncContext, asyncContext->work); IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), - nullptr, HiLog::Error(LABEL, "fail to create async work")); + nullptr, IMAGE_LOGE("fail to create async work")); return result; } @@ -1483,28 +1485,28 @@ napi_value PixelMapNapi::GetBytesNumberPerRow(napi_env env, napi_callback_info i napi_value thisVar = nullptr; size_t argCount = 0; - HiLog::Debug(LABEL, "GetBytesNumberPerRow IN"); + IMAGE_LOGD("GetBytesNumberPerRow IN"); IMG_JS_ARGS(env, info, status, argCount, nullptr, thisVar); - IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), result, HiLog::Error(LABEL, "fail to napi_get_cb_info")); + IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), result, IMAGE_LOGE("fail to napi_get_cb_info")); std::unique_ptr pixelMapNapi = nullptr; status = napi_unwrap(env, thisVar, reinterpret_cast(&pixelMapNapi)); - IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, pixelMapNapi), result, HiLog::Error(LABEL, "fail to unwrap context")); + IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, pixelMapNapi), result, IMAGE_LOGE("fail to unwrap context")); IMG_NAPI_CHECK_RET_D(pixelMapNapi->GetPixelNapiEditable(), ImageNapiUtils::ThrowExceptionError(env, ERR_RESOURCE_UNAVAILABLE, "Pixelmap has crossed threads . GetBytesNumberPerRow failed"), - HiLog::Error(LABEL, "Pixelmap has crossed threads . GetBytesNumberPerRow failed")); + IMAGE_LOGE("Pixelmap has crossed threads . GetBytesNumberPerRow failed")); if (pixelMapNapi->nativePixelMap_ != nullptr) { uint32_t rowBytes = pixelMapNapi->nativePixelMap_->GetRowBytes(); status = napi_create_int32(env, rowBytes, &result); if (!IMG_IS_OK(status)) { - HiLog::Error(LABEL, "napi_create_int32 failed!"); + IMAGE_LOGE("napi_create_int32 failed!"); } } else { - HiLog::Error(LABEL, "native pixelmap is nullptr!"); + IMAGE_LOGE("native pixelmap is nullptr!"); } pixelMapNapi.release(); return result; @@ -1520,28 +1522,28 @@ napi_value PixelMapNapi::GetPixelBytesNumber(napi_env env, napi_callback_info in napi_value thisVar = nullptr; size_t argCount = 0; - HiLog::Debug(LABEL, "GetPixelBytesNumber IN"); + IMAGE_LOGD("GetPixelBytesNumber IN"); IMG_JS_ARGS(env, info, status, argCount, nullptr, thisVar); - IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), result, HiLog::Error(LABEL, "fail to napi_get_cb_info")); + IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), result, IMAGE_LOGE("fail to napi_get_cb_info")); std::unique_ptr pixelMapNapi = nullptr; status = napi_unwrap(env, thisVar, reinterpret_cast(&pixelMapNapi)); - IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, pixelMapNapi), result, HiLog::Error(LABEL, "fail to unwrap context")); + IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, pixelMapNapi), result, IMAGE_LOGE("fail to unwrap context")); IMG_NAPI_CHECK_RET_D(pixelMapNapi->GetPixelNapiEditable(), ImageNapiUtils::ThrowExceptionError(env, ERR_RESOURCE_UNAVAILABLE, "Pixelmap has crossed threads . GetPixelBytesNumber failed"), - HiLog::Error(LABEL, "Pixelmap has crossed threads . GetPixelBytesNumber failed")); + IMAGE_LOGE("Pixelmap has crossed threads . GetPixelBytesNumber failed")); if (pixelMapNapi->nativePixelMap_ != nullptr) { uint32_t byteCount = pixelMapNapi->nativePixelMap_->GetByteCount(); status = napi_create_int32(env, byteCount, &result); if (!IMG_IS_OK(status)) { - HiLog::Error(LABEL, "napi_create_int32 failed!"); + IMAGE_LOGE("napi_create_int32 failed!"); } } else { - HiLog::Error(LABEL, "native pixelmap is nullptr!"); + IMAGE_LOGE("native pixelmap is nullptr!"); } pixelMapNapi.release(); return result; @@ -1556,29 +1558,29 @@ napi_value PixelMapNapi::IsSupportAlpha(napi_env env, napi_callback_info info) napi_value thisVar = nullptr; size_t argCount = NUM_0; - HiLog::Debug(LABEL, "IsSupportAlpha IN"); + IMAGE_LOGD("IsSupportAlpha IN"); IMG_JS_ARGS(env, info, status, argCount, nullptr, thisVar); - IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), result, HiLog::Error(LABEL, "fail to napi_get_cb_info")); + IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), result, IMAGE_LOGE("fail to napi_get_cb_info")); std::unique_ptr pixelMapNapi = nullptr; status = napi_unwrap(env, thisVar, reinterpret_cast(&pixelMapNapi)); - IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, pixelMapNapi), result, HiLog::Error(LABEL, "fail to unwrap context")); + IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, pixelMapNapi), result, IMAGE_LOGE("fail to unwrap context")); IMG_NAPI_CHECK_RET_D(pixelMapNapi->GetPixelNapiEditable(), ImageNapiUtils::ThrowExceptionError(env, ERR_RESOURCE_UNAVAILABLE, "Pixelmap has crossed threads . IsSupportAlpha failed"), - HiLog::Error(LABEL, "Pixelmap has crossed threads . IsSupportAlpha failed")); + IMAGE_LOGE("Pixelmap has crossed threads . IsSupportAlpha failed")); if (pixelMapNapi->nativePixelMap_ != nullptr) { AlphaType alphaType = pixelMapNapi->nativePixelMap_->GetAlphaType(); bool isSupportAlpha = !(alphaType == AlphaType::IMAGE_ALPHA_TYPE_OPAQUE); status = napi_get_boolean(env, isSupportAlpha, &result); if (!IMG_IS_OK(status)) { - HiLog::Error(LABEL, "napi_create_bool failed!"); + IMAGE_LOGE("napi_create_bool failed!"); } } else { - HiLog::Error(LABEL, "native pixelmap is nullptr!"); + IMAGE_LOGE("native pixelmap is nullptr!"); } pixelMapNapi.release(); return result; @@ -1595,10 +1597,10 @@ napi_value PixelMapNapi::SetAlphaAble(napi_env env, napi_callback_info info) size_t argCount = NUM_1; bool isAlphaAble = false; - HiLog::Debug(LABEL, "SetAlphaAble IN"); + IMAGE_LOGD("SetAlphaAble IN"); IMG_JS_ARGS(env, info, status, argCount, argValue, thisVar); - IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), result, HiLog::Error(LABEL, "fail to napi_get_cb_info")); + IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), result, IMAGE_LOGE("fail to napi_get_cb_info")); NAPI_ASSERT(env, argCount > NUM_0, "Invalid input"); NAPI_ASSERT(env, ImageNapiUtils::getType(env, argValue[NUM_0]) == napi_boolean, "Invalid input type"); NAPI_ASSERT(env, napi_get_value_bool(env, argValue[NUM_0], &isAlphaAble) == napi_ok, "Parse input error"); @@ -1606,11 +1608,11 @@ napi_value PixelMapNapi::SetAlphaAble(napi_env env, napi_callback_info info) std::unique_ptr pixelMapNapi = nullptr; status = napi_unwrap(env, thisVar, reinterpret_cast(&pixelMapNapi)); - IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, pixelMapNapi), result, HiLog::Error(LABEL, "fail to unwrap context")); + IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, pixelMapNapi), result, IMAGE_LOGE("fail to unwrap context")); IMG_NAPI_CHECK_RET_D(pixelMapNapi->GetPixelNapiEditable(), ImageNapiUtils::ThrowExceptionError(env, ERR_RESOURCE_UNAVAILABLE, "Pixelmap has crossed threads . SetAlphaAble failed"), - HiLog::Error(LABEL, "Pixelmap has crossed threads . SetAlphaAble failed")); + IMAGE_LOGE("Pixelmap has crossed threads . SetAlphaAble failed")); if (pixelMapNapi->nativePixelMap_ != nullptr) { AlphaType alphaType = pixelMapNapi->nativePixelMap_->GetAlphaType(); if (isAlphaAble && (alphaType == AlphaType::IMAGE_ALPHA_TYPE_OPAQUE)) { @@ -1619,7 +1621,7 @@ napi_value PixelMapNapi::SetAlphaAble(napi_env env, napi_callback_info info) pixelMapNapi->nativePixelMap_->SetAlphaType(AlphaType::IMAGE_ALPHA_TYPE_OPAQUE); } } else { - HiLog::Error(LABEL, "native pixelmap is nullptr!"); + IMAGE_LOGE("native pixelmap is nullptr!"); } pixelMapNapi.release(); return result; @@ -1649,16 +1651,16 @@ napi_value PixelMapNapi::CreateAlphaPixelmap(napi_env env, napi_callback_info in napi_value thisVar = nullptr; napi_value argValue[NUM_1] = {0}; size_t argCount = 1; - HiLog::Debug(LABEL, "CreateAlphaPixelmap IN"); + IMAGE_LOGD("CreateAlphaPixelmap IN"); IMG_JS_ARGS(env, info, status, argCount, argValue, thisVar); - IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, HiLog::Error(LABEL, "fail to napi_get_cb_info")); + IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, IMAGE_LOGE("fail to napi_get_cb_info")); std::unique_ptr asyncContext = std::make_unique(); status = napi_unwrap(env, thisVar, reinterpret_cast(&asyncContext->nConstructor)); IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, asyncContext->nConstructor), - nullptr, HiLog::Error(LABEL, "fail to unwrap context")); + nullptr, IMAGE_LOGE("fail to unwrap context")); asyncContext->rPixelMap = asyncContext->nConstructor->nativePixelMap_; IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, asyncContext->rPixelMap), - nullptr, HiLog::Error(LABEL, "empty native pixelmap")); + nullptr, IMAGE_LOGE("empty native pixelmap")); if (argCount == NUM_1 && ImageNapiUtils::getType(env, argValue[argCount - 1]) == napi_function) { napi_create_reference(env, argValue[argCount - 1], refCount, &asyncContext->callbackRef); } @@ -1683,7 +1685,7 @@ napi_value PixelMapNapi::CreateAlphaPixelmap(napi_env env, napi_callback_info in context->status = SUCCESS; }, CreateAlphaPixelmapComplete, asyncContext, asyncContext->work); IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), - nullptr, HiLog::Error(LABEL, "fail to create async work")); + nullptr, IMAGE_LOGE("fail to create async work")); return result; } @@ -1696,28 +1698,28 @@ napi_value PixelMapNapi::GetDensity(napi_env env, napi_callback_info info) napi_value thisVar = nullptr; size_t argCount = 0; - HiLog::Debug(LABEL, "GetDensity IN"); + IMAGE_LOGD("GetDensity IN"); IMG_JS_ARGS(env, info, status, argCount, nullptr, thisVar); - IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), result, HiLog::Error(LABEL, "fail to napi_get_cb_info")); + IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), result, IMAGE_LOGE("fail to napi_get_cb_info")); std::unique_ptr pixelMapNapi = nullptr; status = napi_unwrap(env, thisVar, reinterpret_cast(&pixelMapNapi)); - IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, pixelMapNapi), result, HiLog::Error(LABEL, "fail to unwrap context")); + IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, pixelMapNapi), result, IMAGE_LOGE("fail to unwrap context")); IMG_NAPI_CHECK_RET_D(pixelMapNapi->GetPixelNapiEditable(), ImageNapiUtils::ThrowExceptionError(env, ERR_RESOURCE_UNAVAILABLE, "Pixelmap has crossed threads . GetDensity failed"), - HiLog::Error(LABEL, "Pixelmap has crossed threads . GetDensity failed")); + IMAGE_LOGE("Pixelmap has crossed threads . GetDensity failed")); if (pixelMapNapi->nativePixelMap_ != nullptr) { uint32_t baseDensity = pixelMapNapi->nativePixelMap_->GetBaseDensity(); status = napi_create_int32(env, baseDensity, &result); if (!IMG_IS_OK(status)) { - HiLog::Error(LABEL, "napi_create_int32 failed!"); + IMAGE_LOGE("napi_create_int32 failed!"); } } else { - HiLog::Error(LABEL, "native pixelmap is nullptr!"); + IMAGE_LOGE("native pixelmap is nullptr!"); } pixelMapNapi.release(); return result; @@ -1734,9 +1736,9 @@ napi_value PixelMapNapi::SetDensity(napi_env env, napi_callback_info info) size_t argCount = NUM_1; uint32_t density = 0; - HiLog::Debug(LABEL, "SetDensity IN"); + IMAGE_LOGD("SetDensity IN"); IMG_JS_ARGS(env, info, status, argCount, argValue, thisVar); - IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), result, HiLog::Error(LABEL, "fail to napi_get_cb_info")); + IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), result, IMAGE_LOGE("fail to napi_get_cb_info")); NAPI_ASSERT(env, (argCount == NUM_1 && ImageNapiUtils::getType(env, argValue[NUM_0]) == napi_number), @@ -1746,18 +1748,18 @@ napi_value PixelMapNapi::SetDensity(napi_env env, napi_callback_info info) std::unique_ptr pixelMapNapi = nullptr; status = napi_unwrap(env, thisVar, reinterpret_cast(&pixelMapNapi)); - IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, pixelMapNapi), result, HiLog::Error(LABEL, "fail to unwrap context")); + IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, pixelMapNapi), result, IMAGE_LOGE("fail to unwrap context")); IMG_NAPI_CHECK_RET_D(pixelMapNapi->GetPixelNapiEditable(), ImageNapiUtils::ThrowExceptionError(env, ERR_RESOURCE_UNAVAILABLE, "Pixelmap has crossed threads . SetDensity failed"), - HiLog::Error(LABEL, "Pixelmap has crossed threads . SetDensity failed")); + IMAGE_LOGE("Pixelmap has crossed threads . SetDensity failed")); if (pixelMapNapi->nativePixelMap_ != nullptr) { ImageInfo imageinfo; pixelMapNapi->nativePixelMap_->GetImageInfo(imageinfo); imageinfo.baseDensity = density; pixelMapNapi->nativePixelMap_->SetImageInfo(imageinfo, true); } else { - HiLog::Error(LABEL, "native pixelmap is nullptr!"); + IMAGE_LOGE("native pixelmap is nullptr!"); } pixelMapNapi.release(); return result; @@ -1774,16 +1776,16 @@ napi_value PixelMapNapi::Release(napi_env env, napi_callback_info info) napi_value argValue[1] = {0}; size_t argCount = 1; - HiLog::Debug(LABEL, "Release IN"); + IMAGE_LOGD("Release IN"); IMG_JS_ARGS(env, info, status, argCount, argValue, thisVar); - IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, HiLog::Error(LABEL, "fail to napi_get_cb_info")); + IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), nullptr, IMAGE_LOGE("fail to napi_get_cb_info")); std::unique_ptr asyncContext = std::make_unique(); status = napi_unwrap(env, thisVar, reinterpret_cast(&asyncContext->nConstructor)); IMG_NAPI_CHECK_RET_D(IMG_IS_READY(status, asyncContext->nConstructor), - nullptr, HiLog::Error(LABEL, "fail to unwrap context")); + nullptr, IMAGE_LOGE("fail to unwrap context")); if (argCount == 1 && ImageNapiUtils::getType(env, argValue[argCount - 1]) == napi_function) { napi_create_reference(env, argValue[argCount - 1], refCount, &asyncContext->callbackRef); @@ -1798,7 +1800,7 @@ napi_value PixelMapNapi::Release(napi_env env, napi_callback_info info) asyncContext->status = ERROR; } else { if (asyncContext->nConstructor->nativePixelMap_ != nullptr) { - HiLog::Debug(LABEL, "Release in napi_id:%{public}d, id:%{public}d", + IMAGE_LOGD("Release in napi_id:%{public}d, id:%{public}d", asyncContext->nConstructor->GetUniqueId(), asyncContext->nConstructor->nativePixelMap_->GetUniqueId()); asyncContext->nConstructor->nativePixelMap_.reset(); @@ -1811,7 +1813,7 @@ napi_value PixelMapNapi::Release(napi_env env, napi_callback_info info) }, EmptyResultComplete, asyncContext, asyncContext->work); IMG_NAPI_CHECK_RET_D(IMG_IS_OK(status), - nullptr, HiLog::Error(LABEL, "fail to create async work")); + nullptr, IMAGE_LOGE("fail to create async work")); return result; } @@ -1830,13 +1832,13 @@ static bool prepareNapiEnv(napi_env env, napi_callback_info info, struct NapiVal napi_get_undefined(env, &(nVal->result)); nVal->status = napi_get_cb_info(env, info, &(nVal->argc), nVal->argv, &(nVal->thisVar), nullptr); if (nVal->status != napi_ok) { - HiLog::Error(LABEL, "fail to napi_get_cb_info"); + IMAGE_LOGE("fail to napi_get_cb_info"); return false; } nVal->context = std::make_unique(); nVal->status = napi_unwrap(env, nVal->thisVar, reinterpret_cast(&(nVal->context->nConstructor))); if (nVal->status != napi_ok) { - HiLog::Error(LABEL, "fail to unwrap context"); + IMAGE_LOGE("fail to unwrap context"); return false; } nVal->context->status = SUCCESS; @@ -1846,7 +1848,7 @@ static bool prepareNapiEnv(napi_env env, napi_callback_info info, struct NapiVal static void SetAlphaExec(napi_env env, PixelMapAsyncContext* context) { if (context == nullptr) { - HiLog::Error(LABEL, "Null context"); + IMAGE_LOGE("Null context"); return; } if (context->status == SUCCESS) { @@ -1854,11 +1856,11 @@ static void SetAlphaExec(napi_env env, PixelMapAsyncContext* context) context->status = context->rPixelMap->SetAlpha( static_cast(context->alpha)); } else { - HiLog::Error(LABEL, "Null native ref"); + IMAGE_LOGE("Null native ref"); context->status = ERR_IMAGE_INIT_ABNORMAL; } } else { - HiLog::Debug(LABEL, "Scale has failed. do nothing"); + IMAGE_LOGD("Scale has failed. do nothing"); } } @@ -1869,19 +1871,19 @@ napi_value PixelMapNapi::SetAlpha(napi_env env, napi_callback_info info) napi_value argValue[NUM_2] = {0}; nVal.argv = argValue; - HiLog::Debug(LABEL, "SetAlpha IN"); + IMAGE_LOGD("SetAlpha IN"); if (!prepareNapiEnv(env, info, &nVal)) { return nVal.result; } nVal.context->rPixelMap = nVal.context->nConstructor->nativePixelMap_; if (nVal.argc != NUM_1 && nVal.argc != NUM_2) { - HiLog::Error(LABEL, "Invalid args count %{public}zu", nVal.argc); + IMAGE_LOGE("Invalid args count %{public}zu", nVal.argc); nVal.context->status = ERR_IMAGE_INVALID_PARAMETER; } else { if (napi_ok != napi_get_value_double(env, nVal.argv[NUM_0], &(nVal.context->alpha))) { - HiLog::Error(LABEL, "Arg 0 type mismatch"); + IMAGE_LOGE("Arg 0 type mismatch"); nVal.context->status = ERR_IMAGE_INVALID_PARAMETER; } } @@ -1918,7 +1920,7 @@ napi_value PixelMapNapi::SetAlpha(napi_env env, napi_callback_info info) static void ScaleExec(napi_env env, PixelMapAsyncContext* context) { if (context == nullptr) { - HiLog::Error(LABEL, "Null context"); + IMAGE_LOGE("Null context"); return; } if (context->status == SUCCESS) { @@ -1926,11 +1928,11 @@ static void ScaleExec(napi_env env, PixelMapAsyncContext* context) context->rPixelMap->scale(static_cast(context->xArg), static_cast(context->yArg)); context->status = SUCCESS; } else { - HiLog::Error(LABEL, "Null native ref"); + IMAGE_LOGE("Null native ref"); context->status = ERR_IMAGE_INIT_ABNORMAL; } } else { - HiLog::Debug(LABEL, "Scale has failed. do nothing"); + IMAGE_LOGD("Scale has failed. do nothing"); } } @@ -1940,22 +1942,22 @@ napi_value PixelMapNapi::Scale(napi_env env, napi_callback_info info) nVal.argc = NUM_3; napi_value argValue[NUM_3] = {0}; nVal.argv = argValue; - HiLog::Debug(LABEL, "Scale IN"); + IMAGE_LOGD("Scale IN"); if (!prepareNapiEnv(env, info, &nVal)) { return nVal.result; } nVal.context->rPixelMap = nVal.context->nConstructor->nativePixelMap_; if (nVal.argc != NUM_2 && nVal.argc != NUM_3) { - HiLog::Error(LABEL, "Invalid args count %{public}zu", nVal.argc); + IMAGE_LOGE("Invalid args count %{public}zu", nVal.argc); nVal.context->status = ERR_IMAGE_INVALID_PARAMETER; } else { if (napi_ok != napi_get_value_double(env, nVal.argv[NUM_0], &(nVal.context->xArg))) { - HiLog::Error(LABEL, "Arg 0 type mismatch"); + IMAGE_LOGE("Arg 0 type mismatch"); nVal.context->status = ERR_IMAGE_INVALID_PARAMETER; } if (napi_ok != napi_get_value_double(env, nVal.argv[NUM_1], &(nVal.context->yArg))) { - HiLog::Error(LABEL, "Arg 1 type mismatch"); + IMAGE_LOGE("Arg 1 type mismatch"); nVal.context->status = ERR_IMAGE_INVALID_PARAMETER; } } @@ -1992,7 +1994,7 @@ napi_value PixelMapNapi::Scale(napi_env env, napi_callback_info info) static void TranslateExec(napi_env env, PixelMapAsyncContext* context) { if (context == nullptr) { - HiLog::Error(LABEL, "Null context"); + IMAGE_LOGE("Null context"); return; } if (context->status == SUCCESS) { @@ -2000,11 +2002,11 @@ static void TranslateExec(napi_env env, PixelMapAsyncContext* context) context->rPixelMap->translate(static_cast(context->xArg), static_cast(context->yArg)); context->status = SUCCESS; } else { - HiLog::Error(LABEL, "Null native ref"); + IMAGE_LOGE("Null native ref"); context->status = ERR_IMAGE_INIT_ABNORMAL; } } else { - HiLog::Debug(LABEL, "Translate has failed. do nothing"); + IMAGE_LOGD("Translate has failed. do nothing"); } } @@ -2014,22 +2016,22 @@ napi_value PixelMapNapi::Translate(napi_env env, napi_callback_info info) nVal.argc = NUM_3; napi_value argValue[NUM_3] = {0}; nVal.argv = argValue; - HiLog::Debug(LABEL, "Translate IN"); + IMAGE_LOGD("Translate IN"); if (!prepareNapiEnv(env, info, &nVal)) { return nVal.result; } nVal.context->rPixelMap = nVal.context->nConstructor->nativePixelMap_; if (nVal.argc != NUM_2 && nVal.argc != NUM_3) { - HiLog::Error(LABEL, "Invalid args count"); + IMAGE_LOGE("Invalid args count"); nVal.context->status = ERR_IMAGE_INVALID_PARAMETER; } else { if (napi_ok != napi_get_value_double(env, nVal.argv[NUM_0], &(nVal.context->xArg))) { - HiLog::Error(LABEL, "Arg 0 type mismatch"); + IMAGE_LOGE("Arg 0 type mismatch"); nVal.context->status = ERR_IMAGE_INVALID_PARAMETER; } if (napi_ok != napi_get_value_double(env, nVal.argv[NUM_1], &(nVal.context->yArg))) { - HiLog::Error(LABEL, "Arg 1 type mismatch"); + IMAGE_LOGE("Arg 1 type mismatch"); nVal.context->status = ERR_IMAGE_INVALID_PARAMETER; } } @@ -2066,7 +2068,7 @@ napi_value PixelMapNapi::Translate(napi_env env, napi_callback_info info) static void RotateExec(napi_env env, PixelMapAsyncContext* context) { if (context == nullptr) { - HiLog::Error(LABEL, "Null context"); + IMAGE_LOGE("Null context"); return; } if (context->status == SUCCESS) { @@ -2074,11 +2076,11 @@ static void RotateExec(napi_env env, PixelMapAsyncContext* context) context->rPixelMap->rotate(context->xArg); context->status = SUCCESS; } else { - HiLog::Error(LABEL, "Null native ref"); + IMAGE_LOGE("Null native ref"); context->status = ERR_IMAGE_INIT_ABNORMAL; } } else { - HiLog::Debug(LABEL, "Rotate has failed. do nothing"); + IMAGE_LOGD("Rotate has failed. do nothing"); } } @@ -2088,18 +2090,18 @@ napi_value PixelMapNapi::Rotate(napi_env env, napi_callback_info info) nVal.argc = NUM_2; napi_value argValue[NUM_2] = {0}; nVal.argv = argValue; - HiLog::Debug(LABEL, "Rotate IN"); + IMAGE_LOGD("Rotate IN"); if (!prepareNapiEnv(env, info, &nVal)) { return nVal.result; } nVal.context->rPixelMap = nVal.context->nConstructor->nativePixelMap_; if (nVal.argc != NUM_1 && nVal.argc != NUM_2) { - HiLog::Error(LABEL, "Invalid args count"); + IMAGE_LOGE("Invalid args count"); nVal.context->status = ERR_IMAGE_INVALID_PARAMETER; } else { if (napi_ok != napi_get_value_double(env, nVal.argv[NUM_0], &(nVal.context->xArg))) { - HiLog::Error(LABEL, "Arg 0 type mismatch"); + IMAGE_LOGE("Arg 0 type mismatch"); nVal.context->status = ERR_IMAGE_INVALID_PARAMETER; } } @@ -2136,7 +2138,7 @@ napi_value PixelMapNapi::Rotate(napi_env env, napi_callback_info info) static void FlipExec(napi_env env, PixelMapAsyncContext* context) { if (context == nullptr) { - HiLog::Error(LABEL, "Null context"); + IMAGE_LOGE("Null context"); return; } if (context->status == SUCCESS) { @@ -2144,11 +2146,11 @@ static void FlipExec(napi_env env, PixelMapAsyncContext* context) context->rPixelMap->flip(context->xBarg, context->yBarg); context->status = SUCCESS; } else { - HiLog::Error(LABEL, "Null native ref"); + IMAGE_LOGE("Null native ref"); context->status = ERR_IMAGE_INIT_ABNORMAL; } } else { - HiLog::Debug(LABEL, "Flip has failed. do nothing"); + IMAGE_LOGD("Flip has failed. do nothing"); } } @@ -2158,22 +2160,22 @@ napi_value PixelMapNapi::Flip(napi_env env, napi_callback_info info) nVal.argc = NUM_3; napi_value argValue[NUM_3] = {0}; nVal.argv = argValue; - HiLog::Debug(LABEL, "Flip IN"); + IMAGE_LOGD("Flip IN"); if (!prepareNapiEnv(env, info, &nVal)) { return nVal.result; } nVal.context->rPixelMap = nVal.context->nConstructor->nativePixelMap_; if (nVal.argc != NUM_2 && nVal.argc != NUM_3) { - HiLog::Error(LABEL, "Invalid args count"); + IMAGE_LOGE("Invalid args count"); nVal.context->status = ERR_IMAGE_INVALID_PARAMETER; } else { if (napi_ok != napi_get_value_bool(env, nVal.argv[NUM_0], &(nVal.context->xBarg))) { - HiLog::Error(LABEL, "Arg 0 type mismatch"); + IMAGE_LOGE("Arg 0 type mismatch"); nVal.context->status = ERR_IMAGE_INVALID_PARAMETER; } if (napi_ok != napi_get_value_bool(env, nVal.argv[NUM_1], &(nVal.context->yBarg))) { - HiLog::Error(LABEL, "Arg 1 type mismatch"); + IMAGE_LOGE("Arg 1 type mismatch"); nVal.context->status = ERR_IMAGE_INVALID_PARAMETER; } } @@ -2210,18 +2212,18 @@ napi_value PixelMapNapi::Flip(napi_env env, napi_callback_info info) static void CropExec(napi_env env, PixelMapAsyncContext* context) { if (context == nullptr) { - HiLog::Error(LABEL, "Null context"); + IMAGE_LOGE("Null context"); return; } if (context->status == SUCCESS) { if (context->rPixelMap != nullptr) { context->status = context->rPixelMap->crop(context->area.region); } else { - HiLog::Error(LABEL, "Null native ref"); + IMAGE_LOGE("Null native ref"); context->status = ERR_IMAGE_INIT_ABNORMAL; } } else { - HiLog::Debug(LABEL, "Crop has failed. do nothing"); + IMAGE_LOGD("Crop has failed. do nothing"); } } @@ -2231,18 +2233,18 @@ napi_value PixelMapNapi::Crop(napi_env env, napi_callback_info info) nVal.argc = NUM_2; napi_value argValue[NUM_2] = {0}; nVal.argv = argValue; - HiLog::Debug(LABEL, "Crop IN"); + IMAGE_LOGD("Crop IN"); if (!prepareNapiEnv(env, info, &nVal)) { return nVal.result; } nVal.context->rPixelMap = nVal.context->nConstructor->nativePixelMap_; if (nVal.argc != NUM_1 && nVal.argc != NUM_2) { - HiLog::Error(LABEL, "Invalid args count"); + IMAGE_LOGE("Invalid args count"); nVal.context->status = ERR_IMAGE_INVALID_PARAMETER; } else { if (!parseRegion(env, nVal.argv[NUM_0], &(nVal.context->area.region))) { - HiLog::Error(LABEL, "Region type mismatch"); + IMAGE_LOGE("Region type mismatch"); nVal.context->status = ERR_IMAGE_INVALID_PARAMETER; } } @@ -2280,7 +2282,7 @@ napi_value PixelMapNapi::GetColorSpace(napi_env env, napi_callback_info info) { NapiValues nVal; nVal.argc = NUM_0; - HiLog::Debug(LABEL, "GetColorSpace IN"); + IMAGE_LOGD("GetColorSpace IN"); napi_get_undefined(env, &nVal.result); if (!prepareNapiEnv(env, info, &nVal)) { return ImageNapiUtils::ThrowExceptionError( @@ -2293,7 +2295,7 @@ napi_value PixelMapNapi::GetColorSpace(napi_env env, napi_callback_info info) IMG_NAPI_CHECK_RET_D(nVal.context->nConstructor->GetPixelNapiEditable(), ImageNapiUtils::ThrowExceptionError(env, ERR_RESOURCE_UNAVAILABLE, "Pixelmap has crossed threads . GetColorSpace failed"), - HiLog::Error(LABEL, "Pixelmap has crossed threads . GetColorSpace failed")); + IMAGE_LOGE("Pixelmap has crossed threads . GetColorSpace failed")); #ifdef IMAGE_COLORSPACE_FLAG if (nVal.context->nConstructor->nativePixelMap_ == nullptr) { return ImageNapiUtils::ThrowExceptionError( @@ -2319,7 +2321,7 @@ napi_value PixelMapNapi::SetColorSpace(napi_env env, napi_callback_info info) nVal.argc = NUM_1; napi_value argValue[NUM_1] = {0}; nVal.argv = argValue; - HiLog::Debug(LABEL, "SetColorSpace IN"); + IMAGE_LOGD("SetColorSpace IN"); napi_get_undefined(env, &nVal.result); if (!prepareNapiEnv(env, info, &nVal)) { return ImageNapiUtils::ThrowExceptionError( @@ -2332,7 +2334,7 @@ napi_value PixelMapNapi::SetColorSpace(napi_env env, napi_callback_info info) IMG_NAPI_CHECK_RET_D(nVal.context->nConstructor->GetPixelNapiEditable(), ImageNapiUtils::ThrowExceptionError(env, ERR_RESOURCE_UNAVAILABLE, "Pixelmap has crossed threads . SetColorSpace failed"), - HiLog::Error(LABEL, "Pixelmap has crossed threads . SetColorSpace failed")); + IMAGE_LOGE("Pixelmap has crossed threads . SetColorSpace failed")); #ifdef IMAGE_COLORSPACE_FLAG nVal.context->colorSpace = ColorManager::GetColorSpaceByJSObject(env, nVal.argv[NUM_0]); if (nVal.context->colorSpace == nullptr) { @@ -2354,7 +2356,7 @@ napi_value PixelMapNapi::Marshalling(napi_env env, napi_callback_info info) nVal.argc = NUM_1; napi_value argValue[NUM_1] = {0}; nVal.argv = argValue; - HiLog::Debug(LABEL, "Marshalling IN"); + IMAGE_LOGD("Marshalling IN"); if (!prepareNapiEnv(env, info, &nVal)) { return ImageNapiUtils::ThrowExceptionError( @@ -2384,16 +2386,16 @@ napi_value PixelMapNapi::Marshalling(napi_env env, napi_callback_info info) static void ApplyColorSpaceExec(napi_env env, PixelMapAsyncContext* context) { if (context == nullptr) { - HiLog::Error(LABEL, "Null context"); + IMAGE_LOGE("Null context"); return; } if (context->status != SUCCESS) { - HiLog::Debug(LABEL, "ApplyColorSpace has failed. do nothing"); + IMAGE_LOGD("ApplyColorSpace has failed. do nothing"); return; } if (context->rPixelMap == nullptr || context->colorSpace == nullptr) { context->status = ERR_IMAGE_INIT_ABNORMAL; - HiLog::Error(LABEL, "ApplyColorSpace Null native ref"); + IMAGE_LOGE("ApplyColorSpace Null native ref"); return; } context->status = context->rPixelMap->ApplyColorSpace(*(context->colorSpace)); @@ -2402,7 +2404,7 @@ static void ApplyColorSpaceExec(napi_env env, PixelMapAsyncContext* context) static void ParseColorSpaceVal(napi_env env, napi_value val, PixelMapAsyncContext* context) { if (context == nullptr) { - HiLog::Error(LABEL, "Null context"); + IMAGE_LOGE("Null context"); return; } @@ -2422,14 +2424,14 @@ napi_value PixelMapNapi::ApplyColorSpace(napi_env env, napi_callback_info info) nVal.argc = NUM_2; napi_value argValue[NUM_2] = {0}; nVal.argv = argValue; - HiLog::Debug(LABEL, "ApplyColorSpace IN"); + IMAGE_LOGD("ApplyColorSpace IN"); if (!prepareNapiEnv(env, info, &nVal)) { return nVal.result; } nVal.context->rPixelMap = nVal.context->nConstructor->nativePixelMap_; if (nVal.argc != NUM_1 && nVal.argc != NUM_2) { - HiLog::Error(LABEL, "Invalid args count"); + IMAGE_LOGE("Invalid args count"); nVal.context->status = ERR_IMAGE_INVALID_PARAMETER; } else { ParseColorSpaceVal(env, nVal.argv[NUM_0], nVal.context.get()); diff --git a/interfaces/innerkits/BUILD.gn b/interfaces/innerkits/BUILD.gn index c8c15351a..871cf9039 100644 --- a/interfaces/innerkits/BUILD.gn +++ b/interfaces/innerkits/BUILD.gn @@ -223,6 +223,7 @@ if (use_clang_android) { "c_utils:utils", "graphic_2d:color_manager", "graphic_surface:surface", + "hilog:libhilog", "hitrace:hitrace_meter", "ipc:ipc_core", "napi:ace_napi", @@ -356,6 +357,7 @@ ohos_static_library("image_static") { "c_utils:utils", "graphic_2d:color_manager", "graphic_surface:surface", + "hilog:libhilog", ] } subsystem_name = "multimedia" diff --git a/interfaces/kits/js/common/BUILD.gn b/interfaces/kits/js/common/BUILD.gn index a4bd627bf..8e553b82f 100644 --- a/interfaces/kits/js/common/BUILD.gn +++ b/interfaces/kits/js/common/BUILD.gn @@ -175,7 +175,10 @@ if (use_clang_ios) { "$image_subsystem/frameworks/innerkitsimpl/pixelconverter:pixelconvertadapter", ] - external_deps = [ "napi:ace_napi" ] + external_deps = [ + "hilog:libhilog", + "napi:ace_napi", + ] output_name = "libimage" relative_install_dir = "module/multimedia" @@ -211,6 +214,7 @@ if (use_clang_ios) { "-DIMAGE_DEBUG_FLAG", "-DIMAGE_COLORSPACE_FLAG", ] + external_deps = [] if (use_clang_android) { defines = image_decode_android_defines @@ -239,9 +243,10 @@ if (use_clang_ios) { "$image_subsystem/frameworks/innerkitsimpl/utils:image_utils", "$image_subsystem/interfaces/innerkits:image_native", ] + external_deps += [ "hilog:libhilog" ] } - external_deps = [ + external_deps += [ "c_utils:utils", "graphic_2d:color_manager", "graphic_2d:color_space_object_convertor", diff --git a/interfaces/kits/native/ndk_test_example/my_pixel_map.cpp b/interfaces/kits/native/ndk_test_example/my_pixel_map.cpp index d7b414a90..fd62f87e6 100644 --- a/interfaces/kits/native/ndk_test_example/my_pixel_map.cpp +++ b/interfaces/kits/native/ndk_test_example/my_pixel_map.cpp @@ -15,14 +15,17 @@ #include "my_pixel_map.h" #include "media_errors.h" -#include "hilog/log.h" +#include "image_log.h" #include "image_napi_utils.h" #include "image_pixel_map_napi.h" -#include "log_tags.h" -using OHOS::HiviewDFX::HiLog; +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE + +#undef LOG_TAG +#define LOG_TAG "MyPixelMapNapiTest" + namespace { -constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "MyPixelMapNapiTest"}; constexpr uint32_t TEST_ARG_SUM = 1; } namespace OHOS { @@ -52,32 +55,32 @@ napi_value MyPixelMap::Init(napi_env env, napi_value exports) if (napi_define_class(env, CLASS_NAME.c_str(), NAPI_AUTO_LENGTH, Constructor, nullptr, IMG_ARRAY_SIZE(props), props, &constructor) != napi_ok) { - HiLog::Error(LABEL, "define class fail"); + IMAGE_LOGE("define class fail"); return nullptr; } if (napi_create_reference(env, constructor, 1, &sConstructor_) != napi_ok) { - HiLog::Error(LABEL, "create reference fail"); + IMAGE_LOGE("create reference fail"); return nullptr; } if (napi_set_named_property(env, exports, CLASS_NAME.c_str(), constructor) != napi_ok) { - HiLog::Error(LABEL, "set named property fail"); + IMAGE_LOGE("set named property fail"); return nullptr; } if (napi_define_properties(env, exports, IMG_ARRAY_SIZE(static_prop), static_prop) != napi_ok) { - HiLog::Error(LABEL, "define properties fail"); + IMAGE_LOGE("define properties fail"); return nullptr; } - HiLog::Debug(LABEL, "Init success"); + IMAGE_LOGD("Init success"); return exports; } napi_value MyPixelMap::Constructor(napi_env env, napi_callback_info info) { - HiLog::Debug(LABEL, "Constructor IN"); + IMAGE_LOGD("Constructor IN"); napi_value undefineVar = nullptr; napi_get_undefined(env, &undefineVar); @@ -87,13 +90,13 @@ napi_value MyPixelMap::Constructor(napi_env env, napi_callback_info info) napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, nullptr); - HiLog::Debug(LABEL, "Constructor OUT"); + IMAGE_LOGD("Constructor OUT"); return thisVar; } napi_value MyPixelMap::TestGetImageInfo(napi_env env, napi_callback_info info) { - HiLog::Debug(LABEL, "TestGetImageInfo IN"); + IMAGE_LOGD("TestGetImageInfo IN"); napi_value result = nullptr; napi_get_undefined(env, &result); @@ -105,23 +108,23 @@ napi_value MyPixelMap::TestGetImageInfo(napi_env env, napi_callback_info info) status = napi_get_cb_info(env, info, &argCount, argValue, &thisVar, nullptr); if (status != napi_ok) { - HiLog::Error(LABEL, "napi_get_cb_info fail"); + IMAGE_LOGE("napi_get_cb_info fail"); } - HiLog::Debug(LABEL, "OH_GetImageInfo Test|Begin"); + IMAGE_LOGD("OH_GetImageInfo Test|Begin"); OhosPixelMapInfo pixelMapInfo; int32_t res = OH_GetImageInfo(env, argValue[0], &pixelMapInfo); - HiLog::Debug(LABEL, "OH_GetImageInfo Test|End, res=%{public}d", res); - HiLog::Debug(LABEL, "OH_GetImageInfo, w=%{public}u, h=%{public}u, r=%{public}u, f=%{public}d", + IMAGE_LOGD("OH_GetImageInfo Test|End, res=%{public}d", res); + IMAGE_LOGD("OH_GetImageInfo, w=%{public}u, h=%{public}u, r=%{public}u, f=%{public}d", pixelMapInfo.width, pixelMapInfo.height, pixelMapInfo.rowSize, pixelMapInfo.pixelFormat); - HiLog::Debug(LABEL, "TestGetImageInfo OUT"); + IMAGE_LOGD("TestGetImageInfo OUT"); return result; } napi_value MyPixelMap::TestAccessPixels(napi_env env, napi_callback_info info) { - HiLog::Debug(LABEL, "TestAccessPixels IN"); + IMAGE_LOGD("TestAccessPixels IN"); napi_value result = nullptr; napi_get_undefined(env, &result); @@ -133,21 +136,21 @@ napi_value MyPixelMap::TestAccessPixels(napi_env env, napi_callback_info info) status = napi_get_cb_info(env, info, &argCount, argValue, &thisVar, nullptr); if (status != napi_ok) { - HiLog::Error(LABEL, "napi_get_cb_info fail"); + IMAGE_LOGE("napi_get_cb_info fail"); } - HiLog::Debug(LABEL, "OH_AccessPixels Test|Begin"); + IMAGE_LOGD("OH_AccessPixels Test|Begin"); void* addrPtr = nullptr; int32_t res = OH_AccessPixels(env, argValue[0], &addrPtr); - HiLog::Debug(LABEL, "OH_AccessPixels Test|End, res=%{public}d", res); + IMAGE_LOGD("OH_AccessPixels Test|End, res=%{public}d", res); - HiLog::Debug(LABEL, "TestAccessPixels OUT"); + IMAGE_LOGD("TestAccessPixels OUT"); return result; } napi_value MyPixelMap::TestUnAccessPixels(napi_env env, napi_callback_info info) { - HiLog::Debug(LABEL, "TestUnAccessPixels IN"); + IMAGE_LOGD("TestUnAccessPixels IN"); napi_value result = nullptr; napi_get_undefined(env, &result); @@ -159,14 +162,14 @@ napi_value MyPixelMap::TestUnAccessPixels(napi_env env, napi_callback_info info) status = napi_get_cb_info(env, info, &argCount, argValue, &thisVar, nullptr); if (status != napi_ok) { - HiLog::Error(LABEL, "napi_get_cb_info fail"); + IMAGE_LOGE("napi_get_cb_info fail"); } - HiLog::Debug(LABEL, "OH_UnAccessPixels Test|Begin"); + IMAGE_LOGD("OH_UnAccessPixels Test|Begin"); int32_t res = OH_UnAccessPixels(env, argValue[0]); - HiLog::Debug(LABEL, "OH_UnAccessPixels Test|End, res=%{public}d", res); + IMAGE_LOGD("OH_UnAccessPixels Test|End, res=%{public}d", res); - HiLog::Debug(LABEL, "TestUnAccessPixels OUT"); + IMAGE_LOGD("TestUnAccessPixels OUT"); return result; } @@ -175,7 +178,7 @@ napi_value MyPixelMap::TestUnAccessPixels(napi_env env, napi_callback_info info) */ static napi_value Export(napi_env env, napi_value exports) { - HiLog::Info(LABEL, "MyPixelMap CALL"); + IMAGE_LOGI("MyPixelMap CALL"); MyPixelMap::Init(env, exports); return exports; } diff --git a/mock/native/src/HiLog.cpp b/mock/native/src/HiLog.cpp index 9b0a34804..69de5fa9c 100644 --- a/mock/native/src/HiLog.cpp +++ b/mock/native/src/HiLog.cpp @@ -19,6 +19,11 @@ #include "hilog/log_cpp.h" #include "ostream" +int HiLogPrint(LogType type, LogLevel level, unsigned int domain, const char *tag, const char *fmt, ...) +{ + return 0; +} + namespace OHOS { namespace HiviewDFX { using namespace std; diff --git a/plugins/common/libs/image/formatagentplugin/BUILD.gn b/plugins/common/libs/image/formatagentplugin/BUILD.gn index 670138f82..9e00f7b0b 100644 --- a/plugins/common/libs/image/formatagentplugin/BUILD.gn +++ b/plugins/common/libs/image/formatagentplugin/BUILD.gn @@ -43,6 +43,7 @@ ohos_shared_library("imageformatagent") { "//foundation/multimedia/image_framework/plugins/common/libs/image/formatagentplugin/include", "//foundation/multimedia/image_framework/plugins/manager/include/utils", "//foundation/multimedia/image_framework/interfaces/innerkits/include", + "${image_subsystem}/frameworks/innerkitsimpl/utils/include", ] if (use_mingw_win) { @@ -74,7 +75,6 @@ ohos_shared_library("imageformatagent") { "hilog:libhilog", ] } - part_name = "image_framework" subsystem_name = "multimedia" diff --git a/plugins/common/libs/image/formatagentplugin/src/bmp_format_agent.cpp b/plugins/common/libs/image/formatagentplugin/src/bmp_format_agent.cpp index ac56ac971..c43e5ee00 100644 --- a/plugins/common/libs/image/formatagentplugin/src/bmp_format_agent.cpp +++ b/plugins/common/libs/image/formatagentplugin/src/bmp_format_agent.cpp @@ -14,18 +14,21 @@ */ #include "bmp_format_agent.h" -#include "hilog/log_c.h" -#include "hilog/log_cpp.h" -#include "log_tags.h" + +#include "image_log.h" #include "plugin_service.h" #include "sched.h" #include "string" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "BmpFormatAgent" + namespace OHOS { namespace ImagePlugin { -using namespace OHOS::HiviewDFX; using namespace MultimediaPlugin; -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "BmpFormatAgent" }; namespace { const std::string FORMAT_TYPE = "image/bmp"; constexpr uint8_t BMP_HEADER[] = { 0x42, 0x4D }; @@ -44,17 +47,17 @@ uint32_t BmpFormatAgent::GetHeaderSize() bool BmpFormatAgent::CheckFormat(const void *headerData, uint32_t dataSize) { if (headerData == nullptr) { - HiLog::Error(LABEL, "check format failed: header data is null."); + IMAGE_LOGE("check format failed: header data is null."); return false; } uint32_t headerSize = sizeof(BMP_HEADER); if (dataSize < headerSize) { - HiLog::Error(LABEL, "read head size:[%{public}u] less than header size:[%{public}u].", dataSize, headerSize); + IMAGE_LOGE("read head size:[%{public}u] less than header size:[%{public}u].", dataSize, headerSize); return false; } if (memcmp(headerData, BMP_HEADER, headerSize) != 0) { - HiLog::Info(LABEL, "header stamp mismatch."); + IMAGE_LOGI("header stamp mismatch."); return false; } return true; diff --git a/plugins/common/libs/image/formatagentplugin/src/gif_format_agent.cpp b/plugins/common/libs/image/formatagentplugin/src/gif_format_agent.cpp index 316c71587..c61bea1b9 100644 --- a/plugins/common/libs/image/formatagentplugin/src/gif_format_agent.cpp +++ b/plugins/common/libs/image/formatagentplugin/src/gif_format_agent.cpp @@ -14,23 +14,26 @@ */ #include "gif_format_agent.h" -#include "hilog/log_c.h" -#include "hilog/log_cpp.h" -#include "log_tags.h" + +#include "image_log.h" #include "plugin_service.h" #include "sched.h" #include "string" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "GifFormatAgent" + namespace OHOS { namespace ImagePlugin { -using namespace OHOS::HiviewDFX; using namespace MultimediaPlugin; static const std::string FORMAT_TYPE = "image/gif"; static const char GIF87_STAMP[] = "GIF87a"; static const char GIF89_STAMP[] = "GIF89a"; static const uint8_t GIF_STAMP_LEN = 6; -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "GifFormatAgent" }; std::string GifFormatAgent::GetFormatType() { @@ -45,17 +48,17 @@ uint32_t GifFormatAgent::GetHeaderSize() bool GifFormatAgent::CheckFormat(const void *headerData, uint32_t dataSize) { if (headerData == nullptr) { - HiLog::Error(LABEL, "check format failed: header data is null."); + IMAGE_LOGE("check format failed: header data is null."); return false; } if (dataSize < GIF_STAMP_LEN) { - HiLog::Error(LABEL, "read head size:[%{public}u] less than header size:[%{public}u].", dataSize, GIF_STAMP_LEN); + IMAGE_LOGE("read head size:[%{public}u] less than header size:[%{public}u].", dataSize, GIF_STAMP_LEN); return false; } if (memcmp(GIF87_STAMP, headerData, GIF_STAMP_LEN) != 0 && memcmp(GIF89_STAMP, headerData, GIF_STAMP_LEN) != 0) { - HiLog::Info(LABEL, "header stamp mismatch."); + IMAGE_LOGI("header stamp mismatch."); return false; } return true; diff --git a/plugins/common/libs/image/formatagentplugin/src/heif_format_agent.cpp b/plugins/common/libs/image/formatagentplugin/src/heif_format_agent.cpp index 326c921b7..3749b7caf 100644 --- a/plugins/common/libs/image/formatagentplugin/src/heif_format_agent.cpp +++ b/plugins/common/libs/image/formatagentplugin/src/heif_format_agent.cpp @@ -14,16 +14,20 @@ */ #include "heif_format_agent.h" -#include "hilog/log_c.h" -#include "hilog/log_cpp.h" -#include "log_tags.h" + +#include "image_log.h" #include "plugin_service.h" #include "string" #include "securec.h" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "HeifFormatAgent" + namespace OHOS { namespace ImagePlugin { -using namespace OHOS::HiviewDFX; using namespace MultimediaPlugin; const std::string FORMAT_TYPE = "image/heif"; @@ -37,7 +41,6 @@ constexpr uint32_t TIMES_SEVEN = 7; constexpr uint32_t TIMES_FIVE = 5; constexpr uint32_t TIMES_THREE = 3; constexpr uint32_t TIMES_TWO = 2; -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "HeifFormatAgent" }; std::string HeifFormatAgent::GetFormatType() { @@ -52,18 +55,18 @@ uint32_t HeifFormatAgent::GetHeaderSize() bool HeifFormatAgent::CheckFormat(const void *headerData, uint32_t dataSize) { if (headerData == nullptr) { - HiLog::Error(LABEL, "check format failed: header data is null."); + IMAGE_LOGE("check format failed: header data is null."); return false; } // Any valid ftyp box should have at least 8 bytes. if (dataSize < HEADER_LEAST_SIZE) { - HiLog::Error(LABEL, "data size[%{public}u] less than eight.", dataSize); + IMAGE_LOGE("data size[%{public}u] less than eight.", dataSize); return false; } uint32_t tmpBuff[HEADER_SIZE]; if (memcpy_s(tmpBuff, HEADER_SIZE, headerData, dataSize) != 0) { - HiLog::Error(LABEL, "memcpy headerData data size:[%{public}d] error.", dataSize); + IMAGE_LOGE("memcpy headerData data size:[%{public}d] error.", dataSize); return false; } @@ -71,7 +74,7 @@ bool HeifFormatAgent::CheckFormat(const void *headerData, uint32_t dataSize) uint64_t chunkSize = EndianSwap32(ptr[0]); // first item uint32_t chunkType = EndianSwap32(ptr[1]); // second item if (chunkType != Fourcc('f', 't', 'y', 'p')) { - HiLog::Error(LABEL, "head type is not ftyp."); + IMAGE_LOGE("head type is not ftyp."); return false; } @@ -83,7 +86,7 @@ bool HeifFormatAgent::CheckFormat(const void *headerData, uint32_t dataSize) // It should at least have major brand (4-byte) and minor version (4-bytes). // The rest of the chunk (if any) is a list of (4-byte) compatible brands. if (chunkDataSize < HEADER_LEAST_SIZE) { - HiLog::Error(LABEL, "chunk data size [%{public}lld] less than eight.", static_cast(chunkDataSize)); + IMAGE_LOGE("chunk data size [%{public}lld] less than eight.", static_cast(chunkDataSize)); return false; } uint32_t numCompatibleBrands = (chunkDataSize - OFFSET_SIZE) / sizeof(uint32_t); @@ -101,7 +104,7 @@ bool HeifFormatAgent::CheckFormat(const void *headerData, uint32_t dataSize) } } } - HiLog::Info(LABEL, "check heif format failed."); + IMAGE_LOGI("check heif format failed."); return false; } @@ -112,21 +115,20 @@ bool HeifFormatAgent::IsHeif64(const void *buffer, const size_t bytesRead, int64 // This indicates that the next 8 bytes represent the chunk size, // and chunk data comes after that. if (bytesRead < HEADER_NEXT_SIZE) { - HiLog::Error(LABEL, "bytes read [%{public}zd] less than sixteen.", bytesRead); + IMAGE_LOGE("bytes read [%{public}zd] less than sixteen.", bytesRead); return false; } auto *chunkSizePtr = static_cast(buffer) + (offset / sizeof(uint64_t)); chunkSize = EndianSwap64(*chunkSizePtr); if (chunkSize < HEADER_NEXT_SIZE) { // The smallest valid chunk is 16 bytes long in this case. - HiLog::Error(LABEL, "chunk size [%{public}llu] less than sixteen.", - static_cast(chunkSize)); + IMAGE_LOGE("chunk size [%{public}llu] less than sixteen.", static_cast(chunkSize)); return false; } offset += OFFSET_SIZE; } else if (chunkSize < HEADER_LEAST_SIZE) { // The smallest valid chunk is 8 bytes long. - HiLog::Error(LABEL, "chunk size [%{public}llu] less than eight.", static_cast(chunkSize)); + IMAGE_LOGE("chunk size [%{public}llu] less than eight.", static_cast(chunkSize)); return false; } diff --git a/plugins/common/libs/image/formatagentplugin/src/jpeg_format_agent.cpp b/plugins/common/libs/image/formatagentplugin/src/jpeg_format_agent.cpp index 3a7ffc604..678dad237 100644 --- a/plugins/common/libs/image/formatagentplugin/src/jpeg_format_agent.cpp +++ b/plugins/common/libs/image/formatagentplugin/src/jpeg_format_agent.cpp @@ -14,21 +14,24 @@ */ #include "jpeg_format_agent.h" -#include "hilog/log_c.h" -#include "hilog/log_cpp.h" -#include "log_tags.h" + +#include "image_log.h" #include "plugin_service.h" #include "sched.h" #include "string" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "JpegFormatAgent" + namespace OHOS { namespace ImagePlugin { -using namespace OHOS::HiviewDFX; using namespace MultimediaPlugin; static const std::string FORMAT_TYPE = "image/jpeg"; static constexpr uint8_t JPEG_HEADER[] = { 0xFF, 0xD8, 0xFF }; -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "JpegFormatAgent" }; std::string JpegFormatAgent::GetFormatType() { @@ -43,17 +46,17 @@ uint32_t JpegFormatAgent::GetHeaderSize() bool JpegFormatAgent::CheckFormat(const void *headerData, uint32_t dataSize) { if (headerData == nullptr) { - HiLog::Error(LABEL, "check format failed: header data is null."); + IMAGE_LOGE("check format failed: header data is null."); return false; } uint32_t headerSize = sizeof(JPEG_HEADER); if (dataSize < headerSize) { - HiLog::Error(LABEL, "read head size:[%{public}u] less than header size:[%{public}u].", dataSize, headerSize); + IMAGE_LOGE("read head size:[%{public}u] less than header size:[%{public}u].", dataSize, headerSize); return false; } if (memcmp(headerData, JPEG_HEADER, headerSize) != 0) { - HiLog::Info(LABEL, "header stamp mismatch."); + IMAGE_LOGI("header stamp mismatch."); return false; } return true; diff --git a/plugins/common/libs/image/formatagentplugin/src/plugin_export.cpp b/plugins/common/libs/image/formatagentplugin/src/plugin_export.cpp index a7cdc544e..a6beca667 100644 --- a/plugins/common/libs/image/formatagentplugin/src/plugin_export.cpp +++ b/plugins/common/libs/image/formatagentplugin/src/plugin_export.cpp @@ -14,14 +14,13 @@ */ #include "plugin_export.h" + #include "bmp_format_agent.h" #include "gif_format_agent.h" #include "heif_format_agent.h" -#include "hilog/log_c.h" -#include "hilog/log_cpp.h" +#include "image_log.h" #include "iosfwd" #include "jpeg_format_agent.h" -#include "log_tags.h" #include "map" #include "plugin_class_base.h" #include "plugin_utils.h" @@ -33,6 +32,11 @@ #include "wbmp_format_agent.h" #include "webp_format_agent.h" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "LibImageFormatAgent" // plugin package name same as metadata. namespace { @@ -53,32 +57,26 @@ PLUGIN_EXPORT_REGISTER_CLASS(OHOS::ImagePlugin::WbmpFormatAgent) PLUGIN_EXPORT_REGISTER_CLASS_END using std::string; -using namespace OHOS::HiviewDFX; - -static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "LibImageFormatAgent" }; - -#define PLUGIN_LOG_D(...) HiLog::Debug(LABEL, __VA_ARGS__) -#define PLUGIN_LOG_E(...) HiLog::Error(LABEL, __VA_ARGS__) // define the external interface of this plugin. PLUGIN_EXPORT_DEFAULT_EXTERNAL_START() PLUGIN_EXPORT_DEFAULT_EXTERNAL_STOP() OHOS::MultimediaPlugin::PluginClassBase *PluginExternalCreate(const string &className) { - HiLog::Debug(LABEL, "PluginExternalCreate: create object for package: %{public}s, class: %{public}s.", - PACKAGE_NAME.c_str(), className.c_str()); + IMAGE_LOGD("PluginExternalCreate: create object for package: %{public}s, class: %{public}s.", + PACKAGE_NAME.c_str(), className.c_str()); auto iter = implClassMap.find(className); if (iter == implClassMap.end()) { - HiLog::Error(LABEL, "PluginExternalCreate: failed to find class: %{public}s, in package: %{public}s.", - className.c_str(), PACKAGE_NAME.c_str()); + IMAGE_LOGE("PluginExternalCreate: failed to find class: %{public}s, in package: %{public}s.", + className.c_str(), PACKAGE_NAME.c_str()); return nullptr; } auto creator = iter->second; if (creator == nullptr) { - HiLog::Error(LABEL, "PluginExternalCreate: null creator for class: %{public}s, in package: %{public}s.", - className.c_str(), PACKAGE_NAME.c_str()); + IMAGE_LOGE("PluginExternalCreate: null creator for class: %{public}s, in package: %{public}s.", + className.c_str(), PACKAGE_NAME.c_str()); return nullptr; } diff --git a/plugins/common/libs/image/formatagentplugin/src/png_format_agent.cpp b/plugins/common/libs/image/formatagentplugin/src/png_format_agent.cpp index efde8c726..78d6fd6bb 100644 --- a/plugins/common/libs/image/formatagentplugin/src/png_format_agent.cpp +++ b/plugins/common/libs/image/formatagentplugin/src/png_format_agent.cpp @@ -14,21 +14,24 @@ */ #include "png_format_agent.h" -#include "hilog/log_c.h" -#include "hilog/log_cpp.h" -#include "log_tags.h" + +#include "image_log.h" #include "plugin_service.h" #include "sched.h" #include "string" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "PngFormatAgent" + namespace OHOS { namespace ImagePlugin { -using namespace OHOS::HiviewDFX; using namespace MultimediaPlugin; static const std::string FORMAT_TYPE = "image/png"; static constexpr uint8_t PNG_HEADER[] = { 137, 80, 78, 71, 13, 10, 26, 10 }; -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "PngFormatAgent" }; std::string PngFormatAgent::GetFormatType() { @@ -43,12 +46,12 @@ uint32_t PngFormatAgent::GetHeaderSize() bool PngFormatAgent::CheckFormat(const void *headerData, uint32_t dataSize) { if (headerData == nullptr || dataSize == 0) { - HiLog::Error(LABEL, "check format input parameter abnormal."); + IMAGE_LOGE("check format input parameter abnormal."); return false; } uint32_t headerSize = sizeof(PNG_HEADER); if (dataSize < headerSize) { - HiLog::Error(LABEL, "read head size:[%{public}u] less than header size:[%{public}u].", dataSize, headerSize); + IMAGE_LOGE("read head size:[%{public}u] less than header size:[%{public}u].", dataSize, headerSize); return false; } return !memcmp(headerData, PNG_HEADER, headerSize); diff --git a/plugins/common/libs/image/formatagentplugin/src/raw_format_agent.cpp b/plugins/common/libs/image/formatagentplugin/src/raw_format_agent.cpp index 91edf2db2..8920a1cb5 100644 --- a/plugins/common/libs/image/formatagentplugin/src/raw_format_agent.cpp +++ b/plugins/common/libs/image/formatagentplugin/src/raw_format_agent.cpp @@ -14,16 +14,20 @@ */ #include "raw_format_agent.h" -#include "hilog/log_c.h" -#include "hilog/log_cpp.h" + +#include "image_log.h" #include "image_plugin_type.h" -#include "log_tags.h" #include "plugin_service.h" #include "string" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "RawFormatAgent" + namespace OHOS { namespace ImagePlugin { -using namespace OHOS::HiviewDFX; using namespace ImagePlugin; using namespace MultimediaPlugin; @@ -41,7 +45,6 @@ using namespace MultimediaPlugin; */ const std::string FORMAT_TYPE = "image/x-raw"; constexpr uint32_t HEADER_SIZE = 0; -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "RawFormatAgent" }; std::string RawFormatAgent::GetFormatType() { @@ -55,7 +58,7 @@ uint32_t RawFormatAgent::GetHeaderSize() bool RawFormatAgent::CheckFormat(const void *headerData, uint32_t dataSize) { - HiLog::Info(LABEL, "RawFormatAgent now pass all image format. dataSize = [%{public}d]", dataSize); + IMAGE_LOGI("RawFormatAgent now pass all image format. dataSize = [%{public}d]", dataSize); return true; } } // namespace ImagePlugin diff --git a/plugins/common/libs/image/formatagentplugin/src/svg_format_agent.cpp b/plugins/common/libs/image/formatagentplugin/src/svg_format_agent.cpp index 9d5931d82..c4f5cd4ff 100644 --- a/plugins/common/libs/image/formatagentplugin/src/svg_format_agent.cpp +++ b/plugins/common/libs/image/formatagentplugin/src/svg_format_agent.cpp @@ -14,23 +14,26 @@ */ #include "svg_format_agent.h" -#include "hilog/log_c.h" -#include "hilog/log_cpp.h" -#include "log_tags.h" + +#include "image_log.h" #include "plugin_service.h" #include "sched.h" #include "string" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "SvgFormatAgent" + namespace OHOS { namespace ImagePlugin { -using namespace OHOS::HiviewDFX; using namespace MultimediaPlugin; namespace { static const std::string FORMAT_TYPE = "image/svg+xml"; static const char SVG_STAMP[] = "= dataSize) { - HiLog::Error(LABEL, "read_header data offset %{public}u. dataSize %{public}u", offset, dataSize); + IMAGE_LOGE("read_header data offset %{public}u. dataSize %{public}u", offset, dataSize); return false; } value = *(stream + offset); @@ -73,24 +76,24 @@ bool WbmpFormatAgent::read_header(const void *stream, uint32_t dataSize) if (!read_byte(pData, data, offset, dataSize) || data != 0) { // unknown type return false; } - HiLog::Debug(LABEL, "read_header data %{public}d.", data); + IMAGE_LOGD("read_header data %{public}d.", data); if (!read_byte(pData, data, offset, dataSize) || (data & 0x9F)) { // skip fixed header return false; } - HiLog::Debug(LABEL, "read_header data %{public}d.", data); + IMAGE_LOGD("read_header data %{public}d.", data); uint64_t width; uint64_t height; if (!read_mbf(pData, width, offset, dataSize) || width > 0xFFFF || !width) { return false; } - HiLog::Debug(LABEL, "read_header width %{public}lld.", static_cast(width)); + IMAGE_LOGD("read_header width %{public}lld.", static_cast(width)); if (!read_mbf(pData, height, offset, dataSize) || height > 0xFFFF || !height) { return false; } - HiLog::Debug(LABEL, "read_header height %{public}lld.", static_cast(height)); + IMAGE_LOGD("read_header height %{public}lld.", static_cast(height)); return true; } @@ -109,16 +112,16 @@ uint32_t WbmpFormatAgent::GetHeaderSize() bool WbmpFormatAgent::CheckFormat(const void *headerData, uint32_t dataSize) { if (headerData == nullptr) { - HiLog::Error(LABEL, "check format failed: header data is null."); + IMAGE_LOGE("check format failed: header data is null."); return false; } if (!read_header(headerData, dataSize)) { - HiLog::Info(LABEL, "not wbmp image format."); + IMAGE_LOGI("not wbmp image format."); return false; } - HiLog::Debug(LABEL, "wbmp image format ok."); + IMAGE_LOGD("wbmp image format ok."); return true; } } // namespace ImagePlugin diff --git a/plugins/common/libs/image/formatagentplugin/src/webp_format_agent.cpp b/plugins/common/libs/image/formatagentplugin/src/webp_format_agent.cpp index 9cc2bddde..8fa92a008 100644 --- a/plugins/common/libs/image/formatagentplugin/src/webp_format_agent.cpp +++ b/plugins/common/libs/image/formatagentplugin/src/webp_format_agent.cpp @@ -14,21 +14,25 @@ */ #include "webp_format_agent.h" + #include -#include "hilog/log_c.h" -#include "hilog/log_cpp.h" -#include "log_tags.h" + +#include "image_log.h" #include "plugin_service.h" #include "sched.h" #include "string" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "WebpFormatAgent" + namespace OHOS { namespace ImagePlugin { -using namespace OHOS::HiviewDFX; using namespace MultimediaPlugin; namespace { -constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "WebpFormatAgent" }; const std::string FORMAT_TYPE = "image/webp"; constexpr size_t WEBP_MINIMUM_LENGTH = 14; const char *WEBP_HEADER_PRE = "RIFF"; @@ -50,7 +54,7 @@ uint32_t WebpFormatAgent::GetHeaderSize() bool WebpFormatAgent::CheckFormat(const void *headerData, uint32_t dataSize) { if (headerData == nullptr || dataSize == 0) { - HiLog::Error(LABEL, "check format input parameter abnormal."); + IMAGE_LOGE("check format input parameter abnormal."); return false; } diff --git a/plugins/common/libs/image/libbmpplugin/BUILD.gn b/plugins/common/libs/image/libbmpplugin/BUILD.gn index 6a5ced37c..ffb921d4d 100644 --- a/plugins/common/libs/image/libbmpplugin/BUILD.gn +++ b/plugins/common/libs/image/libbmpplugin/BUILD.gn @@ -36,6 +36,7 @@ ohos_shared_library("bmpplugin") { "//foundation/multimedia/image_framework/plugins/common/libs/image/libbmpplugin/include", "//foundation/multimedia/image_framework/interfaces/innerkits/include", "//foundation/multimedia/image_framework/frameworks/innerkitsimpl/utils/include", + "${image_subsystem}/frameworks/innerkitsimpl/utils/include", "${graphic_subsystem}/interfaces/inner_api/surface", "$skia_root/skia/include/core", "$skia_root/skia/include/codec", diff --git a/plugins/common/libs/image/libbmpplugin/src/bmp_decoder.cpp b/plugins/common/libs/image/libbmpplugin/src/bmp_decoder.cpp index a4784dabe..e3ddfd268 100644 --- a/plugins/common/libs/image/libbmpplugin/src/bmp_decoder.cpp +++ b/plugins/common/libs/image/libbmpplugin/src/bmp_decoder.cpp @@ -15,21 +15,24 @@ #include "bmp_decoder.h" -#include "hilog/log.h" +#include "image_log.h" #include "image_utils.h" -#include "log_tags.h" #include "media_errors.h" #include "securec.h" #if !defined(IOS_PLATFORM) && !defined(A_PLATFORM) #include "surface_buffer.h" #endif +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "BmpDecoder" + namespace OHOS { namespace ImagePlugin { -using namespace OHOS::HiviewDFX; using namespace Media; using namespace std; -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "BmpDecoder" }; namespace { constexpr uint32_t BMP_IMAGE_NUM = 1; } @@ -53,11 +56,11 @@ void BmpDecoder::Reset() uint32_t BmpDecoder::GetImageSize(uint32_t index, PlSize &size) { if (index >= BMP_IMAGE_NUM) { - HiLog::Error(LABEL, "GetImageSize failed, invalid index:%{public}u, range:%{public}u", index, BMP_IMAGE_NUM); + IMAGE_LOGE("GetImageSize failed, invalid index:%{public}u, range:%{public}u", index, BMP_IMAGE_NUM); return ERR_IMAGE_INVALID_PARAMETER; } if (state_ < BmpDecodingState::SOURCE_INITED) { - HiLog::Error(LABEL, "GetImageSize failed, invalid state:%{public}d", state_); + IMAGE_LOGE("GetImageSize failed, invalid state:%{public}d", state_); return ERR_MEDIA_INVALID_OPERATION; } if (state_ >= BmpDecodingState::BASE_INFO_PARSED) { @@ -66,7 +69,7 @@ uint32_t BmpDecoder::GetImageSize(uint32_t index, PlSize &size) return SUCCESS; } if (!DecodeHeader()) { - HiLog::Error(LABEL, "GetImageSize failed, decode header failed, state=%{public}d", state_); + IMAGE_LOGE("GetImageSize failed, decode header failed, state=%{public}d", state_); return ERR_IMAGE_DECODE_HEAD_ABNORMAL; } size.width = info_.width(); @@ -78,12 +81,12 @@ uint32_t BmpDecoder::GetImageSize(uint32_t index, PlSize &size) uint32_t BmpDecoder::SetDecodeOptions(uint32_t index, const PixelDecodeOptions &opts, PlImageInfo &info) { if (index >= BMP_IMAGE_NUM) { - HiLog::Error(LABEL, "SetDecodeOptions failed, invalid index:%{public}u, range:%{public}u", index, - BMP_IMAGE_NUM); + IMAGE_LOGE("SetDecodeOptions failed, invalid index:%{public}u, range:%{public}u", index, + BMP_IMAGE_NUM); return ERR_IMAGE_INVALID_PARAMETER; } if (state_ < BmpDecodingState::SOURCE_INITED) { - HiLog::Error(LABEL, "SetDecodeOptions failed, invalid state %{public}d", state_); + IMAGE_LOGE("SetDecodeOptions failed, invalid state %{public}d", state_); return ERR_MEDIA_INVALID_OPERATION; } if (state_ >= BmpDecodingState::IMAGE_DECODING) { @@ -92,7 +95,7 @@ uint32_t BmpDecoder::SetDecodeOptions(uint32_t index, const PixelDecodeOptions & } if (state_ < BmpDecodingState::BASE_INFO_PARSED) { if (!DecodeHeader()) { - HiLog::Error(LABEL, "GetImageSize failed, decode header failed, state=%{public}d", state_); + IMAGE_LOGE("GetImageSize failed, decode header failed, state=%{public}d", state_); return ERR_IMAGE_DECODE_HEAD_ABNORMAL; } state_ = BmpDecodingState::BASE_INFO_PARSED; @@ -145,7 +148,7 @@ uint32_t BmpDecoder::SetShareMemBuffer(uint64_t byteCount, DecodeContext &contex static uint32_t DmaMemAlloc(uint64_t count, DecodeContext &context, SkImageInfo &dstInfo) { #if defined(_WIN32) || defined(_APPLE) || defined(A_PLATFORM) || defined(IOS_PLATFORM) - HiLog::Error(LABEL, "Unsupport dma mem alloc"); + IMAGE_LOGE("Unsupport dma mem alloc"); return ERR_IMAGE_DATA_UNSUPPORT; #else sptr sb = SurfaceBuffer::Create(); @@ -161,13 +164,13 @@ static uint32_t DmaMemAlloc(uint64_t count, DecodeContext &context, SkImageInfo }; GSError ret = sb->Alloc(requestConfig); if (ret != GSERROR_OK) { - HiLog::Error(LABEL, "SurfaceBuffer Alloc failed, %{public}s", GSErrorStr(ret).c_str()); + IMAGE_LOGE("SurfaceBuffer Alloc failed, %{public}s", GSErrorStr(ret).c_str()); return ERR_DMA_NOT_EXIST; } void* nativeBuffer = sb.GetRefPtr(); int32_t err = ImageUtils::SurfaceBuffer_Reference(nativeBuffer); if (err != OHOS::GSERROR_OK) { - HiLog::Error(LABEL, "NativeBufferReference failed"); + IMAGE_LOGE("NativeBufferReference failed"); return ERR_DMA_DATA_ABNORMAL; } context.pixelsBuffer.buffer = static_cast(sb->GetVirAddr()); @@ -183,25 +186,25 @@ uint32_t SetBuffer(uint64_t byteCount, DecodeContext &context) { #if !defined(_WIN32) && !defined(_APPLE) && !defined(A_PLATFORM) && !defined(IOS_PLATFORM) if (byteCount == 0) { - HiLog::Error(LABEL, "Decode failed, byteCount is invalid value"); + IMAGE_LOGE("Decode failed, byteCount is invalid value"); return ERR_MEDIA_INVALID_VALUE; } void *outputBuffer = malloc(byteCount); if (outputBuffer == nullptr) { - HiLog::Error(LABEL, "Decode failed, alloc output buffer size:[%{public}llu] error", - static_cast(byteCount)); + IMAGE_LOGE("Decode failed, alloc output buffer size:[%{public}llu] error", + static_cast(byteCount)); return ERR_IMAGE_MALLOC_ABNORMAL; } #ifdef _WIN32 if (memset_s(outputBuffer, 0, byteCount) != EOK) { - HiLog::Error(LABEL, "Decode failed, memset buffer failed", backRet); + IMAGE_LOGE("Decode failed, memset buffer failed", backRet); free(outputBuffer); outputBuffer = nullptr; return ERR_IMAGE_DECODE_FAILED; } #else if (memset_s(outputBuffer, byteCount, 0, byteCount) != EOK) { - HiLog::Error(LABEL, "Decode failed, memset buffer failed"); + IMAGE_LOGE("Decode failed, memset buffer failed"); free(outputBuffer); outputBuffer = nullptr; return ERR_IMAGE_DECODE_FAILED; @@ -220,25 +223,25 @@ uint32_t SetBuffer(uint64_t byteCount, DecodeContext &context) uint32_t SetBufferForPlatform(uint64_t byteCount, DecodeContext &context) { if (byteCount == 0) { - HiLog::Error(LABEL, "Decode failed, byteCount is invalid value"); + IMAGE_LOGE("Decode failed, byteCount is invalid value"); return ERR_MEDIA_INVALID_VALUE; } void *outputBuffer = malloc(byteCount); if (outputBuffer == nullptr) { - HiLog::Error(LABEL, "Decode failed, alloc output buffer size:[%{public}llu] error", - static_cast(byteCount)); + IMAGE_LOGE("Decode failed, alloc output buffer size:[%{public}llu] error", + static_cast(byteCount)); return ERR_IMAGE_MALLOC_ABNORMAL; } #ifdef _WIN32 if (memset_s(outputBuffer, 0, byteCount) != EOK) { - HiLog::Error(LABEL, "Decode failed, memset buffer failed", backRet); + IMAGE_LOGE("Decode failed, memset buffer failed", backRet); free(outputBuffer); outputBuffer = nullptr; return ERR_IMAGE_DECODE_FAILED; } #else if (memset_s(outputBuffer, byteCount, 0, byteCount) != EOK) { - HiLog::Error(LABEL, "Decode failed, memset buffer failed"); + IMAGE_LOGE("Decode failed, memset buffer failed"); free(outputBuffer); outputBuffer = nullptr; return ERR_IMAGE_DECODE_FAILED; @@ -283,22 +286,22 @@ uint32_t BmpDecoder::SetContextPixelsBuffer(uint64_t byteCount, DecodeContext &c uint32_t BmpDecoder::Decode(uint32_t index, DecodeContext &context) { if (index >= BMP_IMAGE_NUM) { - HiLog::Error(LABEL, "Decode failed, invalid index:%{public}u, range:%{public}u", index, BMP_IMAGE_NUM); + IMAGE_LOGE("Decode failed, invalid index:%{public}u, range:%{public}u", index, BMP_IMAGE_NUM); return ERR_IMAGE_INVALID_PARAMETER; } if (codec_ == nullptr) { - HiLog::Error(LABEL, "Decode failed, codec is null"); + IMAGE_LOGE("Decode failed, codec is null"); return ERR_IMAGE_DECODE_FAILED; } if (state_ != BmpDecodingState::IMAGE_DECODING) { - HiLog::Error(LABEL, "Decode failed, invalid state %{public}d", state_); + IMAGE_LOGE("Decode failed, invalid state %{public}d", state_); return ERR_MEDIA_INVALID_OPERATION; } SkImageInfo dstInfo = info_.makeColorType(desireColor_); if (ImageUtils::CheckMulOverflow(dstInfo.width(), dstInfo.height(), dstInfo.bytesPerPixel())) { - HiLog::Error(LABEL, "Decode failed, width:%{public}d, height:%{public}d is too large", - dstInfo.width(), dstInfo.height()); + IMAGE_LOGE("Decode failed, width:%{public}d, height:%{public}d is too large", + dstInfo.width(), dstInfo.height()); return ERR_IMAGE_DECODE_FAILED; } if (context.pixelsBuffer.buffer == nullptr) { @@ -312,7 +315,7 @@ uint32_t BmpDecoder::Decode(uint32_t index, DecodeContext &context) size_t rowBytes = dstInfo.width() * dstInfo.bytesPerPixel(); SkCodec::Result ret = codec_->getPixels(dstInfo, dstBuffer, rowBytes); if (ret != SkCodec::kSuccess) { - HiLog::Error(LABEL, "Decode failed, get pixels failed, ret=%{public}d", ret); + IMAGE_LOGE("Decode failed, get pixels failed, ret=%{public}d", ret); state_ = BmpDecodingState::IMAGE_ERROR; return ERR_IMAGE_DECODE_ABNORMAL; } @@ -330,7 +333,7 @@ bool BmpDecoder::DecodeHeader() { codec_ = SkCodec::MakeFromStream(make_unique(stream_)); if (codec_ == nullptr) { - HiLog::Error(LABEL, "create codec from stream failed"); + IMAGE_LOGE("create codec from stream failed"); return false; } info_ = codec_->getInfo(); @@ -347,7 +350,7 @@ PlAlphaType BmpDecoder::ConvertToAlphaType(SkAlphaType alphaType) case kUnpremul_SkAlphaType: return PlAlphaType::IMAGE_ALPHA_TYPE_UNPREMUL; default: - HiLog::Error(LABEL, "unknown alpha type:%{public}d", alphaType); + IMAGE_LOGE("unknown alpha type:%{public}d", alphaType); break; } return PlAlphaType::IMAGE_ALPHA_TYPE_UNKNOWN; @@ -384,7 +387,7 @@ SkColorType BmpDecoder::ConvertToColorType(PlPixelFormat format, PlPixelFormat & break; } } - HiLog::Debug(LABEL, "unsupported convert to format:%{public}d, set default RGBA", format); + IMAGE_LOGD("unsupported convert to format:%{public}d, set default RGBA", format); outputFormat = PlPixelFormat::RGBA_8888; return kRGBA_8888_SkColorType; } diff --git a/plugins/common/libs/image/libbmpplugin/src/bmp_stream.cpp b/plugins/common/libs/image/libbmpplugin/src/bmp_stream.cpp index 8be119604..6fd802e96 100644 --- a/plugins/common/libs/image/libbmpplugin/src/bmp_stream.cpp +++ b/plugins/common/libs/image/libbmpplugin/src/bmp_stream.cpp @@ -15,25 +15,28 @@ #include "bmp_stream.h" -#include "hilog/log.h" -#include "log_tags.h" +#include "image_log.h" + +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "BmpStream" namespace OHOS { namespace ImagePlugin { -using namespace OHOS::HiviewDFX; -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "BmpStream" }; BmpStream::BmpStream(InputDataStream *stream) : inputStream_(stream) {} size_t BmpStream::read(void *buffer, size_t size) { if (inputStream_ == nullptr) { - HiLog::Error(LABEL, "read failed, inputStream_ is null"); + IMAGE_LOGE("read failed, inputStream_ is null"); return 0; } if (buffer == nullptr) { size_t curPosition = static_cast(inputStream_->Tell()); if (!inputStream_->Seek(curPosition + size)) { - HiLog::Error(LABEL, "read failed, curpositon=%{public}zu, skip size=%{public}zu", curPosition, size); + IMAGE_LOGE("read failed, curpositon=%{public}zu, skip size=%{public}zu", curPosition, size); return 0; } return size; @@ -42,7 +45,7 @@ size_t BmpStream::read(void *buffer, size_t size) uint32_t bufferSize = desireSize; uint32_t readSize = desireSize; if (!inputStream_->Read(desireSize, static_cast(buffer), bufferSize, readSize)) { - HiLog::Error(LABEL, "read failed, desire read size=%{public}u", desireSize); + IMAGE_LOGE("read failed, desire read size=%{public}u", desireSize); return 0; } return readSize; @@ -51,18 +54,18 @@ size_t BmpStream::read(void *buffer, size_t size) size_t BmpStream::peek(void *buffer, size_t size) const { if (inputStream_ == nullptr) { - HiLog::Error(LABEL, "peek failed, inputStream_ is null"); + IMAGE_LOGE("peek failed, inputStream_ is null"); return 0; } if (buffer == nullptr) { - HiLog::Error(LABEL, "peek failed, output buffer is null"); + IMAGE_LOGE("peek failed, output buffer is null"); return 0; } uint32_t desireSize = static_cast(size); uint32_t bufferSize = desireSize; uint32_t readSize = desireSize; if (!inputStream_->Peek(desireSize, static_cast(buffer), bufferSize, readSize)) { - HiLog::Error(LABEL, "peek failed, desire peek size=%{public}u", desireSize); + IMAGE_LOGE("peek failed, desire peek size=%{public}u", desireSize); return 0; } return readSize; @@ -71,7 +74,7 @@ size_t BmpStream::peek(void *buffer, size_t size) const bool BmpStream::isAtEnd() const { if (inputStream_ == nullptr) { - HiLog::Error(LABEL, "get stream status failed, inputStream_ is null."); + IMAGE_LOGE("get stream status failed, inputStream_ is null."); return false; } size_t size = inputStream_->GetStreamSize(); diff --git a/plugins/common/libs/image/libbmpplugin/src/plugin_export.cpp b/plugins/common/libs/image/libbmpplugin/src/plugin_export.cpp index c5ab918cf..20de12a75 100644 --- a/plugins/common/libs/image/libbmpplugin/src/plugin_export.cpp +++ b/plugins/common/libs/image/libbmpplugin/src/plugin_export.cpp @@ -15,10 +15,15 @@ #include "plugin_export.h" #include "bmp_decoder.h" -#include "hilog/log.h" -#include "log_tags.h" +#include "image_log.h" #include "plugin_utils.h" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "LibBmpPlugin" + // plugin package name same as metadata. namespace { const std::string PACKAGE_NAME = ("LibBmpPlugin"); @@ -30,32 +35,26 @@ PLUGIN_EXPORT_REGISTER_CLASS(OHOS::ImagePlugin::BmpDecoder) PLUGIN_EXPORT_REGISTER_CLASS_END using std::string; -using namespace OHOS::HiviewDFX; - -static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "LibBmpPlugin" }; - -#define PLUGIN_LOG_D(...) HiLog::Debug(LABEL, __VA_ARGS__) -#define PLUGIN_LOG_E(...) HiLog::Error(LABEL, __VA_ARGS__) // define the external interface of this plugin. PLUGIN_EXPORT_DEFAULT_EXTERNAL_START() PLUGIN_EXPORT_DEFAULT_EXTERNAL_STOP() OHOS::MultimediaPlugin::PluginClassBase *PluginExternalCreate(const string &className) { - HiLog::Debug(LABEL, "PluginExternalCreate: create object for package: %{public}s, class: %{public}s.", - PACKAGE_NAME.c_str(), className.c_str()); + IMAGE_LOGD("PluginExternalCreate: create object for package: %{public}s, class: %{public}s.", + PACKAGE_NAME.c_str(), className.c_str()); auto iter = implClassMap.find(className); if (iter == implClassMap.end()) { - HiLog::Error(LABEL, "PluginExternalCreate: failed to find class: %{public}s, in package: %{public}s.", - className.c_str(), PACKAGE_NAME.c_str()); + IMAGE_LOGE("PluginExternalCreate: failed to find class: %{public}s, in package: %{public}s.", + className.c_str(), PACKAGE_NAME.c_str()); return nullptr; } auto creator = iter->second; if (creator == nullptr) { - HiLog::Error(LABEL, "PluginExternalCreate: null creator for class: %{public}s, in package: %{public}s.", - className.c_str(), PACKAGE_NAME.c_str()); + IMAGE_LOGE("PluginExternalCreate: null creator for class: %{public}s, in package: %{public}s.", + className.c_str(), PACKAGE_NAME.c_str()); return nullptr; } diff --git a/plugins/common/libs/image/libextplugin/BUILD.gn b/plugins/common/libs/image/libextplugin/BUILD.gn index 4f6dd7587..c75f42e6f 100644 --- a/plugins/common/libs/image/libextplugin/BUILD.gn +++ b/plugins/common/libs/image/libextplugin/BUILD.gn @@ -33,6 +33,7 @@ ohos_static_library("exifhelper") { ] include_dirs = [ "../libjpegplugin/include", + "${image_subsystem}/frameworks/innerkitsimpl/utils/include", "${image_subsystem}/interfaces/innerkits/include", "//third_party/libexif", ] @@ -106,6 +107,7 @@ ohos_shared_library("textureEncoderCL") { } sources = [ "src/texture_encode/image_compressor.cpp" ] include_dirs = [ + "${image_subsystem}/frameworks/innerkitsimpl/utils/include", "${image_subsystem}/interfaces/innerkits/include", "include/texture_encode", ] diff --git a/plugins/common/libs/image/libextplugin/include/ext_encoder.h b/plugins/common/libs/image/libextplugin/include/ext_encoder.h index 98f7b5e78..cf12b757a 100644 --- a/plugins/common/libs/image/libextplugin/include/ext_encoder.h +++ b/plugins/common/libs/image/libextplugin/include/ext_encoder.h @@ -19,8 +19,6 @@ #include #include "abs_image_encoder.h" -#include "hilog/log.h" -#include "log_tags.h" #include "plugin_class_base.h" namespace OHOS { diff --git a/plugins/common/libs/image/libextplugin/src/ext_decoder.cpp b/plugins/common/libs/image/libextplugin/src/ext_decoder.cpp index b73c225c0..f15422c74 100644 --- a/plugins/common/libs/image/libextplugin/src/ext_decoder.cpp +++ b/plugins/common/libs/image/libextplugin/src/ext_decoder.cpp @@ -19,11 +19,10 @@ #include #include "ext_pixel_convert.h" -#include "hilog/log.h" +#include "image_log.h" #include "hisysevent.h" #include "image_system_properties.h" #include "image_utils.h" -#include "log_tags.h" #include "media_errors.h" #include "securec.h" #include "string_ex.h" @@ -31,8 +30,13 @@ #include "surface_buffer.h" #endif +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "ExtDecoder" + namespace { - constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "ExtDecoder"}; constexpr static int32_t ZERO = 0; constexpr static int32_t NUM_3 = 3; constexpr static int32_t NUM_4 = 4; @@ -63,7 +67,6 @@ namespace OHOS { namespace ImagePlugin { using namespace Media; using namespace OHOS::HDI::Base; -using namespace OHOS::HiviewDFX; using namespace std; const static string DEFAULT_EXIF_VALUE = "default_exif_value"; const static string CODEC_INITED_KEY = "CodecInited"; @@ -145,25 +148,25 @@ static void SetDecodeContextBuffer(DecodeContext &context, static uint32_t ShareMemAlloc(DecodeContext &context, uint64_t count) { #if defined(_WIN32) || defined(_APPLE) || defined(A_PLATFORM) || defined(IOS_PLATFORM) - HiLog::Error(LABEL, "Unsupport share mem alloc"); + IMAGE_LOGE("Unsupport share mem alloc"); return ERR_IMAGE_DATA_UNSUPPORT; #else auto fd = make_unique(); *fd = AshmemCreate(EXT_SHAREMEM_NAME.c_str(), count); if (*fd < 0) { - HiLog::Error(LABEL, "AshmemCreate failed"); + IMAGE_LOGE("AshmemCreate failed"); return ERR_SHAMEM_DATA_ABNORMAL; } int result = AshmemSetProt(*fd, PROT_READ | PROT_WRITE); if (result < 0) { ::close(*fd); - HiLog::Error(LABEL, "AshmemSetProt failed"); + IMAGE_LOGE("AshmemSetProt failed"); return ERR_SHAMEM_DATA_ABNORMAL; } void* ptr = ::mmap(nullptr, count, PROT_READ | PROT_WRITE, MAP_SHARED, *fd, ZERO); if (ptr == MAP_FAILED) { ::close(*fd); - HiLog::Error(LABEL, "::mmap failed"); + IMAGE_LOGE("::mmap failed"); return ERR_SHAMEM_DATA_ABNORMAL; } SetDecodeContextBuffer(context, @@ -175,7 +178,7 @@ static uint32_t ShareMemAlloc(DecodeContext &context, uint64_t count) static uint32_t DmaMemAlloc(DecodeContext &context, uint64_t count, SkImageInfo &dstInfo) { #if defined(_WIN32) || defined(_APPLE) || defined(A_PLATFORM) || defined(IOS_PLATFORM) - HiLog::Error(LABEL, "Unsupport dma mem alloc"); + IMAGE_LOGE("Unsupport dma mem alloc"); return ERR_IMAGE_DATA_UNSUPPORT; #else sptr sb = SurfaceBuffer::Create(); @@ -191,13 +194,13 @@ static uint32_t DmaMemAlloc(DecodeContext &context, uint64_t count, SkImageInfo }; GSError ret = sb->Alloc(requestConfig); if (ret != GSERROR_OK) { - HiLog::Error(LABEL, "SurfaceBuffer Alloc failed, %{public}s", GSErrorStr(ret).c_str()); + IMAGE_LOGE("SurfaceBuffer Alloc failed, %{public}s", GSErrorStr(ret).c_str()); return ERR_DMA_NOT_EXIST; } void* nativeBuffer = sb.GetRefPtr(); int32_t err = ImageUtils::SurfaceBuffer_Reference(nativeBuffer); if (err != OHOS::GSERROR_OK) { - HiLog::Error(LABEL, "NativeBufferReference failed"); + IMAGE_LOGE("NativeBufferReference failed"); return ERR_DMA_DATA_ABNORMAL; } @@ -210,7 +213,7 @@ static uint32_t DmaMemAlloc(DecodeContext &context, uint64_t count, SkImageInfo static uint32_t HeapMemAlloc(DecodeContext &context, uint64_t count) { if (count == 0 || count > PIXEL_MAP_MAX_RAM_SIZE) { - HiLog::Error(LABEL, "HeapMemAlloc Invalid value of bufferSize"); + IMAGE_LOGE("HeapMemAlloc Invalid value of bufferSize"); return ERR_IMAGE_DATA_ABNORMAL; } auto out = static_cast(malloc(count)); @@ -219,7 +222,7 @@ static uint32_t HeapMemAlloc(DecodeContext &context, uint64_t count) #else if (memset_s(out, count, ZERO, count) != EOK) { #endif - HiLog::Error(LABEL, "Decode failed, memset buffer failed"); + IMAGE_LOGE("Decode failed, memset buffer failed"); free(out); return ERR_IMAGE_DECODE_FAILED; } @@ -265,11 +268,11 @@ static inline float Max(float a, float b) bool ExtDecoder::GetScaledSize(int &dWidth, int &dHeight, float &scale) { if (info_.isEmpty() && !DecodeHeader()) { - HiLog::Error(LABEL, "DecodeHeader failed in GetScaledSize!"); + IMAGE_LOGE("DecodeHeader failed in GetScaledSize!"); return false; } if (info_.isEmpty()) { - HiLog::Error(LABEL, "empty image info in GetScaledSize!"); + IMAGE_LOGE("empty image info in GetScaledSize!"); return false; } float finalScale = scale; @@ -281,19 +284,19 @@ bool ExtDecoder::GetScaledSize(int &dWidth, int &dHeight, float &scale) dWidth = scaledDimension.width(); dHeight = scaledDimension.height(); scale = finalScale; - HiLog::Debug(LABEL, "IsSupportScaleOnDecode info [%{public}d x %{public}d]", info_.width(), info_.height()); - HiLog::Debug(LABEL, "IsSupportScaleOnDecode [%{public}d x %{public}d]", dWidth, dHeight); - HiLog::Debug(LABEL, "IsSupportScaleOnDecode [%{public}f]", scale); + IMAGE_LOGD("IsSupportScaleOnDecode info [%{public}d x %{public}d]", info_.width(), info_.height()); + IMAGE_LOGD("IsSupportScaleOnDecode [%{public}d x %{public}d]", dWidth, dHeight); + IMAGE_LOGD("IsSupportScaleOnDecode [%{public}f]", scale); return true; } bool ExtDecoder::GetHardwareScaledSize(int &dWidth, int &dHeight, float &scale) { if (info_.isEmpty() && !DecodeHeader()) { - HiLog::Error(LABEL, "DecodeHeader failed in GetHardwareScaledSize!"); + IMAGE_LOGE("DecodeHeader failed in GetHardwareScaledSize!"); return false; } if (info_.isEmpty()) { - HiLog::Error(LABEL, "empty image info in GetHardwareScaledSize!"); + IMAGE_LOGE("empty image info in GetHardwareScaledSize!"); return false; } float finalScale = scale; @@ -371,15 +374,15 @@ bool ExtDecoder::HasProperty(string key) uint32_t ExtDecoder::GetImageSize(uint32_t index, PlSize &size) { - HiLog::Debug(LABEL, "GetImageSize index:%{public}u", index); + IMAGE_LOGD("GetImageSize index:%{public}u", index); if (!CheckIndexValied(index)) { - HiLog::Error(LABEL, "Invalid index:%{public}u, range:%{public}d", index, frameCount_); + IMAGE_LOGE("Invalid index:%{public}u, range:%{public}d", index, frameCount_); return ERR_IMAGE_INVALID_PARAMETER; } - HiLog::Debug(LABEL, "GetImageSize index:%{public}u, range:%{public}d", index, frameCount_); + IMAGE_LOGD("GetImageSize index:%{public}u, range:%{public}d", index, frameCount_); // Info has been get in check process, or empty on get failed. if (info_.isEmpty()) { - HiLog::Error(LABEL, "GetImageSize failed, decode header failed."); + IMAGE_LOGE("GetImageSize failed, decode header failed."); return ERR_IMAGE_DECODE_HEAD_ABNORMAL; } size.width = info_.width(); @@ -419,13 +422,12 @@ static sk_sp getDesiredColorSpace(SkImageInfo &srcInfo, const Pixe uint32_t ExtDecoder::CheckDecodeOptions(uint32_t index, const PixelDecodeOptions &opts) { if (ImageUtils::CheckMulOverflow(dstInfo_.width(), dstInfo_.height(), dstInfo_.bytesPerPixel())) { - HiLog::Error(LABEL, "SetDecodeOptions failed, width:%{public}d, height:%{public}d is too large", + IMAGE_LOGE("SetDecodeOptions failed, width:%{public}d, height:%{public}d is too large", dstInfo_.width(), dstInfo_.height()); return ERR_IMAGE_INVALID_PARAMETER; } if (!IsValidCrop(opts.CropRect, info_, dstSubset_)) { - HiLog::Error(LABEL, - "Invalid crop rect xy [%{public}d x %{public}d], wh [%{public}d x %{public}d]", + IMAGE_LOGE("Invalid crop rect xy [%{public}d x %{public}d], wh [%{public}d x %{public}d]", dstSubset_.left(), dstSubset_.top(), dstSubset_.width(), dstSubset_.height()); return ERR_IMAGE_INVALID_PARAMETER; } @@ -443,11 +445,11 @@ uint32_t ExtDecoder::CheckDecodeOptions(uint32_t index, const PixelDecodeOptions uint32_t ExtDecoder::SetDecodeOptions(uint32_t index, const PixelDecodeOptions &opts, PlImageInfo &info) { if (!CheckIndexValied(index)) { - HiLog::Error(LABEL, "Invalid index:%{public}u, range:%{public}d", index, frameCount_); + IMAGE_LOGE("Invalid index:%{public}u, range:%{public}d", index, frameCount_); return ERR_IMAGE_INVALID_PARAMETER; } if (opts.sampleSize != DEFAULT_SAMPLE_SIZE) { - HiLog::Error(LABEL, "Do not support sample size now!"); + IMAGE_LOGE("Do not support sample size now!"); return ERR_IMAGE_INVALID_PARAMETER; } auto desireColor = ConvertToColorType(opts.desiredPixelFormat, info.pixelFormat); @@ -500,13 +502,13 @@ uint32_t ExtDecoder::SetContextPixelsBuffer(uint64_t byteCount, DecodeContext &c static void DebugInfo(SkImageInfo &info, SkImageInfo &dstInfo, SkCodec::Options &opts) { - HiLog::Debug(LABEL, "Decode source info: WH[%{public}d x %{public}d], A %{public}d, C %{public}d.", + IMAGE_LOGD("Decode source info: WH[%{public}d x %{public}d], A %{public}d, C %{public}d.", info.width(), info.height(), info.alphaType(), info.colorType()); - HiLog::Debug(LABEL, "Decode dst info: WH[%{public}d x %{public}d], A %{public}d, C %{public}d.", + IMAGE_LOGD("Decode dst info: WH[%{public}d x %{public}d], A %{public}d, C %{public}d.", dstInfo.width(), dstInfo.height(), dstInfo.alphaType(), dstInfo.colorType()); if (opts.fSubset != nullptr) { - HiLog::Debug(LABEL, "Decode dstOpts sub: (%{public}d, %{public}d), WH[%{public}d x %{public}d]", + IMAGE_LOGD("Decode dstOpts sub: (%{public}d, %{public}d), WH[%{public}d x %{public}d]", opts.fSubset->fLeft, opts.fSubset->fTop, opts.fSubset->width(), opts.fSubset->height()); } @@ -519,7 +521,7 @@ static uint32_t RGBxToRGB(uint8_t* srcBuffer, size_t srsSize, ExtPixels dst = {dstBuffer, dstSize, pixelCount}; auto res = ExtPixelConvert::RGBxToRGB(src, dst); if (res != SUCCESS) { - HiLog::Error(LABEL, "RGBxToRGB failed %{public}d", res); + IMAGE_LOGE("RGBxToRGB failed %{public}d", res); } return res; } @@ -527,15 +529,15 @@ static uint32_t RGBxToRGB(uint8_t* srcBuffer, size_t srsSize, uint32_t ExtDecoder::PreDecodeCheck(uint32_t index) { if (!CheckIndexValied(index)) { - HiLog::Error(LABEL, "Decode failed, invalid index:%{public}u, range:%{public}d", index, frameCount_); + IMAGE_LOGE("Decode failed, invalid index:%{public}u, range:%{public}d", index, frameCount_); return ERR_IMAGE_INVALID_PARAMETER; } if (codec_ == nullptr) { - HiLog::Error(LABEL, "Decode failed, codec is null"); + IMAGE_LOGE("Decode failed, codec is null"); return ERR_IMAGE_DECODE_FAILED; } if (dstInfo_.isEmpty()) { - HiLog::Error(LABEL, "Decode failed, dst info is empty"); + IMAGE_LOGE("Decode failed, dst info is empty"); return ERR_IMAGE_DECODE_FAILED; } return SUCCESS; @@ -577,7 +579,7 @@ uint32_t ExtDecoder::Decode(uint32_t index, DecodeContext &context) byteCount = byteCount / NUM_4 * NUM_3; } if (context.pixelsBuffer.buffer == nullptr) { - HiLog::Debug(LABEL, "Decode alloc byte count."); + IMAGE_LOGD("Decode alloc byte count."); res = SetContextPixelsBuffer(byteCount, context); if (res != SUCCESS) { return res; @@ -595,7 +597,7 @@ uint32_t ExtDecoder::Decode(uint32_t index, DecodeContext &context) } SkEncodedImageFormat skEncodeFormat = codec_->getEncodedFormat(); ReportImageType(skEncodeFormat); - HiLog::Debug(LABEL, "decode format %{public}d", skEncodeFormat); + IMAGE_LOGD("decode format %{public}d", skEncodeFormat); if (skEncodeFormat == SkEncodedImageFormat::kGIF || skEncodeFormat == SkEncodedImageFormat::kWEBP) { return GifDecode(index, context, rowStride); } @@ -605,7 +607,7 @@ uint32_t ExtDecoder::Decode(uint32_t index, DecodeContext &context) ret = codec_->getPixels(dstInfo_, dstBuffer, rowStride, &dstOptions_); } if (ret != SkCodec::kSuccess) { - HiLog::Error(LABEL, "Decode failed, get pixels failed, ret=%{public}d", ret); + IMAGE_LOGE("Decode failed, get pixels failed, ret=%{public}d", ret); return ERR_IMAGE_DECODE_ABNORMAL; } if (dstInfo_.colorType() == SkColorType::kRGB_888x_SkColorType) { @@ -652,21 +654,21 @@ static std::string GetFormatStr(SkEncodedImageFormat format) void ExtDecoder::ReportImageType(SkEncodedImageFormat skEncodeFormat) { - HiLog::Debug(LABEL, "ExtDecoder::ReportImageType format %{public}d start", skEncodeFormat); + IMAGE_LOGD("ExtDecoder::ReportImageType format %{public}d start", skEncodeFormat); static constexpr char IMAGE_FWK_UE[] = "IMAGE_FWK_UE"; int32_t ret = HiSysEventWrite( IMAGE_FWK_UE, "DECODED_IMAGE_TYPE_STATISTICS", - HiSysEvent::EventType::STATISTIC, + HiviewDFX::HiSysEvent::EventType::STATISTIC, "PNAMEID", DEFAULT_PACKAGE_NAME, "PVERSIONID", DEFAULT_VERSION_ID, "IMAGE_TYPE", GetFormatStr(skEncodeFormat) ); if (SUCCESS != ret) { - HiLog::Debug(LABEL, "ExtDecoder::ReportImageType failed, ret = %{public}d", ret); + IMAGE_LOGD("ExtDecoder::ReportImageType failed, ret = %{public}d", ret); return; } - HiLog::Debug(LABEL, "ExtDecoder::ReportImageType format %{public}d success", skEncodeFormat); + IMAGE_LOGD("ExtDecoder::ReportImageType format %{public}d success", skEncodeFormat); } #ifdef JPEG_HW_DECODE_ENABLE uint32_t ExtDecoder::AllocOutputBuffer(DecodeContext &context) @@ -674,7 +676,7 @@ uint32_t ExtDecoder::AllocOutputBuffer(DecodeContext &context) uint64_t byteCount = static_cast(dstInfo_.height()) * dstInfo_.width() * dstInfo_.bytesPerPixel(); uint32_t ret = DmaMemAlloc(context, byteCount, info_); if (ret != SUCCESS) { - HiLog::Error(LABEL, "Alloc OutputBuffer failed, ret=%{public}d", ret); + IMAGE_LOGE("Alloc OutputBuffer failed, ret=%{public}d", ret); return ERR_IMAGE_DECODE_ABNORMAL; } BufferHandle *handle = (static_cast(context.pixelsBuffer.context))->GetBufferHandle(); @@ -692,7 +694,7 @@ uint32_t ExtDecoder::AllocOutputBuffer(DecodeContext &context) bool CheckContext(const SkImageInfo &dstInfo) { if (dstInfo.colorType() != kRGBA_8888_SkColorType) { - HiLog::Error(LABEL, "hardware decode only support rgba_8888 format"); + IMAGE_LOGE("hardware decode only support rgba_8888 format"); return false; } return true; @@ -713,8 +715,8 @@ uint32_t ExtDecoder::HardWareDecode(DecodeContext &context) { // check if the hwDstInfo is equal to the dstInfo if (hwDstInfo_.width() != dstInfo_.width() || hwDstInfo_.height() != dstInfo_.height()) { - HiLog::Info(LABEL, "hwDstInfo(%{public}d, %{public}d) != dstInfo(%{public}d, %{public}d)", - hwDstInfo_.width(), hwDstInfo_.height(), dstInfo_.width(), dstInfo_.height()); + IMAGE_LOGI("hwDstInfo(%{public}d, %{public}d) != dstInfo(%{public}d, %{public}d)", + hwDstInfo_.width(), hwDstInfo_.height(), dstInfo_.width(), dstInfo_.height()); return ERROR; } JpegHardwareDecoder hwDecoder; @@ -728,12 +730,12 @@ uint32_t ExtDecoder::HardWareDecode(DecodeContext &context) Media::AllocatorType tmpAllocatorType = context.allocatorType; uint32_t ret = AllocOutputBuffer(context); if (ret != SUCCESS) { - HiLog::Error(LABEL, "Decode failed, Alloc OutputBuffer failed, ret=%{public}d", ret); + IMAGE_LOGE("Decode failed, Alloc OutputBuffer failed, ret=%{public}d", ret); return ERR_IMAGE_DECODE_ABNORMAL; } ret = hwDecoder.Decode(codec_.get(), stream_, orgImgSize_, sampleSize_, outputBuffer_); if (ret != SUCCESS) { - HiLog::Error(LABEL, "failed to do jpeg hardware decode, err=%{public}d", ret); + IMAGE_LOGE("failed to do jpeg hardware decode, err=%{public}d", ret); ReleaseOutputBuffer(context, tmpAllocatorType); return ERR_IMAGE_DECODE_ABNORMAL; } @@ -748,7 +750,7 @@ static uint32_t handleGifCache(uint8_t* src, uint8_t* dst, SkImageInfo& info, co for (int i = 0; i < dstHeight; i++) { errno_t err = memcpy_s(dstRow, rowStride, srcRow, rowStride); if (err != EOK) { - HiLog::Error(LABEL, "handle gif memcpy failed. errno:%{public}d", err); + IMAGE_LOGE("handle gif memcpy failed. errno:%{public}d", err); return ERR_IMAGE_DECODE_ABNORMAL; } srcRow += rowStride; @@ -790,7 +792,7 @@ uint32_t ExtDecoder::GifDecode(uint32_t index, DecodeContext &context, const uin ret = codec_->getPixels(dstInfo_, dstBuffer, rowStride, &dstOptions_); } if (ret != SkCodec::kSuccess) { - HiLog::Error(LABEL, "Gif decode failed, get pixels failed, ret=%{public}d", ret); + IMAGE_LOGE("Gif decode failed, get pixels failed, ret=%{public}d", ret); return ERR_IMAGE_DECODE_ABNORMAL; } if (curInfo.fDisposalMethod != SkCodecAnimation::DisposalMethod::kRestorePrevious) { @@ -812,15 +814,15 @@ bool ExtDecoder::CheckCodec() if (codec_ != nullptr) { return true; } else if (stream_ == nullptr) { - HiLog::Error(LABEL, "create codec: input stream is nullptr."); + IMAGE_LOGE("create codec: input stream is nullptr."); return false; } else if (stream_->GetStreamSize() == SIZE_ZERO) { - HiLog::Error(LABEL, "create codec: input stream size is zero."); + IMAGE_LOGE("create codec: input stream size is zero."); return false; } codec_ = SkCodec::MakeFromStream(make_unique(stream_)); if (codec_ == nullptr) { - HiLog::Error(LABEL, "create codec from stream failed"); + IMAGE_LOGE("create codec from stream failed"); return false; } return codec_ != nullptr; @@ -829,12 +831,12 @@ bool ExtDecoder::CheckCodec() bool ExtDecoder::DecodeHeader() { if (!CheckCodec()) { - HiLog::Error(LABEL, "Check codec failed"); + IMAGE_LOGE("Check codec failed"); return false; } info_ = codec_->getInfo(); frameCount_ = codec_->getFrameCount(); - HiLog::Debug(LABEL, "DecodeHeader: get frame count %{public}d.", frameCount_); + IMAGE_LOGD("DecodeHeader: get frame count %{public}d.", frameCount_); return true; } @@ -851,11 +853,11 @@ static uint32_t GetFormatName(SkEncodedImageFormat format, std::string &name) auto formatNameIter = FORMAT_NAME.find(format); if (formatNameIter != FORMAT_NAME.end() && !formatNameIter->second.empty()) { name = formatNameIter->second; - HiLog::Debug(LABEL, "GetFormatName: get encoded format name (%{public}d)=>[%{public}s].", + IMAGE_LOGD("GetFormatName: get encoded format name (%{public}d)=>[%{public}s].", format, name.c_str()); return SUCCESS; } - HiLog::Error(LABEL, "GetFormatName: get encoded format name failed %{public}d.", format); + IMAGE_LOGE("GetFormatName: get encoded format name failed %{public}d.", format); return ERR_IMAGE_DATA_UNSUPPORT; } @@ -904,13 +906,13 @@ SkAlphaType ExtDecoder::ConvertToAlphaType(PlAlphaType desiredType, PlAlphaType return alphaType->second; } } - HiLog::Debug(LABEL, "Unknown alpha type:%{public}d", desiredType); + IMAGE_LOGD("Unknown alpha type:%{public}d", desiredType); SkAlphaType res; if (ConvertInfoToAlphaType(res, outputType)) { - HiLog::Debug(LABEL, "Using alpha type:%{public}d", outputType); + IMAGE_LOGD("Using alpha type:%{public}d", outputType); return res; } - HiLog::Debug(LABEL, "Using default alpha type:%{public}d", PlAlphaType::IMAGE_ALPHA_TYPE_PREMUL); + IMAGE_LOGD("Using default alpha type:%{public}d", PlAlphaType::IMAGE_ALPHA_TYPE_PREMUL); outputType = PlAlphaType::IMAGE_ALPHA_TYPE_PREMUL; return SkAlphaType::kPremul_SkAlphaType; } @@ -924,13 +926,13 @@ SkColorType ExtDecoder::ConvertToColorType(PlPixelFormat format, PlPixelFormat & return colorType->second.skFormat; } } - HiLog::Debug(LABEL, "Unknown pixel format:%{public}d", format); + IMAGE_LOGD("Unknown pixel format:%{public}d", format); SkColorType res; if (ConvertInfoToColorType(res, outputFormat)) { - HiLog::Debug(LABEL, "Using pixel format:%{public}d", outputFormat); + IMAGE_LOGD("Using pixel format:%{public}d", outputFormat); return res; } - HiLog::Debug(LABEL, "Using default pixel format:%{public}d", PlPixelFormat::RGBA_8888); + IMAGE_LOGD("Using default pixel format:%{public}d", PlPixelFormat::RGBA_8888); outputFormat = PlPixelFormat::RGBA_8888; return kRGBA_8888_SkColorType; } @@ -976,7 +978,7 @@ static bool MatchColorSpaceName(const uint8_t* buf, uint32_t size, OHOS::ColorMa } } if (desc.size() <= SIZE_1) { - HiLog::Info(LABEL, "empty buffer"); + IMAGE_LOGI("empty buffer"); return false; } std::string descText(desc.begin() + OFFSET_1, desc.end()); @@ -987,14 +989,14 @@ static bool MatchColorSpaceName(const uint8_t* buf, uint32_t size, OHOS::ColorMa name = nameEnum.name; return true; } - HiLog::Error(LABEL, "Failed to match desc [%{public}s]", descText.c_str()); + IMAGE_LOGE("Failed to match desc [%{public}s]", descText.c_str()); return false; } static bool GetColorSpaceName(const skcms_ICCProfile* profile, OHOS::ColorManager::ColorSpaceName &name) { if (profile == nullptr || profile->buffer == nullptr) { - HiLog::Debug(LABEL, "profile is nullptr"); + IMAGE_LOGD("profile is nullptr"); return false; } auto tags = reinterpret_cast(profile->buffer + ICC_HEADER_SIZE); @@ -1026,7 +1028,7 @@ OHOS::ColorManager::ColorSpace ExtDecoder::getGrColorSpace() if (codec_ != nullptr) { auto profile = codec_->getICCProfile(); if (profile != nullptr) { - HiLog::Debug(LABEL, "profile got !!!!"); + IMAGE_LOGD("profile got !!!!"); GetColorSpaceName(profile, name); } } @@ -1070,12 +1072,12 @@ static bool ParseExifData(InputDataStream *input, EXIFInfo &info) if (info.IsExifDataParsed()) { return true; } - HiLog::Debug(LABEL, "ParseExifData enter"); + IMAGE_LOGD("ParseExifData enter"); auto code = ProcessWithStreamData(input, [&info](uint8_t* buffer, size_t size) { return info.ParseExifData(buffer, size); }); if (code != SUCCESS) { - HiLog::Error(LABEL, "Error parsing EXIF: code %{public}d", code); + IMAGE_LOGE("Error parsing EXIF: code %{public}d", code); } return code == SUCCESS; } @@ -1105,22 +1107,22 @@ bool ExtDecoder::GetPropertyCheck(uint32_t index, const std::string &key, uint32 static uint32_t GetDelayTime(SkCodec * codec, uint32_t index, int32_t &value) { if (codec->getEncodedFormat() != SkEncodedImageFormat::kGIF) { - HiLog::Error(LABEL, "[GetDelayTime] Should not get delay time in %{public}d", codec->getEncodedFormat()); + IMAGE_LOGE("[GetDelayTime] Should not get delay time in %{public}d", codec->getEncodedFormat()); return ERR_MEDIA_INVALID_PARAM; } auto frameInfos = codec->getFrameInfo(); if (index > frameInfos.size() - 1) { - HiLog::Error(LABEL, "[GetDelayTime] frame size %{public}zu, index:%{public}d", frameInfos.size(), index); + IMAGE_LOGE("[GetDelayTime] frame size %{public}zu, index:%{public}d", frameInfos.size(), index); return ERR_MEDIA_INVALID_PARAM; } value = frameInfos[index].fDuration; - HiLog::Debug(LABEL, "[GetDelayTime] index[%{public}d]:%{public}d", index, value); + IMAGE_LOGD("[GetDelayTime] index[%{public}d]:%{public}d", index, value); return SUCCESS; } uint32_t ExtDecoder::GetImagePropertyInt(uint32_t index, const std::string &key, int32_t &value) { - HiLog::Debug(LABEL, "[GetImagePropertyInt] enter ExtDecoder plugin, key:%{public}s", key.c_str()); + IMAGE_LOGD("[GetImagePropertyInt] enter ExtDecoder plugin, key:%{public}s", key.c_str()); uint32_t res = Media::ERR_IMAGE_DATA_ABNORMAL; if (!GetPropertyCheck(index, key, res)) { return res; @@ -1142,13 +1144,13 @@ uint32_t ExtDecoder::GetImagePropertyInt(uint32_t index, const std::string &key, value = atoi(strValue.c_str()); return res; } - HiLog::Error(LABEL, "[GetImagePropertyInt] The key:%{public}s is not supported int32_t", key.c_str()); + IMAGE_LOGE("[GetImagePropertyInt] The key:%{public}s is not supported int32_t", key.c_str()); return Media::ERR_MEDIA_VALUE_INVALID; } uint32_t ExtDecoder::GetImagePropertyString(uint32_t index, const std::string &key, std::string &value) { - HiLog::Debug(LABEL, "[GetImagePropertyString] enter jpeg plugin, key:%{public}s", key.c_str()); + IMAGE_LOGD("[GetImagePropertyString] enter jpeg plugin, key:%{public}s", key.c_str()); uint32_t res = Media::ERR_IMAGE_DATA_ABNORMAL; if (!GetPropertyCheck(index, key, res)) { return res; @@ -1171,12 +1173,12 @@ uint32_t ExtDecoder::GetImagePropertyString(uint32_t index, const std::string &k res = GetMakerImagePropertyString(key, value); if (value.length() == 0) { value = DEFAULT_EXIF_VALUE; - HiLog::Error(LABEL, "[GetImagePropertyString]The image does not contain the %{public}s tag ", key.c_str()); + IMAGE_LOGE("[GetImagePropertyString]The image does not contain the %{public}s tag ", key.c_str()); } return res; } res = exifInfo_.GetExifData(key, value); - HiLog::Debug(LABEL, "[GetImagePropertyString] enter jpeg plugin, value:%{public}s", value.c_str()); + IMAGE_LOGD("[GetImagePropertyString] enter jpeg plugin, value:%{public}s", value.c_str()); return res; } @@ -1192,7 +1194,7 @@ uint32_t ExtDecoder::GetMakerImagePropertyString(const std::string &key, std::st uint32_t ExtDecoder::ModifyImageProperty(uint32_t index, const std::string &key, const std::string &value, const std::string &path) { - HiLog::Debug(LABEL, "[ModifyImageProperty] with path:%{public}s, key:%{public}s, value:%{public}s", + IMAGE_LOGD("[ModifyImageProperty] with path:%{public}s, key:%{public}s, value:%{public}s", path.c_str(), key.c_str(), value.c_str()); return exifInfo_.ModifyExifData(key, value, path); } @@ -1200,7 +1202,7 @@ uint32_t ExtDecoder::ModifyImageProperty(uint32_t index, const std::string &key, uint32_t ExtDecoder::ModifyImageProperty(uint32_t index, const std::string &key, const std::string &value, const int fd) { - HiLog::Debug(LABEL, "[ModifyImageProperty] with fd:%{public}d, key:%{public}s, value:%{public}s", + IMAGE_LOGD("[ModifyImageProperty] with fd:%{public}d, key:%{public}s, value:%{public}s", fd, key.c_str(), value.c_str()); return exifInfo_.ModifyExifData(key, value, fd); } @@ -1208,16 +1210,16 @@ uint32_t ExtDecoder::ModifyImageProperty(uint32_t index, const std::string &key, uint32_t ExtDecoder::ModifyImageProperty(uint32_t index, const std::string &key, const std::string &value, uint8_t *data, uint32_t size) { - HiLog::Debug(LABEL, "[ModifyImageProperty] with key:%{public}s, value:%{public}s", + IMAGE_LOGD("[ModifyImageProperty] with key:%{public}s, value:%{public}s", key.c_str(), value.c_str()); return exifInfo_.ModifyExifData(key, value, data, size); } uint32_t ExtDecoder::GetFilterArea(const int &privacyType, std::vector> &ranges) { - HiLog::Debug(LABEL, "[GetFilterArea] with privacyType:%{public}d ", privacyType); + IMAGE_LOGD("[GetFilterArea] with privacyType:%{public}d ", privacyType); if (!CheckCodec()) { - HiLog::Error(LABEL, "Check codec failed"); + IMAGE_LOGE("Check codec failed"); return NO_EXIF_TAG; } SkEncodedImageFormat format = codec_->getEncodedFormat(); @@ -1229,11 +1231,11 @@ uint32_t ExtDecoder::GetFilterArea(const int &privacyType, std::vector(buffer[APP1_SIZE_H_OFF]) << U8_SHIFT) | buffer[APP1_SIZE_L_OFF]; - HiLog::Debug(LABEL, "[GetFilterArea]: get app1 area size"); + IMAGE_LOGD("[GetFilterArea]: get app1 area size"); appSize += APP1_SIZE_H_OFF; auto ret = exifInfo_.GetFilterArea(buffer, (appSize < size) ? appSize : size, privacyType, ranges); if (ret != SUCCESS) { - HiLog::Error(LABEL, "[GetFilterArea]: failed to get area %{public}d", ret); + IMAGE_LOGE("[GetFilterArea]: failed to get area %{public}d", ret); } return ret; }); diff --git a/plugins/common/libs/image/libextplugin/src/ext_encoder.cpp b/plugins/common/libs/image/libextplugin/src/ext_encoder.cpp index b7d4ee107..22d47634d 100644 --- a/plugins/common/libs/image/libextplugin/src/ext_encoder.cpp +++ b/plugins/common/libs/image/libextplugin/src/ext_encoder.cpp @@ -25,6 +25,7 @@ #include "astc_codec.h" #include "ext_pixel_convert.h" #include "ext_wstream.h" +#include "image_log.h" #include "image_type_converter.h" #include "image_utils.h" #include "media_errors.h" @@ -33,13 +34,15 @@ #include "surface_buffer.h" #endif +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "ExtEncoder" + namespace OHOS { namespace ImagePlugin { -using namespace OHOS::HiviewDFX; using namespace Media; -namespace { - constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "ExtEncoder"}; -} static const std::map FORMAT_NAME = { {SkEncodedImageFormat::kBMP, "image/bmp"}, @@ -120,7 +123,7 @@ static uint32_t BuildSkBitmap(Media::PixelMap *pixelMap, SkBitmap &bitmap, pixelMap->GetCapacity() < skInfo.computeMinByteSize()) { res = RGBToRGBx(pixelMap, skInfo, holder); if (res != SUCCESS) { - HiLog::Error(LABEL, "ExtEncoder::BuildSkBitmap pixel convert failed %{public}d", res); + IMAGE_LOGE("ExtEncoder::BuildSkBitmap pixel convert failed %{public}d", res); return res; } pixels = holder.buf.get(); @@ -133,7 +136,7 @@ static uint32_t BuildSkBitmap(Media::PixelMap *pixelMap, SkBitmap &bitmap, rowStride = sbBuffer->GetStride(); } if (!bitmap.installPixels(skInfo, pixels, rowStride)) { - HiLog::Error(LABEL, "ExtEncoder::BuildSkBitmap to skbitmap failed"); + IMAGE_LOGE("ExtEncoder::BuildSkBitmap to skbitmap failed"); return ERR_IMAGE_INVALID_PARAMETER; } return res; @@ -159,7 +162,7 @@ uint32_t ExtEncoder::FinalizeEncode() return IsSameTextStr(item.second, opts_.format); }); if (iter == FORMAT_NAME.end()) { - HiLog::Error(LABEL, "ExtEncoder::FinalizeEncode unsupported format %{public}s", opts_.format.c_str()); + IMAGE_LOGE("ExtEncoder::FinalizeEncode unsupported format %{public}s", opts_.format.c_str()); return ERR_IMAGE_INVALID_PARAMETER; } auto encodeFormat = iter->first; @@ -167,12 +170,12 @@ uint32_t ExtEncoder::FinalizeEncode() TmpBufferHolder holder; auto errorCode = BuildSkBitmap(pixelmap_, bitmap, encodeFormat, holder); if (errorCode != SUCCESS) { - HiLog::Error(LABEL, "ExtEncoder::FinalizeEncode BuildSkBitmap failed"); + IMAGE_LOGE("ExtEncoder::FinalizeEncode BuildSkBitmap failed"); return errorCode; } ExtWStream wStream(output_); if (!SkEncodeImage(&wStream, bitmap, iter->first, opts_.quality)) { - HiLog::Error(LABEL, "ExtEncoder::FinalizeEncode encode failed"); + IMAGE_LOGE("ExtEncoder::FinalizeEncode encode failed"); return ERR_IMAGE_ENCODE_FAILED; } return SUCCESS; diff --git a/plugins/common/libs/image/libextplugin/src/ext_stream.cpp b/plugins/common/libs/image/libextplugin/src/ext_stream.cpp index 4ab657d37..2f6a8dca4 100644 --- a/plugins/common/libs/image/libextplugin/src/ext_stream.cpp +++ b/plugins/common/libs/image/libextplugin/src/ext_stream.cpp @@ -14,16 +14,19 @@ */ #include "ext_stream.h" -#include "hilog/log.h" -#include "log_tags.h" +#include "image_log.h" + +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "ExtStream" namespace { - constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "ExtStream"}; constexpr static size_t SIZE_ZERO = 0; } namespace OHOS { namespace ImagePlugin { -using namespace OHOS::HiviewDFX; struct InputStream { uint8_t* buf; uint32_t size; @@ -49,7 +52,7 @@ static size_t Skip(InputDataStream *stream, size_t size) uint32_t cur = stream->Tell(); uint32_t seek = cur + static_cast(size); if (!stream->Seek(seek)) { - HiLog::Error(LABEL, "skip failed, curpositon, skip size."); + IMAGE_LOGE("skip failed, curpositon, skip size."); return SIZE_ZERO; } return size; @@ -71,7 +74,7 @@ size_t ExtStream::read(void *buffer, size_t size) desiredSize = stream_->GetStreamSize(); } if (!stream_->Read(desiredSize, buf.buf, buf.size, buf.resSize)) { - HiLog::Error(LABEL, "read failed, desire read size=%{public}u", buf.resSize); + IMAGE_LOGE("read failed, desire read size=%{public}u", buf.resSize); return 0; } return static_cast(buf.resSize); @@ -83,13 +86,13 @@ size_t ExtStream::peek(void *buffer, size_t size) const return SIZE_ZERO; } if (buffer == nullptr) { - HiLog::Error(LABEL, "peek failed, output buffer is null"); + IMAGE_LOGE("peek failed, output buffer is null"); return SIZE_ZERO; } InputStream buf; InputStreamInit(buf, static_cast(buffer), size); if (!stream_->Peek(buf.size, buf.buf, buf.size, buf.resSize)) { - HiLog::Error(LABEL, "peek failed, desire read size=%{public}u", buf.resSize); + IMAGE_LOGE("peek failed, desire read size=%{public}u", buf.resSize); return 0; } return static_cast(buf.resSize); diff --git a/plugins/common/libs/image/libextplugin/src/ext_wstream.cpp b/plugins/common/libs/image/libextplugin/src/ext_wstream.cpp index 2e7300a94..9d984801a 100644 --- a/plugins/common/libs/image/libextplugin/src/ext_wstream.cpp +++ b/plugins/common/libs/image/libextplugin/src/ext_wstream.cpp @@ -14,16 +14,19 @@ */ #include "ext_wstream.h" -#include "hilog/log.h" -#include "log_tags.h" +#include "image_log.h" + +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "ExtWStream" namespace { - constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "ExtWStream"}; constexpr static size_t SIZE_ZERO = 0; } namespace OHOS { namespace ImagePlugin { -using namespace OHOS::HiviewDFX; ExtWStream::ExtWStream(OutputDataStream *stream) : stream_(stream) { @@ -32,7 +35,7 @@ ExtWStream::ExtWStream(OutputDataStream *stream) : stream_(stream) bool ExtWStream::write(const void* buffer, size_t size) __attribute__((no_sanitize("cfi"))) { if (stream_ == nullptr) { - HiLog::Error(LABEL, "ExtWStream::write stream is nullptr"); + IMAGE_LOGE("ExtWStream::write stream is nullptr"); return false; } return stream_->Write(static_cast(buffer), size); @@ -41,7 +44,7 @@ bool ExtWStream::write(const void* buffer, size_t size) __attribute__((no_saniti void ExtWStream::flush() { if (stream_ == nullptr) { - HiLog::Error(LABEL, "ExtWStream::flush stream is nullptr"); + IMAGE_LOGE("ExtWStream::flush stream is nullptr"); return; } stream_->Flush(); @@ -50,7 +53,7 @@ void ExtWStream::flush() size_t ExtWStream::bytesWritten() const { if (stream_ == nullptr) { - HiLog::Error(LABEL, "ExtWStream::bytesWritten stream is nullptr"); + IMAGE_LOGE("ExtWStream::bytesWritten stream is nullptr"); return SIZE_ZERO; } size_t written = SIZE_ZERO; diff --git a/plugins/common/libs/image/libextplugin/src/plugin_export.cpp b/plugins/common/libs/image/libextplugin/src/plugin_export.cpp index 236094793..7346b60b1 100644 --- a/plugins/common/libs/image/libextplugin/src/plugin_export.cpp +++ b/plugins/common/libs/image/libextplugin/src/plugin_export.cpp @@ -16,10 +16,15 @@ #include "plugin_export.h" #include "ext_decoder.h" #include "ext_encoder.h" -#include "hilog/log.h" -#include "log_tags.h" +#include "image_log.h" #include "plugin_utils.h" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "LibExtPlugin" + // plugin package name same as metadata. namespace { const std::string PACKAGE_NAME = ("LibExtPlugin"); @@ -32,32 +37,26 @@ PLUGIN_EXPORT_REGISTER_CLASS(OHOS::ImagePlugin::ExtEncoder) PLUGIN_EXPORT_REGISTER_CLASS_END using std::string; -using namespace OHOS::HiviewDFX; - -static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "LibExtPlugin" }; - -#define PLUGIN_LOG_D(...) HiLog::Debug(LABEL, __VA_ARGS__) -#define PLUGIN_LOG_E(...) HiLog::Error(LABEL, __VA_ARGS__) // define the external interface of this plugin. PLUGIN_EXPORT_DEFAULT_EXTERNAL_START() PLUGIN_EXPORT_DEFAULT_EXTERNAL_STOP() OHOS::MultimediaPlugin::PluginClassBase *PluginExternalCreate(const string &className) { - HiLog::Debug(LABEL, "PluginExternalCreate: create object for package: %{public}s, class: %{public}s.", - PACKAGE_NAME.c_str(), className.c_str()); + IMAGE_LOGD("PluginExternalCreate: create object for package: %{public}s, class: %{public}s.", + PACKAGE_NAME.c_str(), className.c_str()); auto iter = implClassMap.find(className); if (iter == implClassMap.end()) { - HiLog::Error(LABEL, "PluginExternalCreate: failed to find class: %{public}s, in package: %{public}s.", - className.c_str(), PACKAGE_NAME.c_str()); + IMAGE_LOGE("PluginExternalCreate: failed to find class: %{public}s, in package: %{public}s.", + className.c_str(), PACKAGE_NAME.c_str()); return nullptr; } auto creator = iter->second; if (creator == nullptr) { - HiLog::Error(LABEL, "PluginExternalCreate: null creator for class: %{public}s, in package: %{public}s.", - className.c_str(), PACKAGE_NAME.c_str()); + IMAGE_LOGE("PluginExternalCreate: null creator for class: %{public}s, in package: %{public}s.", + className.c_str(), PACKAGE_NAME.c_str()); return nullptr; } diff --git a/plugins/common/libs/image/libextplugin/src/texture_encode/astc_codec.cpp b/plugins/common/libs/image/libextplugin/src/texture_encode/astc_codec.cpp index 16c98dd22..8d45dcfd4 100644 --- a/plugins/common/libs/image/libextplugin/src/texture_encode/astc_codec.cpp +++ b/plugins/common/libs/image/libextplugin/src/texture_encode/astc_codec.cpp @@ -15,19 +15,20 @@ #include "astc_codec.h" #include "image_compressor.h" +#include "image_log.h" #include "image_system_properties.h" #include "securec.h" #include "media_errors.h" -#include "hilog/log.h" -#include "log_tags.h" + +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "AstcCodec" namespace OHOS { namespace ImagePlugin { -using namespace OHOS::HiviewDFX; using namespace Media; -namespace { - constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "AstcCodec"}; -} constexpr uint8_t TEXTURE_HEAD_BYTES = 16; constexpr uint8_t ASTC_MASK = 0xFF; @@ -41,7 +42,7 @@ constexpr uint8_t HIGH_SPEED_PROFILE_MAP_QUALITY = 20; // quality level is 20 fo uint32_t AstcCodec::SetAstcEncode(OutputDataStream* outputStream, PlEncodeOptions &option, Media::PixelMap* pixelMap) { if (outputStream == nullptr || pixelMap == nullptr) { - HiLog::Error(LABEL, "input data is nullptr."); + IMAGE_LOGE("input data is nullptr."); return ERROR; } astcOutput_ = outputStream; @@ -54,7 +55,7 @@ uint32_t AstcCodec::SetAstcEncode(OutputDataStream* outputStream, PlEncodeOption uint32_t GenAstcHeader(uint8_t *header, astcenc_image img, TextureEncodeOptions *encodeParams, size_t size) { if ((encodeParams == nullptr) || (header == nullptr) || size < ASTC_HEADER_SIZE) { - HiLog::Error(LABEL, "header is nullptr or encodeParams is nullptr or header_size is error"); + IMAGE_LOGE("header is nullptr or encodeParams is nullptr or header_size is error"); return ERROR; } uint8_t *tmp = header; @@ -80,7 +81,7 @@ uint32_t GenAstcHeader(uint8_t *header, astcenc_image img, TextureEncodeOptions uint32_t InitAstcencConfig(AstcEncoder* work, TextureEncodeOptions* option) { if ((work == nullptr) || (option == nullptr)) { - HiLog::Error(LABEL, "astc input work or option is nullptr."); + IMAGE_LOGE("astc input work or option is nullptr."); return ERROR; } unsigned int blockX = option->blockX_; @@ -92,13 +93,13 @@ uint32_t InitAstcencConfig(AstcEncoder* work, TextureEncodeOptions* option) astcenc_error status = astcenc_config_init(work->profile, blockX, blockY, blockZ, quality, flags, &work->config); if (status == ASTCENC_ERR_BAD_BLOCK_SIZE) { - HiLog::Error(LABEL, "ERROR: block size is invalid"); + IMAGE_LOGE("ERROR: block size is invalid"); return ERROR; } else if (status == ASTCENC_ERR_BAD_CPU_FLOAT) { - HiLog::Error(LABEL, "ERROR: astcenc must not be compiled with fast-math"); + IMAGE_LOGE("ERROR: astcenc must not be compiled with fast-math"); return ERROR; } else if (status != ASTCENC_SUCCESS) { - HiLog::Error(LABEL, "ERROR: config failed"); + IMAGE_LOGE("ERROR: config failed"); return ERROR; } work->config.privateProfile = option->privateProfile_; @@ -170,7 +171,7 @@ bool CheckQuality(int32_t *mseIn[RGBA_COM], int blockNum, int blockXYZ) double mseRgb = static_cast(mseTotal[RGBA_COM] / (blockNum * blockXYZ * (RGBA_COM - 1))); psnr[RGBA_COM] = LOG_BASE * log(static_cast(MAX_VALUE * MAX_VALUE) / mseRgb) / log(LOG_BASE); } - HiLog::Debug(LABEL, "astc psnr r%{public}f g%{public}f b%{public}f a%{public}f rgb%{public}f", + IMAGE_LOGD("astc psnr r%{public}f g%{public}f b%{public}f a%{public}f rgb%{public}f", psnr[R_COM], psnr[G_COM], psnr[B_COM], psnr[A_COM], psnr[RGBA_COM]); return (psnr[R_COM] > threshold[R_COM]) && (psnr[G_COM] > threshold[G_COM]) @@ -225,7 +226,7 @@ static bool InitMem(AstcEncoder *work, TextureEncodeOptions param, bool enableQu for (int i = R_COM; i < RGBA_COM; i++) { work->mse[i] = (int32_t *)calloc(blockNum, sizeof(int32_t)); if (!work->mse[i]) { - HiLog::Error(LABEL, "quality control calloc failed"); + IMAGE_LOGE("quality control calloc failed"); return false; } } @@ -249,7 +250,7 @@ uint32_t AstcCodec::AstcSoftwareEncode(TextureEncodeOptions ¶m, bool enableQ return ERROR; } if (InitAstcencConfig(&work, ¶m) != SUCCESS) { - HiLog::Error(LABEL, "astc InitAstcencConfig failed"); + IMAGE_LOGE("astc InitAstcencConfig failed"); FreeMem(&work); return ERROR; } @@ -258,7 +259,7 @@ uint32_t AstcCodec::AstcSoftwareEncode(TextureEncodeOptions ¶m, bool enableQ size_t size; astcOutput_->GetCapicity(size); if (GenAstcHeader(work.data_out_, work.image_, ¶m, size) != SUCCESS) { - HiLog::Error(LABEL, "astc GenAstcHeader failed"); + IMAGE_LOGE("astc GenAstcHeader failed"); FreeMem(&work); return ERROR; } @@ -274,7 +275,7 @@ uint32_t AstcCodec::AstcSoftwareEncode(TextureEncodeOptions ¶m, bool enableQ #else if (ASTCENC_SUCCESS != work.error_) { #endif - HiLog::Error(LABEL, "astc compress failed"); + IMAGE_LOGE("astc compress failed"); FreeMem(&work); return ERROR; } @@ -301,26 +302,26 @@ static bool TryAstcEncBasedOnCl(uint8_t *inData, int32_t stride, TextureEncodeOp { ClAstcHandle *astcClEncoder = nullptr; if ((inData == nullptr) || (param == nullptr) || (buffer == nullptr)) { - HiLog::Error(LABEL, "astc Please check TryAstcEncBasedOnCl input!"); + IMAGE_LOGE("astc Please check TryAstcEncBasedOnCl input!"); return false; } if (AstcClCreate(&astcClEncoder, clBinPath) != CL_ASTC_ENC_SUCCESS) { - HiLog::Error(LABEL, "astc AstcClCreate failed!"); + IMAGE_LOGE("astc AstcClCreate failed!"); return false; } ClAstcImageOption imageIn; if (AstcClFillImage(&imageIn, inData, stride, param->width_, param->height_) != CL_ASTC_ENC_SUCCESS) { - HiLog::Error(LABEL, "astc AstcClFillImage failed!"); + IMAGE_LOGE("astc AstcClFillImage failed!"); AstcClClose(astcClEncoder); return false; } if (AstcClEncImage(astcClEncoder, &imageIn, buffer) != CL_ASTC_ENC_SUCCESS) { - HiLog::Error(LABEL, "astc AstcClEncImage failed!"); + IMAGE_LOGE("astc AstcClEncImage failed!"); AstcClClose(astcClEncoder); return false; } if (AstcClClose(astcClEncoder) != CL_ASTC_ENC_SUCCESS) { - HiLog::Error(LABEL, "astc AstcClClose failed!"); + IMAGE_LOGE("astc AstcClClose failed!"); return false; } return true; @@ -344,25 +345,25 @@ uint32_t AstcCodec::ASTCEncode() if (ImageSystemProperties::GetAstcHardWareEncodeEnabled() && (param.blockX_ == DEFAULT_DIM) && (param.blockY_ == DEFAULT_DIM)) { // HardWare only support 4x4 now - HiLog::Info(LABEL, "astc hardware encode begin"); + IMAGE_LOGI("astc hardware encode begin"); std::string clBinPath = "/data/local/tmp/astcKernelBin.bin"; if (TryAstcEncBasedOnCl(static_cast(astcPixelMap_->GetWritablePixels()), astcPixelMap_->GetRowStride(), ¶m, astcOutput_->GetAddr(), clBinPath)) { hardwareFlag = true; - HiLog::Info(LABEL, "astc hardware encode success!"); + IMAGE_LOGI("astc hardware encode success!"); } else { - HiLog::Info(LABEL, "astc hardware encode failed!"); + IMAGE_LOGI("astc hardware encode failed!"); } } if (!hardwareFlag) { uint32_t res = AstcSoftwareEncode(param, enableQualityCheck, blocksNum, outSize); if (res != SUCCESS) { - HiLog::Error(LABEL, "AstcSoftwareEncode failed"); + IMAGE_LOGE("AstcSoftwareEncode failed"); return ERROR; } - HiLog::Info(LABEL, "astc software encode success!"); + IMAGE_LOGI("astc software encode success!"); } - HiLog::Info(LABEL, "astc hardwareFlag %{public}d, enableQualityCheck %{public}d, privateProfile %{public}d", + IMAGE_LOGI("astc hardwareFlag %{public}d, enableQualityCheck %{public}d, privateProfile %{public}d", hardwareFlag, enableQualityCheck, param.privateProfile_); astcOutput_->SetOffset(outSize); return SUCCESS; diff --git a/plugins/common/libs/image/libextplugin/src/texture_encode/image_compressor.cpp b/plugins/common/libs/image/libextplugin/src/texture_encode/image_compressor.cpp index 365b63e87..cdffe8dd2 100644 --- a/plugins/common/libs/image/libextplugin/src/texture_encode/image_compressor.cpp +++ b/plugins/common/libs/image/libextplugin/src/texture_encode/image_compressor.cpp @@ -19,11 +19,13 @@ #include "securec.h" #include "media_errors.h" -#include "hilog/log.h" -#include "log_tags.h" +#include "image_log.h" -using namespace OHOS::HiviewDFX; -constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "ClAstcEnc" }; +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "ClAstcEnc" constexpr int MAX_WIDTH = 8192; constexpr int MAX_HEIGHT = 4096; @@ -1267,14 +1269,14 @@ kernel void AstcCl(read_only image2d_t inputImage, __global uint4* astcArr, __gl CL_ASTC_SHARE_LIB_API CL_ASTC_STATUS AstcClClose(ClAstcHandle *clAstcHandle) { if (clAstcHandle == nullptr) { - HiLog::Error(LABEL, "astc AstcClClose clAstcHandle is nullptr!"); + IMAGE_LOGE("astc AstcClClose clAstcHandle is nullptr!"); return CL_ASTC_ENC_FAILED; } cl_int clRet; if (clAstcHandle->kernel != nullptr) { clRet = clReleaseKernel(clAstcHandle->kernel); if (clRet != CL_SUCCESS) { - HiLog::Error(LABEL, "astc clReleaseKernel failed ret %{public}d!", clRet); + IMAGE_LOGE("astc clReleaseKernel failed ret %{public}d!", clRet); return CL_ASTC_ENC_FAILED; } clAstcHandle->kernel = nullptr; @@ -1282,7 +1284,7 @@ CL_ASTC_SHARE_LIB_API CL_ASTC_STATUS AstcClClose(ClAstcHandle *clAstcHandle) if (clAstcHandle->queue != nullptr) { clRet = clReleaseCommandQueue(clAstcHandle->queue); if (clRet != CL_SUCCESS) { - HiLog::Error(LABEL, "astc clReleaseCommandQueue failed ret %{public}d!", clRet); + IMAGE_LOGE("astc clReleaseCommandQueue failed ret %{public}d!", clRet); return CL_ASTC_ENC_FAILED; } clAstcHandle->queue = nullptr; @@ -1290,7 +1292,7 @@ CL_ASTC_SHARE_LIB_API CL_ASTC_STATUS AstcClClose(ClAstcHandle *clAstcHandle) if (clAstcHandle->context != nullptr) { clRet = clReleaseContext(clAstcHandle->context); if (clRet != CL_SUCCESS) { - HiLog::Error(LABEL, "astc clReleaseContext failed ret %{public}d!", clRet); + IMAGE_LOGE("astc clReleaseContext failed ret %{public}d!", clRet); return CL_ASTC_ENC_FAILED; } clAstcHandle->context = nullptr; @@ -1316,37 +1318,37 @@ static CL_ASTC_STATUS SaveClBin(cl_program program, const std::string clBinPath) size_t programBinarySizes; cl_int clRet = clGetProgramInfo(program, CL_PROGRAM_BINARY_SIZES, sizeof(size_t), &programBinarySizes, NULL); if (clRet != CL_SUCCESS) { - HiLog::Error(LABEL, "astc clGetProgramInfo CL_PROGRAM_BINARY_SIZES failed ret %{public}d!", clRet); + IMAGE_LOGE("astc clGetProgramInfo CL_PROGRAM_BINARY_SIZES failed ret %{public}d!", clRet); return CL_ASTC_ENC_FAILED; } if ((programBinarySizes == 0) || (programBinarySizes > MAX_MALLOC_BYTES)) { - HiLog::Error(LABEL, "astc clGetProgramInfo programBinarySizes %{public}zu too big!", programBinarySizes); + IMAGE_LOGE("astc clGetProgramInfo programBinarySizes %{public}zu too big!", programBinarySizes); return CL_ASTC_ENC_FAILED; } uint8_t *programBinaries = (uint8_t *)malloc(programBinarySizes); if (programBinaries == nullptr) { - HiLog::Error(LABEL, "astc programBinaries malloc failed!"); + IMAGE_LOGE("astc programBinaries malloc failed!"); return CL_ASTC_ENC_FAILED; } clRet = clGetProgramInfo(program, CL_PROGRAM_BINARIES, programBinarySizes, &programBinaries, NULL); if (clRet != CL_SUCCESS) { - HiLog::Error(LABEL, "astc clGetProgramInfo CL_PROGRAM_BINARIES failed ret %{public}d!", clRet); + IMAGE_LOGE("astc clGetProgramInfo CL_PROGRAM_BINARIES failed ret %{public}d!", clRet); free(programBinaries); return CL_ASTC_ENC_FAILED; } FILE *fp = fopen(clBinPath.c_str(), "wb"); if (fp == nullptr) { - HiLog::Error(LABEL, "astc create file: %{public}s failed!", clBinPath.c_str()); + IMAGE_LOGE("astc create file: %{public}s failed!", clBinPath.c_str()); free(programBinaries); return CL_ASTC_ENC_FAILED; } CL_ASTC_STATUS ret = CL_ASTC_ENC_SUCCESS; if (fwrite(programBinaries, 1, programBinarySizes, fp) != programBinarySizes) { - HiLog::Error(LABEL, "astc fwrite programBinaries file failed!"); + IMAGE_LOGE("astc fwrite programBinaries file failed!"); ret = CL_ASTC_ENC_FAILED; } if (fclose(fp) != 0) { - HiLog::Error(LABEL, "astc SaveClBin close file failed!"); + IMAGE_LOGE("astc SaveClBin close file failed!"); ret = CL_ASTC_ENC_FAILED; } fp = nullptr; @@ -1358,12 +1360,12 @@ static CL_ASTC_STATUS BuildProgramAndCreateKernel(cl_program program, ClAstcHand { cl_int clRet = clBuildProgram(program, 1, &clAstcHandle->deviceID, "-cl-std=CL3.0", nullptr, nullptr); if (clRet != CL_SUCCESS) { - HiLog::Error(LABEL, "astc clBuildProgram failed ret %{public}d!", clRet); + IMAGE_LOGE("astc clBuildProgram failed ret %{public}d!", clRet); return CL_ASTC_ENC_FAILED; } clAstcHandle->kernel = clCreateKernel(program, "AstcCl", &clRet); if (clRet != CL_SUCCESS) { - HiLog::Error(LABEL, "astc clCreateKernel failed ret %{public}d!", clRet); + IMAGE_LOGE("astc clCreateKernel failed ret %{public}d!", clRet); return CL_ASTC_ENC_FAILED; } return CL_ASTC_ENC_SUCCESS; @@ -1377,41 +1379,41 @@ static CL_ASTC_STATUS AstcClBuildProgram(ClAstcHandle *clAstcHandle, const std:: size_t sourceSize = strlen(g_programSource) + 1; // '\0' occupies 1 bytes program = clCreateProgramWithSource(clAstcHandle->context, 1, &g_programSource, &sourceSize, &clRet); if (clRet != CL_SUCCESS) { - HiLog::Error(LABEL, "astc clCreateProgramWithSource failed ret %{public}d!", clRet); + IMAGE_LOGE("astc clCreateProgramWithSource failed ret %{public}d!", clRet); return CL_ASTC_ENC_FAILED; } if (BuildProgramAndCreateKernel(program, clAstcHandle) != CL_ASTC_ENC_SUCCESS) { - HiLog::Error(LABEL, "astc clCreateProgramWithSource failed ret %{public}d!", clRet); + IMAGE_LOGE("astc clCreateProgramWithSource failed ret %{public}d!", clRet); clReleaseProgram(program); return CL_ASTC_ENC_FAILED; } if (SaveClBin(program, clBinPath) != CL_ASTC_ENC_SUCCESS) { - HiLog::Info(LABEL, "astc SaveClBin failed!"); + IMAGE_LOGI("astc SaveClBin failed!"); } } else { std::ifstream contents{clBinPath}; std::string binaryContent{std::istreambuf_iterator{contents}, {}}; size_t binSize = binaryContent.length(); if ((binSize == 0) || (binSize > MAX_MALLOC_BYTES)) { - HiLog::Error(LABEL, "astc AstcClBuildProgram read CLbin file lenth error %{public}zu!", binSize); + IMAGE_LOGE("astc AstcClBuildProgram read CLbin file lenth error %{public}zu!", binSize); return CL_ASTC_ENC_FAILED; } const char *binary = static_cast(binaryContent.c_str()); program = clCreateProgramWithBinary(clAstcHandle->context, 1, &clAstcHandle->deviceID, &binSize, (const unsigned char **)&binary, nullptr, &clRet); if (clRet != CL_SUCCESS) { - HiLog::Error(LABEL, "astc clCreateProgramWithBinary failed ret %{public}d!", clRet); + IMAGE_LOGE("astc clCreateProgramWithBinary failed ret %{public}d!", clRet); return CL_ASTC_ENC_FAILED; } if (BuildProgramAndCreateKernel(program, clAstcHandle) != CL_ASTC_ENC_SUCCESS) { - HiLog::Error(LABEL, "astc BuildProgramAndCreateKernel with bin failed!"); + IMAGE_LOGE("astc BuildProgramAndCreateKernel with bin failed!"); clReleaseProgram(program); return CL_ASTC_ENC_FAILED; } } clRet = clReleaseProgram(program); if (clRet != CL_SUCCESS) { - HiLog::Error(LABEL, "astc clReleaseProgram failed ret %{public}d!", clRet); + IMAGE_LOGE("astc clReleaseProgram failed ret %{public}d!", clRet); return CL_ASTC_ENC_FAILED; } return CL_ASTC_ENC_SUCCESS; @@ -1420,35 +1422,35 @@ static CL_ASTC_STATUS AstcClBuildProgram(ClAstcHandle *clAstcHandle, const std:: static CL_ASTC_STATUS AstcCreateClKernel(ClAstcHandle *clAstcHandle, const std::string clBinPath) { if (!OHOS::InitOpenCL()) { - HiLog::Error(LABEL, "astc InitOpenCL error!"); + IMAGE_LOGE("astc InitOpenCL error!"); return CL_ASTC_ENC_FAILED; } cl_int clRet; cl_platform_id platformID; clRet = clGetPlatformIDs(1, &platformID, NULL); if (clRet != CL_SUCCESS) { - HiLog::Error(LABEL, "astc clGetPlatformIDs failed ret %{public}d!", clRet); + IMAGE_LOGE("astc clGetPlatformIDs failed ret %{public}d!", clRet); return CL_ASTC_ENC_FAILED; } clRet = clGetDeviceIDs(platformID, CL_DEVICE_TYPE_GPU, 1, &clAstcHandle->deviceID, NULL); if (clRet != CL_SUCCESS) { - HiLog::Error(LABEL, "astc clGetDeviceIDs failed ret %{public}d!", clRet); + IMAGE_LOGE("astc clGetDeviceIDs failed ret %{public}d!", clRet); return CL_ASTC_ENC_FAILED; } clAstcHandle->context = clCreateContext(0, 1, &clAstcHandle->deviceID, NULL, NULL, &clRet); if (clRet != CL_SUCCESS) { - HiLog::Error(LABEL, "astc clCreateContext failed ret %{public}d!", clRet); + IMAGE_LOGE("astc clCreateContext failed ret %{public}d!", clRet); return CL_ASTC_ENC_FAILED; } cl_queue_properties props[] = {CL_QUEUE_PRIORITY_KHR, CL_QUEUE_PRIORITY_HIGH_KHR, 0}; clAstcHandle->queue = clCreateCommandQueueWithProperties(clAstcHandle->context, clAstcHandle->deviceID, props, &clRet); if (clRet != CL_SUCCESS) { - HiLog::Error(LABEL, "astc clCreateCommandQueueWithProperties failed ret %{public}d!", clRet); + IMAGE_LOGE("astc clCreateCommandQueueWithProperties failed ret %{public}d!", clRet); return CL_ASTC_ENC_FAILED; } if (AstcClBuildProgram(clAstcHandle, clBinPath) != CL_ASTC_ENC_SUCCESS) { - HiLog::Error(LABEL, "astc AstcClBuildProgram failed!"); + IMAGE_LOGE("astc AstcClBuildProgram failed!"); return CL_ASTC_ENC_FAILED; } return CL_ASTC_ENC_SUCCESS; @@ -1458,19 +1460,19 @@ CL_ASTC_SHARE_LIB_API CL_ASTC_STATUS AstcClCreate(ClAstcHandle **handle, const s { ClAstcHandle *clAstcHandle = (ClAstcHandle *)calloc(1, sizeof(ClAstcHandle)); if (clAstcHandle == nullptr) { - HiLog::Error(LABEL, "astc AstcClCreate handle calloc failed!"); + IMAGE_LOGE("astc AstcClCreate handle calloc failed!"); return CL_ASTC_ENC_FAILED; } *handle = clAstcHandle; size_t numMaxBlocks = ((MAX_WIDTH + DIM - 1) / DIM) * ((MAX_HEIGHT + DIM - 1) / DIM); clAstcHandle->encObj.blockErrs_ = (uint32_t *)malloc(numMaxBlocks * sizeof(uint32_t)); // 8MB mem Max if (clAstcHandle->encObj.blockErrs_ == nullptr) { - HiLog::Error(LABEL, "astc blockErrs_ malloc failed!"); + IMAGE_LOGE("astc blockErrs_ malloc failed!"); AstcClClose(*handle); return CL_ASTC_ENC_FAILED; } if (AstcCreateClKernel(clAstcHandle, clBinPath) != CL_ASTC_ENC_SUCCESS) { - HiLog::Error(LABEL, "astc AstcCreateClKernel failed!"); + IMAGE_LOGE("astc AstcCreateClKernel failed!"); AstcClClose(*handle); return CL_ASTC_ENC_FAILED; } @@ -1480,11 +1482,11 @@ CL_ASTC_SHARE_LIB_API CL_ASTC_STATUS AstcClCreate(ClAstcHandle **handle, const s static CL_ASTC_STATUS AstcClEncImageCheckImageOption(const ClAstcImageOption *imageIn) { if ((imageIn->width <= 0) || (imageIn->height <= 0) || (imageIn->stride < imageIn->width)) { - HiLog::Error(LABEL, "astc AstcClEncImage width <= 0 or height <= 0 or stride < width!"); + IMAGE_LOGE("astc AstcClEncImage width <= 0 or height <= 0 or stride < width!"); return CL_ASTC_ENC_FAILED; } if ((imageIn->width > MAX_WIDTH) || (imageIn->height > MAX_HEIGHT)) { - HiLog::Error(LABEL, "astc AstcClEncImage width[%{public}d] \ + IMAGE_LOGE("astc AstcClEncImage width[%{public}d] \ need be [1, %{public}d] and height[%{public}d] need be [1, %{public}d]", \ imageIn->width, MAX_WIDTH, imageIn->height, MAX_HEIGHT); return CL_ASTC_ENC_FAILED; @@ -1496,7 +1498,7 @@ CL_ASTC_SHARE_LIB_API CL_ASTC_STATUS AstcClFillImage(ClAstcImageOption *imageIn, int32_t width, int32_t height) { if (imageIn == nullptr) { - HiLog::Error(LABEL, "astc AstcClFillImage imageIn is nullptr!"); + IMAGE_LOGE("astc AstcClFillImage imageIn is nullptr!"); return CL_ASTC_ENC_FAILED; } imageIn->data = data; @@ -1504,7 +1506,7 @@ CL_ASTC_SHARE_LIB_API CL_ASTC_STATUS AstcClFillImage(ClAstcImageOption *imageIn, imageIn->width = width; imageIn->height = height; if (AstcClEncImageCheckImageOption(imageIn)) { - HiLog::Error(LABEL, "astc AstcClEncImageCheckImageOption failed!"); + IMAGE_LOGE("astc AstcClEncImageCheckImageOption failed!"); return CL_ASTC_ENC_FAILED; } return CL_ASTC_ENC_SUCCESS; @@ -1538,21 +1540,21 @@ static void ReleaseClAstcObj(ClAstcObjEnc *obj) if (obj->inputImage != nullptr) { clRet = clReleaseMemObject(obj->inputImage); if (clRet != CL_SUCCESS) { - HiLog::Error(LABEL, "astc inputImage release failed ret %{public}d!", clRet); + IMAGE_LOGE("astc inputImage release failed ret %{public}d!", clRet); } obj->inputImage = nullptr; } if (obj->astcResult != nullptr) { clRet = clReleaseMemObject(obj->astcResult); if (clRet != CL_SUCCESS) { - HiLog::Error(LABEL, "astc astcResult release failed ret %{public}d!", clRet); + IMAGE_LOGE("astc astcResult release failed ret %{public}d!", clRet); } obj->astcResult = nullptr; } if (obj->errBuffer != nullptr) { clRet = clReleaseMemObject(obj->errBuffer); if (clRet != CL_SUCCESS) { - HiLog::Error(LABEL, "astc errBuffer release failed ret %{public}d!", clRet); + IMAGE_LOGE("astc errBuffer release failed ret %{public}d!", clRet); } obj->errBuffer = nullptr; } @@ -1580,7 +1582,7 @@ static CL_ASTC_STATUS ClCreateBufferAndImage(const ClAstcImageOption *imageIn, size_t blockErrBytes = sizeof(uint32_t) * numBlocks; encObj->astcSize = numBlocks * TEXTURE_BLOCK_BYTES; if ((blockErrs == nullptr) || (memset_s(blockErrs, blockErrBytes, 0, blockErrBytes))) { - HiLog::Error(LABEL, "astc blockErrs is nullptr or memset failed!"); + IMAGE_LOGE("astc blockErrs is nullptr or memset failed!"); return CL_ASTC_ENC_FAILED; } cl_image_format imageFormat = { CL_RGBA, CL_UNORM_INT8 }; @@ -1589,18 +1591,18 @@ static CL_ASTC_STATUS ClCreateBufferAndImage(const ClAstcImageOption *imageIn, encObj->inputImage = clCreateImage(clAstcHandle->context, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, &imageFormat, &desc, data, &clRet); if (clRet != CL_SUCCESS) { - HiLog::Error(LABEL, "astc clCreateImage failed ret %{public}d!", clRet); + IMAGE_LOGE("astc clCreateImage failed ret %{public}d!", clRet); return CL_ASTC_ENC_FAILED; } encObj->astcResult = clCreateBuffer(clAstcHandle->context, CL_MEM_ALLOC_HOST_PTR, encObj->astcSize, NULL, &clRet); if (clRet != CL_SUCCESS) { - HiLog::Error(LABEL, "astc clCreateBuffer astcResult failed ret %{public}d!", clRet); + IMAGE_LOGE("astc clCreateBuffer astcResult failed ret %{public}d!", clRet); return CL_ASTC_ENC_FAILED; } encObj->errBuffer = clCreateBuffer(clAstcHandle->context, CL_MEM_USE_HOST_PTR, blockErrBytes, blockErrs, &clRet); if (clRet != CL_SUCCESS) { - HiLog::Error(LABEL, "astc clCreateBuffer errBuffer failed ret %{public}d!", clRet); + IMAGE_LOGE("astc clCreateBuffer errBuffer failed ret %{public}d!", clRet); return CL_ASTC_ENC_FAILED; } return CL_ASTC_ENC_SUCCESS; @@ -1611,27 +1613,27 @@ static CL_ASTC_STATUS ClKernelArgSet(ClAstcHandle *clAstcHandle, ClAstcObjEnc *e int32_t kernelId = 0; cl_int clRet = clSetKernelArg(clAstcHandle->kernel, kernelId++, sizeof(cl_mem), &encObj->inputImage); if (clRet != CL_SUCCESS) { - HiLog::Error(LABEL, "astc clSetKernelArg inputImage failed ret %{public}d!", clRet); + IMAGE_LOGE("astc clSetKernelArg inputImage failed ret %{public}d!", clRet); return CL_ASTC_ENC_FAILED; } clRet = clSetKernelArg(clAstcHandle->kernel, kernelId++, sizeof(cl_mem), &encObj->astcResult); if (clRet != CL_SUCCESS) { - HiLog::Error(LABEL, "astc clSetKernelArg astcResult failed ret %{public}d!", clRet); + IMAGE_LOGE("astc clSetKernelArg astcResult failed ret %{public}d!", clRet); return CL_ASTC_ENC_FAILED; } clRet = clSetKernelArg(clAstcHandle->kernel, kernelId++, sizeof(cl_mem), &encObj->errBuffer); if (clRet != CL_SUCCESS) { - HiLog::Error(LABEL, "astc clSetKernelArg errBuffer failed ret %{public}d!", clRet); + IMAGE_LOGE("astc clSetKernelArg errBuffer failed ret %{public}d!", clRet); return CL_ASTC_ENC_FAILED; } clRet = clSetKernelArg(clAstcHandle->kernel, kernelId++, sizeof(int), &width); if (clRet != CL_SUCCESS) { - HiLog::Error(LABEL, "astc clSetKernelArg width failed ret %{public}d!", clRet); + IMAGE_LOGE("astc clSetKernelArg width failed ret %{public}d!", clRet); return CL_ASTC_ENC_FAILED; } clRet = clSetKernelArg(clAstcHandle->kernel, kernelId++, sizeof(int), &height); if (clRet != CL_SUCCESS) { - HiLog::Error(LABEL, "astc clSetKernelArg height failed ret %{public}d!", clRet); + IMAGE_LOGE("astc clSetKernelArg height failed ret %{public}d!", clRet); return CL_ASTC_ENC_FAILED; } return CL_ASTC_ENC_SUCCESS; @@ -1640,7 +1642,7 @@ static CL_ASTC_STATUS ClKernelArgSet(ClAstcHandle *clAstcHandle, ClAstcObjEnc *e static CL_ASTC_STATUS ClKernelArgSetAndRun(ClAstcHandle *clAstcHandle, ClAstcObjEnc *encObj, int width, int height) { if (ClKernelArgSet(clAstcHandle, encObj, width, height) != CL_ASTC_ENC_SUCCESS) { - HiLog::Error(LABEL, "astc ClKernelArgSet failed!"); + IMAGE_LOGE("astc ClKernelArgSet failed!"); return CL_ASTC_ENC_FAILED; } size_t local[] = {WORK_GROUP_SIZE, WORK_GROUP_SIZE}; @@ -1651,7 +1653,7 @@ static CL_ASTC_STATUS ClKernelArgSetAndRun(ClAstcHandle *clAstcHandle, ClAstcObj cl_int clRet = clGetKernelWorkGroupInfo(clAstcHandle->kernel, clAstcHandle->deviceID, CL_KERNEL_WORK_GROUP_SIZE, sizeof(size_t), &localMax, nullptr); if ((clRet != CL_SUCCESS) || localMax <= 0) { - HiLog::Error(LABEL, "astc clGetKernelWorkGroupInfo failed ret %{public}d!", clRet); + IMAGE_LOGE("astc clGetKernelWorkGroupInfo failed ret %{public}d!", clRet); return CL_ASTC_ENC_FAILED; } while (local[0] * local[1] > localMax) { @@ -1659,18 +1661,18 @@ static CL_ASTC_STATUS ClKernelArgSetAndRun(ClAstcHandle *clAstcHandle, ClAstcObj local[1]--; } if ((local[0] < 1) || (local[1] < 1)) { - HiLog::Error(LABEL, "astc ClKernelArgSetAndRun local set failed!"); + IMAGE_LOGE("astc ClKernelArgSetAndRun local set failed!"); return CL_ASTC_ENC_FAILED; } clRet = clEnqueueNDRangeKernel(clAstcHandle->queue, clAstcHandle->kernel, GLOBAL_WH_NUM_CL, nullptr, global, local, 0, nullptr, nullptr); if (clRet != CL_SUCCESS) { - HiLog::Error(LABEL, "astc clEnqueueNDRangeKernel failed ret %{public}d!", clRet); + IMAGE_LOGE("astc clEnqueueNDRangeKernel failed ret %{public}d!", clRet); return CL_ASTC_ENC_FAILED; } clRet = clFinish(clAstcHandle->queue); if (clRet != CL_SUCCESS) { - HiLog::Error(LABEL, "astc clFinish failed ret %{public}d!", clRet); + IMAGE_LOGE("astc clFinish failed ret %{public}d!", clRet); return CL_ASTC_ENC_FAILED; } return CL_ASTC_ENC_SUCCESS; @@ -1682,7 +1684,7 @@ static CL_ASTC_STATUS ClReadAstcBufAndBlockError(ClAstcHandle *clAstcHandle, ClA cl_int clRet = clEnqueueReadBuffer(clAstcHandle->queue, encObj->astcResult, CL_TRUE, 0, encObj->astcSize, buffer + TEXTURE_HEAD_BYTES, 0, NULL, NULL); if (clRet != CL_SUCCESS) { - HiLog::Error(LABEL, "astc clEnqueueReadBuffer astcResult failed ret %{public}d!", clRet); + IMAGE_LOGE("astc clEnqueueReadBuffer astcResult failed ret %{public}d!", clRet); return CL_ASTC_ENC_FAILED; } uint32_t maxVal = 0; @@ -1691,7 +1693,7 @@ static CL_ASTC_STATUS ClReadAstcBufAndBlockError(ClAstcHandle *clAstcHandle, ClA clRet = clEnqueueReadBuffer(clAstcHandle->queue, encObj->errBuffer, CL_TRUE, 0, sizeof(uint32_t) * numBlocks, encObj->blockErrs_, 0, NULL, NULL); if (clRet != CL_SUCCESS) { - HiLog::Error(LABEL, "astc clEnqueueReadBuffer blockErrs failed ret %{public}d!", clRet); + IMAGE_LOGE("astc clEnqueueReadBuffer blockErrs failed ret %{public}d!", clRet); return CL_ASTC_ENC_FAILED; } GetMaxAndSumVal(numBlocks, encObj->blockErrs_, maxVal, sumVal); @@ -1702,28 +1704,28 @@ CL_ASTC_SHARE_LIB_API CL_ASTC_STATUS AstcClEncImage(ClAstcHandle *clAstcHandle, const ClAstcImageOption *imageIn, uint8_t *buffer) { if ((clAstcHandle == nullptr) || (imageIn == nullptr) || (buffer == nullptr)) { - HiLog::Error(LABEL, "astc AstcClEncImage clAstcHandle or imageIn or buffer is nullptr!"); + IMAGE_LOGE("astc AstcClEncImage clAstcHandle or imageIn or buffer is nullptr!"); return CL_ASTC_ENC_FAILED; } if (AstcClEncImageCheckImageOption(imageIn)) { - HiLog::Error(LABEL, "astc AstcClEncImageCheckImageOption failed!"); + IMAGE_LOGE("astc AstcClEncImageCheckImageOption failed!"); return CL_ASTC_ENC_FAILED; } GenAstcHeader(buffer, DIM, DIM, imageIn->width, imageIn->height); ClAstcObjEnc *encObj = &clAstcHandle->encObj; if (ClCreateBufferAndImage(imageIn, clAstcHandle, encObj) != CL_ASTC_ENC_SUCCESS) { ReleaseClAstcObj(encObj); - HiLog::Error(LABEL, "astc ClCreateBufferAndImage failed!"); + IMAGE_LOGE("astc ClCreateBufferAndImage failed!"); return CL_ASTC_ENC_FAILED; } if (ClKernelArgSetAndRun(clAstcHandle, encObj, imageIn->width, imageIn->height) != CL_ASTC_ENC_SUCCESS) { ReleaseClAstcObj(encObj); - HiLog::Error(LABEL, "astc ClKernelArgSetAndRun failed!"); + IMAGE_LOGE("astc ClKernelArgSetAndRun failed!"); return CL_ASTC_ENC_FAILED; } if (ClReadAstcBufAndBlockError(clAstcHandle, encObj, imageIn, buffer) != CL_ASTC_ENC_SUCCESS) { ReleaseClAstcObj(encObj); - HiLog::Error(LABEL, "astc ClReadAstcBufAndBlockError failed!"); + IMAGE_LOGE("astc ClReadAstcBufAndBlockError failed!"); return CL_ASTC_ENC_FAILED; } ReleaseClAstcObj(encObj); diff --git a/plugins/common/libs/image/libgifplugin/include/gif_decoder.h b/plugins/common/libs/image/libgifplugin/include/gif_decoder.h index 062bd0895..2b9899257 100644 --- a/plugins/common/libs/image/libgifplugin/include/gif_decoder.h +++ b/plugins/common/libs/image/libgifplugin/include/gif_decoder.h @@ -21,8 +21,6 @@ #include #include "abs_image_decoder.h" #include "gif_lib.h" -#include "hilog/log.h" -#include "log_tags.h" #include "media_errors.h" #include "nocopyable.h" #include "plugin_class_base.h" diff --git a/plugins/common/libs/image/libgifplugin/src/gif_decoder.cpp b/plugins/common/libs/image/libgifplugin/src/gif_decoder.cpp index bfadffdd7..5f5e24ae4 100644 --- a/plugins/common/libs/image/libgifplugin/src/gif_decoder.cpp +++ b/plugins/common/libs/image/libgifplugin/src/gif_decoder.cpp @@ -15,17 +15,22 @@ #include "gif_decoder.h" +#include "image_log.h" #include "image_utils.h" #if !defined(IOS_PLATFORM) && !defined(A_PLATFORM) #include "surface_buffer.h" #endif +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "GifDecoder" + namespace OHOS { namespace ImagePlugin { -using namespace OHOS::HiviewDFX; using namespace MultimediaPlugin; using namespace Media; -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "GifDecoder" }; namespace { #if __BYTE_ORDER == __LITTLE_ENDIAN @@ -73,28 +78,28 @@ void GifDecoder::SetSource(InputDataStream &sourceStream) uint32_t GifDecoder::GetTopLevelImageNum(uint32_t &num) { if (inputStreamPtr_ == nullptr) { - HiLog::Error(LABEL, "[GetTopLevelImageNum]set source need firstly"); + IMAGE_LOGE("[GetTopLevelImageNum]set source need firstly"); return ERR_IMAGE_DATA_ABNORMAL; } if (!inputStreamPtr_->IsStreamCompleted()) { - HiLog::Warn(LABEL, "[GetTopLevelImageNum]don't enough data to decode the frame number"); + IMAGE_LOGW("[GetTopLevelImageNum]don't enough data to decode the frame number"); return ERR_IMAGE_SOURCE_DATA_INCOMPLETE; } uint32_t errorCode = CreateGifFileTypeIfNotExist(); if (errorCode != SUCCESS) { - HiLog::Error(LABEL, "[GetTopLevelImageNum]create GifFileType pointer failed %{public}u", errorCode); + IMAGE_LOGE("[GetTopLevelImageNum]create GifFileType pointer failed %{public}u", errorCode); return ERR_IMAGE_DECODE_ABNORMAL; } if (!isLoadAllFrame_) { errorCode = UpdateGifFileType(INT_MAX); if (errorCode != SUCCESS) { - HiLog::Error(LABEL, "[GetTopLevelImageNum]update GifFileType pointer failed %{public}u", errorCode); + IMAGE_LOGE("[GetTopLevelImageNum]update GifFileType pointer failed %{public}u", errorCode); return ERR_IMAGE_DECODE_ABNORMAL; } } num = gifPtr_->ImageCount; if (num <= 0) { - HiLog::Error(LABEL, "[GetTopLevelImageNum]image frame number must be larger than 0"); + IMAGE_LOGE("[GetTopLevelImageNum]image frame number must be larger than 0"); return ERR_IMAGE_DATA_ABNORMAL; } return SUCCESS; @@ -105,13 +110,13 @@ uint32_t GifDecoder::GetImageSize(uint32_t index, PlSize &size) { uint32_t errorCode = CheckIndex(index); if (errorCode != SUCCESS) { - HiLog::Error(LABEL, "[GetImageSize]index %{public}u is invalid %{public}u", index, errorCode); + IMAGE_LOGE("[GetImageSize]index %{public}u is invalid %{public}u", index, errorCode); return errorCode; } const int32_t bgWidth = gifPtr_->SWidth; const int32_t bgHeight = gifPtr_->SHeight; if (bgWidth <= 0 || bgHeight <= 0) { - HiLog::Error(LABEL, "[GetImageSize]background size [%{public}d, %{public}d] is invalid", bgWidth, bgHeight); + IMAGE_LOGE("[GetImageSize]background size [%{public}d, %{public}d] is invalid", bgWidth, bgHeight); return ERR_IMAGE_INVALID_PARAMETER; } size.width = bgWidth; @@ -123,7 +128,7 @@ uint32_t GifDecoder::SetDecodeOptions(uint32_t index, const PixelDecodeOptions & { uint32_t errorCode = GetImageSize(index, info.size); if (errorCode != SUCCESS) { - HiLog::Error(LABEL, "[SetDecodeOptions]get image size failed %{public}u", errorCode); + IMAGE_LOGE("[SetDecodeOptions]get image size failed %{public}u", errorCode); return errorCode; } info.alphaType = PlAlphaType::IMAGE_ALPHA_TYPE_OPAQUE; @@ -140,7 +145,7 @@ uint32_t GifDecoder::Decode(uint32_t index, DecodeContext &context) PlSize imageSize; uint32_t errorCode = GetImageSize(index, imageSize); if (errorCode != SUCCESS) { - HiLog::Error(LABEL, "[Decode]index %{public}u is invalid %{public}u", index, errorCode); + IMAGE_LOGE("[Decode]index %{public}u is invalid %{public}u", index, errorCode); return errorCode; } // compute start index and end index. @@ -158,20 +163,20 @@ uint32_t GifDecoder::Decode(uint32_t index, DecodeContext &context) startIndex = 0; isOverlapped = false; } - HiLog::Debug(LABEL, "[Decode]start frame: %{public}u, last frame: %{public}u," - "last pixelMapIndex: %{public}d, isOverlapped: %{public}d", - startIndex, endIndex, lastPixelMapIndex_, isOverlapped); + IMAGE_LOGD("[Decode]start frame: %{public}u, last frame: %{public}u," + "last pixelMapIndex: %{public}d, isOverlapped: %{public}d", + startIndex, endIndex, lastPixelMapIndex_, isOverlapped); if (!isOverlapped) { errorCode = OverlapFrame(startIndex, endIndex); if (errorCode != SUCCESS) { - HiLog::Error(LABEL, "[Decode]overlap frame failed %{public}u", errorCode); + IMAGE_LOGE("[Decode]overlap frame failed %{public}u", errorCode); return errorCode; } } errorCode = RedirectOutputBuffer(context); if (errorCode != SUCCESS) { - HiLog::Error(LABEL, "[Decode]redirect output stream failed %{public}u", errorCode); + IMAGE_LOGE("[Decode]redirect output stream failed %{public}u", errorCode); return errorCode; } return SUCCESS; @@ -204,13 +209,13 @@ uint32_t GifDecoder::CreateGifFileTypeIfNotExist() if (gifPtr_ == nullptr) { int32_t errorCode = Media::ERROR; if (inputStreamPtr_ == nullptr) { - HiLog::Error(LABEL, "[CreateGifFileTypeIfNotExist]set source need firstly"); + IMAGE_LOGE("[CreateGifFileTypeIfNotExist]set source need firstly"); return ERR_IMAGE_GET_DATA_ABNORMAL; } // DGifOpen will create GifFileType pointer and set header and screen desc gifPtr_ = DGifOpen(inputStreamPtr_, InputStreamReader, &errorCode); if (gifPtr_ == nullptr) { - HiLog::Error(LABEL, "[CreateGifFileTypeIfNotExist]open image error, %{public}d", errorCode); + IMAGE_LOGE("[CreateGifFileTypeIfNotExist]open image error, %{public}d", errorCode); inputStreamPtr_->Seek(0); savedFrameIndex_ = -1; return ERR_IMAGE_SOURCE_DATA; @@ -224,20 +229,20 @@ int32_t GifDecoder::InputStreamReader(GifFileType *gif, GifByteType *bytes, int3 { uint32_t dataSize = 0; if (gif == nullptr) { - HiLog::Error(LABEL, "[InputStreamReader]GifFileType pointer is null"); + IMAGE_LOGE("[InputStreamReader]GifFileType pointer is null"); return dataSize; } InputDataStream *inputStream = static_cast(gif->UserData); if (inputStream == nullptr) { - HiLog::Error(LABEL, "[InputStreamReader]set source need firstly"); + IMAGE_LOGE("[InputStreamReader]set source need firstly"); return dataSize; } if (size <= 0) { - HiLog::Error(LABEL, "[InputStreamReader]callback size %{public}d is invalid", size); + IMAGE_LOGE("[InputStreamReader]callback size %{public}d is invalid", size); return dataSize; } if (bytes == nullptr) { - HiLog::Error(LABEL, "[InputStreamReader]callback buffer is null"); + IMAGE_LOGE("[InputStreamReader]callback buffer is null"); return dataSize; } inputStream->Read(size, bytes, size, dataSize); @@ -247,25 +252,25 @@ int32_t GifDecoder::InputStreamReader(GifFileType *gif, GifByteType *bytes, int3 uint32_t GifDecoder::CheckIndex(uint32_t index) { if (!inputStreamPtr_->IsStreamCompleted()) { - HiLog::Warn(LABEL, "[CheckIndex]don't enough data to decode the frame number"); + IMAGE_LOGW("[CheckIndex]don't enough data to decode the frame number"); return ERR_IMAGE_SOURCE_DATA_INCOMPLETE; } uint32_t errorCode = CreateGifFileTypeIfNotExist(); if (errorCode != SUCCESS) { - HiLog::Error(LABEL, "[CheckIndex]create GifFileType failed %{public}u", errorCode); + IMAGE_LOGE("[CheckIndex]create GifFileType failed %{public}u", errorCode); return errorCode; } int32_t updateFrameIndex = static_cast(index); if (!isLoadAllFrame_ && updateFrameIndex > savedFrameIndex_) { errorCode = UpdateGifFileType(updateFrameIndex); if (errorCode != SUCCESS) { - HiLog::Error(LABEL, "[CheckIndex]update saved frame to index %{public}u failed", index); + IMAGE_LOGE("[CheckIndex]update saved frame to index %{public}u failed", index); return errorCode; } } uint32_t frameNum = gifPtr_->ImageCount; if (index >= frameNum) { - HiLog::Error(LABEL, "[CheckIndex]index %{public}u out of frame range %{public}u", index, frameNum); + IMAGE_LOGE("[CheckIndex]index %{public}u out of frame range %{public}u", index, frameNum); return ERR_IMAGE_INVALID_PARAMETER; } return SUCCESS; @@ -276,35 +281,33 @@ uint32_t GifDecoder::OverlapFrame(uint32_t startIndex, uint32_t endIndex) for (uint32_t frameIndex = startIndex; frameIndex <= endIndex; frameIndex++) { const SavedImage *savedImage = gifPtr_->SavedImages + frameIndex; if (savedImage == nullptr) { - HiLog::Error(LABEL, "[OverlapFrame]image frame %{public}u data is invalid", frameIndex); + IMAGE_LOGE("[OverlapFrame]image frame %{public}u data is invalid", frameIndex); return ERR_IMAGE_DECODE_ABNORMAL; } // acquire the frame graphices control information int32_t transColor = NO_TRANSPARENT_COLOR; int32_t disposalMode = DISPOSAL_UNSPECIFIED; GetTransparentAndDisposal(frameIndex, transColor, disposalMode); - HiLog::Debug(LABEL, - "[OverlapFrame]frameIndex = %{public}u, transColor = %{public}d, " - "disposalMode = %{public}d", - frameIndex, transColor, disposalMode); + IMAGE_LOGD("[OverlapFrame]frameIndex = %{public}u, transColor = %{public}d, " + "disposalMode = %{public}d", frameIndex, transColor, disposalMode); if (frameIndex == 0 && AllocateLocalPixelMapBuffer() != SUCCESS) { - HiLog::Error(LABEL, "[OverlapFrame]first frame allocate local pixelmap buffer failed"); + IMAGE_LOGE("[OverlapFrame]first frame allocate local pixelmap buffer failed"); return ERR_IMAGE_DECODE_ABNORMAL; } if (localPixelMapBuffer_ == nullptr) { - HiLog::Error(LABEL, "[OverlapFrame]local pixelmap is null, next frame can't overlap"); + IMAGE_LOGE("[OverlapFrame]local pixelmap is null, next frame can't overlap"); return ERR_IMAGE_DECODE_ABNORMAL; } // current frame recover background if (frameIndex != 0 && disposalMode == DISPOSE_BACKGROUND && DisposeBackground(frameIndex, savedImage) != SUCCESS) { - HiLog::Error(LABEL, "[OverlapFrame]dispose frame %{public}d background failed", frameIndex); + IMAGE_LOGE("[OverlapFrame]dispose frame %{public}d background failed", frameIndex); return ERR_IMAGE_DECODE_ABNORMAL; } if (disposalMode != DISPOSE_PREVIOUS && PaddingData(savedImage, transColor) != SUCCESS) { - HiLog::Error(LABEL, "[OverlapFrame]dispose frame %{public}u data color failed", frameIndex); + IMAGE_LOGE("[OverlapFrame]dispose frame %{public}u data color failed", frameIndex); return ERR_IMAGE_DECODE_ABNORMAL; } } @@ -322,7 +325,7 @@ uint32_t GifDecoder::DisposeBackground(uint32_t frameIndex, const SavedImage *cu return SUCCESS; } if (PaddingBgColor(curSavedImage) != SUCCESS) { - HiLog::Error(LABEL, "[DisposeBackground]padding frame %{public}u background color failed", frameIndex); + IMAGE_LOGE("[DisposeBackground]padding frame %{public}u background color failed", frameIndex); return ERR_IMAGE_DECODE_ABNORMAL; } return SUCCESS; @@ -346,25 +349,25 @@ uint32_t GifDecoder::AllocateLocalPixelMapBuffer() uint64_t pixelMapBufferSize = static_cast(bgWidth * bgHeight * sizeof(uint32_t)); // create local pixelmap buffer, next frame depends on the previous if (pixelMapBufferSize > PIXEL_MAP_MAX_RAM_SIZE) { - HiLog::Error(LABEL, "[AllocateLocalPixelMapBuffer]pixelmap buffer size %{public}llu out of max size", - static_cast(pixelMapBufferSize)); + IMAGE_LOGE("[AllocateLocalPixelMapBuffer]pixelmap buffer size %{public}llu out of max size", + static_cast(pixelMapBufferSize)); return ERR_IMAGE_TOO_LARGE; } localPixelMapBuffer_ = reinterpret_cast(malloc(pixelMapBufferSize)); if (localPixelMapBuffer_ == nullptr) { - HiLog::Error(LABEL, "[AllocateLocalPixelMapBuffer]allocate local pixelmap buffer memory error"); + IMAGE_LOGE("[AllocateLocalPixelMapBuffer]allocate local pixelmap buffer memory error"); return ERR_IMAGE_MALLOC_ABNORMAL; } #ifdef _WIN32 errno_t backRet = memset_s(localPixelMapBuffer_, bgColor_, pixelMapBufferSize); if (backRet != EOK) { - HiLog::Error(LABEL, "[DisposeFirstPixelMap]memset local pixelmap buffer background failed", backRet); + IMAGE_LOGE("[DisposeFirstPixelMap]memset local pixelmap buffer background failed", backRet); FreeLocalPixelMapBuffer(); return ERR_IMAGE_MALLOC_ABNORMAL; } #else if (memset_s(localPixelMapBuffer_, pixelMapBufferSize, bgColor_, pixelMapBufferSize) != EOK) { - HiLog::Error(LABEL, "[DisposeFirstPixelMap]memset local pixelmap buffer background failed"); + IMAGE_LOGE("[DisposeFirstPixelMap]memset local pixelmap buffer background failed"); FreeLocalPixelMapBuffer(); return ERR_IMAGE_MALLOC_ABNORMAL; } @@ -396,10 +399,10 @@ uint32_t GifDecoder::PaddingBgColor(const SavedImage *savedImage) frameHeight = bgHeight - frameTop; } if (frameWidth < 0 || frameHeight < 0) { - HiLog::Error(LABEL, "[PaddingBgColor]frameWidth || frameHeight is abnormal," - "bgWidth:%{public}d, bgHeight:%{public}d, " - "frameTop:%{public}d, frameLeft:%{public}d", - bgWidth, bgHeight, frameTop, frameLeft); + IMAGE_LOGE("[PaddingBgColor]frameWidth || frameHeight is abnormal," + "bgWidth:%{public}d, bgHeight:%{public}d, " + "frameTop:%{public}d, frameLeft:%{public}d", + bgWidth, bgHeight, frameTop, frameLeft); return ERR_IMAGE_DECODE_ABNORMAL; } uint32_t *dstPixelMapBuffer = localPixelMapBuffer_ + frameTop * bgWidth + frameLeft; @@ -408,12 +411,12 @@ uint32_t GifDecoder::PaddingBgColor(const SavedImage *savedImage) #ifdef _WIN32 errno_t backRet = memset_s(dstPixelMapBuffer, bgColor_, lineBufferSize); if (backRet != EOK) { - HiLog::Error(LABEL, "[PaddingBgColor]memset local pixelmap buffer failed", backRet); + IMAGE_LOGE("[PaddingBgColor]memset local pixelmap buffer failed", backRet); return ERR_IMAGE_MALLOC_ABNORMAL; } #else if (memset_s(dstPixelMapBuffer, lineBufferSize, bgColor_, lineBufferSize) != EOK) { - HiLog::Error(LABEL, "[PaddingBgColor]memset local pixelmap buffer failed"); + IMAGE_LOGE("[PaddingBgColor]memset local pixelmap buffer failed"); return ERR_IMAGE_MALLOC_ABNORMAL; } #endif @@ -429,14 +432,14 @@ uint32_t GifDecoder::PaddingData(const SavedImage *savedImage, int32_t transpare colorMap = savedImage->ImageDesc.ColorMap; // local color map } if (colorMap == nullptr) { - HiLog::Error(LABEL, "[PaddingData]color map is null"); + IMAGE_LOGE("[PaddingData]color map is null"); return ERR_IMAGE_DECODE_ABNORMAL; } int32_t colorCount = colorMap->ColorCount; int32_t bitsPerPixel = colorMap->BitsPerPixel; if ((bitsPerPixel < 0) || (colorCount != (1 << static_cast(bitsPerPixel)))) { - HiLog::Error(LABEL, "[PaddingData]colormap is invalid, bitsPerPixel: %{public}d, colorCount: %{public}d", - bitsPerPixel, colorCount); + IMAGE_LOGE("[PaddingData]colormap is invalid, bitsPerPixel: %{public}d, colorCount: %{public}d", + bitsPerPixel, colorCount); return ERR_IMAGE_DECODE_ABNORMAL; } @@ -496,7 +499,7 @@ void GifDecoder::ParseBgColor() { const int32_t bgColorIndex = gifPtr_->SBackGroundColor; if (bgColorIndex < 0) { - HiLog::Warn(LABEL, "[ParseBgColor]bgColor index %{public}d is invalid, use default bgColor", bgColorIndex); + IMAGE_LOGW("[ParseBgColor]bgColor index %{public}d is invalid, use default bgColor", bgColorIndex); return; } const ColorMapObject *bgColorMap = gifPtr_->SColorMap; @@ -510,18 +513,18 @@ constexpr size_t SIZE_ZERO = 0; static uint32_t HeapMemoryCreate(PlImageBuffer &plBuffer) { - HiLog::Debug(LABEL, "HeapMemoryCreate IN"); + IMAGE_LOGD("HeapMemoryCreate IN"); if (plBuffer.buffer != nullptr) { - HiLog::Debug(LABEL, "HeapMemoryCreate has created"); + IMAGE_LOGD("HeapMemoryCreate has created"); return SUCCESS; } if (plBuffer.bufferSize == 0 || plBuffer.bufferSize > PIXEL_MAP_MAX_RAM_SIZE) { - HiLog::Error(LABEL, "HeapMemoryCreate Invalid value of bufferSize"); + IMAGE_LOGE("HeapMemoryCreate Invalid value of bufferSize"); return ERR_IMAGE_DATA_ABNORMAL; } auto dataPtr = static_cast(malloc(plBuffer.bufferSize)); if (dataPtr == nullptr) { - HiLog::Error(LABEL, "alloc buffer error"); + IMAGE_LOGE("alloc buffer error"); return ERR_IMAGE_MALLOC_ABNORMAL; } plBuffer.buffer = dataPtr; @@ -531,9 +534,9 @@ static uint32_t HeapMemoryCreate(PlImageBuffer &plBuffer) static uint32_t HeapMemoryRelease(PlImageBuffer &plBuffer) { - HiLog::Debug(LABEL, "HeapMemoryRelease IN"); + IMAGE_LOGD("HeapMemoryRelease IN"); if (plBuffer.buffer == nullptr) { - HiLog::Error(LABEL, "HeapMemory::Release nullptr data"); + IMAGE_LOGE("HeapMemory::Release nullptr data"); return ERR_IMAGE_DATA_ABNORMAL; } free(plBuffer.buffer); @@ -544,7 +547,7 @@ static uint32_t HeapMemoryRelease(PlImageBuffer &plBuffer) static uint32_t DmaMemoryCreate(PlImageBuffer &plBuffer, GifFileType *gifPtr) { #if defined(_WIN32) || defined(_APPLE) || defined(A_PLATFORM) || defined(IOS_PLATFORM) - HiLog::Error(LABEL, "Unsupport dma mem alloc"); + IMAGE_LOGE("Unsupport dma mem alloc"); return ERR_IMAGE_DATA_UNSUPPORT; #else sptr sb = SurfaceBuffer::Create(); @@ -560,13 +563,13 @@ static uint32_t DmaMemoryCreate(PlImageBuffer &plBuffer, GifFileType *gifPtr) }; GSError ret = sb->Alloc(requestConfig); if (ret != GSERROR_OK) { - HiLog::Error(LABEL, "SurfaceBuffer Alloc failed, %{public}s", GSErrorStr(ret).c_str()); + IMAGE_LOGE("SurfaceBuffer Alloc failed, %{public}s", GSErrorStr(ret).c_str()); return ERR_DMA_NOT_EXIST; } void* nativeBuffer = sb.GetRefPtr(); int32_t err = ImageUtils::SurfaceBuffer_Reference(nativeBuffer); if (err != OHOS::GSERROR_OK) { - HiLog::Error(LABEL, "NativeBufferReference failed"); + IMAGE_LOGE("NativeBufferReference failed"); return ERR_DMA_DATA_ABNORMAL; } plBuffer.buffer = static_cast(sb->GetVirAddr()); @@ -579,13 +582,13 @@ static uint32_t DmaMemoryCreate(PlImageBuffer &plBuffer, GifFileType *gifPtr) static uint32_t DmaMemoryRelease(PlImageBuffer &plBuffer) { #if defined(_WIN32) || defined(_APPLE) || defined(A_PLATFORM) || defined(IOS_PLATFORM) - HiLog::Error(LABEL, "Unsupport dma mem release"); + IMAGE_LOGE("Unsupport dma mem release"); return ERR_IMAGE_DATA_UNSUPPORT; #else if (plBuffer.context != nullptr) { int32_t err = ImageUtils::SurfaceBuffer_Unreference(static_cast(plBuffer.context)); if (err != OHOS::GSERROR_OK) { - HiLog::Error(LABEL, "NativeBufferUnReference failed"); + IMAGE_LOGE("NativeBufferUnReference failed"); return ERR_DMA_DATA_ABNORMAL; } plBuffer.buffer = nullptr; @@ -608,24 +611,24 @@ static inline void ReleaseSharedMemory(int* fdPtr, uint8_t* ptr = nullptr, size_ static uint32_t SharedMemoryCreate(PlImageBuffer &plBuffer) { - HiLog::Debug(LABEL, "SharedMemoryCreate IN data size %{public}u", plBuffer.bufferSize); + IMAGE_LOGD("SharedMemoryCreate IN data size %{public}u", plBuffer.bufferSize); if (plBuffer.bufferSize == SIZE_ZERO) { return ERR_IMAGE_DATA_ABNORMAL; } auto fdPtr = std::make_unique(); *fdPtr = AshmemCreate("GIF RawData", plBuffer.bufferSize); if (*fdPtr < 0) { - HiLog::Error(LABEL, "SharedMemoryCreate AshmemCreate fd:[%{public}d].", *fdPtr); + IMAGE_LOGE("SharedMemoryCreate AshmemCreate fd:[%{public}d].", *fdPtr); return ERR_IMAGE_DATA_ABNORMAL; } if (AshmemSetProt(*fdPtr, PROT_READ | PROT_WRITE) < 0) { - HiLog::Error(LABEL, "SharedMemoryCreate AshmemSetProt errno %{public}d.", errno); + IMAGE_LOGE("SharedMemoryCreate AshmemSetProt errno %{public}d.", errno); ReleaseSharedMemory(fdPtr.get()); return ERR_IMAGE_DATA_ABNORMAL; } plBuffer.buffer = ::mmap(nullptr, plBuffer.bufferSize, PROT_READ | PROT_WRITE, MAP_SHARED, *fdPtr, 0); if (plBuffer.buffer == MAP_FAILED) { - HiLog::Error(LABEL, "SharedMemoryCreate mmap failed, errno:%{public}d", errno); + IMAGE_LOGE("SharedMemoryCreate mmap failed, errno:%{public}d", errno); ReleaseSharedMemory(fdPtr.get(), static_cast(plBuffer.buffer), plBuffer.bufferSize); return ERR_IMAGE_DATA_ABNORMAL; } @@ -636,7 +639,7 @@ static uint32_t SharedMemoryCreate(PlImageBuffer &plBuffer) static uint32_t SharedMemoryRelease(PlImageBuffer &plBuffer) { - HiLog::Debug(LABEL, "SharedMemoryRelease IN"); + IMAGE_LOGD("SharedMemoryRelease IN"); std::unique_ptr fdPtr = std::unique_ptr(static_cast(plBuffer.context)); ReleaseSharedMemory(fdPtr.get(), static_cast(plBuffer.buffer), plBuffer.bufferSize); plBuffer.buffer = nullptr; @@ -659,7 +662,7 @@ static uint32_t SharedMemoryRelease(PlImageBuffer &plBuffer) static uint32_t AllocMemory(DecodeContext &context, GifFileType *gifPtr) { if (context.pixelsBuffer.buffer != nullptr) { - HiLog::Debug(LABEL, "AllocMemory has created"); + IMAGE_LOGD("AllocMemory has created"); return SUCCESS; } @@ -677,7 +680,7 @@ static uint32_t AllocMemory(DecodeContext &context, GifFileType *gifPtr) static uint32_t FreeMemory(DecodeContext &context) { if (context.pixelsBuffer.buffer == nullptr) { - HiLog::Debug(LABEL, "FreeMemory has freed"); + IMAGE_LOGD("FreeMemory has freed"); return SUCCESS; } @@ -694,7 +697,7 @@ static uint32_t FreeMemory(DecodeContext &context) uint32_t GifDecoder::RedirectOutputBuffer(DecodeContext &context) { if (localPixelMapBuffer_ == nullptr) { - HiLog::Error(LABEL, "[RedirectOutputBuffer]local pixelmap buffer is null, redirect failed"); + IMAGE_LOGE("[RedirectOutputBuffer]local pixelmap buffer is null, redirect failed"); return ERR_IMAGE_DECODE_ABNORMAL; } int32_t bgWidth = gifPtr_->SWidth; @@ -710,7 +713,7 @@ uint32_t GifDecoder::RedirectOutputBuffer(DecodeContext &context) } if (memcpy_s(context.pixelsBuffer.buffer, context.pixelsBuffer.bufferSize, localPixelMapBuffer_, imageBufferSize) != 0) { - HiLog::Error(LABEL, "[RedirectOutputBuffer]memory copy size %{public}llu failed", + IMAGE_LOGE("[RedirectOutputBuffer]memory copy size %{public}llu failed", static_cast(imageBufferSize)); FreeMemory(context); return ERR_IMAGE_DECODE_ABNORMAL; @@ -722,7 +725,7 @@ uint32_t GifDecoder::GetImageDelayTime(uint32_t index, int32_t &value) { uint32_t errorCode = CheckIndex(index); if (errorCode != SUCCESS) { - HiLog::Error(LABEL, "[GetImageDelayTime]index %{public}u is invalid", index); + IMAGE_LOGE("[GetImageDelayTime]index %{public}u is invalid", index); return errorCode; } @@ -754,10 +757,10 @@ uint32_t GifDecoder::GetImageLoopCount(uint32_t index, int32_t &value) uint32_t GifDecoder::GetImagePropertyInt(uint32_t index, const std::string &key, int32_t &value) { - HiLog::Debug(LABEL, "[GetImagePropertyInt] enter gif plugin, key:%{public}s", key.c_str()); + IMAGE_LOGD("[GetImagePropertyInt] enter gif plugin, key:%{public}s", key.c_str()); uint32_t errorCode = CheckIndex(0); if (errorCode != SUCCESS) { - HiLog::Error(LABEL, "[GetImagePropertyInt]index %{public}u is invalid", index); + IMAGE_LOGE("[GetImagePropertyInt]index %{public}u is invalid", index); return errorCode; } @@ -766,7 +769,7 @@ uint32_t GifDecoder::GetImagePropertyInt(uint32_t index, const std::string &key, } else if (key == GIF_IMAGE_LOOP_COUNT) { errorCode = GetImageLoopCount(0, value); } else { - HiLog::Error(LABEL, "[GetImagePropertyInt]key(%{public}s) not supported", key.c_str()); + IMAGE_LOGE("[GetImagePropertyInt]key(%{public}s) not supported", key.c_str()); return ERR_IMAGE_INVALID_PARAMETER; } @@ -775,7 +778,7 @@ uint32_t GifDecoder::GetImagePropertyInt(uint32_t index, const std::string &key, uint32_t GifDecoder::GetImagePropertyString(uint32_t index, const std::string &key, std::string &value) { - HiLog::Debug(LABEL, "[GetImagePropertyString] enter, index:%{public}u, key:%{public}s", index, key.c_str()); + IMAGE_LOGD("[GetImagePropertyString] enter, index:%{public}u, key:%{public}s", index, key.c_str()); if (key != GIF_IMAGE_DELAY_TIME) { return AbsImageDecoder::GetImagePropertyString(index, key, value); @@ -784,14 +787,14 @@ uint32_t GifDecoder::GetImagePropertyString(uint32_t index, const std::string &k int32_t intValue = 0; uint32_t errorCode = GetImagePropertyInt(index, key, intValue); if (errorCode != SUCCESS) { - HiLog::Error(LABEL, "[GetImagePropertyString] errorCode:%{public}u," + IMAGE_LOGE("[GetImagePropertyString] errorCode:%{public}u," " index:%{public}u, key:%{public}s", errorCode, index, key.c_str()); return errorCode; } value = std::to_string(intValue); - HiLog::Debug(LABEL, "[GetImagePropertyString] leave, index:%{public}u, key:%{public}s, value:%{public}s", + IMAGE_LOGD("[GetImagePropertyString] leave, index:%{public}u, key:%{public}s, value:%{public}s", index, key.c_str(), value.c_str()); return SUCCESS; } @@ -799,7 +802,7 @@ uint32_t GifDecoder::GetImagePropertyString(uint32_t index, const std::string &k uint32_t GifDecoder::ParseFrameDetail() { if (DGifGetImageDesc(gifPtr_) == GIF_ERROR) { - HiLog::Error(LABEL, "[ParseFrameDetail]parse frame desc to gif pointer failed %{public}d", gifPtr_->Error); + IMAGE_LOGE("[ParseFrameDetail]parse frame desc to gif pointer failed %{public}d", gifPtr_->Error); return ERR_IMAGE_DECODE_ABNORMAL; } // DGifGetImageDesc use malloc or reallocarray allocate savedImages memory and increase imageCount. @@ -811,8 +814,8 @@ uint32_t GifDecoder::ParseFrameDetail() int32_t imageHeight = saveImagePtr->ImageDesc.Height; uint64_t imageSize = static_cast(imageWidth * imageHeight); if (imageWidth <= 0 || imageHeight <= 0 || imageSize > SIZE_MAX) { - HiLog::Error(LABEL, "[ParseFrameDetail]check frame size[%{public}d, %{public}d] failed", imageWidth, - imageHeight); + IMAGE_LOGE("[ParseFrameDetail]check frame size[%{public}d, %{public}d] failed", imageWidth, + imageHeight); // if error, imageCount go back and next time DGifGetImageDesc will retry. gifPtr_->ImageCount--; return ERR_IMAGE_DECODE_ABNORMAL; @@ -826,7 +829,7 @@ uint32_t GifDecoder::ParseFrameDetail() } // set savedImage rasterBits if (SetSavedImageRasterBits(saveImagePtr, frameIndex, imageSize, imageWidth, imageHeight) != SUCCESS) { - HiLog::Error(LABEL, "[ParseFrameDetail] set saved image data failed"); + IMAGE_LOGE("[ParseFrameDetail] set saved image data failed"); GifFreeExtensions(&saveImagePtr->ExtensionBlockCount, &saveImagePtr->ExtensionBlocks); return ERR_IMAGE_DECODE_ABNORMAL; } @@ -838,12 +841,12 @@ uint32_t GifDecoder::SetSavedImageRasterBits(SavedImage *saveImagePtr, int32_t f { if (saveImagePtr->RasterBits == nullptr) { if (imageSize == 0 || imageSize > PIXEL_MAP_MAX_RAM_SIZE) { - HiLog::Error(LABEL, "[SetSavedImageData]malloc frame %{public}d failed for invalid imagesize", frameIndex); + IMAGE_LOGE("[SetSavedImageData]malloc frame %{public}d failed for invalid imagesize", frameIndex); return ERR_IMAGE_MALLOC_ABNORMAL; } saveImagePtr->RasterBits = static_cast(malloc(imageSize * sizeof(GifPixelType))); if (saveImagePtr->RasterBits == nullptr) { - HiLog::Error(LABEL, "[SetSavedImageData]malloc frame %{public}d rasterBits failed", frameIndex); + IMAGE_LOGE("[SetSavedImageData]malloc frame %{public}d rasterBits failed", frameIndex); return ERR_IMAGE_MALLOC_ABNORMAL; } } @@ -852,16 +855,16 @@ uint32_t GifDecoder::SetSavedImageRasterBits(SavedImage *saveImagePtr, int32_t f for (int32_t i = 0; i < INTERLACED_PASSES; i++) { for (int32_t j = INTERLACED_OFFSET[i]; j < imageHeight; j += INTERLACED_INTERVAL[i]) { if (DGifGetLine(gifPtr_, saveImagePtr->RasterBits + j * imageWidth, imageWidth) == GIF_ERROR) { - HiLog::Error(LABEL, "[SetSavedImageData]interlace set frame %{public}d bits failed %{public}d", - frameIndex, gifPtr_->Error); + IMAGE_LOGE("[SetSavedImageData]interlace set frame %{public}d bits failed %{public}d", + frameIndex, gifPtr_->Error); return ERR_IMAGE_DECODE_ABNORMAL; } } } } else { if (DGifGetLine(gifPtr_, saveImagePtr->RasterBits, imageSize) == GIF_ERROR) { - HiLog::Error(LABEL, "[SetSavedImageData]normal set frame %{public}d bits failed %{public}d", frameIndex, - gifPtr_->Error); + IMAGE_LOGE("[SetSavedImageData]normal set frame %{public}d bits failed %{public}d", frameIndex, + gifPtr_->Error); return ERR_IMAGE_DECODE_ABNORMAL; } } @@ -873,25 +876,25 @@ uint32_t GifDecoder::ParseFrameExtension() GifByteType *extData = nullptr; int32_t extFunc = 0; if (DGifGetExtension(gifPtr_, &extFunc, &extData) == GIF_ERROR) { - HiLog::Error(LABEL, "[ParseFrameExtension]get extension failed %{public}d", gifPtr_->Error); + IMAGE_LOGE("[ParseFrameExtension]get extension failed %{public}d", gifPtr_->Error); return ERR_IMAGE_DECODE_ABNORMAL; } if (extData == nullptr) { return SUCCESS; } - HiLog::Debug(LABEL, "[ParseFrameExtension] get extension:0x%{public}x", extFunc); + IMAGE_LOGD("[ParseFrameExtension] get extension:0x%{public}x", extFunc); if (GifAddExtensionBlock(&gifPtr_->ExtensionBlockCount, &gifPtr_->ExtensionBlocks, extFunc, extData[EXTENSION_LEN_INDEX], &extData[EXTENSION_DATA_INDEX]) == GIF_ERROR) { - HiLog::Error(LABEL, "[ParseFrameExtension]set extension to gif pointer failed"); + IMAGE_LOGE("[ParseFrameExtension]set extension to gif pointer failed"); // GifAddExtensionBlock will allocate memory, if error, free extension ready to retry GifFreeExtensions(&gifPtr_->ExtensionBlockCount, &gifPtr_->ExtensionBlocks); return ERR_IMAGE_DECODE_ABNORMAL; } while (true) { if (DGifGetExtensionNext(gifPtr_, &extData) == GIF_ERROR) { - HiLog::Error(LABEL, "[ParseFrameExtension]get next extension failed %{public}d", gifPtr_->Error); + IMAGE_LOGE("[ParseFrameExtension]get next extension failed %{public}d", gifPtr_->Error); return ERR_IMAGE_DECODE_ABNORMAL; } if (extData == nullptr) { @@ -900,7 +903,7 @@ uint32_t GifDecoder::ParseFrameExtension() if (GifAddExtensionBlock(&gifPtr_->ExtensionBlockCount, &gifPtr_->ExtensionBlocks, CONTINUE_EXT_FUNC_CODE, extData[EXTENSION_LEN_INDEX], &extData[EXTENSION_DATA_INDEX]) == GIF_ERROR) { - HiLog::Error(LABEL, "[ParseFrameExtension]set next extension to gif pointer failed"); + IMAGE_LOGE("[ParseFrameExtension]set next extension to gif pointer failed"); GifFreeExtensions(&gifPtr_->ExtensionBlockCount, &gifPtr_->ExtensionBlocks); return ERR_IMAGE_DECODE_ABNORMAL; } @@ -910,14 +913,14 @@ uint32_t GifDecoder::ParseFrameExtension() uint32_t GifDecoder::UpdateGifFileType(int32_t updateFrameIndex) { - HiLog::Debug(LABEL, "[UpdateGifFileType]update %{public}d to %{public}d", savedFrameIndex_, updateFrameIndex); + IMAGE_LOGD("[UpdateGifFileType]update %{public}d to %{public}d", savedFrameIndex_, updateFrameIndex); uint32_t startPosition = inputStreamPtr_->Tell(); GifRecordType recordType; gifPtr_->ExtensionBlocks = nullptr; gifPtr_->ExtensionBlockCount = 0; do { if (DGifGetRecordType(gifPtr_, &recordType) == GIF_ERROR) { - HiLog::Error(LABEL, "[UpdateGifFileType]parse file record type failed %{public}d", gifPtr_->Error); + IMAGE_LOGE("[UpdateGifFileType]parse file record type failed %{public}d", gifPtr_->Error); inputStreamPtr_->Seek(startPosition); return ERR_IMAGE_DECODE_ABNORMAL; } @@ -925,14 +928,14 @@ uint32_t GifDecoder::UpdateGifFileType(int32_t updateFrameIndex) switch (recordType) { case EXTENSION_RECORD_TYPE: if (ParseFrameExtension() != SUCCESS) { - HiLog::Error(LABEL, "[UpdateGifFileType]parse frame extension failed"); + IMAGE_LOGE("[UpdateGifFileType]parse frame extension failed"); inputStreamPtr_->Seek(startPosition); return ERR_IMAGE_DECODE_ABNORMAL; } break; case IMAGE_DESC_RECORD_TYPE: if (ParseFrameDetail() != SUCCESS) { - HiLog::Error(LABEL, "[UpdateGifFileType]parse frame detail failed"); + IMAGE_LOGE("[UpdateGifFileType]parse frame detail failed"); inputStreamPtr_->Seek(startPosition); return ERR_IMAGE_DECODE_ABNORMAL; } @@ -940,7 +943,7 @@ uint32_t GifDecoder::UpdateGifFileType(int32_t updateFrameIndex) startPosition = inputStreamPtr_->Tell(); break; case TERMINATE_RECORD_TYPE: - HiLog::Debug(LABEL, "[UpdateGifFileType]parse gif completed"); + IMAGE_LOGD("[UpdateGifFileType]parse gif completed"); isLoadAllFrame_ = true; break; default: @@ -954,7 +957,7 @@ uint32_t GifDecoder::UpdateGifFileType(int32_t updateFrameIndex) if (gifPtr_->ImageCount <= 0) { gifPtr_->Error = D_GIF_ERR_NO_IMAG_DSCR; - HiLog::Error(LABEL, "[UpdateGifFileType]has no frame in gif block"); + IMAGE_LOGE("[UpdateGifFileType]has no frame in gif block"); return ERR_IMAGE_DECODE_ABNORMAL; } return SUCCESS; diff --git a/plugins/common/libs/image/libgifplugin/src/plugin_export.cpp b/plugins/common/libs/image/libgifplugin/src/plugin_export.cpp index 1c77527f7..c4e7156d2 100644 --- a/plugins/common/libs/image/libgifplugin/src/plugin_export.cpp +++ b/plugins/common/libs/image/libgifplugin/src/plugin_export.cpp @@ -15,16 +15,20 @@ #include "plugin_export.h" #include "gif_decoder.h" -#include "hilog/log_c.h" -#include "hilog/log_cpp.h" +#include "image_log.h" #include "iosfwd" -#include "log_tags.h" #include "map" #include "plugin_class_base.h" #include "plugin_utils.h" #include "string" #include "utility" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "LibGifPlugin" + // plugin package name same as metadata. namespace { const std::string PACKAGE_NAME = ("LibGifPlugin"); @@ -36,31 +40,25 @@ PLUGIN_EXPORT_REGISTER_CLASS(OHOS::ImagePlugin::GifDecoder) PLUGIN_EXPORT_REGISTER_CLASS_END using std::string; -using namespace OHOS::HiviewDFX; - -static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "LibGifPlugin" }; - -#define PLUGIN_LOG_D(...) HiLog::Debug(LABEL, __VA_ARGS__) -#define PLUGIN_LOG_E(...) HiLog::Error(LABEL, __VA_ARGS__) // define the external interface of this plugin. PLUGIN_EXPORT_DEFAULT_EXTERNAL_START() PLUGIN_EXPORT_DEFAULT_EXTERNAL_STOP() OHOS::MultimediaPlugin::PluginClassBase *PluginExternalCreate(const string &className) { - HiLog::Debug(LABEL, "PluginExternalCreate: create object for package: %{public}s, class: %{public}s.", + IMAGE_LOGD("PluginExternalCreate: create object for package: %{public}s, class: %{public}s.", PACKAGE_NAME.c_str(), className.c_str()); auto iter = implClassMap.find(className); if (iter == implClassMap.end()) { - HiLog::Error(LABEL, "PluginExternalCreate: failed to find class: %{public}s, in package: %{public}s.", + IMAGE_LOGE("PluginExternalCreate: failed to find class: %{public}s, in package: %{public}s.", className.c_str(), PACKAGE_NAME.c_str()); return nullptr; } auto creator = iter->second; if (creator == nullptr) { - HiLog::Error(LABEL, "PluginExternalCreate: null creator for class: %{public}s, in package: %{public}s.", + IMAGE_LOGE("PluginExternalCreate: null creator for class: %{public}s, in package: %{public}s.", className.c_str(), PACKAGE_NAME.c_str()); return nullptr; } diff --git a/plugins/common/libs/image/libheifplugin/include/heif_decoder.h b/plugins/common/libs/image/libheifplugin/include/heif_decoder.h index a1ce7912a..a092f327e 100644 --- a/plugins/common/libs/image/libheifplugin/include/heif_decoder.h +++ b/plugins/common/libs/image/libheifplugin/include/heif_decoder.h @@ -19,8 +19,6 @@ #include #include "abs_image_decoder.h" #include "heif_decoder_wrapper.h" -#include "hilog/log.h" -#include "log_tags.h" #include "nocopyable.h" #include "plugin_class_base.h" diff --git a/plugins/common/libs/image/libheifplugin/src/heif_decoder.cpp b/plugins/common/libs/image/libheifplugin/src/heif_decoder.cpp index 2421f7cba..9ebe99c4b 100644 --- a/plugins/common/libs/image/libheifplugin/src/heif_decoder.cpp +++ b/plugins/common/libs/image/libheifplugin/src/heif_decoder.cpp @@ -14,16 +14,22 @@ */ #include "heif_decoder.h" + +#include "image_log.h" #include "media_errors.h" #include "securec.h" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "HeifDecoder" + namespace OHOS { namespace ImagePlugin { -using namespace OHOS::HiviewDFX; using namespace MultimediaPlugin; using namespace Media; -constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "HeifDecoder" }; constexpr uint32_t HEIF_IMAGE_NUM = 1; void HeifDecoder::SetSource(InputDataStream &sourceStream) @@ -43,7 +49,7 @@ uint32_t HeifDecoder::SetDecodeOptions(uint32_t index, const PixelDecodeOptions { uint32_t ret = GetImageSize(index, info.size); if (ret != SUCCESS) { - HiLog::Error(LABEL, "get image size failed, ret=%{public}u", ret); + IMAGE_LOGE("get image size failed, ret=%{public}u", ret); return ret; } heifSize_ = info.size; @@ -70,17 +76,17 @@ uint32_t HeifDecoder::SetDecodeOptions(uint32_t index, const PixelDecodeOptions uint32_t HeifDecoder::Decode(uint32_t index, DecodeContext &context) { if (heifDecoderInterface_ == nullptr) { - HiLog::Error(LABEL, "create heif interface object failed!"); + IMAGE_LOGE("create heif interface object failed!"); return ERR_IMAGE_INIT_ABNORMAL; } if (index >= HEIF_IMAGE_NUM) { - HiLog::Error(LABEL, "decode image out of range, index:%{public}u, range:%{public}d.", index, HEIF_IMAGE_NUM); + IMAGE_LOGE("decode image out of range, index:%{public}u, range:%{public}d.", index, HEIF_IMAGE_NUM); return ERR_IMAGE_INVALID_PARAMETER; } if (!AllocHeapBuffer(context)) { - HiLog::Error(LABEL, "get pixels memory fail."); + IMAGE_LOGE("get pixels memory fail."); return ERR_IMAGE_MALLOC_ABNORMAL; } return heifDecoderInterface_->OnGetPixels(heifSize_, heifSize_.width * bytesPerPixel_, context); @@ -89,19 +95,19 @@ uint32_t HeifDecoder::Decode(uint32_t index, DecodeContext &context) uint32_t HeifDecoder::GetImageSize(uint32_t index, PlSize &size) { if (index >= HEIF_IMAGE_NUM) { - HiLog::Error(LABEL, "decode image out of range, index:%{public}u, range:%{public}d.", index, HEIF_IMAGE_NUM); + IMAGE_LOGE("decode image out of range, index:%{public}u, range:%{public}d.", index, HEIF_IMAGE_NUM); return ERR_IMAGE_INVALID_PARAMETER; } if (heifDecoderInterface_ == nullptr) { - HiLog::Error(LABEL, "create heif interface object failed!"); + IMAGE_LOGE("create heif interface object failed!"); return ERR_IMAGE_INIT_ABNORMAL; } heifDecoderInterface_->GetHeifSize(size); if (size.width == 0 || size.height == 0) { - HiLog::Error(LABEL, "get width and height fail, height:%{public}u, width:%{public}u.", size.height, - size.height); + IMAGE_LOGE("get width and height fail, height:%{public}u, width:%{public}u.", size.height, + size.height); return ERR_IMAGE_GET_DATA_ABNORMAL; } return SUCCESS; @@ -123,7 +129,7 @@ bool HeifDecoder::AllocHeapBuffer(DecodeContext &context) { if (context.pixelsBuffer.buffer == nullptr) { if (!IsHeifImageParaValid(heifSize_, bytesPerPixel_)) { - HiLog::Error(LABEL, "check heif image para fail"); + IMAGE_LOGE("check heif image para fail"); return false; } uint64_t byteCount = static_cast(heifSize_.width) * heifSize_.height * bytesPerPixel_; @@ -132,12 +138,12 @@ bool HeifDecoder::AllocHeapBuffer(DecodeContext &context) } else { void *outputBuffer = malloc(byteCount); if (outputBuffer == nullptr) { - HiLog::Error(LABEL, "alloc output buffer size:[%{public}llu] error.", - static_cast(byteCount)); + IMAGE_LOGE("alloc output buffer size:[%{public}llu] error.", + static_cast(byteCount)); return false; } if (memset_s(outputBuffer, byteCount, 0, byteCount) != EOK) { - HiLog::Error(LABEL, "memset buffer failed."); + IMAGE_LOGE("memset buffer failed."); free(outputBuffer); outputBuffer = nullptr; return false; @@ -173,7 +179,7 @@ bool HeifDecoder::AllocShareMem(DecodeContext &context, uint64_t byteCount) context.pixelsBuffer.buffer = ptr; void *fdBuffer = new int32_t(); if (fdBuffer == nullptr) { - HiLog::Error(LABEL, "new fdBuffer fail"); + IMAGE_LOGE("new fdBuffer fail"); ::munmap(ptr, byteCount); ::close(fd); context.pixelsBuffer.buffer = nullptr; @@ -190,21 +196,21 @@ bool HeifDecoder::AllocShareMem(DecodeContext &context, uint64_t byteCount) bool HeifDecoder::IsHeifImageParaValid(PlSize heifSize, uint32_t bytesPerPixel) { if (heifSize.width == 0 || heifSize.height == 0 || bytesPerPixel == 0) { - HiLog::Error(LABEL, "heif image para is 0"); + IMAGE_LOGE("heif image para is 0"); return false; } uint64_t area = static_cast(heifSize.width) * heifSize.height; if ((area / heifSize.width) != heifSize.height) { - HiLog::Error(LABEL, "compute width*height overflow!"); + IMAGE_LOGE("compute width*height overflow!"); return false; } uint64_t size = area * bytesPerPixel; if ((size / bytesPerPixel) != area) { - HiLog::Error(LABEL, "compute area*bytesPerPixel overflow!"); + IMAGE_LOGE("compute area*bytesPerPixel overflow!"); return false; } if (size > UINT32_MAX) { - HiLog::Error(LABEL, "size is too large!"); + IMAGE_LOGE("size is too large!"); return false; } return true; diff --git a/plugins/common/libs/image/libheifplugin/src/plugin_export.cpp b/plugins/common/libs/image/libheifplugin/src/plugin_export.cpp index b18be40a5..8c8978a32 100644 --- a/plugins/common/libs/image/libheifplugin/src/plugin_export.cpp +++ b/plugins/common/libs/image/libheifplugin/src/plugin_export.cpp @@ -15,10 +15,15 @@ #include "plugin_export.h" #include "heif_decoder.h" -#include "hilog/log.h" -#include "log_tags.h" +#include "image_log.h" #include "plugin_utils.h" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "LibHeifPlugin" + // plugin package name same as metadata. namespace { const std::string PACKAGE_NAME = ("LibHeifPlugin"); @@ -30,31 +35,25 @@ PLUGIN_EXPORT_REGISTER_CLASS(OHOS::ImagePlugin::HeifDecoder) PLUGIN_EXPORT_REGISTER_CLASS_END using std::string; -using namespace OHOS::HiviewDFX; - -static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "LibHeifPlugin" }; - -#define PLUGIN_LOG_D(...) HiLog::Debug(LABEL, __VA_ARGS__) -#define PLUGIN_LOG_E(...) HiLog::Error(LABEL, __VA_ARGS__) // define the external interface of this plugin. PLUGIN_EXPORT_DEFAULT_EXTERNAL_START() PLUGIN_EXPORT_DEFAULT_EXTERNAL_STOP() OHOS::MultimediaPlugin::PluginClassBase *PluginExternalCreate(const string &className) { - HiLog::Debug(LABEL, "PluginExternalCreate: create object for package: %{public}s, class: %{public}s.", + IMAGE_LOGD("PluginExternalCreate: create object for package: %{public}s, class: %{public}s.", PACKAGE_NAME.c_str(), className.c_str()); auto iter = implClassMap.find(className); if (iter == implClassMap.end()) { - HiLog::Error(LABEL, "PluginExternalCreate: failed to find class: %{public}s, in package: %{public}s.", + IMAGE_LOGE("PluginExternalCreate: failed to find class: %{public}s, in package: %{public}s.", className.c_str(), PACKAGE_NAME.c_str()); return nullptr; } auto creator = iter->second; if (creator == nullptr) { - HiLog::Error(LABEL, "PluginExternalCreate: null creator for class: %{public}s, in package: %{public}s.", + IMAGE_LOGE("PluginExternalCreate: null creator for class: %{public}s, in package: %{public}s.", className.c_str(), PACKAGE_NAME.c_str()); return nullptr; } diff --git a/plugins/common/libs/image/libjpegplugin/include/icc_profile_info.h b/plugins/common/libs/image/libjpegplugin/include/icc_profile_info.h index 18e36839d..ba6b5c414 100644 --- a/plugins/common/libs/image/libjpegplugin/include/icc_profile_info.h +++ b/plugins/common/libs/image/libjpegplugin/include/icc_profile_info.h @@ -20,7 +20,6 @@ #ifdef IMAGE_COLORSPACE_FLAG #include "color_space.h" #endif -#include "hilog/log.h" #include "image_plugin_type.h" #include "include/core/SkData.h" #include "include/core/SkColorSpace.h" @@ -28,7 +27,6 @@ #include "include/third_party/skcms/skcms.h" #include "jpeg_utils.h" #include "jpeglib.h" -#include "log_tags.h" #include "media_errors.h" #include "src/images/SkImageEncoderFns.h" namespace OHOS { diff --git a/plugins/common/libs/image/libjpegplugin/include/jpeg_decoder.h b/plugins/common/libs/image/libjpegplugin/include/jpeg_decoder.h index 728867426..38f7a6ee0 100644 --- a/plugins/common/libs/image/libjpegplugin/include/jpeg_decoder.h +++ b/plugins/common/libs/image/libjpegplugin/include/jpeg_decoder.h @@ -23,11 +23,9 @@ #ifdef IMAGE_COLORSPACE_FLAG #include "color_space.h" #endif -#include "hilog/log.h" #include "icc_profile_info.h" #include "jpeg_utils.h" #include "jpeglib.h" -#include "log_tags.h" #include "plugin_class_base.h" #include "plugin_server.h" #include "exif_info.h" diff --git a/plugins/common/libs/image/libjpegplugin/src/exif_info.cpp b/plugins/common/libs/image/libjpegplugin/src/exif_info.cpp index 42c503717..139ddd67e 100644 --- a/plugins/common/libs/image/libjpegplugin/src/exif_info.cpp +++ b/plugins/common/libs/image/libjpegplugin/src/exif_info.cpp @@ -21,17 +21,20 @@ #include #include "exif_maker_note.h" -#include "hilog/log.h" -#include "log_tags.h" +#include "image_log.h" #include "media_errors.h" #include "securec.h" #include "string_ex.h" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "exifInfo" + namespace OHOS { namespace ImagePlugin { namespace { - using namespace OHOS::HiviewDFX; - constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "exifInfo" }; static constexpr int PARSE_EXIF_SUCCESS = 0; static constexpr int PARSE_EXIF_DATA_ERROR = 10001; static constexpr int PARSE_EXIF_IFD_ERROR = 10002; @@ -427,18 +430,17 @@ static void inline DumpTagsMap(std::map &tags) { for (auto i = tags.begin(); i != tags.end(); i++) { if (TAG_MAP.count(i->first) == 0) { - HiLog::Debug(LABEL, "DumpTagsMap %{public}d -> %{public}s.", i->first, i->second.c_str()); + IMAGE_LOGD("DumpTagsMap %{public}d -> %{public}s.", i->first, i->second.c_str()); continue; } std::string name = TAG_MAP.at(i->first); - HiLog::Debug(LABEL, - "DumpTagsMap %{public}s(%{public}d) -> %{public}s.", name.c_str(), i->first, i->second.c_str()); + IMAGE_LOGD("DumpTagsMap %{public}s(%{public}d) -> %{public}s.", name.c_str(), i->first, i->second.c_str()); } } int EXIFInfo::ParseExifData(const unsigned char *buf, unsigned len) { - HiLog::Debug(LABEL, "ParseExifData ENTER"); + IMAGE_LOGD("ParseExifData ENTER"); if (exifData_ != nullptr) { exif_data_unref(exifData_); exifData_ = nullptr; @@ -454,7 +456,7 @@ int EXIFInfo::ParseExifData(const unsigned char *buf, unsigned len) ExifIfd ifd = exif_content_get_ifd(ec); (static_cast(userData))->imageFileDirectory_ = ifd; if (ifd == EXIF_IFD_COUNT) { - HiLog::Debug(LABEL, "GetIfd ERROR"); + IMAGE_LOGD("GetIfd ERROR"); return; } exif_content_foreach_entry(ec, @@ -578,7 +580,7 @@ void EXIFInfo::SetExifTagValuesEx(const ExifTag &tag, const std::string &value) } else if (tag == EXIF_TAG_FOCAL_LENGTH_IN_35MM_FILM) { focalLengthIn35mmFilm_ = value; } else { - HiLog::Debug(LABEL, "No match tag name!"); + IMAGE_LOGD("No match tag name!"); } } @@ -587,33 +589,33 @@ uint32_t EXIFInfo::GetFileInfoByPath(const std::string &path, FILE **file, unsig { *file = fopen(path.c_str(), "rb"); if (*file == nullptr) { - HiLog::Debug(LABEL, "Error creating file %{public}s", path.c_str()); + IMAGE_LOGD("Error creating file %{public}s", path.c_str()); return Media::ERR_MEDIA_IO_ABNORMAL; } // read jpeg file to buff fileLength = GetFileSize(*file); if (fileLength == 0 || fileLength > MAX_FILE_SIZE) { - HiLog::Debug(LABEL, "Get file size failed."); + IMAGE_LOGD("Get file size failed."); (void)fclose(*file); return Media::ERR_MEDIA_BUFFER_TOO_SMALL; } *fileBuf = static_cast(malloc(fileLength)); if (*fileBuf == nullptr) { - HiLog::Debug(LABEL, "Allocate buf for %{public}s failed.", path.c_str()); + IMAGE_LOGD("Allocate buf for %{public}s failed.", path.c_str()); (void)fclose(*file); return Media::ERR_IMAGE_MALLOC_ABNORMAL; } if (fread(*fileBuf, fileLength, 1, *file) != 1) { - HiLog::Debug(LABEL, "Read %{public}s failed.", path.c_str()); + IMAGE_LOGD("Read %{public}s failed.", path.c_str()); ReleaseSource(fileBuf, file); return Media::ERR_MEDIA_READ_PARCEL_FAIL; } if (!((*fileBuf)[0] == 0xFF && (*fileBuf)[1] == 0xD8)) { - HiLog::Debug(LABEL, "%{public}s is not jpeg file.", path.c_str()); + IMAGE_LOGD("%{public}s is not jpeg file.", path.c_str()); ReleaseSource(fileBuf, file); return Media::ERR_IMAGE_MISMATCHED_FORMAT; } @@ -641,7 +643,7 @@ uint32_t EXIFInfo::ModifyExifData(const ExifTag &tag, const std::string &value, unsigned int orginExifDataLength = GetOrginExifDataLength(isNewExifData, fileBuf); if (!isNewExifData && orginExifDataLength == 0) { - HiLog::Debug(LABEL, "There is no orginExifDataLength node in %{public}s.", path.c_str()); + IMAGE_LOGD("There is no orginExifDataLength node in %{public}s.", path.c_str()); exif_data_unref(ptrExifData); free(fileBuf); return Media::ERR_IMAGE_DECODE_EXIF_UNSUPPORT; @@ -650,7 +652,7 @@ uint32_t EXIFInfo::ModifyExifData(const ExifTag &tag, const std::string &value, ExifByteOrder order = GetExifByteOrder(isNewExifData, fileBuf); FILE *newFile = fopen(path.c_str(), "wb+"); if (newFile == nullptr) { - HiLog::Debug(LABEL, "Error create new file %{public}s", path.c_str()); + IMAGE_LOGD("Error create new file %{public}s", path.c_str()); ReleaseSource(&fileBuf, &newFile); return Media::ERR_MEDIA_IO_ABNORMAL; } @@ -674,21 +676,21 @@ uint32_t EXIFInfo::GetFileInfoByFd(int localFd, FILE **file, unsigned long &file { *file = fdopen(localFd, "wb+"); if (*file == nullptr) { - HiLog::Debug(LABEL, "Error creating file %{public}d", localFd); + IMAGE_LOGD("Error creating file %{public}d", localFd); return Media::ERR_MEDIA_IO_ABNORMAL; } // read jpeg file to buff fileLength = GetFileSize(*file); if (fileLength == 0 || fileLength > MAX_FILE_SIZE) { - HiLog::Debug(LABEL, "Get file size failed."); + IMAGE_LOGD("Get file size failed."); (void)fclose(*file); return Media::ERR_MEDIA_BUFFER_TOO_SMALL; } *fileBuf = static_cast(malloc(fileLength)); if (*fileBuf == nullptr) { - HiLog::Debug(LABEL, "Allocate buf for %{public}d failed.", localFd); + IMAGE_LOGD("Allocate buf for %{public}d failed.", localFd); (void)fclose(*file); return Media::ERR_IMAGE_MALLOC_ABNORMAL; } @@ -696,13 +698,13 @@ uint32_t EXIFInfo::GetFileInfoByFd(int localFd, FILE **file, unsigned long &file // Set current position to begin of file. (void)fseek(*file, 0L, 0); if (fread(*fileBuf, fileLength, 1, *file) != 1) { - HiLog::Debug(LABEL, "Read %{public}d failed.", localFd); + IMAGE_LOGD("Read %{public}d failed.", localFd); ReleaseSource(fileBuf, file); return Media::ERR_MEDIA_READ_PARCEL_FAIL; } if (!((*fileBuf)[0] == 0xFF && (*fileBuf)[1] == 0xD8)) { - HiLog::Debug(LABEL, "%{public}d is not jpeg file.", localFd); + IMAGE_LOGD("%{public}d is not jpeg file.", localFd); ReleaseSource(fileBuf, file); return Media::ERR_IMAGE_MISMATCHED_FORMAT; } @@ -729,7 +731,7 @@ uint32_t EXIFInfo::ModifyExifData(const ExifTag &tag, const std::string &value, unsigned int orginExifDataLength = GetOrginExifDataLength(isNewExifData, fileBuf); if (!isNewExifData && orginExifDataLength == 0) { - HiLog::Debug(LABEL, "There is no orginExifDataLength node in %{public}d.", localFd); + IMAGE_LOGD("There is no orginExifDataLength node in %{public}d.", localFd); free(fileBuf); exif_data_unref(ptrExifData); return Media::ERR_IMAGE_DECODE_EXIF_UNSUPPORT; @@ -766,17 +768,17 @@ void ReleaseExifDataBuffer(unsigned char* exifDataBuf) uint32_t EXIFInfo::CheckInputDataValid(unsigned char *data, uint32_t size) { if (data == nullptr) { - HiLog::Debug(LABEL, "buffer is nullptr."); + IMAGE_LOGD("buffer is nullptr."); return Media::ERR_IMAGE_SOURCE_DATA; } if (size == 0) { - HiLog::Debug(LABEL, "buffer size is 0."); + IMAGE_LOGD("buffer size is 0."); return Media::ERR_MEDIA_BUFFER_TOO_SMALL; } if (!(data[0] == 0xFF && data[1] == 0xD8)) { - HiLog::Debug(LABEL, "This is not jpeg file."); + IMAGE_LOGD("This is not jpeg file."); return Media::ERR_IMAGE_MISMATCHED_FORMAT; } return Media::SUCCESS; @@ -798,7 +800,7 @@ uint32_t EXIFInfo::ModifyExifData(const ExifTag &tag, const std::string &value, unsigned int orginExifDataLength = GetOrginExifDataLength(isNewExifData, data); if (!isNewExifData && orginExifDataLength == 0) { - HiLog::Debug(LABEL, "There is no orginExifDataLength node in buffer."); + IMAGE_LOGD("There is no orginExifDataLength node in buffer."); exif_data_unref(ptrExifData); return Media::ERR_IMAGE_DECODE_EXIF_UNSUPPORT; } @@ -814,20 +816,20 @@ uint32_t EXIFInfo::ModifyExifData(const ExifTag &tag, const std::string &value, unsigned int exifDataBufLength = 0; exif_data_save_data(ptrExifData, &exifDataBuf, &exifDataBufLength); if (exifDataBuf == nullptr) { - HiLog::Debug(LABEL, "Get Exif Data Buf failed!"); + IMAGE_LOGD("Get Exif Data Buf failed!"); exif_data_unref(ptrExifData); return Media::ERR_IMAGE_DECODE_EXIF_UNSUPPORT; } if (size == 0 || size > MAX_FILE_SIZE) { - HiLog::Debug(LABEL, "Buffer size is out of range."); + IMAGE_LOGD("Buffer size is out of range."); exif_data_unref(ptrExifData); ReleaseExifDataBuffer(exifDataBuf); return Media::ERR_IMAGE_DECODE_EXIF_UNSUPPORT; } unsigned char *tempBuf = static_cast(malloc(size)); if (tempBuf == nullptr) { - HiLog::Debug(LABEL, "Allocate temp buffer ailed."); + IMAGE_LOGD("Allocate temp buffer ailed."); exif_data_unref(ptrExifData); ReleaseExifDataBuffer(exifDataBuf); return Media::ERR_IMAGE_MALLOC_ABNORMAL; @@ -836,7 +838,7 @@ uint32_t EXIFInfo::ModifyExifData(const ExifTag &tag, const std::string &value, // Write EXIF header to buffer uint32_t index = 0; if (sizeof(EXIF_HEADER) >= size) { - HiLog::Debug(LABEL, "There is not enough space for EXIF header!"); + IMAGE_LOGD("There is not enough space for EXIF header!"); ReleaseExifData(tempBuf, ptrExifData, exifDataBuf); return Media::ERR_MEDIA_OUT_OF_RANGE; } @@ -848,7 +850,7 @@ uint32_t EXIFInfo::ModifyExifData(const ExifTag &tag, const std::string &value, // Write EXIF block length in big-endian order unsigned char highBit = static_cast((exifDataBufLength + LENGTH_OFFSET_2) >> MOVE_OFFSET_8); if (index >= size) { - HiLog::Debug(LABEL, "There is not enough space for writing EXIF block length!"); + IMAGE_LOGD("There is not enough space for writing EXIF block length!"); ReleaseExifData(tempBuf, ptrExifData, exifDataBuf); return Media::ERR_MEDIA_OUT_OF_RANGE; } @@ -856,7 +858,7 @@ uint32_t EXIFInfo::ModifyExifData(const ExifTag &tag, const std::string &value, unsigned char lowBit = static_cast((exifDataBufLength + LENGTH_OFFSET_2) & 0xff); if (index >= size) { - HiLog::Debug(LABEL, "There is not enough space for writing EXIF block length!"); + IMAGE_LOGD("There is not enough space for writing EXIF block length!"); ReleaseExifData(tempBuf, ptrExifData, exifDataBuf); return Media::ERR_MEDIA_OUT_OF_RANGE; } @@ -864,7 +866,7 @@ uint32_t EXIFInfo::ModifyExifData(const ExifTag &tag, const std::string &value, // Write EXIF data block if ((index + exifDataBufLength) >= size) { - HiLog::Debug(LABEL, "There is not enough space for writing EXIF data block!"); + IMAGE_LOGD("There is not enough space for writing EXIF data block!"); ReleaseExifData(tempBuf, ptrExifData, exifDataBuf); return Media::ERR_MEDIA_OUT_OF_RANGE; } @@ -874,7 +876,7 @@ uint32_t EXIFInfo::ModifyExifData(const ExifTag &tag, const std::string &value, // Write JPEG image data, skipping the non-EXIF header if ((index + size - orginExifDataLength - sizeof(EXIF_HEADER) - MOVE_OFFSET_8) > size) { - HiLog::Debug(LABEL, "There is not enough space for writing JPEG image data!"); + IMAGE_LOGD("There is not enough space for writing JPEG image data!"); ReleaseExifData(tempBuf, ptrExifData, exifDataBuf); return Media::ERR_MEDIA_OUT_OF_RANGE; } @@ -910,7 +912,7 @@ ExifEntry* EXIFInfo::InitExifTag(ExifData *exif, ExifIfd ifd, ExifTag tag) /* Allocate a new entry */ entry = exif_entry_new(); if (entry == nullptr) { - HiLog::Debug(LABEL, "Create new entry failed!"); + IMAGE_LOGD("Create new entry failed!"); return nullptr; } entry->tag = tag; // tag must be set before calling exif_content_add_entry @@ -938,7 +940,7 @@ static void EXIFInfoBufferCheck(ExifEntry *exifEntry, size_t len) /* Create a memory allocator to manage this ExifEntry */ ExifMem *exifMem = exif_mem_new_default(); if (exifMem == nullptr) { - HiLog::Debug(LABEL, "Create mem failed!"); + IMAGE_LOGD("Create mem failed!"); return; } auto buf = exif_mem_realloc(exifMem, exifEntry->data, len); @@ -963,21 +965,21 @@ ExifEntry* EXIFInfo::CreateExifTag(ExifData *exif, ExifIfd ifd, ExifTag tag, /* Create a memory allocator to manage this ExifEntry */ ExifMem *exifMem = exif_mem_new_default(); if (exifMem == nullptr) { - HiLog::Debug(LABEL, "Create mem failed!"); + IMAGE_LOGD("Create mem failed!"); return nullptr; } /* Create a new ExifEntry using our allocator */ exifEntry = exif_entry_new_mem (exifMem); if (exifEntry == nullptr) { - HiLog::Debug(LABEL, "Create entry by mem failed!"); + IMAGE_LOGD("Create entry by mem failed!"); return nullptr; } /* Allocate memory to use for holding the tag data */ buf = exif_mem_alloc(exifMem, len); if (buf == nullptr) { - HiLog::Debug(LABEL, "Allocate memory failed!"); + IMAGE_LOGD("Allocate memory failed!"); return nullptr; } @@ -1034,15 +1036,15 @@ bool EXIFInfo::CreateExifData(unsigned char *buf, unsigned long length, ExifData buf[BUFFER_POSITION_8] == 'i' && buf[BUFFER_POSITION_9] == 'f')) { *ptrData = exif_data_new_from_data(buf, static_cast(length)); if (!(*ptrData)) { - HiLog::Debug(LABEL, "Create exif data from file failed."); + IMAGE_LOGD("Create exif data from file failed."); return false; } isNewExifData = false; - HiLog::Debug(LABEL, "Create exif data from buffer."); + IMAGE_LOGD("Create exif data from buffer."); } else { *ptrData = exif_data_new(); if (!(*ptrData)) { - HiLog::Debug(LABEL, "Create exif data failed."); + IMAGE_LOGD("Create exif data failed."); return false; } /* Set the image options */ @@ -1053,7 +1055,7 @@ bool EXIFInfo::CreateExifData(unsigned char *buf, unsigned long length, ExifData /* Create the mandatory EXIF fields with default data */ exif_data_fix(*ptrData); isNewExifData = true; - HiLog::Debug(LABEL, "Create new exif data."); + IMAGE_LOGD("Create new exif data."); } return true; } @@ -1099,7 +1101,7 @@ static bool GetFractionFromStr(const std::string &decimal, ExifRational &result) int gcdVal = GCD(numerator, denominator); if (gcdVal == 0) { - HiLog::Debug(LABEL, "gcdVal is zero"); + IMAGE_LOGD("gcdVal is zero"); return false; } numerator /= gcdVal; @@ -1133,7 +1135,7 @@ static void ExifIntValueByFormat(unsigned char *b, ExifByteOrder order, ExifForm case EXIF_FORMAT_ASCII: case EXIF_FORMAT_RATIONAL: default: - HiLog::Debug(LABEL, "ExifIntValueByFormat unsupported format %{public}d.", format); + IMAGE_LOGD("ExifIntValueByFormat unsupported format %{public}d.", format); break; } } @@ -1148,7 +1150,7 @@ static bool ConvertStringToDouble(const std::string &str, double &number) static bool IsValidGpsData(const std::vector &dataVec, const ExifTag &tag) { if (dataVec.size() != SIZE_3 || (tag != EXIF_TAG_GPS_LATITUDE && tag != EXIF_TAG_GPS_LONGITUDE)) { - HiLog::Debug(LABEL, "Gps dms data size is invalid."); + IMAGE_LOGD("Gps dms data size is invalid."); return false; } double degree = 0.0; @@ -1157,14 +1159,14 @@ static bool IsValidGpsData(const std::vector &dataVec, const ExifTa if (!ConvertStringToDouble(dataVec[CONSTANT_0], degree) || !ConvertStringToDouble(dataVec[CONSTANT_1], minute) || !ConvertStringToDouble(dataVec[CONSTANT_2], second)) { - HiLog::Error(LABEL, "Convert gps data to double type failed."); + IMAGE_LOGE("Convert gps data to double type failed."); return false; } constexpr uint32_t timePeriod = 60; double latOrLong = degree + minute / timePeriod + second / (timePeriod * timePeriod); if ((tag == EXIF_TAG_GPS_LATITUDE && (latOrLong > GPS_MAX_LATITUDE || latOrLong < GPS_MIN_LATITUDE)) || (tag == EXIF_TAG_GPS_LONGITUDE && (latOrLong > GPS_MAX_LONGITUDE || latOrLong < GPS_MIN_LONGITUDE))) { - HiLog::Debug(LABEL, "Gps latitude or longitude is out of range."); + IMAGE_LOGD("Gps latitude or longitude is out of range."); return false; } return true; @@ -1174,7 +1176,7 @@ static bool ConvertGpsDataToRationals(const std::vector &dataVec, std::vector &exifRationals) { if (!(dataVec.size() == SIZE_3 && exifRationals.size() == SIZE_3)) { - HiLog::Debug(LABEL, "Data size is invalid."); + IMAGE_LOGD("Data size is invalid."); return false; } @@ -1197,12 +1199,12 @@ bool EXIFInfo::SetGpsRationals(ExifData *data, ExifEntry **ptrEntry, ExifByteOrd const ExifTag &tag, const std::vector &exifRationals) { if (exifRationals.size() != SIZE_3) { - HiLog::Debug(LABEL, "ExifRationals size is invalid."); + IMAGE_LOGD("ExifRationals size is invalid."); return false; } *ptrEntry = GetExifTag(data, EXIF_IFD_GPS, tag, MOVE_OFFSET_24); if ((*ptrEntry) == nullptr) { - HiLog::Debug(LABEL, "Get exif entry failed."); + IMAGE_LOGD("Get exif entry failed."); return false; } exif_set_rational((*ptrEntry)->data, order, exifRationals[CONSTANT_0]); @@ -1215,7 +1217,7 @@ bool EXIFInfo::SetGpsDegreeRational(ExifData *data, ExifEntry **ptrEntry, ExifBy const std::vector &dataVec) { if (dataVec.size() != SIZE_2) { - HiLog::Debug(LABEL, "Gps degree data size is invalid."); + IMAGE_LOGD("Gps degree data size is invalid."); return false; } ExifRational exifRational; @@ -1223,7 +1225,7 @@ bool EXIFInfo::SetGpsDegreeRational(ExifData *data, ExifEntry **ptrEntry, ExifBy exifRational.denominator = static_cast(atoi(dataVec[CONSTANT_1].c_str())); *ptrEntry = CreateExifTag(data, EXIF_IFD_GPS, tag, MOVE_OFFSET_8, EXIF_FORMAT_RATIONAL); if ((*ptrEntry) == nullptr) { - HiLog::Debug(LABEL, "Get exif entry failed."); + IMAGE_LOGD("Get exif entry failed."); return false; } exif_set_rational((*ptrEntry)->data, order, exifRational); @@ -1235,13 +1237,13 @@ bool EXIFInfo::CreateExifEntryOfBitsPerSample(const ExifTag &tag, ExifData *data { *ptrEntry = InitExifTag(data, EXIF_IFD_0, EXIF_TAG_BITS_PER_SAMPLE); if ((*ptrEntry) == nullptr) { - HiLog::Debug(LABEL, "Get exif entry failed."); + IMAGE_LOGD("Get exif entry failed."); return false; } std::vector bitsVec; SplitStr(value, ",", bitsVec); if (bitsVec.size() > CONSTANT_4) { - HiLog::Debug(LABEL, "BITS_PER_SAMPLE Invalid value %{public}s", value.c_str()); + IMAGE_LOGD("BITS_PER_SAMPLE Invalid value %{public}s", value.c_str()); return false; } if (bitsVec.size() != 0) { @@ -1311,7 +1313,7 @@ bool EXIFInfo::CreateExifEntryOfRationalExif(const ExifTag &tag, ExifData *data, std::vector longVec; SplitStr(value, separator, longVec); if (longVec.size() != sepSize) { - HiLog::Debug(LABEL, "%{public}s Invalid value %{public}s", GetExifNameByExifTag(tag).c_str(), value.c_str()); + IMAGE_LOGD("%{public}s Invalid value %{public}s", GetExifNameByExifTag(tag).c_str(), value.c_str()); return false; } ExifRational longRational; @@ -1319,7 +1321,7 @@ bool EXIFInfo::CreateExifEntryOfRationalExif(const ExifTag &tag, ExifData *data, longRational.denominator = static_cast(atoi(longVec[1].c_str())); *ptrEntry = CreateExifTag(data, GetExifIfdByExifTag(tag), tag, sizeof(longRational), GetExifFormatByExifTag(tag)); if ((*ptrEntry) == nullptr) { - HiLog::Debug(LABEL, "Get %{public}s exif entry failed.", GetExifNameByExifTag(tag).c_str()); + IMAGE_LOGD("Get %{public}s exif entry failed.", GetExifNameByExifTag(tag).c_str()); return false; } exif_set_rational((*ptrEntry)->data, order, longRational); @@ -1332,12 +1334,12 @@ bool EXIFInfo::CreateExifEntryOfGpsTimeStamp(const ExifTag &tag, ExifData *data, std::vector longVec; SplitStr(value, ":", longVec); if (longVec.size() != CONSTANT_3) { - HiLog::Debug(LABEL, "GPS time stamp Invalid value %{public}s", value.c_str()); + IMAGE_LOGD("GPS time stamp Invalid value %{public}s", value.c_str()); return false; } *ptrEntry = CreateExifTag(data, EXIF_IFD_GPS, tag, MOVE_OFFSET_24, EXIF_FORMAT_SRATIONAL); if ((*ptrEntry) == nullptr) { - HiLog::Debug(LABEL, "Get GPS time stamp exif entry failed."); + IMAGE_LOGD("Get GPS time stamp exif entry failed."); return false; } exif_set_long((*ptrEntry)->data, order, static_cast(atoi(longVec[CONSTANT_0].c_str()))); @@ -1353,12 +1355,12 @@ bool EXIFInfo::CreateExifEntryOfCompressedBitsPerPixel(const ExifTag &tag, ExifD { *ptrEntry = InitExifTag(data, EXIF_IFD_EXIF, tag); if ((*ptrEntry) == nullptr) { - HiLog::Debug(LABEL, "Get exif entry failed."); + IMAGE_LOGD("Get exif entry failed."); return false; } ExifRational rat; if (!GetFractionFromStr(value, rat)) { - HiLog::Debug(LABEL, "Get fraction from value failed."); + IMAGE_LOGD("Get fraction from value failed."); return false; } exif_set_rational((*ptrEntry)->data, order, rat); @@ -1374,7 +1376,7 @@ bool EXIFInfo::CreateExifEntryOfGpsLatitudeOrLongitude(const ExifTag &tag, ExifD return SetGpsDegreeRational(data, ptrEntry, order, tag, longVec); } if (longVec.size() != CONSTANT_3 || !IsValidGpsData(longVec, tag)) { - HiLog::Debug(LABEL, "%{public}s Invalid value %{public}s", GetExifNameByExifTag(tag).c_str(), + IMAGE_LOGD("%{public}s Invalid value %{public}s", GetExifNameByExifTag(tag).c_str(), value.c_str()); return false; } @@ -1400,7 +1402,7 @@ bool EXIFInfo::CreateExifEntry(const ExifTag &tag, ExifData *data, const std::st } else if (std::find(vector1.begin(), vector1.end(), tag) != vector1.end()) { *ptrEntry = InitExifTag(data, GetExifIfdByExifTag(tag), tag); if ((*ptrEntry) == nullptr) { - HiLog::Debug(LABEL, "Get %{public}s exif entry failed.", GetExifNameByExifTag(tag).c_str()); + IMAGE_LOGD("Get %{public}s exif entry failed.", GetExifNameByExifTag(tag).c_str()); return false; } ExifIntValueByFormat((*ptrEntry)->data, order, (*ptrEntry)->format, atoi(value.c_str())); @@ -1408,11 +1410,11 @@ bool EXIFInfo::CreateExifEntry(const ExifTag &tag, ExifData *data, const std::st } else if (std::find(vector2.begin(), vector2.end(), tag) != vector2.end()) { *ptrEntry = CreateExifTag(data, GetExifIfdByExifTag(tag), tag, value.length(), GetExifFormatByExifTag(tag)); if ((*ptrEntry) == nullptr || (*ptrEntry)->size < value.length()) { - HiLog::Debug(LABEL, "Get %{public}s exif entry failed.", GetExifNameByExifTag(tag).c_str()); + IMAGE_LOGD("Get %{public}s exif entry failed.", GetExifNameByExifTag(tag).c_str()); return false; } if (memcpy_s((*ptrEntry)->data, value.length(), value.c_str(), value.length()) != 0) { - HiLog::Debug(LABEL, "%{public}s memcpy error", GetExifNameByExifTag(tag).c_str()); + IMAGE_LOGD("%{public}s memcpy error", GetExifNameByExifTag(tag).c_str()); } return true; } else if (tag == EXIF_TAG_GPS_LATITUDE || tag == EXIF_TAG_GPS_LONGITUDE) { @@ -1434,40 +1436,40 @@ bool EXIFInfo::WriteExifDataToFile(ExifData *data, unsigned int orginExifDataLen unsigned int exifDataBufLength = 0; exif_data_save_data(data, &exifDataBuf, &exifDataBufLength); if (exifDataBuf == nullptr) { - HiLog::Debug(LABEL, "Get Exif Data Buf failed!"); + IMAGE_LOGD("Get Exif Data Buf failed!"); return false; } // Write EXIF header if (fwrite(EXIF_HEADER, sizeof(EXIF_HEADER), 1, fp) != 1) { - HiLog::Debug(LABEL, "Error writing EXIF header to file!"); + IMAGE_LOGD("Error writing EXIF header to file!"); ReleaseExifDataBuffer(exifDataBuf); return false; } // Write EXIF block length in big-endian order if (fputc((exifDataBufLength + LENGTH_OFFSET_2) >> MOVE_OFFSET_8, fp) < 0) { - HiLog::Debug(LABEL, "Error writing EXIF block length to file!"); + IMAGE_LOGD("Error writing EXIF block length to file!"); ReleaseExifDataBuffer(exifDataBuf); return false; } if (fputc((exifDataBufLength + LENGTH_OFFSET_2) & 0xff, fp) < 0) { - HiLog::Debug(LABEL, "Error writing EXIF block length to file!"); + IMAGE_LOGD("Error writing EXIF block length to file!"); ReleaseExifDataBuffer(exifDataBuf); return false; } // Write EXIF data block if (fwrite(exifDataBuf, exifDataBufLength, 1, fp) != 1) { - HiLog::Debug(LABEL, "Error writing EXIF data block to file!"); + IMAGE_LOGD("Error writing EXIF data block to file!"); ReleaseExifDataBuffer(exifDataBuf); return false; } // Write JPEG image data, skipping the non-EXIF header unsigned int dataOffset = orginExifDataLength + sizeof(EXIF_HEADER); if (fwrite(buf + dataOffset, fileLength - dataOffset, 1, fp) != 1) { - HiLog::Debug(LABEL, "Error writing JPEG image data to file!"); + IMAGE_LOGD("Error writing JPEG image data to file!"); ReleaseExifDataBuffer(exifDataBuf); return false; } @@ -1496,20 +1498,20 @@ void EXIFInfo::UpdateCacheExifData(FILE *fp) { unsigned long fileLength = GetFileSize(fp); if (fileLength == 0 || fileLength > MAX_FILE_SIZE) { - HiLog::Debug(LABEL, "Get file size failed."); + IMAGE_LOGD("Get file size failed."); return; } unsigned char *fileBuf = static_cast(malloc(fileLength)); if (fileBuf == nullptr) { - HiLog::Debug(LABEL, "Allocate buf failed."); + IMAGE_LOGD("Allocate buf failed."); return; } // Set current position to begin of file. (void)fseek(fp, 0L, 0); if (fread(fileBuf, fileLength, 1, fp) != 1) { - HiLog::Debug(LABEL, "Read new file failed."); + IMAGE_LOGD("Read new file failed."); free(fileBuf); fileBuf = nullptr; return; @@ -1528,13 +1530,13 @@ uint32_t EXIFInfo::GetFilterArea(const uint8_t *buf, std::unique_ptr byteOrderedBuffer = std::make_unique(buf, bufSize); byteOrderedBuffer->GenerateDEArray(); if (byteOrderedBuffer->directoryEntryArray_.size() == 0) { - HiLog::Debug(LABEL, "Read Exif info range failed."); + IMAGE_LOGD("Read Exif info range failed."); return ERROR_PARSE_EXIF_FAILED; } GetAreaFromExifEntries(privacyType, byteOrderedBuffer->directoryEntryArray_, ranges); if (ranges.size() == 0) { - HiLog::Debug(LABEL, "There is no exif info need filtered in this image."); + IMAGE_LOGD("There is no exif info need filtered in this image."); return ERROR_NO_EXIF_TAGS; } @@ -1576,7 +1578,7 @@ void ByteOrderedBuffer::GenerateDEArray() curPosition_ = TIFF_OFFSET_FROM_FILE_BEGIN + CONSTANT_4; int32_t ifd0Offset = ReadInt32(); if (ifd0Offset < 0) { - HiLog::Debug(LABEL, "Get IFD0 offset failed!"); + IMAGE_LOGD("Get IFD0 offset failed!"); return; } // Transform tiff offset to position of file @@ -1585,7 +1587,7 @@ void ByteOrderedBuffer::GenerateDEArray() curPosition_ = static_cast(ifd0Offset); if (curPosition_ + CONSTANT_2 > bufferLength_) { - HiLog::Debug(LABEL, "There is no data from the offset: %{public}d.", curPosition_); + IMAGE_LOGD("There is no data from the offset: %{public}d.", curPosition_); return; } GetDataRangeFromIFD(EXIF_IFD_0); @@ -1596,7 +1598,7 @@ void ByteOrderedBuffer::GetDataRangeFromIFD(const ExifIfd &ifd) handledIfdOffsets_.push_back(curPosition_); int16_t entryCount = ReadShort(); if (static_cast(curPosition_ + BYTE_COUNTS_12 * entryCount) > bufferLength_ || entryCount <= 0) { - HiLog::Debug(LABEL, " The size of entries is either too big or negative."); + IMAGE_LOGD(" The size of entries is either too big or negative."); return; } GetDataRangeFromDE(ifd, entryCount); @@ -1604,7 +1606,7 @@ void ByteOrderedBuffer::GetDataRangeFromIFD(const ExifIfd &ifd) if (Peek() + CONSTANT_4 <= bufferLength_) { int32_t nextIfdOffset = ReadInt32(); if (nextIfdOffset == 0) { - HiLog::Debug(LABEL, "Stop reading file since this IFD is finished"); + IMAGE_LOGD("Stop reading file since this IFD is finished"); return; } // Transform tiff offset to position of file @@ -1620,10 +1622,10 @@ void ByteOrderedBuffer::GetDataRangeFromIFD(const ExifIfd &ifd) ExifIfd nextIfd = GetNextIfdFromLinkList(ifd); GetDataRangeFromIFD(nextIfd); } else { - HiLog::Debug(LABEL, "Stop reading buffer since re-reading an IFD at %{public}d.", nextIfdOffset); + IMAGE_LOGD("Stop reading buffer since re-reading an IFD at %{public}d.", nextIfdOffset); } } else { - HiLog::Debug(LABEL, "Stop reading file since a wrong offset at %{public}d.", nextIfdOffset); + IMAGE_LOGD("Stop reading file since a wrong offset at %{public}d.", nextIfdOffset); } } } @@ -1656,7 +1658,7 @@ void ByteOrderedBuffer::GetDataRangeFromDE(const ExifIfd &ifd, const int16_t &co curPosition_ = static_cast(offset); } else { // Skip if invalid data offset. - HiLog::Info(LABEL, "Skip the tag entry since data offset is invalid: %{public}d.", offset); + IMAGE_LOGI("Skip the tag entry since data offset is invalid: %{public}d.", offset); curPosition_ = nextEntryOffset; continue; } @@ -1694,15 +1696,15 @@ bool ByteOrderedBuffer::SetDEDataByteCount(const uint16_t &tagNumber, uint32_t &count) { if (IsValidTagNumber(tagNumber)) { - HiLog::Debug(LABEL, "Skip the tag entry since tag number is not defined: %{public}d.", tagNumber); + IMAGE_LOGD("Skip the tag entry since tag number is not defined: %{public}d.", tagNumber); } else if (dataFormat <= 0 || exif_format_get_size(static_cast(dataFormat)) == 0) { - HiLog::Debug(LABEL, "Skip the tag entry since data format is invalid: %{public}d.", dataFormat); + IMAGE_LOGD("Skip the tag entry since data format is invalid: %{public}d.", dataFormat); } else { count = static_cast(numberOfComponents) * static_cast(exif_format_get_size(static_cast(dataFormat))); if (count < 0) { - HiLog::Debug(LABEL, "Skip the tag entry since the number of components is invalid: %{public}d.", - numberOfComponents); + IMAGE_LOGD("Skip the tag entry since the number of components is invalid: %{public}d.", + numberOfComponents); } else { return true; } @@ -1746,10 +1748,10 @@ void ByteOrderedBuffer::ParseIFDPointerTag(const ExifIfd &ifd, const uint16_t &d curPosition_ = offset; GetDataRangeFromIFD(ifd); } else { - HiLog::Debug(LABEL, "Skip jump into the IFD since it has already been read at %{public}d.", offset); + IMAGE_LOGD("Skip jump into the IFD since it has already been read at %{public}d.", offset); } } else { - HiLog::Debug(LABEL, "Skip jump into the IFD since its offset is invalid: %{public}d.", offset); + IMAGE_LOGD("Skip jump into the IFD since its offset is invalid: %{public}d.", offset); } } @@ -1766,7 +1768,7 @@ bool ByteOrderedBuffer::IsValidTagNumber(const uint16_t &tagNumber) bool ByteOrderedBuffer::IsIFDhandled(const uint32_t &position) { if (handledIfdOffsets_.size() == 0) { - HiLog::Debug(LABEL, "There is no handled IFD!"); + IMAGE_LOGD("There is no handled IFD!"); return false; } @@ -1835,7 +1837,7 @@ int32_t ByteOrderedBuffer::ReadInt32() // Move current position to begin of next segment curPosition_ += CONSTANT_4; if (curPosition_ > bufferLength_) { - HiLog::Debug(LABEL, "Current Position %{public}u out of range.", curPosition_); + IMAGE_LOGD("Current Position %{public}u out of range.", curPosition_); return -1; } @@ -1862,7 +1864,7 @@ int16_t ByteOrderedBuffer::ReadShort() // Move current position to begin of next segment curPosition_ += CONSTANT_2; if (curPosition_ > bufferLength_) { - HiLog::Debug(LABEL, "Current Position %{public}u out of range.", curPosition_); + IMAGE_LOGD("Current Position %{public}u out of range.", curPosition_); return -1; } @@ -2022,7 +2024,7 @@ static uint32_t SpecialExifData(EXIFInfo* info, const std::string &name, std::st return res; } if (ORIENTATION_INT_MAP.count(orgValue) == 0) { - HiLog::Debug(LABEL, "SpecialExifData %{public}s not found %{public}s.", + IMAGE_LOGD("SpecialExifData %{public}s not found %{public}s.", name.c_str(), orgValue.c_str()); return Media::ERR_IMAGE_DECODE_EXIF_UNSUPPORT; } @@ -2053,23 +2055,23 @@ uint32_t EXIFInfo::GetExifData(const std::string name, std::string &value) { auto res = SpecialExifData(this, name, value); if (res == Media::SUCCESS || res != Media::ERR_MEDIA_STATUS_ABNORMAL) { - HiLog::Debug(LABEL, "GetExifData %{public}s special result with %{public}d.", name.c_str(), res); + IMAGE_LOGD("GetExifData %{public}s special result with %{public}d.", name.c_str(), res); return res; } ExifTag tag; if (!GetExifTagByName(name, tag)) { - HiLog::Debug(LABEL, "GetExifData %{public}s not in the TAGs map.", name.c_str()); + IMAGE_LOGD("GetExifData %{public}s not in the TAGs map.", name.c_str()); return Media::ERR_IMAGE_DECODE_EXIF_UNSUPPORT; } DumpTagsMap(exifTags_); if (exifTags_.count(tag) == 0) { - HiLog::Debug(LABEL, "GetExifData has no tag %{public}s[%{public}d], tags Size: %{public}zu.", + IMAGE_LOGD("GetExifData has no tag %{public}s[%{public}d], tags Size: %{public}zu.", name.c_str(), tag, exifTags_.size()); return Media::ERR_IMAGE_DECODE_EXIF_UNSUPPORT; } value = exifTags_.at(tag); if (IsSameTextStr(value, DEFAULT_EXIF_VALUE)) { - HiLog::Debug(LABEL, "GetExifData %{public}s[%{public}d] value is DEFAULT_EXIF_VALUE.", + IMAGE_LOGD("GetExifData %{public}s[%{public}d] value is DEFAULT_EXIF_VALUE.", name.c_str(), tag); return Media::ERR_MEDIA_VALUE_INVALID; } @@ -2080,7 +2082,7 @@ uint32_t EXIFInfo::ModifyExifData(const std::string name, const std::string &val { ExifTag tag; if (!GetExifTagByName(name, tag)) { - HiLog::Debug(LABEL, "ModifyExifData %{public}s not in the TAGs map.", name.c_str()); + IMAGE_LOGD("ModifyExifData %{public}s not in the TAGs map.", name.c_str()); return Media::ERR_IMAGE_DECODE_EXIF_UNSUPPORT; } return ModifyExifData(tag, value, path); @@ -2090,7 +2092,7 @@ uint32_t EXIFInfo::ModifyExifData(const std::string name, const std::string &val { ExifTag tag; if (!GetExifTagByName(name, tag)) { - HiLog::Debug(LABEL, "ModifyExifData %{public}s not in the TAGs map.", name.c_str()); + IMAGE_LOGD("ModifyExifData %{public}s not in the TAGs map.", name.c_str()); return Media::ERR_IMAGE_DECODE_EXIF_UNSUPPORT; } return ModifyExifData(tag, value, fd); @@ -2100,7 +2102,7 @@ uint32_t EXIFInfo::ModifyExifData(const std::string name, const std::string &val { ExifTag tag; if (!GetExifTagByName(name, tag)) { - HiLog::Debug(LABEL, "ModifyExifData %{public}s not in the TAGs map.", name.c_str()); + IMAGE_LOGD("ModifyExifData %{public}s not in the TAGs map.", name.c_str()); return Media::ERR_IMAGE_DECODE_EXIF_UNSUPPORT; } return ModifyExifData(tag, value, data, size); diff --git a/plugins/common/libs/image/libjpegplugin/src/exif_maker_note.cpp b/plugins/common/libs/image/libjpegplugin/src/exif_maker_note.cpp index f92fd7b11..d1eb799ff 100644 --- a/plugins/common/libs/image/libjpegplugin/src/exif_maker_note.cpp +++ b/plugins/common/libs/image/libjpegplugin/src/exif_maker_note.cpp @@ -15,17 +15,21 @@ #include "exif_maker_note.h" #include #include "exif_info.h" -#include "hilog/log.h" -#include "log_tags.h" +#include "image_log.h" #include "media_errors.h" #include "securec.h" #include "string_ex.h" + +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "ExifMakerNote" + namespace OHOS { namespace ImagePlugin { -using namespace HiviewDFX; using namespace Media; namespace { -constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "ExifMakerNote" }; constexpr unsigned char EXIF_HEADER[] = {'E', 'x', 'i', 'f', '\0', '\0'}; constexpr unsigned char HW_MNOTE_HEADER[] = { 'H', 'U', 'A', 'W', 'E', 'I', '\0', '\0' }; constexpr unsigned char HW_MNOTE_TIFF_II[] = { 'I', 'I', 0x2A, 0x00, 0x08, 0x00, 0x00, 0x00 }; @@ -114,7 +118,7 @@ bool ExifMakerNote::ExifItem::GetValue(std::string &value, const ExifByteOrder & { auto *exifData = exif_data_new(); if (exifData == nullptr) { - HiLog::Error(LABEL, "GetValue, data is null."); + IMAGE_LOGE("GetValue, data is null."); return false; } exif_data_set_byte_order(exifData, order); @@ -131,7 +135,7 @@ bool ExifMakerNote::ExifItem::GetValue(std::string &value, ExifData *exifData, { auto *exifContent = exif_content_new(); if (exifContent == nullptr) { - HiLog::Error(LABEL, "GetValue, content is null."); + IMAGE_LOGE("GetValue, content is null."); return false; } @@ -153,7 +157,7 @@ bool ExifMakerNote::ExifItem::GetValue(std::string &value, ExifContent *exifCont { auto *exifEntry = exif_entry_new(); if (exifEntry == nullptr) { - HiLog::Error(LABEL, "GetValue, item is null."); + IMAGE_LOGE("GetValue, item is null."); return false; } @@ -202,11 +206,11 @@ void ExifMakerNote::ExifItem::Dump(const std::string &info, const ExifMakerNote: { uint32_t dataOrOffset = 0; if (!ExifMakerNote::GetUInt32(item.data, order, 0, dataOrOffset)) { - HiLog::Error(LABEL, "ExifMakerNote::ExifItem::Dump, GetUInt32 failed"); + IMAGE_LOGE("ExifMakerNote::ExifItem::Dump, GetUInt32 failed"); return; } - HiLog::Debug(LABEL, "%{public}s, " + IMAGE_LOGD("%{public}s, " "ifd=0x%{public}x, tag=0x%{public}04x, fmt=%{public}u, cnt=%{public}u, " "dataOrOffset=%{public}u(0x%{public}08x), data=[%{public}s]", info.c_str(), @@ -226,24 +230,24 @@ ExifMakerNote::~ExifMakerNote() uint32_t ExifMakerNote::Parser(ExifData *exif, const unsigned char *data, uint32_t size) { - HiLog::Debug(LABEL, "Parser enter"); + IMAGE_LOGD("Parser enter"); bool moreCheck = false; uint32_t res = ParserMakerNote(exif, moreCheck); if ((res == Media::SUCCESS) || (!moreCheck)) { - HiLog::Debug(LABEL, "Parser leave"); + IMAGE_LOGD("Parser leave"); return Media::SUCCESS; } if ((data == nullptr) || (size < sizeof(EXIF_HEADER))) { - HiLog::Error(LABEL, "Parser leave. param invalid"); + IMAGE_LOGE("Parser leave. param invalid"); return Media::ERROR; } const unsigned char *newData = nullptr; uint32_t newSize = 0; if (!FindExifLocation(data, size, newData, newSize)) { - HiLog::Error(LABEL, "Parser leave. findExifLocation failed"); + IMAGE_LOGE("Parser leave. findExifLocation failed"); return Media::ERROR; } @@ -258,69 +262,69 @@ uint32_t ExifMakerNote::Parser(ExifData *exif, const unsigned char *data, uint32 continue; } - HiLog::Debug(LABEL, "Parser, find, ifd=%{public}u, tag=0x%{public}04x, fmt=%{public}u, " + IMAGE_LOGD("Parser, find, ifd=%{public}u, tag=0x%{public}04x, fmt=%{public}u, " "num=%{public}u, valueOffset=%{public}u, valueLength=%{public}u", de.ifd, de.tag, de.format, de.dataCounts, de.valueOffset, de.valueLength); if (ParserMakerNote(data + de.valueOffset, de.valueLength) == Media::SUCCESS) { - HiLog::Debug(LABEL, "Parser leave"); + IMAGE_LOGD("Parser leave"); return Media::SUCCESS; } } - HiLog::Debug(LABEL, "Parser leave"); + IMAGE_LOGD("Parser leave"); return Media::ERROR; } bool ExifMakerNote::FindExifLocation(const unsigned char *data, uint32_t size, const unsigned char *&newData, uint32_t &newSize) { - HiLog::Debug(LABEL, "FindExifLocation enter"); + IMAGE_LOGD("FindExifLocation enter"); if (size < sizeof(EXIF_HEADER)) { - HiLog::Error(LABEL, "FindExifLocation, small. size=%{public}u", size); + IMAGE_LOGE("FindExifLocation, small. size=%{public}u", size); return false; } const unsigned char *d = data; if (memcmp(d, EXIF_HEADER, sizeof(EXIF_HEADER)) != 0) { if (!FindJpegAPP1(d, size, d, size)) { - HiLog::Error(LABEL, "FindExifLocation leave, findJpegAPP1."); + IMAGE_LOGE("FindExifLocation leave, findJpegAPP1."); return false; } d++; size--; unsigned int len = (d[0] << 8) | d[1]; - HiLog::Debug(LABEL, "FindExifLocation, len=%{public}u", len); + IMAGE_LOGD("FindExifLocation, len=%{public}u", len); d += JPEG_TAG_SIZE; size -= JPEG_TAG_SIZE; } if (size < EXIF_MIN_SIZE) { - HiLog::Error(LABEL, "FindExifLocation, small."); + IMAGE_LOGE("FindExifLocation, small."); return false; } if (memcmp(d, EXIF_HEADER, sizeof(EXIF_HEADER)) != 0) { - HiLog::Error(LABEL, "FindExifLocation, no found EXIF header"); + IMAGE_LOGE("FindExifLocation, no found EXIF header"); return false; } - HiLog::Debug(LABEL, "FindExifLocation, Found EXIF header"); + IMAGE_LOGD("FindExifLocation, Found EXIF header"); newData = d; newSize = size; - HiLog::Debug(LABEL, "FindExifLocation leave"); + IMAGE_LOGD("FindExifLocation leave"); return true; } bool ExifMakerNote::FindJpegAPP1(const unsigned char *data, uint32_t size, const unsigned char *&newData, uint32_t &newSize) { - HiLog::Debug(LABEL, "FindJpegAPP1 enter"); + IMAGE_LOGD("FindJpegAPP1 enter"); while (size >= JPEG_CHECK_MIN_SIZE) { while (size && (data[0] == 0xff)) { @@ -343,7 +347,7 @@ bool ExifMakerNote::FindJpegAPP1(const unsigned char *data, uint32_t size, size--; unsigned int l = (data[0] << 8) | data[1]; if (l > size) { - HiLog::Error(LABEL, "FindJpegAPP1, small."); + IMAGE_LOGE("FindJpegAPP1, small."); return false; } data += l; @@ -351,71 +355,71 @@ bool ExifMakerNote::FindJpegAPP1(const unsigned char *data, uint32_t size, continue; } - HiLog::Error(LABEL, "FindJpegAPP1, Unknown."); + IMAGE_LOGE("FindJpegAPP1, Unknown."); return false; } if (size < JPEG_CHECK_MIN_SIZE) { - HiLog::Error(LABEL, "FindJpegAPP1, small2."); + IMAGE_LOGE("FindJpegAPP1, small2."); return false; } newData = data; newSize = size; - HiLog::Debug(LABEL, "FindJpegAPP1 leave"); + IMAGE_LOGD("FindJpegAPP1 leave"); return true; } uint32_t ExifMakerNote::ParserMakerNote(ExifData* exif, bool &moreCheck) { - HiLog::Debug(LABEL, "ParserMakerNote enter"); + IMAGE_LOGD("ParserMakerNote enter"); moreCheck = false; if (exif == nullptr) { - HiLog::Fatal(LABEL, "ParserMakerNote, exif is null."); + IMAGE_LOGF("ParserMakerNote, exif is null."); return Media::ERROR; } auto *ee = exif_data_get_entry (exif, EXIF_TAG_MAKER_NOTE); auto *md = exif_data_get_mnote_data(exif); if ((ee == nullptr) || (md != nullptr)) { - HiLog::Debug(LABEL, "ParserMakerNote leave"); + IMAGE_LOGD("ParserMakerNote leave"); return Media::ERROR; } - HiLog::Info(LABEL, "need parser mnote."); + IMAGE_LOGI("need parser mnote."); if (ParserMakerNote(ee->data, ee->size) == Media::SUCCESS) { - HiLog::Debug(LABEL, "ParserMakerNote leave"); + IMAGE_LOGD("ParserMakerNote leave"); return Media::SUCCESS; } moreCheck = true; - HiLog::Debug(LABEL, "ParserMakerNote leave"); + IMAGE_LOGD("ParserMakerNote leave"); return Media::ERROR; } uint32_t ExifMakerNote::ParserMakerNote(const unsigned char *data, uint32_t size) { - HiLog::Debug(LABEL, "ParserMakerNote enter"); + IMAGE_LOGD("ParserMakerNote enter"); if (!IsHwMakerNote(data, size)) { - HiLog::Debug(LABEL, "ParserMakerNote leave"); + IMAGE_LOGD("ParserMakerNote leave"); return Media::ERROR; } makerNote_.resize(size); if (memcpy_s(makerNote_.data(), makerNote_.size(), data, size) != 0) { - HiLog::Error(LABEL, "memcpy error"); + IMAGE_LOGE("memcpy error"); return Media::ERROR; } ParserHwMakerNote(); - HiLog::Debug(LABEL, "ParserMakerNote leave"); + IMAGE_LOGD("ParserMakerNote leave"); return Media::SUCCESS; } @@ -426,22 +430,22 @@ bool ExifMakerNote::IsParsed() const bool ExifMakerNote::IsHwMakerNote(const unsigned char *data, uint32_t size) { - HiLog::Debug(LABEL, "IsHwMakerNote enter"); + IMAGE_LOGD("IsHwMakerNote enter"); tiff_offset_ = 0; ifd0_offset_ = 0; if (sizeof(HW_MNOTE_TIFF_II) != sizeof(HW_MNOTE_TIFF_MM)) { - HiLog::Fatal(LABEL, "IsHwMakerNote leave, same"); + IMAGE_LOGF("IsHwMakerNote leave, same"); return false; } if (size < (sizeof(HW_MNOTE_HEADER) + sizeof(HW_MNOTE_TIFF_II))) { - HiLog::Debug(LABEL, "IsHwMakerNote leave, size"); + IMAGE_LOGD("IsHwMakerNote leave, size"); return false; } if (memcmp(data, HW_MNOTE_HEADER, sizeof(HW_MNOTE_HEADER)) != 0) { - HiLog::Debug(LABEL, "IsHwMakerNote leave, hd"); + IMAGE_LOGD("IsHwMakerNote leave, hd"); return false; } @@ -450,26 +454,26 @@ bool ExifMakerNote::IsHwMakerNote(const unsigned char *data, uint32_t size) if (memcmp((data + tiff_offset_), HW_MNOTE_TIFF_II, sizeof(HW_MNOTE_TIFF_II)) == 0) { order_ = ExifByteOrder::EXIF_BYTE_ORDER_INTEL; ifd0_offset_ = tiff_offset_ + sizeof(HW_MNOTE_TIFF_II); - HiLog::Debug(LABEL, "IsHwMakerNote leave, ii, tiff=%{public}u, ifd0=%{public}u", tiff_offset_, ifd0_offset_); + IMAGE_LOGD("IsHwMakerNote leave, ii, tiff=%{public}u, ifd0=%{public}u", tiff_offset_, ifd0_offset_); return true; } if (memcmp((data+ tiff_offset_), HW_MNOTE_TIFF_MM, sizeof(HW_MNOTE_TIFF_MM)) == 0) { order_ = ExifByteOrder::EXIF_BYTE_ORDER_MOTOROLA; ifd0_offset_ = tiff_offset_ + sizeof(HW_MNOTE_TIFF_MM); - HiLog::Debug(LABEL, "IsHwMakerNote leave, mm, tiff=%{public}u, ifd0=%{public}u", tiff_offset_, ifd0_offset_); + IMAGE_LOGD("IsHwMakerNote leave, mm, tiff=%{public}u, ifd0=%{public}u", tiff_offset_, ifd0_offset_); return true; } - HiLog::Error(LABEL, "byte order error"); + IMAGE_LOGE("byte order error"); - HiLog::Debug(LABEL, "IsHwMakerNote leave, order"); + IMAGE_LOGD("IsHwMakerNote leave, order"); return false; } bool ExifMakerNote::ParserHwMakerNote() { - HiLog::Debug(LABEL, "ParserHwMakerNote enter"); + IMAGE_LOGD("ParserHwMakerNote enter"); bool ret = ParserIFD(ifd0_offset_, HW_MNOTE_IFD_DEFAULT); @@ -485,20 +489,20 @@ bool ExifMakerNote::ParserHwMakerNote() SetValue(entry, value); } - HiLog::Debug(LABEL, "ParserHwMakerNote leave, ret=%{public}u", ret); + IMAGE_LOGD("ParserHwMakerNote leave, ret=%{public}u", ret); return ret; } bool ExifMakerNote::ParserIFD(uint32_t offset, uint32_t ifd, uint32_t deep) { - HiLog::Debug(LABEL, "ParserIFD enter, offset=%{public}u, ifd=%{public}u, deep=%{public}u", offset, ifd, deep); + IMAGE_LOGD("ParserIFD enter, offset=%{public}u, ifd=%{public}u, deep=%{public}u", offset, ifd, deep); uint16_t count = 0; if (!GetUInt16AndMove(offset, count)) { - HiLog::Error(LABEL, "ParserIFD leave, count, false"); + IMAGE_LOGE("ParserIFD leave, count, false"); return false; } - HiLog::Debug(LABEL, "ParserIFD, count=%{public}u", count); + IMAGE_LOGD("ParserIFD, count=%{public}u", count); for (uint16_t i = 0; i < count; i++) { if (ParserItem(offset, ifd, deep)) { @@ -506,22 +510,22 @@ bool ExifMakerNote::ParserIFD(uint32_t offset, uint32_t ifd, uint32_t deep) continue; } - HiLog::Error(LABEL, "ParserIFD leave, entry, false"); + IMAGE_LOGE("ParserIFD leave, entry, false"); return false; } if (memcmp(makerNote_.data() + offset, HW_MNOTE_IFD_TAIL, sizeof(HW_MNOTE_IFD_TAIL)) != 0) { - HiLog::Error(LABEL, "ParserIFD leave, tail, false"); + IMAGE_LOGE("ParserIFD leave, tail, false"); return false; } - HiLog::Debug(LABEL, "ParserIFD leave, true"); + IMAGE_LOGD("ParserIFD leave, true"); return true; } bool ExifMakerNote::ParserItem(uint32_t offset, uint32_t ifd, uint32_t deep) { - HiLog::Debug(LABEL, "ParserItem enter, offset=%{public}u, deep=%{public}u, data=[%{public}s]", + IMAGE_LOGD("ParserItem enter, offset=%{public}u, deep=%{public}u, data=[%{public}s]", offset, deep, ExifMakerNote::Dump(makerNote_, offset, ENTRY_SIZE).c_str()); uint16_t tag = 0; @@ -529,19 +533,19 @@ bool ExifMakerNote::ParserItem(uint32_t offset, uint32_t ifd, uint32_t deep) uint32_t components = 0; uint32_t dataOrOffset = 0; if (!GetUInt16AndMove(offset, tag)) { - HiLog::Error(LABEL, "ParserItem leave, tag, false"); + IMAGE_LOGE("ParserItem leave, tag, false"); return false; } if (!GetUInt16AndMove(offset, format)) { - HiLog::Error(LABEL, "ParserItem leave, format, false"); + IMAGE_LOGE("ParserItem leave, format, false"); return false; } if (!GetUInt32AndMove(offset, components)) { - HiLog::Error(LABEL, "ParserItem leave, components, false"); + IMAGE_LOGE("ParserItem leave, components, false"); return false; } if (!GetUInt32(offset, dataOrOffset)) { - HiLog::Error(LABEL, "ParserItem leave, data, false"); + IMAGE_LOGE("ParserItem leave, data, false"); return false; } @@ -555,18 +559,18 @@ bool ExifMakerNote::ParserItem(uint32_t offset, uint32_t ifd, uint32_t deep) back.Dump("ParserItem", order_); if (deep > 0) { - HiLog::Debug(LABEL, "ParserItem leave, deep=%{public}u", deep); + IMAGE_LOGD("ParserItem leave, deep=%{public}u", deep); return true; } if ((back.tag == HW_MNOTE_TAG_SCENE_INFO_OFFSET) || (back.tag == HW_MNOTE_TAG_FACE_INFO_OFFSET)) { if (!ParserIFD((tiff_offset_ + dataOrOffset), back.tag, (deep + 1))) { - HiLog::Error(LABEL, "ParserItem leave, ifd, false"); + IMAGE_LOGE("ParserItem leave, ifd, false"); return false; } } - HiLog::Debug(LABEL, "ParserItem leave"); + IMAGE_LOGD("ParserItem leave"); return true; } @@ -627,7 +631,7 @@ bool ExifMakerNote::GetUInt16(const std::vector &buffer, ExifByte size_t offset, uint16_t &value) { if ((offset + sizeof(uint16_t)) > buffer.size()) { - HiLog::Error(LABEL, "GetUInt16 check error."); + IMAGE_LOGE("GetUInt16 check error."); return false; } value = exif_get_short(buffer.data() + offset, order); @@ -638,7 +642,7 @@ bool ExifMakerNote::GetUInt32(const std::vector &buffer, ExifByte size_t offset, uint32_t &value) { if ((offset + sizeof(uint32_t)) > buffer.size()) { - HiLog::Error(LABEL, "GetUInt32 check error."); + IMAGE_LOGE("GetUInt32 check error."); return false; } value = exif_get_long(buffer.data() + offset, order); @@ -649,13 +653,13 @@ bool ExifMakerNote::GetData(const std::vector &buffer, size_t off std::vector &value) { if ((offset + count) > buffer.size()) { - HiLog::Error(LABEL, "GetData check error."); + IMAGE_LOGE("GetData check error."); return false; } value.resize(count); if (memcpy_s(value.data(), count, buffer.data() + offset, count) != 0) { - HiLog::Error(LABEL, "GetData memcpy error."); + IMAGE_LOGE("GetData memcpy error."); return false; } @@ -671,12 +675,12 @@ std::string ExifMakerNote::Dump(const std::vector &data, uint32_t for (size_t loc = 0, cur = offset; ((loc < sum) && (cur < size)); loc++, cur++) { if (loc == 0) { if (sprintf_s(buffer, sizeof(buffer), "%02X", data[cur]) == -1) { - HiLog::Error(LABEL, "Dump sprintf error."); + IMAGE_LOGE("Dump sprintf error."); break; } } else { if (sprintf_s(buffer, sizeof(buffer), " %02X", data[cur]) == -1) { - HiLog::Error(LABEL, "Dump sprintf error."); + IMAGE_LOGE("Dump sprintf error."); break; } } diff --git a/plugins/common/libs/image/libjpegplugin/src/icc_profile_info.cpp b/plugins/common/libs/image/libjpegplugin/src/icc_profile_info.cpp index ed0be0584..1d5f67f37 100644 --- a/plugins/common/libs/image/libjpegplugin/src/icc_profile_info.cpp +++ b/plugins/common/libs/image/libjpegplugin/src/icc_profile_info.cpp @@ -13,18 +13,25 @@ * limitations under the License. */ #include "icc_profile_info.h" + #include #include #include #include + +#include "image_log.h" #include "securec.h" #include "jerror.h" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "IccProfile" + namespace OHOS { namespace ImagePlugin { namespace { - using namespace OHOS::HiviewDFX; - constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "IccProfile" }; static constexpr uint32_t ICC_MARKER = JPEG_APP0 + 2; static constexpr uint32_t ICC_MARKER_HEADER_SIZE = 14; static constexpr uint8_t ICC_SIGNATURE[] = { @@ -42,7 +49,7 @@ ICCProfileInfo::~ICCProfileInfo() #ifdef IMAGE_COLORSPACE_FLAG sk_sp ICCProfileInfo::GetICCData(j_decompress_ptr cinfo) { - HiLog::Info(LABEL, "%{public}s begin", __func__); + IMAGE_LOGI("%{public}s begin", __func__); unsigned char *icc_profile = NULL; unsigned int icc_data_len = 0; bool isReadIccProfile = false; @@ -52,7 +59,7 @@ sk_sp ICCProfileInfo::GetICCData(j_decompress_ptr cinfo) // copy ICC profile data data = SkData::MakeWithCopy(icc_profile, icc_data_len); } else { - HiLog::Error(LABEL, "ERROR: jpeg_read_icc_profile failed!"); + IMAGE_LOGE("ERROR: jpeg_read_icc_profile failed!"); } // clean up @@ -62,7 +69,7 @@ sk_sp ICCProfileInfo::GetICCData(j_decompress_ptr cinfo) uint32_t ICCProfileInfo::ParsingICCProfile(j_decompress_ptr cinfo) { - HiLog::Info(LABEL, "%{public}s begin", __func__); + IMAGE_LOGI("%{public}s begin", __func__); // read icc data to skdata sk_sp profile = GetICCData(cinfo); @@ -81,7 +88,7 @@ uint32_t ICCProfileInfo::ParsingICCProfile(j_decompress_ptr cinfo) if (skColorSpace != nullptr) { parseResult = OHOS::Media::SUCCESS; } else { - HiLog::Error(LABEL, "ERROR: ParsingICCProfile skColorSpace is Null!"); + IMAGE_LOGE("ERROR: ParsingICCProfile skColorSpace is Null!"); } grColorSpace_ = OHOS::ColorManager::ColorSpace(skColorSpace); return parseResult; @@ -99,7 +106,7 @@ bool ICCProfileInfo::IsSupportICCProfile() uint32_t ICCProfileInfo::PackingICCProfile(j_compress_ptr cinfo, const SkImageInfo& info) { - HiLog::Info(LABEL, "%{public}s begin", __func__); + IMAGE_LOGI("%{public}s begin", __func__); uint32_t packingResult = OHOS::Media::ERR_IMAGE_ENCODE_ICC_FAILED; // write colorspace to SKData @@ -120,7 +127,7 @@ uint32_t ICCProfileInfo::PackingICCProfile(j_compress_ptr cinfo, const SkImageIn jpeg_write_marker(cinfo, ICC_MARKER, jpegMarkerData->bytes(), jpegMarkerData->size()); packingResult = OHOS::Media::SUCCESS; } else { - HiLog::Error(LABEL, "ERROR: PackingICCProfile icc profile is Null!"); + IMAGE_LOGE("ERROR: PackingICCProfile icc profile is Null!"); } return packingResult; } diff --git a/plugins/common/libs/image/libjpegplugin/src/jpeg_decoder.cpp b/plugins/common/libs/image/libjpegplugin/src/jpeg_decoder.cpp index 27763eac1..a822e932c 100644 --- a/plugins/common/libs/image/libjpegplugin/src/jpeg_decoder.cpp +++ b/plugins/common/libs/image/libjpegplugin/src/jpeg_decoder.cpp @@ -16,6 +16,7 @@ #include "jpeg_decoder.h" #include #include "hitrace_meter.h" +#include "image_log.h" #include "image_trace.h" #include "image_utils.h" #include "jerror.h" @@ -31,12 +32,16 @@ #include "memory.h" #endif +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "JpegDecoder" + namespace OHOS { namespace ImagePlugin { -using namespace OHOS::HiviewDFX; using namespace MultimediaPlugin; using namespace Media; -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "JpegDecoder" }; static constexpr uint32_t PL_ICC_MARKER = JPEG_APP0 + 2; static constexpr uint32_t PL_MARKER_LENGTH_LIMIT = 0xFFFF; namespace { @@ -156,7 +161,7 @@ void JpegDecoder::CreateDecoder() decodeInfo_.err = jpeg_std_error(&jerr_); jerr_.error_exit = ErrorExit; if (decodeInfo_.err == nullptr) { - HiLog::Error(LABEL, "create jpeg decoder failed."); + IMAGE_LOGE("create jpeg decoder failed."); return; } decodeInfo_.err->output_message = &OutputErrorMessage; @@ -180,11 +185,11 @@ void JpegDecoder::SetSource(InputDataStream &sourceStream) uint32_t JpegDecoder::GetImageSize(uint32_t index, PlSize &size) { if (index >= JPEG_IMAGE_NUM) { - HiLog::Error(LABEL, "decode image index:[%{public}u] out of range:[%{public}u].", index, JPEG_IMAGE_NUM); + IMAGE_LOGE("decode image index:[%{public}u] out of range:[%{public}u].", index, JPEG_IMAGE_NUM); return ERR_IMAGE_INVALID_PARAMETER; } if (state_ < JpegDecodingState::SOURCE_INITED) { - HiLog::Error(LABEL, "get image size failed for state %{public}d.", state_); + IMAGE_LOGE("get image size failed for state %{public}d.", state_); return ERR_MEDIA_INVALID_OPERATION; } if (state_ >= JpegDecodingState::BASE_INFO_PARSED) { @@ -195,7 +200,7 @@ uint32_t JpegDecoder::GetImageSize(uint32_t index, PlSize &size) // only state JpegDecodingState::SOURCE_INITED and JpegDecodingState::BASE_INFO_PARSING can go here. uint32_t ret = DecodeHeader(); if (ret != Media::SUCCESS) { - HiLog::Error(LABEL, "decode header error on get image size, ret:%{public}u.", ret); + IMAGE_LOGE("decode header error on get image size, ret:%{public}u.", ret); state_ = JpegDecodingState::BASE_INFO_PARSING; return ret; } @@ -302,11 +307,11 @@ static void GetScaledFraction(const int& inSampleSize, jpeg_decompress_struct& d uint32_t JpegDecoder::SetDecodeOptions(uint32_t index, const PixelDecodeOptions &opts, PlImageInfo &info) { if (index >= JPEG_IMAGE_NUM) { - HiLog::Error(LABEL, "decode image index:[%{public}u] out of range:[%{public}u].", index, JPEG_IMAGE_NUM); + IMAGE_LOGE("decode image index:[%{public}u] out of range:[%{public}u].", index, JPEG_IMAGE_NUM); return ERR_IMAGE_INVALID_PARAMETER; } if (state_ < JpegDecodingState::SOURCE_INITED) { - HiLog::Error(LABEL, "set decode options failed for state %{public}d.", state_); + IMAGE_LOGE("set decode options failed for state %{public}d.", state_); return ERR_MEDIA_INVALID_OPERATION; } if (state_ >= JpegDecodingState::IMAGE_DECODING) { @@ -317,7 +322,7 @@ uint32_t JpegDecoder::SetDecodeOptions(uint32_t index, const PixelDecodeOptions uint32_t ret = DecodeHeader(); if (ret != Media::SUCCESS) { state_ = JpegDecodingState::BASE_INFO_PARSING; - HiLog::Error(LABEL, "decode header error on set decode options:%{public}u.", ret); + IMAGE_LOGE("decode header error on set decode options:%{public}u.", ret); return ret; } state_ = JpegDecodingState::BASE_INFO_PARSED; @@ -327,7 +332,7 @@ uint32_t JpegDecoder::SetDecodeOptions(uint32_t index, const PixelDecodeOptions GetScaledFraction(inSampleSize, decodeInfo_); uint32_t ret = StartDecompress(opts); if (ret != Media::SUCCESS) { - HiLog::Error(LABEL, "start decompress failed on set decode options:%{public}u.", ret); + IMAGE_LOGE("start decompress failed on set decode options:%{public}u.", ret); return ret; } info.pixelFormat = outputFormat_; @@ -350,7 +355,7 @@ uint32_t JpegDecoder::DoSwDecode(DecodeContext &context) __attribute__((no_sanit { ImageTrace imageTrace("JpegDecoder::DoSwDecode"); if (setjmp(jerr_.setjmp_buffer)) { - HiLog::Error(LABEL, "decode image failed."); + IMAGE_LOGE("decode image failed."); return ERR_IMAGE_DECODE_ABNORMAL; } uint32_t rowStride = GetRowBytes(); @@ -377,7 +382,7 @@ uint32_t JpegDecoder::DoSwDecode(DecodeContext &context) __attribute__((no_sanit context.pixelsBuffer.buffer = ptr; void *fdBuffer = new int32_t(); if (fdBuffer == nullptr) { - HiLog::Error(LABEL, "new fdBuffer fail"); + IMAGE_LOGE("new fdBuffer fail"); ::munmap(ptr, byteCount); ::close(fd); context.pixelsBuffer.buffer = nullptr; @@ -402,13 +407,13 @@ uint32_t JpegDecoder::DoSwDecode(DecodeContext &context) __attribute__((no_sanit }; GSError ret = sb->Alloc(requestConfig); if (ret != GSERROR_OK) { - HiLog::Error(LABEL, "SurfaceBuffer Alloc failed, %{public}s", GSErrorStr(ret).c_str()); + IMAGE_LOGE("SurfaceBuffer Alloc failed, %{public}s", GSErrorStr(ret).c_str()); return ERR_DMA_NOT_EXIST; } void* nativeBuffer = sb.GetRefPtr(); int32_t err = ImageUtils::SurfaceBuffer_Reference(nativeBuffer); if (err != OHOS::GSERROR_OK) { - HiLog::Error(LABEL, "NativeBufferReference failed"); + IMAGE_LOGE("NativeBufferReference failed"); return ERR_DMA_DATA_ABNORMAL; } @@ -420,8 +425,8 @@ uint32_t JpegDecoder::DoSwDecode(DecodeContext &context) __attribute__((no_sanit } else { void *outputBuffer = malloc(byteCount); if (outputBuffer == nullptr) { - HiLog::Error(LABEL, "alloc output buffer size:[%{public}llu] error.", - static_cast(byteCount)); + IMAGE_LOGE("alloc output buffer size:[%{public}llu] error.", + static_cast(byteCount)); return ERR_IMAGE_MALLOC_ABNORMAL; } context.pixelsBuffer.buffer = outputBuffer; @@ -433,8 +438,7 @@ uint32_t JpegDecoder::DoSwDecode(DecodeContext &context) __attribute__((no_sanit #else void *outputBuffer = malloc(byteCount); if (outputBuffer == nullptr) { - HiLog::Error(LABEL, "alloc output buffer size:[%{public}llu] error.", - static_cast(byteCount)); + IMAGE_LOGE("alloc output buffer size:[%{public}llu] error.", static_cast(byteCount)); return ERR_IMAGE_MALLOC_ABNORMAL; } context.pixelsBuffer.buffer = outputBuffer; @@ -446,7 +450,7 @@ uint32_t JpegDecoder::DoSwDecode(DecodeContext &context) __attribute__((no_sanit } uint8_t *base = static_cast(context.pixelsBuffer.buffer); if (base == nullptr) { - HiLog::Error(LABEL, "decode image buffer is null."); + IMAGE_LOGE("decode image buffer is null."); return ERR_IMAGE_INVALID_PARAMETER; } @@ -471,8 +475,8 @@ uint32_t JpegDecoder::DoSwDecode(DecodeContext &context) __attribute__((no_sanit uint32_t readLineNum = jpeg_read_scanlines(&decodeInfo_, &buffer, RW_LINE_NUM); if (readLineNum < RW_LINE_NUM) { streamPosition_ = srcMgr_.inputStream->Tell(); - HiLog::Error(LABEL, "read line fail, read num:%{public}u, total read num:%{public}u.", readLineNum, - decodeInfo_.output_scanline); + IMAGE_LOGE("read line fail, read num:%{public}u, total read num:%{public}u.", readLineNum, + decodeInfo_.output_scanline); return ERR_IMAGE_SOURCE_DATA_INCOMPLETE; } } @@ -482,7 +486,7 @@ uint32_t JpegDecoder::DoSwDecode(DecodeContext &context) __attribute__((no_sanit // parser icc profile info uint32_t iccPaseredResult = iccProfileInfo_.ParsingICCProfile(&decodeInfo_); if (iccPaseredResult == OHOS::Media::ERR_IMAGE_DENCODE_ICC_FAILED) { - HiLog::Error(LABEL, "dencode image icc error."); + IMAGE_LOGE("dencode image icc error."); return iccPaseredResult; } #endif @@ -492,11 +496,11 @@ uint32_t JpegDecoder::DoSwDecode(DecodeContext &context) __attribute__((no_sanit uint32_t JpegDecoder::Decode(uint32_t index, DecodeContext &context) { if (index >= JPEG_IMAGE_NUM) { - HiLog::Error(LABEL, "decode image index:[%{public}u] out of range:[%{public}u].", index, JPEG_IMAGE_NUM); + IMAGE_LOGE("decode image index:[%{public}u] out of range:[%{public}u].", index, JPEG_IMAGE_NUM); return ERR_IMAGE_INVALID_PARAMETER; } if (state_ < JpegDecodingState::IMAGE_DECODING) { - HiLog::Error(LABEL, "decode failed for state %{public}d.", state_); + IMAGE_LOGE("decode failed for state %{public}d.", state_); return ERR_MEDIA_INVALID_OPERATION; } if (state_ > JpegDecodingState::IMAGE_DECODING) { @@ -505,13 +509,13 @@ uint32_t JpegDecoder::Decode(uint32_t index, DecodeContext &context) uint32_t ret = DecodeHeader(); if (ret != Media::SUCCESS) { state_ = JpegDecodingState::BASE_INFO_PARSING; - HiLog::Error(LABEL, "decode header error on decode:%{public}u.", ret); + IMAGE_LOGE("decode header error on decode:%{public}u.", ret); return ret; } state_ = JpegDecodingState::BASE_INFO_PARSED; ret = StartDecompress(opts_); if (ret != Media::SUCCESS) { - HiLog::Error(LABEL, "start decompress failed on decode:%{public}u.", ret); + IMAGE_LOGE("start decompress failed on decode:%{public}u.", ret); return ret; } state_ = JpegDecodingState::IMAGE_DECODING; @@ -522,14 +526,14 @@ uint32_t JpegDecoder::Decode(uint32_t index, DecodeContext &context) uint32_t ret = hwJpegDecompress_->Decompress(&decodeInfo_, srcMgr_.inputStream, context); if (ret == Media::SUCCESS) { state_ = JpegDecodingState::IMAGE_DECODED; - HiLog::Debug(LABEL, "jpeg hardware decode success."); + IMAGE_LOGD("jpeg hardware decode success."); return ret; } } uint32_t ret = DoSwDecode(context); if (ret == Media::SUCCESS) { state_ = JpegDecodingState::IMAGE_DECODED; - HiLog::Debug(LABEL, "jpeg software decode success."); + IMAGE_LOGD("jpeg software decode success."); return Media::SUCCESS; } if (ret == ERR_IMAGE_SOURCE_DATA_INCOMPLETE && opts_.allowPartialImage) { @@ -550,11 +554,11 @@ uint32_t JpegDecoder::PromoteIncrementalDecode(uint32_t index, ProgDecodeContext { progContext.totalProcessProgress = 0; if (index >= JPEG_IMAGE_NUM) { - HiLog::Error(LABEL, "decode image index:[%{public}u] out of range:[%{public}u].", index, JPEG_IMAGE_NUM); + IMAGE_LOGE("decode image index:[%{public}u] out of range:[%{public}u].", index, JPEG_IMAGE_NUM); return ERR_IMAGE_INVALID_PARAMETER; } if (state_ != JpegDecodingState::IMAGE_DECODING) { - HiLog::Error(LABEL, "incremental decode failed for state %{public}d.", state_); + IMAGE_LOGE("incremental decode failed for state %{public}d.", state_); return ERR_MEDIA_INVALID_OPERATION; } @@ -565,7 +569,7 @@ uint32_t JpegDecoder::PromoteIncrementalDecode(uint32_t index, ProgDecodeContext // get promote decode progress, in percentage: 0~100. progContext.totalProcessProgress = decodeInfo_.output_height == 0 ? 0 : (decodeInfo_.output_scanline * NUM_100) / decodeInfo_.output_height; - HiLog::Debug(LABEL, "incremental decode progress %{public}u.", progContext.totalProcessProgress); + IMAGE_LOGD("incremental decode progress %{public}u.", progContext.totalProcessProgress); return ret; } @@ -577,7 +581,7 @@ void JpegDecoder::CreateHwDecompressor() hwJpegDecompress_ = pluginServer_.CreateObject( AbsImageDecompressComponent::SERVICE_DEFAULT, capabilities); if (hwJpegDecompress_ == nullptr) { - HiLog::Error(LABEL, "get hardware jpeg decompress component failed."); + IMAGE_LOGE("get hardware jpeg decompress component failed."); return; } } @@ -662,7 +666,7 @@ bool JpegDecoder::FindMarker(InputDataStream &stream, uint8_t marker) uint32_t JpegDecoder::DecodeHeader() { if (setjmp(jerr_.setjmp_buffer)) { - HiLog::Error(LABEL, "get image size failed."); + IMAGE_LOGE("get image size failed."); return ERR_IMAGE_DECODE_ABNORMAL; } if (state_ == JpegDecodingState::SOURCE_INITED) { @@ -693,10 +697,10 @@ uint32_t JpegDecoder::DecodeHeader() int32_t ret = jpeg_read_header(&decodeInfo_, true); streamPosition_ = srcMgr_.inputStream->Tell(); if (ret == JPEG_SUSPENDED) { - HiLog::Debug(LABEL, "image input data incomplete, decode header error:%{public}u.", ret); + IMAGE_LOGD("image input data incomplete, decode header error:%{public}u.", ret); return ERR_IMAGE_SOURCE_DATA_INCOMPLETE; } else if (ret != JPEG_HEADER_OK) { - HiLog::Error(LABEL, "image type is not jpeg, decode header error:%{public}u.", ret); + IMAGE_LOGE("image type is not jpeg, decode header error:%{public}u.", ret); return ERR_IMAGE_GET_DATA_ABNORMAL; } return Media::SUCCESS; @@ -705,30 +709,30 @@ uint32_t JpegDecoder::DecodeHeader() uint32_t JpegDecoder::StartDecompress(const PixelDecodeOptions &opts) { if (setjmp(jerr_.setjmp_buffer)) { - HiLog::Error(LABEL, "set output image info failed."); + IMAGE_LOGE("set output image info failed."); return ERR_IMAGE_DECODE_ABNORMAL; } // set decode options if (decodeInfo_.jpeg_color_space == JCS_CMYK || decodeInfo_.jpeg_color_space == JCS_YCCK) { // can't support CMYK to alpha8 convert if (opts.desiredPixelFormat == PlPixelFormat::ALPHA_8) { - HiLog::Error(LABEL, "can't support colorspace CMYK to alpha convert."); + IMAGE_LOGE("can't support colorspace CMYK to alpha convert."); return ERR_IMAGE_UNKNOWN_FORMAT; } - HiLog::Debug(LABEL, "jpeg colorspace is CMYK."); + IMAGE_LOGD("jpeg colorspace is CMYK."); decodeInfo_.out_color_space = JCS_CMYK; outputFormat_ = PlPixelFormat::CMYK; } else { decodeInfo_.out_color_space = GetDecodeFormat(opts.desiredPixelFormat, outputFormat_); if (decodeInfo_.out_color_space == JCS_UNKNOWN) { - HiLog::Error(LABEL, "set jpeg output color space invalid."); + IMAGE_LOGE("set jpeg output color space invalid."); return ERR_IMAGE_UNKNOWN_FORMAT; } } srcMgr_.inputStream->Seek(streamPosition_); if (jpeg_start_decompress(&decodeInfo_) != TRUE) { streamPosition_ = srcMgr_.inputStream->Tell(); - HiLog::Error(LABEL, "jpeg start decompress failed, invalid input."); + IMAGE_LOGE("jpeg start decompress failed, invalid input."); return ERR_IMAGE_INVALID_PARAMETER; } streamPosition_ = srcMgr_.inputStream->Tell(); @@ -737,24 +741,24 @@ uint32_t JpegDecoder::StartDecompress(const PixelDecodeOptions &opts) bool JpegDecoder::ParseExifData() { - HiLog::Debug(LABEL, "ParseExifData enter"); + IMAGE_LOGD("ParseExifData enter"); uint32_t curPos = srcMgr_.inputStream->Tell(); srcMgr_.inputStream->Seek(0); unsigned long fsize = static_cast(srcMgr_.inputStream->GetStreamSize()); if (fsize <= 0) { - HiLog::Error(LABEL, "Get stream size failed"); + IMAGE_LOGE("Get stream size failed"); return false; } unsigned char *buf = new unsigned char[fsize]; uint32_t readSize = 0; srcMgr_.inputStream->Read(fsize, buf, fsize, readSize); - HiLog::Debug(LABEL, "parsing EXIF: fsize %{public}lu", fsize); + IMAGE_LOGD("parsing EXIF: fsize %{public}lu", fsize); int code = exifInfo_.ParseExifData(buf, fsize); delete[] buf; srcMgr_.inputStream->Seek(curPos); if (code) { - HiLog::Error(LABEL, "Error parsing EXIF: code %{public}d", code); + IMAGE_LOGE("Error parsing EXIF: code %{public}d", code); return false; } return true; @@ -762,15 +766,15 @@ bool JpegDecoder::ParseExifData() uint32_t JpegDecoder::GetImagePropertyInt(uint32_t index, const std::string &key, int32_t &value) { - HiLog::Debug(LABEL, "[GetImagePropertyInt] enter jpeg plugin, key:%{public}s", key.c_str()); + IMAGE_LOGD("[GetImagePropertyInt] enter jpeg plugin, key:%{public}s", key.c_str()); if (IsSameTextStr(key, ACTUAL_IMAGE_ENCODED_FORMAT)) { - HiLog::Error(LABEL, "[GetImagePropertyInt] this key is used to check the original format of raw image!"); + IMAGE_LOGE("[GetImagePropertyInt] this key is used to check the original format of raw image!"); return Media::ERR_MEDIA_VALUE_INVALID; } if (!exifInfo_.IsExifDataParsed()) { if (!ParseExifData()) { - HiLog::Error(LABEL, "[GetImagePropertyInt] Parse exif data failed!"); + IMAGE_LOGE("[GetImagePropertyInt] Parse exif data failed!"); return Media::ERROR; } } @@ -778,12 +782,12 @@ uint32_t JpegDecoder::GetImagePropertyInt(uint32_t index, const std::string &key if (PROPERTY_INT.find(exifInfo_.orientation_) != PROPERTY_INT.end()) { value = PROPERTY_INT.at(exifInfo_.orientation_); } else { - HiLog::Error(LABEL, "[GetImagePropertyInt] The exifinfo:%{public}s is not found", + IMAGE_LOGE("[GetImagePropertyInt] The exifinfo:%{public}s is not found", exifInfo_.orientation_.c_str()); return Media::ERR_MEDIA_VALUE_INVALID; } } else { - HiLog::Error(LABEL, "[GetImagePropertyInt] The key:%{public}s is not supported int32_t", key.c_str()); + IMAGE_LOGE("[GetImagePropertyInt] The key:%{public}s is not supported int32_t", key.c_str()); return Media::ERR_MEDIA_VALUE_INVALID; } return Media::SUCCESS; @@ -791,15 +795,14 @@ uint32_t JpegDecoder::GetImagePropertyInt(uint32_t index, const std::string &key uint32_t JpegDecoder::GetImagePropertyString(uint32_t index, const std::string &key, std::string &value) { - HiLog::Debug(LABEL, "[GetImagePropertyString] enter jpeg plugin, key:%{public}s", key.c_str()); + IMAGE_LOGD("[GetImagePropertyString] enter jpeg plugin, key:%{public}s", key.c_str()); if (IsSameTextStr(key, ACTUAL_IMAGE_ENCODED_FORMAT)) { - HiLog::Error(LABEL, - "[GetImagePropertyString] this key is used to check the original format of raw image!"); + IMAGE_LOGE("[GetImagePropertyString] this key is used to check the original format of raw image!"); return Media::ERR_MEDIA_VALUE_INVALID; } if (!exifInfo_.IsExifDataParsed()) { if (!ParseExifData()) { - HiLog::Error(LABEL, "[GetImagePropertyString] Parse exif data failed!"); + IMAGE_LOGE("[GetImagePropertyString] Parse exif data failed!"); return Media::ERROR; } } @@ -827,10 +830,10 @@ uint32_t JpegDecoder::GetImagePropertyString(uint32_t index, const std::string & return Media::ERR_IMAGE_DECODE_EXIF_UNSUPPORT; } if (IsSameTextStr(value, EXIFInfo::DEFAULT_EXIF_VALUE)) { - HiLog::Error(LABEL, "[GetImagePropertyString] enter jpeg plugin, ifd and entry are not matched!"); + IMAGE_LOGE("[GetImagePropertyString] enter jpeg plugin, ifd and entry are not matched!"); return Media::ERR_MEDIA_VALUE_INVALID; } - HiLog::Debug(LABEL, "[GetImagePropertyString] enter jpeg plugin, value:%{public}s", value.c_str()); + IMAGE_LOGD("[GetImagePropertyString] enter jpeg plugin, value:%{public}s", value.c_str()); return Media::SUCCESS; } @@ -1011,7 +1014,7 @@ ExifTag JpegDecoder::getExifTagFromKey(const std::string &key) uint32_t JpegDecoder::ModifyImageProperty(uint32_t index, const std::string &key, const std::string &value, const std::string &path) { - HiLog::Debug(LABEL, "[ModifyImageProperty] with path:%{public}s, key:%{public}s, value:%{public}s", + IMAGE_LOGD("[ModifyImageProperty] with path:%{public}s, key:%{public}s, value:%{public}s", path.c_str(), key.c_str(), value.c_str()); ExifTag tag = getExifTagFromKey(key); if (tag == EXIF_TAG_PRINT_IMAGE_MATCHING) { @@ -1028,7 +1031,7 @@ uint32_t JpegDecoder::ModifyImageProperty(uint32_t index, const std::string &key uint32_t JpegDecoder::ModifyImageProperty(uint32_t index, const std::string &key, const std::string &value, const int fd) { - HiLog::Debug(LABEL, "[ModifyImageProperty] with fd:%{public}d, key:%{public}s, value:%{public}s", + IMAGE_LOGD("[ModifyImageProperty] with fd:%{public}d, key:%{public}s, value:%{public}s", fd, key.c_str(), value.c_str()); ExifTag tag = getExifTagFromKey(key); if (tag == EXIF_TAG_PRINT_IMAGE_MATCHING) { @@ -1045,7 +1048,7 @@ uint32_t JpegDecoder::ModifyImageProperty(uint32_t index, const std::string &key uint32_t JpegDecoder::ModifyImageProperty(uint32_t index, const std::string &key, const std::string &value, uint8_t *data, uint32_t size) { - HiLog::Debug(LABEL, "[ModifyImageProperty] with key:%{public}s, value:%{public}s", + IMAGE_LOGD("[ModifyImageProperty] with key:%{public}s, value:%{public}s", key.c_str(), value.c_str()); ExifTag tag = getExifTagFromKey(key); if (tag == EXIF_TAG_PRINT_IMAGE_MATCHING) { @@ -1061,9 +1064,9 @@ uint32_t JpegDecoder::ModifyImageProperty(uint32_t index, const std::string &key uint32_t JpegDecoder::GetFilterArea(const int &privacyType, std::vector> &ranges) { - HiLog::Debug(LABEL, "[GetFilterArea] with privacyType:%{public}d ", privacyType); + IMAGE_LOGD("[GetFilterArea] with privacyType:%{public}d ", privacyType); if (srcMgr_.inputStream == nullptr) { - HiLog::Error(LABEL, "[GetFilterArea] srcMgr_.inputStream is nullptr."); + IMAGE_LOGE("[GetFilterArea] srcMgr_.inputStream is nullptr."); return Media::ERR_MEDIA_INVALID_OPERATION; } uint32_t curPos = srcMgr_.inputStream->Tell(); @@ -1072,7 +1075,7 @@ uint32_t JpegDecoder::GetFilterArea(const int &privacyType, std::vectorRead(JPEG_APP1_SIZE, app1SizeBuf, JPEG_APP1_SIZE, readSize)) { - HiLog::Error(LABEL, "[GetFilterArea] get app1 size failed."); + IMAGE_LOGE("[GetFilterArea] get app1 size failed."); return Media::ERR_MEDIA_INVALID_OPERATION; } uint32_t app1Size = @@ -1080,7 +1083,7 @@ uint32_t JpegDecoder::GetFilterArea(const int &privacyType, std::vector(srcMgr_.inputStream->GetStreamSize()); if (app1Size > fsize) { - HiLog::Error(LABEL, "[GetFilterArea] file format is illegal."); + IMAGE_LOGE("[GetFilterArea] file format is illegal."); return Media::ERR_MEDIA_INVALID_OPERATION; } @@ -1093,7 +1096,7 @@ uint32_t JpegDecoder::GetFilterArea(const int &privacyType, std::vectorSeek(curPos); if (ret != Media::SUCCESS) { - HiLog::Error(LABEL, "[GetFilterArea]: failed to get area, errno %{public}d", ret); + IMAGE_LOGE("[GetFilterArea]: failed to get area, errno %{public}d", ret); return ret; } return Media::SUCCESS; diff --git a/plugins/common/libs/image/libjpegplugin/src/jpeg_encoder.cpp b/plugins/common/libs/image/libjpegplugin/src/jpeg_encoder.cpp index ff32547b9..bf13df15e 100644 --- a/plugins/common/libs/image/libjpegplugin/src/jpeg_encoder.cpp +++ b/plugins/common/libs/image/libjpegplugin/src/jpeg_encoder.cpp @@ -17,18 +17,22 @@ #ifdef IMAGE_COLORSPACE_FLAG #include "color_space.h" #endif -#include "hilog/log.h" +#include "image_log.h" #include "include/core/SkColorSpace.h" #include "include/core/SkImageInfo.h" #include "jerror.h" -#include "log_tags.h" #include "media_errors.h" #include "pixel_convert.h" #include "src/images/SkImageEncoderFns.h" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "JpegEncoder" + namespace OHOS { namespace ImagePlugin { -using namespace OHOS::HiviewDFX; using namespace MultimediaPlugin; using namespace Media; @@ -49,7 +53,6 @@ constexpr uint8_t INDEX_ZERO = 0; constexpr uint8_t INDEX_ONE = 1; constexpr uint8_t INDEX_TWO = 2; constexpr uint8_t SHIFT_MASK = 1; -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "JpegEncoder" }; JpegDstMgr::JpegDstMgr(OutputDataStream *stream) : outputStream(stream) { @@ -67,7 +70,7 @@ JpegEncoder::JpegEncoder() : dstMgr_(nullptr) encodeInfo_.err = jpeg_std_error(&jerr_); jerr_.error_exit = ErrorExit; if (encodeInfo_.err == nullptr) { - HiLog::Error(LABEL, "create jpeg encoder failed."); + IMAGE_LOGE("create jpeg encoder failed."); return; } encodeInfo_.err->output_message = &OutputErrorMessage; @@ -126,7 +129,7 @@ J_COLOR_SPACE JpegEncoder::GetEncodeFormat(PixelFormat format, int32_t &componen break; } default: { - HiLog::Error(LABEL, "encode format:[%{public}d] is unsupported!", format); + IMAGE_LOGE("encode format:[%{public}d] is unsupported!", format); break; } } @@ -137,7 +140,7 @@ J_COLOR_SPACE JpegEncoder::GetEncodeFormat(PixelFormat format, int32_t &componen uint32_t JpegEncoder::AddImage(Media::PixelMap &pixelMap) { if (pixelMaps_.size() >= JPEG_IMAGE_NUM) { - HiLog::Error(LABEL, "add pixel map out of range:[%{public}u].", JPEG_IMAGE_NUM); + IMAGE_LOGE("add pixel map out of range:[%{public}u].", JPEG_IMAGE_NUM); return ERR_IMAGE_ADD_PIXEL_MAP_FAILED; } pixelMaps_.push_back(&pixelMap); @@ -148,12 +151,12 @@ uint32_t JpegEncoder::FinalizeEncode() { uint32_t errorCode = SetCommonConfig(); if (errorCode != SUCCESS) { - HiLog::Error(LABEL, "set jpeg compress struct failed:%{public}u.", errorCode); + IMAGE_LOGE("set jpeg compress struct failed:%{public}u.", errorCode); return errorCode; } const uint8_t *data = pixelMaps_[0]->GetPixels(); if (data == nullptr) { - HiLog::Error(LABEL, "encode image buffer is null."); + IMAGE_LOGE("encode image buffer is null."); return ERR_IMAGE_INVALID_PARAMETER; } PixelFormat pixelFormat = pixelMaps_[0]->GetPixelFormat(); @@ -167,7 +170,7 @@ uint32_t JpegEncoder::FinalizeEncode() errorCode = SequenceEncoder(data); } if (errorCode != SUCCESS) { - HiLog::Error(LABEL, "encode jpeg failed:%{public}u.", errorCode); + IMAGE_LOGE("encode jpeg failed:%{public}u.", errorCode); } return errorCode; } @@ -175,11 +178,11 @@ uint32_t JpegEncoder::FinalizeEncode() uint32_t JpegEncoder::SetCommonConfig() { if (pixelMaps_.empty()) { - HiLog::Error(LABEL, "encode image failed, no pixel map input."); + IMAGE_LOGE("encode image failed, no pixel map input."); return ERR_IMAGE_INVALID_PARAMETER; } if (setjmp(jerr_.setjmp_buffer)) { - HiLog::Error(LABEL, "encode image error, set config failed."); + IMAGE_LOGE("encode image error, set config failed."); return ERR_IMAGE_ENCODE_FAILED; } encodeInfo_.image_width = pixelMaps_[0]->GetWidth(); @@ -187,12 +190,11 @@ uint32_t JpegEncoder::SetCommonConfig() PixelFormat pixelFormat = pixelMaps_[0]->GetPixelFormat(); encodeInfo_.in_color_space = GetEncodeFormat(pixelFormat, encodeInfo_.input_components); if (encodeInfo_.in_color_space == JCS_UNKNOWN) { - HiLog::Error(LABEL, "set input jpeg color space invalid."); + IMAGE_LOGE("set input jpeg color space invalid."); return ERR_IMAGE_UNKNOWN_FORMAT; } - HiLog::Debug(LABEL, "width=%{public}u, height=%{public}u, colorspace=%{public}d, components=%{public}d.", - encodeInfo_.image_width, encodeInfo_.image_height, encodeInfo_.in_color_space, - encodeInfo_.input_components); + IMAGE_LOGD("width=%{public}u, height=%{public}u, colorspace=%{public}d, components=%{public}d.", + encodeInfo_.image_width, encodeInfo_.image_height, encodeInfo_.in_color_space, encodeInfo_.input_components); jpeg_set_defaults(&encodeInfo_); int32_t quality = encodeOpts_.quality; jpeg_set_quality(&encodeInfo_, quality, TRUE); @@ -202,7 +204,7 @@ uint32_t JpegEncoder::SetCommonConfig() uint32_t JpegEncoder::SequenceEncoder(const uint8_t *data) { if (setjmp(jerr_.setjmp_buffer)) { - HiLog::Error(LABEL, "encode image error."); + IMAGE_LOGE("encode image error."); return ERR_IMAGE_ENCODE_FAILED; } jpeg_start_compress(&encodeInfo_, TRUE); @@ -222,7 +224,7 @@ uint32_t JpegEncoder::SequenceEncoder(const uint8_t *data) skImageInfo = SkImageInfo::Make(width, height, ct, at, skColorSpace); uint32_t iccPackedresult = iccProfileInfo_.PackingICCProfile(&encodeInfo_, skImageInfo); if (iccPackedresult == OHOS::Media::ERR_IMAGE_ENCODE_ICC_FAILED) { - HiLog::Error(LABEL, "encode image icc error."); + IMAGE_LOGE("encode image icc error."); return iccPackedresult; } } @@ -266,12 +268,12 @@ uint32_t JpegEncoder::Yuv420spEncoder(const uint8_t *data) uint8_t *uvPlane = const_cast(data + yPlaneSize); auto uPlane = std::make_unique((width >> SHIFT_MASK) * UV_SAMPLE_ROW); if (uPlane == nullptr) { - HiLog::Error(LABEL, "allocate uPlane memory failed."); + IMAGE_LOGE("allocate uPlane memory failed."); return ERR_IMAGE_MALLOC_ABNORMAL; } auto vPlane = std::make_unique((width >> SHIFT_MASK) * UV_SAMPLE_ROW); if (vPlane == nullptr) { - HiLog::Error(LABEL, "allocate vPlane memory failed."); + IMAGE_LOGE("allocate vPlane memory failed."); return ERR_IMAGE_MALLOC_ABNORMAL; } while (encodeInfo_.next_scanline < height) { @@ -320,7 +322,7 @@ void JpegEncoder::Deinterweave(uint8_t *uvPlane, uint8_t *uPlane, uint8_t *vPlan uint32_t JpegEncoder::RGBAF16Encoder(const uint8_t *data) { if (setjmp(jerr_.setjmp_buffer)) { - HiLog::Error(LABEL, "encode image error."); + IMAGE_LOGE("encode image error."); return ERR_IMAGE_ENCODE_FAILED; } jpeg_start_compress(&encodeInfo_, TRUE); @@ -344,9 +346,9 @@ uint32_t JpegEncoder::RGBAF16Encoder(const uint8_t *data) uint32_t JpegEncoder::RGB565Encoder(const uint8_t *data) { - HiLog::Debug(LABEL, "RGB565Encoder IN."); + IMAGE_LOGD("RGB565Encoder IN."); if (setjmp(jerr_.setjmp_buffer)) { - HiLog::Error(LABEL, "encode image error."); + IMAGE_LOGE("encode image error."); return ERR_IMAGE_ENCODE_FAILED; } @@ -375,7 +377,7 @@ uint32_t JpegEncoder::RGB565Encoder(const uint8_t *data) } jpeg_finish_compress(&encodeInfo_); - HiLog::Debug(LABEL, "RGB565Encoder OUT."); + IMAGE_LOGD("RGB565Encoder OUT."); return SUCCESS; } diff --git a/plugins/common/libs/image/libjpegplugin/src/jpeg_utils.cpp b/plugins/common/libs/image/libjpegplugin/src/jpeg_utils.cpp index 15514ad88..66dfad4b7 100644 --- a/plugins/common/libs/image/libjpegplugin/src/jpeg_utils.cpp +++ b/plugins/common/libs/image/libjpegplugin/src/jpeg_utils.cpp @@ -15,15 +15,17 @@ #include "jpeg_utils.h" -#include "hilog/log.h" -#include "log_tags.h" +#include "image_log.h" #include "securec.h" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "JpegUtils" + namespace OHOS { namespace ImagePlugin { -using namespace OHOS::HiviewDFX; - -static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "JpegUtils" }; // these functions are called by libjpeg-turbo third_party library, no need check input parameter. // for error manager @@ -46,7 +48,7 @@ void OutputErrorMessage(j_common_ptr dinfo) } char buffer[JMSG_LENGTH_MAX] = { 0 }; dinfo->err->format_message(dinfo, buffer); - HiLog::Error(LABEL, "libjpeg error %{public}d <%{public}s>.", dinfo->err->msg_code, buffer); + IMAGE_LOGE("libjpeg error %{public}d <%{public}s>.", dinfo->err->msg_code, buffer); } // for source manager @@ -54,7 +56,7 @@ void OutputErrorMessage(j_common_ptr dinfo) void InitSrcStream(j_decompress_ptr dinfo) __attribute__((no_sanitize("cfi"))) { if ((dinfo == nullptr) || (dinfo->src == nullptr)) { - HiLog::Error(LABEL, "init source stream error."); + IMAGE_LOGE("init source stream error."); return; } JpegSrcMgr *src = static_cast(dinfo->src); @@ -66,12 +68,12 @@ void InitSrcStream(j_decompress_ptr dinfo) __attribute__((no_sanitize("cfi"))) boolean FillInputBuffer(j_decompress_ptr dinfo) { if (dinfo == nullptr) { - HiLog::Error(LABEL, "fill input buffer error, decompress struct is null."); + IMAGE_LOGE("fill input buffer error, decompress struct is null."); return FALSE; } JpegSrcMgr *src = static_cast(dinfo->src); if ((src == nullptr) || (src->inputStream == nullptr)) { - HiLog::Error(LABEL, "fill input buffer error, source stream is null."); + IMAGE_LOGE("fill input buffer error, source stream is null."); ERREXIT(dinfo, JERR_FILE_READ); return FALSE; } @@ -82,14 +84,14 @@ boolean FillInputBuffer(j_decompress_ptr dinfo) } src->inputStream->Seek(preReadPos); if (!src->inputStream->Read(src->bufferSize, src->streamData)) { - HiLog::Error(LABEL, "fill input buffer error, read source stream failed."); + IMAGE_LOGE("fill input buffer error, read source stream failed."); return FALSE; } if (!src->inputStream->IsStreamCompleted() && src->streamData.dataSize < JPEG_BUFFER_SIZE) { uint32_t curr = src->inputStream->Tell(); src->inputStream->Seek(curr - src->streamData.dataSize); - HiLog::Debug(LABEL, "fill input buffer seekTo=%{public}u, rewindSize=%{public}u.", - curr - src->streamData.dataSize, src->streamData.dataSize); + IMAGE_LOGD("fill input buffer seekTo=%{public}u, rewindSize=%{public}u.", + curr - src->streamData.dataSize, src->streamData.dataSize); return FALSE; } src->next_input_byte = src->streamData.inputStreamBuffer; @@ -101,12 +103,12 @@ boolean FillInputBuffer(j_decompress_ptr dinfo) void SkipInputData(j_decompress_ptr dinfo, long numBytes) { if (dinfo == nullptr) { - HiLog::Error(LABEL, "skip input buffer error, decompress struct is null."); + IMAGE_LOGE("skip input buffer error, decompress struct is null."); return; } JpegSrcMgr *src = static_cast(dinfo->src); if ((src == nullptr) || (src->inputStream == nullptr)) { - HiLog::Error(LABEL, "skip input buffer error, source stream is null."); + IMAGE_LOGE("skip input buffer error, source stream is null."); ERREXIT(dinfo, JERR_FILE_READ); return; } @@ -115,11 +117,11 @@ void SkipInputData(j_decompress_ptr dinfo, long numBytes) size_t bytesToSkip = bytes - src->bytes_in_buffer; uint32_t nowOffset = src->inputStream->Tell(); if (bytesToSkip > src->inputStream->GetStreamSize() - nowOffset) { - HiLog::Error(LABEL, "skip data:%{public}zu larger than current offset:%{public}u.", bytesToSkip, nowOffset); + IMAGE_LOGE("skip data:%{public}zu larger than current offset:%{public}u.", bytesToSkip, nowOffset); return; } if (!src->inputStream->Seek(nowOffset + bytesToSkip)) { - HiLog::Error(LABEL, "skip data:%{public}zu fail, current offset:%{public}u.", bytesToSkip, nowOffset); + IMAGE_LOGE("skip data:%{public}zu fail, current offset:%{public}u.", bytesToSkip, nowOffset); ERREXIT(dinfo, JERR_FILE_READ); return; } @@ -140,7 +142,7 @@ void TermSrcStream(j_decompress_ptr dinfo) void InitDstStream(j_compress_ptr cinfo) { if ((cinfo == nullptr) || (cinfo->dest == nullptr)) { - HiLog::Error(LABEL, "init destination stream error."); + IMAGE_LOGE("init destination stream error."); return; } JpegDstMgr *dest = static_cast(cinfo->dest); @@ -152,17 +154,17 @@ void InitDstStream(j_compress_ptr cinfo) boolean EmptyOutputBuffer(j_compress_ptr cinfo) { if (cinfo == nullptr) { - HiLog::Error(LABEL, "write output buffer error, compress struct is null."); + IMAGE_LOGE("write output buffer error, compress struct is null."); return FALSE; } JpegDstMgr *dest = static_cast(cinfo->dest); if ((dest == nullptr) || (dest->outputStream == nullptr)) { - HiLog::Error(LABEL, "write output buffer error, dest stream is null."); + IMAGE_LOGE("write output buffer error, dest stream is null."); ERREXIT(cinfo, JERR_FILE_WRITE); return FALSE; } if (!dest->outputStream->Write(dest->buffer, dest->bufferSize)) { - HiLog::Error(LABEL, "write output buffer error, write dest stream failed."); + IMAGE_LOGE("write output buffer error, write dest stream failed."); ERREXIT(cinfo, JERR_FILE_WRITE); return FALSE; } @@ -175,19 +177,19 @@ boolean EmptyOutputBuffer(j_compress_ptr cinfo) void TermDstStream(j_compress_ptr cinfo) { if (cinfo == nullptr) { - HiLog::Error(LABEL, "term output buffer error, compress struct is null."); + IMAGE_LOGE("term output buffer error, compress struct is null."); return; } JpegDstMgr *dest = static_cast(cinfo->dest); if ((dest == nullptr) || (dest->outputStream == nullptr)) { - HiLog::Error(LABEL, "term output buffer error, dest stream is null."); + IMAGE_LOGE("term output buffer error, dest stream is null."); ERREXIT(cinfo, JERR_FILE_WRITE); return; } size_t size = dest->bufferSize - dest->free_in_buffer; if (size > 0) { if (!dest->outputStream->Write(dest->buffer, size)) { - HiLog::Error(LABEL, "term output buffer error, write dest stream size:%{public}zu failed.", size); + IMAGE_LOGE("term output buffer error, write dest stream size:%{public}zu failed.", size); ERREXIT(cinfo, JERR_FILE_WRITE); return; } diff --git a/plugins/common/libs/image/libjpegplugin/src/plugin_export.cpp b/plugins/common/libs/image/libjpegplugin/src/plugin_export.cpp index fd9a7c498..91d75a80f 100644 --- a/plugins/common/libs/image/libjpegplugin/src/plugin_export.cpp +++ b/plugins/common/libs/image/libjpegplugin/src/plugin_export.cpp @@ -14,11 +14,16 @@ */ #include "plugin_export.h" -#include "hilog/log.h" +#include "image_log.h" #include "plugin_utils.h" #include "jpeg_decoder.h" #include "jpeg_encoder.h" -#include "log_tags.h" + +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "LibJpegPlugin" // plugin package name same as metadata. namespace { @@ -34,31 +39,25 @@ PLUGIN_EXPORT_REGISTER_CLASS(OHOS::ImagePlugin::JpegEncoder) PLUGIN_EXPORT_REGISTER_CLASS_END using std::string; -using namespace OHOS::HiviewDFX; - -static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "LibJpegPlugin" }; - -#define PLUGIN_LOG_D(...) HiLog::Debug(LABEL, __VA_ARGS__) -#define PLUGIN_LOG_E(...) HiLog::Error(LABEL, __VA_ARGS__) // define the external interface of this plugin. PLUGIN_EXPORT_DEFAULT_EXTERNAL_START() PLUGIN_EXPORT_DEFAULT_EXTERNAL_STOP() OHOS::MultimediaPlugin::PluginClassBase *PluginExternalCreate(const string &className) { - HiLog::Debug(LABEL, "PluginExternalCreate: create object for package: %{public}s, class: %{public}s.", + IMAGE_LOGD("PluginExternalCreate: create object for package: %{public}s, class: %{public}s.", PACKAGE_NAME.c_str(), className.c_str()); auto iter = implClassMap.find(className); if (iter == implClassMap.end()) { - HiLog::Error(LABEL, "PluginExternalCreate: failed to find class: %{public}s, in package: %{public}s.", + IMAGE_LOGE("PluginExternalCreate: failed to find class: %{public}s, in package: %{public}s.", className.c_str(), PACKAGE_NAME.c_str()); return nullptr; } auto creator = iter->second; if (creator == nullptr) { - HiLog::Error(LABEL, "PluginExternalCreate: null creator for class: %{public}s, in package: %{public}s.", + IMAGE_LOGE("PluginExternalCreate: null creator for class: %{public}s, in package: %{public}s.", className.c_str(), PACKAGE_NAME.c_str()); return nullptr; } diff --git a/plugins/common/libs/image/libpngplugin/src/nine_patch_listener.cpp b/plugins/common/libs/image/libpngplugin/src/nine_patch_listener.cpp index 4d79424ed..3a3ee015b 100644 --- a/plugins/common/libs/image/libpngplugin/src/nine_patch_listener.cpp +++ b/plugins/common/libs/image/libpngplugin/src/nine_patch_listener.cpp @@ -14,21 +14,24 @@ */ #include "nine_patch_listener.h" -#include #include -#include "hilog/log.h" +#include "image_log.h" #ifndef _WIN32 #include "securec.h" #else #include "memory.h" #endif +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "NinePatchListener" + namespace OHOS { namespace ImagePlugin { -using namespace OHOS::HiviewDFX; namespace { -constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "NinePatchListener" }; const std::string CHUNK_NAME = "npTc"; constexpr float FLOAT_NEAR_ZERO = (1.0f / (1 << 12)); constexpr float FHALF = 0.5f; @@ -61,24 +64,24 @@ bool NinePatchListener::ReadChunk(const std::string &tag, void *data, size_t len { if (tag == CHUNK_NAME && length >= sizeof(PngNinePatchRes)) { if (data == nullptr) { - HiLog::Error(LABEL, "data is null"); + IMAGE_LOGE("data is null"); return false; } PngNinePatchRes *patch = static_cast(data); size_t patchSize = patch->SerializedSize(); if (length != patchSize) { - HiLog::Error(LABEL, "length(%{public}zu) not equals patchSize(%{public}zu)", length, patchSize); + IMAGE_LOGE("length(%{public}zu) not equals patchSize(%{public}zu)", length, patchSize); return false; } // copy the data because it is owned by the png reader PngNinePatchRes *patchNew = static_cast(malloc(patchSize)); if (patchNew == nullptr) { - HiLog::Error(LABEL, "malloc failed"); + IMAGE_LOGE("malloc failed"); return false; } errno_t err = memcpy_s(patchNew, patchSize, patch, patchSize); if (err != EOK) { - HiLog::Error(LABEL, "memcpy failed. errno:%{public}d", err); + IMAGE_LOGE("memcpy failed. errno:%{public}d", err); free(patchNew); patchNew = nullptr; return false; @@ -98,7 +101,7 @@ bool NinePatchListener::ReadChunk(const std::string &tag, void *data, size_t len void NinePatchListener::Scale(float scaleX, float scaleY, int32_t scaledWidth, int32_t scaledHeight) { if (patch_ == nullptr) { - HiLog::Error(LABEL, "patch is null"); + IMAGE_LOGE("patch is null"); return; } diff --git a/plugins/common/libs/image/libpngplugin/src/plugin_export.cpp b/plugins/common/libs/image/libpngplugin/src/plugin_export.cpp index 1be1a31d8..d21df139c 100644 --- a/plugins/common/libs/image/libpngplugin/src/plugin_export.cpp +++ b/plugins/common/libs/image/libpngplugin/src/plugin_export.cpp @@ -14,11 +14,16 @@ */ #include "plugin_export.h" -#include "hilog/log.h" -#include "log_tags.h" +#include "image_log.h" #include "plugin_utils.h" #include "png_decoder.h" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "LibPngPlugin" + // plugin package name same as metadata. namespace { const std::string PACKAGE_NAME = ("LibPngPlugin"); @@ -30,31 +35,25 @@ PLUGIN_EXPORT_REGISTER_CLASS(OHOS::ImagePlugin::PngDecoder) PLUGIN_EXPORT_REGISTER_CLASS_END using std::string; -using namespace OHOS::HiviewDFX; - -static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "LibPngPlugin" }; - -#define PLUGIN_LOG_D(...) HiLog::Debug(LABEL, __VA_ARGS__) -#define PLUGIN_LOG_E(...) HiLog::Error(LABEL, __VA_ARGS__) // define the external interface of this plugin. PLUGIN_EXPORT_DEFAULT_EXTERNAL_START() PLUGIN_EXPORT_DEFAULT_EXTERNAL_STOP() OHOS::MultimediaPlugin::PluginClassBase *PluginExternalCreate(const string &className) { - HiLog::Debug(LABEL, "PluginExternalCreate: create object for package: %{public}s, class: %{public}s.", + IMAGE_LOGD("PluginExternalCreate: create object for package: %{public}s, class: %{public}s.", PACKAGE_NAME.c_str(), className.c_str()); auto iter = implClassMap.find(className); if (iter == implClassMap.end()) { - HiLog::Error(LABEL, "PluginExternalCreate: failed to find class: %{public}s, in package: %{public}s.", + IMAGE_LOGE("PluginExternalCreate: failed to find class: %{public}s, in package: %{public}s.", className.c_str(), PACKAGE_NAME.c_str()); return nullptr; } auto creator = iter->second; if (creator == nullptr) { - HiLog::Error(LABEL, "PluginExternalCreate: null creator for class: %{public}s, in package: %{public}s.", + IMAGE_LOGE("PluginExternalCreate: null creator for class: %{public}s, in package: %{public}s.", className.c_str(), PACKAGE_NAME.c_str()); return nullptr; } diff --git a/plugins/common/libs/image/libpngplugin/src/png_decoder.cpp b/plugins/common/libs/image/libpngplugin/src/png_decoder.cpp index bb163b786..da831f64e 100644 --- a/plugins/common/libs/image/libpngplugin/src/png_decoder.cpp +++ b/plugins/common/libs/image/libpngplugin/src/png_decoder.cpp @@ -15,9 +15,8 @@ #include "png_decoder.h" -#include "hilog/log.h" +#include "image_log.h" #include "image_utils.h" -#include "log_tags.h" #include "media_errors.h" #include "pngpriv.h" #include "pngstruct.h" @@ -31,12 +30,16 @@ #include "memory.h" #endif +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "PngDecoder" + namespace OHOS { namespace ImagePlugin { -using namespace OHOS::HiviewDFX; using namespace MultimediaPlugin; using namespace Media; -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "PngDecoder" }; static constexpr uint32_t PNG_IMAGE_NUM = 1; static constexpr int SET_JUMP_VALUE = 1; static constexpr int BITDEPTH_VALUE_1 = 1; @@ -52,7 +55,7 @@ static constexpr int PNG_HEAD_SIZE = 100; PngDecoder::PngDecoder() { if (!InitPnglib()) { - HiLog::Error(LABEL, "Png decoder init failed!"); + IMAGE_LOGE("Png decoder init failed!"); } } @@ -76,15 +79,15 @@ uint32_t PngDecoder::GetImageSize(uint32_t index, PlSize &size) { // PNG format only supports one picture decoding, index in order to Compatible animation scene. if (index >= PNG_IMAGE_NUM) { - HiLog::Error(LABEL, "decode image out of range, index:%{public}u, range:%{public}u.", index, PNG_IMAGE_NUM); + IMAGE_LOGE("decode image out of range, index:%{public}u, range:%{public}u.", index, PNG_IMAGE_NUM); return ERR_IMAGE_INVALID_PARAMETER; } if (pngStructPtr_ == nullptr || pngInfoPtr_ == nullptr) { - HiLog::Error(LABEL, "create Png Struct or Png Info failed!"); + IMAGE_LOGE("create Png Struct or Png Info failed!"); return ERR_IMAGE_INIT_ABNORMAL; } if (state_ < PngDecodingState::SOURCE_INITED) { - HiLog::Error(LABEL, "get image size failed for state %{public}d.", state_); + IMAGE_LOGE("get image size failed for state %{public}d.", state_); return ERR_MEDIA_INVALID_OPERATION; } if (state_ >= PngDecodingState::BASE_INFO_PARSED) { @@ -95,7 +98,7 @@ uint32_t PngDecoder::GetImageSize(uint32_t index, PlSize &size) // only state PngDecodingState::SOURCE_INITED and PngDecodingState::BASE_INFO_PARSING can go here. uint32_t ret = DecodeHeader(); if (ret != SUCCESS) { - HiLog::Debug(LABEL, "decode header error on get image ret:%{public}u.", ret); + IMAGE_LOGD("decode header error on get image ret:%{public}u.", ret); return ret; } size.width = png_get_image_width(pngStructPtr_, pngInfoPtr_); @@ -107,27 +110,27 @@ uint32_t PngDecoder::SetDecodeOptions(uint32_t index, const PixelDecodeOptions & { // PNG format only supports one picture decoding, index in order to Compatible animation scene. if (index >= PNG_IMAGE_NUM) { - HiLog::Error(LABEL, "decode image out of range, index:%{public}u, range:%{public}u.", index, PNG_IMAGE_NUM); + IMAGE_LOGE("decode image out of range, index:%{public}u, range:%{public}u.", index, PNG_IMAGE_NUM); return ERR_IMAGE_INVALID_PARAMETER; } if (pngStructPtr_ == nullptr || pngInfoPtr_ == nullptr) { - HiLog::Error(LABEL, "Png init fail, can't set decode option."); + IMAGE_LOGE("Png init fail, can't set decode option."); return ERR_IMAGE_INIT_ABNORMAL; } if (state_ < PngDecodingState::SOURCE_INITED) { - HiLog::Error(LABEL, "set decode options failed for state %{public}d.", state_); + IMAGE_LOGE("set decode options failed for state %{public}d.", state_); return ERR_MEDIA_INVALID_OPERATION; } if (state_ >= PngDecodingState::IMAGE_DECODING) { if (!FinishOldDecompress()) { - HiLog::Error(LABEL, "finish old decompress fail, can't set decode option."); + IMAGE_LOGE("finish old decompress fail, can't set decode option."); return ERR_IMAGE_INIT_ABNORMAL; } } if (state_ < PngDecodingState::BASE_INFO_PARSED) { uint32_t ret = DecodeHeader(); if (ret != SUCCESS) { - HiLog::Error(LABEL, "decode header error on set decode options:%{public}u.", ret); + IMAGE_LOGE("decode header error on set decode options:%{public}u.", ret); return ret; } } @@ -136,7 +139,7 @@ uint32_t PngDecoder::SetDecodeOptions(uint32_t index, const PixelDecodeOptions & // only state PngDecodingState::BASE_INFO_PARSED can go here. uint32_t ret = ConfigInfo(opts); if (ret != SUCCESS) { - HiLog::Error(LABEL, "config decoding failed on set decode options:%{public}u.", ret); + IMAGE_LOGE("config decoding failed on set decode options:%{public}u.", ret); return ret; } info.size.width = pngImageInfo_.width; @@ -160,30 +163,30 @@ uint32_t PngDecoder::Decode(uint32_t index, DecodeContext &context) { // PNG format only supports one picture decoding, index in order to Compatible animation scene. if (index >= PNG_IMAGE_NUM) { - HiLog::Error(LABEL, "decode image out of range, index:%{public}u, range:%{public}u.", index, PNG_IMAGE_NUM); + IMAGE_LOGE("decode image out of range, index:%{public}u, range:%{public}u.", index, PNG_IMAGE_NUM); return ERR_IMAGE_INVALID_PARAMETER; } if (pngStructPtr_ == nullptr || pngInfoPtr_ == nullptr) { - HiLog::Error(LABEL, "Png init failed can't begin to decode."); + IMAGE_LOGE("Png init failed can't begin to decode."); return ERR_IMAGE_INIT_ABNORMAL; } if (state_ < PngDecodingState::IMAGE_DECODING) { - HiLog::Error(LABEL, "decode failed for state %{public}d.", state_); + IMAGE_LOGE("decode failed for state %{public}d.", state_); return ERR_MEDIA_INVALID_OPERATION; } if (state_ > PngDecodingState::IMAGE_DECODING) { if (!FinishOldDecompress()) { - HiLog::Error(LABEL, "finish old decompress fail on decode."); + IMAGE_LOGE("finish old decompress fail on decode."); return ERR_IMAGE_INIT_ABNORMAL; } uint32_t ret = DecodeHeader(); if (ret != SUCCESS) { - HiLog::Error(LABEL, "decode header error on decode:%{public}u.", ret); + IMAGE_LOGE("decode header error on decode:%{public}u.", ret); return ret; } ret = ConfigInfo(opts_); if (ret != SUCCESS) { - HiLog::Error(LABEL, "config decoding info failed on decode:%{public}u.", ret); + IMAGE_LOGE("config decoding info failed on decode:%{public}u.", ret); return ret; } state_ = PngDecodingState::IMAGE_DECODING; @@ -199,7 +202,7 @@ uint32_t PngDecoder::Decode(uint32_t index, DecodeContext &context) if (ret == ERR_IMAGE_SOURCE_DATA_INCOMPLETE && opts_.allowPartialImage) { state_ = PngDecodingState::IMAGE_PARTIAL; context.ifPartialOutput = true; - HiLog::Error(LABEL, "this is partial image data to decode, ret:%{public}u.", ret); + IMAGE_LOGE("this is partial image data to decode, ret:%{public}u.", ret); return SUCCESS; } state_ = PngDecodingState::IMAGE_ERROR; @@ -210,7 +213,7 @@ uint32_t PngDecoder::Decode(uint32_t index, DecodeContext &context) bool AllocBufferForShareType(DecodeContext &context, uint64_t byteCount) { if (byteCount == 0) { - HiLog::Error(LABEL, "alloc output buffer size: 0 error."); + IMAGE_LOGE("alloc output buffer size: 0 error."); return false; } uint32_t id = context.pixelmapUniqueId_; @@ -232,7 +235,7 @@ bool AllocBufferForShareType(DecodeContext &context, uint64_t byteCount) context.pixelsBuffer.buffer = ptr; void *fdBuffer = new int32_t(); if (fdBuffer == nullptr) { - HiLog::Error(LABEL, "new fdBuffer fail"); + IMAGE_LOGE("new fdBuffer fail"); ::munmap(ptr, byteCount); ::close(fd); context.pixelsBuffer.buffer = nullptr; @@ -261,13 +264,13 @@ bool AllocBufferForDmaType(DecodeContext &context, uint64_t byteCount, PngImageI }; GSError ret = sb->Alloc(requestConfig); if (ret != GSERROR_OK) { - HiLog::Error(LABEL, "SurfaceBuffer Alloc failed, %{public}s", GSErrorStr(ret).c_str()); + IMAGE_LOGE("SurfaceBuffer Alloc failed, %{public}s", GSErrorStr(ret).c_str()); return false; } void* nativeBuffer = sb.GetRefPtr(); int32_t err = ImageUtils::SurfaceBuffer_Reference(nativeBuffer); if (err != OHOS::GSERROR_OK) { - HiLog::Error(LABEL, "NativeBufferReference failed"); + IMAGE_LOGE("NativeBufferReference failed"); return false; } @@ -282,26 +285,25 @@ bool AllocBufferForDmaType(DecodeContext &context, uint64_t byteCount, PngImageI bool AllocOutBuffer(DecodeContext &context, uint64_t byteCount) { if (byteCount == 0) { - HiLog::Error(LABEL, "alloc output buffer size: 0 error."); + IMAGE_LOGE("alloc output buffer size: 0 error."); return false; } void *outputBuffer = malloc(byteCount); if (outputBuffer == nullptr) { - HiLog::Error(LABEL, "alloc output buffer size:[%{public}llu] error.", - static_cast(byteCount)); + IMAGE_LOGE("alloc output buffer size:[%{public}llu] error.", static_cast(byteCount)); return false; } #ifdef _WIN32 errno_t backRet = memset_s(outputBuffer, 0, byteCount); if (backRet != EOK) { - HiLog::Error(LABEL, "init output buffer fail.", backRet); + IMAGE_LOGE("init output buffer fail.", backRet); free(outputBuffer); outputBuffer = nullptr; return false; } #else if (memset_s(outputBuffer, byteCount, 0, byteCount) != EOK) { - HiLog::Error(LABEL, "init output buffer fail."); + IMAGE_LOGE("init output buffer fail."); free(outputBuffer); outputBuffer = nullptr; return false; @@ -319,26 +321,25 @@ bool AllocOutBuffer(DecodeContext &context, uint64_t byteCount) bool AllocBufferForPlatform(DecodeContext &context, uint64_t byteCount) { if (byteCount == 0) { - HiLog::Error(LABEL, "alloc output buffer size: 0 error."); + IMAGE_LOGE("alloc output buffer size: 0 error."); return false; } void *outputBuffer = malloc(byteCount); if (outputBuffer == nullptr) { - HiLog::Error(LABEL, "alloc output buffer size:[%{public}llu] error.", - static_cast(byteCount)); + IMAGE_LOGE("alloc output buffer size:[%{public}llu] error.", static_cast(byteCount)); return false; } #ifdef _WIN32 errno_t backRet = memset_s(outputBuffer, 0, byteCount); if (backRet != EOK) { - HiLog::Error(LABEL, "init output buffer fail.", backRet); + IMAGE_LOGE("init output buffer fail.", backRet); free(outputBuffer); outputBuffer = nullptr; return false; } #else if (memset_s(outputBuffer, byteCount, 0, byteCount) != EOK) { - HiLog::Error(LABEL, "init output buffer fail."); + IMAGE_LOGE("init output buffer fail."); free(outputBuffer); outputBuffer = nullptr; return false; @@ -359,23 +360,23 @@ uint8_t *PngDecoder::AllocOutputBuffer(DecodeContext &context) #if !defined(_WIN32) && !defined(_APPLE) && !defined(A_PLATFORM) && !defined(IOS_PLATFORM) if (context.allocatorType == Media::AllocatorType::SHARE_MEM_ALLOC) { if (!AllocBufferForShareType(context, byteCount)) { - HiLog::Error(LABEL, "alloc output buffer for SHARE_MEM_ALLOC error."); + IMAGE_LOGE("alloc output buffer for SHARE_MEM_ALLOC error."); return nullptr; } } else if (context.allocatorType == Media::AllocatorType::DMA_ALLOC) { if (!AllocBufferForDmaType(context, byteCount, pngImageInfo_)) { - HiLog::Error(LABEL, "alloc output buffer for DMA_ALLOC error."); + IMAGE_LOGE("alloc output buffer for DMA_ALLOC error."); return nullptr; } } else { if (!AllocOutBuffer(context, byteCount)) { - HiLog::Error(LABEL, "alloc output buffer for DMA_ALLOC error."); + IMAGE_LOGE("alloc output buffer for DMA_ALLOC error."); return nullptr; } } #else if (!AllocBufferForPlatform(context, byteCount)) { - HiLog::Error(LABEL, "alloc output buffer for SHARE_MEM_ALLOC error."); + IMAGE_LOGE("alloc output buffer for SHARE_MEM_ALLOC error."); return nullptr; } #endif @@ -388,21 +389,21 @@ uint32_t PngDecoder::PromoteIncrementalDecode(uint32_t index, ProgDecodeContext // PNG format only supports one picture decoding, index in order to Compatible animation scene. context.totalProcessProgress = 0; if (index >= PNG_IMAGE_NUM) { - HiLog::Error(LABEL, "decode image out of range, index:%{public}u, range:%{public}u.", index, PNG_IMAGE_NUM); + IMAGE_LOGE("decode image out of range, index:%{public}u, range:%{public}u.", index, PNG_IMAGE_NUM); return ERR_IMAGE_INVALID_PARAMETER; } if (pngStructPtr_ == nullptr || pngInfoPtr_ == nullptr) { - HiLog::Error(LABEL, "Png init failed can't begin to decode."); + IMAGE_LOGE("Png init failed can't begin to decode."); return ERR_IMAGE_INIT_ABNORMAL; } if (state_ != PngDecodingState::IMAGE_DECODING) { - HiLog::Error(LABEL, "incremental decode failed for state %{public}d.", state_); + IMAGE_LOGE("incremental decode failed for state %{public}d.", state_); return ERR_MEDIA_INVALID_OPERATION; } pixelsData_ = AllocOutputBuffer(context.decodeContext); if (pixelsData_ == nullptr) { - HiLog::Error(LABEL, "get pixels memory fail."); + IMAGE_LOGE("get pixels memory fail."); return ERR_IMAGE_MALLOC_ABNORMAL; } inputStreamPtr_->Seek(streamPosition_); @@ -410,12 +411,12 @@ uint32_t PngDecoder::PromoteIncrementalDecode(uint32_t index, ProgDecodeContext streamPosition_ = inputStreamPtr_->Tell(); if (ret != SUCCESS) { if (ret != ERR_IMAGE_SOURCE_DATA_INCOMPLETE) { - HiLog::Error(LABEL, "Incremental decode fail, ret:%{public}u", ret); + IMAGE_LOGE("Incremental decode fail, ret:%{public}u", ret); } } else { if (outputRowsNum_ != pngImageInfo_.height) { - HiLog::Debug(LABEL, "Incremental decode incomplete, outputRowsNum:%{public}u, height:%{public}u", - outputRowsNum_, pngImageInfo_.height); + IMAGE_LOGD("Incremental decode incomplete, outputRowsNum:%{public}u, height:%{public}u", + outputRowsNum_, pngImageInfo_.height); } state_ = PngDecodingState::IMAGE_DECODED; } @@ -424,7 +425,7 @@ uint32_t PngDecoder::PromoteIncrementalDecode(uint32_t index, ProgDecodeContext // so here pngImageInfo_.height will not be equal to 0 in the PngDecodingState::IMAGE_DECODING state. context.totalProcessProgress = outputRowsNum_ == 0 ? 0 : outputRowsNum_ * ProgDecodeContext::FULL_PROGRESS / pngImageInfo_.height; - HiLog::Debug(LABEL, "Incremental decode progress %{public}u.", context.totalProcessProgress); + IMAGE_LOGD("Incremental decode progress %{public}u.", context.totalProcessProgress); return ret; } @@ -448,7 +449,7 @@ bool PngDecoder::ConvertOriginalFormat(png_byte source, png_byte &destination) if (png_get_valid(pngStructPtr_, pngInfoPtr_, PNG_INFO_tRNS)) { png_set_tRNS_to_alpha(pngStructPtr_); } - HiLog::Info(LABEL, "color type:[%{public}d]", source); + IMAGE_LOGI("color type:[%{public}d]", source); switch (source) { case PNG_COLOR_TYPE_PALETTE: { // value is 3 png_set_palette_to_rgb(pngStructPtr_); @@ -474,7 +475,7 @@ bool PngDecoder::ConvertOriginalFormat(png_byte source, png_byte &destination) break; } default: { - HiLog::Error(LABEL, "the color type:[%{public}d] libpng unsupported!", source); + IMAGE_LOGE("the color type:[%{public}d] libpng unsupported!", source); return false; } } @@ -546,12 +547,12 @@ void PngDecoder::ChooseFormat(PlPixelFormat format, PlPixelFormat &outputFormat, void PngDecoder::PngErrorExit(png_structp pngPtr, png_const_charp message) { if ((pngPtr == nullptr) || (message == nullptr)) { - HiLog::Error(LABEL, "ErrorExit png_structp or error message is null."); + IMAGE_LOGE("ErrorExit png_structp or error message is null."); return; } jmp_buf *jmpBuf = &(png_jmpbuf(pngPtr)); if (jmpBuf == nullptr) { - HiLog::Error(LABEL, "jmpBuf exception."); + IMAGE_LOGE("jmpBuf exception."); return; } longjmp(*jmpBuf, SET_JUMP_VALUE); @@ -560,28 +561,28 @@ void PngDecoder::PngErrorExit(png_structp pngPtr, png_const_charp message) void PngDecoder::PngWarning(png_structp pngPtr, png_const_charp message) { if (message == nullptr) { - HiLog::Debug(LABEL, "WarningExit message is null."); + IMAGE_LOGD("WarningExit message is null."); return; } - HiLog::Warn(LABEL, "png warn %{public}s", message); + IMAGE_LOGD("png warn %{public}s", message); } void PngDecoder::PngErrorMessage(png_structp pngPtr, png_const_charp message) { if (message == nullptr) { - HiLog::Debug(LABEL, "PngErrorMessage message is null."); + IMAGE_LOGD("PngErrorMessage message is null."); return; } - HiLog::Error(LABEL, "PngErrorMessage, message:%{public}s.", message); + IMAGE_LOGE("PngErrorMessage, message:%{public}s.", message); } void PngDecoder::PngWarningMessage(png_structp pngPtr, png_const_charp message) { if (message == nullptr) { - HiLog::Debug(LABEL, "PngWarningMessage message is null."); + IMAGE_LOGD("PngWarningMessage message is null."); return; } - HiLog::Warn(LABEL, "PngWarningMessage, message:%{public}s.", message); + IMAGE_LOGD("PngWarningMessage, message:%{public}s.", message); } // image incremental decode Interface @@ -590,17 +591,15 @@ uint32_t PngDecoder::ProcessData(png_structp pngStructPtr, png_infop infoStructP { if ((pngStructPtr == nullptr) || (infoStructPtr == nullptr) || (sourceStream == nullptr) || (totalSize == 0) || (bufferSize == 0)) { - HiLog::Error(LABEL, "ProcessData input error, totalSize:%{public}zu, bufferSize:%{public}zu.", totalSize, - bufferSize); + IMAGE_LOGE("ProcessData input error, totalSize:%{public}zu, bufferSize:%{public}zu.", totalSize, bufferSize); return ERR_IMAGE_INVALID_PARAMETER; } while (totalSize > 0) { size_t readSize = (bufferSize < totalSize) ? bufferSize : totalSize; uint32_t ret = IncrementalRead(sourceStream, readSize, streamData); if (ret != SUCCESS) { - HiLog::Error(LABEL, "ProcessData Read from source stream fail, readSize:%{public}zu, \ - bufferSize:%{public}zu, dataSize:%{public}u, totalSize:%{public}zu.", - readSize, bufferSize, streamData.dataSize, totalSize); + IMAGE_LOGE("ProcessData Read from source stream fail, readSize:%{public}zu, bufferSize:%{public}zu," + "dataSize:%{public}u, totalSize:%{public}zu.", readSize, bufferSize, streamData.dataSize, totalSize); return ret; } png_process_data(pngStructPtr, infoStructPtr, const_cast(streamData.inputStreamBuffer), @@ -613,7 +612,7 @@ uint32_t PngDecoder::ProcessData(png_structp pngStructPtr, png_infop infoStructP bool PngDecoder::IsChunk(const png_byte *chunk, const char *flag) { if (chunk == nullptr || flag == nullptr) { - HiLog::Error(LABEL, "IsChunk input parameter exception."); + IMAGE_LOGE("IsChunk input parameter exception."); return false; } return memcmp(chunk + CHUNK_DATA_LEN, flag, CHUNK_DATA_LEN) == 0; @@ -626,18 +625,17 @@ bool PngDecoder::GetImageInfo(PngImageInfo &info) int32_t bitDepth = 0; png_get_IHDR(pngStructPtr_, pngInfoPtr_, &origWidth, &origHeight, &bitDepth, nullptr, nullptr, nullptr, nullptr); if ((origWidth == 0) || (origHeight == 0) || (origWidth > PNG_UINT_31_MAX) || (origHeight > PNG_UINT_31_MAX)) { - HiLog::Error(LABEL, "Get the png image size abnormal, width:%{public}u, height:%{public}u", origWidth, - origHeight); + IMAGE_LOGE("Get the png image size abnormal, width:%{public}u, height:%{public}u", origWidth, origHeight); return false; } if (bitDepth != BITDEPTH_VALUE_1 && bitDepth != BITDEPTH_VALUE_2 && bitDepth != BITDEPTH_VALUE_4 && bitDepth != BITDEPTH_VALUE_8 && bitDepth != BITDEPTH_VALUE_16) { - HiLog::Error(LABEL, "Get the png image bit depth abnormal, bitDepth:%{public}d.", bitDepth); + IMAGE_LOGE("Get the png image bit depth abnormal, bitDepth:%{public}d.", bitDepth); return false; } size_t rowDataSize = png_get_rowbytes(pngStructPtr_, pngInfoPtr_); if (rowDataSize == 0) { - HiLog::Error(LABEL, "Get the bitmap row bytes size fail."); + IMAGE_LOGE("Get the bitmap row bytes size fail."); return false; } info.numberPasses = png_set_interlace_handling(pngStructPtr_); @@ -645,7 +643,7 @@ bool PngDecoder::GetImageInfo(PngImageInfo &info) info.height = origHeight; info.bitDepth = bitDepth; info.rowDataSize = rowDataSize; - HiLog::Info(LABEL, "GetImageInfo:width:%{public}u,height:%{public}u,bitDepth:%{public}u,numberPasses:%{public}d.", + IMAGE_LOGI("GetImageInfo:width:%{public}u,height:%{public}u,bitDepth:%{public}u,numberPasses:%{public}d.", origWidth, origHeight, info.bitDepth, info.numberPasses); return true; } @@ -658,17 +656,17 @@ uint32_t PngDecoder::IncrementalRead(InputDataStream *stream, uint32_t desiredSi uint32_t curPos = stream->Tell(); if (!stream->Read(desiredSize, outData)) { - HiLog::Debug(LABEL, "read data fail."); + IMAGE_LOGD("read data fail."); return ERR_IMAGE_SOURCE_DATA_INCOMPLETE; } if (outData.inputStreamBuffer == nullptr || outData.dataSize == 0) { - HiLog::Error(LABEL, "inputStreamBuffer is null or data size is %{public}u.", outData.dataSize); + IMAGE_LOGE("inputStreamBuffer is null or data size is %{public}u.", outData.dataSize); return ERR_IMAGE_GET_DATA_ABNORMAL; } if (outData.dataSize < desiredSize) { stream->Seek(curPos); - HiLog::Debug(LABEL, "read outdata size[%{public}u] < data size[%{public}u] and curpos:%{public}u", - outData.dataSize, desiredSize, curPos); + IMAGE_LOGD("read outdata size[%{public}u] < data size[%{public}u] and curpos:%{public}u", outData.dataSize, + desiredSize, curPos); return ERR_IMAGE_SOURCE_DATA_INCOMPLETE; } return SUCCESS; @@ -687,13 +685,13 @@ uint32_t PngDecoder::GetImageIdatSize(InputDataStream *stream) png_byte *chunk = const_cast(readData.inputStreamBuffer); const size_t length = png_get_uint_32(chunk); if (IsChunk(chunk, "IDAT")) { - HiLog::Debug(LABEL, "first idat Length is %{public}zu.", length); + IMAGE_LOGD("first idat Length is %{public}zu.", length); idatLength_ = length; return SUCCESS; } uint32_t afterReadPos = stream->Tell(); if (!stream->Seek(length + afterReadPos + CHUNK_DATA_LEN)) { - HiLog::Debug(LABEL, "stream current pos is %{public}u, chunk size is %{public}zu.", preReadPos, length); + IMAGE_LOGD("stream current pos is %{public}u, chunk size is %{public}zu.", preReadPos, length); stream->Seek(preReadPos); return ERR_IMAGE_SOURCE_DATA_INCOMPLETE; } @@ -710,19 +708,19 @@ uint32_t PngDecoder::GetImageIdatSize(InputDataStream *stream) uint32_t PngDecoder::ReadIncrementalHead(InputDataStream *stream, PngImageInfo &info) { if (stream == nullptr) { - HiLog::Error(LABEL, "read incremental head input data is null!"); + IMAGE_LOGE("read incremental head input data is null!"); return ERR_IMAGE_INVALID_PARAMETER; } uint32_t pos = stream->Tell(); if (!stream->Seek(PNG_HEAD_SIZE)) { - HiLog::Debug(LABEL, "don't enough the data to decode the image head."); + IMAGE_LOGD("don't enough the data to decode the image head."); return ERR_IMAGE_SOURCE_DATA_INCOMPLETE; } stream->Seek(pos); // set the exception handle jmp_buf *jmpBuf = &(png_jmpbuf(pngStructPtr_)); if ((jmpBuf == nullptr) || setjmp(*jmpBuf)) { - HiLog::Error(LABEL, "read incremental head PNG decode head exception."); + IMAGE_LOGE("read incremental head PNG decode head exception."); return ERR_IMAGE_DECODE_HEAD_ABNORMAL; } @@ -741,7 +739,7 @@ uint32_t PngDecoder::ReadIncrementalHead(InputDataStream *stream, PngImageInfo & } uint32_t ret = GetImageIdatSize(stream); if (ret != SUCCESS) { - HiLog::Error(LABEL, "get image idat size fail, ret:%{public}u.", ret); + IMAGE_LOGE("get image idat size fail, ret:%{public}u.", ret); return ret; } if (!GetImageInfo(info)) { @@ -753,9 +751,8 @@ uint32_t PngDecoder::ReadIncrementalHead(InputDataStream *stream, PngImageInfo & void PngDecoder::SaveRows(png_bytep row, png_uint_32 rowNum) { if (rowNum != outputRowsNum_ || pngImageInfo_.height < rowNum) { - HiLog::Error(LABEL, - "AllRowsCallback exception, rowNum:%{public}u, outputRowsNum:%{public}u, height:%{public}u.", - rowNum, outputRowsNum_, pngImageInfo_.height); + IMAGE_LOGE("AllRowsCallback exception, rowNum:%{public}u, outputRowsNum:%{public}u, height:%{public}u.", + rowNum, outputRowsNum_, pngImageInfo_.height); return; } outputRowsNum_++; @@ -763,8 +760,8 @@ void PngDecoder::SaveRows(png_bytep row, png_uint_32 rowNum) uint32_t offsetSize = (pngImageInfo_.height - rowNum) * pngImageInfo_.rowDataSize; errno_t ret = memcpy_s(offset, offsetSize, row, pngImageInfo_.rowDataSize); if (ret != 0) { - HiLog::Error(LABEL, "copy data fail, ret:%{public}d, rowDataSize:%{public}u, offsetSize:%{public}u.", ret, - pngImageInfo_.rowDataSize, offsetSize); + IMAGE_LOGE("copy data fail, ret:%{public}d, rowDataSize:%{public}u, offsetSize:%{public}u.", ret, + pngImageInfo_.rowDataSize, offsetSize); return; } } @@ -772,11 +769,11 @@ void PngDecoder::SaveRows(png_bytep row, png_uint_32 rowNum) void PngDecoder::SaveInterlacedRows(png_bytep row, png_uint_32 rowNum, int pass) { if (row == nullptr) { - HiLog::Error(LABEL, "input row is null."); + IMAGE_LOGE("input row is null."); return; } if (rowNum < firstRow_ || rowNum > lastRow_ || interlacedComplete_) { - HiLog::Error(LABEL, "ignore this row, rowNum:%{public}u,InterlacedComplete:%{public}u.", rowNum, + IMAGE_LOGE("ignore this row, rowNum:%{public}u,InterlacedComplete:%{public}u.", rowNum, interlacedComplete_); return; } @@ -784,7 +781,7 @@ void PngDecoder::SaveInterlacedRows(png_bytep row, png_uint_32 rowNum, int pass) uint64_t mollocByteCount = static_cast(pngImageInfo_.rowDataSize) * pngImageInfo_.height; uint64_t needByteCount = static_cast(pngStructPtr_->width) * sizeof(*oldRow); if (mollocByteCount < needByteCount) { - HiLog::Error(LABEL, "malloc byte size is(%{public}llu), but actual needs (%{public}llu)", + IMAGE_LOGE("malloc byte size is(%{public}llu), but actual needs (%{public}llu)", static_cast(mollocByteCount), static_cast(needByteCount)); return; } @@ -792,20 +789,20 @@ void PngDecoder::SaveInterlacedRows(png_bytep row, png_uint_32 rowNum, int pass) if (pass == 0) { // The first pass initializes all rows. if (outputRowsNum_ == rowNum - firstRow_) { - HiLog::Info(LABEL, "rowNum(%{public}u) - firstRow(%{public}u) = outputRow(%{public}u)", rowNum, firstRow_, + IMAGE_LOGI("rowNum(%{public}u) - firstRow(%{public}u) = outputRow(%{public}u)", rowNum, firstRow_, outputRowsNum_); return; } outputRowsNum_++; } else { if (outputRowsNum_ == lastRow_ - firstRow_ + 1) { - HiLog::Info(LABEL, "lastRow_(%{public}u) + firstRow(%{public}u) + 1 = outputRow(%{public}u)", lastRow_, + IMAGE_LOGI("lastRow_(%{public}u) + firstRow(%{public}u) + 1 = outputRow(%{public}u)", lastRow_, firstRow_, outputRowsNum_); return; } if (pngImageInfo_.numberPasses - 1 == pass && rowNum == lastRow_) { // Last pass, and we have read all of the rows we care about. - HiLog::Info(LABEL, "last pass:%{public}d, numberPasses:%{public}d, rowNum:%{public}d, lastRow:%{public}d.", + IMAGE_LOGI("last pass:%{public}d, numberPasses:%{public}d, rowNum:%{public}d, lastRow:%{public}d.", pass, pngImageInfo_.numberPasses, rowNum, lastRow_); interlacedComplete_ = true; } @@ -815,12 +812,12 @@ void PngDecoder::SaveInterlacedRows(png_bytep row, png_uint_32 rowNum, int pass) void PngDecoder::GetAllRows(png_structp pngPtr, png_bytep row, png_uint_32 rowNum, int pass) { if (pngPtr == nullptr || row == nullptr) { - HiLog::Error(LABEL, "get decode rows exception, rowNum:%{public}u.", rowNum); + IMAGE_LOGE("get decode rows exception, rowNum:%{public}u.", rowNum); return; } PngDecoder *decoder = static_cast(png_get_progressive_ptr(pngPtr)); if (decoder == nullptr) { - HiLog::Error(LABEL, "get all rows fail, get decoder is null."); + IMAGE_LOGE("get all rows fail, get decoder is null."); return; } decoder->SaveRows(row, rowNum); @@ -829,12 +826,12 @@ void PngDecoder::GetAllRows(png_structp pngPtr, png_bytep row, png_uint_32 rowNu void PngDecoder::GetInterlacedRows(png_structp pngPtr, png_bytep row, png_uint_32 rowNum, int pass) { if (pngPtr == nullptr || row == nullptr) { - HiLog::Debug(LABEL, "get decode rows exception, rowNum:%{public}u.", rowNum); + IMAGE_LOGD("get decode rows exception, rowNum:%{public}u.", rowNum); return; } PngDecoder *decoder = static_cast(png_get_progressive_ptr(pngPtr)); if (decoder == nullptr) { - HiLog::Error(LABEL, "get all rows fail, get decoder is null."); + IMAGE_LOGE("get all rows fail, get decoder is null."); return; } decoder->SaveInterlacedRows(row, rowNum, pass); @@ -844,7 +841,7 @@ int32_t PngDecoder::ReadUserChunk(png_structp png_ptr, png_unknown_chunkp chunk) { NinePatchListener *chunkReader = static_cast(png_get_user_chunk_ptr(png_ptr)); if (chunkReader == nullptr) { - HiLog::Error(LABEL, "chunk header is null."); + IMAGE_LOGE("chunk header is null."); return ERR_IMAGE_DECODE_ABNORMAL; } return chunkReader->ReadChunk(reinterpret_cast(chunk->name), chunk->data, chunk->size) @@ -855,14 +852,12 @@ int32_t PngDecoder::ReadUserChunk(png_structp png_ptr, png_unknown_chunkp chunk) uint32_t PngDecoder::PushAllToDecode(InputDataStream *stream, size_t bufferSize, size_t length) { if (stream == nullptr || bufferSize == 0 || length == 0) { - HiLog::Error(LABEL, "iend process input exception, bufferSize:%{public}zu, length:%{public}zu.", bufferSize, - length); + IMAGE_LOGE("iend process input exception, bufferSize:%{public}zu, length:%{public}zu.", bufferSize, length); return ERR_IMAGE_INVALID_PARAMETER; } DataStreamBuffer ReadData; if (ProcessData(pngStructPtr_, pngInfoPtr_, stream, ReadData, bufferSize, length) != SUCCESS) { - HiLog::Error(LABEL, "ProcessData return false, bufferSize:%{public}zu, length:%{public}zu.", bufferSize, - length); + IMAGE_LOGE("ProcessData return false, bufferSize:%{public}zu, length:%{public}zu.", bufferSize, length); return ERR_IMAGE_DECODE_ABNORMAL; } bool iend = false; @@ -871,7 +866,7 @@ uint32_t PngDecoder::PushAllToDecode(InputDataStream *stream, size_t bufferSize, // Parse chunk length and type. ret = IncrementalRead(stream, CHUNK_SIZE, ReadData); if (ret != SUCCESS) { - HiLog::Error(LABEL, "set iend mode Read chunk fail,ret:%{public}u", ret); + IMAGE_LOGE("set iend mode Read chunk fail,ret:%{public}u", ret); break; } png_byte *chunk = const_cast(ReadData.inputStreamBuffer); @@ -892,17 +887,17 @@ uint32_t PngDecoder::PushAllToDecode(InputDataStream *stream, size_t bufferSize, uint32_t PngDecoder::IncrementalReadRows(InputDataStream *stream) { if (stream == nullptr) { - HiLog::Error(LABEL, "input data is null!"); + IMAGE_LOGE("input data is null!"); return ERR_IMAGE_GET_DATA_ABNORMAL; } if (idatLength_ < incrementalLength_) { - HiLog::Error(LABEL, "incremental len:%{public}zu > idat len:%{public}zu.", incrementalLength_, idatLength_); + IMAGE_LOGE("incremental len:%{public}zu > idat len:%{public}zu.", incrementalLength_, idatLength_); return ERR_IMAGE_INVALID_PARAMETER; } // set the exception handle jmp_buf *jmpBuf = &(png_jmpbuf(pngStructPtr_)); if ((jmpBuf == nullptr) || setjmp(*jmpBuf)) { - HiLog::Error(LABEL, "[IncrementalReadRows]PNG decode exception."); + IMAGE_LOGE("[IncrementalReadRows]PNG decode exception."); return ERR_IMAGE_DECODE_ABNORMAL; } // set process decode state to IDAT mode. @@ -922,17 +917,16 @@ uint32_t PngDecoder::IncrementalReadRows(InputDataStream *stream) if (stream->IsStreamCompleted()) { uint32_t ret = PushAllToDecode(stream, DECODE_BUFFER_SIZE, idatLength_ - incrementalLength_); if (ret != SUCCESS) { - HiLog::Error(LABEL, "iend set fail, ret:%{public}u, idatLen:%{public}zu, incrementalLen:%{public}zu.", ret, - idatLength_, incrementalLength_); + IMAGE_LOGE("iend set fail, ret:%{public}u, idatLen:%{public}zu, incrementalLen:%{public}zu.", ret, + idatLength_, incrementalLength_); return ret; } return SUCCESS; } uint32_t ret = PushCurrentToDecode(stream); if (ret != SUCCESS) { - HiLog::Error(LABEL, - "push stream to decode fail, ret:%{public}u, idatLen:%{public}zu, incrementalLen:%{public}zu.", - ret, idatLength_, incrementalLength_); + IMAGE_LOGE("push stream to decode fail, ret:%{public}u, idatLen:%{public}zu, incrementalLen:%{public}zu.", + ret, idatLength_, incrementalLength_); return ret; } return SUCCESS; @@ -941,11 +935,11 @@ uint32_t PngDecoder::IncrementalReadRows(InputDataStream *stream) uint32_t PngDecoder::PushCurrentToDecode(InputDataStream *stream) { if (stream == nullptr) { - HiLog::Error(LABEL, "push current stream to decode input data is null!"); + IMAGE_LOGE("push current stream to decode input data is null!"); return ERR_IMAGE_GET_DATA_ABNORMAL; } if (idatLength_ == 0) { - HiLog::Error(LABEL, "idat Length is zero."); + IMAGE_LOGE("idat Length is zero."); return ERR_IMAGE_DECODE_ABNORMAL; } @@ -955,7 +949,7 @@ uint32_t PngDecoder::PushCurrentToDecode(InputDataStream *stream) const size_t targetSize = std::min(DECODE_BUFFER_SIZE, idatLength_ - incrementalLength_); ret = IncrementalRead(stream, targetSize, ReadData); if (ret != SUCCESS) { - HiLog::Debug(LABEL, "push current stream read fail, ret:%{public}u", ret); + IMAGE_LOGD("push current stream read fail, ret:%{public}u", ret); return ret; } incrementalLength_ += ReadData.dataSize; @@ -965,7 +959,7 @@ uint32_t PngDecoder::PushCurrentToDecode(InputDataStream *stream) while (true) { ret = IncrementalRead(stream, CHUNK_SIZE, ReadData); if (ret != SUCCESS) { - HiLog::Debug(LABEL, "set iend mode Read chunk fail,ret:%{public}u", ret); + IMAGE_LOGD("set iend mode Read chunk fail,ret:%{public}u", ret); break; } png_byte *chunk = const_cast(ReadData.inputStreamBuffer); @@ -976,7 +970,7 @@ uint32_t PngDecoder::PushCurrentToDecode(InputDataStream *stream) const size_t targetSize = std::min(DECODE_BUFFER_SIZE, idatLength_ - incrementalLength_); ret = IncrementalRead(stream, targetSize, ReadData); if (ret != SUCCESS) { - HiLog::Debug(LABEL, "push current stream read fail, ret:%{public}u", ret); + IMAGE_LOGD("push current stream read fail, ret:%{public}u", ret); return ret; } incrementalLength_ += ReadData.dataSize; @@ -1006,13 +1000,13 @@ uint32_t PngDecoder::DecodeHeader() state_ = PngDecodingState::BASE_INFO_PARSING; } else { state_ = PngDecodingState::SOURCE_INITED; - HiLog::Error(LABEL, "decode image head, ret:%{public}u.", ret); + IMAGE_LOGE("decode image head, ret:%{public}u.", ret); } return ret; } if (pngImageInfo_.width == 0 || pngImageInfo_.height == 0) { - HiLog::Error(LABEL, "get width and height fail, height:%{public}u, width:%{public}u.", pngImageInfo_.height, - pngImageInfo_.width); + IMAGE_LOGE("get width and height fail, height:%{public}u, width:%{public}u.", pngImageInfo_.height, + pngImageInfo_.width); state_ = PngDecodingState::SOURCE_INITED; return ERR_IMAGE_GET_DATA_ABNORMAL; } @@ -1036,14 +1030,14 @@ uint32_t PngDecoder::ConfigInfo(const PixelDecodeOptions &opts) ret = GetDecodeFormat(opts.desiredPixelFormat, outputFormat_, alphaType_); } if (ret != SUCCESS) { - HiLog::Error(LABEL, "get the color type fail."); + IMAGE_LOGE("get the color type fail."); return ERR_IMAGE_DATA_ABNORMAL; } // get the libpng interface exception. jmp_buf *jmpBuf = &(png_jmpbuf(pngStructPtr_)); if ((jmpBuf == nullptr) || setjmp(*jmpBuf)) { - HiLog::Error(LABEL, "config decoding info fail."); + IMAGE_LOGE("config decoding info fail."); return ERR_IMAGE_DATA_ABNORMAL; } png_read_update_info(pngStructPtr_, pngInfoPtr_); @@ -1053,23 +1047,23 @@ uint32_t PngDecoder::ConfigInfo(const PixelDecodeOptions &opts) uint32_t PngDecoder::DoOneTimeDecode(DecodeContext &context) { if (idatLength_ <= 0) { - HiLog::Error(LABEL, "normal decode the image source incomplete."); + IMAGE_LOGE("normal decode the image source incomplete."); return ERR_IMAGE_SOURCE_DATA_INCOMPLETE; } jmp_buf *jmpBuf = &(png_jmpbuf(pngStructPtr_)); if ((jmpBuf == nullptr) || setjmp(*jmpBuf)) { - HiLog::Error(LABEL, "decode the image fail."); + IMAGE_LOGE("decode the image fail."); return ERR_IMAGE_DECODE_ABNORMAL; } pixelsData_ = AllocOutputBuffer(context); if (pixelsData_ == nullptr) { - HiLog::Error(LABEL, "get pixels memory fail."); + IMAGE_LOGE("get pixels memory fail."); return ERR_IMAGE_MALLOC_ABNORMAL; } inputStreamPtr_->Seek(streamPosition_); uint32_t ret = IncrementalReadRows(inputStreamPtr_); if (ret != SUCCESS) { - HiLog::Error(LABEL, "normal decode the image fail, ret:%{public}u", ret); + IMAGE_LOGE("normal decode the image fail, ret:%{public}u", ret); return ret; } streamPosition_ = inputStreamPtr_->Tell(); @@ -1089,7 +1083,7 @@ bool PngDecoder::FinishOldDecompress() if (pngStructPtr_ != nullptr) { png_infopp pngInfoPtr = pngInfoPtr_ ? &pngInfoPtr_ : nullptr; png_destroy_read_struct(&pngStructPtr_, pngInfoPtr, nullptr); - HiLog::Debug(LABEL, "FinishOldDecompress png_destroy_read_struct"); + IMAGE_LOGD("FinishOldDecompress png_destroy_read_struct"); } state_ = PngDecodingState::SOURCE_INITED; if (InitPnglib()) { @@ -1106,7 +1100,7 @@ bool PngDecoder::InitPnglib() // set the libpng exception message callback function png_set_error_fn(pngStructPtr_, nullptr, PngErrorMessage, PngWarningMessage); if (pngStructPtr_ == nullptr || pngInfoPtr_ == nullptr) { - HiLog::Error(LABEL, "Png lib init fail."); + IMAGE_LOGE("Png lib init fail."); return false; } return true; diff --git a/plugins/common/libs/image/librawplugin/src/plugin_export.cpp b/plugins/common/libs/image/librawplugin/src/plugin_export.cpp index 8fc0648de..05867e344 100644 --- a/plugins/common/libs/image/librawplugin/src/plugin_export.cpp +++ b/plugins/common/libs/image/librawplugin/src/plugin_export.cpp @@ -14,11 +14,16 @@ */ #include "plugin_export.h" -#include "hilog/log.h" -#include "log_tags.h" +#include "image_log.h" #include "plugin_utils.h" #include "raw_decoder.h" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "LibRawPlugin" + // plugin package name same as metadata. namespace { const std::string PACKAGE_NAME = ("LibRawPlugin"); @@ -30,31 +35,25 @@ PLUGIN_EXPORT_REGISTER_CLASS(OHOS::ImagePlugin::RawDecoder) PLUGIN_EXPORT_REGISTER_CLASS_END using std::string; -using namespace OHOS::HiviewDFX; - -static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "LibRawPlugin" }; - -#define PLUGIN_LOG_D(...) HiLog::Debug(LABEL, __VA_ARGS__) -#define PLUGIN_LOG_E(...) HiLog::Error(LABEL, __VA_ARGS__) // define the external interface of this plugin. PLUGIN_EXPORT_DEFAULT_EXTERNAL_START() PLUGIN_EXPORT_DEFAULT_EXTERNAL_STOP() OHOS::MultimediaPlugin::PluginClassBase *PluginExternalCreate(const string &className) { - HiLog::Debug(LABEL, "PluginExternalCreate: create object for package: %{public}s, class: %{public}s.", + IMAGE_LOGD("PluginExternalCreate: create object for package: %{public}s, class: %{public}s.", PACKAGE_NAME.c_str(), className.c_str()); auto iter = implClassMap.find(className); if (iter == implClassMap.end()) { - HiLog::Error(LABEL, "PluginExternalCreate: failed to find class: %{public}s, in package: %{public}s.", + IMAGE_LOGE("PluginExternalCreate: failed to find class: %{public}s, in package: %{public}s.", className.c_str(), PACKAGE_NAME.c_str()); return nullptr; } auto creator = iter->second; if (creator == nullptr) { - HiLog::Error(LABEL, "PluginExternalCreate: null creator for class: %{public}s, in package: %{public}s.", + IMAGE_LOGE("PluginExternalCreate: null creator for class: %{public}s, in package: %{public}s.", className.c_str(), PACKAGE_NAME.c_str()); return nullptr; } diff --git a/plugins/common/libs/image/librawplugin/src/raw_decoder.cpp b/plugins/common/libs/image/librawplugin/src/raw_decoder.cpp index 220b40813..f3e4ad53b 100644 --- a/plugins/common/libs/image/librawplugin/src/raw_decoder.cpp +++ b/plugins/common/libs/image/librawplugin/src/raw_decoder.cpp @@ -13,40 +13,44 @@ * limitations under the License. */ #include "raw_decoder.h" -#include "hilog/log.h" -#include "log_tags.h" +#include "image_log.h" #include "buffer_source_stream.h" #include "jpeg_decoder.h" #include "raw_stream.h" + +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "RawDecoder" + namespace OHOS { namespace ImagePlugin { -using namespace OHOS::HiviewDFX; using namespace MultimediaPlugin; using namespace Media; namespace { -constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "RawDecoder" }; constexpr uint32_t RAW_IMAGE_NUM = 1; } RawDecoder::RawDecoder() { - HiLog::Debug(LABEL, "create IN"); + IMAGE_LOGD("create IN"); - HiLog::Debug(LABEL, "create OUT"); + IMAGE_LOGD("create OUT"); } RawDecoder::~RawDecoder() { - HiLog::Debug(LABEL, "release IN"); + IMAGE_LOGD("release IN"); Reset(); - HiLog::Debug(LABEL, "release OUT"); + IMAGE_LOGD("release OUT"); } void RawDecoder::Reset() { - HiLog::Debug(LABEL, "Reset IN"); + IMAGE_LOGD("Reset IN"); inputStream_ = nullptr; state_ = RawDecodingState::UNDECIDED; @@ -63,59 +67,59 @@ void RawDecoder::Reset() jpegStream_ = nullptr; jpegDecoder_ = nullptr; - HiLog::Debug(LABEL, "Reset OUT"); + IMAGE_LOGD("Reset OUT"); } bool RawDecoder::HasProperty(std::string key) { - HiLog::Debug(LABEL, "HasProperty IN key=[%{public}s]", key.c_str()); + IMAGE_LOGD("HasProperty IN key=[%{public}s]", key.c_str()); - HiLog::Debug(LABEL, "HasProperty OUT"); + IMAGE_LOGD("HasProperty OUT"); return false; } uint32_t RawDecoder::PromoteIncrementalDecode(uint32_t index, ProgDecodeContext &progContext) { - HiLog::Debug(LABEL, "PromoteIncrementalDecode index=%{public}u", index); + IMAGE_LOGD("PromoteIncrementalDecode index=%{public}u", index); return Media::ERR_IMAGE_DATA_UNSUPPORT; } uint32_t RawDecoder::GetTopLevelImageNum(uint32_t &num) { num = RAW_IMAGE_NUM; - HiLog::Debug(LABEL, "GetTopLevelImageNum, num=%{public}u", num); + IMAGE_LOGD("GetTopLevelImageNum, num=%{public}u", num); return Media::SUCCESS; } void RawDecoder::SetSource(InputDataStream &sourceStream) { - HiLog::Debug(LABEL, "SetSource IN"); + IMAGE_LOGD("SetSource IN"); inputStream_ = &sourceStream; rawStream_ = std::make_unique(sourceStream); state_ = RawDecodingState::SOURCE_INITED; - HiLog::Debug(LABEL, "SetSource OUT"); + IMAGE_LOGD("SetSource OUT"); } uint32_t RawDecoder::SetDecodeOptions(uint32_t index, const PixelDecodeOptions &opts, PlImageInfo &info) { - HiLog::Debug(LABEL, "SetDecodeOptions IN index=%{public}u", index); + IMAGE_LOGD("SetDecodeOptions IN index=%{public}u", index); if (index >= RAW_IMAGE_NUM) { - HiLog::Error(LABEL, "[SetDecodeOptions] decode image index[%{public}u], out of range[%{public}u].", + IMAGE_LOGE("[SetDecodeOptions] decode image index[%{public}u], out of range[%{public}u].", index, RAW_IMAGE_NUM); return Media::ERR_IMAGE_INVALID_PARAMETER; } - HiLog::Debug(LABEL, "SetDecodeOptions opts, pixelFormat=%{public}d, alphaType=%{public}d, " + IMAGE_LOGD("SetDecodeOptions opts, pixelFormat=%{public}d, alphaType=%{public}d, " "colorSpace=%{public}d, size=(%{public}u, %{public}u), state=%{public}d", static_cast(opts.desiredPixelFormat), static_cast(opts.desireAlphaType), static_cast(opts.desiredColorSpace), opts.desiredSize.width, opts.desiredSize.height, state_); if (state_ < RawDecodingState::SOURCE_INITED) { - HiLog::Error(LABEL, "[SetDecodeOptions] set decode options failed for state %{public}d.", state_); + IMAGE_LOGE("[SetDecodeOptions] set decode options failed for state %{public}d.", state_); return Media::ERR_MEDIA_INVALID_OPERATION; } @@ -127,7 +131,7 @@ uint32_t RawDecoder::SetDecodeOptions(uint32_t index, const PixelDecodeOptions & uint32_t ret = DoDecodeHeader(); if (ret != Media::SUCCESS) { state_ = RawDecodingState::BASE_INFO_PARSING; - HiLog::Error(LABEL, "[SetDecodeOptions] decode header error on set decode options:%{public}u.", ret); + IMAGE_LOGE("[SetDecodeOptions] decode header error on set decode options:%{public}u.", ret); return ret; } @@ -138,119 +142,119 @@ uint32_t RawDecoder::SetDecodeOptions(uint32_t index, const PixelDecodeOptions & uint32_t ret = DoSetDecodeOptions(index, opts, info); if (ret != Media::SUCCESS) { state_ = RawDecodingState::BASE_INFO_PARSING; - HiLog::Error(LABEL, "[SetDecodeOptions] do set decode options fail, ret:%{public}u.", ret); + IMAGE_LOGE("[SetDecodeOptions] do set decode options fail, ret:%{public}u.", ret); return ret; } state_ = RawDecodingState::IMAGE_DECODING; - HiLog::Debug(LABEL, "SetDecodeOptions OUT"); + IMAGE_LOGD("SetDecodeOptions OUT"); return Media::SUCCESS; } uint32_t RawDecoder::GetImageSize(uint32_t index, PlSize &size) { - HiLog::Debug(LABEL, "GetImageSize IN index=%{public}u", index); + IMAGE_LOGD("GetImageSize IN index=%{public}u", index); if (index >= RAW_IMAGE_NUM) { - HiLog::Error(LABEL, "[GetImageSize] decode image index[%{public}u], out of range[%{public}u].", + IMAGE_LOGE("[GetImageSize] decode image index[%{public}u], out of range[%{public}u].", index, RAW_IMAGE_NUM); return Media::ERR_IMAGE_INVALID_PARAMETER; } if (state_ < RawDecodingState::SOURCE_INITED) { - HiLog::Error(LABEL, "[GetImageSize] get image size failed for state %{public}d.", state_); + IMAGE_LOGE("[GetImageSize] get image size failed for state %{public}d.", state_); return ERR_MEDIA_INVALID_OPERATION; } if (state_ >= RawDecodingState::BASE_INFO_PARSED) { size = info_.size; - HiLog::Debug(LABEL, "GetImageSize OUT size=(%{public}u, %{public}u)", size.width, size.height); + IMAGE_LOGD("GetImageSize OUT size=(%{public}u, %{public}u)", size.width, size.height); return Media::SUCCESS; } // only state RawDecodingState::SOURCE_INITED and RawDecodingState::BASE_INFO_PARSING can go here. uint32_t ret = DoDecodeHeader(); if (ret != Media::SUCCESS) { - HiLog::Error(LABEL, "[GetImageSize]decode header error on get image size, ret:%{public}u.", ret); + IMAGE_LOGE("[GetImageSize]decode header error on get image size, ret:%{public}u.", ret); state_ = RawDecodingState::BASE_INFO_PARSING; return ret; } ret = DoGetImageSize(index, size); if (ret != Media::SUCCESS) { - HiLog::Error(LABEL, "[GetImageSize]do get image size failed, ret:%{public}u.", ret); + IMAGE_LOGE("[GetImageSize]do get image size failed, ret:%{public}u.", ret); state_ = RawDecodingState::BASE_INFO_PARSING; return ret; } state_ = RawDecodingState::BASE_INFO_PARSED; - HiLog::Debug(LABEL, "GetImageSize OUT size=(%{public}u, %{public}u)", size.width, size.height); + IMAGE_LOGD("GetImageSize OUT size=(%{public}u, %{public}u)", size.width, size.height); return Media::SUCCESS; } uint32_t RawDecoder::Decode(uint32_t index, DecodeContext &context) { - HiLog::Debug(LABEL, "Decode IN index=%{public}u", index); + IMAGE_LOGD("Decode IN index=%{public}u", index); if (index >= RAW_IMAGE_NUM) { - HiLog::Error(LABEL, "[Decode] decode image index:[%{public}u] out of range:[%{public}u].", + IMAGE_LOGE("[Decode] decode image index:[%{public}u] out of range:[%{public}u].", index, RAW_IMAGE_NUM); return Media::ERR_IMAGE_INVALID_PARAMETER; } if (state_ < RawDecodingState::IMAGE_DECODING) { - HiLog::Error(LABEL, "[Decode] decode failed for state %{public}d.", state_); + IMAGE_LOGE("[Decode] decode failed for state %{public}d.", state_); return Media::ERR_MEDIA_INVALID_OPERATION; } uint32_t ret = DoDecode(index, context); if (ret == Media::SUCCESS) { state_ = RawDecodingState::IMAGE_DECODED; - HiLog::Info(LABEL, "[Decode] success."); + IMAGE_LOGI("[Decode] success."); } else { state_ = RawDecodingState::IMAGE_ERROR; - HiLog::Error(LABEL, "[Decode] fail, ret=%{public}u", ret); + IMAGE_LOGE("[Decode] fail, ret=%{public}u", ret); } - HiLog::Debug(LABEL, "Decode OUT"); + IMAGE_LOGD("Decode OUT"); return ret; } uint32_t RawDecoder::DoDecodeHeader() { - HiLog::Debug(LABEL, "DoDecodeHeader IN"); + IMAGE_LOGD("DoDecodeHeader IN"); if (piex::IsRaw(rawStream_.get())) { jpegDecoder_ = nullptr; jpegStream_ = nullptr; uint32_t ret = DoDecodeHeaderByPiex(); if (ret != Media::SUCCESS) { - HiLog::Error(LABEL, "DoDecodeHeader piex header decode fail."); + IMAGE_LOGE("DoDecodeHeader piex header decode fail."); return ret; } if (jpegDecoder_ != nullptr) { - HiLog::Info(LABEL, "DoDecodeHeader piex header decode success."); + IMAGE_LOGI("DoDecodeHeader piex header decode success."); return Media::SUCCESS; } } uint32_t ret = Media::ERR_IMAGE_DATA_UNSUPPORT; - HiLog::Error(LABEL, "DoDecodeHeader header decode fail, ret=[%{public}u]", ret); + IMAGE_LOGE("DoDecodeHeader header decode fail, ret=[%{public}u]", ret); - HiLog::Debug(LABEL, "DoDecodeHeader OUT"); + IMAGE_LOGD("DoDecodeHeader OUT"); return ret; } uint32_t RawDecoder::DoDecodeHeaderByPiex() { - HiLog::Debug(LABEL, "DoDecodeHeaderByPiex IN"); + IMAGE_LOGD("DoDecodeHeaderByPiex IN"); piex::PreviewImageData imageData; piex::Error error = piex::GetPreviewImageData(rawStream_.get(), &imageData); if (error == piex::Error::kFail) { - HiLog::Error(LABEL, "DoDecodeHeaderByPiex get preview fail"); + IMAGE_LOGE("DoDecodeHeaderByPiex get preview fail"); return Media::ERR_IMAGE_DATA_ABNORMAL; } @@ -264,7 +268,7 @@ uint32_t RawDecoder::DoDecodeHeaderByPiex() } if (!hasImage) { - HiLog::Debug(LABEL, "DoDecodeHeaderByPiex OUT 2"); + IMAGE_LOGD("DoDecodeHeaderByPiex OUT 2"); return Media::SUCCESS; } @@ -272,13 +276,13 @@ uint32_t RawDecoder::DoDecodeHeaderByPiex() std::unique_ptr data = std::make_unique(size); error = rawStream_->GetData(piexImage.offset, size, data.get()); if (error != piex::Error::kOk) { - HiLog::Error(LABEL, "DoDecodeHeaderByPiex getdata fail"); + IMAGE_LOGE("DoDecodeHeaderByPiex getdata fail"); return Media::ERR_IMAGE_MALLOC_ABNORMAL; } jpegStream_ = BufferSourceStream::CreateSourceStream(data.get(), size); if (!jpegStream_) { - HiLog::Error(LABEL, "DoDecodeHeaderByPiex create sourcestream fail"); + IMAGE_LOGE("DoDecodeHeaderByPiex create sourcestream fail"); return Media::ERR_IMAGE_MALLOC_ABNORMAL; } @@ -286,31 +290,31 @@ uint32_t RawDecoder::DoDecodeHeaderByPiex() jpegDecoder_ = std::make_unique(); jpegDecoder_->SetSource(*(jpegStream_.get())); - HiLog::Debug(LABEL, "DoDecodeHeaderByPiex OUT"); + IMAGE_LOGD("DoDecodeHeaderByPiex OUT"); return Media::SUCCESS; } uint32_t RawDecoder::DoSetDecodeOptions(uint32_t index, const PixelDecodeOptions &opts, PlImageInfo &info) { - HiLog::Debug(LABEL, "DoSetDecodeOptions IN index=%{public}u", index); + IMAGE_LOGD("DoSetDecodeOptions IN index=%{public}u", index); uint32_t ret; opts_ = opts; if (jpegDecoder_ != nullptr) { - HiLog::Info(LABEL, "DoSetDecodeOptions, set decode options for JpegDecoder"); + IMAGE_LOGI("DoSetDecodeOptions, set decode options for JpegDecoder"); ret = jpegDecoder_->SetDecodeOptions(index, opts_, info_); } else { - HiLog::Error(LABEL, "DoSetDecodeOptions, unsupport"); + IMAGE_LOGE("DoSetDecodeOptions, unsupport"); ret = Media::ERR_IMAGE_DATA_UNSUPPORT; } info = info_; if (ret == Media::SUCCESS) { - HiLog::Info(LABEL, "DoSetDecodeOptions set decode options success."); + IMAGE_LOGI("DoSetDecodeOptions set decode options success."); } else { - HiLog::Error(LABEL, "DoSetDecodeOptions set decode options fail, ret=[%{public}u]", ret); + IMAGE_LOGE("DoSetDecodeOptions set decode options fail, ret=[%{public}u]", ret); } - HiLog::Debug(LABEL, "DoSetDecodeOptions OUT pixelFormat=%{public}d, alphaType=%{public}d, " + IMAGE_LOGD("DoSetDecodeOptions OUT pixelFormat=%{public}d, alphaType=%{public}d, " "colorSpace=%{public}d, size=(%{public}u, %{public}u)", static_cast(info.pixelFormat), static_cast(info.alphaType), static_cast(info.colorSpace), info.size.width, info.size.height); @@ -319,48 +323,48 @@ uint32_t RawDecoder::DoSetDecodeOptions(uint32_t index, const PixelDecodeOptions uint32_t RawDecoder::DoGetImageSize(uint32_t index, PlSize &size) { - HiLog::Debug(LABEL, "DoGetImageSize IN index=%{public}u", index); + IMAGE_LOGD("DoGetImageSize IN index=%{public}u", index); uint32_t ret; if (jpegDecoder_ != nullptr) { - HiLog::Info(LABEL, "DoGetImageSize, get image size for JpegDecoder"); + IMAGE_LOGI("DoGetImageSize, get image size for JpegDecoder"); ret = jpegDecoder_->GetImageSize(index, info_.size); } else { - HiLog::Error(LABEL, "DoGetImageSize, unsupport"); + IMAGE_LOGE("DoGetImageSize, unsupport"); ret = Media::ERR_IMAGE_DATA_UNSUPPORT; } size = info_.size; if (ret == Media::SUCCESS) { - HiLog::Info(LABEL, "DoGetImageSize, get image size success."); + IMAGE_LOGI("DoGetImageSize, get image size success."); } else { - HiLog::Error(LABEL, "DoGetImageSize, get image size fail, ret=[%{public}u]", ret); + IMAGE_LOGE("DoGetImageSize, get image size fail, ret=[%{public}u]", ret); } - HiLog::Debug(LABEL, "DoGetImageSize OUT size=(%{public}u, %{public}u)", size.width, size.height); + IMAGE_LOGD("DoGetImageSize OUT size=(%{public}u, %{public}u)", size.width, size.height); return ret; } uint32_t RawDecoder::DoDecode(uint32_t index, DecodeContext &context) { - HiLog::Debug(LABEL, "DoDecode IN index=%{public}u", index); + IMAGE_LOGD("DoDecode IN index=%{public}u", index); uint32_t ret; if (jpegDecoder_ != nullptr) { - HiLog::Info(LABEL, "DoDecode decode by JpegDecoder."); + IMAGE_LOGI("DoDecode decode by JpegDecoder."); ret = jpegDecoder_->Decode(index, context); } else { - HiLog::Error(LABEL, "DoDecode decode unsupport."); + IMAGE_LOGE("DoDecode decode unsupport."); ret = Media::ERR_IMAGE_DATA_UNSUPPORT; } if (ret == Media::SUCCESS) { - HiLog::Info(LABEL, "DoDecode decode success."); + IMAGE_LOGI("DoDecode decode success."); } else { - HiLog::Error(LABEL, "DoDecode decode fail, ret=%{public}u", ret); + IMAGE_LOGE("DoDecode decode fail, ret=%{public}u", ret); } - HiLog::Debug(LABEL, "DoDecode OUT ret=%{public}u", ret); + IMAGE_LOGD("DoDecode OUT ret=%{public}u", ret); return ret; } } // namespace ImagePlugin diff --git a/plugins/common/libs/image/librawplugin/src/raw_stream.cpp b/plugins/common/libs/image/librawplugin/src/raw_stream.cpp index c6f1e1938..2e3c6a84a 100644 --- a/plugins/common/libs/image/librawplugin/src/raw_stream.cpp +++ b/plugins/common/libs/image/librawplugin/src/raw_stream.cpp @@ -13,38 +13,40 @@ * limitations under the License. */ #include "raw_stream.h" -#include "hilog/log.h" -#include "log_tags.h" +#include "image_log.h" + +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "RawStream" + namespace OHOS { namespace ImagePlugin { -using namespace OHOS::HiviewDFX; -namespace { -constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "RawStream" }; -} RawStream::RawStream(InputDataStream &sourceStream) { - HiLog::Debug(LABEL, "create IN"); + IMAGE_LOGD("create IN"); inputStream_ = &sourceStream; - HiLog::Debug(LABEL, "create OUT"); + IMAGE_LOGD("create OUT"); } RawStream::~RawStream() { - HiLog::Debug(LABEL, "release IN"); + IMAGE_LOGD("release IN"); inputStream_ = nullptr; - HiLog::Debug(LABEL, "release OUT"); + IMAGE_LOGD("release OUT"); } // api for piex::StreamInterface piex::Error RawStream::GetData(const size_t offset, const size_t length, uint8_t* data) { if (inputStream_ == nullptr) { - HiLog::Error(LABEL, "GetData, InputStream is null"); + IMAGE_LOGE("GetData, InputStream is null"); return piex::kUnsupported; } @@ -53,24 +55,24 @@ piex::Error RawStream::GetData(const size_t offset, const size_t length, uint8_t if (inputStream_->Tell() != u32Offset) { if (!inputStream_->Seek(u32Offset)) { - HiLog::Error(LABEL, "GetData, seek fail"); + IMAGE_LOGE("GetData, seek fail"); return piex::kFail; } if (inputStream_->Tell() != u32Offset) { - HiLog::Error(LABEL, "GetData, seeked fail"); + IMAGE_LOGE("GetData, seeked fail"); return piex::kFail; } } uint32_t readSize = 0; if (!inputStream_->Read(u32Length, data, u32Length, readSize)) { - HiLog::Error(LABEL, "GetData, read fail"); + IMAGE_LOGE("GetData, read fail"); return piex::kFail; } if (readSize != u32Length) { - HiLog::Error(LABEL, "GetData, read want:%{public}u, real:%{public}u", u32Length, readSize); + IMAGE_LOGE("GetData, read want:%{public}u, real:%{public}u", u32Length, readSize); return piex::kFail; } diff --git a/plugins/common/libs/image/libsvgplugin/src/plugin_export.cpp b/plugins/common/libs/image/libsvgplugin/src/plugin_export.cpp index 52e5cce61..8f21b6641 100644 --- a/plugins/common/libs/image/libsvgplugin/src/plugin_export.cpp +++ b/plugins/common/libs/image/libsvgplugin/src/plugin_export.cpp @@ -18,13 +18,17 @@ #include #include #include "svg_decoder.h" -#include "hilog/log_c.h" -#include "hilog/log_cpp.h" -#include "log_tags.h" +#include "image_log.h" #include "plugin_class_base.h" #include "plugin_utils.h" #include "plugin_export.h" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "LibSvgPlugin" + // plugin package name same as metadata. namespace { const std::string PACKAGE_NAME = ("LibSvgPlugin"); @@ -36,30 +40,25 @@ PLUGIN_EXPORT_REGISTER_CLASS(OHOS::ImagePlugin::SvgDecoder) PLUGIN_EXPORT_REGISTER_CLASS_END using std::string; -using namespace OHOS::HiviewDFX; - -static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "LibSvgPlugin" }; - -#define PLUGIN_LOG_D(...) HiLog::Debug(LABEL, __VA_ARGS__) // define the external interface of this plugin. PLUGIN_EXPORT_DEFAULT_EXTERNAL_START() PLUGIN_EXPORT_DEFAULT_EXTERNAL_STOP() OHOS::MultimediaPlugin::PluginClassBase *PluginExternalCreate(const string &className) { - HiLog::Debug(LABEL, "PluginExternalCreate: create object for package: %{public}s, class: %{public}s.", + IMAGE_LOGD("PluginExternalCreate: create object for package: %{public}s, class: %{public}s.", PACKAGE_NAME.c_str(), className.c_str()); auto iter = implClassMap.find(className); if (iter == implClassMap.end()) { - HiLog::Error(LABEL, "PluginExternalCreate: failed to find class: %{public}s, in package: %{public}s.", + IMAGE_LOGE("PluginExternalCreate: failed to find class: %{public}s, in package: %{public}s.", className.c_str(), PACKAGE_NAME.c_str()); return nullptr; } auto creator = iter->second; if (creator == nullptr) { - HiLog::Error(LABEL, "PluginExternalCreate: null creator for class: %{public}s, in package: %{public}s.", + IMAGE_LOGE("PluginExternalCreate: null creator for class: %{public}s, in package: %{public}s.", className.c_str(), PACKAGE_NAME.c_str()); return nullptr; } diff --git a/plugins/common/libs/image/libsvgplugin/src/svg_decoder.cpp b/plugins/common/libs/image/libsvgplugin/src/svg_decoder.cpp index 6909f197d..e5fb95141 100644 --- a/plugins/common/libs/image/libsvgplugin/src/svg_decoder.cpp +++ b/plugins/common/libs/image/libsvgplugin/src/svg_decoder.cpp @@ -19,22 +19,25 @@ #include "include/core/SkBitmap.h" #include "include/core/SkCanvas.h" #include "include/core/SkImageInfo.h" -#include "hilog/log.h" +#include "image_log.h" #include "image_utils.h" -#include "log_tags.h" #include "media_errors.h" #include "securec.h" #if !defined(IOS_PLATFORM) && !defined(A_PLATFORM) #include "surface_buffer.h" #endif +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "SvgDecoder" + namespace OHOS { namespace ImagePlugin { -using namespace OHOS::HiviewDFX; using namespace MultimediaPlugin; using namespace Media; namespace { -constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "SvgDecoder" }; constexpr uint32_t SVG_IMAGE_NUM = 1; constexpr uint32_t SVG_BYTES_PER_PIXEL = 4; constexpr uint32_t SVG_FILL_COLOR_ATTR_WIDTH = 6; @@ -50,11 +53,11 @@ static inline uint32_t Float2UInt32(float val) bool AllocShareBuffer(DecodeContext &context, uint64_t byteCount) { - HiLog::Debug(LABEL, "[AllocShareBuffer] IN byteCount=%{public}llu", + IMAGE_LOGD("[AllocShareBuffer] IN byteCount=%{public}llu", static_cast(byteCount)); if (byteCount > PIXEL_MAP_MAX_RAM_SIZE) { - HiLog::Error(LABEL, "[AllocShareBuffer] pixelmap buffer size %{public}llu out of max size", + IMAGE_LOGE("[AllocShareBuffer] pixelmap buffer size %{public}llu out of max size", static_cast(byteCount)); return false; } @@ -63,20 +66,20 @@ bool AllocShareBuffer(DecodeContext &context, uint64_t byteCount) std::string name = "SVG RawData, uniqueId: " + std::to_string(getpid()) + '_' + std::to_string(id); int fd = AshmemCreate(name.c_str(), byteCount); if (fd < 0) { - HiLog::Error(LABEL, "[AllocShareBuffer] create fail"); + IMAGE_LOGE("[AllocShareBuffer] create fail"); return false; } int result = AshmemSetProt(fd, PROT_READ | PROT_WRITE); if (result < 0) { - HiLog::Error(LABEL, "[AllocShareBuffer] set fail"); + IMAGE_LOGE("[AllocShareBuffer] set fail"); ::close(fd); return false; } void* ptr = ::mmap(nullptr, byteCount, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if (ptr == MAP_FAILED) { - HiLog::Error(LABEL, "[AllocShareBuffer] map fail"); + IMAGE_LOGE("[AllocShareBuffer] map fail"); ::close(fd); return false; } @@ -84,7 +87,7 @@ bool AllocShareBuffer(DecodeContext &context, uint64_t byteCount) context.pixelsBuffer.buffer = ptr; void *fdBuffer = new int32_t(); if (fdBuffer == nullptr) { - HiLog::Error(LABEL, "[AllocShareBuffer] new fdBuffer fail"); + IMAGE_LOGE("[AllocShareBuffer] new fdBuffer fail"); ::munmap(ptr, byteCount); ::close(fd); context.pixelsBuffer.buffer = nullptr; @@ -97,21 +100,21 @@ bool AllocShareBuffer(DecodeContext &context, uint64_t byteCount) context.allocatorType = AllocatorType::SHARE_MEM_ALLOC; context.freeFunc = nullptr; - HiLog::Debug(LABEL, "[AllocShareBuffer] OUT"); + IMAGE_LOGD("[AllocShareBuffer] OUT"); return true; #else - HiLog::Error(LABEL, "[AllocShareBuffer] Not support Ashmem!"); + IMAGE_LOGE("[AllocShareBuffer] Not support Ashmem!"); return false; #endif } bool AllocDmaBuffer(DecodeContext &context, uint64_t byteCount, SkSize &svgSize) { - HiLog::Debug(LABEL, "[AllocDmaBuffer] IN byteCount=%{public}llu", + IMAGE_LOGD("[AllocDmaBuffer] IN byteCount=%{public}llu", static_cast(byteCount)); if (byteCount > PIXEL_MAP_MAX_RAM_SIZE) { - HiLog::Error(LABEL, "[AllocDmaBuffer] pixelmap buffer size %{public}llu out of max size", + IMAGE_LOGE("[AllocDmaBuffer] pixelmap buffer size %{public}llu out of max size", static_cast(byteCount)); return false; } @@ -129,13 +132,13 @@ bool AllocDmaBuffer(DecodeContext &context, uint64_t byteCount, SkSize &svgSize) }; GSError ret = sb->Alloc(requestConfig); if (ret != GSERROR_OK) { - HiLog::Error(LABEL, "SurfaceBuffer Alloc failed, %{public}s", GSErrorStr(ret).c_str()); + IMAGE_LOGE("SurfaceBuffer Alloc failed, %{public}s", GSErrorStr(ret).c_str()); return false; } void* nativeBuffer = sb.GetRefPtr(); int32_t err = ImageUtils::SurfaceBuffer_Reference(nativeBuffer); if (err != OHOS::GSERROR_OK) { - HiLog::Error(LABEL, "NativeBufferReference failed"); + IMAGE_LOGE("NativeBufferReference failed"); return false; } @@ -145,34 +148,34 @@ bool AllocDmaBuffer(DecodeContext &context, uint64_t byteCount, SkSize &svgSize) context.allocatorType = AllocatorType::DMA_ALLOC; context.freeFunc = nullptr; - HiLog::Debug(LABEL, "[AllocDmaBuffer] OUT"); + IMAGE_LOGD("[AllocDmaBuffer] OUT"); return true; #else - HiLog::Error(LABEL, "[AllocDmaBuffer] Not support dma!"); + IMAGE_LOGE("[AllocDmaBuffer] Not support dma!"); return false; #endif } bool AllocHeapBuffer(DecodeContext &context, uint64_t byteCount) { - HiLog::Debug(LABEL, "[AllocHeapBuffer] IN byteCount=%{public}llu", + IMAGE_LOGD("[AllocHeapBuffer] IN byteCount=%{public}llu", static_cast(byteCount)); if (byteCount > PIXEL_MAP_MAX_RAM_SIZE) { - HiLog::Error(LABEL, "[AllocHeapBuffer] pixelmap buffer size %{public}llu out of max size", + IMAGE_LOGE("[AllocHeapBuffer] pixelmap buffer size %{public}llu out of max size", static_cast(byteCount)); return false; } auto outputBuffer = malloc(byteCount); if (outputBuffer == nullptr) { - HiLog::Error(LABEL, "[AllocHeapBuffer] alloc buffer size:[%{public}llu] failed.", + IMAGE_LOGE("[AllocHeapBuffer] alloc buffer size:[%{public}llu] failed.", static_cast(byteCount)); return false; } if (memset_s(outputBuffer, byteCount, 0, byteCount) != EOK) { - HiLog::Error(LABEL, "[AllocHeapBuffer] memset buffer failed."); + IMAGE_LOGE("[AllocHeapBuffer] memset buffer failed."); free(outputBuffer); outputBuffer = nullptr; return false; @@ -184,7 +187,7 @@ bool AllocHeapBuffer(DecodeContext &context, uint64_t byteCount) context.allocatorType = AllocatorType::HEAP_ALLOC; context.freeFunc = nullptr; - HiLog::Debug(LABEL, "[AllocHeapBuffer] OUT"); + IMAGE_LOGD("[AllocHeapBuffer] OUT"); return true; } @@ -200,35 +203,35 @@ SkImageInfo MakeImageInfo(const PixelDecodeOptions &opts) SvgDecoder::SvgDecoder() { - HiLog::Debug(LABEL, "[Create] IN"); + IMAGE_LOGD("[Create] IN"); - HiLog::Debug(LABEL, "[Create] OUT"); + IMAGE_LOGD("[Create] OUT"); } SvgDecoder::~SvgDecoder() { - HiLog::Debug(LABEL, "[Release] IN"); + IMAGE_LOGD("[Release] IN"); Reset(); - HiLog::Debug(LABEL, "[Release] OUT"); + IMAGE_LOGD("[Release] OUT"); } void SvgDecoder::SetSource(InputDataStream &sourceStream) { - HiLog::Debug(LABEL, "[SetSource] IN"); + IMAGE_LOGD("[SetSource] IN"); Reset(); inputStreamPtr_ = &sourceStream; state_ = SvgDecodingState::SOURCE_INITED; - HiLog::Debug(LABEL, "[SetSource] OUT"); + IMAGE_LOGD("[SetSource] OUT"); } void SvgDecoder::Reset() { - HiLog::Debug(LABEL, "[Reset] IN"); + IMAGE_LOGD("[Reset] IN"); state_ = SvgDecodingState::UNDECIDED; @@ -245,24 +248,24 @@ void SvgDecoder::Reset() PixelDecodeOptions opts; opts_ = opts; - HiLog::Debug(LABEL, "[Reset] OUT"); + IMAGE_LOGD("[Reset] OUT"); } uint32_t SvgDecoder::SetDecodeOptions(uint32_t index, const PixelDecodeOptions &opts, PlImageInfo &info) { if (index >= SVG_IMAGE_NUM) { - HiLog::Error(LABEL, "[SetDecodeOptions] decode image index[%{public}u], out of range[%{public}u].", + IMAGE_LOGE("[SetDecodeOptions] decode image index[%{public}u], out of range[%{public}u].", index, SVG_IMAGE_NUM); return Media::ERR_IMAGE_INVALID_PARAMETER; } - HiLog::Debug(LABEL, "[SetDecodeOptions] IN index=%{public}u, pixelFormat=%{public}d, alphaType=%{public}d, " + IMAGE_LOGD("[SetDecodeOptions] IN index=%{public}u, pixelFormat=%{public}d, alphaType=%{public}d, " "colorSpace=%{public}d, size=(%{public}u, %{public}u), state=%{public}d", index, static_cast(opts.desiredPixelFormat), static_cast(opts.desireAlphaType), static_cast(opts.desiredColorSpace), opts.desiredSize.width, opts.desiredSize.height, state_); if (state_ < SvgDecodingState::SOURCE_INITED) { - HiLog::Error(LABEL, "[SetDecodeOptions] set decode options failed for state %{public}d.", state_); + IMAGE_LOGE("[SetDecodeOptions] set decode options failed for state %{public}d.", state_); return Media::ERR_MEDIA_INVALID_OPERATION; } @@ -273,7 +276,7 @@ uint32_t SvgDecoder::SetDecodeOptions(uint32_t index, const PixelDecodeOptions & if (state_ < SvgDecodingState::BASE_INFO_PARSED) { uint32_t ret = DoDecodeHeader(); if (ret != Media::SUCCESS) { - HiLog::Error(LABEL, "[SetDecodeOptions] decode header error on set decode options, ret:%{public}u.", ret); + IMAGE_LOGE("[SetDecodeOptions] decode header error on set decode options, ret:%{public}u.", ret); state_ = SvgDecodingState::BASE_INFO_PARSING; return ret; } @@ -284,42 +287,42 @@ uint32_t SvgDecoder::SetDecodeOptions(uint32_t index, const PixelDecodeOptions & // only state SvgDecodingState::BASE_INFO_PARSED can go here. uint32_t ret = DoSetDecodeOptions(index, opts, info); if (ret != Media::SUCCESS) { - HiLog::Error(LABEL, "[SetDecodeOptions] do set decode options failed, ret:%{public}u.", ret); + IMAGE_LOGE("[SetDecodeOptions] do set decode options failed, ret:%{public}u.", ret); state_ = SvgDecodingState::BASE_INFO_PARSING; return ret; } state_ = SvgDecodingState::IMAGE_DECODING; - HiLog::Debug(LABEL, "[SetDecodeOptions] OUT"); + IMAGE_LOGD("[SetDecodeOptions] OUT"); return Media::SUCCESS; } uint32_t SvgDecoder::Decode(uint32_t index, DecodeContext &context) { if (index >= SVG_IMAGE_NUM) { - HiLog::Error(LABEL, "[Decode] decode image index[%{public}u], out of range[%{public}u].", + IMAGE_LOGE("[Decode] decode image index[%{public}u], out of range[%{public}u].", index, SVG_IMAGE_NUM); return Media::ERR_IMAGE_INVALID_PARAMETER; } - HiLog::Debug(LABEL, "[Decode] IN index=%{public}u", index); + IMAGE_LOGD("[Decode] IN index=%{public}u", index); if (state_ < SvgDecodingState::IMAGE_DECODING) { - HiLog::Error(LABEL, "[Decode] decode failed for state %{public}d.", state_); + IMAGE_LOGE("[Decode] decode failed for state %{public}d.", state_); return Media::ERR_MEDIA_INVALID_OPERATION; } uint32_t ret = DoDecode(index, context); if (ret == Media::SUCCESS) { - HiLog::Info(LABEL, "[Decode] success."); + IMAGE_LOGI("[Decode] success."); state_ = SvgDecodingState::IMAGE_DECODED; } else { - HiLog::Error(LABEL, "[Decode] fail, ret=%{public}u", ret); + IMAGE_LOGE("[Decode] fail, ret=%{public}u", ret); state_ = SvgDecodingState::IMAGE_ERROR; } - HiLog::Debug(LABEL, "[Decode] OUT ret=%{public}u", ret); + IMAGE_LOGD("[Decode] OUT ret=%{public}u", ret); return ret; } @@ -340,51 +343,51 @@ uint32_t SvgDecoder::GetTopLevelImageNum(uint32_t &num) uint32_t SvgDecoder::GetImageSize(uint32_t index, PlSize &size) { if (index >= SVG_IMAGE_NUM) { - HiLog::Error(LABEL, "[GetImageSize] decode image index[%{public}u], out of range[%{public}u].", + IMAGE_LOGE("[GetImageSize] decode image index[%{public}u], out of range[%{public}u].", index, SVG_IMAGE_NUM); return Media::ERR_IMAGE_INVALID_PARAMETER; } - HiLog::Debug(LABEL, "[GetImageSize] IN index=%{public}u", index); + IMAGE_LOGD("[GetImageSize] IN index=%{public}u", index); if (state_ < SvgDecodingState::SOURCE_INITED) { - HiLog::Error(LABEL, "[GetImageSize] get image size failed for state %{public}d.", state_); + IMAGE_LOGE("[GetImageSize] get image size failed for state %{public}d.", state_); return ERR_MEDIA_INVALID_OPERATION; } if (state_ >= SvgDecodingState::BASE_INFO_PARSED) { DoGetImageSize(index, size); - HiLog::Debug(LABEL, "[GetImageSize] OUT size=(%{public}u, %{public}u)", size.width, size.height); + IMAGE_LOGD("[GetImageSize] OUT size=(%{public}u, %{public}u)", size.width, size.height); return Media::SUCCESS; } // only state SvgDecodingState::SOURCE_INITED and SvgDecodingState::BASE_INFO_PARSING can go here. uint32_t ret = DoDecodeHeader(); if (ret != Media::SUCCESS) { - HiLog::Error(LABEL, "[GetImageSize] decode header error on get image size, ret:%{public}u.", ret); + IMAGE_LOGE("[GetImageSize] decode header error on get image size, ret:%{public}u.", ret); state_ = SvgDecodingState::BASE_INFO_PARSING; return ret; } ret = DoGetImageSize(index, size); if (ret != Media::SUCCESS) { - HiLog::Error(LABEL, "[GetImageSize] do get image size failed, ret:%{public}u.", ret); + IMAGE_LOGE("[GetImageSize] do get image size failed, ret:%{public}u.", ret); state_ = SvgDecodingState::BASE_INFO_PARSING; return ret; } state_ = SvgDecodingState::BASE_INFO_PARSED; - HiLog::Debug(LABEL, "[GetImageSize] OUT size=(%{public}u, %{public}u)", size.width, size.height); + IMAGE_LOGD("[GetImageSize] OUT size=(%{public}u, %{public}u)", size.width, size.height); return Media::SUCCESS; } bool SvgDecoder::AllocBuffer(DecodeContext &context) { - HiLog::Debug(LABEL, "[AllocBuffer] IN"); + IMAGE_LOGD("[AllocBuffer] IN"); if (svgDom_ == nullptr) { - HiLog::Error(LABEL, "[AllocBuffer] DOM is null."); + IMAGE_LOGE("[AllocBuffer] DOM is null."); return false; } @@ -392,7 +395,7 @@ bool SvgDecoder::AllocBuffer(DecodeContext &context) if (context.pixelsBuffer.buffer == nullptr) { auto svgSize = svgDom_->containerSize(); if (svgSize.isEmpty()) { - HiLog::Error(LABEL, "[AllocBuffer] size is empty."); + IMAGE_LOGE("[AllocBuffer] size is empty."); return false; } uint32_t width = Float2UInt32(svgSize.width()); @@ -407,16 +410,16 @@ bool SvgDecoder::AllocBuffer(DecodeContext &context) } } - HiLog::Debug(LABEL, "[AllocBuffer] OUT ret=%{public}d", ret); + IMAGE_LOGD("[AllocBuffer] OUT ret=%{public}d", ret); return ret; } bool SvgDecoder::BuildStream() { - HiLog::Debug(LABEL, "[BuildStream] IN"); + IMAGE_LOGD("[BuildStream] IN"); if (inputStreamPtr_ == nullptr) { - HiLog::Error(LABEL, "[BuildStream] Stream is null."); + IMAGE_LOGE("[BuildStream] Stream is null."); return false; } @@ -427,13 +430,13 @@ bool SvgDecoder::BuildStream() auto data = std::make_unique(length); uint32_t readSize = 0; if (!inputStreamPtr_->Read(length, data.get(), length, readSize)) { - HiLog::Error(LABEL, "[BuildStream] read failed."); + IMAGE_LOGE("[BuildStream] read failed."); return false; } svgStream_ = std::make_unique(data.get(), length, true); } - HiLog::Debug(LABEL, "[BuildStream] OUT"); + IMAGE_LOGD("[BuildStream] OUT"); return true; } @@ -442,7 +445,7 @@ static void SetSVGFillColor(SkSVGNode* node, std::string color) if (node == nullptr) { return; } - HiLog::Debug(LABEL, "[SetSVGFillColor] node tag %{public}d %{public}s.", node->tag(), color.c_str()); + IMAGE_LOGD("[SetSVGFillColor] node tag %{public}d %{public}s.", node->tag(), color.c_str()); node->setAttribute(SVG_FILL_COLOR_ATTR.c_str(), color.c_str()); for (auto childNode : node->getChild()) { SetSVGFillColor(childNode.get(), color); @@ -461,56 +464,56 @@ static void SetSVGFillColor(SkSVGNode* node, uint32_t color) bool SvgDecoder::BuildDom() { - HiLog::Debug(LABEL, "[BuildDom] IN"); + IMAGE_LOGD("[BuildDom] IN"); if (svgStream_ == nullptr) { - HiLog::Error(LABEL, "[BuildDom] Stream is null."); + IMAGE_LOGE("[BuildDom] Stream is null."); return false; } svgDom_ = SkSVGDOM::MakeFromStream(*(svgStream_.get())); if (svgDom_ == nullptr) { - HiLog::Error(LABEL, "[BuildDom] DOM is null."); + IMAGE_LOGE("[BuildDom] DOM is null."); return false; } svgSize_ = svgDom_->containerSize(); if (svgSize_.isEmpty()) { - HiLog::Error(LABEL, "[BuildDom] size is empty."); + IMAGE_LOGE("[BuildDom] size is empty."); return false; } auto width = Float2UInt32(svgSize_.width()); auto height = Float2UInt32(svgSize_.height()); - HiLog::Debug(LABEL, "[BuildDom] OUT size=(%{public}u, %{public}u)", width, height); + IMAGE_LOGD("[BuildDom] OUT size=(%{public}u, %{public}u)", width, height); return true; } uint32_t SvgDecoder::DoDecodeHeader() { - HiLog::Debug(LABEL, "[DoDecodeHeader] IN"); + IMAGE_LOGD("[DoDecodeHeader] IN"); if (!BuildStream()) { - HiLog::Error(LABEL, "[DoDecodeHeader] Build Stream failed"); + IMAGE_LOGE("[DoDecodeHeader] Build Stream failed"); return Media::ERR_IMAGE_TOO_LARGE; } if (!BuildDom()) { - HiLog::Error(LABEL, "[DoDecodeHeader] Build DOM failed"); + IMAGE_LOGE("[DoDecodeHeader] Build DOM failed"); return Media::ERR_IMAGE_DATA_UNSUPPORT; } - HiLog::Debug(LABEL, "[DoDecodeHeader] OUT"); + IMAGE_LOGD("[DoDecodeHeader] OUT"); return Media::SUCCESS; } uint32_t SvgDecoder::DoSetDecodeOptions(uint32_t index, const PixelDecodeOptions &opts, PlImageInfo &info) { - HiLog::Debug(LABEL, "[DoSetDecodeOptions] IN index=%{public}u", index); + IMAGE_LOGD("[DoSetDecodeOptions] IN index=%{public}u", index); if (svgDom_ == nullptr) { - HiLog::Error(LABEL, "[DoSetDecodeOptions] DOM is null."); + IMAGE_LOGE("[DoSetDecodeOptions] DOM is null."); return Media::ERROR; } @@ -518,7 +521,7 @@ uint32_t SvgDecoder::DoSetDecodeOptions(uint32_t index, const PixelDecodeOptions auto svgSize = svgDom_->containerSize(); if (svgSize.isEmpty()) { - HiLog::Error(LABEL, "[DoSetDecodeOptions] size is empty."); + IMAGE_LOGE("[DoSetDecodeOptions] size is empty."); return Media::ERROR; } @@ -543,7 +546,7 @@ uint32_t SvgDecoder::DoSetDecodeOptions(uint32_t index, const PixelDecodeOptions info.colorSpace = PlColorSpace::UNKNOWN; info.alphaType = PlAlphaType::IMAGE_ALPHA_TYPE_PREMUL; - HiLog::Debug(LABEL, "[DoSetDecodeOptions] OUT pixelFormat=%{public}d, alphaType=%{public}d, " + IMAGE_LOGD("[DoSetDecodeOptions] OUT pixelFormat=%{public}d, alphaType=%{public}d, " "colorSpace=%{public}d, size=(%{public}u, %{public}u)", static_cast(info.pixelFormat), static_cast(info.alphaType), static_cast(info.colorSpace), info.size.width, info.size.height); @@ -552,32 +555,32 @@ uint32_t SvgDecoder::DoSetDecodeOptions(uint32_t index, const PixelDecodeOptions uint32_t SvgDecoder::DoGetImageSize(uint32_t index, PlSize &size) { - HiLog::Debug(LABEL, "[DoGetImageSize] IN index=%{public}u", index); + IMAGE_LOGD("[DoGetImageSize] IN index=%{public}u", index); if (svgDom_ == nullptr) { - HiLog::Error(LABEL, "[DoGetImageSize] DOM is null."); + IMAGE_LOGE("[DoGetImageSize] DOM is null."); return Media::ERROR; } auto svgSize = svgDom_->containerSize(); if (svgSize.isEmpty()) { - HiLog::Error(LABEL, "[DoGetImageSize] size is empty."); + IMAGE_LOGE("[DoGetImageSize] size is empty."); return Media::ERROR; } size.width = Float2UInt32(svgSize.width()); size.height = Float2UInt32(svgSize.height()); - HiLog::Debug(LABEL, "[DoGetImageSize] OUT size=(%{public}u, %{public}u)", size.width, size.height); + IMAGE_LOGD("[DoGetImageSize] OUT size=(%{public}u, %{public}u)", size.width, size.height); return Media::SUCCESS; } uint32_t SvgDecoder::DoDecode(uint32_t index, DecodeContext &context) { - HiLog::Debug(LABEL, "[DoDecode] IN index=%{public}u", index); + IMAGE_LOGD("[DoDecode] IN index=%{public}u", index); if (svgDom_ == nullptr) { - HiLog::Error(LABEL, "[DoDecode] DOM is null."); + IMAGE_LOGE("[DoDecode] DOM is null."); return Media::ERROR; } @@ -586,7 +589,7 @@ uint32_t SvgDecoder::DoDecode(uint32_t index, DecodeContext &context) } if (!AllocBuffer(context)) { - HiLog::Error(LABEL, "[DoDecode] alloc buffer failed."); + IMAGE_LOGE("[DoDecode] alloc buffer failed."); return Media::ERR_IMAGE_MALLOC_ABNORMAL; } @@ -596,13 +599,13 @@ uint32_t SvgDecoder::DoDecode(uint32_t index, DecodeContext &context) SkBitmap bitmap; if (!bitmap.installPixels(imageInfo, pixels, rowBytes)) { - HiLog::Error(LABEL, "[DoDecode] bitmap install pixels failed."); + IMAGE_LOGE("[DoDecode] bitmap install pixels failed."); return Media::ERROR; } auto canvas = SkCanvas::MakeRasterDirect(imageInfo, bitmap.getPixels(), bitmap.rowBytes()); if (canvas == nullptr) { - HiLog::Error(LABEL, "[DoDecode] make canvas failed."); + IMAGE_LOGE("[DoDecode] make canvas failed."); return Media::ERROR; } canvas->clear(SK_ColorTRANSPARENT); @@ -610,11 +613,11 @@ uint32_t SvgDecoder::DoDecode(uint32_t index, DecodeContext &context) bool result = canvas->readPixels(imageInfo, pixels, rowBytes, 0, 0); if (!result) { - HiLog::Error(LABEL, "[DoDecode] read pixels failed."); + IMAGE_LOGE("[DoDecode] read pixels failed."); return Media::ERROR; } - HiLog::Debug(LABEL, "[DoDecode] OUT"); + IMAGE_LOGD("[DoDecode] OUT"); return Media::SUCCESS; } } // namespace ImagePlugin diff --git a/plugins/common/libs/image/libwebpplugin/BUILD.gn b/plugins/common/libs/image/libwebpplugin/BUILD.gn index cc55b486e..4750dca00 100644 --- a/plugins/common/libs/image/libwebpplugin/BUILD.gn +++ b/plugins/common/libs/image/libwebpplugin/BUILD.gn @@ -79,8 +79,10 @@ ohos_shared_library("webpplugin") { "c_utils:utils", "graphic_2d:color_manager", "graphic_surface:surface", + "hilog:libhilog", ] } + cflags = [ "-DIMAGE_COLORSPACE_FLAG" ] part_name = "image_framework" diff --git a/plugins/common/libs/image/libwebpplugin/src/plugin_export.cpp b/plugins/common/libs/image/libwebpplugin/src/plugin_export.cpp index d4620ea75..7b9a874f2 100644 --- a/plugins/common/libs/image/libwebpplugin/src/plugin_export.cpp +++ b/plugins/common/libs/image/libwebpplugin/src/plugin_export.cpp @@ -14,12 +14,17 @@ */ #include "plugin_export.h" -#include "hilog/log.h" -#include "log_tags.h" +#include "image_log.h" #include "plugin_utils.h" #include "webp_decoder.h" #include "webp_encoder.h" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "LibWebpPlugin" + // plugin package name same as metadata. namespace { const std::string PACKAGE_NAME = ("LibWebpPlugin"); @@ -32,32 +37,26 @@ PLUGIN_EXPORT_REGISTER_CLASS(OHOS::ImagePlugin::WebpEncoder) PLUGIN_EXPORT_REGISTER_CLASS_END using std::string; -using namespace OHOS::HiviewDFX; - -static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "LibWebpPlugin" }; - -#define PLUGIN_LOG_D(...) HiLog::Debug(LABEL, __VA_ARGS__) -#define PLUGIN_LOG_E(...) HiLog::Error(LABEL, __VA_ARGS__) // define the external interface of this plugin. PLUGIN_EXPORT_DEFAULT_EXTERNAL_START() PLUGIN_EXPORT_DEFAULT_EXTERNAL_STOP() OHOS::MultimediaPlugin::PluginClassBase *PluginExternalCreate(const string &className) { - HiLog::Debug(LABEL, "PluginExternalCreate: create object for package: %{public}s, class: %{public}s.", - PACKAGE_NAME.c_str(), className.c_str()); + IMAGE_LOGD("PluginExternalCreate: create object for package: %{public}s, class: %{public}s.", + PACKAGE_NAME.c_str(), className.c_str()); auto iter = implClassMap.find(className); if (iter == implClassMap.end()) { - HiLog::Error(LABEL, "PluginExternalCreate: failed to find class: %{public}s, in package: %{public}s.", - className.c_str(), PACKAGE_NAME.c_str()); + IMAGE_LOGE("PluginExternalCreate: failed to find class: %{public}s, in package: %{public}s.", + className.c_str(), PACKAGE_NAME.c_str()); return nullptr; } auto creator = iter->second; if (creator == nullptr) { - HiLog::Error(LABEL, "PluginExternalCreate: null creator for class: %{public}s, in package: %{public}s.", - className.c_str(), PACKAGE_NAME.c_str()); + IMAGE_LOGE("PluginExternalCreate: null creator for class: %{public}s, in package: %{public}s.", + className.c_str(), PACKAGE_NAME.c_str()); return nullptr; } diff --git a/plugins/common/libs/image/libwebpplugin/src/webp_decoder.cpp b/plugins/common/libs/image/libwebpplugin/src/webp_decoder.cpp index dd2e833d0..56c156de5 100644 --- a/plugins/common/libs/image/libwebpplugin/src/webp_decoder.cpp +++ b/plugins/common/libs/image/libwebpplugin/src/webp_decoder.cpp @@ -15,9 +15,8 @@ #include "webp_decoder.h" -#include "hilog/log.h" +#include "image_log.h" #include "image_utils.h" -#include "log_tags.h" #include "media_errors.h" #include "multimedia_templates.h" #include "securec.h" @@ -25,15 +24,19 @@ #include "surface_buffer.h" #endif +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "WebpDecoder" + namespace OHOS { namespace ImagePlugin { -using namespace OHOS::HiviewDFX; using namespace MultimediaPlugin; using namespace Media; using namespace MultiMedia; namespace { -constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "WebpDecoder" }; constexpr int32_t WEBP_IMAGE_NUM = 1; constexpr int32_t EXTERNAL_MEMORY = 1; constexpr size_t DECODE_VP8CHUNK_MIN_SIZE = 4096; @@ -56,11 +59,11 @@ void WebpDecoder::SetSource(InputDataStream &sourceStream) uint32_t WebpDecoder::GetImageSize(uint32_t index, PlSize &size) { if (index >= WEBP_IMAGE_NUM) { - HiLog::Error(LABEL, "image size:invalid index, index:%{public}u, range:%{public}u.", index, WEBP_IMAGE_NUM); + IMAGE_LOGE("image size:invalid index, index:%{public}u, range:%{public}u.", index, WEBP_IMAGE_NUM); return ERR_IMAGE_INVALID_PARAMETER; } if (state_ < WebpDecodingState::SOURCE_INITED) { - HiLog::Error(LABEL, "get image size failed for state %{public}d.", state_); + IMAGE_LOGE("get image size failed for state %{public}d.", state_); return ERR_MEDIA_INVALID_OPERATION; } if (state_ >= WebpDecodingState::BASE_INFO_PARSED) { @@ -70,7 +73,7 @@ uint32_t WebpDecoder::GetImageSize(uint32_t index, PlSize &size) uint32_t ret = DecodeHeader(); if (ret != SUCCESS) { - HiLog::Debug(LABEL, "decode header error on get image ret:%{public}u.", ret); + IMAGE_LOGD("decode header error on get image ret:%{public}u.", ret); return ret; } size = webpSize_; @@ -80,11 +83,11 @@ uint32_t WebpDecoder::GetImageSize(uint32_t index, PlSize &size) uint32_t WebpDecoder::SetDecodeOptions(uint32_t index, const PixelDecodeOptions &opts, PlImageInfo &info) { if (index >= WEBP_IMAGE_NUM) { - HiLog::Error(LABEL, "set option:invalid index, index:%{public}u, range:%{public}u.", index, WEBP_IMAGE_NUM); + IMAGE_LOGE("set option:invalid index, index:%{public}u, range:%{public}u.", index, WEBP_IMAGE_NUM); return ERR_IMAGE_INVALID_PARAMETER; } if (state_ < WebpDecodingState::SOURCE_INITED) { - HiLog::Error(LABEL, "set decode option failed for state %{public}d.", state_); + IMAGE_LOGE("set decode option failed for state %{public}d.", state_); return ERR_MEDIA_INVALID_OPERATION; } if (state_ >= WebpDecodingState::IMAGE_DECODING) { @@ -94,7 +97,7 @@ uint32_t WebpDecoder::SetDecodeOptions(uint32_t index, const PixelDecodeOptions if (state_ < WebpDecodingState::BASE_INFO_PARSED) { uint32_t ret = DecodeHeader(); if (ret != SUCCESS) { - HiLog::Error(LABEL, "decode header error on set decode options:%{public}u.", ret); + IMAGE_LOGE("decode header error on set decode options:%{public}u.", ret); state_ = WebpDecodingState::BASE_INFO_PARSING; return ret; } @@ -124,18 +127,18 @@ uint32_t WebpDecoder::Decode(uint32_t index, DecodeContext &context) context.allocatorType = Media::AllocatorType::HEAP_ALLOC; #endif if (index >= WEBP_IMAGE_NUM) { - HiLog::Error(LABEL, "decode:invalid index, index:%{public}u, range:%{public}u.", index, WEBP_IMAGE_NUM); + IMAGE_LOGE("decode:invalid index, index:%{public}u, range:%{public}u.", index, WEBP_IMAGE_NUM); return ERR_IMAGE_INVALID_PARAMETER; } if (state_ < WebpDecodingState::IMAGE_DECODING) { - HiLog::Error(LABEL, "set decode option failed for state %{public}d.", state_); + IMAGE_LOGE("set decode option failed for state %{public}d.", state_); return ERR_MEDIA_INVALID_OPERATION; } if (state_ > WebpDecodingState::IMAGE_DECODING) { FinishOldDecompress(); uint32_t ret = DecodeHeader(); if (ret != SUCCESS) { - HiLog::Error(LABEL, "decode header error on set decode options:%{public}u.", ret); + IMAGE_LOGE("decode header error on set decode options:%{public}u.", ret); state_ = WebpDecodingState::BASE_INFO_PARSING; return ret; } @@ -156,17 +159,17 @@ uint32_t WebpDecoder::PromoteIncrementalDecode(uint32_t index, ProgDecodeContext { context.totalProcessProgress = 0; if (index >= WEBP_IMAGE_NUM) { - HiLog::Error(LABEL, "incremental:invalid index, index:%{public}u, range:%{public}u.", index, WEBP_IMAGE_NUM); + IMAGE_LOGE("incremental:invalid index, index:%{public}u, range:%{public}u.", index, WEBP_IMAGE_NUM); return ERR_IMAGE_INVALID_PARAMETER; } if (state_ != WebpDecodingState::IMAGE_DECODING) { - HiLog::Error(LABEL, "incremental decode failed for state %{public}d.", state_); + IMAGE_LOGE("incremental decode failed for state %{public}d.", state_); return ERR_MEDIA_INVALID_OPERATION; } if (!IsDataEnough()) { - HiLog::Debug(LABEL, "increment data not enough, need next data."); + IMAGE_LOGD("increment data not enough, need next data."); return ERR_IMAGE_SOURCE_DATA_INCOMPLETE; } return DoIncrementalDecode(context); @@ -180,7 +183,7 @@ uint32_t WebpDecoder::DecodeHeader() state_ = WebpDecodingState::BASE_INFO_PARSING; } else { state_ = WebpDecodingState::SOURCE_INITED; - HiLog::Error(LABEL, "decode image head failed, ret:%{public}u.", ret); + IMAGE_LOGE("decode image head failed, ret:%{public}u.", ret); } return ret; } @@ -194,11 +197,11 @@ uint32_t WebpDecoder::ReadIncrementalHead() if (stremSize >= DECODE_VP8CHUNK_MIN_SIZE || stream_->IsStreamCompleted()) { stream_->Seek(0); if (!stream_->Read(stream_->GetStreamSize(), dataBuffer_)) { - HiLog::Error(LABEL, "read data fail."); + IMAGE_LOGE("read data fail."); return ERR_IMAGE_SOURCE_DATA_INCOMPLETE; } if (dataBuffer_.inputStreamBuffer == nullptr || dataBuffer_.dataSize == 0) { - HiLog::Error(LABEL, "inputStreamBuffer is null or data size is %{public}u.", dataBuffer_.dataSize); + IMAGE_LOGE("inputStreamBuffer is null or data size is %{public}u.", dataBuffer_.dataSize); return ERR_IMAGE_GET_DATA_ABNORMAL; } @@ -207,12 +210,12 @@ uint32_t WebpDecoder::ReadIncrementalHead() int32_t ret = WebPGetInfo(dataBuffer_.inputStreamBuffer, dataBuffer_.bufferSize, &width, &height); if (ret == 0 || (width == 0 && height == 0)) { // may be incomplete data - HiLog::Error(LABEL, "get width and height fail."); + IMAGE_LOGE("get width and height fail."); return ERR_IMAGE_SOURCE_DATA_INCOMPLETE; } if (width < 0 || height < 0) { - HiLog::Error(LABEL, "width and height invalid, width:%{public}d, height:%{public}d.", width, height); + IMAGE_LOGE("width and height invalid, width:%{public}d, height:%{public}d.", width, height); return ERR_IMAGE_INVALID_PARAMETER; } webpSize_.width = static_cast(width); @@ -274,7 +277,7 @@ uint32_t WebpDecoder::DoCommonDecode(DecodeContext &context) { WebPDecoderConfig config; if (!PreDecodeProc(context, config, false)) { - HiLog::Error(LABEL, "prepare common decode failed."); + IMAGE_LOGE("prepare common decode failed."); state_ = WebpDecodingState::IMAGE_ERROR; return ERR_IMAGE_MALLOC_ABNORMAL; } @@ -282,7 +285,7 @@ uint32_t WebpDecoder::DoCommonDecode(DecodeContext &context) TAutoCallProc webpOutput(&config.output); TAutoCallProc idec(WebPINewDecoder(&config.output)); if (idec == nullptr) { - HiLog::Error(LABEL, "common decode:idec is null."); + IMAGE_LOGE("common decode:idec is null."); state_ = WebpDecodingState::IMAGE_ERROR; return ERR_IMAGE_DECODE_FAILED; } @@ -295,11 +298,11 @@ uint32_t WebpDecoder::DoCommonDecode(DecodeContext &context) if (status == VP8_STATUS_SUSPENDED && opts_.allowPartialImage) { state_ = WebpDecodingState::IMAGE_PARTIAL; context.ifPartialOutput = true; - HiLog::Info(LABEL, "this is partial image data to decode."); + IMAGE_LOGI("this is partial image data to decode."); return SUCCESS; } - HiLog::Error(LABEL, "decode image data failed, status:%{public}d.", status); + IMAGE_LOGE("decode image data failed, status:%{public}d.", status); state_ = WebpDecodingState::IMAGE_ERROR; return ERR_IMAGE_DECODE_FAILED; } @@ -308,37 +311,37 @@ uint32_t WebpDecoder::DoIncrementalDecode(ProgDecodeContext &context) { WebPDecoderConfig config; if (!PreDecodeProc(context.decodeContext, config, true)) { - HiLog::Error(LABEL, "prepare increment decode failed."); + IMAGE_LOGE("prepare increment decode failed."); return ERR_IMAGE_MALLOC_ABNORMAL; } TAutoCallProc webpOutput(&config.output); TAutoCallProc idec(WebPINewDecoder(&config.output)); if (idec == nullptr) { - HiLog::Error(LABEL, "incremental code:idec is null."); + IMAGE_LOGE("incremental code:idec is null."); return ERR_IMAGE_DECODE_FAILED; } dataBuffer_ = { nullptr, 0, 0 }; stream_->Seek(0); if (!stream_->Read(stream_->GetStreamSize(), dataBuffer_)) { - HiLog::Error(LABEL, "incremental:read data failed."); + IMAGE_LOGE("incremental:read data failed."); return ERR_IMAGE_DECODE_FAILED; } if (dataBuffer_.inputStreamBuffer == nullptr || dataBuffer_.dataSize == 0) { - HiLog::Error(LABEL, "incremental:data is null."); + IMAGE_LOGE("incremental:data is null."); return ERR_IMAGE_DECODE_FAILED; } VP8StatusCode status = WebPIUpdate(idec, dataBuffer_.inputStreamBuffer, static_cast(dataBuffer_.dataSize)); if (status != VP8_STATUS_OK && status != VP8_STATUS_SUSPENDED) { - HiLog::Error(LABEL, "incremental:webp status exception,status:%{public}d.", status); + IMAGE_LOGE("incremental:webp status exception,status:%{public}d.", status); return ERR_IMAGE_DECODE_FAILED; } if (status == VP8_STATUS_SUSPENDED) { int32_t curHeight = 0; if (WebPIDecGetRGB(idec, &curHeight, nullptr, nullptr, nullptr) == nullptr) { - HiLog::Debug(LABEL, "refresh image failed, current height:%{public}d.", curHeight); + IMAGE_LOGD("refresh image failed, current height:%{public}d.", curHeight); } if (curHeight > 0 && webpSize_.height != 0) { context.totalProcessProgress = @@ -365,11 +368,11 @@ void WebpDecoder::InitWebpOutput(const DecodeContext &context, WebPDecBuffer &ou bool WebpDecoder::PreDecodeProc(DecodeContext &context, WebPDecoderConfig &config, bool isIncremental) { if (WebPInitDecoderConfig(&config) == 0) { - HiLog::Error(LABEL, "init config failed."); + IMAGE_LOGE("init config failed."); return false; } if (!AllocOutputBuffer(context, isIncremental)) { - HiLog::Error(LABEL, "get pixels memory failed."); + IMAGE_LOGE("get pixels memory failed."); return false; } @@ -387,7 +390,7 @@ void WebpDecoder::Reset() static bool SharedMemoryCreate(DecodeContext &context, const uint32_t &byteCount) { #if defined(_WIN32) || defined(_APPLE) || defined(A_PLATFORM) || defined(IOS_PLATFORM) - HiLog::Error(LABEL, "Unsupport dma mem alloc"); + IMAGE_LOGE("Unsupport dma mem alloc"); return false; #else uint32_t id = context.pixelmapUniqueId_; @@ -409,7 +412,7 @@ static bool SharedMemoryCreate(DecodeContext &context, const uint32_t &byteCount context.pixelsBuffer.buffer = ptr; void *fdBuffer = new int32_t(); if (fdBuffer == nullptr) { - HiLog::Error(LABEL, "malloc fdBuffer fail"); + IMAGE_LOGE("malloc fdBuffer fail"); ::munmap(ptr, byteCount); ::close(fd); context.pixelsBuffer.buffer = nullptr; @@ -427,26 +430,26 @@ static bool SharedMemoryCreate(DecodeContext &context, const uint32_t &byteCount static bool HeapMemoryCreate(DecodeContext &context, const uint32_t &byteCount) { if (byteCount == 0 || byteCount > PIXEL_MAP_MAX_RAM_SIZE) { - HiLog::Error(LABEL, "Invalid value of byteCount"); + IMAGE_LOGE("Invalid value of byteCount"); return false; } void *outputBuffer = malloc(byteCount); if (outputBuffer == nullptr) { - HiLog::Error(LABEL, "alloc output buffer size:[%{public}llu] error.", + IMAGE_LOGE("alloc output buffer size:[%{public}llu] error.", static_cast(byteCount)); return false; } #ifdef _WIN32 errno_t backRet = memset_s(outputBuffer, 0, byteCount); if (backRet != EOK) { - HiLog::Error(LABEL, "memset buffer failed.", backRet); + IMAGE_LOGE("memset buffer failed.", backRet); free(outputBuffer); outputBuffer = nullptr; return false; } #else if (memset_s(outputBuffer, byteCount, 0, byteCount) != EOK) { - HiLog::Error(LABEL, "memset buffer failed."); + IMAGE_LOGE("memset buffer failed."); free(outputBuffer); outputBuffer = nullptr; return false; @@ -463,7 +466,7 @@ static bool HeapMemoryCreate(DecodeContext &context, const uint32_t &byteCount) static bool DmaMemoryCreate(DecodeContext &context, const uint32_t &byteCount, const PlSize &webpSize) { #if defined(_WIN32) || defined(_APPLE) || defined(A_PLATFORM) || defined(IOS_PLATFORM) - HiLog::Error(LABEL, "Unsupport dma mem alloc"); + IMAGE_LOGE("Unsupport dma mem alloc"); return false; #else sptr sb = SurfaceBuffer::Create(); @@ -479,13 +482,13 @@ static bool DmaMemoryCreate(DecodeContext &context, const uint32_t &byteCount, c }; GSError ret = sb->Alloc(requestConfig); if (ret != GSERROR_OK) { - HiLog::Error(LABEL, "SurfaceBuffer Alloc failed, %{public}s", GSErrorStr(ret).c_str()); + IMAGE_LOGE("SurfaceBuffer Alloc failed, %{public}s", GSErrorStr(ret).c_str()); return false; } void* nativeBuffer = sb.GetRefPtr(); int32_t err = ImageUtils::SurfaceBuffer_Reference(nativeBuffer); if (err != OHOS::GSERROR_OK) { - HiLog::Error(LABEL, "NativeBufferReference failed"); + IMAGE_LOGE("NativeBufferReference failed"); return false; } diff --git a/plugins/common/libs/image/libwebpplugin/src/webp_encoder.cpp b/plugins/common/libs/image/libwebpplugin/src/webp_encoder.cpp index 43d74c5f8..445b7def1 100644 --- a/plugins/common/libs/image/libwebpplugin/src/webp_encoder.cpp +++ b/plugins/common/libs/image/libwebpplugin/src/webp_encoder.cpp @@ -14,17 +14,21 @@ */ #include "webp_encoder.h" #include "webp/mux.h" -#include "hilog/log.h" -#include "log_tags.h" +#include "image_log.h" #include "media_errors.h" #include "pixel_convert_adapter.h" + +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "WebpEncoder" + namespace OHOS { namespace ImagePlugin { -using namespace OHOS::HiviewDFX; using namespace MultimediaPlugin; using namespace Media; namespace { -constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "WebpEncoder" }; constexpr uint32_t WEBP_IMAGE_NUM = 1; constexpr uint32_t COMPONENT_NUM_3 = 3; constexpr uint32_t COMPONENT_NUM_4 = 4; @@ -32,7 +36,7 @@ constexpr uint32_t COMPONENT_NUM_4 = 4; static int StreamWriter(const uint8_t* data, size_t data_size, const WebPPicture* const picture) { - HiLog::Debug(LABEL, "StreamWriter data_size=%{public}zu", data_size); + IMAGE_LOGD("StreamWriter data_size=%{public}zu", data_size); auto webpEncoder = static_cast(picture->custom_ptr); return webpEncoder->Write(data, data_size) ? 1 : 0; @@ -40,23 +44,23 @@ static int StreamWriter(const uint8_t* data, size_t data_size, const WebPPicture WebpEncoder::WebpEncoder() { - HiLog::Debug(LABEL, "create IN"); + IMAGE_LOGD("create IN"); - HiLog::Debug(LABEL, "create OUT"); + IMAGE_LOGD("create OUT"); } WebpEncoder::~WebpEncoder() { - HiLog::Debug(LABEL, "release IN"); + IMAGE_LOGD("release IN"); pixelMaps_.clear(); - HiLog::Debug(LABEL, "release OUT"); + IMAGE_LOGD("release OUT"); } uint32_t WebpEncoder::StartEncode(OutputDataStream &outputStream, PlEncodeOptions &option) { - HiLog::Debug(LABEL, "StartEncode IN, quality=%{public}u, numberHint=%{public}u", + IMAGE_LOGD("StartEncode IN, quality=%{public}u, numberHint=%{public}u", option.quality, option.numberHint); pixelMaps_.clear(); @@ -64,35 +68,35 @@ uint32_t WebpEncoder::StartEncode(OutputDataStream &outputStream, PlEncodeOption outputStream_ = &outputStream; encodeOpts_ = option; - HiLog::Debug(LABEL, "StartEncode OUT"); + IMAGE_LOGD("StartEncode OUT"); return SUCCESS; } uint32_t WebpEncoder::AddImage(Media::PixelMap &pixelMap) { - HiLog::Debug(LABEL, "AddImage IN"); + IMAGE_LOGD("AddImage IN"); if (pixelMaps_.size() >= WEBP_IMAGE_NUM) { - HiLog::Error(LABEL, "AddImage, add pixel map out of range=%{public}u.", WEBP_IMAGE_NUM); + IMAGE_LOGE("AddImage, add pixel map out of range=%{public}u.", WEBP_IMAGE_NUM); return ERR_IMAGE_ADD_PIXEL_MAP_FAILED; } pixelMaps_.push_back(&pixelMap); - HiLog::Debug(LABEL, "AddImage OUT"); + IMAGE_LOGD("AddImage OUT"); return SUCCESS; } uint32_t WebpEncoder::FinalizeEncode() { - HiLog::Debug(LABEL, "FinalizeEncode IN"); + IMAGE_LOGD("FinalizeEncode IN"); if (pixelMaps_.empty()) { - HiLog::Error(LABEL, "FinalizeEncode, no pixel map input."); + IMAGE_LOGE("FinalizeEncode, no pixel map input."); return ERR_IMAGE_INVALID_PARAMETER; } - HiLog::Debug(LABEL, "FinalizeEncode, quality=%{public}u, numberHint=%{public}u", + IMAGE_LOGD("FinalizeEncode, quality=%{public}u, numberHint=%{public}u", encodeOpts_.quality, encodeOpts_.numberHint); uint32_t errorCode = ERROR; @@ -103,29 +107,29 @@ uint32_t WebpEncoder::FinalizeEncode() WebPPictureInit(&webpPicture); errorCode = SetEncodeConfig(pixelMap, webpConfig, webpPicture); - HiLog::Debug(LABEL, "FinalizeEncode, config, %{public}u.", errorCode); + IMAGE_LOGD("FinalizeEncode, config, %{public}u.", errorCode); if (errorCode != SUCCESS) { - HiLog::Error(LABEL, "FinalizeEncode, config failed=%{public}u.", errorCode); + IMAGE_LOGE("FinalizeEncode, config failed=%{public}u.", errorCode); WebPPictureFree(&webpPicture); return errorCode; } errorCode = DoEncode(pixelMap, webpConfig, webpPicture); - HiLog::Debug(LABEL, "FinalizeEncode, encode,%{public}u.", errorCode); + IMAGE_LOGD("FinalizeEncode, encode,%{public}u.", errorCode); WebPPictureFree(&webpPicture); if (errorCode != SUCCESS) { - HiLog::Error(LABEL, "FinalizeEncode, encode failed=%{public}u.", errorCode); + IMAGE_LOGE("FinalizeEncode, encode failed=%{public}u.", errorCode); } - HiLog::Debug(LABEL, "FinalizeEncode OUT"); + IMAGE_LOGD("FinalizeEncode OUT"); return errorCode; } bool WebpEncoder::Write(const uint8_t* data, size_t data_size) { - HiLog::Debug(LABEL, "Write data_size=%{public}zu, iccValid=%{public}d", data_size, iccValid_); + IMAGE_LOGD("Write data_size=%{public}zu, iccValid=%{public}d", data_size, iccValid_); if (iccValid_) { return memoryStream_.write(data, data_size); @@ -137,40 +141,40 @@ bool WebpEncoder::Write(const uint8_t* data, size_t data_size) bool WebpEncoder::CheckEncodeFormat(Media::PixelMap &pixelMap) { PixelFormat pixelFormat = GetPixelFormat(pixelMap); - HiLog::Debug(LABEL, "CheckEncodeFormat, pixelFormat=%{public}u", pixelFormat); + IMAGE_LOGD("CheckEncodeFormat, pixelFormat=%{public}u", pixelFormat); switch (pixelFormat) { case PixelFormat::RGBA_8888: { - HiLog::Debug(LABEL, "CheckEncodeFormat, RGBA_8888"); + IMAGE_LOGD("CheckEncodeFormat, RGBA_8888"); return true; } case PixelFormat::BGRA_8888: { - HiLog::Debug(LABEL, "CheckEncodeFormat, BGRA_8888"); + IMAGE_LOGD("CheckEncodeFormat, BGRA_8888"); return true; } case PixelFormat::RGBA_F16: { - HiLog::Debug(LABEL, "CheckEncodeFormat, RGBA_F16"); + IMAGE_LOGD("CheckEncodeFormat, RGBA_F16"); return true; } case PixelFormat::ARGB_8888: { - HiLog::Debug(LABEL, "CheckEncodeFormat, ARGB_8888"); + IMAGE_LOGD("CheckEncodeFormat, ARGB_8888"); return true; } case PixelFormat::RGB_888: { - HiLog::Debug(LABEL, "CheckEncodeFormat, RGB_888"); + IMAGE_LOGD("CheckEncodeFormat, RGB_888"); return true; } case PixelFormat::RGB_565: { bool isOpaque = IsOpaque(pixelMap); - HiLog::Debug(LABEL, "CheckEncodeFormat, RGB_565, isOpaque=%{public}d", isOpaque); + IMAGE_LOGD("CheckEncodeFormat, RGB_565, isOpaque=%{public}d", isOpaque); return isOpaque; } case PixelFormat::ALPHA_8: { - HiLog::Debug(LABEL, "CheckEncodeFormat, ALPHA_8"); + IMAGE_LOGD("CheckEncodeFormat, ALPHA_8"); return true; } default: { - HiLog::Error(LABEL, "CheckEncodeFormat, pixelFormat=%{public}u", pixelFormat); + IMAGE_LOGE("CheckEncodeFormat, pixelFormat=%{public}u", pixelFormat); return false; } } @@ -178,11 +182,11 @@ bool WebpEncoder::CheckEncodeFormat(Media::PixelMap &pixelMap) bool WebpEncoder::DoTransform(Media::PixelMap &pixelMap, char* dst, int componentsNum) { - HiLog::Debug(LABEL, "DoTransform IN"); + IMAGE_LOGD("DoTransform IN"); PixelFormat pixelFormat = GetPixelFormat(pixelMap); AlphaType alphaType = GetAlphaType(pixelMap); - HiLog::Debug(LABEL, "DoTransform, pixelFormat=%{public}u, alphaType=%{public}d, componentsNum=%{public}d", + IMAGE_LOGD("DoTransform, pixelFormat=%{public}u, alphaType=%{public}d, componentsNum=%{public}d", pixelFormat, alphaType, componentsNum); if ((pixelFormat == PixelFormat::RGBA_8888) && (alphaType == AlphaType::IMAGE_ALPHA_TYPE_OPAQUE)) { @@ -212,28 +216,28 @@ bool WebpEncoder::DoTransform(Media::PixelMap &pixelMap, char* dst, int componen } else if (pixelFormat == PixelFormat::RGB_888) { return DoTransformMemcpy(pixelMap, dst, componentsNum); } else if ((pixelFormat == PixelFormat::RGB_565) && IsOpaque(pixelMap)) { - HiLog::Debug(LABEL, "DoTransform, RGB_565, Opaque"); + IMAGE_LOGD("DoTransform, RGB_565, Opaque"); return DoTransformRGB565(pixelMap, dst, componentsNum); } else if (pixelFormat == PixelFormat::ALPHA_8) { - HiLog::Debug(LABEL, "DoTransform, ALPHA_8"); + IMAGE_LOGD("DoTransform, ALPHA_8"); return DoTransformGray(pixelMap, dst, componentsNum); } - HiLog::Debug(LABEL, "DoTransform OUT"); + IMAGE_LOGD("DoTransform OUT"); return false; } uint32_t WebpEncoder::SetEncodeConfig(Media::PixelMap &pixelMap, WebPConfig &webpConfig, WebPPicture &webpPicture) { - HiLog::Debug(LABEL, "SetEncodeConfig IN"); + IMAGE_LOGD("SetEncodeConfig IN"); if (pixelMap.GetPixels() == nullptr) { - HiLog::Error(LABEL, "SetEncodeConfig, pixels invalid."); + IMAGE_LOGE("SetEncodeConfig, pixels invalid."); return ERROR; } if (!CheckEncodeFormat(pixelMap)) { - HiLog::Error(LABEL, "SetEncodeConfig, check invalid."); + IMAGE_LOGE("SetEncodeConfig, check invalid."); return ERR_IMAGE_UNKNOWN_FORMAT; } @@ -242,10 +246,10 @@ uint32_t WebpEncoder::SetEncodeConfig(Media::PixelMap &pixelMap, WebPConfig &web } else { componentsNum_ = IsOpaque(pixelMap) ? COMPONENT_NUM_3 : COMPONENT_NUM_4; } - HiLog::Debug(LABEL, "SetEncodeConfig, componentsNum=%{public}u", componentsNum_); + IMAGE_LOGD("SetEncodeConfig, componentsNum=%{public}u", componentsNum_); if (!WebPConfigPreset(&webpConfig, WEBP_PRESET_DEFAULT, encodeOpts_.quality)) { - HiLog::Error(LABEL, "SetEncodeConfig, config preset issue."); + IMAGE_LOGE("SetEncodeConfig, config preset issue."); return ERROR; } @@ -261,28 +265,28 @@ uint32_t WebpEncoder::SetEncodeConfig(Media::PixelMap &pixelMap, WebPConfig &web webpPicture.custom_ptr = static_cast(this); auto colorSpace = GetColorSpace(pixelMap); - HiLog::Debug(LABEL, "SetEncodeConfig, " + IMAGE_LOGD("SetEncodeConfig, " "width=%{public}u, height=%{public}u, colorspace=%{public}d, componentsNum=%{public}d.", webpPicture.width, webpPicture.height, colorSpace, componentsNum_); - HiLog::Debug(LABEL, "SetEncodeConfig OUT"); + IMAGE_LOGD("SetEncodeConfig OUT"); return SUCCESS; } uint32_t WebpEncoder::DoEncode(Media::PixelMap &pixelMap, WebPConfig &webpConfig, WebPPicture &webpPicture) { - HiLog::Debug(LABEL, "DoEncode IN"); + IMAGE_LOGD("DoEncode IN"); const int width = pixelMap.GetWidth(); const int height = webpPicture.height; const int rgbStride = width * componentsNum_; const int rgbSize = rgbStride * height; - HiLog::Debug(LABEL, "DoEncode, width=%{public}d, height=%{public}d, componentsNum=%{public}d," + IMAGE_LOGD("DoEncode, width=%{public}d, height=%{public}d, componentsNum=%{public}d," " rgbStride=%{public}d, rgbSize=%{public}d", width, height, componentsNum_, rgbStride, rgbSize); std::unique_ptr rgb = std::make_unique(rgbSize); if (!DoTransform(pixelMap, reinterpret_cast(&rgb[0]), componentsNum_)) { - HiLog::Error(LABEL, "DoEncode, transform issue."); + IMAGE_LOGE("DoEncode, transform issue."); return ERROR; } @@ -291,34 +295,34 @@ uint32_t WebpEncoder::DoEncode(Media::PixelMap &pixelMap, WebPConfig &webpConfig importProc = (IsOpaque(pixelMap)) ? WebPPictureImportRGBX : WebPPictureImportRGBA; } - HiLog::Debug(LABEL, "DoEncode, importProc"); + IMAGE_LOGD("DoEncode, importProc"); if (!importProc(&webpPicture, &rgb[0], rgbStride)) { - HiLog::Error(LABEL, "DoEncode, import issue."); + IMAGE_LOGE("DoEncode, import issue."); return ERROR; } - HiLog::Debug(LABEL, "DoEncode, WebPEncode"); + IMAGE_LOGD("DoEncode, WebPEncode"); if (!WebPEncode(&webpConfig, &webpPicture)) { - HiLog::Error(LABEL, "DoEncode, encode issue."); + IMAGE_LOGE("DoEncode, encode issue."); return ERROR; } - HiLog::Debug(LABEL, "DoEncode, iccValid=%{public}d", iccValid_); + IMAGE_LOGD("DoEncode, iccValid=%{public}d", iccValid_); if (iccValid_) { auto res = DoEncodeForICC(pixelMap); if (res != SUCCESS) { - HiLog::Error(LABEL, "DoEncode, encode for icc issue."); + IMAGE_LOGE("DoEncode, encode for icc issue."); return res; } } - HiLog::Debug(LABEL, "DoEncode OUT"); + IMAGE_LOGD("DoEncode OUT"); return SUCCESS; } uint32_t WebpEncoder::DoEncodeForICC(Media::PixelMap &pixelMap) { - HiLog::Debug(LABEL, "DoEncodeForICC IN"); + IMAGE_LOGD("DoEncodeForICC IN"); auto encodedData = memoryStream_.detachAsData(); WebPData webpEncode = { encodedData->bytes(), encodedData->size() }; @@ -326,20 +330,20 @@ uint32_t WebpEncoder::DoEncodeForICC(Media::PixelMap &pixelMap) auto mux = WebPMuxNew(); if (WebPMuxSetImage(mux, &webpEncode, 0) != WEBP_MUX_OK) { - HiLog::Error(LABEL, "DoEncodeForICC, image issue."); + IMAGE_LOGE("DoEncodeForICC, image issue."); WebPMuxDelete(mux); return ERROR; } if (WebPMuxSetChunk(mux, "ICCP", &webpIcc, 0) != WEBP_MUX_OK) { - HiLog::Error(LABEL, "DoEncodeForICC, icc issue."); + IMAGE_LOGE("DoEncodeForICC, icc issue."); WebPMuxDelete(mux); return ERROR; } WebPData webpAssembled; if (WebPMuxAssemble(mux, &webpAssembled) != WEBP_MUX_OK) { - HiLog::Error(LABEL, "DoEncodeForICC, assemble issue."); + IMAGE_LOGE("DoEncodeForICC, assemble issue."); WebPMuxDelete(mux); return ERROR; } @@ -348,7 +352,7 @@ uint32_t WebpEncoder::DoEncodeForICC(Media::PixelMap &pixelMap) WebPDataClear(&webpAssembled); WebPMuxDelete(mux); - HiLog::Debug(LABEL, "DoEncodeForICC OUT"); + IMAGE_LOGD("DoEncodeForICC OUT"); return SUCCESS; } @@ -379,11 +383,11 @@ bool WebpEncoder::IsOpaque(Media::PixelMap &pixelMap) bool WebpEncoder::DoTransformMemcpy(Media::PixelMap &pixelMap, char* dst, int componentsNum) { - HiLog::Debug(LABEL, "DoTransformMemcpy IN"); + IMAGE_LOGD("DoTransformMemcpy IN"); auto src = pixelMap.GetPixels(); if ((src == nullptr) || (dst == nullptr)) { - HiLog::Error(LABEL, "DoTransformMemcpy, address issue."); + IMAGE_LOGE("DoTransformMemcpy, address issue."); return false; } @@ -392,8 +396,7 @@ bool WebpEncoder::DoTransformMemcpy(Media::PixelMap &pixelMap, char* dst, int co const uint32_t rowBytes = pixelMap.GetRowBytes(); const int stride = pixelMap.GetWidth() * componentsNum; - HiLog::Debug(LABEL, - "width=%{public}u, height=%{public}u, rowBytes=%{public}u, stride=%{public}d, componentsNum=%{public}d", + IMAGE_LOGD("width=%{public}u, height=%{public}u, rowBytes=%{public}u, stride=%{public}d, componentsNum=%{public}d", width, height, rowBytes, stride, componentsNum); for (int32_t h = 0; h < height; h++) { @@ -402,13 +405,13 @@ bool WebpEncoder::DoTransformMemcpy(Media::PixelMap &pixelMap, char* dst, int co width, componentsNum); } - HiLog::Debug(LABEL, "DoTransformMemcpy OUT"); + IMAGE_LOGD("DoTransformMemcpy OUT"); return true; } bool WebpEncoder::DoTransformRGBX(Media::PixelMap &pixelMap, char* dst, int componentsNum) { - HiLog::Debug(LABEL, "DoTransformRGBX IN"); + IMAGE_LOGD("DoTransformRGBX IN"); const void *srcPixels = pixelMap.GetPixels(); uint32_t srcRowBytes = pixelMap.GetRowBytes(); @@ -423,24 +426,24 @@ bool WebpEncoder::DoTransformRGBX(Media::PixelMap &pixelMap, char* dst, int comp ShowTransformParam(srcInfo, srcRowBytes, dstInfo, dstRowBytes, componentsNum); if ((srcPixels == nullptr) || (dstPixels == nullptr)) { - HiLog::Error(LABEL, "DoTransformRGBX, address issue."); + IMAGE_LOGE("DoTransformRGBX, address issue."); return false; } const Position dstPos; if (!PixelConvertAdapter::WritePixelsConvert(srcPixels, srcRowBytes, srcInfo, dstPixels, dstPos, dstRowBytes, dstInfo)) { - HiLog::Error(LABEL, "DoTransformRGBX, pixel convert in adapter failed."); + IMAGE_LOGE("DoTransformRGBX, pixel convert in adapter failed."); return false; } - HiLog::Debug(LABEL, "DoTransformRGBX OUT"); + IMAGE_LOGD("DoTransformRGBX OUT"); return true; } bool WebpEncoder::DoTransformRgbA(Media::PixelMap &pixelMap, char* dst, int componentsNum) { - HiLog::Debug(LABEL, "DoTransformRgbA IN"); + IMAGE_LOGD("DoTransformRgbA IN"); const void *srcPixels = pixelMap.GetPixels(); uint32_t srcRowBytes = pixelMap.GetRowBytes(); @@ -455,24 +458,24 @@ bool WebpEncoder::DoTransformRgbA(Media::PixelMap &pixelMap, char* dst, int comp ShowTransformParam(srcInfo, srcRowBytes, dstInfo, dstRowBytes, componentsNum); if ((srcPixels == nullptr) || (dstPixels == nullptr)) { - HiLog::Error(LABEL, "DoTransformRgbA, address issue."); + IMAGE_LOGE("DoTransformRgbA, address issue."); return false; } const Position dstPos; if (!PixelConvertAdapter::WritePixelsConvert(srcPixels, srcRowBytes, srcInfo, dstPixels, dstPos, dstRowBytes, dstInfo)) { - HiLog::Error(LABEL, "DoTransformRgbA, pixel convert in adapter failed."); + IMAGE_LOGE("DoTransformRgbA, pixel convert in adapter failed."); return false; } - HiLog::Debug(LABEL, "DoTransformRgbA OUT"); + IMAGE_LOGD("DoTransformRgbA OUT"); return true; } bool WebpEncoder::DoTransformBGRX(Media::PixelMap &pixelMap, char* dst, int componentsNum) { - HiLog::Debug(LABEL, "DoTransformBGRX IN"); + IMAGE_LOGD("DoTransformBGRX IN"); const void *srcPixels = pixelMap.GetPixels(); uint32_t srcRowBytes = pixelMap.GetRowBytes(); @@ -487,24 +490,24 @@ bool WebpEncoder::DoTransformBGRX(Media::PixelMap &pixelMap, char* dst, int comp ShowTransformParam(srcInfo, srcRowBytes, dstInfo, dstRowBytes, componentsNum); if ((srcPixels == nullptr) || (dstPixels == nullptr)) { - HiLog::Error(LABEL, "DoTransformBGRX, address issue."); + IMAGE_LOGE("DoTransformBGRX, address issue."); return false; } const Position dstPos; if (!PixelConvertAdapter::WritePixelsConvert(srcPixels, srcRowBytes, srcInfo, dstPixels, dstPos, dstRowBytes, dstInfo)) { - HiLog::Error(LABEL, "DoTransformBGRX, pixel convert in adapter failed."); + IMAGE_LOGE("DoTransformBGRX, pixel convert in adapter failed."); return false; } - HiLog::Debug(LABEL, "DoTransformBGRX OUT"); + IMAGE_LOGD("DoTransformBGRX OUT"); return true; } bool WebpEncoder::DoTransformBGRA(Media::PixelMap &pixelMap, char* dst, int componentsNum) { - HiLog::Debug(LABEL, "DoTransformBGRA IN"); + IMAGE_LOGD("DoTransformBGRA IN"); const void *srcPixels = pixelMap.GetPixels(); uint32_t srcRowBytes = pixelMap.GetRowBytes(); @@ -519,24 +522,24 @@ bool WebpEncoder::DoTransformBGRA(Media::PixelMap &pixelMap, char* dst, int comp ShowTransformParam(srcInfo, srcRowBytes, dstInfo, dstRowBytes, componentsNum); if ((srcPixels == nullptr) || (dstPixels == nullptr)) { - HiLog::Error(LABEL, "DoTransformBGRA, address issue."); + IMAGE_LOGE("DoTransformBGRA, address issue."); return false; } const Position dstPos; if (!PixelConvertAdapter::WritePixelsConvert(srcPixels, srcRowBytes, srcInfo, dstPixels, dstPos, dstRowBytes, dstInfo)) { - HiLog::Error(LABEL, "DoTransformBGRA, pixel convert in adapter failed."); + IMAGE_LOGE("DoTransformBGRA, pixel convert in adapter failed."); return false; } - HiLog::Debug(LABEL, "DoTransformBGRA OUT"); + IMAGE_LOGD("DoTransformBGRA OUT"); return true; } bool WebpEncoder::DoTransformBgrA(Media::PixelMap &pixelMap, char* dst, int componentsNum) { - HiLog::Debug(LABEL, "DoTransformBgrA IN"); + IMAGE_LOGD("DoTransformBgrA IN"); const void *srcPixels = pixelMap.GetPixels(); uint32_t srcRowBytes = pixelMap.GetRowBytes(); @@ -551,24 +554,24 @@ bool WebpEncoder::DoTransformBgrA(Media::PixelMap &pixelMap, char* dst, int comp ShowTransformParam(srcInfo, srcRowBytes, dstInfo, dstRowBytes, componentsNum); if ((srcPixels == nullptr) || (dstPixels == nullptr)) { - HiLog::Error(LABEL, "DoTransformBgrA, address issue."); + IMAGE_LOGE("DoTransformBgrA, address issue."); return false; } const Position dstPos; if (!PixelConvertAdapter::WritePixelsConvert(srcPixels, srcRowBytes, srcInfo, dstPixels, dstPos, dstRowBytes, dstInfo)) { - HiLog::Error(LABEL, "DoTransformBgrA, pixel convert in adapter failed."); + IMAGE_LOGE("DoTransformBgrA, pixel convert in adapter failed."); return false; } - HiLog::Debug(LABEL, "DoTransformBgrA OUT"); + IMAGE_LOGD("DoTransformBgrA OUT"); return true; } bool WebpEncoder::DoTransformF16To8888(Media::PixelMap &pixelMap, char* dst, int componentsNum) { - HiLog::Debug(LABEL, "DoTransformF16To8888 IN"); + IMAGE_LOGD("DoTransformF16To8888 IN"); const void *srcPixels = pixelMap.GetPixels(); uint32_t srcRowBytes = pixelMap.GetRowBytes(); @@ -583,24 +586,24 @@ bool WebpEncoder::DoTransformF16To8888(Media::PixelMap &pixelMap, char* dst, int ShowTransformParam(srcInfo, srcRowBytes, dstInfo, dstRowBytes, componentsNum); if ((srcPixels == nullptr) || (dstPixels == nullptr)) { - HiLog::Error(LABEL, "DoTransformF16To8888, address issue."); + IMAGE_LOGE("DoTransformF16To8888, address issue."); return false; } const Position dstPos; if (!PixelConvertAdapter::WritePixelsConvert(srcPixels, srcRowBytes, srcInfo, dstPixels, dstPos, dstRowBytes, dstInfo)) { - HiLog::Error(LABEL, "DoTransformF16To8888, pixel convert in adapter failed."); + IMAGE_LOGE("DoTransformF16To8888, pixel convert in adapter failed."); return false; } - HiLog::Debug(LABEL, "DoTransformF16To8888 OUT"); + IMAGE_LOGD("DoTransformF16To8888 OUT"); return true; } bool WebpEncoder::DoTransformF16pTo8888(Media::PixelMap &pixelMap, char* dst, int componentsNum) { - HiLog::Debug(LABEL, "DoTransformF16pTo8888 IN"); + IMAGE_LOGD("DoTransformF16pTo8888 IN"); const void *srcPixels = pixelMap.GetPixels(); uint32_t srcRowBytes = pixelMap.GetRowBytes(); @@ -615,24 +618,24 @@ bool WebpEncoder::DoTransformF16pTo8888(Media::PixelMap &pixelMap, char* dst, in ShowTransformParam(srcInfo, srcRowBytes, dstInfo, dstRowBytes, componentsNum); if ((srcPixels == nullptr) || (dstPixels == nullptr)) { - HiLog::Error(LABEL, "DoTransformF16pTo8888, address issue."); + IMAGE_LOGE("DoTransformF16pTo8888, address issue."); return false; } const Position dstPos; if (!PixelConvertAdapter::WritePixelsConvert(srcPixels, srcRowBytes, srcInfo, dstPixels, dstPos, dstRowBytes, dstInfo)) { - HiLog::Error(LABEL, "DoTransformF16pTo8888, pixel convert in adapter failed."); + IMAGE_LOGE("DoTransformF16pTo8888, pixel convert in adapter failed."); return false; } - HiLog::Debug(LABEL, "DoTransformF16pTo8888 OUT"); + IMAGE_LOGD("DoTransformF16pTo8888 OUT"); return true; } bool WebpEncoder::DoTransformArgbToRgb(Media::PixelMap &pixelMap, char* dst, int componentsNum) { - HiLog::Debug(LABEL, "DoTransformArgbToRgb IN"); + IMAGE_LOGD("DoTransformArgbToRgb IN"); const void *srcPixels = pixelMap.GetPixels(); uint32_t srcRowBytes = pixelMap.GetRowBytes(); @@ -647,24 +650,24 @@ bool WebpEncoder::DoTransformArgbToRgb(Media::PixelMap &pixelMap, char* dst, int ShowTransformParam(srcInfo, srcRowBytes, dstInfo, dstRowBytes, componentsNum); if ((srcPixels == nullptr) || (dstPixels == nullptr)) { - HiLog::Error(LABEL, "DoTransformArgbToRgb, address issue."); + IMAGE_LOGE("DoTransformArgbToRgb, address issue."); return false; } const Position dstPos; if (!PixelConvertAdapter::WritePixelsConvert(srcPixels, srcRowBytes, srcInfo, dstPixels, dstPos, dstRowBytes, dstInfo)) { - HiLog::Error(LABEL, "DoTransformArgbToRgb, pixel convert in adapter failed."); + IMAGE_LOGE("DoTransformArgbToRgb, pixel convert in adapter failed."); return false; } - HiLog::Debug(LABEL, "DoTransformArgbToRgb OUT"); + IMAGE_LOGD("DoTransformArgbToRgb OUT"); return true; } bool WebpEncoder::DoTransformArgbToRgba(Media::PixelMap &pixelMap, char* dst, int componentsNum) { - HiLog::Debug(LABEL, "DoTransformArgbToRgba IN"); + IMAGE_LOGD("DoTransformArgbToRgba IN"); const void *srcPixels = pixelMap.GetPixels(); uint32_t srcRowBytes = pixelMap.GetRowBytes(); @@ -679,24 +682,24 @@ bool WebpEncoder::DoTransformArgbToRgba(Media::PixelMap &pixelMap, char* dst, in ShowTransformParam(srcInfo, srcRowBytes, dstInfo, dstRowBytes, componentsNum); if ((srcPixels == nullptr) || (dstPixels == nullptr)) { - HiLog::Error(LABEL, "DoTransformArgbToRgba, address issue."); + IMAGE_LOGE("DoTransformArgbToRgba, address issue."); return false; } const Position dstPos; if (!PixelConvertAdapter::WritePixelsConvert(srcPixels, srcRowBytes, srcInfo, dstPixels, dstPos, dstRowBytes, dstInfo)) { - HiLog::Error(LABEL, "DoTransformArgbToRgba, pixel convert in adapter failed."); + IMAGE_LOGE("DoTransformArgbToRgba, pixel convert in adapter failed."); return false; } - HiLog::Debug(LABEL, "DoTransformArgbToRgba OUT"); + IMAGE_LOGD("DoTransformArgbToRgba OUT"); return true; } bool WebpEncoder::DoTransformRGB565(Media::PixelMap &pixelMap, char* dst, int componentsNum) { - HiLog::Debug(LABEL, "DoTransformRGB565 IN"); + IMAGE_LOGD("DoTransformRGB565 IN"); const void *srcPixels = pixelMap.GetPixels(); uint32_t srcRowBytes = pixelMap.GetRowBytes(); @@ -711,24 +714,24 @@ bool WebpEncoder::DoTransformRGB565(Media::PixelMap &pixelMap, char* dst, int co ShowTransformParam(srcInfo, srcRowBytes, dstInfo, dstRowBytes, componentsNum); if ((srcPixels == nullptr) || (dstPixels == nullptr)) { - HiLog::Error(LABEL, "DoTransformRGB565, address issue."); + IMAGE_LOGE("DoTransformRGB565, address issue."); return false; } const Position dstPos; if (!PixelConvertAdapter::WritePixelsConvert(srcPixels, srcRowBytes, srcInfo, dstPixels, dstPos, dstRowBytes, dstInfo)) { - HiLog::Error(LABEL, "DoTransformRGB565, pixel convert in adapter failed."); + IMAGE_LOGE("DoTransformRGB565, pixel convert in adapter failed."); return false; } - HiLog::Debug(LABEL, "DoTransformRGB565 OUT"); + IMAGE_LOGD("DoTransformRGB565 OUT"); return true; } bool WebpEncoder::DoTransformGray(Media::PixelMap &pixelMap, char* dst, int componentsNum) { - HiLog::Debug(LABEL, "DoTransformGray IN"); + IMAGE_LOGD("DoTransformGray IN"); const void *srcPixels = pixelMap.GetPixels(); uint32_t srcRowBytes = pixelMap.GetRowBytes(); @@ -743,18 +746,18 @@ bool WebpEncoder::DoTransformGray(Media::PixelMap &pixelMap, char* dst, int comp ShowTransformParam(srcInfo, srcRowBytes, dstInfo, dstRowBytes, componentsNum); if ((srcPixels == nullptr) || (dstPixels == nullptr)) { - HiLog::Error(LABEL, "DoTransformGray, address issue."); + IMAGE_LOGE("DoTransformGray, address issue."); return false; } const Position dstPos; if (!PixelConvertAdapter::WritePixelsConvert(srcPixels, srcRowBytes, srcInfo, dstPixels, dstPos, dstRowBytes, dstInfo)) { - HiLog::Error(LABEL, "DoTransformGray, pixel convert in adapter failed."); + IMAGE_LOGE("DoTransformGray, pixel convert in adapter failed."); return false; } - HiLog::Debug(LABEL, "DoTransformGray OUT"); + IMAGE_LOGD("DoTransformGray OUT"); return true; } @@ -776,8 +779,7 @@ ImageInfo WebpEncoder::MakeImageInfo(int width, int height, PixelFormat pf, Alph void WebpEncoder::ShowTransformParam(const ImageInfo &srcInfo, const uint32_t &srcRowBytes, const ImageInfo &dstInfo, const uint32_t &dstRowBytes, const int &componentsNum) { - HiLog::Debug(LABEL, - "src(width=%{public}u, height=%{public}u, rowBytes=%{public}u," + IMAGE_LOGD("src(width=%{public}u, height=%{public}u, rowBytes=%{public}u," " pixelFormat=%{public}u, colorspace=%{public}d, alphaType=%{public}d, baseDensity=%{public}d), " "dst(width=%{public}u, height=%{public}u, rowBytes=%{public}u," " pixelFormat=%{public}u, colorspace=%{public}d, alphaType=%{public}d, baseDensity=%{public}d), " diff --git a/plugins/manager/include/pluginbase/plugin_utils.h b/plugins/manager/include/pluginbase/plugin_utils.h index d356da374..7d90053eb 100644 --- a/plugins/manager/include/pluginbase/plugin_utils.h +++ b/plugins/manager/include/pluginbase/plugin_utils.h @@ -55,14 +55,14 @@ static ImplClassMap implClassMap = { #define PLUGIN_EXPORT_DEFAULT_EXTERNAL_START() \ bool PluginExternalStart() \ { \ - PLUGIN_LOG_D("call PluginExternalStart() in package: %{public}s.", PACKAGE_NAME.c_str()); \ + IMAGE_LOGD("call PluginExternalStart() in package: %{public}s.", PACKAGE_NAME.c_str()); \ return true; \ } #define PLUGIN_EXPORT_DEFAULT_EXTERNAL_STOP() \ void PluginExternalStop() \ { \ - PLUGIN_LOG_D("call PluginExternalStop() in package: %{public}s.", PACKAGE_NAME.c_str()); \ + IMAGE_LOGD("call PluginExternalStop() in package: %{public}s.", PACKAGE_NAME.c_str()); \ return; \ } #endif // PLUGIN_UTILS_H diff --git a/plugins/manager/src/common/attr_data.cpp b/plugins/manager/src/common/attr_data.cpp index 8265ccc21..f819d6e30 100644 --- a/plugins/manager/src/common/attr_data.cpp +++ b/plugins/manager/src/common/attr_data.cpp @@ -20,11 +20,9 @@ #include #include "__tree" #include "cstdint" -#include "hilog/log_c.h" -#include "hilog/log_cpp.h" +#include "image_log.h" #include "iosfwd" #include "iterator" -#include "log_tags.h" #include "new" #include "plugin_errors.h" #ifndef _WIN32 @@ -36,13 +34,16 @@ #include "string" #include "type_traits" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "AttrData" + namespace OHOS { namespace MultimediaPlugin { using std::set; using std::string; -using namespace OHOS::HiviewDFX; - -static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "AttrData" }; AttrData::AttrData() : type_(AttrDataType::ATTR_DATA_NULL) {} @@ -61,7 +62,7 @@ AttrData::AttrData(const string &value) : type_(AttrDataType::ATTR_DATA_STRING) { value_.stringValue = new (std::nothrow) string(value); if (value_.stringValue == nullptr) { - HiLog::Error(LABEL, "AttrData: alloc stringValue result null!"); + IMAGE_LOGE("AttrData: alloc stringValue result null!"); type_ = AttrDataType::ATTR_DATA_NULL; } } @@ -70,7 +71,7 @@ AttrData::AttrData(string &&value) : type_(AttrDataType::ATTR_DATA_STRING) { value_.stringValue = new (std::nothrow) string(std::move(value)); if (value_.stringValue == nullptr) { - HiLog::Error(LABEL, "AttrData: alloc stringValue result null!"); + IMAGE_LOGE("AttrData: alloc stringValue result null!"); type_ = AttrDataType::ATTR_DATA_NULL; } } @@ -117,7 +118,7 @@ AttrData::AttrData(const AttrData &data) break; } default: { - HiLog::Debug(LABEL, "AttrData: null or unexpected type in copy constructor: %{public}d.", data.type_); + IMAGE_LOGD("AttrData: null or unexpected type in copy constructor: %{public}d.", data.type_); type_ = AttrDataType::ATTR_DATA_NULL; } } @@ -130,7 +131,7 @@ AttrData::AttrData(AttrData &&data) noexcept data.type_ = AttrDataType::ATTR_DATA_NULL; } else { type_ = AttrDataType::ATTR_DATA_NULL; - HiLog::Error(LABEL, "memcpy error in assignment operator!"); + IMAGE_LOGE("memcpy error in assignment operator!"); } } @@ -149,7 +150,7 @@ AttrData &AttrData::operator=(const AttrData &data) temp.type_ = AttrDataType::ATTR_DATA_NULL; } else { type_ = AttrDataType::ATTR_DATA_NULL; - HiLog::Error(LABEL, "memcpy error in assignment operator!"); + IMAGE_LOGE("memcpy error in assignment operator!"); } return *this; @@ -168,7 +169,7 @@ AttrData &AttrData::operator=(AttrData &&data) noexcept data.type_ = AttrDataType::ATTR_DATA_NULL; } else { type_ = AttrDataType::ATTR_DATA_NULL; - HiLog::Error(LABEL, "memcpy error in assignment operator!"); + IMAGE_LOGE("memcpy error in assignment operator!"); } return *this; @@ -197,7 +198,7 @@ uint32_t AttrData::SetData(const string &value) string *newValue = new (std::nothrow) string(value); if (newValue == nullptr) { - HiLog::Error(LABEL, "SetData: alloc string result null!"); + IMAGE_LOGE("SetData: alloc string result null!"); return ERR_INTERNAL; } @@ -216,7 +217,7 @@ uint32_t AttrData::SetData(string &&value) string *newValue = new (std::nothrow) string(std::move(value)); if (newValue == nullptr) { - HiLog::Error(LABEL, "SetData: alloc string result null!"); + IMAGE_LOGE("SetData: alloc string result null!"); return ERR_INTERNAL; } @@ -229,8 +230,8 @@ uint32_t AttrData::SetData(string &&value) uint32_t AttrData::SetData(uint32_t lowerBound, uint32_t upperBound) { if (lowerBound > upperBound) { - HiLog::Error(LABEL, "SetData: lowerBound is upper than upperBound, lower: %{public}u, upper: %{public}u.", - lowerBound, upperBound); + IMAGE_LOGE("SetData: lowerBound is upper than upperBound, lower: %{public}u, upper: %{public}u.", + lowerBound, upperBound); return ERR_INVALID_PARAMETER; } @@ -267,7 +268,7 @@ void AttrData::ClearData() } default: { // do nothing - HiLog::Debug(LABEL, "ClearData: do nothing for type %{public}d.", type_); + IMAGE_LOGD("ClearData: do nothing for type %{public}d.", type_); break; } } @@ -280,7 +281,7 @@ uint32_t AttrData::InsertSet(uint32_t value) if (type_ == AttrDataType::ATTR_DATA_NULL) { value_.uint32Set = new (std::nothrow) set({ value }); if (value_.uint32Set == nullptr) { - HiLog::Error(LABEL, "InsertSet: alloc uint32Set result null!"); + IMAGE_LOGE("InsertSet: alloc uint32Set result null!"); return ERR_INTERNAL; } @@ -289,13 +290,13 @@ uint32_t AttrData::InsertSet(uint32_t value) } if (type_ != AttrDataType::ATTR_DATA_UINT32_SET) { - HiLog::Error(LABEL, "InsertSet: AttrData type is not uint32Set or null, type: %{public}d.", type_); + IMAGE_LOGE("InsertSet: AttrData type is not uint32Set or null, type: %{public}d.", type_); return ERR_UNSUPPORTED; } auto result = value_.uint32Set->insert(value); if (!result.second) { - HiLog::Error(LABEL, "InsertSet: set insert error!"); + IMAGE_LOGE("InsertSet: set insert error!"); return ERR_GENERAL; } @@ -307,7 +308,7 @@ uint32_t AttrData::InsertSet(const string &value) if (type_ == AttrDataType::ATTR_DATA_NULL) { value_.stringSet = new (std::nothrow) set({ value }); if (value_.stringSet == nullptr) { - HiLog::Error(LABEL, "InsertSet: alloc stringSet result null!"); + IMAGE_LOGE("InsertSet: alloc stringSet result null!"); return ERR_INTERNAL; } @@ -316,13 +317,13 @@ uint32_t AttrData::InsertSet(const string &value) } if (type_ != AttrDataType::ATTR_DATA_STRING_SET) { - HiLog::Error(LABEL, "InsertSet: AttrData type is not stringSet or null, type: %{public}d.", type_); + IMAGE_LOGE("InsertSet: AttrData type is not stringSet or null, type: %{public}d.", type_); return ERR_UNSUPPORTED; } auto result = value_.stringSet->insert(value); if (!result.second) { - HiLog::Error(LABEL, "InsertSet: set insert error!"); + IMAGE_LOGE("InsertSet: set insert error!"); return ERR_INTERNAL; } @@ -334,7 +335,7 @@ uint32_t AttrData::InsertSet(string &&value) if (type_ == AttrDataType::ATTR_DATA_NULL) { value_.stringSet = new (std::nothrow) set; if (value_.stringSet == nullptr) { - HiLog::Error(LABEL, "InsertSet: alloc stringSet result null!"); + IMAGE_LOGE("InsertSet: alloc stringSet result null!"); return ERR_INTERNAL; } @@ -342,7 +343,7 @@ uint32_t AttrData::InsertSet(string &&value) if (!result.second) { delete value_.stringSet; value_.stringSet = nullptr; - HiLog::Error(LABEL, "InsertSet: set insert error!"); + IMAGE_LOGE("InsertSet: set insert error!"); return ERR_INTERNAL; } @@ -351,13 +352,13 @@ uint32_t AttrData::InsertSet(string &&value) } if (type_ != AttrDataType::ATTR_DATA_STRING_SET) { - HiLog::Error(LABEL, "InsertSet: AttrData type is not stringSet or null, type: %{public}d.", type_); + IMAGE_LOGE("InsertSet: AttrData type is not stringSet or null, type: %{public}d.", type_); return ERR_UNSUPPORTED; } auto result = value_.stringSet->insert(std::move(value)); if (!result.second) { - HiLog::Error(LABEL, "InsertSet: set insert error!"); + IMAGE_LOGE("InsertSet: set insert error!"); return ERR_INTERNAL; } @@ -367,7 +368,7 @@ uint32_t AttrData::InsertSet(string &&value) bool AttrData::InRange(bool value) const { if (type_ != AttrDataType::ATTR_DATA_BOOL) { - HiLog::Error(LABEL, "InRange: comparison of bool type with non-bool type: %{public}d.", type_); + IMAGE_LOGE("InRange: comparison of bool type with non-bool type: %{public}d.", type_); return false; } @@ -387,7 +388,7 @@ bool AttrData::InRange(uint32_t value) const return InRangeUint32Range(value); } default: { - HiLog::Error(LABEL, "InRange: comparison of uint32 type with non-uint32 type: %{public}d.", type_); + IMAGE_LOGE("InRange: comparison of uint32 type with non-uint32 type: %{public}d.", type_); return false; } } @@ -403,7 +404,7 @@ bool AttrData::InRange(const string &value) const return value_.stringSet->find(value) != value_.stringSet->end(); } default: { - HiLog::Error(LABEL, "InRange: comparison of string type with non-string type: %{public}d.", type_); + IMAGE_LOGE("InRange: comparison of string type with non-string type: %{public}d.", type_); return false; } } @@ -434,7 +435,7 @@ bool AttrData::InRange(const AttrData &data) const return InRange(data.value_.uint32Rang); } default: { - HiLog::Error(LABEL, "InRange: unexpected AttrData type: %{public}d.", data.type_); + IMAGE_LOGE("InRange: unexpected AttrData type: %{public}d.", data.type_); return false; } } @@ -455,7 +456,7 @@ uint32_t AttrData::GetMinValue(uint32_t &value) const case AttrDataType::ATTR_DATA_UINT32_SET: { auto iter = value_.uint32Set->begin(); if (iter == value_.uint32Set->end()) { - HiLog::Error(LABEL, "GetMinValue: uint32Set is empty."); + IMAGE_LOGE("GetMinValue: uint32Set is empty."); return ERR_GENERAL; } value = *iter; @@ -466,7 +467,7 @@ uint32_t AttrData::GetMinValue(uint32_t &value) const return SUCCESS; } default: { - HiLog::Error(LABEL, "GetMinValue: invalid data type for uint32: %{public}d.", type_); + IMAGE_LOGE("GetMinValue: invalid data type for uint32: %{public}d.", type_); return ERR_INVALID_PARAMETER; } } @@ -482,7 +483,7 @@ uint32_t AttrData::GetMaxValue(uint32_t &value) const case AttrDataType::ATTR_DATA_UINT32_SET: { auto iter = value_.uint32Set->rbegin(); if (iter == value_.uint32Set->rend()) { - HiLog::Error(LABEL, "GetMaxValue: GetMaxValue: uint32Set is empty."); + IMAGE_LOGE("GetMaxValue: GetMaxValue: uint32Set is empty."); return ERR_GENERAL; } @@ -494,7 +495,7 @@ uint32_t AttrData::GetMaxValue(uint32_t &value) const return SUCCESS; } default: { - HiLog::Error(LABEL, "GetMaxValue: invalid data type for uint32: %{public}d.", type_); + IMAGE_LOGE("GetMaxValue: invalid data type for uint32: %{public}d.", type_); return ERR_INVALID_PARAMETER; } } @@ -510,7 +511,7 @@ uint32_t AttrData::GetMinValue(const string *&value) const case AttrDataType::ATTR_DATA_STRING_SET: { auto iter = value_.stringSet->begin(); if (iter == value_.stringSet->end()) { - HiLog::Error(LABEL, "GetMinValue: stringSet is empty."); + IMAGE_LOGE("GetMinValue: stringSet is empty."); return ERR_GENERAL; } @@ -518,7 +519,7 @@ uint32_t AttrData::GetMinValue(const string *&value) const return SUCCESS; } default: { - HiLog::Error(LABEL, "GetMinValue: invalid data type for string: %{public}d.", type_); + IMAGE_LOGE("GetMinValue: invalid data type for string: %{public}d.", type_); return ERR_INVALID_PARAMETER; } } @@ -534,7 +535,7 @@ uint32_t AttrData::GetMaxValue(const string *&value) const case AttrDataType::ATTR_DATA_STRING_SET: { auto iter = value_.stringSet->rbegin(); if (iter == value_.stringSet->rend()) { - HiLog::Error(LABEL, "GetMaxValue: stringSet is empty."); + IMAGE_LOGE("GetMaxValue: stringSet is empty."); return ERR_GENERAL; } @@ -542,7 +543,7 @@ uint32_t AttrData::GetMaxValue(const string *&value) const return SUCCESS; } default: { - HiLog::Error(LABEL, "GetMaxValue: invalid data type for string: %{public}d.", type_); + IMAGE_LOGE("GetMaxValue: invalid data type for string: %{public}d.", type_); return ERR_INVALID_PARAMETER; } } @@ -551,7 +552,7 @@ uint32_t AttrData::GetMaxValue(const string *&value) const uint32_t AttrData::GetValue(bool &value) const { if (type_ != AttrDataType::ATTR_DATA_BOOL) { - HiLog::Error(LABEL, "Get uint32 value: not a bool AttrData type: %{public}d.", type_); + IMAGE_LOGE("Get uint32 value: not a bool AttrData type: %{public}d.", type_); return ERR_INVALID_PARAMETER; } @@ -562,7 +563,7 @@ uint32_t AttrData::GetValue(bool &value) const uint32_t AttrData::GetValue(uint32_t &value) const { if (type_ != AttrDataType::ATTR_DATA_UINT32) { - HiLog::Error(LABEL, "Get uint32 value: not a uint32 AttrData type: %{public}d.", type_); + IMAGE_LOGE("Get uint32 value: not a uint32 AttrData type: %{public}d.", type_); return ERR_INVALID_PARAMETER; } @@ -573,7 +574,7 @@ uint32_t AttrData::GetValue(uint32_t &value) const uint32_t AttrData::GetValue(string &value) const { if (type_ != AttrDataType::ATTR_DATA_STRING) { - HiLog::Error(LABEL, "Get string value by reference: not a string AttrData type: %{public}d.", type_); + IMAGE_LOGE("Get string value by reference: not a string AttrData type: %{public}d.", type_); return ERR_INVALID_PARAMETER; } @@ -584,7 +585,7 @@ uint32_t AttrData::GetValue(string &value) const uint32_t AttrData::GetValue(const string *&value) const { if (type_ != AttrDataType::ATTR_DATA_STRING) { - HiLog::Error(LABEL, "Get string value: not a string AttrData type: %{public}d.", type_); + IMAGE_LOGE("Get string value: not a string AttrData type: %{public}d.", type_); return ERR_INVALID_PARAMETER; } @@ -597,7 +598,7 @@ uint32_t AttrData::InitStringAttrData(const AttrData &data) { value_.stringValue = new (std::nothrow) string(*(data.value_.stringValue)); if (value_.stringValue == nullptr) { - HiLog::Error(LABEL, "InitStringAttrData: alloc stringValue result null!"); + IMAGE_LOGE("InitStringAttrData: alloc stringValue result null!"); type_ = AttrDataType::ATTR_DATA_NULL; return ERR_INTERNAL; } @@ -609,7 +610,7 @@ uint32_t AttrData::InitUint32SetAttrData(const AttrData &data) { value_.uint32Set = new (std::nothrow) set(*(data.value_.uint32Set)); if (value_.uint32Set == nullptr) { - HiLog::Error(LABEL, "InitUint32SetAttrData: alloc uint32Set result null!"); + IMAGE_LOGE("InitUint32SetAttrData: alloc uint32Set result null!"); type_ = AttrDataType::ATTR_DATA_NULL; return ERR_INTERNAL; } @@ -621,7 +622,7 @@ uint32_t AttrData::InitStringSetAttrData(const AttrData &data) { value_.stringSet = new (std::nothrow) set(*(data.value_.stringSet)); if (value_.stringSet == nullptr) { - HiLog::Error(LABEL, "InitStringSetAttrData: alloc stringSet result null!"); + IMAGE_LOGE("InitStringSetAttrData: alloc stringSet result null!"); type_ = AttrDataType::ATTR_DATA_NULL; return ERR_INTERNAL; } @@ -652,7 +653,7 @@ bool AttrData::InRange(const set &uint32Set) const bool AttrData::InRange(const set &stringSet) const { if (stringSet.empty()) { - HiLog::Debug(LABEL, "InRange: empty set of parameter."); + IMAGE_LOGD("InRange: empty set of parameter."); return false; } diff --git a/plugins/manager/src/common/platform_adp.cpp b/plugins/manager/src/common/platform_adp.cpp index 96499558d..3f3d0ecc5 100644 --- a/plugins/manager/src/common/platform_adp.cpp +++ b/plugins/manager/src/common/platform_adp.cpp @@ -18,19 +18,20 @@ #include #endif #include "directory_ex.h" -#include "hilog/log_c.h" -#include "hilog/log_cpp.h" -#include "log_tags.h" +#include "image_log.h" #include "string" #include "plugin_errors.h" #include "type_traits" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "PlatformAdp" + namespace OHOS { namespace MultimediaPlugin { using std::string; -using namespace OHOS::HiviewDFX; - -static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "PlatformAdp" }; const string PlatformAdp::DIR_SEPARATOR = "/"; const string PlatformAdp::LIBRARY_FILE_SUFFIX = "so"; @@ -71,14 +72,14 @@ uint32_t PlatformAdp::CheckAndNormalizePath(string &path) { #if !defined(_WIN32) && !defined(_APPLE) if (path.empty()) { - HiLog::Error(LABEL, "check path empty."); + IMAGE_LOGE("check path empty."); return ERR_GENERAL; } #endif string realPath; if (!PathToRealPath(path, realPath)) { - HiLog::Error(LABEL, "path to real path error."); + IMAGE_LOGE("path to real path error."); return ERR_GENERAL; } diff --git a/plugins/manager/src/framework/capability.cpp b/plugins/manager/src/framework/capability.cpp index 151646599..f9125032f 100644 --- a/plugins/manager/src/framework/capability.cpp +++ b/plugins/manager/src/framework/capability.cpp @@ -14,20 +14,22 @@ */ #include "capability.h" -#include "hilog/log.h" +#include "image_log.h" #include "json_helper.h" -#include "log_tags.h" #include "plugin_common_type.h" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "Capability" + namespace OHOS { namespace MultimediaPlugin { using nlohmann::json; using std::map; using std::size_t; using std::string; -using namespace OHOS::HiviewDFX; - -static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "Capability" }; const string Capability::CAPABILITY_BOOL_TRUE = "true"; const string Capability::CAPABILITY_BOOL_FALSE = "false"; @@ -40,7 +42,7 @@ Capability::Capability(map &&caps) : caps_(std::move(caps)) uint32_t Capability::SetCapability(const json &capsInfo) { if (!capsInfo.is_array()) { - HiLog::Error(LABEL, "not a array type value."); + IMAGE_LOGE("not a array type value."); return ERR_INVALID_PARAMETER; } @@ -49,19 +51,19 @@ uint32_t Capability::SetCapability(const json &capsInfo) } size_t capNum = capsInfo.size(); - HiLog::Debug(LABEL, "class cap num: %{public}zu.", capNum); + IMAGE_LOGD("class cap num: %{public}zu.", capNum); string name; for (size_t i = 0; i < capNum; i++) { const json &capabilityInfo = capsInfo[i]; if (JsonHelper::GetStringValue(capabilityInfo, "name", name) != SUCCESS) { - HiLog::Error(LABEL, "failed to analysis cap name."); + IMAGE_LOGE("failed to analysis cap name."); continue; } - HiLog::Debug(LABEL, "get new cap, name: %{public}s.", name.c_str()); + IMAGE_LOGD("get new cap, name: %{public}s.", name.c_str()); AttrData attrData; if (AnalyzeAttrData(capabilityInfo, attrData) != SUCCESS) { - HiLog::Error(LABEL, "failed to analysis cap value."); + IMAGE_LOGE("failed to analysis cap value."); continue; } @@ -107,7 +109,7 @@ uint32_t Capability::AnalyzeAttrData(const json &capInfo, AttrData &attrData) { string type; if (JsonHelper::GetStringValue(capInfo, "type", type) != SUCCESS) { - HiLog::Error(LABEL, "failed to analysis data type."); + IMAGE_LOGE("failed to analysis data type."); return ERR_INVALID_PARAMETER; } @@ -122,7 +124,7 @@ uint32_t Capability::AnalyzeAttrData(const json &capInfo, AttrData &attrData) auto iter = typeMap_.find(type); if (iter == typeMap_.end()) { - HiLog::Error(LABEL, "unknown cap value type: %{public}s.", type.c_str()); + IMAGE_LOGE("unknown cap value type: %{public}s.", type.c_str()); return ERR_INVALID_PARAMETER; } @@ -146,7 +148,7 @@ uint32_t Capability::AnalyzeAttrData(const json &capInfo, AttrData &attrData) return AnalyzeUint32Range(capInfo, attrData); } default: { - HiLog::Error(LABEL, "unexpected cap value type: %{public}d.", iter->second); + IMAGE_LOGE("unexpected cap value type: %{public}d.", iter->second); return ERR_INTERNAL; } } @@ -158,7 +160,7 @@ uint32_t Capability::AnalyzeBool(const json &capInfo, AttrData &attrData) { string value; if (JsonHelper::GetStringValue(capInfo, "value", value) != SUCCESS) { - HiLog::Error(LABEL, "failed to analysis bool value."); + IMAGE_LOGE("failed to analysis bool value."); return ERR_INVALID_PARAMETER; } @@ -168,11 +170,11 @@ uint32_t Capability::AnalyzeBool(const json &capInfo, AttrData &attrData) } else if (value == CAPABILITY_BOOL_FALSE) { attrValue = false; } else { - HiLog::Error(LABEL, "failed to analyze bool value: %{public}s.", value.c_str()); + IMAGE_LOGE("failed to analyze bool value: %{public}s.", value.c_str()); return ERR_INVALID_PARAMETER; } - HiLog::Debug(LABEL, "get bool AttrData: %{public}s.", value.c_str()); + IMAGE_LOGD("get bool AttrData: %{public}s.", value.c_str()); attrData.SetData(attrValue); return SUCCESS; @@ -182,11 +184,11 @@ uint32_t Capability::AnalyzeUint32(const json &capInfo, AttrData &attrData) { uint32_t value; if (JsonHelper::GetUint32Value(capInfo, "value", value) != SUCCESS) { - HiLog::Error(LABEL, "failed to analysis uint32 value."); + IMAGE_LOGE("failed to analysis uint32 value."); return ERR_INVALID_PARAMETER; } - HiLog::Debug(LABEL, "get uint32 AttrData: %{public}u.", value); + IMAGE_LOGD("get uint32 AttrData: %{public}u.", value); attrData.SetData(value); return SUCCESS; @@ -196,18 +198,18 @@ uint32_t Capability::AnalyzeString(const json &capInfo, AttrData &attrData) { string value; if (JsonHelper::GetStringValue(capInfo, "value", value) != SUCCESS) { - HiLog::Error(LABEL, "failed to analysis string value."); + IMAGE_LOGE("failed to analysis string value."); return ERR_INVALID_PARAMETER; } if (value.empty()) { - HiLog::Error(LABEL, "failed to analyze string value."); + IMAGE_LOGE("failed to analyze string value."); return ERR_INVALID_PARAMETER; } - HiLog::Debug(LABEL, "get string AttrData: %{public}s.", value.c_str()); + IMAGE_LOGD("get string AttrData: %{public}s.", value.c_str()); if (attrData.SetData(std::move(value)) != SUCCESS) { - HiLog::Error(LABEL, "AnalyzeString: failed to call SetData for string type."); + IMAGE_LOGE("AnalyzeString: failed to call SetData for string type."); return ERR_INTERNAL; } @@ -218,13 +220,13 @@ uint32_t Capability::AnalyzeUint32Set(const json &capInfo, AttrData &attrData) { size_t arraySize; if (JsonHelper::GetArraySize(capInfo, "value", arraySize) != SUCCESS) { - HiLog::Error(LABEL, "failed to analysis uint32Set value."); + IMAGE_LOGE("failed to analysis uint32Set value."); return ERR_INVALID_PARAMETER; } - HiLog::Debug(LABEL, "uint32Set size: %{public}zu.", arraySize); + IMAGE_LOGD("uint32Set size: %{public}zu.", arraySize); if (arraySize < SET_MIN_VALUE_NUM) { - HiLog::Error(LABEL, "invalid uint32Set size: %{public}zu.", arraySize); + IMAGE_LOGE("invalid uint32Set size: %{public}zu.", arraySize); return ERR_INVALID_PARAMETER; } @@ -232,13 +234,13 @@ uint32_t Capability::AnalyzeUint32Set(const json &capInfo, AttrData &attrData) const json &valueArray = capInfo["value"]; for (size_t i = 0; i < arraySize; i++) { if (JsonHelper::GetUint32Value(valueArray[i], value) != SUCCESS) { - HiLog::Error(LABEL, "fail to analyze uint32Set[%{public}zu]: %{public}u.", i, value); + IMAGE_LOGE("fail to analyze uint32Set[%{public}zu]: %{public}u.", i, value); attrData.ClearData(); return ERR_INVALID_PARAMETER; } - HiLog::Debug(LABEL, "get uint32Set[%{public}zu]: %{public}u.", i, value); + IMAGE_LOGD("get uint32Set[%{public}zu]: %{public}u.", i, value); if (attrData.InsertSet(value) != SUCCESS) { - HiLog::Error(LABEL, "AnalyzeUint32Set: failed to call InsertSet."); + IMAGE_LOGE("AnalyzeUint32Set: failed to call InsertSet."); attrData.ClearData(); return ERR_INTERNAL; } @@ -251,33 +253,32 @@ uint32_t Capability::AnalyzeUint32Range(const json &capInfo, AttrData &attrData) { size_t arraySize; if (JsonHelper::GetArraySize(capInfo, "value", arraySize) != SUCCESS) { - HiLog::Error(LABEL, "failed to analysis uint32Range value."); + IMAGE_LOGE("failed to analysis uint32Range value."); return ERR_INVALID_PARAMETER; } - HiLog::Debug(LABEL, "uint32Range size: %{public}zu.", arraySize); + IMAGE_LOGD("uint32Range size: %{public}zu.", arraySize); if (arraySize != AttrData::RANGE_ARRAY_SIZE) { - HiLog::Error(LABEL, "invalid uint32Range size: %{public}zu.", arraySize); + IMAGE_LOGE("invalid uint32Range size: %{public}zu.", arraySize); return ERR_INVALID_PARAMETER; } const json &valueArray = capInfo["value"]; uint32_t lowerBound = 0; if (JsonHelper::GetUint32Value(valueArray[AttrData::LOWER_BOUND_INDEX], lowerBound) != SUCCESS) { - HiLog::Error(LABEL, "fail to analyze uint32 value of lowerBound: %{public}u.", lowerBound); + IMAGE_LOGE("fail to analyze uint32 value of lowerBound: %{public}u.", lowerBound); return ERR_INVALID_PARAMETER; } uint32_t upperBound = 0; if (JsonHelper::GetUint32Value(valueArray[AttrData::UPPER_BOUND_INDEX], upperBound) != SUCCESS) { - HiLog::Error(LABEL, "fail to analyze uint32 value of upperBound: %{public}u.", upperBound); + IMAGE_LOGE("fail to analyze uint32 value of upperBound: %{public}u.", upperBound); return ERR_INVALID_PARAMETER; } - HiLog::Debug(LABEL, "AnalyzeUint32Range: get lowerBound: %{public}u, upperBound: %{public}u.", lowerBound, - upperBound); + IMAGE_LOGD("AnalyzeUint32Range: get lowerBound: %{public}u, upperBound: %{public}u.", lowerBound, upperBound); if (attrData.SetData(lowerBound, upperBound) != SUCCESS) { - HiLog::Error(LABEL, "AnalyzeUint32Range: failed to call SetData."); + IMAGE_LOGE("AnalyzeUint32Range: failed to call SetData."); return ERR_INTERNAL; } @@ -288,13 +289,13 @@ uint32_t Capability::AnalyzeStringSet(const json &capInfo, AttrData &attrData) { size_t arraySize; if (JsonHelper::GetArraySize(capInfo, "value", arraySize) != SUCCESS) { - HiLog::Error(LABEL, "failed to analysis stringSet value."); + IMAGE_LOGE("failed to analysis stringSet value."); return ERR_INVALID_PARAMETER; } - HiLog::Debug(LABEL, "stringSet size: %{public}zu.", arraySize); + IMAGE_LOGD("stringSet size: %{public}zu.", arraySize); if (arraySize < SET_MIN_VALUE_NUM) { - HiLog::Error(LABEL, "invalid stringSet size: %{public}zu.", arraySize); + IMAGE_LOGE("invalid stringSet size: %{public}zu.", arraySize); return ERR_INVALID_PARAMETER; } @@ -302,14 +303,14 @@ uint32_t Capability::AnalyzeStringSet(const json &capInfo, AttrData &attrData) string value; for (size_t i = 0; i < arraySize; i++) { if (JsonHelper::GetStringValue(valueArray[i], value) != SUCCESS) { - HiLog::Error(LABEL, "failed to analyze string value in stringSet[%{public}zu].", i); + IMAGE_LOGE("failed to analyze string value in stringSet[%{public}zu].", i); attrData.ClearData(); return ERR_INVALID_PARAMETER; } - HiLog::Debug(LABEL, "AnalyzeStringSet: get stringSet[%{public}zu]: %{public}s.", i, value.c_str()); + IMAGE_LOGD("AnalyzeStringSet: get stringSet[%{public}zu]: %{public}s.", i, value.c_str()); if (attrData.InsertSet(std::move(value)) != SUCCESS) { - HiLog::Error(LABEL, "AnalyzeStringSet: failed to call InsertSet."); + IMAGE_LOGE("AnalyzeStringSet: failed to call InsertSet."); attrData.ClearData(); return ERR_INTERNAL; } diff --git a/plugins/manager/src/framework/impl_class.cpp b/plugins/manager/src/framework/impl_class.cpp index b83190a57..6b740fb18 100644 --- a/plugins/manager/src/framework/impl_class.cpp +++ b/plugins/manager/src/framework/impl_class.cpp @@ -15,15 +15,20 @@ #include "impl_class.h" #include -#include "hilog/log.h" +#include "image_log.h" #include "impl_class_key.h" #include "json_helper.h" -#include "log_tags.h" #include "plugin.h" #include "plugin_class_base.h" #include "plugin_common_type.h" #include "plugin_export.h" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "ImplClass" + namespace OHOS { namespace MultimediaPlugin { using nlohmann::json; @@ -34,9 +39,6 @@ using std::shared_ptr; using std::size_t; using std::string; using std::weak_ptr; -using namespace OHOS::HiviewDFX; - -static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "ImplClass" }; string ImplClass::emptyString_; ImplClass::ImplClass() : selfKey_(*this) @@ -46,37 +48,37 @@ uint32_t ImplClass::Register(const weak_ptr &plugin, const json &classIn { if (state_ != ClassState::CLASS_STATE_UNREGISTER) { // repeat registration - HiLog::Info(LABEL, "repeat registration."); + IMAGE_LOGI("repeat registration."); return ERR_INTERNAL; } if (JsonHelper::GetStringValue(classInfo, "className", className_) != SUCCESS) { - HiLog::Error(LABEL, "read className failed."); + IMAGE_LOGE("read className failed."); return ERR_INVALID_PARAMETER; } - HiLog::Debug(LABEL, "register class: %{public}s.", className_.c_str()); + IMAGE_LOGD("register class: %{public}s.", className_.c_str()); if (!AnalysisServices(classInfo)) { - HiLog::Error(LABEL, "failed to analysis services for class %{public}s.", className_.c_str()); + IMAGE_LOGE("failed to analysis services for class %{public}s.", className_.c_str()); return ERR_INVALID_PARAMETER; } uint32_t result = JsonHelper::GetUint16Value(classInfo, "priority", priority_); if (result != SUCCESS) { if (result != ERR_NO_TARGET) { - HiLog::Error(LABEL, "read priority failed, result: %{public}u.", result); + IMAGE_LOGE("read priority failed, result: %{public}u.", result); return ERR_INVALID_PARAMETER; } // priority is optional, and default zero. priority_ = 0; } - HiLog::Debug(LABEL, "get class priority: %{public}u.", priority_); + IMAGE_LOGD("get class priority: %{public}u.", priority_); if (!AnalysisMaxInstance(classInfo)) { - HiLog::Error(LABEL, "failed to analysis maxInstance for class %{public}s.", className_.c_str()); + IMAGE_LOGE("failed to analysis maxInstance for class %{public}s.", className_.c_str()); return ERR_INVALID_PARAMETER; } - HiLog::Debug(LABEL, "get class maxInstance: %{public}u.", maxInstance_); + IMAGE_LOGD("get class maxInstance: %{public}u.", maxInstance_); if (JsonHelper::CheckElementExistence(classInfo, "capabilities") == SUCCESS) { capability_.SetCapability(classInfo["capabilities"]); @@ -90,23 +92,22 @@ PluginClassBase *ImplClass::CreateObject(uint32_t &errorCode) { errorCode = ERR_INTERNAL; if (state_ != ClassState::CLASS_STATE_REGISTERED) { - HiLog::Error(LABEL, "failed to create for unregistered, className: %{public}s.", className_.c_str()); + IMAGE_LOGE("failed to create for unregistered, className: %{public}s.", className_.c_str()); return nullptr; } auto sharedPlugin = pluginRef_.lock(); if (sharedPlugin == nullptr) { - HiLog::Error(LABEL, "failed to dereference Plugin, className: %{public}s.", className_.c_str()); + IMAGE_LOGE("failed to dereference Plugin, className: %{public}s.", className_.c_str()); return nullptr; } - HiLog::Debug(LABEL, "create object, className: %{public}s.", className_.c_str()); + IMAGE_LOGD("create object, className: %{public}s.", className_.c_str()); std::unique_lock guard(dynDataLock_); if (maxInstance_ != INSTANCE_NO_LIMIT_NUM && instanceNum_ >= maxInstance_) { - HiLog::Error(LABEL, "failed to create for limit, currentNum: %{public}u, maxNum: %{public}u, \ - className: %{public}s.", - instanceNum_, maxInstance_, className_.c_str()); + IMAGE_LOGE("failed to create for limit, currentNum: %{public}u, maxNum: %{public}u, \ + className: %{public}s.", instanceNum_, maxInstance_, className_.c_str()); guard.unlock(); errorCode = ERR_INSTANCE_LIMIT; return nullptr; @@ -120,7 +121,7 @@ PluginClassBase *ImplClass::CreateObject(uint32_t &errorCode) PluginClassBase *object = DoCreateObject(sharedPlugin); if (object == nullptr) { - HiLog::Error(LABEL, "create object result null, className: %{public}s.", className_.c_str()); + IMAGE_LOGE("create object result null, className: %{public}s.", className_.c_str()); if (instanceNum_ == 0) { sharedPlugin->DeRef(); } @@ -128,7 +129,7 @@ PluginClassBase *ImplClass::CreateObject(uint32_t &errorCode) } ++instanceNum_; - HiLog::Debug(LABEL, "create object success, InstanceNum: %{public}u.", instanceNum_); + IMAGE_LOGD("create object success, InstanceNum: %{public}u.", instanceNum_); guard.unlock(); errorCode = SUCCESS; @@ -152,15 +153,13 @@ const string &ImplClass::GetClassName() const const string &ImplClass::GetPackageName() const { if (state_ != ClassState::CLASS_STATE_REGISTERED) { - HiLog::Error(LABEL, "get package name, className: %{public}s, state error: %{public}d.", className_.c_str(), - state_); + IMAGE_LOGE("get package name, className: %{public}s, state error: %{public}d.", className_.c_str(), state_); return emptyString_; } auto sharedPlugin = pluginRef_.lock(); if (sharedPlugin == nullptr) { - HiLog::Error(LABEL, "get package name, failed to dereference Plugin, className: %{public}s.", - className_.c_str()); + IMAGE_LOGE("get package name, failed to dereference Plugin, className: %{public}s.", className_.c_str()); return emptyString_; } @@ -169,14 +168,14 @@ const string &ImplClass::GetPackageName() const bool ImplClass::IsSupport(uint16_t interfaceID) const { - HiLog::Debug(LABEL, "search for support iid: %{public}u, className: %{public}s.", interfaceID, className_.c_str()); + IMAGE_LOGD("search for support iid: %{public}u, className: %{public}s.", interfaceID, className_.c_str()); for (uint32_t serviceFlag : services_) { if (MakeIID(serviceFlag) == interfaceID) { return true; } } - HiLog::Debug(LABEL, "there is no matching interfaceID"); + IMAGE_LOGD("there is no matching interfaceID"); return false; } @@ -186,8 +185,7 @@ void ImplClass::OnObjectDestroy() // the process context can guarantee that this will not happen. // the judgment statement here is for protection and positioning purposes only. if (state_ != ClassState::CLASS_STATE_REGISTERED) { - HiLog::Error(LABEL, "failed to destroy object because class unregistered, className: %{public}s.", - className_.c_str()); + IMAGE_LOGE("failed to destroy object because class unregistered, className: %{public}s.", className_.c_str()); return; } @@ -195,7 +193,7 @@ void ImplClass::OnObjectDestroy() // this situation does not happen in design. if (instanceNum_ == 0) { guard.unlock(); - HiLog::Error(LABEL, "destroy object while instanceNum is zero."); + IMAGE_LOGE("destroy object while instanceNum is zero."); return; } @@ -205,17 +203,17 @@ void ImplClass::OnObjectDestroy() // this situation does not happen in design. if (sharedPlugin == nullptr) { guard.unlock(); - HiLog::Error(LABEL, "destroy object failed because failed to dereference Plugin, className: %{public}s.", - className_.c_str()); + IMAGE_LOGE("destroy object failed because failed to dereference Plugin, className: %{public}s.", + className_.c_str()); return; } - HiLog::Debug(LABEL, "destroy object: className: %{public}s", className_.c_str()); + IMAGE_LOGD("destroy object: className: %{public}s", className_.c_str()); if (instanceNum_ == 0) { sharedPlugin->DeRef(); } - HiLog::Debug(LABEL, "destroy object success, InstanceNum: %{public}u.", instanceNum_); + IMAGE_LOGD("destroy object success, InstanceNum: %{public}u.", instanceNum_); } const set &ImplClass::GetServices() const @@ -247,10 +245,10 @@ bool ImplClass::AnalysisServices(const json &classInfo) { size_t serviceNum; if (JsonHelper::GetArraySize(classInfo, "services", serviceNum) != SUCCESS) { - HiLog::Error(LABEL, "read array size of services failed."); + IMAGE_LOGE("read array size of services failed."); return false; } - HiLog::Debug(LABEL, "class service num: %{public}zu.", serviceNum); + IMAGE_LOGD("class service num: %{public}zu.", serviceNum); uint16_t interfaceID; #ifndef PLUGIN_FLAG_RTTI_ENABLE @@ -262,13 +260,13 @@ bool ImplClass::AnalysisServices(const json &classInfo) for (size_t i = 0; i < serviceNum; i++) { const json &serviceInfo = servicesInfo[i]; if (JsonHelper::GetUint16Value(serviceInfo, "interfaceID", interfaceID) != SUCCESS) { - HiLog::Error(LABEL, "read interfaceID failed at %{public}zu.", i); + IMAGE_LOGE("read interfaceID failed at %{public}zu.", i); #ifndef PLUGIN_FLAG_RTTI_ENABLE // when -frtti is not enable, to ensure correct base class side-to-side conversion, we require that // the plugin class inherit only one service interface class and the PluginClassBase class, // while the location of the service interface class is in front of the PluginClassBase. // below, we check only one business interface class is allowed to inherit. - HiLog::Error(LABEL, "no valid service info or encounter the risk of more than one business \ + IMAGE_LOGE("no valid service info or encounter the risk of more than one business \ interface base class."); return false; #else @@ -279,7 +277,7 @@ bool ImplClass::AnalysisServices(const json &classInfo) #ifndef PLUGIN_FLAG_RTTI_ENABLE // check only one business interface class is allowed to inherit. if (lastInterfaceID != UINT32_MAX_VALUE && lastInterfaceID != interfaceID) { - HiLog::Error(LABEL, "more than one business interface base class."); + IMAGE_LOGE("more than one business interface base class."); return false; } lastInterfaceID = interfaceID; @@ -287,14 +285,14 @@ bool ImplClass::AnalysisServices(const json &classInfo) uint32_t result = JsonHelper::GetUint16Value(serviceInfo, "serviceType", serviceType); if (result != SUCCESS) { if (result != ERR_NO_TARGET) { - HiLog::Error(LABEL, "read serviceType failed at %{public}zu.", i); + IMAGE_LOGE("read serviceType failed at %{public}zu.", i); continue; } // serviceType is optional, and default zero. serviceType = 0; } - HiLog::Debug(LABEL, "insert service iid: %{public}hu, serviceType: %{public}hu.", interfaceID, serviceType); + IMAGE_LOGD("insert service iid: %{public}hu, serviceType: %{public}hu.", interfaceID, serviceType); services_.insert(MakeServiceFlag(interfaceID, serviceType)); serviceAdded = true; } @@ -306,16 +304,16 @@ bool ImplClass::AnalysisMaxInstance(const json &classInfo) { uint32_t result = JsonHelper::GetUint16Value(classInfo, "maxInstance", maxInstance_); if (result == SUCCESS) { - HiLog::Debug(LABEL, "class maxInstance num: %{public}u.", maxInstance_); + IMAGE_LOGD("class maxInstance num: %{public}u.", maxInstance_); if (maxInstance_ == 0) { - HiLog::Error(LABEL, "class maxInstance num is invalid zero."); + IMAGE_LOGE("class maxInstance num is invalid zero."); return false; } return true; } if (result != ERR_NO_TARGET) { - HiLog::Error(LABEL, "read maxInstance failed."); + IMAGE_LOGE("read maxInstance failed."); return false; } @@ -335,13 +333,13 @@ PluginClassBase *ImplClass::DoCreateObject(shared_ptr &plugin) // so it is reread every time here. PluginCreateFunc factory = plugin->GetCreateFunc(); if (factory == nullptr) { - HiLog::Error(LABEL, "failed to get create func, className: %{public}s.", className_.c_str()); + IMAGE_LOGE("failed to get create func, className: %{public}s.", className_.c_str()); return nullptr; } PluginClassBase *pluginBaseObj = CfiFactory(factory, className_); if (pluginBaseObj == nullptr) { - HiLog::Error(LABEL, "create object result null, className: %{public}s.", className_.c_str()); + IMAGE_LOGE("create object result null, className: %{public}s.", className_.c_str()); return nullptr; } @@ -353,15 +351,14 @@ PluginClassBase *ImplClass::DoCreateObject(shared_ptr &plugin) void *obj = dynamic_cast(pluginBaseObj); // adjust pointer position when multiple inheritance. if (obj == pluginBaseObj) { // PluginClassBase is the first base class, not allowed. - HiLog::Error(LABEL, "service interface class is not the first base class. className: %{public}s.", - className_.c_str()); + IMAGE_LOGE("service interface class is not the first base class. className: %{public}s.", className_.c_str()); delete pluginBaseObj; return nullptr; } #endif if (pluginBaseObj->SetImplClassKey(selfKey_) != PluginClassBase::MAGIC_CODE) { - HiLog::Error(LABEL, "failed to set key, className: %{public}s.", className_.c_str()); + IMAGE_LOGE("failed to set key, className: %{public}s.", className_.c_str()); delete pluginBaseObj; return nullptr; } diff --git a/plugins/manager/src/framework/impl_class_key.cpp b/plugins/manager/src/framework/impl_class_key.cpp index 12163c291..341cc6314 100644 --- a/plugins/manager/src/framework/impl_class_key.cpp +++ b/plugins/manager/src/framework/impl_class_key.cpp @@ -14,23 +14,23 @@ */ #include "impl_class_key.h" -#include "hilog/log_c.h" -#include "hilog/log_cpp.h" +#include "image_log.h" #include "impl_class.h" #include "iosfwd" -#include "log_tags.h" #include "string" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "ImplClassKey" + namespace OHOS { namespace MultimediaPlugin { -using namespace OHOS::HiviewDFX; - -static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "ImplClassKey" }; - void ImplClassKey::OnObjectDestroy() { - HiLog::Debug(LABEL, "destroy object: className: %{public}s, packageName: %{public}s,", - implClass_.GetClassName().c_str(), implClass_.GetPackageName().c_str()); + IMAGE_LOGD("destroy object: className: %{public}s, packageName: %{public}s,", + implClass_.GetClassName().c_str(), implClass_.GetPackageName().c_str()); implClass_.OnObjectDestroy(); } diff --git a/plugins/manager/src/framework/impl_class_mgr.cpp b/plugins/manager/src/framework/impl_class_mgr.cpp index a62fdd316..2063a4556 100644 --- a/plugins/manager/src/framework/impl_class_mgr.cpp +++ b/plugins/manager/src/framework/impl_class_mgr.cpp @@ -14,12 +14,17 @@ */ #include "impl_class_mgr.h" -#include "hilog/log.h" +#include "image_log.h" #include "impl_class.h" -#include "log_tags.h" #include "plugin.h" #include "plugin_class_base.h" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "ImplClassMgr" + namespace OHOS { namespace MultimediaPlugin { using nlohmann::json; @@ -31,37 +36,34 @@ using std::set; using std::shared_ptr; using std::string; using std::weak_ptr; -using namespace OHOS::HiviewDFX; - -static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "ImplClassMgr" }; uint32_t ImplClassMgr::AddClass(weak_ptr &plugin, const json &classInfo) { shared_ptr implClass = std::make_shared(); if (implClass == nullptr) { - HiLog::Error(LABEL, "AddClass: failed to create ImplClass."); + IMAGE_LOGE("AddClass: failed to create ImplClass."); return ERR_INTERNAL; } auto ret = implClass->Register(plugin, classInfo); if (ret != SUCCESS) { - HiLog::Error(LABEL, "AddClass: failed to register impClass.ERRNO: %{public}u.", ret); + IMAGE_LOGE("AddClass: failed to register impClass.ERRNO: %{public}u.", ret); return ret; } const string &key = implClass->GetClassName(); if (key.empty()) { - HiLog::Error(LABEL, "AddClass: empty className."); + IMAGE_LOGE("AddClass: empty className."); return ERR_INTERNAL; } - HiLog::Debug(LABEL, "AddClass: insert Class: %{public}s.", key.c_str()); + IMAGE_LOGD("AddClass: insert Class: %{public}s.", key.c_str()); classMultimap_.insert(NameClassMultimap::value_type(&key, implClass)); // for fast search by service flag const set &services = implClass->GetServices(); for (const uint32_t &srv : services) { - HiLog::Debug(LABEL, "AddClass: insert service: %{public}u.", srv); + IMAGE_LOGD("AddClass: insert service: %{public}u.", srv); srvSearchMultimap_.insert(ServiceClassMultimap::value_type(srv, implClass)); } @@ -94,12 +96,12 @@ void ImplClassMgr::DeleteClass(const weak_ptr &plugin) PluginClassBase *ImplClassMgr::CreateObject(uint16_t interfaceID, const string &className, uint32_t &errorCode) { - HiLog::Debug(LABEL, "create object iid: %{public}hu, className: %{public}s.", interfaceID, className.c_str()); + IMAGE_LOGD("create object iid: %{public}hu, className: %{public}s.", interfaceID, className.c_str()); NameClassMultimap::iterator iter = classMultimap_.lower_bound(&className); NameClassMultimap::iterator endIter = classMultimap_.upper_bound(&className); if (iter == endIter) { - HiLog::Error(LABEL, "failed to find matching class by className: %{public}s.", className.c_str()); + IMAGE_LOGE("failed to find matching class by className: %{public}s.", className.c_str()); errorCode = ERR_MATCHING_PLUGIN; return nullptr; } @@ -111,8 +113,8 @@ PluginClassBase *ImplClassMgr::CreateObject(uint16_t interfaceID, const string & } // no this class - HiLog::Error(LABEL, "failed to find matching class for iid: %{public}hu, className: %{public}s.", interfaceID, - className.c_str()); + IMAGE_LOGE("failed to find matching class for iid: %{public}hu, className: %{public}s.", interfaceID, + className.c_str()); errorCode = ERR_MATCHING_PLUGIN; return nullptr; } @@ -124,7 +126,7 @@ PluginClassBase *ImplClassMgr::CreateObject(uint16_t interfaceID, uint16_t servi uint32_t serviceFlag = ImplClass::MakeServiceFlag(interfaceID, serviceType); list> candidates; - HiLog::Debug(LABEL, "create object iid: %{public}u, serviceType: %{public}u.", interfaceID, serviceType); + IMAGE_LOGD("create object iid: %{public}u, serviceType: %{public}u.", interfaceID, serviceType); auto iter = srvSearchMultimap_.lower_bound(serviceFlag); auto endIter = srvSearchMultimap_.upper_bound(serviceFlag); @@ -138,12 +140,12 @@ PluginClassBase *ImplClassMgr::CreateObject(uint16_t interfaceID, uint16_t servi shared_ptr target = SearchByPriority(candidates, priorityScheme); if (target == nullptr) { - HiLog::Debug(LABEL, "failed to find class by priority."); + IMAGE_LOGD("failed to find class by priority."); errorCode = ERR_MATCHING_PLUGIN; return nullptr; } - HiLog::Debug(LABEL, "search by priority result, className: %{public}s.", target->GetClassName().c_str()); + IMAGE_LOGD("search by priority result, className: %{public}s.", target->GetClassName().c_str()); return target->CreateObject(errorCode); } @@ -154,12 +156,12 @@ uint32_t ImplClassMgr::ImplClassMgrGetClassInfo(uint16_t interfaceID, uint16_t s // get service flag by interfaceID and serviceType uint32_t serviceFlag = ImplClass::MakeServiceFlag(interfaceID, serviceType); - HiLog::Debug(LABEL, "get classinfo iid: %{public}u, serviceType: %{public}u.", interfaceID, serviceType); + IMAGE_LOGD("get classinfo iid: %{public}u, serviceType: %{public}u.", interfaceID, serviceType); auto iter = srvSearchMultimap_.lower_bound(serviceFlag); auto endIter = srvSearchMultimap_.upper_bound(serviceFlag); if (iter == endIter) { - HiLog::Error(LABEL, "failed to get class by serviceFlag, iid: %{public}u, serviceType: %{public}u.", - interfaceID, serviceType); + IMAGE_LOGE("failed to get class by serviceFlag, iid: %{public}u, serviceType: %{public}u.", + interfaceID, serviceType); return ERR_MATCHING_PLUGIN; } @@ -169,8 +171,7 @@ uint32_t ImplClassMgr::ImplClassMgrGetClassInfo(uint16_t interfaceID, uint16_t s continue; } // after multiple filtering, there are only a few instances here, which will not cause massive logs. - HiLog::Debug(LABEL, "found by serviceFlag & capabilities, className: %{public}s.", - temp->GetClassName().c_str()); + IMAGE_LOGD("found by serviceFlag & capabilities, className: %{public}s.", temp->GetClassName().c_str()); ClassInfo classInfo; classInfo.packageName = temp->GetPackageName(); classInfo.className = temp->GetClassName(); @@ -180,8 +181,8 @@ uint32_t ImplClassMgr::ImplClassMgrGetClassInfo(uint16_t interfaceID, uint16_t s } if (classesInfo.empty()) { - HiLog::Error(LABEL, "failed to get class by capabilities, iid: %{public}u, serviceType: %{public}u.", - interfaceID, serviceType); + IMAGE_LOGE("failed to get class by capabilities, iid: %{public}u, serviceType: %{public}u.", interfaceID, + serviceType); return ERR_MATCHING_PLUGIN; } @@ -190,7 +191,7 @@ uint32_t ImplClassMgr::ImplClassMgrGetClassInfo(uint16_t interfaceID, uint16_t s shared_ptr ImplClassMgr::GetImplClass(const string &packageName, const string &className) { - HiLog::Debug(LABEL, "search ImplClass, className: %{public}s.", className.c_str()); + IMAGE_LOGD("search ImplClass, className: %{public}s.", className.c_str()); shared_ptr implClass = nullptr; auto iter = classMultimap_.lower_bound(&className); auto endIter = classMultimap_.upper_bound(&className); @@ -202,7 +203,7 @@ shared_ptr ImplClassMgr::GetImplClass(const string &packageName, cons } if (implClass == nullptr) { - HiLog::Error(LABEL, "failed to get ImplClass, className: %{public}s.", className.c_str()); + IMAGE_LOGE("failed to get ImplClass, className: %{public}s.", className.c_str()); } return implClass; @@ -220,7 +221,7 @@ shared_ptr ImplClassMgr::SearchByPriority(const list ImplClassMgr::SearchByPriority(const list ImplClassMgr::SearchSimplePriority(const list> &candidates) { if (candidates.size() == 0) { - HiLog::Error(LABEL, "SearchSimplePriority: candidates size is zero."); + IMAGE_LOGE("SearchSimplePriority: candidates size is zero."); return nullptr; } auto targetIter = candidates.begin(); @@ -297,8 +298,8 @@ shared_ptr ImplClassMgr::SearchSimplePriority(const list(jsonNum)); + IMAGE_LOGE("GetUint32Value: not a unsigned integer type value, num: %{public}lld.", + static_cast(jsonNum)); return ERR_DATA_TYPE; } if (jsonNum > UINT32_MAX_VALUE) { - HiLog::Error(LABEL, "GetUint32Value: out of range value, num: %{public}llu.", - static_cast(jsonNum)); + IMAGE_LOGE("GetUint32Value: out of range value, num: %{public}llu.", + static_cast(jsonNum)); return ERR_DATA_TYPE; } @@ -102,19 +104,19 @@ uint32_t JsonHelper::GetUint16Value(const json &jsonObject, const string &key, u } if (!jsonNum.is_number_integer()) { - HiLog::Error(LABEL, "GetUint16Value: not a integer type value for key %{public}s.", key.c_str()); + IMAGE_LOGE("GetUint16Value: not a integer type value for key %{public}s.", key.c_str()); return ERR_DATA_TYPE; } if (jsonNum < 0) { - HiLog::Error(LABEL, "GetUint16Value: not a unsigned integer type value for key %{public}s, num: %{public}lld.", - key.c_str(), static_cast(jsonNum)); + IMAGE_LOGE("GetUint16Value: not a unsigned integer type value for key %{public}s, num: %{public}lld.", + key.c_str(), static_cast(jsonNum)); return ERR_DATA_TYPE; } if (jsonNum > UINT16_MAX_VALUE) { - HiLog::Error(LABEL, "GetUint16Value: out of range value for key %{public}s, num: %{public}llu.", key.c_str(), - static_cast(jsonNum)); + IMAGE_LOGE("GetUint16Value: out of range value for key %{public}s, num: %{public}llu.", key.c_str(), + static_cast(jsonNum)); return ERR_DATA_TYPE; } @@ -132,7 +134,7 @@ uint32_t JsonHelper::GetArraySize(const json &jsonObject, const string &key, siz } if (!jsonArray.is_array()) { - HiLog::Error(LABEL, "GetArraySize: not a array type value for key %{public}s.", key.c_str()); + IMAGE_LOGE("GetArraySize: not a array type value for key %{public}s.", key.c_str()); return ERR_DATA_TYPE; } @@ -144,7 +146,7 @@ uint32_t JsonHelper::GetArraySize(const json &jsonObject, const string &key, siz const json &JsonHelper::GetJsonElement(const json &jsonObject, const string &key, uint32_t &errorCode) { if (!jsonObject.is_object()) { - HiLog::Error(LABEL, "GetJsonElement: not an object type json for key %{public}s.", key.c_str()); + IMAGE_LOGE("GetJsonElement: not an object type json for key %{public}s.", key.c_str()); errorCode = ERR_DATA_TYPE; return nullJson_; } @@ -152,7 +154,7 @@ const json &JsonHelper::GetJsonElement(const json &jsonObject, const string &key auto iter = jsonObject.find(key); if (iter == jsonObject.end()) { // some elements are optional, it is normal to miss them, so do not use error level here. - HiLog::Debug(LABEL, "GetJsonElement: failed to find key %{public}s.", key.c_str()); + IMAGE_LOGD("GetJsonElement: failed to find key %{public}s.", key.c_str()); errorCode = ERR_NO_TARGET; return nullJson_; } @@ -165,11 +167,11 @@ void JsonHelper::PrintElementMissingLog(const std::string &identifier, const std { if (errorCode == ERR_NO_TARGET) { // some elements are optional, it is normal to miss them, so do not use error level here. - HiLog::Debug(LABEL, "%{public}s: failed to find key %{public}s, ERRNO: %{public}u.", identifier.c_str(), - key.c_str(), errorCode); + IMAGE_LOGD("%{public}s: failed to find key %{public}s, ERRNO: %{public}u.", identifier.c_str(), + key.c_str(), errorCode); } else { - HiLog::Error(LABEL, "%{public}s: failed to find key %{public}s, ERRNO: %{public}u.", identifier.c_str(), - key.c_str(), errorCode); + IMAGE_LOGE("%{public}s: failed to find key %{public}s, ERRNO: %{public}u.", identifier.c_str(), + key.c_str(), errorCode); } } } // namespace MultimediaPlugin diff --git a/plugins/manager/src/framework/plugin.cpp b/plugins/manager/src/framework/plugin.cpp index 6b336fd48..28e0673ae 100644 --- a/plugins/manager/src/framework/plugin.cpp +++ b/plugins/manager/src/framework/plugin.cpp @@ -15,11 +15,10 @@ #include "plugin.h" #include -#include "hilog/log.h" +#include "image_log.h" #include "impl_class_mgr.h" #include "json.hpp" #include "json_helper.h" -#include "log_tags.h" #include "platform_adp.h" #include "singleton.h" #ifdef _WIN32 @@ -27,6 +26,12 @@ HMODULE hDll = NULL; #endif +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "Plugin" + namespace OHOS { namespace MultimediaPlugin { using nlohmann::json; @@ -36,7 +41,6 @@ using std::recursive_mutex; using std::size_t; using std::string; using std::weak_ptr; -using namespace OHOS::HiviewDFX; enum class VersionParseStep : int32_t { STEP_MAJOR = 0, STEP_MINOR, STEP_MICRO, STEP_NANO, STEP_FINISHED }; @@ -47,8 +51,6 @@ struct VersionNum { uint16_t nano = 0; }; -static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "Plugin" }; - Plugin::Plugin() : platformAdp_(DelayedRefSingleton::GetInstance()), implClassMgr_(DelayedRefSingleton::GetInstance()) {} @@ -60,7 +62,7 @@ Plugin::~Plugin() // this situation does not happen in design. // the process context can guarantee that this will not happen. // the judgment statement here is for protection and positioning purposes only. - HiLog::Error(LABEL, "release plugin: refNum: %{public}u.", refNum_); + IMAGE_LOGE("release plugin: refNum: %{public}u.", refNum_); } implClassMgr_.DeleteClass(plugin_); @@ -72,14 +74,14 @@ uint32_t Plugin::Register(istream &metadata, string &&libraryPath, weak_ptr guard(dynDataLock_); if (state_ != PluginState::PLUGIN_STATE_UNREGISTER) { guard.unlock(); - HiLog::Info(LABEL, "repeat registration."); + IMAGE_LOGI("repeat registration."); return ERR_INTERNAL; } auto ret = RegisterMetadata(metadata, plugin); if (ret != SUCCESS) { guard.unlock(); - HiLog::Error(LABEL, "failed to register metadata, ERRNO: %{public}u.", ret); + IMAGE_LOGE("failed to register metadata, ERRNO: %{public}u.", ret); return ret; } @@ -102,7 +104,7 @@ uint32_t Plugin::Ref() if (state_ == PluginState::PLUGIN_STATE_REGISTERED) { if (ResolveLibrary() != SUCCESS) { guard.unlock(); - HiLog::Error(LABEL, "failed to resolve library."); + IMAGE_LOGE("failed to resolve library."); return ERR_GENERAL; } state_ = PluginState::PLUGIN_STATE_RESOLVED; @@ -112,7 +114,7 @@ uint32_t Plugin::Ref() // maybe asynchronous, or for reduce the locking time state_ = PluginState::PLUGIN_STATE_STARTING; if (!CfiStartFunc_(startFunc_)) { - HiLog::Error(LABEL, "failed to start plugin."); + IMAGE_LOGE("failed to start plugin."); FreeLibrary(); state_ = PluginState::PLUGIN_STATE_REGISTERED; return ERR_GENERAL; @@ -121,12 +123,12 @@ uint32_t Plugin::Ref() } if (state_ != PluginState::PLUGIN_STATE_ACTIVE) { - HiLog::Error(LABEL, "plugin ref: state error, state: %{public}d.", state_); + IMAGE_LOGE("plugin ref: state error, state: %{public}d.", state_); return ERR_GENERAL; } ++refNum_; - HiLog::Debug(LABEL, "plugin refNum: %{public}d.", refNum_); + IMAGE_LOGD("plugin refNum: %{public}d.", refNum_); return SUCCESS; } @@ -138,12 +140,12 @@ void Plugin::DeRef() // the process context can guarantee that this will not happen. // the judgment statement here is for protection and positioning purposes only. guard.unlock(); - HiLog::Error(LABEL, "DeRef while RefNum is zero."); + IMAGE_LOGE("DeRef while RefNum is zero."); return; } --refNum_; - HiLog::Debug(LABEL, "plugin refNum: %{public}d.", refNum_); + IMAGE_LOGD("plugin refNum: %{public}d.", refNum_); } void Plugin::Block() @@ -167,7 +169,7 @@ PluginCreateFunc Plugin::GetCreateFunc() std::unique_lock guard(dynDataLock_); if ((state_ != PluginState::PLUGIN_STATE_ACTIVE) || (refNum_ == 0)) { // In this case, we can't guarantee that the pointer is lasting valid. - HiLog::Error(LABEL, "failed to get create func, State: %{public}d, RefNum: %{public}u.", state_, refNum_); + IMAGE_LOGE("failed to get create func, State: %{public}d, RefNum: %{public}u.", state_, refNum_); return nullptr; } @@ -194,7 +196,7 @@ uint32_t Plugin::ResolveLibrary() #ifdef _WIN32 hDll = platformAdp_.AdpLoadLibrary(libraryPath_); if (hDll == NULL) { - HiLog::Error(LABEL, "failed to load library."); + IMAGE_LOGE("failed to load library."); return ERR_GENERAL; } @@ -202,7 +204,7 @@ uint32_t Plugin::ResolveLibrary() stopFunc_ = (PluginStopFunc)platformAdp_.AdpGetSymAddress(hDll, pluginStopSymbol); createFunc_ = (PluginCreateFunc)platformAdp_.AdpGetSymAddress(hDll, pluginCreateSymbol); if (startFunc_ == NULL || stopFunc_ == NULL || createFunc_ == NULL) { - HiLog::Error(LABEL, "failed to get export symbol for the plugin."); + IMAGE_LOGE("failed to get export symbol for the plugin."); FreeLibrary(); return ERR_GENERAL; } @@ -216,7 +218,7 @@ uint32_t Plugin::ResolveLibrary() #else handle_ = platformAdp_.LoadLibrary(libraryPath_); if (handle_ == nullptr) { - HiLog::Error(LABEL, "failed to load library."); + IMAGE_LOGE("failed to load library."); return ERR_GENERAL; } @@ -224,7 +226,7 @@ uint32_t Plugin::ResolveLibrary() stopFunc_ = (PluginStopFunc)platformAdp_.GetSymAddress(handle_, pluginStopSymbol); createFunc_ = (PluginCreateFunc)platformAdp_.GetSymAddress(handle_, pluginCreateSymbol); if (startFunc_ == nullptr || stopFunc_ == nullptr || createFunc_ == nullptr) { - HiLog::Error(LABEL, "failed to get export symbol for the plugin."); + IMAGE_LOGE("failed to get export symbol for the plugin."); FreeLibrary(); return ERR_GENERAL; } @@ -277,44 +279,43 @@ uint32_t Plugin::RegisterMetadata(istream &metadata, weak_ptr &plugin) json root; metadata >> root; if (JsonHelper::GetStringValue(root, "packageName", packageName_) != SUCCESS) { - HiLog::Error(LABEL, "read packageName failed."); + IMAGE_LOGE("read packageName failed."); return ERR_INVALID_PARAMETER; } string targetVersion; if (JsonHelper::GetStringValue(root, "targetVersion", targetVersion) != SUCCESS) { - HiLog::Error(LABEL, "read targetVersion failed."); + IMAGE_LOGE("read targetVersion failed."); return ERR_INVALID_PARAMETER; } uint32_t ret = CheckTargetVersion(targetVersion); if (ret != SUCCESS) { // target version is not compatible - HiLog::Error(LABEL, "check targetVersion failed, Version: %{public}s, ERRNO: %{public}u.", - targetVersion.c_str(), ret); + IMAGE_LOGE("check targetVersion failed, Version: %{public}s, ERRNO: %{public}u.", targetVersion.c_str(), ret); return ret; } if (JsonHelper::GetStringValue(root, "version", version_) != SUCCESS) { - HiLog::Error(LABEL, "read version failed."); + IMAGE_LOGE("read version failed."); return ERR_INVALID_PARAMETER; } VersionNum versionNum; ret = AnalyzeVersion(version_, versionNum); if (ret != SUCCESS) { - HiLog::Error(LABEL, "check version failed, Version: %{public}s, ERRNO: %{public}u.", version_.c_str(), ret); + IMAGE_LOGE("check version failed, Version: %{public}s, ERRNO: %{public}u.", version_.c_str(), ret); return ret; } size_t classNum; if (JsonHelper::GetArraySize(root, "classes", classNum) != SUCCESS) { - HiLog::Error(LABEL, "get array size of classes failed."); + IMAGE_LOGE("get array size of classes failed."); return ERR_INVALID_PARAMETER; } - HiLog::Debug(LABEL, "parse class num: %{public}zu.", classNum); + IMAGE_LOGD("parse class num: %{public}zu.", classNum); for (size_t i = 0; i < classNum; i++) { const json &classInfo = root["classes"][i]; if (implClassMgr_.AddClass(plugin, classInfo) != SUCCESS) { - HiLog::Error(LABEL, "failed to add class, index: %{public}zu.", i); + IMAGE_LOGE("failed to add class, index: %{public}zu.", i); continue; } } @@ -327,7 +328,7 @@ uint32_t Plugin::CheckTargetVersion(const string &targetVersion) VersionNum versionNum; auto ret = AnalyzeVersion(targetVersion, versionNum); if (ret != SUCCESS) { - HiLog::Error(LABEL, "failed to analyze version, ERRNO: %{public}u.", ret); + IMAGE_LOGE("failed to analyze version, ERRNO: %{public}u.", ret); return ret; } @@ -344,20 +345,20 @@ uint32_t Plugin::AnalyzeVersion(const string &versionInfo, VersionNum &versionNu while (getline(versionInput, tmp, '.')) { auto ret = ExecuteVersionAnalysis(tmp, step, versionArray); if (ret != SUCCESS) { - HiLog::Error(LABEL, "failed to execute version analysis, ERRNO: %{public}u.", ret); + IMAGE_LOGE("failed to execute version analysis, ERRNO: %{public}u.", ret); return ret; } } if (step == VersionParseStep::STEP_NANO) { // we treat nano version as optional, and default 0. - HiLog::Debug(LABEL, "default nano version 0."); + IMAGE_LOGD("default nano version 0."); versionArray[VERSION_NANO_INDEX] = 0; step = VersionParseStep::STEP_FINISHED; } if (step != VersionParseStep::STEP_FINISHED) { - HiLog::Error(LABEL, "analysis version failed, step = %{public}d.", step); + IMAGE_LOGE("analysis version failed, step = %{public}d.", step); return ERR_INVALID_PARAMETER; } @@ -366,8 +367,8 @@ uint32_t Plugin::AnalyzeVersion(const string &versionInfo, VersionNum &versionNu versionNum.micro = versionArray[VERSION_MICRO_INDEX]; versionNum.nano = versionArray[VERSION_NANO_INDEX]; - HiLog::Debug(LABEL, "analysis result: %{public}u.%{public}u.%{public}u.%{public}u.", versionNum.major, - versionNum.minor, versionNum.micro, versionNum.nano); + IMAGE_LOGD("analysis result: %{public}u.%{public}u.%{public}u.%{public}u.", versionNum.major, + versionNum.minor, versionNum.micro, versionNum.nano); return SUCCESS; } @@ -379,8 +380,7 @@ uint32_t Plugin::ExecuteVersionAnalysis(const string &input, VersionParseStep &s case VersionParseStep::STEP_MAJOR: { auto ret = GetUint16ValueFromDecimal(input, versionNum[VERSION_MAJOR_INDEX]); if (ret != SUCCESS) { - HiLog::Error(LABEL, "read major version failed, input: %{public}s, ERRNO: %{public}u.", input.c_str(), - ret); + IMAGE_LOGE("read major version failed, input: %{public}s, ERRNO: %{public}u.", input.c_str(), ret); return ret; } step = VersionParseStep::STEP_MINOR; @@ -389,8 +389,7 @@ uint32_t Plugin::ExecuteVersionAnalysis(const string &input, VersionParseStep &s case VersionParseStep::STEP_MINOR: { auto ret = GetUint16ValueFromDecimal(input, versionNum[VERSION_MINOR_INDEX]); if (ret != SUCCESS) { - HiLog::Error(LABEL, "read minor version failed, input: %{public}s, ERRNO: %{public}u.", input.c_str(), - ret); + IMAGE_LOGE("read minor version failed, input: %{public}s, ERRNO: %{public}u.", input.c_str(), ret); return ret; } step = VersionParseStep::STEP_MICRO; @@ -399,8 +398,7 @@ uint32_t Plugin::ExecuteVersionAnalysis(const string &input, VersionParseStep &s case VersionParseStep::STEP_MICRO: { auto ret = GetUint16ValueFromDecimal(input, versionNum[VERSION_MICRO_INDEX]); if (ret != SUCCESS) { - HiLog::Error(LABEL, "read micro version failed, input: %{public}s, ERRNO: %{public}u.", input.c_str(), - ret); + IMAGE_LOGE("read micro version failed, input: %{public}s, ERRNO: %{public}u.", input.c_str(), ret); return ret; } step = VersionParseStep::STEP_NANO; @@ -409,15 +407,14 @@ uint32_t Plugin::ExecuteVersionAnalysis(const string &input, VersionParseStep &s case VersionParseStep::STEP_NANO: { auto ret = GetUint16ValueFromDecimal(input, versionNum[VERSION_NANO_INDEX]); if (ret != SUCCESS) { - HiLog::Error(LABEL, "read nano version failed, input: %{public}s, ERRNO: %{public}u.", input.c_str(), - ret); + IMAGE_LOGE("read nano version failed, input: %{public}s, ERRNO: %{public}u.", input.c_str(), ret); return ret; } step = VersionParseStep::STEP_FINISHED; break; } default: { - HiLog::Error(LABEL, "read redundant version data, input: %{public}s.", input.c_str()); + IMAGE_LOGE("read redundant version data, input: %{public}s.", input.c_str()); return ERR_INVALID_PARAMETER; } } @@ -428,21 +425,21 @@ uint32_t Plugin::ExecuteVersionAnalysis(const string &input, VersionParseStep &s uint32_t Plugin::GetUint16ValueFromDecimal(const string &source, uint16_t &result) { if (source.empty() || source.size() > UINT16_MAX_DECIMAL_DIGITS) { - HiLog::Error(LABEL, "invalid string of uint16: %{public}s.", source.c_str()); + IMAGE_LOGE("invalid string of uint16: %{public}s.", source.c_str()); return ERR_INVALID_PARAMETER; } // determine if all characters are numbers. for (const auto &character : source) { if (character < '0' || character > '9') { - HiLog::Error(LABEL, "character out of the range of digital: %{public}s.", source.c_str()); + IMAGE_LOGE("character out of the range of digital: %{public}s.", source.c_str()); return ERR_INVALID_PARAMETER; } } unsigned long tmp = stoul(source); if (tmp > UINT16_MAX_VALUE) { - HiLog::Error(LABEL, "result out of the range of uint16: %{public}s.", source.c_str()); + IMAGE_LOGE("result out of the range of uint16: %{public}s.", source.c_str()); return ERR_INVALID_PARAMETER; } diff --git a/plugins/manager/src/framework/plugin_export.cpp b/plugins/manager/src/framework/plugin_export.cpp index 11bf76a60..be4e7dabf 100644 --- a/plugins/manager/src/framework/plugin_export.cpp +++ b/plugins/manager/src/framework/plugin_export.cpp @@ -18,14 +18,11 @@ #include "bmp_format_agent.h" #include "gif_decoder.h" #include "gif_format_agent.h" -#include "hilog/log.h" -#include "hilog/log_c.h" -#include "hilog/log_cpp.h" +#include "image_log.h" #include "iosfwd" #include "jpeg_decoder.h" #include "jpeg_encoder.h" #include "jpeg_format_agent.h" -#include "log_tags.h" #include "map" #include "plugin_class_base.h" #include "plugin_utils.h" @@ -42,6 +39,12 @@ #include "webp_encoder.h" #include "webp_format_agent.h" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "BmpFormatAgent" + namespace { const std::string PACKAGE_NAME = ("LibImagePluginsExport"); } @@ -68,32 +71,26 @@ PLUGIN_EXPORT_REGISTER_CLASS(OHOS::ImagePlugin::SvgFormatAgent) PLUGIN_EXPORT_REGISTER_CLASS_END using std::string; -using namespace OHOS::HiviewDFX; - -static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "LibImagePluginsExport" }; - -#define PLUGIN_LOG_D(...) HiLog::Debug(LABEL, __VA_ARGS__) -#define PLUGIN_LOG_E(...) HiLog::Error(LABEL, __VA_ARGS__) // define the external interface of this plugin. PLUGIN_EXPORT_DEFAULT_EXTERNAL_START() PLUGIN_EXPORT_DEFAULT_EXTERNAL_STOP() OHOS::MultimediaPlugin::PluginClassBase *PluginExternalCreate(const string &className) { - HiLog::Debug(LABEL, "LibImagePluginsExport: create object for package: %{public}s, class: %{public}s.", - PACKAGE_NAME.c_str(), className.c_str()); + IMAGE_LOGD("LibImagePluginsExport: create object for package: %{public}s, class: %{public}s.", + PACKAGE_NAME.c_str(), className.c_str()); auto iter = implClassMap.find(className); if (iter == implClassMap.end()) { - HiLog::Error(LABEL, "LibImagePluginsExport: failed to find class: %{public}s, in package: %{public}s.", - className.c_str(), PACKAGE_NAME.c_str()); + IMAGE_LOGE("LibImagePluginsExport: failed to find class: %{public}s, in package: %{public}s.", + className.c_str(), PACKAGE_NAME.c_str()); return nullptr; } auto creator = iter->second; if (creator == nullptr) { - HiLog::Error(LABEL, "LibImagePluginsExport: null creator for class: %{public}s, in package: %{public}s.", - className.c_str(), PACKAGE_NAME.c_str()); + IMAGE_LOGE("LibImagePluginsExport: null creator for class: %{public}s, in package: %{public}s.", + className.c_str(), PACKAGE_NAME.c_str()); return nullptr; } diff --git a/plugins/manager/src/framework/plugin_fw.cpp b/plugins/manager/src/framework/plugin_fw.cpp index b440a6f0f..302bae3a2 100644 --- a/plugins/manager/src/framework/plugin_fw.cpp +++ b/plugins/manager/src/framework/plugin_fw.cpp @@ -14,13 +14,18 @@ */ #include "plugin_fw.h" -#include "hilog/log.h" +#include "image_log.h" #include "singleton.h" -#include "log_tags.h" #include "impl_class_mgr.h" #include "plugin_info_lock.h" #include "plugin_mgr.h" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "PluginFw" + namespace OHOS { namespace MultimediaPlugin { using std::map; @@ -29,13 +34,10 @@ using std::vector; using OHOS::Utils::RWLock; using OHOS::Utils::UniqueReadGuard; using OHOS::Utils::UniqueWriteGuard; -using namespace OHOS::HiviewDFX; - -static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "PluginFw" }; uint32_t PluginFw::Register(const vector &canonicalPaths) { - HiLog::Debug(LABEL, "plugin register."); + IMAGE_LOGD("plugin register."); // Use the read-write lock to mutually exclusive write plugin information and read plugin information operations, // where Register() plays the write role. UniqueWriteGuard lk(DelayedRefSingleton::GetInstance().rwLock_); diff --git a/plugins/manager/src/framework/plugin_mgr.cpp b/plugins/manager/src/framework/plugin_mgr.cpp index 42d07fcd8..59ac7dae4 100644 --- a/plugins/manager/src/framework/plugin_mgr.cpp +++ b/plugins/manager/src/framework/plugin_mgr.cpp @@ -17,14 +17,19 @@ #include #include #include "directory_ex.h" -#include "hilog/log.h" +#include "image_log.h" #include "json.hpp" #include "json_helper.h" -#include "log_tags.h" #include "platform_adp.h" #include "plugin.h" #include "plugin_metadata.h" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "PluginMgr" + namespace OHOS { namespace MultimediaPlugin { using nlohmann::json; @@ -34,9 +39,6 @@ using std::size_t; using std::string; using std::vector; using std::weak_ptr; -using namespace OHOS::HiviewDFX; - -static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "PluginMgr" }; PlatformAdp &PluginMgr::platformAdp_ = DelayedRefSingleton::GetInstance(); uint32_t PluginMgr::Register(const vector &canonicalPaths) @@ -86,7 +88,7 @@ uint32_t PluginMgr::TraverseFiles(const string &canonicalPath) vector strFiles; GetDirFiles(canonicalPath, strFiles); if (strFiles.empty()) { - HiLog::Error(LABEL, "failed to get dir files."); + IMAGE_LOGE("failed to get dir files."); return ERR_GENERAL; } @@ -100,7 +102,7 @@ uint32_t PluginMgr::TraverseFiles(const string &canonicalPath) } if (noTarget) { - HiLog::Warn(LABEL, "there is no plugin meta file in path."); + IMAGE_LOGW("there is no plugin meta file in path."); return ERR_NO_TARGET; } @@ -127,7 +129,7 @@ bool PluginMgr::CheckPluginMetaFile(const string &candidateFile, string &library ifstream metadata(candidateFile); if (!metadata) { - HiLog::Error(LABEL, "failed to open metadata file."); + IMAGE_LOGE("failed to open metadata file."); return false; } @@ -135,7 +137,7 @@ bool PluginMgr::CheckPluginMetaFile(const string &candidateFile, string &library metadata >> root; metadata.close(); if (JsonHelper::GetStringValue(root, "libraryPath", libraryPath) != SUCCESS) { - HiLog::Error(LABEL, "read libraryPath failed."); + IMAGE_LOGE("read libraryPath failed."); return false; } @@ -145,7 +147,7 @@ bool PluginMgr::CheckPluginMetaFile(const string &candidateFile, string &library fileExt = ExtractFileExt(libraryPath); if (fileExt != libraryFileSuffix) { - HiLog::Error(LABEL, "invalid library suffix."); + IMAGE_LOGE("invalid library suffix."); return false; } @@ -160,7 +162,7 @@ bool PluginMgr::CheckPluginMetaFile(const string &candidateFile, string &library string realPath; if (!PathToRealPath(libraryPath, realPath)) { - HiLog::Error(LABEL, "library path to real path error."); + IMAGE_LOGE("library path to real path error."); return false; } @@ -173,38 +175,38 @@ uint32_t PluginMgr::RegisterPlugin(const string &metadataPath, string &&libraryP auto iter = plugins_.find(&libraryPath); if (iter != plugins_.end()) { // already registered before, just skip it. - HiLog::Debug(LABEL, "the libraryPath has already been registered before."); + IMAGE_LOGD("the libraryPath has already been registered before."); return ERR_GENERAL; } ifstream metadata(metadataPath); if (!metadata) { - HiLog::Error(LABEL, "failed to open metadata file."); + IMAGE_LOGE("failed to open metadata file."); return ERR_GENERAL; } auto plugin = std::make_shared(); if (plugin == nullptr) { - HiLog::Error(LABEL, "failed to create Plugin."); + IMAGE_LOGE("failed to create Plugin."); return ERR_INTERNAL; } weak_ptr weakPtr = plugin; auto regRet = plugin->Register(metadata, std::move(libraryPath), weakPtr); if (regRet != SUCCESS) { - HiLog::Error(LABEL, "failed to register plugin,ERRNO: %{public}u.", regRet); + IMAGE_LOGE("failed to register plugin,ERRNO: %{public}u.", regRet); return regRet; } const std::string &key = plugin->GetLibraryPath(); if (key.empty()) { - HiLog::Error(LABEL, "get empty libraryPath."); + IMAGE_LOGE("get empty libraryPath."); return ERR_INTERNAL; } auto insertRet = plugins_.insert(PluginMap::value_type(&key, std::move(plugin))); if (!insertRet.second) { - HiLog::Error(LABEL, "failed to insert Plugin"); + IMAGE_LOGE("failed to insert Plugin"); return ERR_INTERNAL; } @@ -216,20 +218,20 @@ uint32_t PluginMgr::RegisterPlugin(const string &metadataJson) string libraryPath; json root = nlohmann::json::parse(metadataJson); if (JsonHelper::GetStringValue(root, "libraryPath", libraryPath) != SUCCESS) { - HiLog::Error(LABEL, "read libraryPath failed."); + IMAGE_LOGE("read libraryPath failed."); return false; } auto iter = plugins_.find(&libraryPath); if (iter != plugins_.end()) { // already registered before, just skip it. - HiLog::Debug(LABEL, "the libraryPath has already been registered before."); + IMAGE_LOGD("the libraryPath has already been registered before."); return ERR_GENERAL; } istringstream metadata(metadataJson); if (!metadata) { - HiLog::Error(LABEL, "failed to read metadata."); + IMAGE_LOGE("failed to read metadata."); return ERR_GENERAL; } @@ -237,19 +239,19 @@ uint32_t PluginMgr::RegisterPlugin(const string &metadataJson) weak_ptr weakPtr = crossPlugin; auto regRet = crossPlugin->Register(metadata, std::move(libraryPath), weakPtr); if (regRet != SUCCESS) { - HiLog::Error(LABEL, "failed to register plugin,ERRNO: %{public}u.", regRet); + IMAGE_LOGE("failed to register plugin,ERRNO: %{public}u.", regRet); return regRet; } const std::string &key = crossPlugin->GetLibraryPath(); if (key.empty()) { - HiLog::Error(LABEL, "get empty libraryPath."); + IMAGE_LOGE("get empty libraryPath."); return ERR_INTERNAL; } auto insertRet = plugins_.insert(PluginMap::value_type(&key, std::move(crossPlugin))); if (!insertRet.second) { - HiLog::Error(LABEL, "failed to insert Plugin"); + IMAGE_LOGE("failed to insert Plugin"); return ERR_INTERNAL; } diff --git a/plugins/manager/src/plugin_server.cpp b/plugins/manager/src/plugin_server.cpp index 0ffaa773d..6515f3766 100644 --- a/plugins/manager/src/plugin_server.cpp +++ b/plugins/manager/src/plugin_server.cpp @@ -15,9 +15,7 @@ #include "plugin_server.h" #include "gst_plugin_fw.h" -#include "hilog/log_c.h" -#include "hilog/log_cpp.h" -#include "log_tags.h" +#include "image_log.h" #include "map" #include "new" #include "platform_adp.h" @@ -29,14 +27,17 @@ #include "type_traits" #include "vector" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "PluginServer" + namespace OHOS { namespace MultimediaPlugin { using std::map; using std::string; using std::vector; -using namespace OHOS::HiviewDFX; - -static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "PluginServer" }; uint32_t PluginServer::Register(vector &&pluginPaths) { @@ -47,7 +48,7 @@ uint32_t PluginServer::Register(vector &&pluginPaths) vector gstCanonicalPaths; for (string &path : pluginPaths) { if (platformAdp_.CheckAndNormalizePath(path) != SUCCESS) { - HiLog::Error(LABEL, "failed to check and normalize path: %{public}s.", path.c_str()); + IMAGE_LOGE("failed to check and normalize path: %{public}s.", path.c_str()); continue; } @@ -55,31 +56,31 @@ uint32_t PluginServer::Register(vector &&pluginPaths) switch (fwType) { case PluginFWType::PLUGIN_FW_GENERAL: { // directory path parameters, usually not too much, will not cause massive logs. - HiLog::Debug(LABEL, "PluginFW path: %{public}s.", path.c_str()); + IMAGE_LOGD("PluginFW path: %{public}s.", path.c_str()); canonicalPaths.push_back(std::move(path)); break; } case PluginFWType::PLUGIN_FW_GSTREAMER: { // directory path parameters, usually not too much, will not cause massive logs. - HiLog::Debug(LABEL, "GstPluginFW path: %{public}s.", path.c_str()); + IMAGE_LOGD("GstPluginFW path: %{public}s.", path.c_str()); gstCanonicalPaths.push_back(std::move(path)); break; } default: { - HiLog::Error(LABEL, "unknown FWType: %{public}d.", fwType); + IMAGE_LOGE("unknown FWType: %{public}d.", fwType); } } } if (canonicalPaths.empty() && gstCanonicalPaths.empty()) { - HiLog::Error(LABEL, "failed to find any valid plugin path."); + IMAGE_LOGE("failed to find any valid plugin path."); return ERR_INVALID_PARAMETER; } if (!gstCanonicalPaths.empty()) { uint32_t result = gstPluginFw_.Register(gstCanonicalPaths); if (result != SUCCESS) { - HiLog::Error(LABEL, "failed to register gst plugin path, ERRNO: %{public}u.", result); + IMAGE_LOGE("failed to register gst plugin path, ERRNO: %{public}u.", result); return result; } } @@ -87,7 +88,7 @@ uint32_t PluginServer::Register(vector &&pluginPaths) if (!canonicalPaths.empty()) { uint32_t result = pluginFw_.Register(canonicalPaths); if (result != SUCCESS) { - HiLog::Error(LABEL, "failed to register plugin path, ERRNO: %{public}u.", result); + IMAGE_LOGE("failed to register plugin path, ERRNO: %{public}u.", result); return result; } } @@ -105,11 +106,11 @@ PluginServer::~PluginServer() {} PluginClassBase *PluginServer::CreateObject(uint16_t interfaceID, const string &className, uint32_t &errorCode) { - HiLog::Debug(LABEL, "create object iid: %{public}u, className: %{public}s.", interfaceID, className.c_str()); + IMAGE_LOGD("create object iid: %{public}u, className: %{public}s.", interfaceID, className.c_str()); PluginClassBase *obj = nullptr; // if it is a pipeline service, use the gstreamer framework first. if (GetInterfaceIDType(interfaceID) == IID_TYPE_PIPELINE) { - HiLog::Debug(LABEL, "it is a pipeline interface type."); + IMAGE_LOGD("it is a pipeline interface type."); obj = gstPluginFw_.CreateObject(interfaceID, className, errorCode); if (obj != nullptr) { return obj; @@ -124,11 +125,11 @@ PluginClassBase *PluginServer::CreateObject(uint16_t interfaceID, uint16_t servi const map &capabilities, const PriorityScheme &priorityScheme, uint32_t &errorCode) { - HiLog::Debug(LABEL, "create object iid: %{public}hu, service Type: %{public}u.", interfaceID, serviceType); + IMAGE_LOGD("create object iid: %{public}hu, service Type: %{public}u.", interfaceID, serviceType); PluginClassBase *obj = nullptr; // if it is a pipeline service, use the gstreamer framework first. if (GetInterfaceIDType(interfaceID) == IID_TYPE_PIPELINE) { - HiLog::Debug(LABEL, "it is a pipeline interface type."); + IMAGE_LOGD("it is a pipeline interface type."); obj = gstPluginFw_.CreateObject(interfaceID, serviceType, capabilities, priorityScheme, errorCode); if (obj != nullptr) { return obj; @@ -158,8 +159,8 @@ uint32_t PluginServer::PluginServerGetClassInfo(uint16_t interfaceID, uint16_t s // if both gstreamer and self-developing plugin can not get class information, then considered fail. if ((resultGst != SUCCESS) && (resultFw != SUCCESS)) { - HiLog::Error(LABEL, "failed to get class by serviceType, resultGst: %{public}u, resultFw: %{public}u.", - resultGst, resultFw); + IMAGE_LOGE("failed to get class by serviceType, resultGst: %{public}u, resultFw: %{public}u.", + resultGst, resultFw); return resultFw; } diff --git a/plugins/manager/src/pluginbase/plugin_class_base.cpp b/plugins/manager/src/pluginbase/plugin_class_base.cpp index b2899c4e0..146ad10d5 100644 --- a/plugins/manager/src/pluginbase/plugin_class_base.cpp +++ b/plugins/manager/src/pluginbase/plugin_class_base.cpp @@ -16,15 +16,16 @@ #include "plugin_class_base.h" #include #include "abs_impl_class_key.h" -#include "hilog/log_c.h" -#include "hilog/log_cpp.h" -#include "log_tags.h" +#include "image_log.h" + +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "PluginClassBase" namespace OHOS { namespace MultimediaPlugin { -using namespace OHOS::HiviewDFX; - -static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "PluginClassBase" }; PluginClassBase::~PluginClassBase() { @@ -32,7 +33,7 @@ PluginClassBase::~PluginClassBase() // the process context can guarantee that this will not happen. // the judgment statement here is for protection and positioning purposes only. if (implClassKey_ == nullptr) { - HiLog::Error(LABEL, "release class base, null implClassKey."); + IMAGE_LOGE("release class base, null implClassKey."); return; } diff --git a/plugins/manager/src/thirdpartyadp/gstreamer/gst_plugin_fw.cpp b/plugins/manager/src/thirdpartyadp/gstreamer/gst_plugin_fw.cpp index 3b7ff07a7..ff875062f 100644 --- a/plugins/manager/src/thirdpartyadp/gstreamer/gst_plugin_fw.cpp +++ b/plugins/manager/src/thirdpartyadp/gstreamer/gst_plugin_fw.cpp @@ -15,27 +15,28 @@ #include "gst_plugin_fw.h" #include "__mutex_base" -#include "hilog/log_c.h" -#include "hilog/log_cpp.h" -#include "log_tags.h" +#include "image_log.h" #include "map" #include "plugin_errors.h" #include "vector" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "GstPluginFw" + namespace OHOS { namespace MultimediaPlugin { using std::map; using std::mutex; using std::string; using std::vector; -using namespace OHOS::HiviewDFX; - -static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "GstPluginFw" }; uint32_t GstPluginFw::Register(const vector &canonicalPaths) { (void) canonicalPaths; - HiLog::Debug(LABEL, "register called."); + IMAGE_LOGD("register called."); return SUCCESS; } @@ -43,7 +44,7 @@ PluginClassBase *GstPluginFw::CreateObject(uint16_t interfaceID, const string &c { (void) interfaceID; (void) className; - HiLog::Debug(LABEL, "CreateObject by name called."); + IMAGE_LOGD("CreateObject by name called."); errorCode = ERR_MATCHING_PLUGIN; return nullptr; @@ -57,7 +58,7 @@ PluginClassBase *GstPluginFw::CreateObject(uint16_t interfaceID, uint16_t servic (void) serviceType; (void) capabilities; (void) priorityScheme; - HiLog::Debug(LABEL, "CreateObject by serviceType called."); + IMAGE_LOGD("CreateObject by serviceType called."); errorCode = ERR_MATCHING_PLUGIN; return nullptr; @@ -71,7 +72,7 @@ uint32_t GstPluginFw::GstPluginFwGetClassInfo(uint16_t interfaceID, uint16_t ser (void) serviceType; (void) capabilities; (void) classesInfo; - HiLog::Debug(LABEL, "GetClassInfo by serviceType called."); + IMAGE_LOGD("GetClassInfo by serviceType called."); return ERR_MATCHING_PLUGIN; } diff --git a/plugins/manager/test/unittest/common/plugin_example/plugin_example1/cloud_label_detector.cpp b/plugins/manager/test/unittest/common/plugin_example/plugin_example1/cloud_label_detector.cpp index 1c233ca01..228508d64 100644 --- a/plugins/manager/test/unittest/common/plugin_example/plugin_example1/cloud_label_detector.cpp +++ b/plugins/manager/test/unittest/common/plugin_example/plugin_example1/cloud_label_detector.cpp @@ -14,36 +14,38 @@ */ #include "cloud_label_detector.h" -#include "hilog/log.h" -#include "log_tags.h" +#include "image_log.h" + +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "CloudLabelDetector" namespace OHOS { namespace PluginExample { using std::string; -using namespace OHOS::HiviewDFX; - -static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "CloudLabelDetector" }; const string CloudLabelDetector::RESULT_STR = "CloudLabelDetector"; CloudLabelDetector::CloudLabelDetector() { - HiLog::Debug(LABEL, "call CloudLabelDetector()."); + IMAGE_LOGD("call CloudLabelDetector()."); } CloudLabelDetector::~CloudLabelDetector() { - HiLog::Debug(LABEL, "call ~CloudLabelDetector()."); + IMAGE_LOGD("call ~CloudLabelDetector()."); } bool CloudLabelDetector::Prepare() { - HiLog::Debug(LABEL, "call Prepare()."); + IMAGE_LOGD("call Prepare()."); return true; } string CloudLabelDetector::Process() { - HiLog::Debug(LABEL, "call Process()."); + IMAGE_LOGD("call Process()."); return RESULT_STR; } } // namespace PluginExample diff --git a/plugins/manager/test/unittest/common/plugin_example/plugin_example1/label_detector.cpp b/plugins/manager/test/unittest/common/plugin_example/plugin_example1/label_detector.cpp index 7d6467427..0fd86b58d 100644 --- a/plugins/manager/test/unittest/common/plugin_example/plugin_example1/label_detector.cpp +++ b/plugins/manager/test/unittest/common/plugin_example/plugin_example1/label_detector.cpp @@ -14,36 +14,38 @@ */ #include "label_detector.h" -#include "hilog/log.h" -#include "log_tags.h" +#include "image_log.h" + +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "LabelDetector" namespace OHOS { namespace PluginExample { using std::string; -using namespace OHOS::HiviewDFX; - -static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "LabelDetector" }; const string LabelDetector::RESULT_STR = "LabelDetector"; LabelDetector::LabelDetector() { - HiLog::Debug(LABEL, "call LabelDetector()."); + IMAGE_LOGD("call LabelDetector()."); } LabelDetector::~LabelDetector() { - HiLog::Debug(LABEL, "call ~LabelDetector()."); + IMAGE_LOGD("call ~LabelDetector()."); } bool LabelDetector::Prepare() { - HiLog::Debug(LABEL, "call Prepare()."); + IMAGE_LOGD("call Prepare()."); return true; } string LabelDetector::Process() { - HiLog::Debug(LABEL, "call Process()."); + IMAGE_LOGD("call Process()."); return RESULT_STR; } } // namespace PluginExample diff --git a/plugins/manager/test/unittest/common/plugin_example/plugin_example1/plugin_export.cpp b/plugins/manager/test/unittest/common/plugin_example/plugin_example1/plugin_export.cpp index 854ed7235..73a6ba324 100644 --- a/plugins/manager/test/unittest/common/plugin_example/plugin_example1/plugin_export.cpp +++ b/plugins/manager/test/unittest/common/plugin_example/plugin_example1/plugin_export.cpp @@ -15,22 +15,25 @@ #include "plugin_export.h" #include -#include "hilog/log.h" -#include "log_tags.h" +#include "image_log.h" #include "plugin_class_base.h" #include "plugin_utils.h" #include "cloud_label_detector.h" #include "label_detector.h" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "plugin_example1" + // this file shows how to write plugin_export.cpp file directly. // but this file can also be simplified using the code elements provided by plugin_utils.h, // see plugin_example2 and plugin_example3. using std::map; using std::string; -using namespace OHOS::HiviewDFX; static const string PACKAGE_NAME = "plugin_example1"; -static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "plugin_example1" }; using ImplClassMap = map; static ImplClassMap implClassMap = { @@ -40,7 +43,7 @@ static ImplClassMap implClassMap = { bool PluginExternalStart() { - HiLog::Debug(LABEL, "call PluginExternalStart() in package: %{public}s.", PACKAGE_NAME.c_str()); + IMAGE_LOGD("call PluginExternalStart() in package: %{public}s.", PACKAGE_NAME.c_str()); // in this example we don't have to do anything, // but you may need to do some preparations below for your plugin... return true; @@ -48,7 +51,7 @@ bool PluginExternalStart() void PluginExternalStop() { - HiLog::Debug(LABEL, "call PluginExternalStop() in package: %{public}s.", PACKAGE_NAME.c_str()); + IMAGE_LOGD("call PluginExternalStop() in package: %{public}s.", PACKAGE_NAME.c_str()); // in this example we don't have to do anything, // but you may need to do some cleaning work below for your plugin... return; @@ -56,20 +59,20 @@ void PluginExternalStop() OHOS::MultimediaPlugin::PluginClassBase *PluginExternalCreate(const string &className) { - HiLog::Debug(LABEL, "PluginExternalCreate: create object for package: %{public}s, class: %{public}s.", - PACKAGE_NAME.c_str(), className.c_str()); + IMAGE_LOGD("PluginExternalCreate: create object for package: %{public}s, class: %{public}s.", + PACKAGE_NAME.c_str(), className.c_str()); auto iter = implClassMap.find(className); if (iter == implClassMap.end()) { - HiLog::Error(LABEL, "PluginExternalCreate: failed to find class: %{public}s, in package: %{public}s.", - className.c_str(), PACKAGE_NAME.c_str()); + IMAGE_LOGE("PluginExternalCreate: failed to find class: %{public}s, in package: %{public}s.", + className.c_str(), PACKAGE_NAME.c_str()); return nullptr; } auto creator = iter->second; if (creator == nullptr) { - HiLog::Error(LABEL, "PluginExternalCreate: null creator for class: %{public}s, in package: %{public}s.", - className.c_str(), PACKAGE_NAME.c_str()); + IMAGE_LOGE("PluginExternalCreate: null creator for class: %{public}s, in package: %{public}s.", + className.c_str(), PACKAGE_NAME.c_str()); return nullptr; } diff --git a/plugins/manager/test/unittest/common/plugin_example/plugin_example2/cloud_label_detector2.cpp b/plugins/manager/test/unittest/common/plugin_example/plugin_example2/cloud_label_detector2.cpp index fdd0266b1..9f8aa2c38 100644 --- a/plugins/manager/test/unittest/common/plugin_example/plugin_example2/cloud_label_detector2.cpp +++ b/plugins/manager/test/unittest/common/plugin_example/plugin_example2/cloud_label_detector2.cpp @@ -14,37 +14,39 @@ */ #include "cloud_label_detector2.h" -#include "hilog/log.h" -#include "log_tags.h" +#include "image_log.h" #include "plugin_utils.h" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "CloudLabelDetector2" + namespace OHOS { namespace PluginExample { using std::string; -using namespace OHOS::HiviewDFX; - -static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "CloudLabelDetector2" }; const string CloudLabelDetector2::RESULT_STR = "CloudLabelDetector2"; CloudLabelDetector2::CloudLabelDetector2() { - HiLog::Debug(LABEL, "call CloudLabelDetector2()."); + IMAGE_LOGD("call CloudLabelDetector2()."); } CloudLabelDetector2::~CloudLabelDetector2() { - HiLog::Debug(LABEL, "call ~CloudLabelDetector2()."); + IMAGE_LOGD("call ~CloudLabelDetector2()."); } bool CloudLabelDetector2::Prepare() { - HiLog::Debug(LABEL, "call Prepare()."); + IMAGE_LOGD("call Prepare()."); return true; } string CloudLabelDetector2::Process() { - HiLog::Debug(LABEL, "call Process()."); + IMAGE_LOGD("call Process()."); return RESULT_STR; } } // namespace PluginExample diff --git a/plugins/manager/test/unittest/common/plugin_example/plugin_example2/label_detector2.cpp b/plugins/manager/test/unittest/common/plugin_example/plugin_example2/label_detector2.cpp index da94d4d3a..22d282406 100644 --- a/plugins/manager/test/unittest/common/plugin_example/plugin_example2/label_detector2.cpp +++ b/plugins/manager/test/unittest/common/plugin_example/plugin_example2/label_detector2.cpp @@ -14,37 +14,39 @@ */ #include "label_detector2.h" -#include "hilog/log.h" -#include "log_tags.h" +#include "image_log.h" #include "plugin_utils.h" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "LabelDetector2" + namespace OHOS { namespace PluginExample { using std::string; -using namespace OHOS::HiviewDFX; - -static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "LabelDetector2" }; const string LabelDetector2::RESULT_STR = "LabelDetector2"; LabelDetector2::LabelDetector2() { - HiLog::Debug(LABEL, "call LabelDetector2()."); + IMAGE_LOGD("call LabelDetector2()."); } LabelDetector2::~LabelDetector2() { - HiLog::Debug(LABEL, "call ~LabelDetector2()."); + IMAGE_LOGD("call ~LabelDetector2()."); } bool LabelDetector2::Prepare() { - HiLog::Debug(LABEL, "call Prepare()."); + IMAGE_LOGD("call Prepare()."); return true; } string LabelDetector2::Process() { - HiLog::Debug(LABEL, "call Process()."); + IMAGE_LOGD("call Process()."); return RESULT_STR; } } // namespace PluginExample diff --git a/plugins/manager/test/unittest/common/plugin_example/plugin_example2/plugin_export.cpp b/plugins/manager/test/unittest/common/plugin_example/plugin_example2/plugin_export.cpp index 9bab70dcf..9d62ae7fc 100644 --- a/plugins/manager/test/unittest/common/plugin_example/plugin_example2/plugin_export.cpp +++ b/plugins/manager/test/unittest/common/plugin_example/plugin_example2/plugin_export.cpp @@ -14,12 +14,17 @@ */ #include "plugin_export.h" -#include "hilog/log.h" -#include "log_tags.h" +#include "image_log.h" #include "plugin_utils.h" #include "cloud_label_detector2.h" #include "label_detector2.h" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "plugin_example2" + // this file shows how to easily write the plugin_export.cpp file using the code elements provided by plugin_utils.h. // but sometimes you may need to write this file directly, see plugin_example1. namespace { @@ -33,32 +38,26 @@ PLUGIN_EXPORT_REGISTER_CLASS(OHOS::PluginExample::CloudLabelDetector2) PLUGIN_EXPORT_REGISTER_CLASS_END using std::string; -using namespace OHOS::HiviewDFX; - -static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "plugin_example2" }; - -#define PLUGIN_LOG_D(...) HiLog::Debug(LABEL, __VA_ARGS__) -#define PLUGIN_LOG_E(...) HiLog::Error(LABEL, __VA_ARGS__) // define the external interface of this plugin PLUGIN_EXPORT_DEFAULT_EXTERNAL_START() PLUGIN_EXPORT_DEFAULT_EXTERNAL_STOP() OHOS::MultimediaPlugin::PluginClassBase *PluginExternalCreate(const string &className) { - HiLog::Debug(LABEL, "PluginExternalCreate: create object for package: %{public}s, class: %{public}s.", - PACKAGE_NAME.c_str(), className.c_str()); + IMAGE_LOGD("PluginExternalCreate: create object for package: %{public}s, class: %{public}s.", + PACKAGE_NAME.c_str(), className.c_str()); auto iter = implClassMap.find(className); if (iter == implClassMap.end()) { - HiLog::Error(LABEL, "PluginExternalCreate: failed to find class: %{public}s, in package: %{public}s.", - className.c_str(), PACKAGE_NAME.c_str()); + IMAGE_LOGE("PluginExternalCreate: failed to find class: %{public}s, in package: %{public}s.", + className.c_str(), PACKAGE_NAME.c_str()); return nullptr; } auto creator = iter->second; if (creator == nullptr) { - HiLog::Error(LABEL, "PluginExternalCreate: null creator for class: %{public}s, in package: %{public}s.", - className.c_str(), PACKAGE_NAME.c_str()); + IMAGE_LOGE("PluginExternalCreate: null creator for class: %{public}s, in package: %{public}s.", + className.c_str(), PACKAGE_NAME.c_str()); return nullptr; } diff --git a/plugins/manager/test/unittest/common/plugin_example/plugin_example3/cloud_label_detector3.cpp b/plugins/manager/test/unittest/common/plugin_example/plugin_example3/cloud_label_detector3.cpp index 0ee17a313..f5f4165fc 100644 --- a/plugins/manager/test/unittest/common/plugin_example/plugin_example3/cloud_label_detector3.cpp +++ b/plugins/manager/test/unittest/common/plugin_example/plugin_example3/cloud_label_detector3.cpp @@ -14,37 +14,39 @@ */ #include "cloud_label_detector3.h" -#include "hilog/log.h" -#include "log_tags.h" +#include "image_log.h" #include "plugin_utils.h" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "CloudLabelDetector3" + namespace OHOS { namespace PluginExample { using std::string; -using namespace OHOS::HiviewDFX; - -static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "CloudLabelDetector3" }; const string CloudLabelDetector3::RESULT_STR = "CloudLabelDetector3"; CloudLabelDetector3::CloudLabelDetector3() { - HiLog::Debug(LABEL, "call CloudLabelDetector3()."); + IMAGE_LOGD("call CloudLabelDetector3()."); } CloudLabelDetector3::~CloudLabelDetector3() { - HiLog::Debug(LABEL, "call ~CloudLabelDetector3()."); + IMAGE_LOGD("call ~CloudLabelDetector3()."); } bool CloudLabelDetector3::Prepare() { - HiLog::Debug(LABEL, "call Prepare()."); + IMAGE_LOGD("call Prepare()."); return true; } string CloudLabelDetector3::Process() { - HiLog::Debug(LABEL, "call Process()."); + IMAGE_LOGD("call Process()."); return RESULT_STR; } } // namespace PluginExample diff --git a/plugins/manager/test/unittest/common/plugin_example/plugin_example3/label_detector3.cpp b/plugins/manager/test/unittest/common/plugin_example/plugin_example3/label_detector3.cpp index be201a687..71ca42448 100644 --- a/plugins/manager/test/unittest/common/plugin_example/plugin_example3/label_detector3.cpp +++ b/plugins/manager/test/unittest/common/plugin_example/plugin_example3/label_detector3.cpp @@ -14,37 +14,39 @@ */ #include "label_detector3.h" -#include "hilog/log.h" -#include "log_tags.h" +#include "image_log.h" #include "plugin_utils.h" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "LabelDetector3" + namespace OHOS { namespace PluginExample { using std::string; -using namespace OHOS::HiviewDFX; - -static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "LabelDetector3" }; const string LabelDetector3::RESULT_STR = "LabelDetector3"; LabelDetector3::LabelDetector3() { - HiLog::Debug(LABEL, "call LabelDetector3()."); + IMAGE_LOGD("call LabelDetector3()."); } LabelDetector3::~LabelDetector3() { - HiLog::Debug(LABEL, "call ~LabelDetector3()."); + IMAGE_LOGD("call ~LabelDetector3()."); } bool LabelDetector3::Prepare() { - HiLog::Debug(LABEL, "call Prepare()."); + IMAGE_LOGD("call Prepare()."); return true; } string LabelDetector3::Process() { - HiLog::Debug(LABEL, "call Process()."); + IMAGE_LOGD("call Process()."); return RESULT_STR; } } // namespace PluginExample diff --git a/plugins/manager/test/unittest/common/plugin_example/plugin_example3/plugin_export.cpp b/plugins/manager/test/unittest/common/plugin_example/plugin_example3/plugin_export.cpp index 922036264..26b2e99fb 100644 --- a/plugins/manager/test/unittest/common/plugin_example/plugin_example3/plugin_export.cpp +++ b/plugins/manager/test/unittest/common/plugin_example/plugin_example3/plugin_export.cpp @@ -14,12 +14,17 @@ */ #include "plugin_export.h" -#include "hilog/log.h" -#include "log_tags.h" +#include "image_log.h" #include "plugin_utils.h" #include "cloud_label_detector3.h" #include "label_detector3.h" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "plugin_example3" + // this file shows how to easily write the plugin_export.cpp file using the code elements provided by plugin_utils.h. // but sometimes you may need to write this file directly, see plugin_example1. namespace { @@ -33,32 +38,26 @@ PLUGIN_EXPORT_REGISTER_CLASS(OHOS::PluginExample::CloudLabelDetector3) PLUGIN_EXPORT_REGISTER_CLASS_END using std::string; -using namespace OHOS::HiviewDFX; - -static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "plugin_example3" }; - -#define PLUGIN_LOG_D(...) HiLog::Debug(LABEL, __VA_ARGS__) -#define PLUGIN_LOG_E(...) HiLog::Error(LABEL, __VA_ARGS__) // define the external interface of this plugin PLUGIN_EXPORT_DEFAULT_EXTERNAL_START() PLUGIN_EXPORT_DEFAULT_EXTERNAL_STOP() OHOS::MultimediaPlugin::PluginClassBase *PluginExternalCreate(const string &className) { - HiLog::Debug(LABEL, "PluginExternalCreate: create object for package: %{public}s, class: %{public}s.", - PACKAGE_NAME.c_str(), className.c_str()); + IMAGE_LOGD("PluginExternalCreate: create object for package: %{public}s, class: %{public}s.", + PACKAGE_NAME.c_str(), className.c_str()); auto iter = implClassMap.find(className); if (iter == implClassMap.end()) { - HiLog::Error(LABEL, "PluginExternalCreate: failed to find class: %{public}s, in package: %{public}s.", - className.c_str(), PACKAGE_NAME.c_str()); + IMAGE_LOGE("PluginExternalCreate: failed to find class: %{public}s, in package: %{public}s.", + className.c_str(), PACKAGE_NAME.c_str()); return nullptr; } auto creator = iter->second; if (creator == nullptr) { - HiLog::Error(LABEL, "PluginExternalCreate: null creator for class: %{public}s, in package: %{public}s.", - className.c_str(), PACKAGE_NAME.c_str()); + IMAGE_LOGE("PluginExternalCreate: null creator for class: %{public}s, in package: %{public}s.", + className.c_str(), PACKAGE_NAME.c_str()); return nullptr; } diff --git a/plugins/manager/test/unittest/common/plugin_manager_test.cpp b/plugins/manager/test/unittest/common/plugin_manager_test.cpp index 33ccd3c94..6563e2c78 100644 --- a/plugins/manager/test/unittest/common/plugin_manager_test.cpp +++ b/plugins/manager/test/unittest/common/plugin_manager_test.cpp @@ -16,22 +16,25 @@ #include #include #include "abs_image_detector.h" -#include "hilog/log.h" -#include "log_tags.h" +#include "image_log.h" #include "plugin_server.h" +#undef LOG_DOMAIN +#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_PLUGIN + +#undef LOG_TAG +#define LOG_TAG "PluginManagerTest" + using OHOS::DelayedRefSingleton; using std::string; + using std::vector; using namespace testing::ext; -using namespace OHOS::HiviewDFX; using namespace OHOS::MultimediaPlugin; using namespace OHOS::PluginExample; namespace OHOS { namespace Multimedia { -static constexpr HiLogLabel LABEL = { LOG_CORE, LOG_TAG_DOMAIN_ID_PLUGIN, "PluginManagerTest" }; - class PluginManagerTest : public testing::Test { public: static void SetUpTestCase(void); @@ -348,7 +351,7 @@ HWTEST_F(PluginManagerTest, TestCreateByService001, TestSize.Level3) HWTEST_F(PluginManagerTest, TestCreateByService002, TestSize.Level3) { AbsImageDetector *unknownDetector = nullptr; - HiLog::Debug(LABEL, "[PluginManager_TestCreateByService_002] Start."); + IMAGE_LOGD("[PluginManager_TestCreateByService_002] Start."); PluginServer &pluginServer = DelayedRefSingleton::GetInstance(); /** @@ -746,39 +749,39 @@ uint32_t PluginManagerTest::DoTestRegister003(PluginServer &pluginServer) string implClassName = "OHOS::PluginExample::CloudLabelDetector2"; AbsImageDetector *cLabelDetector2 = pluginServer.CreateObject(implClassName, errorCode); if (cLabelDetector2 == nullptr) { - HiLog::Error(LABEL, "[DoTestRegister003] cLabelDetector2 null. ERRNO: %{public}u.", errorCode); + IMAGE_LOGE("[DoTestRegister003] cLabelDetector2 null. ERRNO: %{public}u.", errorCode); goto TEST_END; } implClassName = "OHOS::PluginExample::LabelDetector3"; labelDetector3 = pluginServer.CreateObject(implClassName, errorCode); if (labelDetector3 == nullptr) { - HiLog::Error(LABEL, "[DoTestRegister003] labelDetector3 null. ERRNO: %{public}u.", errorCode); + IMAGE_LOGE("[DoTestRegister003] labelDetector3 null. ERRNO: %{public}u.", errorCode); goto TEST_END; } implClassName = "OHOS::PluginExample::CloudLabelDetector"; cLabelDetector = pluginServer.CreateObject(implClassName, errorCode); if (cLabelDetector == nullptr) { - HiLog::Error(LABEL, "[DoTestRegister003] cLabelDetector null. ERRNO: %{public}u.", errorCode); + IMAGE_LOGE("[DoTestRegister003] cLabelDetector null. ERRNO: %{public}u.", errorCode); goto TEST_END; } result = cLabelDetector2->Process(); if (result != "CloudLabelDetector2") { - HiLog::Error(LABEL, "[DoTestRegister003] result1 check fail, result: %{public}s.", result.c_str()); + IMAGE_LOGE("[DoTestRegister003] result1 check fail, result: %{public}s.", result.c_str()); goto TEST_END; } result = labelDetector3->Process(); if (result != "LabelDetector3") { - HiLog::Error(LABEL, "[DoTestRegister003] result2 check fail, result: %{public}s.", result.c_str()); + IMAGE_LOGE("[DoTestRegister003] result2 check fail, result: %{public}s.", result.c_str()); goto TEST_END; } result = cLabelDetector->Process(); if (result != "CloudLabelDetector") { - HiLog::Error(LABEL, "[DoTestRegister003] result3 check fail, result: %{public}s.", result.c_str()); + IMAGE_LOGE("[DoTestRegister003] result3 check fail, result: %{public}s.", result.c_str()); goto TEST_END; } testRet = SUCCESS; @@ -810,39 +813,39 @@ uint32_t PluginManagerTest::DoTestRegister004(PluginServer &pluginServer) string implClassName = "OHOS::PluginExample::CloudLabelDetector"; AbsImageDetector *cLabelDetector = pluginServer.CreateObject(implClassName, errorCode); if (cLabelDetector == nullptr) { - HiLog::Error(LABEL, "[DoTestRegister004] cLabelDetector null. ERRNO: %{public}u.", errorCode); + IMAGE_LOGE("[DoTestRegister004] cLabelDetector null. ERRNO: %{public}u.", errorCode); goto TEST_END; } implClassName = "OHOS::PluginExample::CloudLabelDetector2"; cLabelDetector2 = pluginServer.CreateObject(implClassName, errorCode); if (cLabelDetector2 == nullptr) { - HiLog::Error(LABEL, "[DoTestRegister004] cLabelDetector2 null. ERRNO: %{public}u.", errorCode); + IMAGE_LOGE("[DoTestRegister004] cLabelDetector2 null. ERRNO: %{public}u.", errorCode); goto TEST_END; } implClassName = "OHOS::PluginExample::LabelDetector3"; labelDetector3 = pluginServer.CreateObject(implClassName, errorCode); if (labelDetector3 == nullptr) { - HiLog::Error(LABEL, "[DoTestRegister004] labelDetector3 null. ERRNO: %{public}u.", errorCode); + IMAGE_LOGE("[DoTestRegister004] labelDetector3 null. ERRNO: %{public}u.", errorCode); goto TEST_END; } result = cLabelDetector->Process(); if (result != "CloudLabelDetector") { - HiLog::Error(LABEL, "[DoTestRegister004] result1 check fail, result: %{public}s.", result.c_str()); + IMAGE_LOGE("[DoTestRegister004] result1 check fail, result: %{public}s.", result.c_str()); goto TEST_END; } result = cLabelDetector2->Process(); if (result != "CloudLabelDetector2") { - HiLog::Error(LABEL, "[DoTestRegister004] result2 check fail, result: %{public}s.", result.c_str()); + IMAGE_LOGE("[DoTestRegister004] result2 check fail, result: %{public}s.", result.c_str()); goto TEST_END; } result = labelDetector3->Process(); if (result != "LabelDetector3") { - HiLog::Error(LABEL, "[DoTestRegister004] result3 check fail, result: %{public}s.", result.c_str()); + IMAGE_LOGE("[DoTestRegister004] result3 check fail, result: %{public}s.", result.c_str()); return ERR_GENERAL; } testRet = SUCCESS; @@ -874,32 +877,28 @@ uint32_t PluginManagerTest::DoTestInstanceLimit001(PluginServer &pluginServer) string implClassName = "OHOS::PluginExample::LabelDetector"; labelDetectorIns1 = pluginServer.CreateObject(implClassName, errorCode); if (labelDetectorIns1 == nullptr) { - HiLog::Error(LABEL, "[PluginManager_TestInstanceLimit_001] labelDetectorIns1 null. ERRNO: %{public}u.", - errorCode); + IMAGE_LOGE("[PluginManager_TestInstanceLimit_001] labelDetectorIns1 null. ERRNO: %{public}u.", errorCode); goto TEST_END; } implClassName = "OHOS::PluginExample::CloudLabelDetector"; cLabelDetectorIns1 = pluginServer.CreateObject(implClassName, errorCode); if (cLabelDetectorIns1 == nullptr) { - HiLog::Error(LABEL, "[PluginManager_TestInstanceLimit_001] cLabelDetectorIns1 null. ERRNO: %{public}u.", - errorCode); + IMAGE_LOGE("[PluginManager_TestInstanceLimit_001] cLabelDetectorIns1 null. ERRNO: %{public}u.", errorCode); goto TEST_END; } implClassName = "OHOS::PluginExample::LabelDetector"; labelDetectorIns2 = pluginServer.CreateObject(implClassName, errorCode); if (labelDetectorIns2 == nullptr) { - HiLog::Error(LABEL, "[PluginManager_TestInstanceLimit_001] labelDetectorIns2 null. ERRNO: %{public}u.", - errorCode); + IMAGE_LOGE("[PluginManager_TestInstanceLimit_001] labelDetectorIns2 null. ERRNO: %{public}u.", errorCode); goto TEST_END; } implClassName = "OHOS::PluginExample::CloudLabelDetector"; cLabelDetectorIns2 = pluginServer.CreateObject(implClassName, errorCode); if (cLabelDetectorIns2 == nullptr) { - HiLog::Error(LABEL, "[PluginManager_TestInstanceLimit_001] cLabelDetectorIns2 null. ERRNO: %{public}u.", - errorCode); + IMAGE_LOGE("[PluginManager_TestInstanceLimit_001] cLabelDetectorIns2 null. ERRNO: %{public}u.", errorCode); goto TEST_END; } testRet = SUCCESS; @@ -940,30 +939,30 @@ uint32_t PluginManagerTest::DoTestInstanceLimit003(PluginServer &pluginServer) AbsImageDetector *labelDetectorIns1 = pluginServer.CreateObject(AbsImageDetector::SERVICE_FACE, errorCode); if (labelDetectorIns1 == nullptr) { - HiLog::Error(LABEL, "[DoTestInstanceLimit003] labelDetectorIns1 null. ERRNO: %{public}u.", errorCode); + IMAGE_LOGE("[DoTestInstanceLimit003] labelDetectorIns1 null. ERRNO: %{public}u.", errorCode); goto TEST_END; } labelDetectorIns2 = pluginServer.CreateObject(AbsImageDetector::SERVICE_FACE, errorCode); if (labelDetectorIns1 == nullptr) { - HiLog::Error(LABEL, "[DoTestInstanceLimit003] labelDetectorIns2 null. ERRNO: %{public}u.", errorCode); + IMAGE_LOGE("[DoTestInstanceLimit003] labelDetectorIns2 null. ERRNO: %{public}u.", errorCode); goto TEST_END; } labelDetectorIns3 = pluginServer.CreateObject(AbsImageDetector::SERVICE_FACE, errorCode); if (labelDetectorIns1 == nullptr) { - HiLog::Error(LABEL, "[DoTestInstanceLimit003] labelDetectorIns3 null. ERRNO: %{public}u.", errorCode); + IMAGE_LOGE("[DoTestInstanceLimit003] labelDetectorIns3 null. ERRNO: %{public}u.", errorCode); goto TEST_END; } labelDetectorIns4 = pluginServer.CreateObject(AbsImageDetector::SERVICE_FACE, errorCode); if (labelDetectorIns4 != nullptr) { - HiLog::Error(LABEL, "[DoTestInstanceLimit003] labelDetectorIns4 not null. ERRNO: %{public}u.", errorCode); + IMAGE_LOGE("[DoTestInstanceLimit003] labelDetectorIns4 not null. ERRNO: %{public}u.", errorCode); goto TEST_END; } if (errorCode != ERR_INSTANCE_LIMIT) { - HiLog::Error(LABEL, "[DoTestInstanceLimit003] unexpected errorCode: %{public}u.", errorCode); + IMAGE_LOGE("[DoTestInstanceLimit003] unexpected errorCode: %{public}u.", errorCode); goto TEST_END; } @@ -977,7 +976,7 @@ uint32_t PluginManagerTest::DoTestInstanceLimit003(PluginServer &pluginServer) labelDetectorIns5 = pluginServer.CreateObject(AbsImageDetector::SERVICE_FACE, errorCode); if (labelDetectorIns1 == nullptr) { - HiLog::Error(LABEL, "[DoTestInstanceLimit003] labelDetectorIns5 null. ERRNO: %{public}u.", errorCode); + IMAGE_LOGE("[DoTestInstanceLimit003] labelDetectorIns5 null. ERRNO: %{public}u.", errorCode); goto TEST_END; } testRet = SUCCESS;