diff --git a/frameworks/innerkitsimpl/codec/src/image_source.cpp b/frameworks/innerkitsimpl/codec/src/image_source.cpp index 4c88fe492028851ac906d5db84e1cc5b8153effc..e21ec270486a8a0458c9c5489a4677d2578b4c09 100644 --- a/frameworks/innerkitsimpl/codec/src/image_source.cpp +++ b/frameworks/innerkitsimpl/codec/src/image_source.cpp @@ -1062,6 +1062,7 @@ unique_ptr ImageSource::CreatePixelMapExtended(uint32_t index, const D CHECK_ERROR_PRINT_LOG(convertRes != SUCCESS, "convert rgb to yuv failed, return origin rgb!"); } ImageUtils::FlushSurfaceBuffer(pixelMap.get()); + pixelMap->SetMemoryName(GetPixelMapName(pixelMap.get())); return pixelMap; } @@ -1465,6 +1466,7 @@ unique_ptr ImageSource::CreatePixelMap(uint32_t index, const DecodeOpt // not ext decode, dump pixelMap while decoding svg here ImageUtils::DumpPixelMapIfDumpEnabled(pixelMap, imageId_); + pixelMap->SetMemoryName(GetPixelMapName(pixelMap.get())); return pixelMap; } @@ -5300,5 +5302,19 @@ void ImageSource::RefreshImageSourceByPathName() } } +std::string ImageSource::GetPixelMapName(PixelMap* pixelMap) +{ + if (pixelMap == nullptr) { + IMAGE_LOGE("%{public}s error, pixelMap is null", __func__); + return "undefined_"; + } + std::string pixelMapStr = "w" + std::to_string(pixelMap->GetWidth()) + + "_h" + std::to_string(pixelMap->GetHeight()) + + "_streamSize" + std::to_string(sourceStreamPtr_->GetStreamSize()) + + "_mimeType" + sourceInfo_.encodedFormat; + IMAGE_LOGD("pixelMapStr is %{public}s", pixelMapStr.c_str()); + return pixelMapStr; +} + } // namespace Media } // namespace OHOS 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 cfe0b6baca6d870d20564a5c5c829c1128364e20..526c9528cab409440c5e045088ac2b8007751d1f 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 @@ -1727,6 +1727,8 @@ HWTEST_F(ImageSourceTest, End2EndTest001, TestSize.Level3) ASSERT_NE(pixelMap.get(), nullptr); ASSERT_EQ(desiredWidth, pixelMap->GetWidth()); ASSERT_EQ(desiredHeight, pixelMap->GetHeight()); + ASSERT_EQ("undefined_", imageSource->GetPixelMapName(nullptr)); + ASSERT_EQ("w400_h200_streamSize27897_mimeTypeimage/jpeg", imageSource->GetPixelMapName(pixelMap.get())); } /** diff --git a/interfaces/innerkits/include/image_source.h b/interfaces/innerkits/include/image_source.h index 43a7094e2b8b08419d6283716112d786cf908e9b..bcf81be0f7756312d2a14309589ecc0eab83e8fd 100644 --- a/interfaces/innerkits/include/image_source.h +++ b/interfaces/innerkits/include/image_source.h @@ -380,6 +380,7 @@ private: bool CheckCropRectValid(const DecodeOptions &opts); void InitDecoderForJpeg(); void RefreshImageSourceByPathName(); + std::string GetPixelMapName(PixelMap* pixelMap); #if !defined(IOS_PLATFORM) && !defined(ANDROID_PLATFORM) void SpecialSetComposeBuffer(ImagePlugin::DecodeContext &baseCtx, sptr& baseSptr,